How to use the link-lib.defaultNS.rdf function in link-lib

To help you get started, we’ve selected a few link-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fletcher91 / link-redux / src / components / __tests__ / LinkedResourceContainer.spec.ts View on Github external
it("renders blank nodes", () => {
        const bn = new BlankNode();
        const opts = ctx.chargeLRS(
            [
                new Statement(bn, defaultNS.rdf("type"), defaultNS.schema("Thing")),
                new Statement(bn, defaultNS.schema("name"), new Literal("title")),
            ],
            bn,
        );

        const comp = createTestElement();
        opts.lrs.registerAll(LinkedRenderStore.registerRenderer(comp, defaultNS.schema("Thing")));
        const elem = mount(
            opts.wrapComponent(createElement(LinkedResourceContainer, {
                loadLinkedObject,
                subject: bn,
            })),
        );

        expect(elem.find("span.testComponent")).toExist();
    });
github fletcher91 / link-redux / src / components / __tests__ / Property.spec.ts View on Github external
it("renders the children and association renderer when data is not present with forceRender and children", () => {
        const opts = ctx.fullCW();
        opts.lrs.registerAll(LinkedRenderStore.registerRenderer(
            ({ children }) => React.createElement("div", { className: "association" }, children),
            defaultNS.schema("CreativeWork"),
            defaultNS.rdf("predicate"),
        ));
        const elem = mount(opts.wrapComponent(React.createElement(
            Property,
            {
                children: React.createElement("span", { className: "child-elem" }),
                forceRender: true,
                label: defaultNS.ex("nonexistent"),
                subject,
                ...opts.contextProps(),
            },
        )));
        expect(elem).toContainMatchingElement(".association");
        expect(elem).toContainMatchingElement(".child-elem");
    });
github fletcher91 / link-redux / test / fixtures.ts View on Github external
const typeObject = (id: NamedNode) => [
    new Statement(id, NS.rdf("type"), NS.schema("CreativeWork")),
];
github fletcher91 / link-redux / test / fixtures.js View on Github external
const typeObject = id => [
  new rdf.Statement(exNS(id), defaultNS.rdf('type'), schema('CreativeWork')),
];
github fletcher91 / link-redux / src / components / Property.tsx View on Github external
const objRaw = subjectData
        .filter((s) => labels.includes(s.predicate))
        .map((s) => s.object);

    if (error) {
        return renderError(childProps, lrs, error);
    }

    if (objRaw.length === 0 && !childProps.forceRender) {
        return null;
    }

    const associationRenderer = getLinkedObjectClass(
        childProps,
        lrs,
        defaultNS.rdf("predicate"),
    ) || React.Fragment;
    const associationProps = associationRenderer !== React.Fragment ? childProps : null;
    const childComp = typeof childProps.children === "function" ? childProps.children(objRaw) : childProps.children;
    if (typeof childProps.children === "function") {
        return React.createElement(associationRenderer, associationProps, childComp);
    }

    const component = getLinkedObjectClass(childProps, lrs);
    if (component) {
        const toRender = limitTimes(
            childProps,
            objRaw,
            lrs,
            (p) => React.createElement(component, { ...childProps, linkedProp: p }, childComp),
            associationRenderer,
        );