@ulb-darmstadt/shacl-form 1.10.4 → 2.0.0-rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/bundle.d.ts +3 -0
  2. package/dist/bundle.js +415 -0
  3. package/dist/constants.d.ts +16 -16
  4. package/dist/constraints.d.ts +2 -2
  5. package/dist/form.d.ts +4 -3
  6. package/dist/index.js +62 -0
  7. package/dist/plugins/assets/plugin-VN3CfgGe.js +1 -0
  8. package/dist/plugins/file-upload.js +1 -0
  9. package/dist/plugins/leaflet.d.ts +8 -2
  10. package/dist/plugins/leaflet.js +5 -708
  11. package/dist/{themes/default.d.ts → theme.default.d.ts} +2 -2
  12. package/package.json +20 -26
  13. package/dist/form-bootstrap.d.ts +0 -5
  14. package/dist/form-bootstrap.js +0 -413
  15. package/dist/form-default.d.ts +0 -5
  16. package/dist/form-default.js +0 -402
  17. package/dist/form-material.d.ts +0 -5
  18. package/dist/form-material.js +0 -722
  19. package/dist/plugins/fixed-list.d.ts +0 -9
  20. package/dist/plugins/map-util.d.ts +0 -5
  21. package/dist/plugins/mapbox.d.ts +0 -19
  22. package/dist/plugins/mapbox.js +0 -2904
  23. package/dist/themes/bootstrap.d.ts +0 -10
  24. package/dist/themes/material.d.ts +0 -15
  25. package/src/config.ts +0 -110
  26. package/src/constants.ts +0 -30
  27. package/src/constraints.ts +0 -149
  28. package/src/exports.ts +0 -7
  29. package/src/form-bootstrap.ts +0 -12
  30. package/src/form-default.ts +0 -12
  31. package/src/form-material.ts +0 -12
  32. package/src/form.ts +0 -319
  33. package/src/globals.d.ts +0 -2
  34. package/src/group.ts +0 -34
  35. package/src/loader.ts +0 -187
  36. package/src/node.ts +0 -192
  37. package/src/plugin.ts +0 -60
  38. package/src/plugins/file-upload.ts +0 -26
  39. package/src/plugins/fixed-list.ts +0 -19
  40. package/src/plugins/leaflet.ts +0 -196
  41. package/src/plugins/map-util.ts +0 -41
  42. package/src/plugins/mapbox.ts +0 -157
  43. package/src/property-template.ts +0 -151
  44. package/src/property.ts +0 -309
  45. package/src/serialize.ts +0 -96
  46. package/src/shacl-engine.d.ts +0 -2
  47. package/src/styles.css +0 -49
  48. package/src/theme.ts +0 -132
  49. package/src/themes/bootstrap.css +0 -6
  50. package/src/themes/bootstrap.ts +0 -44
  51. package/src/themes/default.css +0 -4
  52. package/src/themes/default.ts +0 -258
  53. package/src/themes/material.css +0 -14
  54. package/src/themes/material.ts +0 -253
  55. package/src/util.ts +0 -275
@@ -8,19 +8,19 @@ export declare const PREFIX_OWL = "http://www.w3.org/2002/07/owl#";
8
8
  export declare const PREFIX_OA = "http://www.w3.org/ns/oa#";
9
9
  export declare const PREFIX_DCTERMS = "http://purl.org/dc/terms/";
10
10
  export declare const PREFIX_FOAF = "http://xmlns.com/foaf/0.1/";
11
- export declare const SHAPES_GRAPH: import('n3').NamedNode<"loaded-shapes">;
12
- export declare const DATA_GRAPH: import('n3').NamedNode<"loaded-data">;
13
- export declare const RDF_PREDICATE_TYPE: import('n3').NamedNode<string>;
14
- export declare const DCTERMS_PREDICATE_CONFORMS_TO: import('n3').NamedNode<string>;
15
- export declare const RDFS_PREDICATE_SUBCLASS_OF: import('n3').NamedNode<string>;
16
- export declare const OWL_PREDICATE_IMPORTS: import('n3').NamedNode<string>;
17
- export declare const SKOS_PREDICATE_BROADER: import('n3').NamedNode<string>;
18
- export declare const SKOS_PREDICATE_NARROWER: import('n3').NamedNode<string>;
19
- export declare const SHACL_OBJECT_NODE_SHAPE: import('n3').NamedNode<string>;
20
- export declare const SHACL_OBJECT_IRI: import('n3').NamedNode<string>;
21
- export declare const SHACL_PREDICATE_PROPERTY: import('n3').NamedNode<string>;
22
- export declare const SHACL_PREDICATE_CLASS: import('n3').NamedNode<string>;
23
- export declare const SHACL_PREDICATE_NODE: import('n3').NamedNode<string>;
24
- export declare const SHACL_PREDICATE_TARGET_CLASS: import('n3').NamedNode<string>;
25
- export declare const SHACL_PREDICATE_NODE_KIND: import('n3').NamedNode<string>;
26
- export declare const XSD_DATATYPE_STRING: import('n3').NamedNode<string>;
11
+ export declare const SHAPES_GRAPH: import("n3").NamedNode<"loaded-shapes">;
12
+ export declare const DATA_GRAPH: import("n3").NamedNode<"loaded-data">;
13
+ export declare const RDF_PREDICATE_TYPE: import("n3").NamedNode<string>;
14
+ export declare const DCTERMS_PREDICATE_CONFORMS_TO: import("n3").NamedNode<string>;
15
+ export declare const RDFS_PREDICATE_SUBCLASS_OF: import("n3").NamedNode<string>;
16
+ export declare const OWL_PREDICATE_IMPORTS: import("n3").NamedNode<string>;
17
+ export declare const SKOS_PREDICATE_BROADER: import("n3").NamedNode<string>;
18
+ export declare const SKOS_PREDICATE_NARROWER: import("n3").NamedNode<string>;
19
+ export declare const SHACL_OBJECT_NODE_SHAPE: import("n3").NamedNode<string>;
20
+ export declare const SHACL_OBJECT_IRI: import("n3").NamedNode<string>;
21
+ export declare const SHACL_PREDICATE_PROPERTY: import("n3").NamedNode<string>;
22
+ export declare const SHACL_PREDICATE_CLASS: import("n3").NamedNode<string>;
23
+ export declare const SHACL_PREDICATE_NODE: import("n3").NamedNode<string>;
24
+ export declare const SHACL_PREDICATE_TARGET_CLASS: import("n3").NamedNode<string>;
25
+ export declare const SHACL_PREDICATE_NODE_KIND: import("n3").NamedNode<string>;
26
+ export declare const XSD_DATATYPE_STRING: import("n3").NamedNode<string>;
@@ -1,7 +1,7 @@
1
1
  import { Quad } from 'n3';
2
2
  import { Term } from '@rdfjs/types';
3
- import { ShaclNode } from './node';
4
- import { ShaclProperty } from './property';
3
+ import { ShaclNode } from "./node";
4
+ import { ShaclProperty } from "./property";
5
5
  import { Config } from './config';
6
6
  export declare function createShaclOrConstraint(options: Term[], context: ShaclNode | ShaclProperty, config: Config): HTMLElement;
7
7
  export declare function resolveShaclOrConstraintOnProperty(subjects: Term[], value: Term, config: Config): Quad[];
package/dist/form.d.ts CHANGED
@@ -3,18 +3,19 @@ import { Config } from './config';
3
3
  import { ClassInstanceProvider, Plugin } from './plugin';
4
4
  import { Store, Quad } from 'n3';
5
5
  import { Theme } from './theme';
