@ulb-darmstadt/shacl-form 3.0.4 → 3.0.5
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 +78 -87
- package/dist/index.js +13 -14
- package/dist/plugins/assets/property-template-c2vtkOt_.js +1 -0
- package/dist/plugins/file-upload.js +1 -1
- package/dist/plugins/leaflet.js +5 -5
- package/dist/util.d.ts +1 -0
- package/package.json +11 -9
- package/dist/plugins/assets/property-template-BtuDp76T.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{DataFactory as h,StreamParser as ke,Store as ee,Literal as R,NamedNode as k,Writer as De}from"n3";import{RdfXmlParser as Ne}from"rdfxml-streaming-parser";import $e from"jsonld";import{RokitDialog as qe,RokitCollapsible as te,RokitButton as me,RokitInput as K,RokitTextArea as Oe,RokitSelect as _e}from"@ro-kit/ui-widgets";import{v4 as le}from"uuid";import{Validator as ce}from"shacl-engine";const u="http://www.w3.org/ns/shacl#",de="http://datashapes.org/dash#",x="http://www.w3.org/2001/XMLSchema#",I="http://www.w3.org/1999/02/22-rdf-syntax-ns#",G="http://www.w3.org/2000/01/rdf-schema#",se="http://www.w3.org/2004/02/skos/core#",Fe="http://www.w3.org/2002/07/owl#",Ve="http://www.w3.org/ns/oa#",ne="http://purl.org/dc/terms/",Qe="http://xmlns.com/foaf/0.1/",y=h.namedNode("loaded-shapes"),m=h.namedNode("loaded-data"),b=h.namedNode(I+"type"),ve=h.namedNode(I+"langString"),N=h.namedNode(ne+"conformsTo"),ue=h.namedNode(G+"subClassOf"),ie=h.namedNode(Fe+"imports"),ze=h.namedNode(se+"broader"),Me=h.namedNode(se+"narrower"),_=h.namedNode(u+"NodeShape"),ye=h.namedNode(u+"IRI"),X=h.namedNode(u+"property"),oe=h.namedNode(u+"class"),Be=h.namedNode(u+"node"),U=h.namedNode(u+"targetClass"),Ge=h.namedNode(u+"nodeKind"),Ue=h.namedNode(x+"string"),Ke=h.namedNode(x+"boolean");function A(t,e,s=u,o){let n="";const i=He(t,e,s,o);return i&&(n=i.value),n}function He(t,e,s=u,o){let n;const i=s+e;if(o?.length){for(const a of o)for(const r of t)if(r.predicate.value===i){if(r.object.id.endsWith(`@${a}`))return r.object;r.object.id.indexOf("@")<0?n=r.object:n||(n=r.object)}}else for(const a of t)if(a.predicate.value===i)return a.object;return n}function We(t){t.querySelector(".editor")?.focus()}function C(t,e){return A(t,"prefLabel",se,e)||A(t,"label",G,e)||A(t,"title",ne,e)||A(t,"name",Qe,e)}function we(t,e,s){const o=[];for(const n of t)o.push({value:n,label:C(e.getQuads(n,null,null,null),s),children:[]});return o}function J(t,e){for(const s in e){const o=e[s];t.startsWith(o)&&(t=t.slice(o.length))}return t}function Se(t,e,s,o,n=new Set){for(const i of e.owlImports)n.has(i.id)||(n.add(i.id),o.push(...s.getSubjects(b,t,i)));e.parent&&Se(t,e.parent,s,o,n)}function Ee(t,e){if(e.in){const s=e.config.lists[e.in];return we(s?.length?s:[],e.config.store,e.config.languages)}else{const s=e.config.store.getSubjects(b,t,y);s.push(...e.config.store.getSubjects(b,t,m)),Se(t,e,e.config.store,s);const o=new Map,n=new Map;for(const a of s)o.set(a.id,{value:a,label:C(e.config.store.getQuads(a,null,null,null),e.config.languages),children:[]});for(const a of s){for(const r of e.config.store.getObjects(a,ze,null))o.has(r.id)&&n.set(a.id,r.id);for(const r of e.config.store.getObjects(a,Me,null))o.has(r.id)&&n.set(r.id,a.id);for(const r of e.config.store.getObjects(a,ue,null))o.has(r.id)&&n.set(a.id,r.id)}for(const[a,r]of n.entries())o.get(r)?.children?.push(o.get(a));const i=[];for(const[a,r]of o.entries())n.has(a)||i.push(r);for(const a of e.config.store.getSubjects(ue,t,null))i.push(...Ee(a,e));return i}}function Y(t){let e;try{e=new URL(t)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}function V(t,e,s){if(e===void 0)return s;if(s===void 0)return e;const o=t.indexOf(e.language);if(o<0)return s;const n=t.indexOf(s.language);return n<0||n>o?e:s}function Xe(t){const e=new Set;for(const s of t.getObjects(null,oe,y))e.add(s.value);for(const s of t.getObjects(null,U,y))e.add(s.value);return e}function Je(t,e){return t instanceof Set?[...e].filter(s=>!t.has(s)):[...e].filter(s=>!t.includes(s))}function Ye(t,{remove:e=!1,ignoreErrors:s=!1}={}){const o={},n=s?(()=>!0):((r,l)=>{throw new Error(`${r.value} ${l}`)}),i=t.getQuads(null,I+"rest",I+"nil",null),a=e?[...i]:[];return i.forEach(r=>{const l=[];let c=!1,f,d;const p=r.graph;let g=r.subject;for(;g&&!c;){const w=t.getQuads(null,null,g,null),L=t.getQuads(g,null,null,null).filter(S=>!S.predicate.equals(b));let v,$=null,re=null,q=null;for(let S=0;S<L.length&&!c;S++)v=L[S],v.graph.equals(p)?f?c=n(g,"has non-list arcs out"):v.predicate.value===I+"first"?$?c=n(g,"has multiple rdf:first arcs"):a.push($=v):v.predicate.value===I+"rest"?re?c=n(g,"has multiple rdf:rest arcs"):a.push(re=v):w.length?c=n(g,"can't be subject and object"):(f=v,d="subject"):c=n(g,"not confined to single graph");for(let S=0;S<w.length&&!c;++S)v=w[S],f?c=n(g,"can't have coreferences"):v.predicate.value===I+"rest"?q?c=n(g,"has incoming rdf:rest arcs"):q=v:(f=v,d="object");$?l.unshift($.object):c=n(g,"has no list head"),g=q&&q.subject}c?e=!1:f&&(o[f[d].value]=l)}),e&&t.removeQuads(a),o}const O={},P={};function xe(t){const e=new Set;for(const s of t.getQuads(null,N,null,m))s.subject.termType==="NamedNode"&&e.add(s.subject.value);if(e.size===1)return e.values().next().value}function Ze(t,e){const s=h.namedNode(e);for(const o of t.getObjects(s,N,m))if(o.termType==="NamedNode"&&t.getQuads(o,b,_,null).length>0)return o}async function et(t){const e={store:new ee,importedUrls:[],atts:t},s=[];if(t.shapes?s.push(E(j(t.shapes),e,y)):t.shapesUrl&&s.push(E(F(t.shapesUrl,e.atts.proxy),e,y)),t.values?s.push(E(j(t.values),e,m)):t.valuesUrl&&s.push(E(F(t.valuesUrl,e.atts.proxy),e,m)),await Promise.all(s),t.classInstanceProvider)try{const o=Xe(e.store),n=await t.classInstanceProvider(o);n&&await E(j(n),e,y)}catch(o){console.error("failed loading class instances",o)}if(t.valuesSubject||(t.valuesSubject=xe(e.store)||null),t.valuesSubject&&e.store.countQuads(null,null,null,y)===0){const o=[...e.store.getObjects(t.valuesSubject,b,m),...e.store.getObjects(t.valuesSubject,N,m)],n=[];for(const i of o){let a=Ce(i.value);!a&&i.value.startsWith("urn:")&&e.atts.proxy&&(a=i.value),a&&e.importedUrls.indexOf(a)<0&&(e.importedUrls.push(a),n.push(E(F(a,e.atts.proxy),e,y)))}try{await Promise.allSettled(n)}catch(i){console.warn(i)}}return e.store}async function E(t,e,s){const o=await t,n=[];for(const i of o){let a=s;if(e.atts.valuesSubject&&m.equals(s)&&i.graph.id&&i.graph.id!==e.atts.valuesSubject&&(a=i.graph),e.store.add(h.quad(i.subject,i.predicate,i.object,a)),e.atts.loadOwlImports&&ie.equals(i.predicate)){const r=Ce(i.object.value);r&&e.importedUrls.indexOf(r)<0&&(e.importedUrls.push(r),n.push(E(F(r,e.atts.proxy),e,h.namedNode(r))))}}await Promise.allSettled(n)}async function F(t,e){return t in O||(O[t]=(async()=>{let s=t;e&&(s=e+encodeURIComponent(t));const o=await fetch(s,{headers:{Accept:"text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json"}});if(o.ok){const n=await o.text();return j(n)}else return console.warn("failed fetching RDF from",t),[]})()),O[t]}async function j(t){if(!t.trim())return[];const e=tt(t);if(e==="json")try{t=await $e.toRDF(JSON.parse(t),{format:"application/n-quads"})}catch(o){console.error(o)}const s=[];return await new Promise((o,n)=>{const i=e==="xml"?new Ne:new ke;i.on("data",a=>{s.push(h.quad(a.subject,a.predicate,a.object,a.graph))}).on("error",a=>{n(a)}).on("prefix",(a,r)=>{a&&(P[a]=r)}).on("end",()=>{o(null)}),i.write(t),i.end()}),s}function Ce(t){if(Y(t))return t;const e=t.split(":");if(e.length===2){const s=P[e[0]];if(s&&(t=t.replace(`${e[0]}:`,s),Y(t)))return t}return null}function tt(t){return/^\s*[\\[{]/.test(t)?"json":/^\s*<\?xml/.test(t)?"xml":"ttl"}const st={[`${u}name`]:(t,e)=>{const s=e;t.name=V(t.config.languages,t.name,s)},[`${u}description`]:(t,e)=>{const s=e;t.description=V(t.config.languages,t.description,s)},[`${u}path`]:(t,e)=>{t.path=e.value},[`${u}group`]:(t,e)=>{t.group=e.id},[`${u}datatype`]:(t,e)=>{t.datatype=e},[`${u}nodeKind`]:(t,e)=>{t.nodeKind=e},[`${u}minCount`]:(t,e)=>{t.minCount=parseInt(e.value)},[`${u}maxCount`]:(t,e)=>{t.maxCount=parseInt(e.value)},[`${u}minLength`]:(t,e)=>{t.minLength=parseInt(e.value)},[`${u}maxLength`]:(t,e)=>{t.maxLength=parseInt(e.value)},[`${u}minInclusive`]:(t,e)=>{t.minInclusive=parseInt(e.value)},[`${u}maxInclusive`]:(t,e)=>{t.maxInclusive=parseInt(e.value)},[`${u}minExclusive`]:(t,e)=>{t.minExclusive=parseInt(e.value)},[`${u}maxExclusive`]:(t,e)=>{t.maxExclusive=parseInt(e.value)},[`${u}pattern`]:(t,e)=>{t.pattern=e.value},[`${u}order`]:(t,e)=>{t.order=parseInt(e.value)},[`${de}singleLine`]:(t,e)=>{t.singleLine=e.value==="true"},[`${de}readonly`]:(t,e)=>{t.readonly=e.value==="true"},[`${Ve}styleClass`]:(t,e)=>{t.cssClass=e.value},[`${u}in`]:(t,e)=>{t.in=e.value},[`${u}languageIn`]:(t,e)=>{t.languageIn=t.config.lists[e.value],t.datatype=ve},[`${u}defaultValue`]:(t,e)=>{t.defaultValue=e},[`${u}hasValue`]:(t,e)=>{t.hasValue=e},[`${u}node`]:(t,e)=>{t.node=e,t.nodeShapes.add(t.config.getNodeTemplate(e,t))},[`${u}and`]:(t,e)=>{t.and=e.value;const s=t.config.lists[t.and];if(s?.length)for(const o of s)t.nodeShapes.add(t.config.getNodeTemplate(o,t))},[`${u}qualifiedValueShape`]:(t,e)=>{const s=t.config.getNodeTemplate(e,t);t.qualifiedValueShape=s,t.nodeShapes.add(s)},[`${u}qualifiedMinCount`]:(t,e)=>{t.qualifiedMinCount=parseInt(e.value)},[`${u}qualifiedMaxCount`]:(t,e)=>{t.qualifiedMaxCount=parseInt(e.value)},[ie.id]:(t,e)=>{t.owlImports.add(e)},[oe.id]:(t,e)=>{t.class=e;const s=t.config.store.getSubjects(U,e,null);s.length>0&&(t.node=s[0])},[`${u}or`]:(t,e)=>{const s=t.config.lists[e.value];s?.length?t.or=s:console.error("list for sh:or not found:",e.value,"existing lists:",t.config.lists)},[`${u}xone`]:(t,e)=>{const s=t.config.lists[e.value];s?.length?t.xone=s:console.error("list for sh:xone not found:",e.value,"existing lists:",t.config.lists)}};class he{constructor(e,s){this.label="",this.nodeShapes=new Set,this.owlImports=new Set,this.id=e,this.parent=s,this.config=s.config,this.config.registerPropertyTemplate(this),ae(this,this.config.store.getQuads(e,null,null,null))}}function Q(t){return Math.max(t.minCount??0,t.qualifiedMinCount??0)}function nt(t){return Math.min(t.maxCount??Number.MAX_SAFE_INTEGER,t.qualifiedMaxCount??Number.MAX_SAFE_INTEGER)}function Le(t){const e=Object.assign({},t);return e.nodeShapes=new Set(t.nodeShapes),e.owlImports=new Set(t.owlImports),t.languageIn&&(e.languageIn=[...t.languageIn]),t.or&&(e.or=[...t.or]),t.xone&&(e.xone=[...t.xone]),e}function ae(t,e){for(const s of e)st[s.predicate.id]?.call(t,t,s.object);return t.label=t.name?.value||C(e,t.config.languages),t.label||(t.label=t.path?J(t.path,P):"unknown"),t}function Ie(t,e){const s=e,o=t;for(const n in e)if(n!=="parent"&&n!=="config"&&n!=="id"){const i=s[n];if(i!==void 0&&i!=="")if(Array.isArray(i)){const a=o[n];Array.isArray(a)?a.push(...i):o[n]=[...i]}else if(i instanceof Set&&i.size){const a=o[n];o[n]=new Set([...a instanceof Set?a:[],...i])}else o[n]=i}}function Re(t,e,s){const o=document.createElement("div");o.classList.add("shacl-or-constraint"),o.setAttribute("part","constraint");const n=[];if(e instanceof T){const i=[];let a=!1;t.length&&(a=s.store.countQuads(t[0],X,null,null)>0);for(let c=0;c<t.length;c++)if(a){const f=s.store.getObjects(t[c],X,null),d=[];let p="";for(const g of f){const w=s.getPropertyTemplate(g,e.template),L=new z(w,e);d.push(L),p+=(p.length>0?" / ":"")+L.template.label}i.push(d),n.push({label:p,value:c.toString()})}else{const f=t[c],d=s.getPropertyTemplate(f,e.template),p=new z(d,e);i.push([p]),n.push({label:p.template.label,value:c.toString()})}const r=s.theme.createListEditor("Please choose",null,!1,n);r.setAttribute("part","constraint-editor");const l=r.querySelector(".editor");l.onchange=()=>{if(l.value){const c=i[parseInt(l.value)];let f;c.length&&(f=c[0],o.replaceWith(c[0]),f.updateControls());for(let d=1;d<c.length;d++)f.after(c[d]),f=c[d],f.updateControls()}},o.appendChild(r)}else{const i=[];for(let l=0;l<t.length;l++){const c=s.store.getQuads(t[l],null,null,null);if(c.length){i.push(c);let f=C(c,s.languages);for(const d of c)d.predicate.equals(Be)&&(f=C(s.store.getQuads(d.object,null,null,null),s.languages));n.push({label:f||J(c[0].predicate.value,P)+" = "+J(c[0].object.value,P),value:l.toString()})}}const a=s.theme.createListEditor(e.template.label+"?",null,!1,n,e.template);a.setAttribute("part","constraint-editor");const r=a.querySelector(".editor");r.onchange=async()=>{if(r.value){const l=ae(Le(e.template),i[parseInt(r.value)]),c=await M(l,void 0,!0),f=c.querySelector(":scope > label");f&&f.classList.add("persistent"),o.replaceWith(c)}},o.appendChild(a)}return o}function it(t,e,s){if(e.termType==="Literal"){const o=e.datatype;for(const n of t){const i=s.store.getQuads(n,null,null,null);for(const a of i)if(a.predicate.value===`${u}datatype`&&a.object.equals(o))return i}}else{const o=s.store.getObjects(e,b,null);for(const n of t){const i=s.store.getQuads(n,null,null,null);for(const a of i)if(o.length>0){if(a.predicate.value===`${u}node`){for(const r of o)if(s.store.getQuads(a.object,U,r,null).length>0)return i}if(a.predicate.equals(oe)){for(const r of o)if(a.object.equals(r))return i}}else if(a.predicate.equals(Ge)&&a.object.equals(ye))return i}}return console.error("couldn't resolve sh:or/sh:xone on property for value",e),[]}function ot(t,e,s){for(const o of t){let n=!1;const i=s.store.getObjects(o,X,null);for(const a of i){const r=s.store.getObjects(a,`${u}path`,null);for(const l of r)if(n=s.store.countQuads(e,l,null,null)>0,n)break}if(n)return i}return console.error("couldn't resolve sh:or/sh:xone on node for value",e),[]}const at=`:host {
|
|
1
|
+
import{DataFactory as e,Literal as t,NamedNode as n,Store as r,StreamParser as i,Writer as a}from"n3";import{RdfXmlParser as o}from"rdfxml-streaming-parser";import s from"jsonld";import{RokitButton as c,RokitCollapsible as l,RokitDialog as u,RokitInput as d,RokitSelect as f,RokitTextArea as p}from"@ro-kit/ui-widgets";import{v4 as m}from"uuid";import{Validator as ee}from"shacl-engine";var h=`http://www.w3.org/ns/shacl#`,te=`http://datashapes.org/dash#`,g=`http://www.w3.org/2001/XMLSchema#`,_=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,v=`http://www.w3.org/2000/01/rdf-schema#`,ne=`http://www.w3.org/2004/02/skos/core#`,re=`http://www.w3.org/2002/07/owl#`,ie=`http://www.w3.org/ns/oa#`,y=`http://purl.org/dc/terms/`,b=e.namedNode(`loaded-shapes`),x=e.namedNode(`loaded-data`),S=e.namedNode(_+`type`),ae=e.namedNode(_+`langString`),C=e.namedNode(y+`conformsTo`),oe=e.namedNode(v+`subClassOf`),w=e.namedNode(re+`imports`),se=e.namedNode(ne+`broader`),ce=e.namedNode(ne+`narrower`),T=e.namedNode(h+`NodeShape`),le=e.namedNode(h+`IRI`),E=e.namedNode(h+`property`),D=e.namedNode(h+`class`),ue=e.namedNode(h+`node`),O=e.namedNode(h+`targetClass`),de=e.namedNode(h+`nodeKind`),fe=e.namedNode(g+`string`),pe=e.namedNode(g+`boolean`);function k(e,t,n=h,r){let i=``,a=me(e,t,n,r);return a&&(i=a.value),i}function me(e,t,n=h,r){let i,a=n+t;if(r?.length){for(let t of r)for(let n of e)if(n.predicate.value===a){if(n.object.id.endsWith(`@${t}`))return n.object;n.object.id.indexOf(`@`)<0?i=n.object:i||=n.object}}else for(let t of e)if(t.predicate.value===a)return t.object;return i}function he(e){e.querySelector(`.editor`)?.focus()}function A(e,t){return k(e,`prefLabel`,`http://www.w3.org/2004/02/skos/core#`,t)||k(e,`label`,`http://www.w3.org/2000/01/rdf-schema#`,t)||k(e,`title`,`http://purl.org/dc/terms/`,t)||k(e,`name`,`http://xmlns.com/foaf/0.1/`,t)}function ge(e,t,n){let r=[];for(let i of e)r.push({value:i,label:A(t.getQuads(i,null,null,null),n),children:[]});return r}function j(e,t){for(let n in t){let r=t[n];e.startsWith(r)&&(e=e.slice(r.length))}return e}function _e(e,t,n,r,i=new Set){for(let a of t.owlImports)i.has(a.id)||(i.add(a.id),r.push(...n.getSubjects(S,e,a)));t.parent&&_e(e,t.parent,n,r,i)}function ve(e,t){if(t.in){let e=t.config.lists[t.in];return ge(e?.length?e:[],t.config.store,t.config.languages)}else{let n=t.config.store.getSubjects(S,e,b);n.push(...t.config.store.getSubjects(S,e,x)),_e(e,t,t.config.store,n);let r=new Map,i=new Map;for(let e of n)r.set(e.id,{value:e,label:A(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of n){for(let n of t.config.store.getObjects(e,se,null))r.has(n.id)&&i.set(e.id,n.id);for(let n of t.config.store.getObjects(e,ce,null))r.has(n.id)&&i.set(n.id,e.id);for(let n of t.config.store.getObjects(e,oe,null))r.has(n.id)&&i.set(e.id,n.id)}for(let[e,t]of i.entries())r.get(t)?.children?.push(r.get(e));let a=[];for(let[e,t]of r.entries())i.has(e)||a.push(t);for(let n of t.config.store.getSubjects(oe,e,null))a.push(...ve(n,t));return a}}function M(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}function N(e,t,n){if(t===void 0)return n;if(n===void 0)return t;let r=e.indexOf(t.language);if(r<0)return n;let i=e.indexOf(n.language);return i<0||i>r?t:n}function ye(e,t){let n;for(let r of t)n=N(e,n,r);return n?n.value:``}function be(e){let t=new Set;for(let n of e.getObjects(null,D,b))t.add(n.value);for(let n of e.getObjects(null,O,b))t.add(n.value);return t}function xe(e,t){return e instanceof Set?[...t].filter(t=>!e.has(t)):[...t].filter(t=>!e.includes(t))}function Se(e,{remove:t=!1,ignoreErrors:n=!1}={}){let r={},i=n?(()=>!0):((e,t)=>{throw Error(`${e.value} ${t}`)}),a=e.getQuads(null,_+`rest`,_+`nil`,null),o=t?[...a]:[];return a.forEach(n=>{let a=[],s=!1,c,l,u=n.graph,d=n.subject;for(;d&&!s;){let t=e.getQuads(null,null,d,null),n=e.getQuads(d,null,null,null).filter(e=>!e.predicate.equals(S)),r,f=null,p=null,m=null;for(let e=0;e<n.length&&!s;e++)r=n[e],r.graph.equals(u)?c?s=i(d,`has non-list arcs out`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#first`?f?s=i(d,`has multiple rdf:first arcs`):o.push(f=r):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?p?s=i(d,`has multiple rdf:rest arcs`):o.push(p=r):t.length?s=i(d,`can't be subject and object`):(c=r,l=`subject`):s=i(d,`not confined to single graph`);for(let e=0;e<t.length&&!s;++e)r=t[e],c?s=i(d,`can't have coreferences`):r.predicate.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#rest`?m?s=i(d,`has incoming rdf:rest arcs`):m=r:(c=r,l=`object`);f?a.unshift(f.object):s=i(d,`has no list head`),d=m&&m.subject}s?t=!1:c&&(r[c[l].value]=a)}),t&&e.removeQuads(o),r}var P={},F={};function I(e){let t=new Set;for(let n of e.getQuads(null,C,null,x))n.subject.termType===`NamedNode`&&t.add(n.subject.value);if(t.size===1)return t.values().next().value}function Ce(t,n){let r=e.namedNode(n);for(let e of t.getObjects(r,C,x))if(e.termType===`NamedNode`&&t.getQuads(e,S,T,null).length>0)return e}async function we(e){let t={store:new r,importedUrls:[],atts:e},n=[];if(e.shapes?n.push(L(z(e.shapes),t,b)):e.shapesUrl&&n.push(L(R(e.shapesUrl,t.atts.proxy),t,b)),e.values?n.push(L(z(e.values),t,x)):e.valuesUrl&&n.push(L(R(e.valuesUrl,t.atts.proxy),t,x)),await Promise.all(n),e.classInstanceProvider)try{let n=be(t.store),r=await e.classInstanceProvider(n);r&&await L(z(r),t,b)}catch(e){console.error(`failed loading class instances`,e)}if(e.valuesSubject||=I(t.store)||null,e.valuesSubject&&t.store.countQuads(null,null,null,b)===0){let n=[...t.store.getObjects(e.valuesSubject,S,x),...t.store.getObjects(e.valuesSubject,C,x)],r=[];for(let e of n){let n=Te(e.value);!n&&e.value.startsWith(`urn:`)&&t.atts.proxy&&(n=e.value),n&&t.importedUrls.indexOf(n)<0&&(t.importedUrls.push(n),r.push(L(R(n,t.atts.proxy),t,b)))}try{await Promise.allSettled(r)}catch(e){console.warn(e)}}return t.store}async function L(t,n,r){let i=await t,a=[];for(let t of i){let i=r;if(n.atts.valuesSubject&&x.equals(r)&&t.graph.id&&t.graph.id!==n.atts.valuesSubject&&(i=t.graph),n.store.add(e.quad(t.subject,t.predicate,t.object,i)),n.atts.loadOwlImports&&w.equals(t.predicate)){let r=Te(t.object.value);r&&n.importedUrls.indexOf(r)<0&&(n.importedUrls.push(r),a.push(L(R(r,n.atts.proxy),n,e.namedNode(r))))}}await Promise.allSettled(a)}async function R(e,t){return e in P||(P[e]=(async()=>{let n=e;t&&(n=t+encodeURIComponent(e));let r=await fetch(n,{headers:{Accept:`text/turtle, application/trig, application/n-triples, application/n-quads, text/n3, application/ld+json`}});return r.ok?z(await r.text()):(console.warn(`failed fetching RDF from`,e),[])})()),P[e]}async function z(t){if(!t.trim())return[];let n=Ee(t);if(n===`json`)try{t=await s.toRDF(JSON.parse(t),{format:`application/n-quads`})}catch(e){console.error(e)}let r=[];return await new Promise((a,s)=>{let c=n===`xml`?new o:new i;c.on(`data`,t=>{r.push(e.quad(t.subject,t.predicate,t.object,t.graph))}).on(`error`,e=>{s(e)}).on(`prefix`,(e,t)=>{e&&(F[e]=t)}).on(`end`,()=>{a(null)}),c.write(t),c.end()}),r}function Te(e){if(M(e))return e;let t=e.split(`:`);if(t.length===2){let n=F[t[0]];if(n&&(e=e.replace(`${t[0]}:`,n),M(e)))return e}return null}function Ee(e){return/^\s*[\\[{]/.test(e)?`json`:/^\s*<\?xml/.test(e)?`xml`:`ttl`}var De={[`${h}name`]:(e,t)=>{let n=t;e.name=N(e.config.languages,e.name,n)},[`${h}description`]:(e,t)=>{let n=t;e.description=N(e.config.languages,e.description,n)},[`${h}path`]:(e,t)=>{e.path=t.value},[`${h}group`]:(e,t)=>{e.group=t.id},[`${h}datatype`]:(e,t)=>{e.datatype=t},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}minCount`]:(e,t)=>{e.minCount=parseInt(t.value)},[`${h}maxCount`]:(e,t)=>{e.maxCount=parseInt(t.value)},[`${h}minLength`]:(e,t)=>{e.minLength=parseInt(t.value)},[`${h}maxLength`]:(e,t)=>{e.maxLength=parseInt(t.value)},[`${h}minInclusive`]:(e,t)=>{e.minInclusive=parseInt(t.value)},[`${h}maxInclusive`]:(e,t)=>{e.maxInclusive=parseInt(t.value)},[`${h}minExclusive`]:(e,t)=>{e.minExclusive=parseInt(t.value)},[`${h}maxExclusive`]:(e,t)=>{e.maxExclusive=parseInt(t.value)},[`${h}pattern`]:(e,t)=>{e.pattern=t.value},[`${h}order`]:(e,t)=>{e.order=parseInt(t.value)},[`${te}singleLine`]:(e,t)=>{e.singleLine=t.value===`true`},[`${te}readonly`]:(e,t)=>{e.readonly=t.value===`true`},[`${ie}styleClass`]:(e,t)=>{e.cssClass=t.value},[`${h}in`]:(e,t)=>{e.in=t.value},[`${h}languageIn`]:(e,t)=>{e.languageIn=e.config.lists[t.value],e.datatype=ae},[`${h}defaultValue`]:(e,t)=>{e.defaultValue=t},[`${h}hasValue`]:(e,t)=>{e.hasValue=t},[`${h}node`]:(e,t)=>{e.node=t,e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}and`]:(e,t)=>{e.and=t.value;let n=e.config.lists[e.and];if(n?.length)for(let t of n)e.nodeShapes.add(e.config.getNodeTemplate(t,e))},[`${h}qualifiedValueShape`]:(e,t)=>{let n=e.config.getNodeTemplate(t,e);e.qualifiedValueShape=n,e.nodeShapes.add(n)},[`${h}qualifiedMinCount`]:(e,t)=>{e.qualifiedMinCount=parseInt(t.value)},[`${h}qualifiedMaxCount`]:(e,t)=>{e.qualifiedMaxCount=parseInt(t.value)},[w.id]:(e,t)=>{e.owlImports.add(t)},[D.id]:(e,t)=>{e.class=t;let n=e.config.store.getSubjects(O,t,null);n.length>0&&(e.node=n[0])},[`${h}or`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.or=n:console.error(`list for sh:or not found:`,t.value,`existing lists:`,e.config.lists)},[`${h}xone`]:(e,t)=>{let n=e.config.lists[t.value];n?.length?e.xone=n:console.error(`list for sh:xone not found:`,t.value,`existing lists:`,e.config.lists)}},B=class{constructor(e,t){this.label=``,this.nodeShapes=new Set,this.owlImports=new Set,this.id=e,this.parent=t,this.config=t.config,this.config.registerPropertyTemplate(this),H(this,this.config.store.getQuads(e,null,null,null))}};function V(e){return Math.max(e.minCount??0,e.qualifiedMinCount??0)}function Oe(e){return Math.min(e.maxCount??2**53-1,e.qualifiedMaxCount??2**53-1)}function ke(e){let t=Object.assign({},e);return t.nodeShapes=new Set(e.nodeShapes),t.owlImports=new Set(e.owlImports),e.languageIn&&(t.languageIn=[...e.languageIn]),e.or&&(t.or=[...e.or]),e.xone&&(t.xone=[...e.xone]),t}function H(e,t){for(let n of t)De[n.predicate.id]?.call(e,e,n.object);return e.label=e.name?.value||A(t,e.config.languages),e.label||=e.path?j(e.path,F):`unknown`,e}function Ae(e,t){let n=t,r=e;for(let e in t)if(e!==`parent`&&e!==`config`&&e!==`id`){let t=n[e];if(t!==void 0&&t!==``)if(Array.isArray(t)){let n=r[e];Array.isArray(n)?n.push(...t):r[e]=[...t]}else if(t instanceof Set&&t.size){let n=r[e];r[e]=new Set([...n instanceof Set?n:[],...t])}else r[e]=t}}function je(e,t,n){let r=document.createElement(`div`);r.classList.add(`shacl-or-constraint`),r.setAttribute(`part`,`constraint`);let i=[];if(t instanceof q){let a=[],o=!1;e.length&&(o=n.store.countQuads(e[0],E,null,null)>0);for(let r=0;r<e.length;r++)if(o){let o=n.store.getObjects(e[r],E,null),s=[],c=``;for(let e of o){let r=new G(n.getPropertyTemplate(e,t.template),t);s.push(r),c+=(c.length>0?` / `:``)+r.template.label}a.push(s),i.push({label:c,value:r.toString()})}else{let o=e[r],s=new G(n.getPropertyTemplate(o,t.template),t);a.push([s]),i.push({label:s.template.label,value:r.toString()})}let s=n.theme.createListEditor(`Please choose`,null,!1,i);s.setAttribute(`part`,`constraint-editor`);let c=s.querySelector(`.editor`);c.onchange=()=>{if(c.value){let e=a[parseInt(c.value)],t;e.length&&(t=e[0],r.replaceWith(e[0]),t.updateControls());for(let n=1;n<e.length;n++)t.after(e[n]),t=e[n],t.updateControls()}},r.appendChild(s)}else{let a=[];for(let t=0;t<e.length;t++){let r=n.store.getQuads(e[t],null,null,null);if(r.length){a.push(r);let e=A(r,n.languages);for(let t of r)t.predicate.equals(ue)&&(e=A(n.store.getQuads(t.object,null,null,null),n.languages));i.push({label:e||j(r[0].predicate.value,F)+` = `+j(r[0].object.value,F),value:t.toString()})}}let o=n.theme.createListEditor(t.template.label+`?`,null,!1,i,t.template);o.setAttribute(`part`,`constraint-editor`);let s=o.querySelector(`.editor`);s.onchange=async()=>{if(s.value){let e=await K(H(ke(t.template),a[parseInt(s.value)]),void 0,!0),n=e.querySelector(`:scope > label`);n&&n.classList.add(`persistent`),r.replaceWith(e)}},r.appendChild(o)}return r}function Me(e,t,n){if(t.termType===`Literal`){let r=t.datatype;for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(t.predicate.value===`http://www.w3.org/ns/shacl#datatype`&&t.object.equals(r))return e}}else{let r=n.store.getObjects(t,S,null);for(let t of e){let e=n.store.getQuads(t,null,null,null);for(let t of e)if(r.length>0){if(t.predicate.value===`http://www.w3.org/ns/shacl#node`){for(let i of r)if(n.store.getQuads(t.object,O,i,null).length>0)return e}if(t.predicate.equals(D)){for(let n of r)if(t.object.equals(n))return e}}else if(t.predicate.equals(de)&&t.object.equals(le))return e}}return console.error(`couldn't resolve sh:or/sh:xone on property for value`,t),[]}function Ne(e,t,n){for(let r of e){let e=!1,i=n.store.getObjects(r,E,null);for(let r of i){let i=n.store.getObjects(r,`${h}path`,null);for(let r of i)if(e=n.store.countQuads(t,r,null,null)>0,e)break}if(e)return i}return console.error(`couldn't resolve sh:or/sh:xone on node for value`,t),[]}var Pe=`:host {
|
|
2
2
|
--shacl-font-family: inherit;
|
|
3
3
|
--shacl-font-size: 14px;
|
|
4
4
|
--shacl-text-color: #333;
|
|
@@ -79,20 +79,19 @@ h3 { margin-top: 0; }
|
|
|
79
79
|
.link-option { padding: 10px; }
|
|
80
80
|
.link-option:hover { background-color: #F5F5F5; cursor: pointer; }
|
|
81
81
|
rokit-dialog.link-chooser::part(dialog) { min-height: min(434px, 90vh); width: min(90vw, 600px); }
|
|
82
|
-
|
|
83
|
-
`+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(s)}apply(e){}setDense(e){this.dense=e}createViewer(e,s,o){const n=document.createElement("div"),i=document.createElement("label");i.textContent=`${e}:`,o.description&&i.setAttribute("title",o.description.value),n.appendChild(i);let a=s.value,r=null;if(s instanceof k){const c=o.config.store.getQuads(a,null,null,null);if(c.length){const f=C(c,o.config.languages);f&&(a=f)}}else s instanceof R&&(s.language?(r=document.createElement("span"),r.classList.add("lang"),r.innerText=`@${s.language}`):s.datatype.value===`${x}date`?a=new Date(Date.parse(s.value)).toDateString():s.datatype.value===`${x}dateTime`&&(a=new Date(Date.parse(s.value)).toLocaleString()));let l;return Y(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 lt(t,e,s){if(s){const o=Q(t)>0;if(t.class&&!t.hasValue)return t.config.theme.createListEditor(t.label,e,o,Ee(t.class,t),t);if(t.in){const n=t.config.lists[t.in];if(n?.length){const i=we(n,t.config.store,t.config.languages);return t.config.theme.createListEditor(t.label,e,o,i,t)}else console.error("list not found:",t.in,"existing lists:",t.config.lists)}if(t.datatype?.equals(ve)||t.languageIn?.length||t.datatype===void 0&&e instanceof R&&e.language)return t.config.theme.createLangStringEditor(t.label,e,o,t);switch(t.datatype?.value.replace(x,"")){case"integer":case"float":case"double":case"decimal":return t.config.theme.createNumberEditor(t.label,e,o,t);case"date":case"dateTime":return t.config.theme.createDateEditor(t.label,e,o,t);case"boolean":return t.config.theme.createBooleanEditor(t.label,e,o,t);case"base64Binary":return t.config.theme.createFileEditor(t.label,e,o,t)}return t.config.theme.createTextEditor(t.label,e,o,t)}else return e?t.config.theme.createViewer(t.label,e,t):document.createElement("div")}function ct(t,e,s){if(e==="application/ld+json")return dt(t);{const o=new De({format:e,prefixes:s});o.addQuads(t);let n="";return o.end((i,a)=>{i&&console.error(i),n=a}),n}}function dt(t){const e=[];for(const s of t){const o={"@id":s.subject.id};if(s.predicate===b)o["@type"]=s.object.id;else{let n=s.object.value;s.object instanceof R?s.object.language?n={"@language":s.object.language,"@value":s.object.value}:s.object.datatype&&s.object.datatype.value!==`${x}#string`&&(n={"@type":s.object.datatype.value,"@value":s.object.value}):n={"@id":s.object.id},o[s.predicate.value]=n}e.push(o)}return JSON.stringify(e)}function fe(t){let e=t.shaclDatatype,s=t.dataset.value||t.value;if(t.type==="checkbox"||t.getAttribute("type")==="checkbox"){if(t.checked||parseInt(t.dataset.minCount||"0")>0)return h.literal(t.checked?"true":"false",e)}else if(s){if(s.startsWith("<")&&s.endsWith(">")&&s.indexOf(":")>-1)return h.namedNode(s.substring(1,s.length-1));if(t.dataset.class||t.dataset.nodeKind===u+"IRI")return h.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 k&&Ue.equals(e))&&typeof s=="string"){let o=s.split("^^");o.length===2&&o[0].startsWith('"')&&o[0].endsWith('"')&&o[1].split(":").length===2?(s=o[0].substring(1,o[0].length-1),e=h.namedNode(o[1])):(o=s.split("@"),o.length===2&&o[0].startsWith('"')&&o[0].endsWith('"')?(s=o[0].substring(1,o[0].length-1),e=o[1]):s.startsWith('"')&&s.endsWith('"')&&(s=s.substring(1,s.length-1)))}return h.literal(s,e)}}const D={};function ut(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 ht(){return Object.entries(D).map(t=>t[1])}function ft(t,e){let s=D[`${t}^${e}`];return s||(s=D[`${t}^undefined`],s)?s:D[`undefined^${e}`]}class Nt{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)}}async function pt(t){if(t.template.nodeShapes.size===0)return;const e=t.template.config.resourceLinkProvider;if((!e||e&&!e.lazyLoad)&&(await ge(t.template),pe(t).length===0))return;const s=t.template.config.theme.createButton(t.template.label,!1);s.title="Link existing "+t.template.label,s.classList.add("link-button"),s.setAttribute("text","");const o=s.getAttribute("part");return s.setAttribute("part",`${o?o+" ":""}link-button`),s.addEventListener("click",async()=>{e?.lazyLoad&&(s.classList.add("loading"),await ge(t.template),s.classList.remove("loading"));const n=pe(t);if(n.length===0)s.innerText="No linkable resources found",s.setAttribute("disabled",""),setTimeout(()=>s.remove(),2e3);else{let i=t.template.config.form.querySelector("#dialog");i||(i=new qe,i.classList.add("link-chooser"),i.closable=!0,t.template.config.form.appendChild(i)),i.title="Link existing "+t.template.label,gt(i,t,n),i.open=!0}}),s}function gt(t,e,s){const o=document.createElement("div");for(const n of s){const i=document.createElement("div");i.classList.add("link-option"),i.title="Link this resource",i.innerText=n.label||n.value,i.addEventListener("click",()=>{bt(n.value,e),t.open=!1}),o.appendChild(i)}t.replaceChildren(o)}function pe(t){const e=[];if(t.template.config.resourceLinkProvider){for(const s of t.template.nodeShapes)if(t.template.config.providedConformingResourceIds[s.id.value])for(const o of t.template.config.providedConformingResourceIds[s.id.value])t.querySelector(`:scope > .property-instance > shacl-node[data-node-id='${o}'], :scope > .collapsible > .property-instance > shacl-node[data-node-id='${o}']`)===null&&e.push({value:o,label:C(t.template.config.store.getQuads(h.namedNode(o),null,null,null),t.template.config.languages),children:[]})}return e}async function bt(t,e){const s=h.namedNode(t);if(Ae(s,e.template.config.store)){if(e.template.config.providedResources[t]?.length>0){const n={store:e.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await E(j(e.template.config.providedResources[t]),n,y),e.template.config.providedResources[t]=""}const o=await M(e.template,s,!0,!0);e.container.insertBefore(o,e.querySelector(":scope > .add-button-wrapper")),await e.updateControls()}}async function ge(t){const e=t.config.resourceLinkProvider;if(!e)return;const s=new Set(Array.from(t.nodeShapes).map(n=>n.id.value));if(s.size===0)return;const o=Je(Object.keys(t.config.providedConformingResourceIds),s);if(o.length!==0)try{const n=await e.listConformingResources(o,t);if(n){for(const i of Object.keys(n)){const a=new Set(n[i]);t.config.providedConformingResourceIds[i]=a,await Te(a,!1,t.config)}for(const i of o)t.config.providedConformingResourceIds[i]||(t.config.providedConformingResourceIds[i]=new Set)}}catch(n){console.error("failed loading conforming resources",n)}}async function Te(t,e,s){if(s.resourceLinkProvider&&t.size>0){const o=[];for(const n of t)s.providedResources[n]||o.push(n);if(o.length===0)return[];try{const n=await s.resourceLinkProvider.loadResources(o);if(n){const i={store:s.store,importedUrls:[],atts:{loadOwlImports:!1}};for(const a of n)s.providedResources[a.resourceId]=a.resourceRDF,e&&await E(j(a.resourceRDF),i,y);return n}for(const i of o)s.providedResources[i]||(s.providedResources[i]="")}catch(n){console.error("failed loading resources",n)}}return[]}async function mt(t){const e=new Set;for(const s of t.store.getQuads(null,null,null,m))Ae(s.object,t.store)&&e.add(s.object.value);await Te(e,!0,t)}function Ae(t,e){return t.termType==="NamedNode"&&e.countQuads(t,null,null,null)===0}const H=":scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper",vt=":scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance";class z extends HTMLElement{constructor(e,s){if(super(),this.template=e,this.parent=s,this.container=this,this.setAttribute("part","property"),this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){const o=new te;o.classList.add("collapsible","shacl-group"),o.open=e.config.attributes.collapse==="open",o.label=this.template.label,o.setAttribute("part","collapsible"),this.container=o,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.addEventListener("change",async()=>{await this.updateControls()})}async bindValues(e,s){if(this.template.path){let o=!1;if(e){let n=this.template.config.store.getQuads(e,this.template.path,null,this.parent.linked?null:m);s&&(n=await this.filterValidValues(n,e));for(const i of n)this.parent.linked||this.template.config.store.delete(i),await this.addPropertyInstance(i.object,!m.equals(i.graph)||this.template.config.providedResources[i.object.value]!==void 0,this.template.config.providedResources[i.object.value]!==void 0),this.template.hasValue&&i.object.equals(this.template.hasValue)&&(o=!0)}this.template.config.editMode&&this.template.hasValue&&!o&&!this.parent.linked&&await this.addPropertyInstance(this.template.hasValue)}}async addPropertyInstance(e,s,o=!1){let n;if(this.template.or?.length||this.template.xone?.length){const i=this.template.or?.length?this.template.or:this.template.xone;let a=!1;if(e){const r=it(i,e,this.template.config);if(r.length){const l=ae(Le(this.template),r);n=await M(l,e,!this.parent.linked,this.parent.linked,this.parent),a=!0}}!a&&this.template.config.editMode&&(n=Re(i,this,this.template.config),je(n,"",this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else n=await M(this.template,e,o,s||this.parent.linked,this.parent);return n&&this.container.insertBefore(n,this.querySelector(H)),n}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(H)&&this.container.appendChild(await this.createAddControls());const e=Q(this.template),s=this.template.nodeShapes.size===0,o=this.querySelector(":scope > .add-button-wrapper > .link-button, :scope > .collapsible > .add-button-wrapper > .link-button")===null,n=s||!this.hasRecursiveNodeShape();let i=this.instanceCount();i===0&&n&&(s||o&&e>0)&&(await this.addPropertyInstance(),i=1),s||this.querySelector(H)?.classList.toggle("required",i<e);let a;e>0?a=i>e:a=!s||i>1;const r=i<nt(this.template);this.classList.toggle("may-remove",a),this.classList.toggle("may-add",r)}instanceCount(){return this.querySelectorAll(vt).length}hasRecursiveNodeShape(){const e=new Set;this.parent.ancestorShapeIds.forEach(s=>e.add(s)),e.add(this.parent.template.id.value);for(const s of this.template.nodeShapes)if(e.has(s.id.value))return!0;return!1}toRDF(e,s){const o=h.namedNode(this.template.path);for(const n of this.querySelectorAll(":scope > .property-instance, :scope > .collapsible > .property-instance"))if(n.firstChild instanceof T){const i=n.firstChild.toRDF(e);e.addQuad(s,o,i,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(const i of n.querySelectorAll(":scope > .editor")){const a=fe(i);a&&e.addQuad(s,o,a,this.template.config.valuesGraphId)}else{const i=fe(n);i&&e.addQuad(s,o,i,this.template.config.valuesGraphId)}}async filterValidValues(e,s){let o=this.template.id,n=[s];if(this.template.qualifiedValueShape){o=this.template.qualifiedValueShape.id,n=[];for(const r of e)n.push(r.object)}const i=await this.template.config.validator.validate({dataset:this.template.config.store,terms:n},[{terms:[o]}]),a=new Set;for(const r of i.results){const l=this.template.qualifiedValueShape?r.focusNode:r.value;l?.ptrs?.length&&a.add(l.ptrs[0]._term.id)}return e.filter(r=>!a.has(r.object.id))}async createAddControls(){const e=document.createElement("div");e.classList.add("add-button-wrapper"),e.setAttribute("part","add-controls");const s=await pt(this);s&&e.appendChild(s);const o=this.template.config.theme.createButton(this.template.label,!1);o.title="Add "+this.template.label,o.classList.add("add-button"),o.setAttribute("text","");const n=o.getAttribute("part");return o.setAttribute("part",`${n?n+" ":""}add-button`),o.addEventListener("click",async()=>{const i=await this.addPropertyInstance();i&&(i.classList.add("fadeIn"),await this.updateControls(),setTimeout(()=>{We(i),i.classList.remove("fadeIn")},200))}),e.appendChild(o),e}}async function M(t,e,s=!1,o=!1,n){let i;if(t.nodeShapes.size){i=document.createElement("div"),i.classList.add("property-instance"),i.setAttribute("part","property-instance");const a=new Set(n?.ancestorShapeIds??[]);n&&a.add(n.template.id.value);for(const r of t.nodeShapes){const l=new T(r,e,t.nodeKind,t.label,o,a);i.appendChild(l),await l.ready}}else{const a=ft(t.path,t.datatype?.value);a?t.config.editMode&&!o?i=a.createEditor(t,e):i=a.createViewer(t,e):i=lt(t,e||null,t.config.editMode&&!o),i.childNodes.length>0&&(i.classList.add("property-instance"),i.setAttribute("part","property-instance")),o&&i.classList.add("linked")}return t.config.editMode&&(!o||s)?je(i,t.label,t.config.theme.dense,t.config.hierarchyColorsStyleSheet!==void 0,s):t.config.hierarchyColorsStyleSheet!==void 0&&i.appendChild(Pe(!0)),e&&!t.config.editMode&&(e instanceof R?(i.dataset.value=e.value,e.language.length>0?i.dataset.lang=e.language:i.shaclDatatype=e.datatype):i.dataset.value="<"+e.value+">"),i.dataset.path=t.path,i}function je(t,e,s,o,n=!1){const i=Pe(o),a=new me;a.classList.add("remove-button","clear"),a.title="Remove "+e,a.dense=s,a.icon=!0;const r=a.getAttribute("part");a.setAttribute("part",`${r?r+" ":""}remove-button`),a.addEventListener("click",()=>{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"),i.appendChild(a),t.appendChild(i)}function Pe(t){const e=document.createElement("div");return e.className="remove-button-wrapper",e.setAttribute("part","remove-controls"),t&&e.classList.add("colorize"),e}window.customElements.define("shacl-property",z);function yt(t,e){let s=t;const o=e.store.getQuads(t,null,null,null),n=A(o,"label",G,e.languages);n&&(s=n);let i;if(e.attributes.collapse!==null)i=new te,i.classList.add("collapsible"),i.open=e.attributes.collapse==="open",i.label=s,i.setAttribute("part","group collapsible");else{i=document.createElement("div");const r=document.createElement("h1");r.innerText=s,r.setAttribute("part","group-title"),i.appendChild(r),i.setAttribute("part","group")}i.dataset.subject=t,i.classList.add("shacl-group");const a=A(o,"order");return a&&(i.style.order=a),i}class T extends HTMLElement{constructor(e,s,o,n,i,a=new Set){super(),this.template=e,this.linked=i??!1,this.ancestorShapeIds=a,this.setAttribute("part","node");let r=s;r||(!o&&e.nodeKind&&(o=e.nodeKind),o===void 0&&e.config.attributes.valuesNamespace||o?.value===`${u}IRI`?r=h.namedNode(e.config.attributes.valuesNamespace+le()):r=h.blankNode(le())),this.nodeId=r;const l=JSON.stringify([e.id,s]);if(s&&e.config.renderedNodes.has(l)){n=n||"Link";const c=document.createElement("label");c.innerText=n,c.classList.add("linked"),this.appendChild(c);const f=this.getAttribute("part");this.setAttribute("part",`${f?f+" ":""}linked-node`);const d=document.createElement("a"),p=s.termType==="BlankNode"?"_:"+s.value:s.value;d.innerText=p,d.classList.add("ref-link"),d.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${p}']`)?.scrollIntoView()},this.appendChild(d),this.style.flexDirection="row",this.ready=Promise.resolve()}else{s&&e.config.renderedNodes.add(l);const c=this.ancestorShapeIds,f=this.template.id.value;if(this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){const d=document.createElement("div");d.innerText=`id: ${this.nodeId.id}`,d.classList.add("node-id-display"),this.appendChild(d)}this.ready=(async()=>{const d=new Set(c);d.add(f);for(const[p,g]of Object.entries(e.properties))for(const w of g)await this.addPropertyInstance(w,s,g.length>1);for(const p of e.extendedShapes){const g=new T(p,s,void 0,void 0,i,d);this.prepend(g),await g.ready}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 p=document.createElement("h1");p.innerText=n,p.setAttribute("part","node-title"),this.prepend(p)}})()}}toRDF(e,s,o=""){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,b,this.template.targetClass,this.template.config.valuesGraphId),o&&e.addQuad(s,h.namedNode(o),this.template.id,this.template.config.valuesGraphId)}return s}async addPropertyInstance(e,s,o){let n=null;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let a=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);a||(a=yt(e.group,e.config),this.appendChild(a)),n=a}else console.warn("ignoring unknown group reference",e.group,"existing groups:",e.config.groups);const i=new z(e,this);await i.bindValues(s,o),(e.config.editMode||i.instanceCount()>0)&&(n?n.appendChild(i):this.appendChild(i),await i.updateControls())}async tryResolve(e,s,o){let n=!1;if(s){const i=ot(e,s,o);if(i.length){for(const a of i)await this.addPropertyInstance(o.getPropertyTemplate(a,this.template),s);n=!0}}n||this.appendChild(Re(e,this,o))}}window.customElements.define("shacl-node",T);const wt=`
|
|
82
|
+
`,Fe=class{constructor(e){this.dense=!0;let t=Pe;e&&(t+=`
|
|
83
|
+
`+e),this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(t)}apply(e){}setDense(e){this.dense=e}createViewer(e,r,i){let a=document.createElement(`div`),o=document.createElement(`label`);o.textContent=`${e}:`,i.description&&o.setAttribute(`title`,i.description.value),a.appendChild(o);let s=r.value,c=null;if(r instanceof n){let e=i.config.store.getQuads(s,null,null,null);if(e.length){let t=A(e,i.config.languages);t&&(s=t)}}else r instanceof t&&(r.language?(c=document.createElement(`span`),c.classList.add(`lang`),c.innerText=`@${r.language}`):r.datatype.value===`http://www.w3.org/2001/XMLSchema#date`?s=new Date(Date.parse(r.value)).toDateString():r.datatype.value===`http://www.w3.org/2001/XMLSchema#dateTime`&&(s=new Date(Date.parse(r.value)).toLocaleString()));let l;return M(r.value)?(l=document.createElement(`a`),l.setAttribute(`href`,r.value)):l=document.createElement(`div`),l.classList.add(`d-flex`),l.innerText=s,c&&l.appendChild(c),a.appendChild(l),a}};function Ie(e,n,r){if(r){let r=V(e)>0;if(e.class&&!e.hasValue)return e.config.theme.createListEditor(e.label,n,r,ve(e.class,e),e);if(e.in){let t=e.config.lists[e.in];if(t?.length){let i=ge(t,e.config.store,e.config.languages);return e.config.theme.createListEditor(e.label,n,r,i,e)}else console.error(`list not found:`,e.in,`existing lists:`,e.config.lists)}if(e.datatype?.equals(ae)||e.languageIn?.length||e.datatype===void 0&&n instanceof t&&n.language)return e.config.theme.createLangStringEditor(e.label,n,r,e);switch(e.datatype?.value.replace(g,``)){case`integer`:case`float`:case`double`:case`decimal`:return e.config.theme.createNumberEditor(e.label,n,r,e);case`date`:case`dateTime`:return e.config.theme.createDateEditor(e.label,n,r,e);case`boolean`:return e.config.theme.createBooleanEditor(e.label,n,r,e);case`base64Binary`:return e.config.theme.createFileEditor(e.label,n,r,e)}return e.config.theme.createTextEditor(e.label,n,r,e)}else return n?e.config.theme.createViewer(e.label,n,e):document.createElement(`div`)}function Le(e,t,n){if(t===`application/ld+json`)return Re(e);{let r=new a({format:t,prefixes:n});r.addQuads(e);let i=``;return r.end((e,t)=>{e&&console.error(e),i=t}),i}}function Re(e){let n=[];for(let r of e){let e={"@id":r.subject.id};if(r.predicate===S)e[`@type`]=r.object.id;else{let n=r.object.value;r.object instanceof t?r.object.language?n={"@language":r.object.language,"@value":r.object.value}:r.object.datatype&&r.object.datatype.value!==`http://www.w3.org/2001/XMLSchema##string`&&(n={"@type":r.object.datatype.value,"@value":r.object.value}):n={"@id":r.object.id},e[r.predicate.value]=n}n.push(e)}return JSON.stringify(n)}function ze(t){let r=t.shaclDatatype,i=t.dataset.value||t.value;if(t.type===`checkbox`||t.getAttribute(`type`)===`checkbox`){if(t.checked||parseInt(t.dataset.minCount||`0`)>0)return e.literal(t.checked?`true`:`false`,r)}else if(i){if(i.startsWith(`<`)&&i.endsWith(`>`)&&i.indexOf(`:`)>-1)return e.namedNode(i.substring(1,i.length-1));if(t.dataset.class||t.dataset.nodeKind===`http://www.w3.org/ns/shacl#IRI`)return e.namedNode(i);if(t.dataset.link)return JSON.parse(t.dataset.link);if(t.dataset.lang?r=t.dataset.lang:t.type===`number`?i=parseFloat(i):t.type===`file`&&t.binaryData?i=t.binaryData:t.type===`datetime-local`&&(i=new Date(i).toISOString().slice(0,19)),(!r||r instanceof n&&fe.equals(r))&&typeof i==`string`){let t=i.split(`^^`);t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)&&t[1].split(`:`).length===2?(i=t[0].substring(1,t[0].length-1),r=e.namedNode(t[1])):(t=i.split(`@`),t.length===2&&t[0].startsWith(`"`)&&t[0].endsWith(`"`)?(i=t[0].substring(1,t[0].length-1),r=t[1]):i.startsWith(`"`)&&i.endsWith(`"`)&&(i=i.substring(1,i.length-1)))}return e.literal(i,r)}}var U={};function Be(e){e.predicate===void 0&&e.datatype===void 0?console.warn(`not registering plugin because it does neither define "predicate" nor "datatype"`,e):U[`${e.predicate}^${e.datatype}`]=e}function Ve(){return Object.entries(U).map(e=>e[1])}function He(e,t){let n=U[`${e}^${t}`];return n||(n=U[`${e}^undefined`],n)?n:U[`undefined^${t}`]}var Ue=class{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)}};async function We(e){if(e.template.nodeShapes.size===0)return;let t=e.template.config.resourceLinkProvider;if((!t||t&&!t.lazyLoad)&&(await Je(e.template),Ke(e).length===0))return;let n=e.template.config.theme.createButton(e.template.label,!1);n.title=`Link existing `+e.template.label,n.classList.add(`link-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}link-button`),n.addEventListener(`click`,async()=>{t?.lazyLoad&&(n.classList.add(`loading`),await Je(e.template),n.classList.remove(`loading`));let r=Ke(e);if(r.length===0)n.innerText=`No linkable resources found`,n.setAttribute(`disabled`,``),setTimeout(()=>n.remove(),2e3);else{let t=e.template.config.form.querySelector(`#dialog`);t||(t=new u,t.classList.add(`link-chooser`),t.closable=!0,e.template.config.form.appendChild(t)),t.title=`Link existing `+e.template.label,Ge(t,e,r),t.open=!0}}),n}function Ge(e,t,n){let r=document.createElement(`div`);for(let i of n){let n=document.createElement(`div`);n.classList.add(`link-option`),n.title=`Link this resource`,n.innerText=i.label||i.value,n.addEventListener(`click`,()=>{qe(i.value,t),e.open=!1}),r.appendChild(n)}e.replaceChildren(r)}function Ke(t){let n=[];if(t.template.config.resourceLinkProvider){for(let r of t.template.nodeShapes)if(t.template.config.providedConformingResourceIds[r.id.value])for(let i of t.template.config.providedConformingResourceIds[r.id.value])t.querySelector(`:scope > .property-instance > shacl-node[data-node-id='${i}'], :scope > .collapsible > .property-instance > shacl-node[data-node-id='${i}']`)===null&&n.push({value:i,label:A(t.template.config.store.getQuads(e.namedNode(i),null,null,null),t.template.config.languages),children:[]})}return n}async function qe(t,n){let r=e.namedNode(t);if(Ze(r,n.template.config.store)){if(n.template.config.providedResources[t]?.length>0){let e={store:n.template.config.store,importedUrls:[],atts:{loadOwlImports:!1}};await L(z(n.template.config.providedResources[t]),e,b),n.template.config.providedResources[t]=``}let e=await K(n.template,r,!0,!0);n.container.insertBefore(e,n.querySelector(`:scope > .add-button-wrapper`)),await n.updateControls()}}async function Je(e){let t=e.config.resourceLinkProvider;if(!t)return;let n=new Set(Array.from(e.nodeShapes).map(e=>e.id.value));if(n.size===0)return;let r=xe(Object.keys(e.config.providedConformingResourceIds),n);if(r.length!==0)try{let n=await t.listConformingResources(r,e);if(n){for(let t of Object.keys(n)){let r=new Set(n[t]);e.config.providedConformingResourceIds[t]=r,await Ye(r,!1,e.config)}for(let t of r)e.config.providedConformingResourceIds[t]||(e.config.providedConformingResourceIds[t]=new Set)}}catch(e){console.error(`failed loading conforming resources`,e)}}async function Ye(e,t,n){if(n.resourceLinkProvider&&e.size>0){let r=[];for(let t of e)n.providedResources[t]||r.push(t);if(r.length===0)return[];try{let e=await n.resourceLinkProvider.loadResources(r);if(e){let r={store:n.store,importedUrls:[],atts:{loadOwlImports:!1}};for(let i of e)n.providedResources[i.resourceId]=i.resourceRDF,t&&await L(z(i.resourceRDF),r,b);return e}for(let e of r)n.providedResources[e]||(n.providedResources[e]=``)}catch(e){console.error(`failed loading resources`,e)}}return[]}async function Xe(e){let t=new Set;for(let n of e.store.getQuads(null,null,null,x))Ze(n.object,e.store)&&t.add(n.object.value);await Ye(t,!0,e)}function Ze(e,t){return e.termType===`NamedNode`&&t.countQuads(e,null,null,null)===0}var W=`:scope > .add-button-wrapper, :scope > .collapsible > .add-button-wrapper`,Qe=`:scope > .property-instance, :scope > .shacl-or-constraint, :scope > shacl-node, :scope > .collapsible > .property-instance`,G=class extends HTMLElement{constructor(e,t){if(super(),this.template=e,this.parent=t,this.container=this,this.setAttribute(`part`,`property`),this.template.nodeShapes.size&&this.template.config.attributes.collapse!==null&&(this.template.maxCount===void 0||this.template.maxCount>1)){let t=new l;t.classList.add(`collapsible`,`shacl-group`),t.open=e.config.attributes.collapse===`open`,t.label=this.template.label,t.setAttribute(`part`,`collapsible`),this.container=t,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&&!t.linked&&this.addEventListener(`change`,async()=>{await this.updateControls()})}async bindValues(e,t){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:x);t&&(r=await this.filterValidValues(r,e));for(let e of r)this.parent.linked||this.template.config.store.delete(e),await this.addPropertyInstance(e.object,!x.equals(e.graph)||this.template.config.providedResources[e.object.value]!==void 0,this.template.config.providedResources[e.object.value]!==void 0),this.template.hasValue&&e.object.equals(this.template.hasValue)&&(n=!0)}this.template.config.editMode&&this.template.hasValue&&!n&&!this.parent.linked&&await this.addPropertyInstance(this.template.hasValue)}}async addPropertyInstance(e,t,n=!1){let r;if(this.template.or?.length||this.template.xone?.length){let t=this.template.or?.length?this.template.or:this.template.xone,n=!1;if(e){let i=Me(t,e,this.template.config);i.length&&(r=await K(H(ke(this.template),i),e,!this.parent.linked,this.parent.linked,this.parent),n=!0)}!n&&this.template.config.editMode&&(r=je(t,this,this.template.config),$e(r,``,this.template.config.theme.dense,this.template.config.hierarchyColorsStyleSheet!==void 0))}else r=await K(this.template,e,n,t||this.parent.linked,this.parent);return r&&this.container.insertBefore(r,this.querySelector(W)),r}async updateControls(){this.template.config.editMode&&!this.parent.linked&&!this.querySelector(W)&&this.container.appendChild(await this.createAddControls());let e=V(this.template),t=this.template.nodeShapes.size===0,n=this.querySelector(`:scope > .add-button-wrapper > .link-button, :scope > .collapsible > .add-button-wrapper > .link-button`)===null,r=t||!this.hasRecursiveNodeShape(),i=this.instanceCount();i===0&&r&&(t||n&&e>0)&&(await this.addPropertyInstance(),i=1),t||this.querySelector(W)?.classList.toggle(`required`,i<e);let a;a=e>0?i>e:!t||i>1;let o=i<Oe(this.template);this.classList.toggle(`may-remove`,a),this.classList.toggle(`may-add`,o)}instanceCount(){return this.querySelectorAll(Qe).length}hasRecursiveNodeShape(){let e=new Set;this.parent.ancestorShapeIds.forEach(t=>e.add(t)),e.add(this.parent.template.id.value);for(let t of this.template.nodeShapes)if(e.has(t.id.value))return!0;return!1}toRDF(t,n){let r=e.namedNode(this.template.path);for(let e of this.querySelectorAll(`:scope > .property-instance, :scope > .collapsible > .property-instance`))if(e.firstChild instanceof q){let i=e.firstChild.toRDF(t);t.addQuad(n,r,i,this.template.config.valuesGraphId)}else if(this.template.config.editMode)for(let i of e.querySelectorAll(`:scope > .editor`)){let e=ze(i);e&&t.addQuad(n,r,e,this.template.config.valuesGraphId)}else{let i=ze(e);i&&t.addQuad(n,r,i,this.template.config.valuesGraphId)}}async filterValidValues(e,t){let n=this.template.id,r=[t];if(this.template.qualifiedValueShape){n=this.template.qualifiedValueShape.id,r=[];for(let t of e)r.push(t.object)}let i=await this.template.config.validator.validate({dataset:this.template.config.store,terms:r},[{terms:[n]}]),a=new Set;for(let e of i.results){let t=this.template.qualifiedValueShape?e.focusNode:e.value;t?.ptrs?.length&&a.add(t.ptrs[0]._term.id)}return e.filter(e=>!a.has(e.object.id))}async createAddControls(){let e=document.createElement(`div`);e.classList.add(`add-button-wrapper`),e.setAttribute(`part`,`add-controls`);let t=await We(this);t&&e.appendChild(t);let n=this.template.config.theme.createButton(this.template.label,!1);n.title=`Add `+this.template.label,n.classList.add(`add-button`),n.setAttribute(`text`,``);let r=n.getAttribute(`part`);return n.setAttribute(`part`,`${r?r+` `:``}add-button`),n.addEventListener(`click`,async()=>{let e=await this.addPropertyInstance();e&&(e.classList.add(`fadeIn`),await this.updateControls(),setTimeout(()=>{he(e),e.classList.remove(`fadeIn`)},200))}),e.appendChild(n),e}};async function K(e,n,r=!1,i=!1,a){let o;if(e.nodeShapes.size){o=document.createElement(`div`),o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`);let t=new Set(a?.ancestorShapeIds??[]);a&&t.add(a.template.id.value);for(let r of e.nodeShapes){let a=new q(r,n,e.nodeKind,e.label,i,t);o.appendChild(a),await a.ready}}else{let t=He(e.path,e.datatype?.value);o=t?e.config.editMode&&!i?t.createEditor(e,n):t.createViewer(e,n):Ie(e,n||null,e.config.editMode&&!i),o.childNodes.length>0&&(o.classList.add(`property-instance`),o.setAttribute(`part`,`property-instance`)),i&&o.classList.add(`linked`)}return e.config.editMode&&(!i||r)?$e(o,e.label,e.config.theme.dense,e.config.hierarchyColorsStyleSheet!==void 0,r):e.config.hierarchyColorsStyleSheet!==void 0&&o.appendChild(et(!0)),n&&!e.config.editMode&&(n instanceof t?(o.dataset.value=n.value,n.language.length>0?o.dataset.lang=n.language:o.shaclDatatype=n.datatype):o.dataset.value=`<`+n.value+`>`),o.dataset.path=e.path,o}function $e(e,t,n,r,i=!1){let a=et(r),o=new c;o.classList.add(`remove-button`,`clear`),o.title=`Remove `+t,o.dense=n,o.icon=!0;let s=o.getAttribute(`part`);o.setAttribute(`part`,`${s?s+` `:``}remove-button`),o.addEventListener(`click`,()=>{e.classList.remove(`fadeIn`),e.classList.add(`fadeOut`),setTimeout(()=>{let t=e.parentElement;e.remove(),t?.dispatchEvent(new Event(`change`,{bubbles:!0,cancelable:!0}))},200)}),i&&o.classList.add(`persistent`),a.appendChild(o),e.appendChild(a)}function et(e){let t=document.createElement(`div`);return t.className=`remove-button-wrapper`,t.setAttribute(`part`,`remove-controls`),e&&t.classList.add(`colorize`),t}window.customElements.define(`shacl-property`,G);function tt(e,t){let n=e,r=t.store.getQuads(e,null,null,null),i=k(r,`label`,v,t.languages);i&&(n=i);let a;if(t.attributes.collapse!==null)a=new l,a.classList.add(`collapsible`),a.open=t.attributes.collapse===`open`,a.label=n,a.setAttribute(`part`,`group collapsible`);else{a=document.createElement(`div`);let e=document.createElement(`h1`);e.innerText=n,e.setAttribute(`part`,`group-title`),a.appendChild(e),a.setAttribute(`part`,`group`)}a.dataset.subject=e,a.classList.add(`shacl-group`);let o=k(r,`order`);return o&&(a.style.order=o),a}var q=class t extends HTMLElement{constructor(n,r,i,a,o,s=new Set){super(),this.template=n,this.linked=o??!1,this.ancestorShapeIds=s,this.setAttribute(`part`,`node`);let c=r;c||=(!i&&n.nodeKind&&(i=n.nodeKind),i===void 0&&n.config.attributes.valuesNamespace||i?.value===`http://www.w3.org/ns/shacl#IRI`?e.namedNode(n.config.attributes.valuesNamespace+m()):e.blankNode(m())),this.nodeId=c;let l=JSON.stringify([n.id,r]);if(r&&n.config.renderedNodes.has(l)){a||=`Link`;let e=document.createElement(`label`);e.innerText=a,e.classList.add(`linked`),this.appendChild(e);let t=this.getAttribute(`part`);this.setAttribute(`part`,`${t?t+` `:``}linked-node`);let n=document.createElement(`a`),i=r.termType===`BlankNode`?`_:`+r.value:r.value;n.innerText=i,n.classList.add(`ref-link`),n.onclick=()=>{this.template.config.form.querySelector(`shacl-node[data-node-id='${i}']`)?.scrollIntoView()},this.appendChild(n),this.style.flexDirection=`row`,this.ready=Promise.resolve()}else{r&&n.config.renderedNodes.add(l);let e=this.ancestorShapeIds,i=this.template.id.value;if(this.dataset.nodeId=this.nodeId.id,this.template.config.attributes.showNodeIds!==null){let e=document.createElement(`div`);e.innerText=`id: ${this.nodeId.id}`,e.classList.add(`node-id-display`),this.appendChild(e)}this.ready=(async()=>{let s=new Set(e);s.add(i);for(let[e,t]of Object.entries(n.properties))for(let e of t)await this.addPropertyInstance(e,r,t.length>1);for(let e of n.extendedShapes){let n=new t(e,r,void 0,void 0,o,s);this.prepend(n),await n.ready}if(n.or?.length&&await this.tryResolve(n.or,r,n.config),n.xone?.length&&await this.tryResolve(n.xone,r,n.config),a){let e=document.createElement(`h1`);e.innerText=a,e.setAttribute(`part`,`node-title`),this.prepend(e)}})()}}toRDF(t,n,r=``){if(n||=this.nodeId,!this.linked){for(let e of this.querySelectorAll(`:scope > shacl-node, :scope > .shacl-group > shacl-node, :scope > shacl-property, :scope > .shacl-group > shacl-property`))e.toRDF(t,n);this.template.targetClass&&t.addQuad(n,S,this.template.targetClass,this.template.config.valuesGraphId),r&&t.addQuad(n,e.namedNode(r),this.template.id,this.template.config.valuesGraphId)}return n}async addPropertyInstance(e,t,n){let r=null;if(e.group)if(e.config.groups.indexOf(e.group)>-1){let t=this.querySelector(`:scope > .shacl-group[data-subject='${e.group}']`);t||(t=tt(e.group,e.config),this.appendChild(t)),r=t}else console.warn(`ignoring unknown group reference`,e.group,`existing groups:`,e.config.groups);let i=new G(e,this);await i.bindValues(t,n),(e.config.editMode||i.instanceCount()>0)&&(r?r.appendChild(i):this.appendChild(i),await i.updateControls())}async tryResolve(e,t,n){let r=!1;if(t){let i=Ne(e,t,n);if(i.length){for(let e of i)await this.addPropertyInstance(n.getPropertyTemplate(e,this.template),t);r=!0}}r||this.appendChild(je(e,this,n))}};window.customElements.define(`shacl-node`,q);var nt=`
|
|
84
84
|
.editor:not([type='checkbox']) { border: 1px solid var(--shacl-border-color, #DDD); }
|
|
85
85
|
.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; }
|
|
86
86
|
.property-instance:not(:first-child) > label:not(.persistent) { visibility: hidden; max-height: 0; }
|
|
87
87
|
.mode-edit .property-instance label { width: var(--label-width); }
|
|
88
|
-
|
|
89
|
-
`+
|
|
90
|
-
`).replace(/:host\b/g
|
|
91
|
-
`);this.styleElement||(this.styleElement=document.createElement(
|
|
92
|
-
:scope shacl-node[data-node-id='${
|
|
93
|
-
:scope shacl-node[data-node-id='${
|
|
94
|
-
:scope shacl-node[data-node-id='${
|
|
95
|
-
:scope shacl-node[data-node-id='${
|
|
96
|
-
:scope [data-node-id='${
|
|
97
|
-
:scope [data-node-id='${
|
|
98
|
-
`;else n.sourceConstraintComponent?.value&&(o.title=n.sourceConstraintComponent.value);else typeof e=="string"&&(o.title=e);return o}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){const e=h.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(e,b,_,null).length===0){console.warn(`shapes graph does not contain requested node shape ${this.config.attributes.shapeSubject}`);return}else return e}else{if(this.config.attributes.valuesSubject&&this.config.store.countQuads(null,null,null,m)>0){const s=h.namedNode(this.config.attributes.valuesSubject),o=Ze(this.config.store,this.config.attributes.valuesSubject),n=this.config.store.getQuads(s,b,null,m);if(n.length===0&&console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${b.id} nor ${N.id} statement`),o)return o;for(const a of n)if(this.config.store.getQuads(a.object,b,_,null).length>0)return a.object;const i=this.config.store.getObjects(s,b,m);for(const a of i)for(const r of this.config.store.getQuads(null,U,a,null))return r.subject}const e=this.config.store.getQuads(null,b,_,null);if(e.length==0){console.warn("shapes graph does not contain any node shapes");return}return e.length>1&&(console.warn("shapes graph contains",e.length,"node shapes. choosing first found which is",e[0].subject.value),console.info('hint: set the node shape to use with element attribute "data-shape-subject"')),e[0].subject}}removeFromDataGraph(e){for(const s of this.config.store.getQuads(e,null,null,m))this.config.store.delete(s),(s.object.termType==="NamedNode"||s.object.termType==="BlankNode")&&this.removeFromDataGraph(s.object)}}window.customElements.define("shacl-form",Rt);export{be as Config,St as DefaultTheme,Nt as Plugin,Rt as ShaclForm,he as ShaclPropertyTemplate,rt as Theme,F as fetchRDF,Ze as findConformsToShapeSubject,xe as findConformsToValuesSubject,C as findLabel,E as importRDF,It as initTimeout,et as loadGraphs,j as parseRDF,P as prefixes,st as propertyMappers,O as rdfCache,ut as registerPlugin};
|
|
88
|
+
`,J=class extends Fe{constructor(e){super(e||nt),this.idCtr=0}createDefaultTemplate(r,i,a,o,s){if(o.id=`e${this.idCtr++}`,o.classList.add(`editor`),o.setAttribute(`part`,`editor`),s?.datatype?o.shaclDatatype=s.datatype:i instanceof t&&(o.shaclDatatype=i.datatype),s&&V(s)>0&&(o.dataset.minCount=String(V(s))),s?.class&&(o.dataset.class=s.class.value),s?.nodeKind)o.dataset.nodeKind=s.nodeKind.value;else if(i&&(i instanceof n||s?.nodeKind?.equals(le))&&(o.dataset.nodeKind=h+`IRI`,s)){let t=A(s.config.store.getQuads(i,null,null,null),s.config.languages);t&&(o.dataset.value=`<`+i.value+`>`,i=e.literal(t))}(s?.hasValue&&i||s?.readonly)&&(o.disabled=!0),s?.datatype?.equals(pe)?o.checked=i?.value===`true`||s?.defaultValue?.value===`true`:o.value=i?.value||s?.defaultValue?.value||``;let c=document.createElement(`label`);c.htmlFor=o.id,c.innerText=r,c.setAttribute(`part`,`label`),s?.description&&c.setAttribute(`title`,s.description.value);let l=s?.description?s.description.value:s?.pattern?s.pattern:null;l&&o.setAttribute(`placeholder`,l),a&&(o.setAttribute(`required`,`true`),c.classList.add(`required`));let u=document.createElement(`div`);return u.setAttribute(`part`,`field`),u.appendChild(c),u.appendChild(o),u}createDateEditor(e,t,n,r){let i=new d;r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?(i.type=`datetime-local`,i.setAttribute(`step`,`1`)):i.type=`date`,i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let a=this.createDefaultTemplate(e,null,n,i,r);if(t)try{let e=new Date(t.value).toISOString();e=r.datatype?.value===`http://www.w3.org/2001/XMLSchema#dateTime`?e.slice(0,19):e.slice(0,10),i.value=e}catch(e){console.error(e,t)}return a}createTextEditor(e,t,n,r){let i;return r.singleLine===!1?(i=new p,i.resize=`auto`):i=new d,i.dense=this.dense,r.pattern&&(i.pattern=r.pattern),r.minLength&&(i.minLength=r.minLength),r.maxLength&&(i.maxLength=r.maxLength),this.createDefaultTemplate(e,t,n,i,r)}createLangStringEditor(e,n,r,i){let a=this.createTextEditor(e,n,r,i),o=a.querySelector(`:scope .editor`),s;if(i.languageIn?.length){s=document.createElement(`select`);for(let e of i.languageIn){let t=document.createElement(`option`);t.innerText=e.value,s.appendChild(t)}}else s=document.createElement(`input`),s.maxLength=5,s.size=5,s.placeholder=`lang?`;return s.title=`Language of the text`,s.classList.add(`lang-chooser`),s.setAttribute(`part`,`lang-chooser`),s.slot=`suffix`,o.addEventListener(`change`,()=>{s.required=o.value!==``}),s.addEventListener(`change`,e=>{e.stopPropagation(),o&&(o.dataset.lang=s.value,o.dispatchEvent(new Event(`change`,{bubbles:!0})))}),n instanceof t&&(s.value=n.language),o.dataset.lang=s.value,o.appendChild(s),a}createBooleanEditor(e,n,r,i){let a=document.createElement(`input`);a.type=`checkbox`,a.classList.add(`ml-0`);let o=this.createDefaultTemplate(e,null,r,a,i);return a.removeAttribute(`required`),o.querySelector(`:scope label`)?.classList.remove(`required`),n instanceof t&&(a.checked=n.value===`true`),o}createFileEditor(e,t,n,r){let i=document.createElement(`input`);return i.type=`file`,i.addEventListener(`change`,e=>{if(i.files?.length){e.stopPropagation();let t=new FileReader;t.readAsDataURL(i.files[0]),t.onload=()=>{i.binaryData=btoa(t.result),i.parentElement?.dispatchEvent(new Event(`change`,{bubbles:!0}))}}else i.binaryData=void 0}),this.createDefaultTemplate(e,t,n,i,r)}createNumberEditor(e,t,n,r){let i=new d;i.type=`number`,i.clearable=!0,i.dense=this.dense,i.classList.add(`pr-0`);let a=r.minInclusive===void 0?r.minExclusive===void 0?void 0:r.minExclusive+1:r.minInclusive,o=r.maxInclusive===void 0?r.maxExclusive===void 0?void 0:r.maxExclusive-1:r.maxInclusive;return a!==void 0&&(i.min=String(a)),o!==void 0&&(i.max=String(o)),r.datatype?.value!==`http://www.w3.org/2001/XMLSchema#integer`&&(i.step=`any`),this.createDefaultTemplate(e,t,n,i,r)}createListEditor(e,t,r,i,a){let o=new f;o.clearable=!0,o.dense=this.dense;let s=this.createDefaultTemplate(e,null,r,o,a),c=document.createElement(`ul`),l=!0,u=(e,t)=>{let r=document.createElement(`li`);if(typeof e.value==`string`?(r.dataset.value=e.value,r.innerText=e.label?e.label:e.value):(r.dataset.value=e.value.id,e.value instanceof n&&(r.dataset.value=`<`+r.dataset.value+`>`),r.innerText=e.label?e.label:e.value.value),t.appendChild(r),e.children?.length){l=!1;let t=document.createElement(`ul`);r.appendChild(t);for(let n of e.children)u(n,t)}};for(let e of i)u(e,c);return l||(o.collapse=!0),o.appendChild(c),t=t??a?.defaultValue??null,t&&(o.value=t.id,t instanceof n&&(o.value=`<`+o.value+`>`)),s}createButton(e,t){let n=new c;return n.dense=this.dense,n.innerHTML=e,t?(n.setAttribute(`primary`,``),n.setAttribute(`part`,`button primary`)):n.setAttribute(`part`,`button`),n}},rt={[`${h}node`]:(e,t)=>{e.extendedShapes.add(new Y(t,e.config,e))},[`${h}and`]:(e,t)=>{for(let n of e.config.lists[t.value])e.extendedShapes.add(new Y(n,e.config,e))},[`${h}property`]:(e,t)=>{let n=e.config.getPropertyTemplate(t,e);if(n.path){let t=e.properties[n.path];if(t||(t=[],e.properties[n.path]=t),n.qualifiedValueShape)t.push(n);else{let r;for(let t=0;t<e.properties[n.path].length&&!r;t++)e.properties[n.path][t].qualifiedValueShape||(r=e.properties[n.path][t]);r?Ae(r,n):t.push(n)}}},[`${h}nodeKind`]:(e,t)=>{e.nodeKind=t},[`${h}targetClass`]:(e,t)=>{e.targetClass=t},[`${h}or`]:(e,t)=>{e.or=e.config.lists[t.value]},[`${h}xone`]:(e,t)=>{e.xone=e.config.lists[t.value]},[w.id]:(e,t)=>{e.owlImports.add(t)},[`${y}title`]:(e,t)=>{let n=t;e.label=N(e.config.languages,e.label,n)},[`${v}label`]:(e,t)=>{let n=t;e.label=N(e.config.languages,e.label,n)}},Y=class{constructor(e,t,n){this.extendedShapes=new Set,this.properties={},this.owlImports=new Set,this.id=e,this.config=t,this.parent=n,t.registerNodeTemplate(this),it(this,this.config.store.getQuads(e,null,null,null))}};function it(e,t){for(let n of t)rt[n.predicate.id]?.call(e,e,n.object);return e}function at(e){for(let t of Object.values(e.properties))for(let n of t){let[t,r]=X(e,n.path);if(t.length>1&&r){let e=t[t.length-1];for(let n=t.length-2;n>=0;n--){let r=t[n];delete r.parent.properties[r.path],Ae(e,r)}}}}function X(e,t,n=new Set,r=[],i=!1){if(!n.has(e.id.value)){n.add(e.id.value);let a=e.properties[t];if(a?.length===1){r.push(a[0]),i||=a[0].maxCount===1;for(let e of a[0].nodeShapes){let[a,o]=X(e,t,n,r,i);i||=o}}for(let a of e.extendedShapes){let[e,o]=X(a,t,n,r,i);i||=o}}return[r,i]}var Z=class{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.hierarchyColors=null,this.submitButton=null,this.generateNodeShapeReference=C.value,this.showNodeIds=null,this.showRootShapeLabel=null,this.dense=`true`,this.useShadowRoot=`true`}},ot=`#4c93d785, #f85e9a85, #00327385, #87001f85`,Q=class{constructor(t){this.attributes=new Z,this.editMode=!0,this.lists={},this.groups=[],this.renderedNodes=new Set,this._store=new r,this._nodeTemplates={},this._propertyTemplates={},this.validator=new ee(this._store,{details:!0,factory:e}),this.providedConformingResourceIds={},this.providedResources={},this.form=t,this._theme=new J,this.languages=[...new Set(navigator.languages.flatMap(e=>e.length>2?[e.toLocaleLowerCase(),e.substring(0,2)]:e)),``]}reset(){this.lists={},this.groups=[],this.renderedNodes.clear(),this.providedConformingResourceIds={},this.providedResources={},this._nodeTemplates={},this._propertyTemplates={}}updateAttributes(t){let n=new Z;if(Object.keys(n).forEach(e=>{let r=t.dataset[e];r!==void 0&&(n[e]=r)}),this.editMode=n.view===null,this.theme.setDense(n.dense===`true`),this.attributes=n,this.attributes.valueSubject&&!this.attributes.valuesSubject&&(this.attributes.valuesSubject=this.attributes.valueSubject),n.language){let e=this.languages.indexOf(n.language);e>-1&&this.languages.splice(e,1),this.languages.unshift(n.language)}if(n.valuesGraph&&(this.valuesGraphId=e.namedNode(n.valuesGraph)),n.hierarchyColors!=null){let e=n.hierarchyColors.length?n.hierarchyColors:ot,t=`:host { --hierarchy-colors: ${e}; --hierarchy-colors-length: ${e.split(`,`).length} }`;for(let e=8;e>=0;e--){let n=`shacl-property { --hierarchy-level: ${e} }`;for(let t=0;t<e;t++)n=`shacl-property `+n;t=t+`
|
|
89
|
+
`+n}this.hierarchyColorsStyleSheet=new CSSStyleSheet,this.hierarchyColorsStyleSheet.replaceSync(t)}}static dataAttributes(){let e=new Z;return Object.keys(e).map(e=>(e=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase()),`data-`+e))}buildTemplateKey(e,t){let n=e.value;return t&&(t instanceof B?n+=`*`+t.id.value:n+=`*`+this.buildTemplateKey(t.id,t.parent)),n}registerNodeTemplate(e){this._nodeTemplates[this.buildTemplateKey(e.id,e.parent)]=e}registerPropertyTemplate(e){this._propertyTemplates[this.buildTemplateKey(e.id,e.parent)]=e}getNodeTemplateIds(){let e=new Set;for(let t of Object.values(this._nodeTemplates))e.add(t.id.value);return e}getNodeTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._nodeTemplates[n];return r||=new Y(e,this,t),r}getPropertyTemplate(e,t){let n=this.buildTemplateKey(e,t),r=this._propertyTemplates[n];return r||=new B(e,t),r}get nodeTemplates(){return Object.values(this._nodeTemplates)}get theme(){return this._theme}set theme(e){this._theme=e,e.setDense(this.attributes.dense===`true`)}get store(){return this._store}set store(t){this._store=t,this.lists=Se(t,{ignoreErrors:!0}),this.groups=[],t.forSubjects(e=>{this.groups.push(e.id)},S,`${h}PropertyGroup`,null),this.validator=new ee(t,{details:!0,factory:e})}},st=200,$=class extends HTMLElement{static get observedAttributes(){return Q.dataAttributes()}constructor(){super(),this.shape=null,this.styleElement=null,this.form=document.createElement(`form`),this.form.setAttribute(`part`,`form`),this.config=new Q(this.form),this.form.addEventListener(`change`,e=>{e.stopPropagation(),this.config.editMode&&this.validate(!0).then(e=>{this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,cancelable:!1,composed:!0,detail:{valid:e.conforms,report:e}}))}).catch(e=>{console.warn(e)})})}connectedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}attributeChangedCallback(){this.config.updateAttributes(this),this.ensureRenderRoot(),this.initialize()}initialize(){clearTimeout(this.initDebounceTimeout),this.setAttribute(`loading`,``),this.form.replaceChildren(document.createTextNode(this.config.attributes.loading)),this.initDebounceTimeout=setTimeout(async()=>{try{this.config.reset(),this.config.store=await we({shapes:this.config.attributes.shapes,shapesUrl:this.config.attributes.shapesUrl,values:this.config.attributes.values,valuesUrl:this.config.attributes.valuesUrl,valuesSubject:this.config.attributes.valuesSubject,loadOwlImports:this.config.attributes.ignoreOwlImports===null,classInstanceProvider:this.config.classInstanceProvider,proxy:this.config.attributes.proxy}),this.config.resourceLinkProvider&&await Xe(this.config),this.config.attributes.valuesSubject||(this.config.attributes.valuesSubject=I(this.config.store)||null),this.form.replaceChildren();let t=this.findRootShaclShapeSubject();if(t){this.form.classList.forEach(e=>{this.form.classList.remove(e)}),this.form.classList.toggle(`mode-edit`,this.config.editMode),this.form.classList.toggle(`mode-view`,!this.config.editMode),this.config.theme.apply(this.form);let n=[this.config.theme.stylesheet];this.config.hierarchyColorsStyleSheet&&n.push(this.config.hierarchyColorsStyleSheet);for(let e of Ve())e.stylesheet&&n.push(e.stylesheet);this.applyStyles(n);let r=new Y(t,this.config);for(let e of this.config.nodeTemplates)at(e);if(this.shape=new q(r,this.config.attributes.valuesSubject?e.namedNode(this.config.attributes.valuesSubject):void 0),this.form.appendChild(this.shape),this.config.attributes.showRootShapeLabel!==null&&r.label){let e=document.createElement(`h3`);e.innerText=r.label.value,this.form.prepend(e)}if(this.config.editMode){if(this.config.attributes.submitButton!==null){let e=this.config.theme.createButton(this.config.attributes.submitButton||`Submit`,!0);e.classList.add(`submit-button`);let t=e.getAttribute(`part`);e.setAttribute(`part`,`${t?t+` `:``}submit-button`),e.addEventListener(`click`,e=>{e.preventDefault(),this.form.reportValidity()&&this.validate().then(e=>{if(e?.conforms)this.dispatchEvent(new Event(`submit`,{bubbles:!0,cancelable:!0}));else{let e=this.form.querySelector(`:scope .invalid > .editor`);e?e.focus():this.form.querySelector(`:scope .invalid`)?.scrollIntoView()}})}),this.form.appendChild(e)}(async()=>{await this.shape?.ready,this.config.attributes.valuesSubject&&this.removeFromDataGraph(e.namedNode(this.config.attributes.valuesSubject)),this.validate(!0)})()}}else if(this.config.store.countQuads(null,null,null,b)>0)throw Error(`shacl root node shape not found`)}catch(e){console.error(e);let t=document.createElement(`div`);t.innerText=String(e),this.form.replaceChildren(t)}this.removeAttribute(`loading`),await this.shape?.ready,this.dispatchEvent(new Event(`ready`))},200)}ensureRenderRoot(){this.config.attributes.useShadowRoot===`false`?(this.shadowRoot?.contains(this.form)&&this.shadowRoot.removeChild(this.form),this.contains(this.form)||this.prepend(this.form)):(this.shadowRoot||this.attachShadow({mode:`open`}),this.shadowRoot.contains(this.form)||this.shadowRoot.prepend(this.form))}applyStyles(e){if(this.config.attributes.useShadowRoot!==`false`&&this.shadowRoot){this.shadowRoot.adoptedStyleSheets=e,this.styleElement&&=(this.styleElement.remove(),null);return}let t=e.map(e=>Array.from(e.cssRules).map(e=>e.cssText).join(`
|
|
90
|
+
`).replace(/:host\b/g,`shacl-form`)).join(`
|
|
91
|
+
`);this.styleElement||(this.styleElement=document.createElement(`style`),this.prepend(this.styleElement)),this.styleElement.textContent=t}serialize(e=`text/turtle`,t=this.toRDF()){return Le(t.getQuads(null,null,null,null),e,F)}toRDF(e=new r){return this.shape?.toRDF(e,void 0,this.config.attributes.generateNodeShapeReference),e}registerPlugin(e){Be(e),this.initialize()}setTheme(e){this.config.theme=e,this.initialize()}setClassInstanceProvider(e){this.config.classInstanceProvider=e,this.initialize()}setResourceLinkProvider(e){this.config.resourceLinkProvider=e,this.initialize()}async validate(e=!1){for(let e of this.form.querySelectorAll(`:scope .validation-error`))e.remove();for(let e of this.form.querySelectorAll(`:scope .property-instance`))e.classList.remove(`invalid`),e.querySelector(`:scope > .editor`)?.value?e.classList.add(`valid`):e.classList.remove(`valid`);for(let e of this.form.querySelectorAll(`.add-button-wrapper`))e.classList.remove(`invalid`,`validation-error`);if(!this.shape)return{conforms:!0,results:[]};if(!e){let e=this.form.querySelectorAll(`.add-button-wrapper.required`);for(let t of e)t.classList.add(`invalid`),t.after(this.createValidationErrorDisplay(`Value is required`,`node`));if(e.length>0)return{conforms:!1,results:[]}}let t=this.shape;return new Promise(n=>{this.config.store.deleteGraph(this.config.valuesGraphId||``).on(`end`,async()=>{t.toRDF(this.config.store,void 0,this.config.attributes.generateNodeShapeReference);try{let r=await this.config.validator.validate({dataset:this.config.store,terms:[t.nodeId]},[{terms:[t.template.id]}]);for(let t of r.results)if(t.focusNode?.ptrs?.length)for(let n of t.focusNode.ptrs){let r=n._term;if(t.path?.length){let n=t.path[0].predicates[0],i=this.form.querySelectorAll(`
|
|
92
|
+
:scope shacl-node[data-node-id='${r.id}'] > shacl-property > .property-instance[data-path='${n.id}'] > .editor,
|
|
93
|
+
:scope shacl-node[data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${n.id}'] > .editor,
|
|
94
|
+
:scope shacl-node[data-node-id='${r.id}'] > .shacl-group > shacl-property > .property-instance[data-path='${n.id}'] > .editor,
|
|
95
|
+
:scope shacl-node[data-node-id='${r.id}'] > .shacl-group > shacl-property > .shacl-group > .property-instance[data-path='${n.id}'] > .editor`);i.length===0&&(i=this.form.querySelectorAll(`
|
|
96
|
+
:scope [data-node-id='${r.id}'] > shacl-property > .property-instance[data-path='${n.id}'],
|
|
97
|
+
:scope [data-node-id='${r.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${n.id}']`));for(let n of i)if(n.classList.contains(`editor`)){if(!e||n.value){let e=n.parentElement;e.classList.add(`invalid`),e.classList.remove(`valid`),e.appendChild(this.createValidationErrorDisplay(t));do e instanceof l&&(e.open=!0),e=e.parentElement;while(e)}}else e||(n.classList.add(`invalid`),n.classList.remove(`valid`),n.appendChild(this.createValidationErrorDisplay(t,`node`)))}else e||this.form.querySelector(`:scope [data-node-id='${r.id}']`)?.prepend(this.createValidationErrorDisplay(t,`node`))}n(r)}catch(e){console.error(e),n({conforms:!1,results:[]})}})})}createValidationErrorDisplay(e,t){let n=document.createElement(`span`);n.classList.add(`validation-error`),t&&n.classList.add(t);let r=typeof e==`object`&&e?e:null;return r?r.message?.length?n.title+=ye(this.config.languages,r.message):r.sourceConstraintComponent?.value&&(n.title=r.sourceConstraintComponent.value):typeof e==`string`&&(n.title=e),n}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){let t=e.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(t,S,T,null).length===0){console.warn(`shapes graph does not contain requested node shape ${this.config.attributes.shapeSubject}`);return}else return t}else{if(this.config.attributes.valuesSubject&&this.config.store.countQuads(null,null,null,x)>0){let t=e.namedNode(this.config.attributes.valuesSubject),n=Ce(this.config.store,this.config.attributes.valuesSubject),r=this.config.store.getQuads(t,S,null,x);if(r.length===0&&console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${S.id} nor ${C.id} statement`),n)return n;for(let e of r)if(this.config.store.getQuads(e.object,S,T,null).length>0)return e.object;let i=this.config.store.getObjects(t,S,x);for(let e of i)for(let t of this.config.store.getQuads(null,O,e,null))return t.subject}let t=this.config.store.getQuads(null,S,T,null);if(t.length==0){console.warn(`shapes graph does not contain any node shapes`);return}return t.length>1&&(console.warn(`shapes graph contains`,t.length,`node shapes. choosing first found which is`,t[0].subject.value),console.info(`hint: set the node shape to use with element attribute "data-shape-subject"`)),t[0].subject}}removeFromDataGraph(e){for(let t of this.config.store.getQuads(e,null,null,x))this.config.store.delete(t),(t.object.termType===`NamedNode`||t.object.termType===`BlankNode`)&&this.removeFromDataGraph(t.object)}};window.customElements.define(`shacl-form`,$);export{Q as Config,J as DefaultTheme,Ue as Plugin,$ as ShaclForm,B as ShaclPropertyTemplate,Fe as Theme,R as fetchRDF,Ce as findConformsToShapeSubject,I as findConformsToValuesSubject,A as findLabel,L as importRDF,st as initTimeout,we as loadGraphs,z as parseRDF,F as prefixes,De as propertyMappers,P as rdfCache,Be as registerPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DataFactory as e}from"n3";import"rdfxml-streaming-parser";import"jsonld";var t=class{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)}},n=`http://www.w3.org/ns/shacl#`,r=`http://datashapes.org/dash#`,i=`http://www.w3.org/2001/XMLSchema#`,a=`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,o=`http://www.w3.org/2000/01/rdf-schema#`,s=`http://www.w3.org/2004/02/skos/core#`,c=`http://www.w3.org/2002/07/owl#`,l=`http://www.w3.org/ns/oa#`,u=`http://purl.org/dc/terms/`,d=e.namedNode(`loaded-shapes`),f=e.namedNode(`loaded-data`),p=e.namedNode(a+`type`),m=e.namedNode(a+`langString`);e.namedNode(u+`conformsTo`);var h=e.namedNode(o+`subClassOf`),g=e.namedNode(c+`imports`),_=e.namedNode(s+`broader`),v=e.namedNode(s+`narrower`);e.namedNode(n+`NodeShape`),e.namedNode(n+`IRI`),e.namedNode(n+`property`);var y=e.namedNode(n+`class`);e.namedNode(n+`node`),e.namedNode(n+`targetClass`),e.namedNode(n+`nodeKind`),e.namedNode(i+`string`),e.namedNode(i+`boolean`);function b(e,t,r=n,i){let a=``,o=x(e,t,r,i);return o&&(a=o.value),a}function x(e,t,r=n,i){let a,o=r+t;if(i?.length){for(let t of i)for(let n of e)if(n.predicate.value===o){if(n.object.id.endsWith(`@${t}`))return n.object;n.object.id.indexOf(`@`)<0?a=n.object:a||=n.object}}else for(let t of e)if(t.predicate.value===o)return t.object;return a}function S(e,t){return b(e,`prefLabel`,`http://www.w3.org/2004/02/skos/core#`,t)||b(e,`label`,`http://www.w3.org/2000/01/rdf-schema#`,t)||b(e,`title`,`http://purl.org/dc/terms/`,t)||b(e,`name`,`http://xmlns.com/foaf/0.1/`,t)}function C(e,t,n){let r=[];for(let i of e)r.push({value:i,label:S(t.getQuads(i,null,null,null),n),children:[]});return r}function w(e,t,n,r,i=new Set){for(let a of t.owlImports)i.has(a.id)||(i.add(a.id),r.push(...n.getSubjects(p,e,a)));t.parent&&w(e,t.parent,n,r,i)}function T(e,t){if(t.in){let e=t.config.lists[t.in];return C(e?.length?e:[],t.config.store,t.config.languages)}else{let n=t.config.store.getSubjects(p,e,d);n.push(...t.config.store.getSubjects(p,e,f)),w(e,t,t.config.store,n);let r=new Map,i=new Map;for(let e of n)r.set(e.id,{value:e,label:S(t.config.store.getQuads(e,null,null,null),t.config.languages),children:[]});for(let e of n){for(let n of t.config.store.getObjects(e,_,null))r.has(n.id)&&i.set(e.id,n.id);for(let n of t.config.store.getObjects(e,v,null))r.has(n.id)&&i.set(n.id,e.id);for(let n of t.config.store.getObjects(e,h,null))r.has(n.id)&&i.set(e.id,n.id)}for(let[e,t]of i.entries())r.get(t)?.children?.push(r.get(e));let a=[];for(let[e,t]of r.entries())i.has(e)||a.push(t);for(let n of t.config.store.getSubjects(h,e,null))a.push(...T(n,t));return a}}`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${r}`,`${r}`,`${l}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,`${n}`,g.id,y.id,`${n}`,`${n}`;function E(e){return Math.max(e.minCount??0,e.qualifiedMinCount??0)}export{m as a,i,C as n,t as o,T as r,E as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{o as e,t}from"./assets/property-template-c2vtkOt_.js";var n=class extends e{constructor(e,t,n){super(e),this.onChange=t,this.fileType=n}createEditor(e){let n=t(e)>0,r=e.config.theme.createFileEditor(e.label,null,n,e);return r.addEventListener(`change`,e=>{e.stopPropagation(),this.onChange(e)}),this.fileType&&r.querySelector(`input[type="file"]`)?.setAttribute(`accept`,this.fileType),r}};export{n as FileUploadPlugin};
|
package/dist/plugins/leaflet.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,t as a}from"./assets/property-template-c2vtkOt_.js";import*as o from"leaflet";import"leaflet-editable/src/Leaflet.Editable.js";import s from"leaflet/dist/leaflet.css?raw";import c from"leaflet.fullscreen/Control.FullScreen.css?raw";import"leaflet.fullscreen/Control.FullScreen.js";import{Literal as l}from"n3";function u(r,o,s){if(s){let s=a(r)>0;if(r.class&&!r.hasValue)return r.config.theme.createListEditor(r.label,o,s,i(r.class,r),r);if(r.in){let e=r.config.lists[r.in];if(e?.length){let t=n(e,r.config.store,r.config.languages);return r.config.theme.createListEditor(r.label,o,s,t,r)}else console.error(`list not found:`,r.in,`existing lists:`,r.config.lists)}if(r.datatype?.equals(e)||r.languageIn?.length||r.datatype===void 0&&o instanceof l&&o.language)return r.config.theme.createLangStringEditor(r.label,o,s,r);switch(r.datatype?.value.replace(t,``)){case`integer`:case`float`:case`double`:case`decimal`:return r.config.theme.createNumberEditor(r.label,o,s,r);case`date`:case`dateTime`:return r.config.theme.createDateEditor(r.label,o,s,r);case`boolean`:return r.config.theme.createBooleanEditor(r.label,o,s,r);case`base64Binary`:return r.config.theme.createFileEditor(r.label,o,s,r)}return r.config.theme.createTextEditor(r.label,o,s,r)}else return o?r.config.theme.createViewer(r.label,o,r):document.createElement(`div`)}var d=`
|
|
2
2
|
#shaclMapDialog .closeButton { position: absolute; right: 0; top: 0; z-index: 1; padding: 6px 8px; cursor: pointer; border: 0; background-color: #FFFA; font-size: 24px; z-index: 1000; }
|
|
3
3
|
#shaclMapDialog { padding: 0; width:90vw; height: 90vh; margin: auto; }
|
|
4
4
|
#shaclMapDialog::backdrop { background-color: #0007; }
|
|
@@ -7,11 +7,11 @@ import*as c from"leaflet";import"leaflet-editable/src/Leaflet.Editable.js";impor
|
|
|
7
7
|
.leaflet-container { min-height: 300px; }
|
|
8
8
|
.fullscreen-icon { background-image: url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjYgNTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIwLjYgMzYuN0gxNmEuOS45IDAgMCAxLS44LS44di00LjVjMC0uMi4yLS40LjQtLjRoMS40Yy4zIDAgLjUuMi41LjR2M2gzYy4yIDAgLjQuMi40LjV2MS40YzAgLjItLjIuNC0uNC40em0tOS45LS44di00LjVjMC0uMi0uMi0uNC0uNC0uNEg4LjljLS4zIDAtLjUuMi0uNS40djNoLTNjLS4yIDAtLjQuMi0uNC41djEuNGMwIC4yLjIuNC40LjRIMTBjLjQgMCAuOC0uNC44LS44em0wIDEwLjdWNDJjMC0uNC0uNC0uOC0uOC0uOEg1LjRjLS4yIDAtLjQuMi0uNC40djEuNGMwIC4zLjIuNS40LjVoM3YzYzAgLjIuMi40LjUuNGgxLjRjLjIgMCAuNC0uMi40LS40em02LjkgMHYtM2gzYy4yIDAgLjQtLjIuNC0uNXYtMS40YzAtLjItLjItLjQtLjQtLjRIMTZjLS40IDAtLjguNC0uOC44djQuNWMwIC4yLjIuNC40LjRoMS40Yy4zIDAgLjUtLjIuNS0uNHpNNSAxMC4zVjUuOWMwLS41LjQtLjkuOS0uOWg0LjRjLjIgMCAuNC4yLjQuNFY3YzAgLjItLjIuNC0uNC40aC0zdjNjMCAuMi0uMi40LS40LjRINS40YS40LjQgMCAwIDEtLjQtLjR6bTEwLjMtNC45VjdjMCAuMi4yLjQuNC40aDN2M2MwIC4yLjIuNC40LjRoMS41Yy4yIDAgLjQtLjIuNC0uNFY1LjljMC0uNS0uNC0uOS0uOS0uOWgtNC40Yy0uMiAwLS40LjItLjQuNHptNS4zIDkuOUgxOWMtLjIgMC0uNC4yLS40LjR2M2gtM2MtLjIgMC0uNC4yLS40LjR2MS41YzAgLjIuMi40LjQuNGg0LjRjLjUgMCAuOS0uNC45LS45di00LjRjMC0uMi0uMi0uNC0uNC0uNHptLTkuOSA1LjNWMTljMC0uMi0uMi0uNC0uNC0uNGgtM3YtM2MwLS4yLS4yLS40LS40LS40SDUuNGMtLjIgMC0uNC4yLS40LjR2NC40YzAgLjUuNC45LjkuOWg0LjRjLjIgMCAuNC0uMi40LS40eiIgZmlsbD0iY3VycmVudENvbG9yIi8+PC9zdmc+); }
|
|
9
9
|
#shaclMapDialogContainer { width:100%; height: 100%; }
|
|
10
|
-
`,
|
|
10
|
+
`,f=`
|
|
11
11
|
<dialog id="shaclMapDialog" onclick="event.target==this && this.close()">
|
|
12
12
|
<div id="shaclMapDialogContainer"></div>
|
|
13
13
|
<div class="hint">ⓘ Draw a polygon or marker, then close dialog</div>
|
|
14
14
|
<button class="closeButton" type="button" onclick="this.parentElement.close()">✕</button>
|
|
15
|
-
</dialog>`,
|
|
16
|
-
`+
|
|
17
|
-
`+
|
|
15
|
+
</dialog>`,p={lng:8.657238961696038,lat:49.87627570549512},m=`© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>`,h=`https://tile.openstreetmap.de/{z}/{x}/{y}.png`,g=o.icon({iconUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=`,shadowUrl:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC`,iconSize:[25,41],shadowSize:[41,41],iconAnchor:[12,41],shadowAnchor:[14,41],popupAnchor:[-3,-76]}),_=class extends r{constructor(e){super(e,s+`
|
|
16
|
+
`+c+`
|
|
17
|
+
`+d)}initEditMode(e){e.insertAdjacentHTML(`beforeend`,f);let t=e.querySelector(`#shaclMapDialogContainer`);this.map=o.map(t,{fullscreenControl:!0,editable:!0,layers:[o.tileLayer(h)],zoom:5,maxBounds:v,center:p}),this.map.attributionControl.addAttribution(m);let n=o.Control.extend({options:{position:`topleft`,callback:null,kind:``,html:``},onAdd:function(e){let t=o.DomUtil.create(`div`,`leaflet-control leaflet-bar`),n=o.DomUtil.create(`a`,``,t);return n.href=`#`,n.title=`Create a new `+this.options.kind,n.innerHTML=this.options.html,o.DomEvent.on(n,`click`,o.DomEvent.stop).on(n,`click`,()=>{window.LAYER=this.options.callback.call(e.editTools)},this),t}});this.map.addControl(new(n.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startPolygon()},kind:`polygon`,html:`▰`}}))),this.map.addControl(new(n.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startMarker(void 0,{icon:g})},kind:`marker`,html:`•`}}))),this.map.on(`editable:drawing:end`,()=>{this.saveChanges()}),this.map.on(`editable:vertex:dragend`,()=>{this.saveChanges()});let r=e.querySelector(`#shaclMapDialog`);return r.addEventListener(`close`,()=>{let e=document.body.style.top;document.body.style.position=``,document.body.style.top=``,window.scrollTo(0,parseInt(e||`0`)*-1),this.currentEditor&&this.createdGeometry&&(this.currentEditor.value=b(this.createdGeometry),this.currentEditor.dispatchEvent(new Event(`change`,{bubbles:!0})))}),r}createEditor(e,t){let n=e.config.form.querySelector(`#shaclMapDialog`);n||=this.initEditMode(e.config.form);let r=e.config.theme.createButton(`Open map...`,!1);r.style.marginLeft=`5px`,r.classList.add(`open-map-button`),r.onclick=()=>{this.currentEditor=i.querySelector(`.editor`),this.createdGeometry=void 0,this.displayedShape?.remove(),this.drawAndZoomToGeometry(y(this.currentEditor.value||``),this.map),document.body.style.top=`-${window.scrollY}px`,document.body.style.position=`fixed`,n.showModal()};let i=u(e,t||null,!0);return i.appendChild(r),i}createViewer(e,t){let n=document.createElement(`div`),r=y(t.value);if(r?.coordinates?.length){let e=o.map(n,{fullscreenControl:!0,layers:[o.tileLayer(h)],zoom:5,center:p,maxBounds:v});e.attributionControl.addAttribution(m),this.drawAndZoomToGeometry(r,e)}return n}drawAndZoomToGeometry(e,t){if(setTimeout(()=>{t.invalidateSize()}),e?.type===`Point`){let n={lng:e.coordinates[0],lat:e.coordinates[1]};this.displayedShape=o.marker(n,{icon:g}).addTo(t),t.setView(n,15,{animate:!1})}else if(e?.type===`Polygon`){let n=e.coordinates[0].map(e=>({lng:e[0],lat:e[1]})),r=o.polygon(n).addTo(t);this.displayedShape=r,t.fitBounds(r.getBounds(),{animate:!1}),setTimeout(()=>{t.fitBounds(r.getBounds(),{animate:!1}),t.setView(r.getCenter(),void 0,{animate:!1})},1)}else t.setZoom(5)}saveChanges(){if(this.displayedShape instanceof o.Marker){let e=this.displayedShape.getLatLng();this.createdGeometry={type:`Point`,coordinates:[e.lng,e.lat]}}else if(this.displayedShape instanceof o.Polygon){let e=this.displayedShape.getLatLngs();e[0][0].equals(e[0][e[0].length-1])||e[0].push(e[0][0]),this.createdGeometry={type:`Polygon`,coordinates:[e[0].map(e=>[e.lng,e.lat])]}}else this.createdGeometry=void 0}},v=[[-90,-180],[90,180]];function y(e){let t=e.match(/^POINT\((.*)\)$/);if(t?.length==2){let e=t[1].split(` `);if(e.length===2)return{type:`Point`,coordinates:[parseFloat(e[0]),parseFloat(e[1])]}}let n=e.match(/^POLYGON[(]{2}(.*)[)]{2}$/);if(n?.length==2){let e=n[1].split(`,`);if(e.length>2){let t=[],n=[];t.push(n);for(let t of e){let e=t.split(` `);e.length===2&&n.push([parseFloat(e[0]),parseFloat(e[1])])}return{type:`Polygon`,coordinates:t}}}}function b(e){return e.type===`Point`?`POINT(${e.coordinates.join(` `)})`:e.type===`Polygon`?`POLYGON((${e.coordinates[0].map(e=>e.join(` `)).join(`,`)}))`:``}export{_ as LeafletPlugin,b as geometryToWkt,y as wktToGeometry,v as worldBounds};
|
package/dist/util.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function removePrefixes(id: string, prefixes: Prefixes): string;
|
|
|
11
11
|
export declare function findInstancesOf(clazz: NamedNode, template: ShaclPropertyTemplate): InputListEntry[];
|
|
12
12
|
export declare function isURL(input: string): boolean;
|
|
13
13
|
export declare function prioritizeByLanguage(languages: string[], text1?: Literal, text2?: Literal): Literal | undefined;
|
|
14
|
+
export declare function findBestMatchingLiteral(languages: string[], literals: Literal[]): string;
|
|
14
15
|
export declare function findAllClasses(store: Store): Set<string>;
|
|
15
16
|
export declare function filterOutExistingItems(existing: Set<string> | string[], items: Set<string>): string[];
|
|
16
17
|
export declare function extractLists(store: Store, { remove, ignoreErrors }?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ulb-darmstadt/shacl-form",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"description": "SHACL form generator",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@open-wc/testing": "^4.0.0",
|
|
48
|
-
"@remcovaes/web-test-runner-vite-plugin": "^1.4.
|
|
48
|
+
"@remcovaes/web-test-runner-vite-plugin": "^1.4.1",
|
|
49
49
|
"@types/jsonld": "^1.5.15",
|
|
50
50
|
"@types/leaflet": "^1.9.21",
|
|
51
51
|
"@types/leaflet-editable": "^1.2.7",
|
|
@@ -53,19 +53,21 @@
|
|
|
53
53
|
"@types/mapbox__mapbox-gl-draw": "^1.4.9",
|
|
54
54
|
"@types/mocha": "^10.0.10",
|
|
55
55
|
"@types/n3": "^1.26.1",
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
57
|
-
"@typescript-eslint/parser": "^8.
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
|
57
|
+
"@typescript-eslint/parser": "^8.58.0",
|
|
58
58
|
"@web/test-runner": "^0.20.2",
|
|
59
59
|
"@web/test-runner-chrome": "^0.18.1",
|
|
60
|
-
"
|
|
60
|
+
"@web/test-runner-puppeteer": "^0.18.0",
|
|
61
|
+
"eslint": "^10.2.0",
|
|
62
|
+
"puppeteer": "^24.40.0",
|
|
61
63
|
"rdf-isomorphic": "^2.0.1",
|
|
62
|
-
"rimraf": "^6.1.
|
|
64
|
+
"rimraf": "^6.1.3",
|
|
63
65
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
64
|
-
"typescript": "^
|
|
65
|
-
"vite": "^
|
|
66
|
+
"typescript": "^6.0.2",
|
|
67
|
+
"vite": "^8.0.5"
|
|
66
68
|
},
|
|
67
69
|
"peerDependencies": {
|
|
68
|
-
"@ro-kit/ui-widgets": "^1.0.
|
|
70
|
+
"@ro-kit/ui-widgets": "^1.0.44",
|
|
69
71
|
"jsonld": "^9.0.0",
|
|
70
72
|
"leaflet": "^1.9.4",
|
|
71
73
|
"leaflet-editable": "^1.3.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{DataFactory as e}from"n3";import"rdfxml-streaming-parser";import"jsonld";class A{constructor(o,a){this.predicate=o.predicate,this.datatype=o.datatype,a&&(this.stylesheet=new CSSStyleSheet,this.stylesheet.replaceSync(a))}createViewer(o,a){return o.config.theme.createViewer(o.label,a,o)}}const n="http://www.w3.org/ns/shacl#",s="http://www.w3.org/2001/XMLSchema#",d="http://www.w3.org/1999/02/22-rdf-syntax-ns#",c="http://www.w3.org/2000/01/rdf-schema#",r="http://www.w3.org/2004/02/skos/core#",S="http://www.w3.org/2002/07/owl#",R="http://purl.org/dc/terms/",N="http://xmlns.com/foaf/0.1/",P=e.namedNode("loaded-shapes"),C=e.namedNode("loaded-data"),g=e.namedNode(d+"type"),l=e.namedNode(d+"langString");e.namedNode(R+"conformsTo");const p=e.namedNode(c+"subClassOf"),w=e.namedNode(S+"imports"),I=e.namedNode(r+"broader"),D=e.namedNode(r+"narrower");e.namedNode(n+"NodeShape");e.namedNode(n+"IRI");e.namedNode(n+"property");const E=e.namedNode(n+"class");e.namedNode(n+"node");const _=e.namedNode(n+"targetClass");e.namedNode(n+"nodeKind");e.namedNode(s+"string");e.namedNode(s+"boolean");w.id+"",E.id+"";function F(t){return Math.max(t.minCount??0,t.qualifiedMinCount??0)}export{C as D,n as P,g as R,P as S,I as a,D as b,p as c,r as d,c as e,R as f,N as g,F as h,l as i,s as j,A as k};
|