UNPKG

@reactodia/workspace

Version:

Reactodia Workspace -- library for visual interaction with graphs in a form of a diagram.

158 lines (157 loc) 11.9 kB
import { jsx } from "react/jsx-runtime"; const classIcon = "data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCAyNiAyNiI+CiAgICA8dGV4dCB4PSIzIiB5PSIyMiIgY2xhc3M9InRleHQiIGZpbGw9IiNlYWFjNzciCiAgICAgICAgc3R5bGU9ImZvbnQtZmFtaWx5OiAnSGVsdmV0aWNhIE5ldWUnLCAnSGVsdmV0aWNhJywgJ0FyaWFsJywgc2Fucy1zZXJpZjsgZm9udC1zaXplOiAyNnB4OyBmb250LXdlaWdodDogYm9sZDsiPgogICAgICAgIEMKICAgIDwvdGV4dD4KPC9zdmc+Cg=="; const objectPropertyIcon = "data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCAyNiAyNiI+CiAgICA8dGV4dCB4PSIwIiB5PSIyMCIgY2xhc3M9InRleHQiIGZpbGw9IiMzNGM3ZjMiCiAgICAgICAgc3R5bGU9ImZvbnQtZmFtaWx5OiAnSGVsdmV0aWNhIE5ldWUnLCAnSGVsdmV0aWNhJywgJ0FyaWFsJywgc2Fucy1zZXJpZjsgZm9udC1zaXplOiAxOHB4OyBmb250LXdlaWdodDogYm9sZDsiPgogICAgICAgIE9QCiAgICA8L3RleHQ+Cjwvc3ZnPgo="; const datatypePropertyIcon = "data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCAyNiAyNiI+CiAgICA8dGV4dCB4PSIwIiB5PSIyMCIgY2xhc3M9InRleHQiIGZpbGw9IiMzNGM3ZjMiCiAgICAgICAgc3R5bGU9ImZvbnQtZmFtaWx5OiAnSGVsdmV0aWNhIE5ldWUnLCAnSGVsdmV0aWNhJywgJ0FyaWFsJywgc2Fucy1zZXJpZjsgZm9udC1zaXplOiAxOHB4OyBmb250LXdlaWdodDogYm9sZDsiPgogICAgICAgIERQCiAgICA8L3RleHQ+Cjwvc3ZnPgo="; const personIcon = "data:image/svg+xml,%3csvg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20x='0px'%20y='0px'%20viewBox='0%200%20350%20350'%3e%3cpath%20fill='%23eb7777'%20d='M175,171.173c38.914,0,70.463-38.318,70.463-85.586C245.463,38.318,235.105,0,175,0s-70.465,38.318-70.465,85.587%20C104.535,132.855,136.084,171.173,175,171.173z'/%3e%3cpath%20fill='%23eb7777'%20d='M41.909,301.853C41.897,298.971,41.885,301.041,41.909,301.853L41.909,301.853z'/%3e%3cpath%20fill='%23eb7777'%20d='M308.085,304.104C308.123,303.315,308.098,298.63,308.085,304.104L308.085,304.104z'/%3e%3cpath%20fill='%23eb7777'%20d='M307.935,298.397c-1.305-82.342-12.059-105.805-94.352-120.657c0,0-11.584,14.761-38.584,14.761%20s-38.586-14.761-38.586-14.761c-81.395,14.69-92.803,37.805-94.303,117.982c-0.123,6.547-0.18,6.891-0.202,6.131%20c0.005,1.424,0.011,4.058,0.011,8.651c0,0,19.592,39.496,133.08,39.496c113.486,0,133.08-39.496,133.08-39.496%20c0-2.951,0.002-5.003,0.005-6.399C308.062,304.575,308.018,303.664,307.935,298.397z'/%3e%3c/svg%3e"; const countryIcon = "data:image/svg+xml,%3csvg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20x='0px'%20y='0px'%20viewBox='0%200%20512%20512'%3e%3cpath%20fill='%2377ca98'%20d='M472.928,34.752c-4.416-3.008-10.016-3.552-14.944-1.6c-1.024,0.416-106.88,42.048-195.168,0.384%20C186.72-2.432,102.912,14.4,64,25.76V16c0-8.832-7.168-16-16-16c-8.832,0-16,7.168-16,16v32v256v192c0,8.832,7.168,16,16,16%20c8.832,0,16-7.168,16-16V315.328c28.384-9.184,112.608-31.136,185.184,3.136c34.592,16.352,70.784,21.792,103.648,21.792%20c63.2,0,114.016-20.128,117.184-21.408c6.016-2.464,9.984-8.32,9.984-14.848V48C480,42.688,477.344,37.728,472.928,34.752z'/%3e%3c/svg%3e"; const organizationIcon = "data:image/svg+xml,%3csvg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20x='0px'%20y='0px'%20viewBox='0%200%20512%20512'%3e%3cpath%20fill='%2377ca98'%20d='M155,0H15C6.716,0,0,6.716,0,15v35h170V15C170,6.716,163.284,0,155,0z'/%3e%3cpath%20fill='%2377ca98'%20d='M504.464,142.989c-4.662-2.674-10.397-2.651-15.036,0.063L341,229.852V156c0-5.374-2.875-10.337-7.536-13.011%20c-4.662-2.674-10.397-2.651-15.036,0.063L170,229.852V80H0v417c0,8.284,6.716,15,15,15h482c8.284,0,15-6.716,15-15V156%20C512,150.626,509.125,145.663,504.464,142.989z%20M230,406.5c0,8.284-6.716,15-15,15h-60c-8.284,0-15-6.716-15-15v-60%20c0-8.284,6.716-15,15-15h60c8.284,0,15,6.716,15,15V406.5z%20M401,406.5c0,8.284-6.716,15-15,15h-60c-8.284,0-15-6.716-15-15v-60%20c0-8.284,6.716-15,15-15h60c8.284,0,15,6.716,15,15V406.5z'/%3e%3c/svg%3e"; const locationIcon = "data:image/svg+xml,%3csvg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20x='0px'%20y='0px'%20width='47.825px'%20height='47.825px'%20viewBox='0%200%2047.825%2047.825'%3e%3cpath%20fill='%23bebc71'%20d='M36.439,12.646c0-6.919-5.608-12.527-12.528-12.527S11.384,5.727,11.384,12.646c0,9.913,12.527,24.582,12.527,24.582%20S36.439,22.508,36.439,12.646z%20M17.733,11.898c0-3.413,2.767-6.179,6.179-6.179s6.179,2.766,6.179,6.179%20c0,3.413-2.767,6.179-6.179,6.179S17.733,15.311,17.733,11.898z'/%3e%3ccircle%20fill='%23bebc71'%20cx='23.911'%20cy='11.898'%20r='3.038'/%3e%3cpath%20fill='%23bebc71'%20d='M30.994,32.87c-1.021,1.476-1.979,2.761-2.777,3.793c7.916,0.476,13.104,2.185,15.034,3.456%20c-2.261,1.491-8.979,3.587-19.338,3.587c-10.358,0-17.077-2.097-19.338-3.587c1.93-1.271,7.114-2.979,15.022-3.455%20c-0.8-1.032-1.759-2.316-2.781-3.792C7.075,33.831,0,36.713,0,40.118c0,4.19,10.707,7.588,23.913,7.588%20c13.207,0,23.912-3.396,23.912-7.588C47.827,36.711,40.744,33.828,30.994,32.87z'/%3e%3c/svg%3e"; const eventIcon = "data:image/svg+xml,%3csvg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20x='0px'%20y='0px'%20width='97.473px'%20height='97.473px'%20viewBox='0%200%2097.473%2097.473'%3e%3crect%20fill='%23b4b1fb'%20x='41.569'%20y='47.753'%20width='14.333'%20height='14.333'/%3e%3crect%20fill='%23b4b1fb'%20x='41.569'%20y='67.754'%20width='14.333'%20height='14.332'/%3e%3crect%20fill='%23b4b1fb'%20x='18.569'%20y='67.754'%20width='14.333'%20height='14.332'/%3e%3crect%20fill='%23b4b1fb'%20x='18.569'%20y='47.753'%20width='14.333'%20height='14.333'/%3e%3cpath%20fill='%23b4b1fb'%20d='M95.472,14.466H84.427V2.701c0-1.104-0.896-2-2-2H65.811c-1.104,0-2,0.896-2,2v11.765H33.662V2.701c0-1.104-0.896-2-2-2%20H15.045c-1.104,0-2,0.896-2,2v11.765H2c-1.104,0-2,0.896-2,2v78.305c0,1.104,0.896,2,2,2h93.473c1.104,0,2-0.896,2-2V16.466%20C97.472,15.362,96.576,14.466,95.472,14.466z%20M69.645,8.037c0-0.828,0.672-1.5,1.5-1.5h5.947c0.829,0,1.5,0.672,1.5,1.5v20.34%20c0,0.828-0.671,1.5-1.5,1.5h-5.947c-0.828,0-1.5-0.672-1.5-1.5V8.037z%20M18.88,8.037c0-0.828,0.671-1.5,1.5-1.5h5.947%20c0.829,0,1.5,0.672,1.5,1.5v20.34c0,0.828-0.671,1.5-1.5,1.5H20.38c-0.829,0-1.5-0.672-1.5-1.5V8.037z%20M87.068,84.902%20c0,0.828-0.67,1.5-1.5,1.5H11.903c-0.829,0-1.5-0.672-1.5-1.5v-40c0-0.828,0.671-1.5,1.5-1.5h73.666c0.83,0,1.5,0.672,1.5,1.5%20V84.902z'/%3e%3crect%20fill='%23b4b1fb'%20x='64.568'%20y='47.753'%20width='14.334'%20height='14.333'/%3e%3crect%20fill='%23b4b1fb'%20x='64.568'%20y='67.754'%20width='14.334'%20height='14.332'/%3e%3c/svg%3e"; const objectIcon = "data:image/svg+xml,%3csvg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20x='0px'%20y='0px'%20width='50px'%20height='50px'%20viewBox='0%200%2050%2050'%3e%3cpath%20fill='%2353ccb2'%20d='M26.12,14.488c0.879-1.468,2.27-3.569,4.027-5.585h0.002c1.488-1.711,4.402-3.907,4.402-3.907%20c0.438-0.331,0.391-0.792-0.107-1.024l-3.522-1.646c-0.498-0.233-1.175-0.063-1.505,0.376c0,0-2.605,3.737-5.671,11.692%20c-9.48-4.288-18.491,1.718-18.491,12.162c0,10.909,8.393,27.48,19.743,22.478c11.954,5.173,19.749-11.568,19.749-22.478%20C44.747,16.022,36.647,9.846,26.12,14.488z'/%3e%3cpath%20fill='%2353ccb2'%20d='M23.997,10.955c0.548-0.046,1.032-0.531,1.076-1.078c0,0,0.352-4.266-2.621-7.242c-2.982-2.977-7.24-2.622-7.24-2.622%20c-0.548,0.046-1.032,0.531-1.077,1.078c0,0-0.358,4.268,2.619,7.245C19.729,11.31,23.997,10.955,23.997,10.955z'/%3e%3c/svg%3e"; const SemanticTypeStyles = (types) => { if (types.indexOf("http://www.w3.org/2002/07/owl#Class") !== -1 || types.indexOf("http://www.w3.org/2000/01/rdf-schema#Class") !== -1) { return { color: "#eaac77", icon: classIcon }; } else if (types.indexOf("http://www.w3.org/2002/07/owl#ObjectProperty") !== -1) { return { color: "#34c7f3", icon: objectPropertyIcon }; } else if (types.indexOf("http://www.w3.org/2002/07/owl#DatatypeProperty") !== -1) { return { color: "#34c7f3", icon: datatypePropertyIcon }; } else if (types.indexOf("http://xmlns.com/foaf/0.1/Person") !== -1 || types.indexOf("http://www.wikidata.org/entity/Q5") !== -1) { return { color: "#eb7777", icon: personIcon }; } else if (types.indexOf("http://www.wikidata.org/entity/Q6256") !== -1) { return { color: "#77ca98", icon: countryIcon }; } else if (types.indexOf("http://schema.org/Organization") !== -1 || types.indexOf("http://dbpedia.org/ontology/Organisation") !== -1 || types.indexOf("http://xmlns.com/foaf/0.1/Organization") !== -1 || types.indexOf("http://www.wikidata.org/entity/Q43229") !== -1) { return { color: "#77ca98", icon: organizationIcon }; } else if (types.indexOf("http://www.wikidata.org/entity/Q618123") !== -1) { return { color: "#bebc71", icon: locationIcon }; } else if (types.indexOf("http://www.wikidata.org/entity/Q1190554") !== -1) { return { color: "#b4b1fb", icon: eventIcon }; } else if (types.indexOf("http://www.wikidata.org/entity/Q488383") !== -1) { return { color: "#53ccb2", icon: objectIcon }; } else { return void 0; } }; function makeLinkStyleShowIri(Reactodia) { return { ...Reactodia.StandardLinkTemplate, renderLink: (props) => /* @__PURE__ */ jsx( Reactodia.StandardRelation, { ...props, prependLabels: /* @__PURE__ */ jsx( Reactodia.LinkLabel, { link: props.link, position: props.getPathPosition(0.5), line: 1, style: { color: "gray", fontSize: 12, fontWeight: "lighter" }, children: props.link.typeId } ), propertyLabelStartLine: 2 } ) }; } function makeOntologyLinkTemplates(Reactodia) { const LINK_SUB_CLASS_OF = { ...Reactodia.StandardLinkTemplate, markerTarget: { ...Reactodia.StandardLinkTemplate.markerTarget, fill: "#f8a485", stroke: "#cf8e76" }, renderLink: (props) => /* @__PURE__ */ jsx( Reactodia.StandardRelation, { ...props, pathProps: { stroke: "#f8a485" } } ) }; const LINK_DOMAIN = { ...Reactodia.StandardLinkTemplate, markerTarget: { ...Reactodia.StandardLinkTemplate.markerTarget, fill: "#34c7f3", stroke: "#38b5db" }, renderLink: (props) => /* @__PURE__ */ jsx( Reactodia.StandardRelation, { ...props, pathProps: { stroke: "#34c7f3" } } ) }; const LINK_RANGE = { ...Reactodia.StandardLinkTemplate, markerTarget: { ...Reactodia.StandardLinkTemplate.markerTarget, fill: "#34c7f3", stroke: "#38b5db" }, renderLink: (props) => /* @__PURE__ */ jsx( Reactodia.StandardRelation, { ...props, pathProps: { stroke: "#34c7f3" } } ) }; const LINK_TYPE_OF = { ...Reactodia.StandardLinkTemplate, markerTarget: { ...Reactodia.StandardLinkTemplate.markerTarget, fill: "#8cd965", stroke: "#5b9a3b" }, renderLink: (props) => /* @__PURE__ */ jsx( Reactodia.StandardRelation, { ...props, pathProps: { stroke: "#8cd965" } } ) }; const LINK_PLACEHOLDER = { ...Reactodia.StandardLinkTemplate, markerTarget: { ...Reactodia.StandardLinkTemplate.markerTarget, fill: "none" } }; return (type) => { if (type === "http://www.w3.org/2000/01/rdf-schema#subClassOf") { return LINK_SUB_CLASS_OF; } else if (type === "http://www.w3.org/2000/01/rdf-schema#domain") { return LINK_DOMAIN; } else if (type === "http://www.w3.org/2000/01/rdf-schema#range") { return LINK_RANGE; } else if (type === "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") { return LINK_TYPE_OF; } else if (type === Reactodia.PlaceholderRelationType) { return LINK_PLACEHOLDER; } else { return void 0; } }; } export { SemanticTypeStyles, makeLinkStyleShowIri, makeOntologyLinkTemplates }; //# sourceMappingURL=legacy-styles.js.map