@ulb-darmstadt/shacl-form 2.0.1 → 2.0.2

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.
package/dist/bundle.js CHANGED
@@ -370,7 +370,7 @@ h3 { margin-top: 0; }
370
370
  .inner { display: flex; padding: 10px; }
371
371
  .text { flex-grow: 1; }
372
372
  .text a { color: inherit; }
373
- `;Ur=U_([_n("rokit-snackbar")],Ur);class $s extends HTMLElement{constructor(e,n){if(super(),this.template=e,this.parent=n,this.container=this,this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){const r=new Ct;r.classList.add("collapsible","shacl-group"),r.open=e.config.attributes.collapse==="open",r.label=this.template.label,this.container=r,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!n.linked&&(this.addButton=this.createAddButton(),this.container.appendChild(this.addButton),this.addEventListener("change",()=>{this.updateControls()}))}async bindValues(e){if(this.template.path){let n=!1;if(e){let r=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:on);r=await this.filterValidValues(r,e);for(const o of r)this.template.config.store.delete(o),this.addPropertyInstance(o.object),this.template.hasValue&&o.object.equals(this.template.hasValue)&&(n=!0)}this.template.config.editMode&&(this.template.hasValue&&!n&&!this.parent.linked&&this.addPropertyInstance(this.template.hasValue),this.updateControls())}}addPropertyInstance(e){let n;if(this.template.or?.length||this.template.xone?.length){const r=this.template.or?.length?this.template.or:this.template.xone;let o=!1;if(e){const a=$m(r,e,this.template.config);if(a.length){const l=Wl(jf(this.template),a);n=Cs(l,e,!0),o=!0}}o||(n=$f(r,this,this.template.config),lp(n,"",this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else{let r=!1;if(e&&!(e instanceof Wt)){const o=this.getRdfClassToLinkOrCreate();o&&this.template.config.store.countQuads(e,Rt,o,on)===0&&(r=!0)}n=Cs(this.template,e,void 0,r||this.parent.linked)}return this.addButton?this.container.insertBefore(n,this.addButton):this.container.appendChild(n),n}updateControls(){let e=this.instanceCount();e===0&&(this.template.nodeShapes.size===0||this.template.aggregatedMinCount>0)&&(this.addPropertyInstance(),e=this.instanceCount());let n;this.template.aggregatedMinCount>0?n=e>this.template.aggregatedMinCount:n=this.template.nodeShapes.size>0||e>1;const r=this.template.maxCount===void 0||e<this.template.maxCount;this.classList.toggle("may-remove",n),this.classList.toggle("may-add",r)}instanceCount(){return this.querySelectorAll(":scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance").length}toRDF(e,n){const r=ze.namedNode(this.template.path);for(const o of this.querySelectorAll(":scope > .property-instance, :scope > .collapsible > .property-instance"))if(o.firstChild instanceof Ei){const a=o.firstChild.toRDF(e);e.addQuad(n,r,a,this.template.config.valuesGraphId)}else for(const a of o.querySelectorAll(":scope > .editor")){const l=Gm(a);l&&e.addQuad(n,r,l,this.template.config.valuesGraphId)}}getRdfClassToLinkOrCreate(){if(this.template.class&&this.template.nodeShapes.size)return this.template.class;for(const e of this.template.nodeShapes)if(e.targetClass)return e.targetClass}async filterValidValues(e,n){let r=this.template.id,o=[n];if(this.template.qualifiedValueShape){r=this.template.qualifiedValueShape.id,o=[];for(const u of e)o.push(u.object)}const a=await this.template.config.validator.validate({dataset:this.template.config.store,terms:o},[{terms:[r]}]),l=[];for(const u of a.results){const f=this.template.qualifiedValueShape?u.focusNode:u.value;f?.ptrs?.length&&l.push(f.ptrs[0]._term.id)}return e.filter(u=>l.indexOf(u.object.id)===-1)}createAddButton(){const e=new ht;e.dense=this.template.config.theme.dense,e.label="+ "+this.template.label,e.title="Add "+this.template.label,e.autoGrowLabelWidth=!0,e.classList.add("add-button");let n=[],r=this.getRdfClassToLinkOrCreate();if(r&&(n=ql(r,this.template)),n.length===0)e.emptyMessage="",e.inputMinWidth=0,e.addEventListener("click",o=>{e.blur();const a=this.addPropertyInstance();a.classList.add("fadeIn"),this.updateControls(),setTimeout(()=>{Kg(a),a.classList.remove("fadeIn")},200)});else{const o=document.createElement("ul"),a=document.createElement("li");a.innerHTML="&#xFF0B; Create new "+this.template.label+"...",a.dataset.value="new",a.classList.add("large"),o.appendChild(a);const l=document.createElement("li");l.classList.add("divider"),o.appendChild(l);const u=document.createElement("li");u.classList.add("header"),u.innerText="Or link existing:",o.appendChild(u);for(const f of n){const h=document.createElement("li"),m=typeof f.value=="string"?f.value:f.value.value;h.innerText=f.label?f.label:m,h.dataset.value=JSON.stringify(f.value),o.appendChild(h)}e.appendChild(o),e.collapsibleWidth="250px",e.collapsibleOrientationLeft="",e.addEventListener("change",()=>{if(e.value==="new")this.addPropertyInstance();else{const f=JSON.parse(e.value);this.container.insertBefore(Cs(this.template,f,!0,!0),e)}e.value=""})}return e}}function Cs(i,e,n=!1,r=!1){let o;if(i.nodeShapes.size){o=document.createElement("div"),o.classList.add("property-instance");for(const a of i.nodeShapes)o.appendChild(new Ei(a,e,i.nodeKind,i.label,r))}else{const a=Xm(i.path,i.datatype?.value);a?i.config.editMode&&!r?o=a.createEditor(i,e):o=a.createViewer(i,e):o=qf(i,e||null,i.config.editMode&&!r),o.classList.add("property-instance"),r&&o.classList.add("linked")}return i.config.editMode&&lp(o,i.label,i.config.theme.dense,i.config.hierarchyColorsStyleSheet!==void 0,n),o.dataset.path=i.path,o}function lp(i,e,n,r,o=!1){const a=document.createElement("div");a.className="remove-button-wrapper",r&&a.classList.add("colorize");const l=new Nn;l.classList.add("remove-button","clear"),l.title="Remove "+e,l.dense=n,l.icon=!0,l.addEventListener("click",u=>{i.classList.remove("fadeIn"),i.classList.add("fadeOut"),setTimeout(()=>{const f=i.parentElement;i.remove(),f?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},200)}),o&&l.classList.add("persistent"),a.appendChild(l),i.appendChild(a)}window.customElements.define("shacl-property",$s);function W_(i,e){let n=i;const r=e.store.getQuads(i,null,null,null),o=Or(r,"label",Xs,e.languages);o&&(n=o);let a;if(e.attributes.collapse!==null)a=new Ct,a.classList.add("collapsible"),a.open=e.attributes.collapse==="open",a.label=n;else{a=document.createElement("div");const u=document.createElement("h1");u.innerText=n,a.appendChild(u)}a.dataset.subject=i,a.classList.add("shacl-group");const l=Or(r,"order");return l&&(a.style.order=l),a}const Tt=[];for(let i=0;i<256;++i)Tt.push((i+256).toString(16).slice(1));function Z_(i,e=0){return(Tt[i[e+0]]+Tt[i[e+1]]+Tt[i[e+2]]+Tt[i[e+3]]+"-"+Tt[i[e+4]]+Tt[i[e+5]]+"-"+Tt[i[e+6]]+Tt[i[e+7]]+"-"+Tt[i[e+8]]+Tt[i[e+9]]+"-"+Tt[i[e+10]]+Tt[i[e+11]]+Tt[i[e+12]]+Tt[i[e+13]]+Tt[i[e+14]]+Tt[i[e+15]]).toLowerCase()}let el;const X_=new Uint8Array(16);function Q_(){if(!el){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");el=crypto.getRandomValues.bind(crypto)}return el(X_)}const J_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),rh={randomUUID:J_};function K_(i,e,n){i=i||{};const r=i.random??i.rng?.()??Q_();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Z_(r)}function sh(i,e,n){return rh.randomUUID&&!i?rh.randomUUID():K_(i)}class Ei extends HTMLElement{constructor(e,n,r,o,a){super(),this.template=e,this.linked=a||!1;let l=n;l||(!r&&e.nodeKind&&(r=e.nodeKind),r===void 0&&e.config.attributes.valuesNamespace||r?.value===`${Fe}IRI`?l=ze.namedNode(e.config.attributes.valuesNamespace+sh()):l=ze.blankNode(sh())),this.nodeId=l;const u=JSON.stringify([e.id,n]);if(n&&e.config.renderedNodes.has(u)){o=o||"Link";const f=document.createElement("label");f.innerText=o,f.classList.add("linked"),this.appendChild(f);const h=document.createElement("a");let m=n.termType==="BlankNode"?"_:"+n.value:n.value;h.innerText=m,h.classList.add("ref-link"),h.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${m}']`)?.scrollIntoView()},this.appendChild(h),this.style.flexDirection="row"}else{if(n&&e.config.renderedNodes.add(u),this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){const f=document.createElement("div");f.innerText=`id: ${this.nodeId.id}`,f.classList.add("node-id-display"),this.appendChild(f)}(async()=>{for(const[f,h]of Object.entries(e.properties))for(const m of h)await this.addPropertyInstance(m,n);for(const f of e.extendedShapes)this.prepend(new Ei(f,n));if(e.or?.length&&await this.tryResolve(e.or,n,e.config),e.xone?.length&&await this.tryResolve(e.xone,n,e.config),o){const f=document.createElement("h1");f.innerText=o,this.prepend(f)}})()}}toRDF(e,n,r=""){if(n||(n=this.nodeId),!this.linked){for(const o of this.querySelectorAll(":scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property"))o.toRDF(e,n);this.template.targetClass&&e.addQuad(n,Rt,this.template.targetClass,this.template.config.valuesGraphId),r&&e.addQuad(n,ze.namedNode(r),this.template.id,this.template.config.valuesGraphId)}return n}async addPropertyInstance(e,n){let r=this;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let a=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);a||(a=W_(e.group,e.config),this.appendChild(a)),r=a}else console.warn("ignoring unknown group reference",e.group,"existing groups:",e.config.groups);const o=new $s(e,this);await o.bindValues(n),(e.config.editMode||o.instanceCount()>0)&&(r.appendChild(o),o.updateControls())}async tryResolve(e,n,r){let o=!1;if(n){const a=qm(e,n,r);if(a.length){for(const l of a)await this.addPropertyInstance(r.getPropertyTemplate(l,this.template),n);o=!0}}o||this.appendChild($f(e,this,r))}}window.customElements.define("shacl-node",Ei);const Y_=`
373
+ `;Ur=U_([_n("rokit-snackbar")],Ur);class $s extends HTMLElement{constructor(e,n){if(super(),this.template=e,this.parent=n,this.container=this,this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){const r=new Ct;r.classList.add("collapsible","shacl-group"),r.open=e.config.attributes.collapse==="open",r.label=this.template.label,this.container=r,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!n.linked&&(this.addButton=this.createAddButton(),this.container.appendChild(this.addButton),this.addEventListener("change",()=>{this.updateControls()}))}async bindValues(e,n){if(this.template.path){let r=!1;if(e){let o=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:on);n&&(o=await this.filterValidValues(o,e));for(const a of o)this.template.config.store.delete(a),this.addPropertyInstance(a.object),this.template.hasValue&&a.object.equals(this.template.hasValue)&&(r=!0)}this.template.config.editMode&&(this.template.hasValue&&!r&&!this.parent.linked&&this.addPropertyInstance(this.template.hasValue),this.updateControls())}}addPropertyInstance(e){let n;if(this.template.or?.length||this.template.xone?.length){const r=this.template.or?.length?this.template.or:this.template.xone;let o=!1;if(e){const a=$m(r,e,this.template.config);if(a.length){const l=Wl(jf(this.template),a);n=Cs(l,e,!0),o=!0}}o||(n=$f(r,this,this.template.config),lp(n,"",this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else{let r=!1;if(e&&!(e instanceof Wt)){const o=this.getRdfClassToLinkOrCreate();o&&this.template.config.store.countQuads(e,Rt,o,on)===0&&(r=!0)}n=Cs(this.template,e,void 0,r||this.parent.linked)}return this.addButton?this.container.insertBefore(n,this.addButton):this.container.appendChild(n),n}updateControls(){let e=this.instanceCount();e===0&&(this.template.nodeShapes.size===0||this.template.aggregatedMinCount>0)&&(this.addPropertyInstance(),e=this.instanceCount());let n;this.template.aggregatedMinCount>0?n=e>this.template.aggregatedMinCount:n=this.template.nodeShapes.size>0||e>1;const r=this.template.maxCount===void 0||e<this.template.maxCount;this.classList.toggle("may-remove",n),this.classList.toggle("may-add",r)}instanceCount(){return this.querySelectorAll(":scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance").length}toRDF(e,n){const r=ze.namedNode(this.template.path);for(const o of this.querySelectorAll(":scope > .property-instance, :scope > .collapsible > .property-instance"))if(o.firstChild instanceof Ei){const a=o.firstChild.toRDF(e);e.addQuad(n,r,a,this.template.config.valuesGraphId)}else for(const a of o.querySelectorAll(":scope > .editor")){const l=Gm(a);l&&e.addQuad(n,r,l,this.template.config.valuesGraphId)}}getRdfClassToLinkOrCreate(){if(this.template.class&&this.template.nodeShapes.size)return this.template.class;for(const e of this.template.nodeShapes)if(e.targetClass)return e.targetClass}async filterValidValues(e,n){let r=this.template.id,o=[n];if(this.template.qualifiedValueShape){r=this.template.qualifiedValueShape.id,o=[];for(const u of e)o.push(u.object)}const a=await this.template.config.validator.validate({dataset:this.template.config.store,terms:o},[{terms:[r]}]),l=[];for(const u of a.results){const f=this.template.qualifiedValueShape?u.focusNode:u.value;f?.ptrs?.length&&l.push(f.ptrs[0]._term.id)}return e.filter(u=>l.indexOf(u.object.id)===-1)}createAddButton(){const e=new ht;e.dense=this.template.config.theme.dense,e.label="+ "+this.template.label,e.title="Add "+this.template.label,e.autoGrowLabelWidth=!0,e.classList.add("add-button");let n=[],r=this.getRdfClassToLinkOrCreate();if(r&&(n=ql(r,this.template)),n.length===0)e.emptyMessage="",e.inputMinWidth=0,e.addEventListener("click",o=>{e.blur();const a=this.addPropertyInstance();a.classList.add("fadeIn"),this.updateControls(),setTimeout(()=>{Kg(a),a.classList.remove("fadeIn")},200)});else{const o=document.createElement("ul"),a=document.createElement("li");a.innerHTML="&#xFF0B; Create new "+this.template.label+"...",a.dataset.value="new",a.classList.add("large"),o.appendChild(a);const l=document.createElement("li");l.classList.add("divider"),o.appendChild(l);const u=document.createElement("li");u.classList.add("header"),u.innerText="Or link existing:",o.appendChild(u);for(const f of n){const h=document.createElement("li"),m=typeof f.value=="string"?f.value:f.value.value;h.innerText=f.label?f.label:m,h.dataset.value=JSON.stringify(f.value),o.appendChild(h)}e.appendChild(o),e.collapsibleWidth="250px",e.collapsibleOrientationLeft="",e.addEventListener("change",()=>{if(e.value==="new")this.addPropertyInstance();else{const f=JSON.parse(e.value);this.container.insertBefore(Cs(this.template,f,!0,!0),e)}e.value=""})}return e}}function Cs(i,e,n=!1,r=!1){let o;if(i.nodeShapes.size){o=document.createElement("div"),o.classList.add("property-instance");for(const a of i.nodeShapes)o.appendChild(new Ei(a,e,i.nodeKind,i.label,r))}else{const a=Xm(i.path,i.datatype?.value);a?i.config.editMode&&!r?o=a.createEditor(i,e):o=a.createViewer(i,e):o=qf(i,e||null,i.config.editMode&&!r),o.classList.add("property-instance"),r&&o.classList.add("linked")}return i.config.editMode&&lp(o,i.label,i.config.theme.dense,i.config.hierarchyColorsStyleSheet!==void 0,n),o.dataset.path=i.path,o}function lp(i,e,n,r,o=!1){const a=document.createElement("div");a.className="remove-button-wrapper",r&&a.classList.add("colorize");const l=new Nn;l.classList.add("remove-button","clear"),l.title="Remove "+e,l.dense=n,l.icon=!0,l.addEventListener("click",u=>{i.classList.remove("fadeIn"),i.classList.add("fadeOut"),setTimeout(()=>{const f=i.parentElement;i.remove(),f?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},200)}),o&&l.classList.add("persistent"),a.appendChild(l),i.appendChild(a)}window.customElements.define("shacl-property",$s);function W_(i,e){let n=i;const r=e.store.getQuads(i,null,null,null),o=Or(r,"label",Xs,e.languages);o&&(n=o);let a;if(e.attributes.collapse!==null)a=new Ct,a.classList.add("collapsible"),a.open=e.attributes.collapse==="open",a.label=n;else{a=document.createElement("div");const u=document.createElement("h1");u.innerText=n,a.appendChild(u)}a.dataset.subject=i,a.classList.add("shacl-group");const l=Or(r,"order");return l&&(a.style.order=l),a}const Tt=[];for(let i=0;i<256;++i)Tt.push((i+256).toString(16).slice(1));function Z_(i,e=0){return(Tt[i[e+0]]+Tt[i[e+1]]+Tt[i[e+2]]+Tt[i[e+3]]+"-"+Tt[i[e+4]]+Tt[i[e+5]]+"-"+Tt[i[e+6]]+Tt[i[e+7]]+"-"+Tt[i[e+8]]+Tt[i[e+9]]+"-"+Tt[i[e+10]]+Tt[i[e+11]]+Tt[i[e+12]]+Tt[i[e+13]]+Tt[i[e+14]]+Tt[i[e+15]]).toLowerCase()}let el;const X_=new Uint8Array(16);function Q_(){if(!el){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");el=crypto.getRandomValues.bind(crypto)}return el(X_)}const J_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),rh={randomUUID:J_};function K_(i,e,n){i=i||{};const r=i.random??i.rng?.()??Q_();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Z_(r)}function sh(i,e,n){return rh.randomUUID&&!i?rh.randomUUID():K_(i)}class Ei extends HTMLElement{constructor(e,n,r,o,a){super(),this.template=e,this.linked=a||!1;let l=n;l||(!r&&e.nodeKind&&(r=e.nodeKind),r===void 0&&e.config.attributes.valuesNamespace||r?.value===`${Fe}IRI`?l=ze.namedNode(e.config.attributes.valuesNamespace+sh()):l=ze.blankNode(sh())),this.nodeId=l;const u=JSON.stringify([e.id,n]);if(n&&e.config.renderedNodes.has(u)){o=o||"Link";const f=document.createElement("label");f.innerText=o,f.classList.add("linked"),this.appendChild(f);const h=document.createElement("a");let m=n.termType==="BlankNode"?"_:"+n.value:n.value;h.innerText=m,h.classList.add("ref-link"),h.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${m}']`)?.scrollIntoView()},this.appendChild(h),this.style.flexDirection="row"}else{if(n&&e.config.renderedNodes.add(u),this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){const f=document.createElement("div");f.innerText=`id: ${this.nodeId.id}`,f.classList.add("node-id-display"),this.appendChild(f)}(async()=>{for(const[f,h]of Object.entries(e.properties))for(const m of h)await this.addPropertyInstance(m,n,h.length>1);for(const f of e.extendedShapes)this.prepend(new Ei(f,n));if(e.or?.length&&await this.tryResolve(e.or,n,e.config),e.xone?.length&&await this.tryResolve(e.xone,n,e.config),o){const f=document.createElement("h1");f.innerText=o,this.prepend(f)}})()}}toRDF(e,n,r=""){if(n||(n=this.nodeId),!this.linked){for(const o of this.querySelectorAll(":scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property"))o.toRDF(e,n);this.template.targetClass&&e.addQuad(n,Rt,this.template.targetClass,this.template.config.valuesGraphId),r&&e.addQuad(n,ze.namedNode(r),this.template.id,this.template.config.valuesGraphId)}return n}async addPropertyInstance(e,n,r){let o=this;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let l=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);l||(l=W_(e.group,e.config),this.appendChild(l)),o=l}else console.warn("ignoring unknown group reference",e.group,"existing groups:",e.config.groups);const a=new $s(e,this);await a.bindValues(n,r),(e.config.editMode||a.instanceCount()>0)&&(o.appendChild(a),a.updateControls())}async tryResolve(e,n,r){let o=!1;if(n){const a=qm(e,n,r);if(a.length){for(const l of a)await this.addPropertyInstance(r.getPropertyTemplate(l,this.template),n);o=!0}}o||this.appendChild($f(e,this,r))}}window.customElements.define("shacl-node",Ei);const Y_=`
374
374
  .editor:not([type='checkbox']) { border: 1px solid #DDD; }
375
375
  .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; }
376
376
  .property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
package/dist/index.js CHANGED
@@ -62,7 +62,7 @@ h3 { margin-top: 0; }
62
62
  }
63
63
  .property-instance:not(:has(shacl-node)) > .remove-button-wrapper.colorize::before { background: 0; }
64
64
  `;class He{constructor(e){this.dense=!0;let s=Ue;e&&(s+=`
65
- `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(s)}apply(e){}setDense(e){this.dense=e}createViewer(e,s,i){const n=document.createElement("div"),o=document.createElement("label");o.innerHTML=e+":",i.description&&o.setAttribute("title",i.description.value),n.appendChild(o);let a=s.value,r=null;if(s instanceof $){const c=i.config.store.getQuads(a,null,null,null);if(c.length){const f=R(c,i.config.languages);f&&(a=f)}}else s instanceof S&&(s.language?(r=document.createElement("span"),r.classList.add("lang"),r.innerText=`@${s.language}`):s.datatype.value===`${E}date`?a=new Date(Date.parse(s.value)).toDateString():s.datatype.value===`${E}dateTime`&&(a=new Date(Date.parse(s.value)).toLocaleString()));let l;return J(s.value)?(l=document.createElement("a"),l.setAttribute("href",s.value)):l=document.createElement("div"),l.classList.add("d-flex"),l.innerText=a,r&&l.appendChild(r),n.appendChild(l),n}}function Ke(t,e,s){if(s){const i=t.aggregatedMinCount>0;if(t.class&&!t.hasValue)return t.config.theme.createListEditor(t.label,e,i,ie(t.class,t),t);if(t.in){const n=t.config.lists[t.in];if(n?.length){const o=ye(n,t.config.store,t.config.languages);return t.config.theme.createListEditor(t.label,e,i,o,t)}else console.error("list not found:",t.in,"existing lists:",t.config.lists)}if(t.datatype?.equals(be)||t.languageIn?.length||t.datatype===void 0&&e instanceof S&&e.language)return t.config.theme.createLangStringEditor(t.label,e,i,t);switch(t.datatype?.value.replace(E,"")){case"integer":case"float":case"double":case"decimal":return t.config.theme.createNumberEditor(t.label,e,i,t);case"date":case"dateTime":return t.config.theme.createDateEditor(t.label,e,i,t);case"boolean":return t.config.theme.createBooleanEditor(t.label,e,i,t);case"base64Binary":return t.config.theme.createFileEditor(t.label,e,i,t)}return t.config.theme.createTextEditor(t.label,e,i,t)}else{if(e)return t.config.theme.createViewer(t.label,e,t);const i=document.createElement("div");return i.innerHTML="No value",i}}function We(t,e,s){if(e==="application/ld+json")return Xe(t);{const i=new Ie({format:e,prefixes:s});i.addQuads(t);let n="";return i.end((o,a)=>{o&&console.error(o),n=a}),n}}function Xe(t){const e=[];for(const s of t){const i={"@id":s.subject.id};if(s.predicate===g)i["@type"]=s.object.id;else{let n=s.object.value;s.object instanceof S?s.object.language?n={"@language":s.object.language,"@value":s.object.value}:s.object.datatype&&s.object.datatype.value!==`${E}#string`&&(n={"@type":s.object.datatype.value,"@value":s.object.value}):n={"@id":s.object.id},i[s.predicate.value]=n}e.push(i)}return JSON.stringify(e)}function Je(t){let e=t.shaclDatatype,s=t.dataset.value||t.value;if(s){if(s.startsWith("<")&&s.endsWith(">")&&s.indexOf(":")>-1)return u.namedNode(s.substring(1,s.length-1));if(t.dataset.class||t.dataset.nodeKind===d+"IRI")return u.namedNode(s);if(t.dataset.link)return JSON.parse(t.dataset.link);if(t.dataset.lang?e=t.dataset.lang:t.type==="number"?s=parseFloat(s):t.type==="file"&&t.binaryData?s=t.binaryData:t.type==="datetime-local"&&(s=new Date(s).toISOString().slice(0,19)),(!e||e instanceof $&&ke.equals(e))&&typeof s=="string"){let i=s.split("^^");i.length===2&&i[0].startsWith('"')&&i[0].endsWith('"')&&i[1].split(":").length===2?(s=i[0].substring(1,i[0].length-1),e=u.namedNode(i[1])):(i=s.split("@"),i.length===2&&i[0].startsWith('"')&&i[0].endsWith('"')?(s=i[0].substring(1,i[0].length-1),e=i[1]):s.startsWith('"')&&s.endsWith('"')&&(s=s.substring(1,s.length-1)))}return u.literal(s,e)}else if((t.type==="checkbox"||t.getAttribute("type")==="checkbox")&&(t.checked||parseInt(t.dataset.minCount||"0")>0))return u.literal(t.checked?"true":"false",e)}const D={};function Ye(t){t.predicate===void 0&&t.datatype===void 0?console.warn('not registering plugin because it does neither define "predicate" nor "datatype"',t):D[`${t.predicate}^${t.datatype}`]=t}function Ze(){return Object.entries(D).map(t=>t[1])}function et(t,e){let s=D[`${t}^${e}`];return s||(s=D[`${t}^undefined`],s)?s:D[`undefined^${e}`]}class mt{constructor(e,s){this.predicate=e.predicate,this.datatype=e.datatype,s&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(s))}createViewer(e,s){return e.config.theme.createViewer(e.label,s,e)}}class M extends HTMLElement{constructor(e,s){if(super(),this.template=e,this.parent=s,this.container=this,this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){const i=new ee;i.classList.add("collapsible","shacl-group"),i.open=e.config.attributes.collapse==="open",i.label=this.template.label,this.container=i,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!s.linked&&(this.addButton=this.createAddButton(),this.container.appendChild(this.addButton),this.addEventListener("change",()=>{this.updateControls()}))}async bindValues(e){if(this.template.path){let s=!1;if(e){let i=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:b);i=await this.filterValidValues(i,e);for(const n of i)this.template.config.store.delete(n),this.addPropertyInstance(n.object),this.template.hasValue&&n.object.equals(this.template.hasValue)&&(s=!0)}this.template.config.editMode&&(this.template.hasValue&&!s&&!this.parent.linked&&this.addPropertyInstance(this.template.hasValue),this.updateControls())}}addPropertyInstance(e){let s;if(this.template.or?.length||this.template.xone?.length){const i=this.template.or?.length?this.template.or:this.template.xone;let n=!1;if(e){const o=ze(i,e,this.template.config);if(o.length){const a=oe(Ee(this.template),o);s=q(a,e,!0),n=!0}}n||(s=xe(i,this,this.template.config),Le(s,"",this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else{let i=!1;if(e&&!(e instanceof S)){const n=this.getRdfClassToLinkOrCreate();n&&this.template.config.store.countQuads(e,g,n,b)===0&&(i=!0)}s=q(this.template,e,void 0,i||this.parent.linked)}return this.addButton?this.container.insertBefore(s,this.addButton):this.container.appendChild(s),s}updateControls(){let e=this.instanceCount();e===0&&(this.template.nodeShapes.size===0||this.template.aggregatedMinCount>0)&&(this.addPropertyInstance(),e=this.instanceCount());let s;this.template.aggregatedMinCount>0?s=e>this.template.aggregatedMinCount:s=this.template.nodeShapes.size>0||e>1;const i=this.template.maxCount===void 0||e<this.template.maxCount;this.classList.toggle("may-remove",s),this.classList.toggle("may-add",i)}instanceCount(){return this.querySelectorAll(":scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance").length}toRDF(e,s){const i=u.namedNode(this.template.path);for(const n of this.querySelectorAll(":scope > .property-instance, :scope > .collapsible > .property-instance"))if(n.firstChild instanceof I){const o=n.firstChild.toRDF(e);e.addQuad(s,i,o,this.template.config.valuesGraphId)}else for(const o of n.querySelectorAll(":scope > .editor")){const a=Je(o);a&&e.addQuad(s,i,a,this.template.config.valuesGraphId)}}getRdfClassToLinkOrCreate(){if(this.template.class&&this.template.nodeShapes.size)return this.template.class;for(const e of this.template.nodeShapes)if(e.targetClass)return e.targetClass}async filterValidValues(e,s){let i=this.template.id,n=[s];if(this.template.qualifiedValueShape){i=this.template.qualifiedValueShape.id,n=[];for(const r of e)n.push(r.object)}const o=await this.template.config.validator.validate({dataset:this.template.config.store,terms:n},[{terms:[i]}]),a=[];for(const r of o.results){const l=this.template.qualifiedValueShape?r.focusNode:r.value;l?.ptrs?.length&&a.push(l.ptrs[0]._term.id)}return e.filter(r=>a.indexOf(r.object.id)===-1)}createAddButton(){const e=new ge;e.dense=this.template.config.theme.dense,e.label="+ "+this.template.label,e.title="Add "+this.template.label,e.autoGrowLabelWidth=!0,e.classList.add("add-button");let s=[],i=this.getRdfClassToLinkOrCreate();if(i&&(s=ie(i,this.template)),s.length===0)e.emptyMessage="",e.inputMinWidth=0,e.addEventListener("click",n=>{e.blur();const o=this.addPropertyInstance();o.classList.add("fadeIn"),this.updateControls(),setTimeout(()=>{Ve(o),o.classList.remove("fadeIn")},200)});else{const n=document.createElement("ul"),o=document.createElement("li");o.innerHTML="&#xFF0B; Create new "+this.template.label+"...",o.dataset.value="new",o.classList.add("large"),n.appendChild(o);const a=document.createElement("li");a.classList.add("divider"),n.appendChild(a);const r=document.createElement("li");r.classList.add("header"),r.innerText="Or link existing:",n.appendChild(r);for(const l of s){const c=document.createElement("li"),f=typeof l.value=="string"?l.value:l.value.value;c.innerText=l.label?l.label:f,c.dataset.value=JSON.stringify(l.value),n.appendChild(c)}e.appendChild(n),e.collapsibleWidth="250px",e.collapsibleOrientationLeft="",e.addEventListener("change",()=>{if(e.value==="new")this.addPropertyInstance();else{const l=JSON.parse(e.value);this.container.insertBefore(q(this.template,l,!0,!0),e)}e.value=""})}return e}}function q(t,e,s=!1,i=!1){let n;if(t.nodeShapes.size){n=document.createElement("div"),n.classList.add("property-instance");for(const o of t.nodeShapes)n.appendChild(new I(o,e,t.nodeKind,t.label,i))}else{const o=et(t.path,t.datatype?.value);o?t.config.editMode&&!i?n=o.createEditor(t,e):n=o.createViewer(t,e):n=Ke(t,e||null,t.config.editMode&&!i),n.classList.add("property-instance"),i&&n.classList.add("linked")}return t.config.editMode&&Le(n,t.label,t.config.theme.dense,t.config.hierarchyColorsStyleSheet!==void 0,s),n.dataset.path=t.path,n}function Le(t,e,s,i,n=!1){const o=document.createElement("div");o.className="remove-button-wrapper",i&&o.classList.add("colorize");const a=new $e;a.classList.add("remove-button","clear"),a.title="Remove "+e,a.dense=s,a.icon=!0,a.addEventListener("click",r=>{t.classList.remove("fadeIn"),t.classList.add("fadeOut"),setTimeout(()=>{const l=t.parentElement;t.remove(),l?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},200)}),n&&a.classList.add("persistent"),o.appendChild(a),t.appendChild(o)}window.customElements.define("shacl-property",M);function tt(t,e){let s=t;const i=e.store.getQuads(t,null,null,null),n=P(i,"label",B,e.languages);n&&(s=n);let o;if(e.attributes.collapse!==null)o=new ee,o.classList.add("collapsible"),o.open=e.attributes.collapse==="open",o.label=s;else{o=document.createElement("div");const r=document.createElement("h1");r.innerText=s,o.appendChild(r)}o.dataset.subject=t,o.classList.add("shacl-group");const a=P(i,"order");return a&&(o.style.order=a),o}class I extends HTMLElement{constructor(e,s,i,n,o){super(),this.template=e,this.linked=o||!1;let a=s;a||(!i&&e.nodeKind&&(i=e.nodeKind),i===void 0&&e.config.attributes.valuesNamespace||i?.value===`${d}IRI`?a=u.namedNode(e.config.attributes.valuesNamespace+re()):a=u.blankNode(re())),this.nodeId=a;const r=JSON.stringify([e.id,s]);if(s&&e.config.renderedNodes.has(r)){n=n||"Link";const l=document.createElement("label");l.innerText=n,l.classList.add("linked"),this.appendChild(l);const c=document.createElement("a");let f=s.termType==="BlankNode"?"_:"+s.value:s.value;c.innerText=f,c.classList.add("ref-link"),c.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${f}']`)?.scrollIntoView()},this.appendChild(c),this.style.flexDirection="row"}else{if(s&&e.config.renderedNodes.add(r),this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){const l=document.createElement("div");l.innerText=`id: ${this.nodeId.id}`,l.classList.add("node-id-display"),this.appendChild(l)}(async()=>{for(const[l,c]of Object.entries(e.properties))for(const f of c)await this.addPropertyInstance(f,s);for(const l of e.extendedShapes)this.prepend(new I(l,s));if(e.or?.length&&await this.tryResolve(e.or,s,e.config),e.xone?.length&&await this.tryResolve(e.xone,s,e.config),n){const l=document.createElement("h1");l.innerText=n,this.prepend(l)}})()}}toRDF(e,s,i=""){if(s||(s=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,s);this.template.targetClass&&e.addQuad(s,g,this.template.targetClass,this.template.config.valuesGraphId),i&&e.addQuad(s,u.namedNode(i),this.template.id,this.template.config.valuesGraphId)}return s}async addPropertyInstance(e,s){let i=this;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let o=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);o||(o=tt(e.group,e.config),this.appendChild(o)),i=o}else console.warn("ignoring unknown group reference",e.group,"existing groups:",e.config.groups);const n=new M(e,this);await n.bindValues(s),(e.config.editMode||n.instanceCount()>0)&&(i.appendChild(n),n.updateControls())}async tryResolve(e,s,i){let n=!1;if(s){const o=Ge(e,s,i);if(o.length){for(const a of o)await this.addPropertyInstance(i.getPropertyTemplate(a,this.template),s);n=!0}}n||this.appendChild(xe(e,this,i))}}window.customElements.define("shacl-node",I);const st=`
65
+ `+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(s)}apply(e){}setDense(e){this.dense=e}createViewer(e,s,i){const n=document.createElement("div"),o=document.createElement("label");o.innerHTML=e+":",i.description&&o.setAttribute("title",i.description.value),n.appendChild(o);let a=s.value,r=null;if(s instanceof $){const c=i.config.store.getQuads(a,null,null,null);if(c.length){const f=R(c,i.config.languages);f&&(a=f)}}else s instanceof S&&(s.language?(r=document.createElement("span"),r.classList.add("lang"),r.innerText=`@${s.language}`):s.datatype.value===`${E}date`?a=new Date(Date.parse(s.value)).toDateString():s.datatype.value===`${E}dateTime`&&(a=new Date(Date.parse(s.value)).toLocaleString()));let l;return J(s.value)?(l=document.createElement("a"),l.setAttribute("href",s.value)):l=document.createElement("div"),l.classList.add("d-flex"),l.innerText=a,r&&l.appendChild(r),n.appendChild(l),n}}function Ke(t,e,s){if(s){const i=t.aggregatedMinCount>0;if(t.class&&!t.hasValue)return t.config.theme.createListEditor(t.label,e,i,ie(t.class,t),t);if(t.in){const n=t.config.lists[t.in];if(n?.length){const o=ye(n,t.config.store,t.config.languages);return t.config.theme.createListEditor(t.label,e,i,o,t)}else console.error("list not found:",t.in,"existing lists:",t.config.lists)}if(t.datatype?.equals(be)||t.languageIn?.length||t.datatype===void 0&&e instanceof S&&e.language)return t.config.theme.createLangStringEditor(t.label,e,i,t);switch(t.datatype?.value.replace(E,"")){case"integer":case"float":case"double":case"decimal":return t.config.theme.createNumberEditor(t.label,e,i,t);case"date":case"dateTime":return t.config.theme.createDateEditor(t.label,e,i,t);case"boolean":return t.config.theme.createBooleanEditor(t.label,e,i,t);case"base64Binary":return t.config.theme.createFileEditor(t.label,e,i,t)}return t.config.theme.createTextEditor(t.label,e,i,t)}else{if(e)return t.config.theme.createViewer(t.label,e,t);const i=document.createElement("div");return i.innerHTML="No value",i}}function We(t,e,s){if(e==="application/ld+json")return Xe(t);{const i=new Ie({format:e,prefixes:s});i.addQuads(t);let n="";return i.end((o,a)=>{o&&console.error(o),n=a}),n}}function Xe(t){const e=[];for(const s of t){const i={"@id":s.subject.id};if(s.predicate===g)i["@type"]=s.object.id;else{let n=s.object.value;s.object instanceof S?s.object.language?n={"@language":s.object.language,"@value":s.object.value}:s.object.datatype&&s.object.datatype.value!==`${E}#string`&&(n={"@type":s.object.datatype.value,"@value":s.object.value}):n={"@id":s.object.id},i[s.predicate.value]=n}e.push(i)}return JSON.stringify(e)}function Je(t){let e=t.shaclDatatype,s=t.dataset.value||t.value;if(s){if(s.startsWith("<")&&s.endsWith(">")&&s.indexOf(":")>-1)return u.namedNode(s.substring(1,s.length-1));if(t.dataset.class||t.dataset.nodeKind===d+"IRI")return u.namedNode(s);if(t.dataset.link)return JSON.parse(t.dataset.link);if(t.dataset.lang?e=t.dataset.lang:t.type==="number"?s=parseFloat(s):t.type==="file"&&t.binaryData?s=t.binaryData:t.type==="datetime-local"&&(s=new Date(s).toISOString().slice(0,19)),(!e||e instanceof $&&ke.equals(e))&&typeof s=="string"){let i=s.split("^^");i.length===2&&i[0].startsWith('"')&&i[0].endsWith('"')&&i[1].split(":").length===2?(s=i[0].substring(1,i[0].length-1),e=u.namedNode(i[1])):(i=s.split("@"),i.length===2&&i[0].startsWith('"')&&i[0].endsWith('"')?(s=i[0].substring(1,i[0].length-1),e=i[1]):s.startsWith('"')&&s.endsWith('"')&&(s=s.substring(1,s.length-1)))}return u.literal(s,e)}else if((t.type==="checkbox"||t.getAttribute("type")==="checkbox")&&(t.checked||parseInt(t.dataset.minCount||"0")>0))return u.literal(t.checked?"true":"false",e)}const D={};function Ye(t){t.predicate===void 0&&t.datatype===void 0?console.warn('not registering plugin because it does neither define "predicate" nor "datatype"',t):D[`${t.predicate}^${t.datatype}`]=t}function Ze(){return Object.entries(D).map(t=>t[1])}function et(t,e){let s=D[`${t}^${e}`];return s||(s=D[`${t}^undefined`],s)?s:D[`undefined^${e}`]}class mt{constructor(e,s){this.predicate=e.predicate,this.datatype=e.datatype,s&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(s))}createViewer(e,s){return e.config.theme.createViewer(e.label,s,e)}}class M extends HTMLElement{constructor(e,s){if(super(),this.template=e,this.parent=s,this.container=this,this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){const i=new ee;i.classList.add("collapsible","shacl-group"),i.open=e.config.attributes.collapse==="open",i.label=this.template.label,this.container=i,this.appendChild(this.container)}this.template.order!==void 0&&(this.style.order=`${this.template.order}`),this.template.cssClass&&this.classList.add(this.template.cssClass),e.config.editMode&&!s.linked&&(this.addButton=this.createAddButton(),this.container.appendChild(this.addButton),this.addEventListener("change",()=>{this.updateControls()}))}async bindValues(e,s){if(this.template.path){let i=!1;if(e){let n=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:b);s&&(n=await this.filterValidValues(n,e));for(const o of n)this.template.config.store.delete(o),this.addPropertyInstance(o.object),this.template.hasValue&&o.object.equals(this.template.hasValue)&&(i=!0)}this.template.config.editMode&&(this.template.hasValue&&!i&&!this.parent.linked&&this.addPropertyInstance(this.template.hasValue),this.updateControls())}}addPropertyInstance(e){let s;if(this.template.or?.length||this.template.xone?.length){const i=this.template.or?.length?this.template.or:this.template.xone;let n=!1;if(e){const o=ze(i,e,this.template.config);if(o.length){const a=oe(Ee(this.template),o);s=q(a,e,!0),n=!0}}n||(s=xe(i,this,this.template.config),Le(s,"",this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else{let i=!1;if(e&&!(e instanceof S)){const n=this.getRdfClassToLinkOrCreate();n&&this.template.config.store.countQuads(e,g,n,b)===0&&(i=!0)}s=q(this.template,e,void 0,i||this.parent.linked)}return this.addButton?this.container.insertBefore(s,this.addButton):this.container.appendChild(s),s}updateControls(){let e=this.instanceCount();e===0&&(this.template.nodeShapes.size===0||this.template.aggregatedMinCount>0)&&(this.addPropertyInstance(),e=this.instanceCount());let s;this.template.aggregatedMinCount>0?s=e>this.template.aggregatedMinCount:s=this.template.nodeShapes.size>0||e>1;const i=this.template.maxCount===void 0||e<this.template.maxCount;this.classList.toggle("may-remove",s),this.classList.toggle("may-add",i)}instanceCount(){return this.querySelectorAll(":scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance").length}toRDF(e,s){const i=u.namedNode(this.template.path);for(const n of this.querySelectorAll(":scope > .property-instance, :scope > .collapsible > .property-instance"))if(n.firstChild instanceof I){const o=n.firstChild.toRDF(e);e.addQuad(s,i,o,this.template.config.valuesGraphId)}else for(const o of n.querySelectorAll(":scope > .editor")){const a=Je(o);a&&e.addQuad(s,i,a,this.template.config.valuesGraphId)}}getRdfClassToLinkOrCreate(){if(this.template.class&&this.template.nodeShapes.size)return this.template.class;for(const e of this.template.nodeShapes)if(e.targetClass)return e.targetClass}async filterValidValues(e,s){let i=this.template.id,n=[s];if(this.template.qualifiedValueShape){i=this.template.qualifiedValueShape.id,n=[];for(const r of e)n.push(r.object)}const o=await this.template.config.validator.validate({dataset:this.template.config.store,terms:n},[{terms:[i]}]),a=[];for(const r of o.results){const l=this.template.qualifiedValueShape?r.focusNode:r.value;l?.ptrs?.length&&a.push(l.ptrs[0]._term.id)}return e.filter(r=>a.indexOf(r.object.id)===-1)}createAddButton(){const e=new ge;e.dense=this.template.config.theme.dense,e.label="+ "+this.template.label,e.title="Add "+this.template.label,e.autoGrowLabelWidth=!0,e.classList.add("add-button");let s=[],i=this.getRdfClassToLinkOrCreate();if(i&&(s=ie(i,this.template)),s.length===0)e.emptyMessage="",e.inputMinWidth=0,e.addEventListener("click",n=>{e.blur();const o=this.addPropertyInstance();o.classList.add("fadeIn"),this.updateControls(),setTimeout(()=>{Ve(o),o.classList.remove("fadeIn")},200)});else{const n=document.createElement("ul"),o=document.createElement("li");o.innerHTML="&#xFF0B; Create new "+this.template.label+"...",o.dataset.value="new",o.classList.add("large"),n.appendChild(o);const a=document.createElement("li");a.classList.add("divider"),n.appendChild(a);const r=document.createElement("li");r.classList.add("header"),r.innerText="Or link existing:",n.appendChild(r);for(const l of s){const c=document.createElement("li"),f=typeof l.value=="string"?l.value:l.value.value;c.innerText=l.label?l.label:f,c.dataset.value=JSON.stringify(l.value),n.appendChild(c)}e.appendChild(n),e.collapsibleWidth="250px",e.collapsibleOrientationLeft="",e.addEventListener("change",()=>{if(e.value==="new")this.addPropertyInstance();else{const l=JSON.parse(e.value);this.container.insertBefore(q(this.template,l,!0,!0),e)}e.value=""})}return e}}function q(t,e,s=!1,i=!1){let n;if(t.nodeShapes.size){n=document.createElement("div"),n.classList.add("property-instance");for(const o of t.nodeShapes)n.appendChild(new I(o,e,t.nodeKind,t.label,i))}else{const o=et(t.path,t.datatype?.value);o?t.config.editMode&&!i?n=o.createEditor(t,e):n=o.createViewer(t,e):n=Ke(t,e||null,t.config.editMode&&!i),n.classList.add("property-instance"),i&&n.classList.add("linked")}return t.config.editMode&&Le(n,t.label,t.config.theme.dense,t.config.hierarchyColorsStyleSheet!==void 0,s),n.dataset.path=t.path,n}function Le(t,e,s,i,n=!1){const o=document.createElement("div");o.className="remove-button-wrapper",i&&o.classList.add("colorize");const a=new $e;a.classList.add("remove-button","clear"),a.title="Remove "+e,a.dense=s,a.icon=!0,a.addEventListener("click",r=>{t.classList.remove("fadeIn"),t.classList.add("fadeOut"),setTimeout(()=>{const l=t.parentElement;t.remove(),l?.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))},200)}),n&&a.classList.add("persistent"),o.appendChild(a),t.appendChild(o)}window.customElements.define("shacl-property",M);function tt(t,e){let s=t;const i=e.store.getQuads(t,null,null,null),n=P(i,"label",B,e.languages);n&&(s=n);let o;if(e.attributes.collapse!==null)o=new ee,o.classList.add("collapsible"),o.open=e.attributes.collapse==="open",o.label=s;else{o=document.createElement("div");const r=document.createElement("h1");r.innerText=s,o.appendChild(r)}o.dataset.subject=t,o.classList.add("shacl-group");const a=P(i,"order");return a&&(o.style.order=a),o}class I extends HTMLElement{constructor(e,s,i,n,o){super(),this.template=e,this.linked=o||!1;let a=s;a||(!i&&e.nodeKind&&(i=e.nodeKind),i===void 0&&e.config.attributes.valuesNamespace||i?.value===`${d}IRI`?a=u.namedNode(e.config.attributes.valuesNamespace+re()):a=u.blankNode(re())),this.nodeId=a;const r=JSON.stringify([e.id,s]);if(s&&e.config.renderedNodes.has(r)){n=n||"Link";const l=document.createElement("label");l.innerText=n,l.classList.add("linked"),this.appendChild(l);const c=document.createElement("a");let f=s.termType==="BlankNode"?"_:"+s.value:s.value;c.innerText=f,c.classList.add("ref-link"),c.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${f}']`)?.scrollIntoView()},this.appendChild(c),this.style.flexDirection="row"}else{if(s&&e.config.renderedNodes.add(r),this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){const l=document.createElement("div");l.innerText=`id: ${this.nodeId.id}`,l.classList.add("node-id-display"),this.appendChild(l)}(async()=>{for(const[l,c]of Object.entries(e.properties))for(const f of c)await this.addPropertyInstance(f,s,c.length>1);for(const l of e.extendedShapes)this.prepend(new I(l,s));if(e.or?.length&&await this.tryResolve(e.or,s,e.config),e.xone?.length&&await this.tryResolve(e.xone,s,e.config),n){const l=document.createElement("h1");l.innerText=n,this.prepend(l)}})()}}toRDF(e,s,i=""){if(s||(s=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,s);this.template.targetClass&&e.addQuad(s,g,this.template.targetClass,this.template.config.valuesGraphId),i&&e.addQuad(s,u.namedNode(i),this.template.id,this.template.config.valuesGraphId)}return s}async addPropertyInstance(e,s,i){let n=this;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let a=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);a||(a=tt(e.group,e.config),this.appendChild(a)),n=a}else console.warn("ignoring unknown group reference",e.group,"existing groups:",e.config.groups);const o=new M(e,this);await o.bindValues(s,i),(e.config.editMode||o.instanceCount()>0)&&(n.appendChild(o),o.updateControls())}async tryResolve(e,s,i){let n=!1;if(s){const o=Ge(e,s,i);if(o.length){for(const a of o)await this.addPropertyInstance(i.getPropertyTemplate(a,this.template),s);n=!0}}n||this.appendChild(xe(e,this,i))}}window.customElements.define("shacl-node",I);const st=`
66
66
  .editor:not([type='checkbox']) { border: 1px solid #DDD; }
67
67
  .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; }
68
68
  .property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
package/dist/node.d.ts CHANGED
@@ -9,6 +9,6 @@ export declare class ShaclNode extends HTMLElement {
9
9
  linked: boolean;
10
10
  constructor(template: ShaclNodeTemplate, valueSubject: NamedNode | BlankNode | undefined, nodeKind?: NamedNode, label?: string, linked?: boolean);
11
11
  toRDF(graph: Store, subject?: NamedNode | BlankNode, generateNodeShapeReference?: string): (NamedNode | BlankNode);
12
- addPropertyInstance(template: ShaclPropertyTemplate, valueSubject: NamedNode | BlankNode | undefined): Promise<void>;
12
+ addPropertyInstance(template: ShaclPropertyTemplate, valueSubject: NamedNode | BlankNode | undefined, multiValuedPath?: boolean): Promise<void>;
13
13
  tryResolve(options: Term[], valueSubject: NamedNode | BlankNode | undefined, config: Config): Promise<void>;
14
14
  }
@@ -9,7 +9,7 @@ export declare class ShaclProperty extends HTMLElement {
9
9
  container: HTMLElement;
10
10
  parent: ShaclNode;
11
11
  constructor(template: ShaclPropertyTemplate, parent: ShaclNode);
12
- bindValues(valueSubject: NamedNode | BlankNode | undefined): Promise<void>;
12
+ bindValues(valueSubject: NamedNode | BlankNode | undefined, multiValuedPath?: boolean): Promise<void>;
13
13
  addPropertyInstance(value?: Term): HTMLElement;
14
14
  updateControls(): void;
15
15
  instanceCount(): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulb-darmstadt/shacl-form",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "SHACL form generator",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",