6
+ export * from './exports';
6
7
  export declare class ShaclForm extends HTMLElement {
7
8
  static get observedAttributes(): string[];
8
9
  config: Config;
9
10
  shape: ShaclNode | null;
10
11
  form: HTMLFormElement;
11
12
  initDebounceTimeout: ReturnType<typeof setTimeout> | undefined;
12
- constructor(theme: Theme);
13
+ constructor();
13
14
  connectedCallback(): void;
14
15
  attributeChangedCallback(): void;
15
16
  private initialize;
16
- serialize(format?: string, graph?: Store<import('@rdfjs/types').Quad, Quad, import('@rdfjs/types').Quad, import('@rdfjs/types').Quad>): string;
17
- toRDF(graph?: Store<import('@rdfjs/types').Quad, Quad, import('@rdfjs/types').Quad, import('@rdfjs/types').Quad>): Store;
17
+ serialize(format?: string, graph?: Store<import("@rdfjs/types").Quad, Quad, import("@rdfjs/types").Quad, import("@rdfjs/types").Quad>): string;
18
+ toRDF(graph?: Store<import("@rdfjs/types").Quad, Quad, import("@rdfjs/types").Quad, import("@rdfjs/types").Quad>): Store;
18
19
  registerPlugin(plugin: Plugin): void;
19
20
  setTheme(theme: Theme): void;
20
21
  setClassInstanceProvider(provider: ClassInstanceProvider): void;
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ import{DataFactory as f,Literal as C,NamedNode as N,Writer as ue,Store as H,StreamParser as he,Quad as ae}from"n3";import{RokitCollapsible as k,RokitSelect as oe,RokitButton as fe,RokitInput as q,RokitTextArea as pe}from"@ro-kit/ui-widgets";import{v4 as Z}from"uuid";import{RdfXmlParser as ge}from"rdfxml-streaming-parser";import{toRDF as me}from"jsonld";import{Validator as be}from"shacl-engine";const h="http://www.w3.org/ns/shacl#",ee="http://datashapes.org/dash#",x="http://www.w3.org/2001/XMLSchema#",E="http://www.w3.org/1999/02/22-rdf-syntax-ns#",X="http://www.w3.org/2000/01/rdf-schema#",W="http://www.w3.org/2004/02/skos/core#",ve="http://www.w3.org/2002/07/owl#",ye="http://www.w3.org/ns/oa#",we="http://purl.org/dc/terms/",Ee="http://xmlns.com/foaf/0.1/",L=f.namedNode("loaded-shapes"),w=f.namedNode("loaded-data"),m=f.namedNode(E+"type"),B=f.namedNode(we+"conformsTo"),te=f.namedNode(X+"subClassOf"),z=f.namedNode(ve+"imports"),xe=f.namedNode(W+"broader"),Se=f.namedNode(W+"narrower"),A=f.namedNode(h+"NodeShape"),Ce=f.namedNode(h+"IRI"),F=f.namedNode(h+"property"),K=f.namedNode(h+"class"),Ie=f.namedNode(h+"node"),I=f.namedNode(h+"targetClass"),Le=f.namedNode(h+"nodeKind");f.namedNode(x+"string");function j(s,e,t=h,n){let i="";const a=je(s,e,t,n);return a&&(i=a.value),i}function je(s,e,t=h,n){let i;const a=t+e;if(n?.length){for(const o of n)for(const l of s)if(l.predicate.value===a){if(l.object.id.endsWith(`@${o}`))return l.object;l.object.id.indexOf("@")<0?i=l.object:i||(i=l.object)}}else for(const o of s)if(o.predicate.value===a)return o.object;return i}function Re(s){s.querySelector(".editor")?.focus()}function D(s,e){return j(s,"prefLabel",W,e)||j(s,"label",X,e)||j(s,"name",Ee,e)}function le(s,e,t){const n=[];for(const i of s)n.push({value:i,label:D(e.getQuads(i,null,null,null),t),children:[]});return n}function U(s,e){for(const t in e)s=s.replace(e[t],"");return s}function re(s,e,t,n,i=new Set){for(const a of e.owlImports)i.has(a.id)||(i.add(a.id),n.push(...t.getSubjects(m,s,a)));e.parent&&re(s,e.parent,t,n,i)}function J(s,e){if(e.shaclIn){const t=e.config.lists[e.shaclIn];return le(t?.length?t:[],e.config.store,e.config.languages)}else{const t=e.config.store.getSubjects(m,s,L);t.push(...e.config.store.getSubjects(m,s,w)),re(s,e,e.config.store,t);const n=new Map,i=new Map;for(const o of t)n.set(o.id,{value:o,label:D(e.config.store.getQuads(o,null,null,null),e.config.languages),children:[]});for(const o of t){for(const l of e.config.store.getObjects(o,xe,null))n.has(l.id)&&i.set(o.id,l.id);for(const l of e.config.store.getObjects(o,Se,null))n.has(l.id)&&i.set(l.id,o.id);for(const l of e.config.store.getObjects(o,te,null))n.has(l.id)&&i.set(o.id,l.id)}for(const[o,l]of i.entries())n.get(l)?.children?.push(n.get(o));const a=[];for(const[o,l]of n.entries())i.has(o)||a.push(l);for(const o of e.config.store.getSubjects(te,s,null))a.push(...J(o,e));return a}}function G(s){let e;try{e=new URL(s)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}function se(s,e,t){if(e===void 0)return t;if(t===void 0)return e;const n=s.indexOf(e.language);if(n<0)return t;const i=s.indexOf(t.language);return i<0||i>n?e:t}function De(s,{remove:e=!1,ignoreErrors:t=!1}={}){const n={},i=t?(()=>!0):((l,c)=>{throw new Error(`${l.value} ${c}`)}),a=s.getQuads(null,E+"rest",E+"nil",null),o=e?[...a]:[];return a.forEach(l=>{const c=[];let d=!1,r,u;const g=l.graph;let p=l.subject;for(;p&&!d;){const v=s.getQuads(null,null,p,null),$=s.getQuads(p,null,null,null).filter(y=>!y.predicate.equals(m));let b,O=null,Y=null,T=null;for(let y=0;y<$.length&&!d;y++)b=$[y],b.graph.equals(g)?r?d=i(p,"has non-list arcs out"):b.predicate.value===E+"first"?O?d=i(p,"has multiple rdf:first arcs"):o.push(O=b):b.predicate.value===E+"rest"?Y?d=i(p,"has multiple rdf:rest arcs"):o.push(Y=b):v.length?d=i(p,"can't be subject and object"):(r=b,u="subject"):d=i(p,"not confined to single graph");for(let y=0;y<v.length&&!d;++y)b=v[y],r?d=i(p,"can't have coreferences"):b.predicate.value===E+"rest"?T?d=i(p,"has incoming rdf:rest arcs"):T=b:(r=b,u="object");O?c.unshift(O.object):d=i(p,"has no list head"),p=T&&T.subject}d?e=!1:r&&(n[r[u].value]=c)}),e&&s.removeQuads(o),n}function ce(s,e,t){const n=document.createElement("div");n.classList.add("shacl-or-constraint");const i=[];if(e instanceof S){const a=[];let o=!1;s.length&&(o=t.store.countQuads(s[0],F,null,null)>0);for(let d=0;d<s.length;d++)if(o){const r=t.store.getObjects(s[d],F,null),u=[];let g="";for(const p of r){const v=new _(p,e,t);u.push(v),g+=(g.length>1?" / ":"")+v.template.label}a.push(u),i.push({label:g,value:d.toString()})}else{const r=new _(s[d],e,t);a.push([r]),i.push({label:r.template.label,value:d.toString()})}const l=t.theme.createListEditor("Please choose",null,!1,i),c=l.querySelector(".editor");c.onchange=()=>{if(c.value){const d=a[parseInt(c.value)];let r;d.length&&(r=d[0],n.replaceWith(d[0]));for(let u=1;u<d.length;u++)r.after(d[u]),r=d[u]}},n.appendChild(l)}else{const a=[];for(let c=0;c<s.length;c++){const d=t.store.getQuads(s[c],null,null,null);d.length&&(a.push(d),i.push({label:D(d,t.languages)||U(d[0].predicate.value,t.prefixes)+" = "+U(d[0].object.value,t.prefixes),value:c.toString()}))}const o=t.theme.createListEditor(e.template.label+"?",null,!1,i,e.template),l=o.querySelector(".editor");l.onchange=()=>{l.value&&n.replaceWith(P(e.template.clone().merge(a[parseInt(l.value)]),void 0,!0))},n.appendChild(o)}return n}function $e(s,e,t){if(e instanceof C){const n=e.datatype;for(const i of s){const a=t.store.getQuads(i,null,null,null);for(const o of a)if(o.predicate.value===`${h}datatype`&&o.object.equals(n))return a}}else{const n=t.store.getObjects(e,m,null);for(const i of s){const a=t.store.getQuads(i,null,null,null);for(const o of a)if(n.length>0){if(o.predicate.value===`${h}node`){for(const l of n)if(t.store.getQuads(o.object,I,l,null).length>0)return a}if(o.predicate.equals(K)){for(const l of n)if(o.object.equals(l))return a}}else if(o.predicate.equals(Le)&&o.object.equals(Ce))return a}}return console.error("couldn't resolve sh:or/sh:xone on property for value",e),[]}function Oe(s,e,t){for(const n of s){let i=!1;const a=t.store.getObjects(n,F,null);for(const o of a){const l=t.store.getObjects(o,`${h}path`,null);for(const c of l)if(i=t.store.countQuads(e,c,null,null)>0,i)break}if(i)return a}return console.error("couldn't resolve sh:or/sh:xone on node for value",e),[]}const Te={[`${h}name`]:(s,e)=>{const t=e;s.name=se(s.config.languages,s.name,t)},[`${h}description`]:(s,e)=>{const t=e;s.description=se(s.config.languages,s.description,t)},[`${h}path`]:(s,e)=>{s.path=e.value},[`${h}node`]:(s,e)=>{s.node=e},[`${h}datatype`]:(s,e)=>{s.datatype=e},[`${h}nodeKind`]:(s,e)=>{s.nodeKind=e},[`${h}minCount`]:(s,e)=>{s.minCount=parseInt(e.value)},[`${h}maxCount`]:(s,e)=>{s.maxCount=parseInt(e.value)},[`${h}minLength`]:(s,e)=>{s.minLength=parseInt(e.value)},[`${h}maxLength`]:(s,e)=>{s.maxLength=parseInt(e.value)},[`${h}minInclusive`]:(s,e)=>{s.minInclusive=parseInt(e.value)},[`${h}maxInclusive`]:(s,e)=>{s.maxInclusive=parseInt(e.value)},[`${h}minExclusive`]:(s,e)=>{s.minExclusive=parseInt(e.value)},[`${h}maxExclusive`]:(s,e)=>{s.maxExclusive=parseInt(e.value)},[`${h}pattern`]:(s,e)=>{s.pattern=e.value},[`${h}order`]:(s,e)=>{s.order=parseInt(e.value)},[`${ee}singleLine`]:(s,e)=>{s.singleLine=e.value==="true"},[`${ee}readonly`]:(s,e)=>{s.readonly=e.value==="true"},[`${ye}styleClass`]:(s,e)=>{s.cssClass=e.value},[`${h}and`]:(s,e)=>{s.shaclAnd=e.value},[`${h}in`]:(s,e)=>{s.shaclIn=e.value},[`${h}languageIn`]:(s,e)=>{s.languageIn=s.config.lists[e.value],s.datatype=f.namedNode(E+"langString")},[`${h}defaultValue`]:(s,e)=>{s.defaultValue=e},[`${h}hasValue`]:(s,e)=>{s.hasValue=e},[`${h}qualifiedValueShape`]:(s,e)=>{s.qualifiedValueShape=e},[`${h}qualifiedMinCount`]:(s,e)=>{s.minCount=parseInt(e.value)},[`${h}qualifiedMaxCount`]:(s,e)=>{s.maxCount=parseInt(e.value)},[z.id]:(s,e)=>{s.owlImports.push(e)},[K.id]:(s,e)=>{s.class=e;const t=s.config.store.getSubjects(I,e,null);t.length>0&&(s.node=t[0])},[`${h}or`]:(s,e)=>{const t=s.config.lists[e.value];t?.length?s.shaclOr=t:console.error("list for sh:or not found:",e.value,"existing lists:",s.config.lists)},[`${h}xone`]:(s,e)=>{const t=s.config.lists[e.value];t?.length?s.shaclXone=t:console.error("list for sh:xone not found:",e.value,"existing lists:",s.config.lists)}};class Ae{constructor(e,t,n){this.label="",this.owlImports=[],this.extendedShapes=[],this.parent=t,this.config=n,this.merge(e),this.qualifiedValueShape&&this.merge(n.store.getQuads(this.qualifiedValueShape,null,null,null))}merge(e){for(const t of e)Te[t.predicate.id]?.call(this,this,t.object);if(this.label=this.name?.value||D(e,this.config.languages),!this.label&&!this.shaclAnd&&(this.label=this.path?U(this.path,this.config.prefixes):"unknown"),this.node&&this.extendedShapes.push(this.node),this.shaclAnd){const t=this.config.lists[this.shaclAnd];if(t?.length)for(const n of t)this.extendedShapes.push(n)}return this}clone(){const e=Object.assign({},this);return e.extendedShapes=[...this.extendedShapes],e.owlImports=[...this.owlImports],this.languageIn&&(e.languageIn=[...this.languageIn]),this.shaclOr&&(e.shaclOr=[...this.shaclOr]),this.shaclXone&&(e.shaclXone=[...this.shaclXone]),e.merge=this.merge.bind(e),e.clone=this.clone.bind(e),e}}const Ne=`form { display:block; --label-width: 8em; --caret-size: 10px; }
2
+ form.mode-edit { padding-left: 1em; }
3
+ form, form * { box-sizing: border-box; }
4
+ shacl-node, .collapsible::part(content) { display: flex; flex-direction: column; width: 100%; position: relative; }
5
+ shacl-node .remove-button { margin-left: 4px; margin-top: 1px; }
6
+ shacl-node .add-button { color: #555; background-color: transparent; margin: 4px 24px 0 0; border: 0; }
7
+ shacl-node .add-button:hover { color:#222; }
8
+ shacl-node .add-button:focus { box-shadow: none; }
9
+ shacl-node h1 { font-size: 16px; border-bottom: 1px solid #AAA; margin-top: 4px; color: #555; }
10
+ shacl-property:not(:has(>.collapsible)), shacl-property>.collapsible::part(content) { display: flex; flex-direction: column; align-items: end; position: relative; }
11
+ shacl-property:not(.may-add) > .add-button { display: none; }
12
+ shacl-property:not(.may-remove) > .property-instance > .remove-button:not(.persistent) { visibility: hidden; }
13
+ shacl-property:not(.may-remove) > .shacl-or-constraint > .remove-button:not(.persistent) { visibility: hidden; }
14
+ .mode-view .shacl-group:not(:has(shacl-property)) { display: none; }
15
+ .property-instance, .shacl-or-constraint { display: flex; align-items: flex-start; padding: 4px 0; width: 100%; position: relative; }
16
+ .shacl-or-constraint > div { display: flex; flex-grow: 1; align-items: flex-start; }
17
+ .shacl-or-constraint label { display: inline-block; word-break: break-word; width: var(--label-width); line-height: 1em; padding-top: 0.15em; padding-right: 1em; flex-shrink: 0; position: relative; }
18
+ .property-instance label[title] { cursor: help; text-decoration: underline dashed #AAA; }
19
+ .property-instance.linked label:after, label.linked:after { content: '\\1F517'; font-size: 0.6em; padding-left: 6px; }
20
+ .mode-edit .property-instance label.required::before { color: red; content: '\\2736'; font-size: 0.6rem; position: absolute; left: -1.4em; top: 0.15rem; }
21
+ .property-instance.valid::before { content: ''; position: absolute; left: calc(var(--label-width) - 1em); top:0.5em; width: 0.9em; height: 0.9em; background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" fill="green" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M866.133333 258.133333L362.666667 761.6l-204.8-204.8L98.133333 618.666667 362.666667 881.066667l563.2-563.2z"/></svg>'); }
22
+ .editor:not([type='checkbox']) { flex-grow: 1; }
23
+ textarea.editor { resize: vertical; }
24
+ .lang-chooser { border: 0; background-color: #e9e9ed; padding: 2px 4px; align-self: flex-start; }
25
+ .validation-error { position: absolute; left: calc(var(--label-width) - 1em); color: red; cursor: help; }
26
+ .validation-error::before { content: '\\26a0' }
27
+ .validation-error.node { left: -1em; }
28
+ .invalid > .editor { border-color: red !important; }
29
+ .ml-0 { margin-left: 0 !important; }
30
+ .pr-0 { padding-right: 0 !important; }
31
+ .mode-view .property-instance:not(:first-child) > label { visibility: hidden; }
32
+ .mode-view .property-instance label { width: var(--label-width); }
33
+
34
+ .d-flex { display: flex; }
35
+ .lang { opacity: 0.65; font-size: 0.6em; }
36
+ a, a:visited { color: inherit; }
37
+
38
+ .fadeIn, .fadeOut { animation: fadeIn 0.2s ease-out; }
39
+ .fadeOut { animation-direction: reverse; animation-timing-function: ease-out;}
40
+ @keyframes fadeIn {
41
+ 0% { opacity: 0; transform: scaleY(0.8); }
42
+ 100% { opacity: 1; transform: scaleY(1); }
43
+ }
44
+ .collapsible::part(label) { font-weight: 600; }
45
+ .collapsible > .property-instance:nth-child(even) { background-color: #F8F8F8; }
46
+ .collapsible > .property-instance > shacl-node > h1 { display: none; }
47
+ .ref-link { cursor: pointer; }
48
+ .ref-link:hover { text-decoration: underline; }
49
+ .node-id-display { color: #999; font-size: 11px; }`;class Pe{constructor(e){let t=Ne;e&&(t+=`
50
+ `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}createViewer(e,t,n){const i=document.createElement("div"),a=document.createElement("label");a.innerHTML=e+":",n.description&&a.setAttribute("title",n.description.value),i.appendChild(a);let o=t.value,l=null;if(t instanceof N){const d=n.config.store.getQuads(o,null,null,null);if(d.length){const r=D(d,n.config.languages);r&&(o=r)}}else t instanceof C&&(t.language?(l=document.createElement("span"),l.classList.add("lang"),l.innerText=`@${t.language}`):t.datatype.value===`${x}date`?o=new Date(Date.parse(t.value)).toDateString():t.datatype.value===`${x}dateTime`&&(o=new Date(Date.parse(t.value)).toLocaleString()));let c;return G(t.value)?(c=document.createElement("a"),c.setAttribute("href",t.value)):c=document.createElement("div"),c.classList.add("d-flex"),c.innerText=o,l&&c.appendChild(l),i.appendChild(c),i}}function ke(s,e,t){if(t){const n=s.minCount!==void 0&&s.minCount>0;if(s.class)return s.config.theme.createListEditor(s.label,e,n,J(s.class,s),s);if(s.shaclIn){const i=s.config.lists[s.shaclIn];if(i?.length){const a=le(i,s.config.store,s.config.languages);return s.config.theme.createListEditor(s.label,e,n,a,s)}else console.error("list not found:",s.shaclIn,"existing lists:",s.config.lists)}if(s.datatype?.value===`${E}langString`||s.languageIn?.length)return s.config.theme.createLangStringEditor(s.label,e,n,s);switch(s.datatype?.value.replace(x,"")){case"integer":case"float":case"double":case"decimal":return s.config.theme.createNumberEditor(s.label,e,n,s);case"date":case"dateTime":return s.config.theme.createDateEditor(s.label,e,n,s);case"boolean":return s.config.theme.createBooleanEditor(s.label,e,n,s);case"base64Binary":return s.config.theme.createFileEditor(s.label,e,n,s)}return s.config.theme.createTextEditor(s.label,e,n,s)}else{if(e)return s.config.theme.createViewer(s.label,e,s);const n=document.createElement("div");return n.innerHTML="No value",n}}function Fe(s,e,t){if(e==="application/ld+json")return _e(s);{const n=new ue({format:e,prefixes:t});n.addQuads(s);let i="";return n.end((a,o)=>{a&&console.error(a),i=o}),i}}function _e(s){const e=[];for(const t of s){const n={"@id":t.subject.id};if(t.predicate===m)n["@type"]=t.object.id;else{let i=t.object.value;t.object instanceof C?t.object.language?i={"@language":t.object.language,"@value":t.object.value}:t.object.datatype&&t.object.datatype.value!==`${x}#string`&&(i={"@type":t.object.datatype.value,"@value":t.object.value}):i={"@id":t.object.id},n[t.predicate.value]=i}e.push(n)}return JSON.stringify(e)}function qe(s){let e=s.shaclDatatype,t=s.value;if(t){if(t.startsWith("<")&&t.endsWith(">")&&t.indexOf(":")>-1)return f.namedNode(t.substring(1,t.length-1));if(s.dataset.class||s.dataset.nodeKind===h+"IRI")return f.namedNode(t);if(s.dataset.link)return JSON.parse(s.dataset.link);if(s.dataset.lang?e=s.dataset.lang:s.type==="number"?t=parseFloat(t):s.type==="file"&&s.binaryData?t=s.binaryData:s.type==="datetime-local"&&(t=new Date(t).toISOString().slice(0,19)),!e&&typeof t=="string"){let n=t.split("^^");n.length===2&&n[0].startsWith('"')&&n[0].endsWith('"')&&n[1].split(":").length===2?(t=n[0].substring(1,n[0].length-1),e=f.namedNode(n[1])):(n=t.split("@"),n.length===2&&n[0].startsWith('"')&&n[0].endsWith('"')&&(t=n[0].substring(1,n[0].length-1),e=n[1]))}return f.literal(t,e)}else if((s.type==="checkbox"||s.getAttribute("type")==="checkbox")&&(s.checked||parseInt(s.dataset.minCount||"0")>0))return f.literal(s.checked?"true":"false",e)}const R={};function Qe(s){s.predicate===void 0&&s.datatype===void 0?console.warn('not registering plugin because it does neither define "predicate" nor "datatype"',s):R[`${s.predicate}^${s.datatype}`]=s}function Ve(){return Object.entries(R).map(s=>s[1])}function Me(s,e){let t=R[`${s}^${e}`];return t||(t=R[`${s}^undefined`],t)?t:R[`undefined^${e}`]}class et{constructor(e,t){this.predicate=e.predicate,this.datatype=e.datatype,t&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t))}createViewer(e,t){return e.config.theme.createViewer(e.label,t,e)}}class _ extends HTMLElement{constructor(e,t,n,i){if(super(),this.template=new Ae(n.store.getQuads(e,null,null,null),t,n),this.container=this,this.template.extendedShapes.length&&this.template.config.attributes.collapse!==null&&(!this.template.maxCount||this.template.maxCount>1)){const a=new k;a.classList.add("collapsible","shacl-group"),a.open=n.attributes.collapse==="open",a.label=this.template.label,this.container=a}if(this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),n.editMode&&!t.linked&&(this.addButton=this.createAddButton(),this.container.appendChild(this.addButton)),this.template.path){let a=[];i&&(t.linked?a=n.store.getQuads(i,this.template.path,null,null):a=n.store.getQuads(i,this.template.path,null,w));let o=!1;for(const l of a)this.isValueValid(l.object)&&(this.addPropertyInstance(l.object),this.template.hasValue&&l.object.equals(this.template.hasValue)&&(o=!0));n.editMode&&this.template.hasValue&&!o&&!t.linked&&this.addPropertyInstance(this.template.hasValue)}n.editMode&&!t.linked&&(this.addEventListener("change",()=>{this.updateControls()}),this.updateControls()),this.container instanceof k&&(n.editMode&&!t.linked||this.container.childElementCount>0)&&this.appendChild(this.container)}addPropertyInstance(e){let t;if(this.template.shaclOr?.length||this.template.shaclXone?.length){const n=this.template.shaclOr?.length?this.template.shaclOr:this.template.shaclXone;let i=!1;if(e){const a=$e(n,e,this.template.config);a.length&&(t=P(this.template.clone().merge(a),e,!0),i=!0)}i||(t=ce(n,this,this.template.config),de(t,""))}else{let n=!1;if(e&&!(e instanceof C)){const i=this.getRdfClassToLinkOrCreate();i&&this.template.config.store.countQuads(e,m,i,w)===0&&(n=!0)}t=P(this.template,e,void 0,n||this.template.parent.linked)}return this.addButton?this.container.insertBefore(t,this.addButton):this.container.appendChild(t),t}updateControls(){let e=this.querySelectorAll(":scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node").length;e===0&&(!this.template.extendedShapes.length||this.template.minCount!==void 0&&this.template.minCount>0)&&(this.addPropertyInstance(),e=this.querySelectorAll(":scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node").length);let t;this.template.minCount!==void 0?t=e>this.template.minCount:t=this.template.extendedShapes.length>0||e>1;const n=this.template.maxCount===void 0||e<this.template.maxCount;this.classList.toggle("may-remove",t),this.classList.toggle("may-add",n)}toRDF(e,t){for(const n of this.querySelectorAll(":scope > .property-instance, :scope > .collapsible > .property-instance")){const i=f.namedNode(n.dataset.path);if(n.firstChild instanceof S){const a=n.firstChild.toRDF(e);e.addQuad(t,i,a,this.template.config.valuesGraphId)}else for(const a of n.querySelectorAll(":scope > .editor")){const o=qe(a);o&&e.addQuad(t,i,o,this.template.config.valuesGraphId)}}}getRdfClassToLinkOrCreate(){if(this.template.class&&this.template.node)return this.template.class;for(const e of this.template.extendedShapes){const t=this.template.config.store.getObjects(e,I,null);if(t.length>0)return t[0]}}isValueValid(e){if(!this.template.extendedShapes.length)return!0;for(const t of this.template.extendedShapes){const n=this.template.config.store.getObjects(t,I,null);for(const i of n)if(this.template.config.store.countQuads(e,m,i,null)>0)return!0}return!1}createAddButton(){const e=new oe;e.dense=!0,e.label="+ "+this.template.label,e.title="Add "+this.template.label,e.autoGrowLabelWidth=!0,e.classList.add("add-button");let t=[],n=this.getRdfClassToLinkOrCreate();if(n&&(t=J(n,this.template)),t.length===0)e.emptyMessage="",e.inputMinWidth=0,e.addEventListener("click",i=>{e.blur();const a=this.addPropertyInstance();a.classList.add("fadeIn"),this.updateControls(),setTimeout(()=>{Re(a),a.classList.remove("fadeIn")},200)});else{const i=document.createElement("ul"),a=document.createElement("li");a.innerHTML="&#xFF0B; Create new "+this.template.label+"...",a.dataset.value="new",a.classList.add("large"),i.appendChild(a);const o=document.createElement("li");o.classList.add("divider"),i.appendChild(o);const l=document.createElement("li");l.classList.add("header"),l.innerText="Or link existing:",i.appendChild(l);for(const c of t){const d=document.createElement("li"),r=typeof c.value=="string"?c.value:c.value.value;d.innerText=c.label?c.label:r,d.dataset.value=JSON.stringify(c.value),i.appendChild(d)}e.appendChild(i),e.collapsibleWidth="250px",e.collapsibleOrientationLeft="",e.addEventListener("change",()=>{if(e.value==="new")this.addPropertyInstance();else{const c=JSON.parse(e.value);this.container.insertBefore(P(this.template,c,!0,!0),e)}e.value=""})}return e}}function P(s,e,t=!1,n=!1){let i;if(s.extendedShapes.length){i=document.createElement("div"),i.classList.add("property-instance");for(const a of s.extendedShapes)i.appendChild(new S(a,s.config,e,s.parent,s.nodeKind,s.label,n))}else{const a=Me(s.path,s.datatype?.value);a?s.config.editMode&&!n?i=a.createEditor(s,e):i=a.createViewer(s,e):i=ke(s,e||null,s.config.editMode&&!n),i.classList.add("property-instance"),n&&i.classList.add("linked")}return s.config.editMode&&de(i,s.label,t),i.dataset.path=s.path,i}function de(s,e,t=!1){const n=new fe;n.classList.add("remove-button","clear"),n.title="Remove "+e,n.dense=!0,n.icon=!0,n.addEventListener("click",i=>{s.classList.remove("fadeIn"),s.classList.add("fadeOut"),setTimeout(()=>{const a=s.parentElement;s.remove(),a?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},200)}),t&&n.classList.add("persistent"),s.appendChild(n)}window.customElements.define("shacl-property",_);function Be(s,e){let t=s;const n=e.store.getQuads(s,null,null,null),i=j(n,"label",X,e.languages);i&&(t=i);let a;if(e.attributes.collapse!==null)a=new k,a.classList.add("collapsible"),a.open=e.attributes.collapse==="open",a.label=t;else{a=document.createElement("div");const l=document.createElement("h1");l.innerText=t,a.appendChild(l)}a.dataset.subject=s,a.classList.add("shacl-group");const o=j(n,"order");return o&&(a.style.order=o),a}class S extends HTMLElement{constructor(e,t,n,i,a,o,l){super(),this.owlImports=[],this.parent=i,this.config=t,this.shaclSubject=e,this.linked=l||!1;let c=n;if(!c){if(!a){const r=t.store.getObjects(e,`${h}nodeKind`,null);r.length&&(a=r[0])}a===void 0&&t.attributes.valuesNamespace||a?.value===`${h}IRI`?c=f.namedNode(t.attributes.valuesNamespace+Z()):c=f.blankNode(Z())}this.nodeId=c;const d=JSON.stringify([e,n]);if(n&&t.renderedNodes.has(d)){o=o||"Link";const r=document.createElement("label");r.innerText=o,r.classList.add("linked"),this.appendChild(r);const u=document.createElement("a");let g=n.termType==="BlankNode"?"_:"+n.value:n.value;u.innerText=g,u.classList.add("ref-link"),u.onclick=()=>{this.config.form.querySelector(`shacl-node[data-node-id='${g}']`)?.scrollIntoView()},this.appendChild(u),this.style.flexDirection="row"}else{if(n&&t.renderedNodes.add(d),this.dataset.nodeId=this.nodeId.id,this.config.attributes.showNodeIds!==null){const r=document.createElement("div");r.innerText=`id: ${this.nodeId.id}`,r.classList.add("node-id-display"),this.appendChild(r)}for(const r of t.store.getQuads(e,z,null,null))this.owlImports.push(r.object);for(const r of t.store.getQuads(e,null,null,null))switch(r.predicate.id){case F.id:this.addPropertyInstance(r.object,t,n);break;case`${h}and`:const u=t.lists[r.object.value];if(u?.length)for(const g of u)this.prepend(new S(g,t,n,this));else console.error("list not found:",r.object.value,"existing lists:",t.lists);break;case Ie.id:this.prepend(new S(r.object,t,n,this));break;case`${h}targetClass`:this.targetClass=r.object;break;case`${h}or`:this.tryResolve(r.object,n,t);break;case`${h}xone`:this.tryResolve(r.object,n,t);break}if(o){const r=document.createElement("h1");r.innerText=o,this.prepend(r)}}}toRDF(e,t){if(t||(t=this.nodeId),!this.linked){for(const n of this.querySelectorAll(":scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property"))n.toRDF(e,t);this.targetClass&&e.addQuad(t,m,this.targetClass,this.config.valuesGraphId),this.config.attributes.generateNodeShapeReference&&!this.parent&&e.addQuad(t,f.namedNode(this.config.attributes.generateNodeShapeReference),this.shaclSubject,this.config.valuesGraphId)}return t}addPropertyInstance(e,t,n){let i=this;const a=t.store.getQuads(e,`${h}group`,null,null);if(a.length>0){const l=a[0].object.value;if(t.groups.indexOf(l)>-1){let c=this.querySelector(`:scope > .shacl-group[data-subject='${l}']`);c||(c=Be(l,t),this.appendChild(c)),i=c}else console.warn("ignoring unknown group reference",a[0],"existing groups:",t.groups)}const o=new _(e,this,t,n);o.childElementCount>0&&i.appendChild(o)}tryResolve(e,t,n){const i=n.lists[e.value];if(i?.length){let a=!1;if(t){const o=Oe(i,t,n);if(o.length){for(const l of o)this.addPropertyInstance(l,n,t);a=!0}}a||this.appendChild(ce(i,this,n))}else console.error("list for sh:or/sh:xone not found:",e,"existing lists:",n.lists)}}window.customElements.define("shacl-node",S);const Q={},V={};class Ue{constructor(e){this.loadedExternalUrls=[],this.loadedClasses=[],this.config=e}async loadGraphs(){this.loadedExternalUrls=[],this.loadedClasses=[],this.config.prefixes={};const e=[],t=new H;if(e.push(this.importRDF(this.config.attributes.shapes?this.config.attributes.shapes:this.config.attributes.shapesUrl?this.fetchRDF(this.config.attributes.shapesUrl):"",t,L)),e.push(this.importRDF(this.config.attributes.values?this.config.attributes.values:this.config.attributes.valuesUrl?this.fetchRDF(this.config.attributes.valuesUrl):"",t,w)),await Promise.all(e),t.countQuads(null,null,null,L)===0&&this.config.attributes.valuesSubject){const n=[...t.getObjects(this.config.attributes.valuesSubject,B,w)],i=[];for(const a of n){const o=this.toURL(a.value);o&&this.loadedExternalUrls.indexOf(o)<0&&(this.loadedExternalUrls.push(o),i.push(this.importRDF(this.fetchRDF(o),t,L)))}try{await Promise.allSettled(i)}catch(a){console.warn(a)}}this.config.store=t}async importRDF(e,t,n){const i=async a=>{const o=[];await new Promise((l,c)=>{const d=ne(a)==="xml"?new ge:new he;d.on("data",r=>{if(t.add(new ae(r.subject,r.predicate,r.object,n)),this.config.attributes.ignoreOwlImports===null&&z.equals(r.predicate)){const u=this.toURL(r.object.value);u&&this.loadedExternalUrls.indexOf(u)<0&&(this.loadedExternalUrls.push(u),o.push(this.importRDF(this.fetchRDF(u),t,f.namedNode(u))))}if(this.config.classInstanceProvider&&(K.equals(r.predicate)||I.equals(r.predicate))){const u=r.object.value;if(this.loadedClasses.indexOf(u)<0){let g;u in V?g=V[u]:(g=this.config.classInstanceProvider(u),V[u]=g),this.loadedClasses.push(u),o.push(this.importRDF(g,t,n))}}}).on("error",r=>{console.warn("failed parsing graph",n,r.message),c(r)}).on("prefix",(r,u)=>{r&&(this.config.prefixes[r]=u)}).on("end",()=>{l(null)}),d.write(a),d.end()});try{await Promise.allSettled(o)}catch(l){console.warn(l)}};if(e instanceof Promise&&(e=await e),e){if(ne(e)==="json")try{e=await me(JSON.parse(e),{format:"application/n-quads"})}catch(a){console.error(a)}await i(e)}}toURL(e){if(G(e))return e;if(this.config.prefixes){const t=e.split(":");if(t.length===2){const n=this.config.prefixes[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),G(e)))return e}}return null}async fetchRDF(e){if(e in Q)return Q[e];let t=e;this.config.attributes.proxy&&(t=this.config.attributes.proxy+encodeURIComponent(e));const n=fetch(t,{headers:{Accept:"text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json"}}).then(i=>i.text());return Q[e]=n,n}}function ne(s){return/^\s*\{/.test(s)?"json":/^\s*<\?xml/.test(s)?"xml":"ttl"}class M{constructor(){this.shapes=null,this.shapesUrl=null,this.shapeSubject=null,this.values=null,this.valuesUrl=null,this.valueSubject=null,this.valuesSubject=null,this.valuesNamespace="",this.valuesGraph=null,this.view=null,this.language=null,this.loading="Loading…",this.proxy=null,this.ignoreOwlImports=null,this.collapse=null,this.submitButton=null,this.generateNodeShapeReference=null,this.showNodeIds=null}}class ie{constructor(e,t){this.attributes=new M,this.loader=new Ue(this),this.prefixes={},this.editMode=!0,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new H,this.theme=e,this.form=t,this.languages=[...new Set(navigator.languages.flatMap(n=>n.length>2?[n.toLocaleLowerCase(),n.substring(0,2)]:n)),""]}updateAttributes(e){const t=new M;if(Object.keys(t).forEach(n=>{const i=e.dataset[n];i!==void 0&&(t[n]=i)}),this.editMode=t.view===null,this.attributes=t,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),t.language){const n=this.languages.indexOf(t.language);n>-1&&this.languages.splice(n,1),this.languages.unshift(t.language)}t.valuesGraph&&(this.valuesGraphId=f.namedNode(t.valuesGraph))}static dataAttributes(){const e=new M;return Object.keys(e).map(t=>(t=t.replace(/[A-Z]/g,n=>"-"+n.toLowerCase()),"data-"+t))}get store(){return this._store}set store(e){this._store=e,this.lists=De(e,{ignoreErrors:!0}),this.groups=[],e.forSubjects(t=>{this.groups.push(t.id)},m,`${h}PropertyGroup`,null)}}const Ge=`
51
+ .editor:not([type='checkbox']) { border: 1px solid #DDD; }
52
+ .property-instance label { display: inline-flex; word-break: break-word; line-height: 1em; padding-top: 0.15em; padding-right: 1em; flex-shrink: 0; position: relative; }
53
+ .property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
54
+ .mode-edit .property-instance label { width: var(--label-width); }
55
+ `;class He extends Pe{constructor(e){super(e||Ge),this.idCtr=0}createDefaultTemplate(e,t,n,i,a){i.id=`e${this.idCtr++}`,i.classList.add("editor"),a?.datatype?i.shaclDatatype=a.datatype:t instanceof C&&(i.shaclDatatype=t.datatype),a?.minCount!==void 0&&(i.dataset.minCount=String(a.minCount)),a?.class&&(i.dataset.class=a.class.value),a?.nodeKind?i.dataset.nodeKind=a.nodeKind.value:t instanceof N&&(i.dataset.nodeKind=h+"IRI"),(a?.hasValue||a?.readonly)&&(i.disabled=!0),i.value=t?.value||a?.defaultValue?.value||"";const o=document.createElement("label");o.htmlFor=i.id,o.innerText=e,a?.description&&o.setAttribute("title",a.description.value);const l=a?.description?a.description.value:a?.pattern?a.pattern:null;l&&i.setAttribute("placeholder",l),n&&(i.setAttribute("required","true"),o.classList.add("required"));const c=document.createElement("div");return c.appendChild(o),c.appendChild(i),c}createDateEditor(e,t,n,i){const a=new q;i.datatype?.value===x+"dateTime"?(a.type="datetime-local",a.setAttribute("step","1")):a.type="date",a.clearable=!0,a.dense=!0,a.classList.add("pr-0");const o=this.createDefaultTemplate(e,null,n,a,i);if(t)try{let l=new Date(t.value).toISOString();i.datatype?.value===x+"dateTime"?l=l.slice(0,19):l=l.slice(0,10),a.value=l}catch(l){console.error(l,t)}return o}createTextEditor(e,t,n,i){let a;return i.singleLine===!1?(a=new pe,a.resize="auto"):a=new q,a.dense=!0,i.pattern&&(a.pattern=i.pattern),i.minLength&&(a.minLength=i.minLength),i.maxLength&&(a.maxLength=i.maxLength),this.createDefaultTemplate(e,t,n,a,i)}createLangStringEditor(e,t,n,i){const a=this.createTextEditor(e,t,n,i),o=a.querySelector(":scope .editor");let l;if(i.languageIn?.length){l=document.createElement("select");for(const c of i.languageIn){const d=document.createElement("option");d.innerText=c.value,l.appendChild(d)}}else l=document.createElement("input"),l.maxLength=5,l.size=5,l.placeholder="lang?";return l.title="Language of the text",l.classList.add("lang-chooser"),l.slot="suffix",l.addEventListener("change",c=>{c.stopPropagation(),o&&(o.dataset.lang=l.value,o.dispatchEvent(new Event("change",{bubbles:!0})))}),t instanceof C&&(l.value=t.language),o.dataset.lang=l.value,o.appendChild(l),a}createBooleanEditor(e,t,n,i){const a=document.createElement("input");a.type="checkbox",a.classList.add("ml-0");const o=this.createDefaultTemplate(e,null,n,a,i);return a.removeAttribute("required"),o.querySelector(":scope label")?.classList.remove("required"),t instanceof C&&(a.checked=t.value==="true"),o}createFileEditor(e,t,n,i){const a=document.createElement("input");return a.type="file",a.addEventListener("change",o=>{if(a.files?.length){o.stopPropagation();const l=new FileReader;l.readAsDataURL(a.files[0]),l.onload=()=>{a.binaryData=btoa(l.result),a.parentElement?.dispatchEvent(new Event("change",{bubbles:!0}))}}else a.binaryData=void 0}),this.createDefaultTemplate(e,t,n,a,i)}createNumberEditor(e,t,n,i){const a=new q;a.type="number",a.clearable=!0,a.dense=!0,a.classList.add("pr-0");const o=i.minInclusive!==void 0?i.minInclusive:i.minExclusive!==void 0?i.minExclusive+1:void 0,l=i.maxInclusive!==void 0?i.maxInclusive:i.maxExclusive!==void 0?i.maxExclusive-1:void 0;return o!==void 0&&(a.min=String(o)),l!==void 0&&(a.max=String(l)),i.datatype?.value!==x+"integer"&&(a.step="0.1"),this.createDefaultTemplate(e,t,n,a,i)}createListEditor(e,t,n,i,a){const o=new oe;o.clearable=!0,o.dense=!0;const l=this.createDefaultTemplate(e,null,n,o,a),c=document.createElement("ul");let d=!0;const r=(u,g)=>{const p=document.createElement("li");if(typeof u.value=="string"?(p.dataset.value=u.value,p.innerText=u.label?u.label:u.value):(p.dataset.value=u.value.id,u.value instanceof N&&(p.dataset.value="<"+p.dataset.value+">"),p.innerText=u.label?u.label:u.value.value),g.appendChild(p),u.children?.length){d=!1;const v=document.createElement("ul");p.appendChild(v);for(const $ of u.children)r($,v)}};for(const u of i)r(u,c);return d||(o.collapse=!0),o.appendChild(c),t&&(o.value=t.id,t instanceof N&&(o.value="<"+o.value+">")),l}createButton(e,t){const n=document.createElement("rokit-button");return n.innerHTML=e,n}}class Xe extends HTMLElement{constructor(){super(),this.shape=null,this.attachShadow({mode:"open"}),this.form=document.createElement("form"),this.config=new ie(new He,this.form),this.form.addEventListener("change",e=>{e.stopPropagation(),this.config.editMode&&this.validate(!0).then(t=>{this.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:t.conforms,report:t}}))}).catch(t=>{console.warn(t)})})}static get observedAttributes(){return ie.dataAttributes()}connectedCallback(){this.shadowRoot.prepend(this.form)}attributeChangedCallback(){this.config.updateAttributes(this),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.setAttribute("loading",""),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{await this.config.loader.loadGraphs(),this.form.replaceChildren(),this.config.renderedNodes.clear();const e=this.findRootShaclShapeSubject();if(e){this.form.classList.forEach(n=>{this.form.classList.remove(n)}),this.form.classList.toggle("mode-edit",this.config.editMode),this.form.classList.toggle("mode-view",!this.config.editMode),this.config.theme.apply(this.form);const t=[this.config.theme.stylesheet];for(const n of Ve())n.stylesheet&&t.push(n.stylesheet);if(this.shadowRoot.adoptedStyleSheets=t,this.shape=new S(e,this.config,this.config.attributes.valuesSubject?f.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.editMode){if(this.config.attributes.submitButton!==null){const n=this.config.theme.createButton(this.config.attributes.submitButton||"Submit",!0);n.addEventListener("click",i=>{i.preventDefault(),this.form.reportValidity()&&this.validate().then(a=>{if(a?.conforms)this.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}));else{let o=this.form.querySelector(":scope .invalid > .editor");o?o.focus():this.form.querySelector(":scope .invalid")?.scrollIntoView()}})}),this.form.appendChild(n)}this.config.attributes.valuesSubject&&this.removeFromDataGraph(f.namedNode(this.config.attributes.valuesSubject)),await this.validate(!0)}}else if(this.config.store.countQuads(null,null,null,L)>0)throw new Error("shacl root node shape not found")}catch(e){console.error(e);const t=document.createElement("div");t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute("loading")},200)}serialize(e="text/turtle",t=this.toRDF()){const n=t.getQuads(null,null,null,null);return Fe(n,e,this.config.prefixes)}toRDF(e=new H){return this.shape?.toRDF(e),e}registerPlugin(e){Qe(e),this.initialize()}setTheme(e){this.config.theme=e,this.initialize()}setClassInstanceProvider(e){this.config.classInstanceProvider=e,this.initialize()}async validate(e=!1){for(const t of this.form.querySelectorAll(":scope .validation-error"))t.remove();for(const t of this.form.querySelectorAll(":scope .property-instance"))t.classList.remove("invalid"),t.querySelector(":scope > .editor")?.value?t.classList.add("valid"):t.classList.remove("valid");this.config.store.deleteGraph(this.config.valuesGraphId||""),this.shape&&(this.shape.toRDF(this.config.store),this.config.store.add(new ae(this.shape.shaclSubject,f.namedNode(h+"targetNode"),this.shape.nodeId,this.config.valuesGraphId)));try{const t=this.config.store,n=await new be(t,{details:!0,factory:f}).validate({dataset:t});for(const i of n.results)if(i.focusNode?.ptrs?.length)for(const a of i.focusNode.ptrs){const o=a._term;if(i.path?.length){const l=i.path[0].predicates[0];let c=this.form.querySelectorAll(`
56
+ :scope shacl-node[data-node-id='${o.id}'] > shacl-property > .property-instance[data-path='${l.id}'] > .editor,
57
+ :scope shacl-node[data-node-id='${o.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${l.id}'] > .editor,
58
+ :scope shacl-node[data-node-id='${o.id}'] > .shacl-group > shacl-property > .property-instance[data-path='${l.id}'] > .editor,
59
+ :scope shacl-node[data-node-id='${o.id}'] > .shacl-group > shacl-property > .shacl-group > .property-instance[data-path='${l.id}'] > .editor`);c.length===0&&(c=this.form.querySelectorAll(`
60
+ :scope [data-node-id='${o.id}'] > shacl-property > .property-instance[data-path='${l.id}'],
61
+ :scope [data-node-id='${o.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${l.id}']`));for(const d of c)if(d.classList.contains("editor")){if(!e||d.value){let r=d.parentElement;r.classList.add("invalid"),r.classList.remove("valid"),r.appendChild(this.createValidationErrorDisplay(i));do r instanceof k&&(r.open=!0),r=r.parentElement;while(r)}}else e||(d.classList.add("invalid"),d.classList.remove("valid"),d.appendChild(this.createValidationErrorDisplay(i,"node")))}else e||this.form.querySelector(`:scope [data-node-id='${o.id}']`)?.prepend(this.createValidationErrorDisplay(i,"node"))}return n}catch(t){return console.error(t),!1}}createValidationErrorDisplay(e,t){const n=document.createElement("span");if(n.classList.add("validation-error"),t&&n.classList.add(t),e)if(e.message?.length>0)for(const i of e.message)n.title+=i.value+`
62
+ `;else n.title=e.sourceConstraintComponent?.value;return n}findRootShaclShapeSubject(){let e=null;if(this.config.attributes.shapeSubject){if(e=f.namedNode(this.config.attributes.shapeSubject),this.config.store.getQuads(e,m,A,null).length===0){console.warn(`shapes graph does not contain requested root shape ${this.config.attributes.shapeSubject}`);return}}else if(this.config.attributes.valuesSubject&&this.config.store.countQuads(null,null,null,w)>0){const t=f.namedNode(this.config.attributes.valuesSubject),n=[...this.config.store.getQuads(t,m,null,w),...this.config.store.getQuads(t,B,null,w)];if(n.length===0){console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${m.id} nor ${B.id} statement`);return}for(const i of n)if(this.config.store.getQuads(i.object,m,A,null).length>0){e=i.object;break}if(!e){const i=this.config.store.getQuads(null,I,n[0].object,null);if(i.length===0){console.error(`value subject '${this.config.attributes.valuesSubject}' has no shacl shape definition in the shapes graph`);return}if(i.length>1&&console.warn(`value subject '${this.config.attributes.valuesSubject}' has multiple shacl shape definitions in the shapes graph, choosing the first found (${i[0].subject})`),this.config.store.getQuads(i[0].subject,m,A,null).length===0){console.error(`value subject '${this.config.attributes.valuesSubject}' references a shape which is not a NodeShape (${i[0].subject})`);return}e=i[0].subject}}else{const t=this.config.store.getQuads(null,m,A,null);if(t.length==0){console.warn("shapes graph does not contain any root shapes");return}t.length>1&&(console.warn("shapes graph contains",t.length,"root shapes. choosing first found which is",t[0].subject.value),console.info('hint: set the shape to use with attribute "data-shape-subject"')),e=t[0].subject}return e}removeFromDataGraph(e){this.config.attributes.valuesSubject;for(const t of this.config.store.getQuads(e,null,null,w))this.config.store.delete(t),(t.object.termType==="NamedNode"||t.object.termType==="BlankNode")&&this.removeFromDataGraph(t.object)}}window.customElements.define("shacl-form",Xe);export{ie as Config,Ue as Loader,et as Plugin,Xe as ShaclForm,Ae as ShaclPropertyTemplate,Pe as Theme,D as findLabel,Qe as registerPlugin};
@@ -0,0 +1 @@
1
+ class a{constructor(e,t){this.predicate=e.predicate,this.datatype=e.datatype,t&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t))}createViewer(e,t){return e.config.theme.createViewer(e.label,t,e)}}export{a as P};
@@ -0,0 +1 @@
1
+ import{P as o}from"./assets/plugin-VN3CfgGe.js";class c extends o{constructor(e,t,i){super(e),this.onChange=t,this.fileType=i}createEditor(e){const t=e.minCount!==void 0&&e.minCount>0,i=e.config.theme.createFileEditor(e.label,null,t,e);return i.addEventListener("change",n=>{n.stopPropagation(),this.onChange(n)}),this.fileType&&i.querySelector('input[type="file"]')?.setAttribute("accept",this.fileType),i}}export{c as FileUploadPlugin};
@@ -1,9 +1,11 @@
1
+ import * as L from 'leaflet';
2
+ import 'leaflet-editable/src/Leaflet.Editable.js';
3
+ import 'leaflet.fullscreen/Control.FullScreen.js';
1
4
  import { Term } from '@rdfjs/types';
5
+ import { Point, Polygon } from 'geojson';
2
6
  import { Plugin, PluginOptions } from '../plugin';
3
7
  import { Editor } from '../theme';
4
8
  import { ShaclPropertyTemplate } from '../property-template';
5
- import { Geometry } from './map-util';
6
- import * as L from 'leaflet';
7
9
  export declare class LeafletPlugin extends Plugin {
8
10
  map: L.Map | undefined;
9
11
  currentEditor: Editor | undefined;
@@ -16,3 +18,7 @@ export declare class LeafletPlugin extends Plugin {
16
18
  drawAndZoomToGeometry(geometry: Geometry | undefined, map: L.Map): void;
17
19
  saveChanges(): void;
18
20
  }
21
+ export type Geometry = Point | Polygon;
22
+ export declare const worldBounds: [number, number][];
23
+ export declare function wktToGeometry(wkt: string): Geometry | undefined;
24
+ export declare function geometryToWkt(geometry: Geometry): string;