How to use the link-lib.defaultNS.rdfs 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__ / Property.spec.ts View on Github external
it("renders the literal renderer", () => {
        const opts = ctx.fullCW();
        opts.lrs.registerAll(LinkedRenderStore.registerRenderer(
            ({ linkedProp }) => React.createElement(
                "div",
                { className: "integerRenderer", children: linkedProp.value },
            ),
            defaultNS.rdfs("Literal"),
            defaultNS.xsd("integer"),
        ));

        const comp = React.createElement(
            Property,
            { label: defaultNS.ex("timesRead"), ...opts.contextProps() },
        );
        const elem = mount(opts.wrapComponent(comp));

        expect(elem).toContainMatchingElement(".integerRenderer");
        expect(elem.find(".integerRenderer")).toHaveText("5");
    });
github fletcher91 / link-redux / src / hocs / __tests__ / link.spec.ts View on Github external
it("passes object with custom options", () => {
            const opts = ctx.fullCW(iri);

            const comp = link({
                author: defaultNS.schema("author"),
                name: [defaultNS.schema("name"), defaultNS.rdfs("label")],
                tags: {
                    label: defaultNS.example("tags"),
                    limit: Infinity,
                },
                text: defaultNS.schema("text"),
            })(TestComponent);
            opts.lrs.registerAll(LinkedRenderStore.registerRenderer(comp, defaultNS.schema("Thing")));

            const elem = mount(opts.wrapComponent());

            expect(elem.find(TestComponent)).toHaveLength(1);
            expect(elem.find(TestComponent)).not.toHaveProp("label");
            expect(elem.find(TestComponent)).toHaveProp("name", new Literal("title"));
            expect(elem.find(TestComponent)).toHaveProp("text", new Literal("text"));
            expect(elem.find(TestComponent)).toHaveProp("author", new NamedNode("http://example.org/people/0"));
            expect(elem.find(TestComponent)).toHaveProp("tags", [
github fletcher91 / link-redux / src / components / Property.tsx View on Github external
return function(p: SomeTerm): React.ReactNode {
        if (props.children || p.termType !== "Literal") {
            return React.createElement(React.Fragment, null, props.children || p.value);
        }

        const { topology, topologyCtx, subjectCtx } = props;
        const literalRenderer = lrs.getComponentForProperty(
            defaultNS.rdfs("Literal"),
            NamedNode.find(p.datatype.value),
            topology === null ? undefined : topology || topologyCtx,
        );

        if (!literalRenderer) {
            return React.createElement(React.Fragment, null, p.value);
        }

        return React.createElement(
            literalRenderer,
            {
                linkedProp: p,
                subject: p.datatype,
                subjectCtx,
                topology,
                topologyCtx,