How to use the link-lib.normalizeType 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 / hocs / link.ts View on Github external
label: [predObj],
                    limit: opts.limit || globalLinkOptsDefaults.limit,
                    name: propKey || term(predObj),
                };
            } else {
                if (predObj.label === undefined) {
                    throw new TypeError("Inner opts label must be a single NamedNode");
                }
                const labelArr = Array.isArray(predObj.label) ? predObj.label : [predObj.label];

                labelArr.forEach((label) => {
                    requestedProperties.push(label.sI);
                });
                propMap[propKey || predObj.name || term(labelArr[0])] = {
                    forceRender: predObj.forceRender || opts.forceRender || globalLinkOptsDefaults.forceRender,
                    label: normalizeType(predObj.label),
                    limit: predObj.limit || opts.limit || globalLinkOptsDefaults.limit,
                    linkedProp: predObj.linkedProp || opts.linkedProp || globalLinkOptsDefaults.linkedProp,
                    name: propKey || predObj.name || term(labelArr[0]),
                    returnType: predObj.returnType || opts.returnType || globalLinkOptsDefaults.returnType,
                } as ProcessedLinkOpts;
            }
        }
    }

    return [ propMap, requestedProperties ];
}
github fletcher91 / link-redux / src / components / Property.tsx View on Github external
const lrs = useLRS();
    const [error, setError] = React.useState(undefined);
    const context = useLinkRenderContext();
    const subjectData = lrs.tryEntity(context.subject);

    const childProps = useCalculateChildProps(props, context, options);
    try {
        useDataInvalidation(childProps);
    } catch (e) {
        setError(e);
    }
    if (subjectData.length === 0) {
        return null;
    }
    const labels = normalizeType(childProps.label);
    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"),