@ulb-darmstadt/shacl-form 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -1130,4 +1130,4 @@ svg.leaflet-image-layer.leaflet-interactive path {\r
1130
1130
  <button class="closeButton" type="button" onclick="this.parentElement.close()">&#x2715;</button>
1131
1131
  </dialog>`,Yh={lng:8.657238961696038,lat:49.87627570549512},ef='&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',tf="https://tile.openstreetmap.de/{z}/{x}/{y}.png",nf=Ot.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+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMw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XDhPa0T9TEe69gWupwc6uBUphquXgf+/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 fw extends Wf{constructor(e){super(e,N0+`
1132
1132
  `+A0+`
1133
- `+P0)}initEditMode(e){e.insertAdjacentHTML("beforeend",k0);const n=e.querySelector("#shaclMapDialogContainer");this.map=Ot.map(n,{fullscreenControl:!0,editable:!0,layers:[Ot.tileLayer(tf)],zoom:5,maxBounds:rf,center:Yh}),this.map.attributionControl.addAttribution(ef);const r=Ot.Control.extend({options:{position:"topleft",callback:null,kind:"",html:""},onAdd:function(a){let l=Ot.DomUtil.create("div","leaflet-control leaflet-bar"),u=Ot.DomUtil.create("a","",l);return u.href="#",u.title="Create a new "+this.options.kind,u.innerHTML=this.options.html,Ot.DomEvent.on(u,"click",Ot.DomEvent.stop).on(u,"click",()=>{window.LAYER=this.options.callback.call(a.editTools)},this),l}});this.map.addControl(new(r.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startPolygon()},kind:"polygon",html:"▰"}}))),this.map.addControl(new(r.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startMarker(void 0,{icon:nf})},kind:"marker",html:"•"}}))),this.map.on("editable:drawing:end",()=>{this.saveChanges()}),this.map.on("editable:vertex:dragend",()=>{this.saveChanges()});const o=e.querySelector("#shaclMapDialog");return o.addEventListener("close",()=>{const a=document.body.style.top;document.body.style.position="",document.body.style.top="",window.scrollTo(0,parseInt(a||"0")*-1),this.currentEditor&&this.createdGeometry&&(this.currentEditor.value=D0(this.createdGeometry),this.currentEditor.dispatchEvent(new Event("change",{bubbles:!0})))}),o}createEditor(e,n){let r=e.config.form.querySelector("#shaclMapDialog");r||(r=this.initEditMode(e.config.form));const o=e.config.theme.createButton("Open&#160;map...",!1);o.style.marginLeft="5px",o.classList.add("open-map-button"),o.onclick=()=>{this.currentEditor=a.querySelector(".editor"),this.createdGeometry=void 0,this.displayedShape?.remove(),this.drawAndZoomToGeometry(sf(this.currentEditor.value||""),this.map),document.body.style.top=`-${window.scrollY}px`,document.body.style.position="fixed",r.showModal()};const a=Gf(e,n||null,!0);return a.appendChild(o),a}createViewer(e,n){const r=document.createElement("div"),o=sf(n.value);if(o?.coordinates?.length){const a=Ot.map(r,{fullscreenControl:!0,layers:[Ot.tileLayer(tf)],zoom:5,center:Yh,maxBounds:rf});a.attributionControl.addAttribution(ef),this.drawAndZoomToGeometry(o,a)}return r}drawAndZoomToGeometry(e,n){if(setTimeout(()=>{n.invalidateSize()}),e?.type==="Point"){const r={lng:e.coordinates[0],lat:e.coordinates[1]};this.displayedShape=Ot.marker(r,{icon:nf}).addTo(n),n.setView(r,15,{animate:!1})}else if(e?.type==="Polygon"){const r=e.coordinates[0].map(a=>({lng:a[0],lat:a[1]})),o=Ot.polygon(r).addTo(n);this.displayedShape=o,n.fitBounds(o.getBounds(),{animate:!1}),setTimeout(()=>{n.fitBounds(o.getBounds(),{animate:!1}),n.setView(o.getCenter(),void 0,{animate:!1})},1)}else n.setZoom(5)}saveChanges(){if(this.displayedShape instanceof Ot.Marker){const e=this.displayedShape.getLatLng();this.createdGeometry={type:"Point",coordinates:[e.lng,e.lat]}}else if(this.displayedShape instanceof Ot.Polygon){const 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(n=>[n.lng,n.lat])]}}else this.createdGeometry=void 0}}const rf=[[-90,-180],[90,180]];function sf(i){const e=i.match(/^POINT\((.*)\)$/);if(e?.length==2){const r=e[1].split(" ");if(r.length===2)return{type:"Point",coordinates:[parseFloat(r[0]),parseFloat(r[1])]}}const n=i.match(/^POLYGON[(]{2}(.*)[)]{2}$/);if(n?.length==2){const r=n[1].split(",");if(r.length>2){const o=[],a=[];o.push(a);for(const l of r){const u=l.split(" ");u.length===2&&a.push([parseFloat(u[0]),parseFloat(u[1])])}return{type:"Polygon",coordinates:o}}}}function D0(i){return i.type==="Point"?`POINT(${i.coordinates.join(" ")})`:i.type==="Polygon"?`POLYGON((${i.coordinates[0].map(e=>e.join(" ")).join(",")}))`:""}export{Xh as Config,ly as DefaultTheme,hw as FileUploadPlugin,fw as LeafletPlugin,Wf as Plugin,T0 as ShaclForm,Xm as Theme,Ya as classesCache,Qi as findLabel,D0 as geometryToWkt,S0 as initTimeout,Hm as loadGraphs,zi as prefixes,xs as rdfCache,Ym as registerPlugin,sf as wktToGeometry,rf as worldBounds};
1133
+ `+P0)}initEditMode(e){e.insertAdjacentHTML("beforeend",k0);const n=e.querySelector("#shaclMapDialogContainer");this.map=Ot.map(n,{fullscreenControl:!0,editable:!0,layers:[Ot.tileLayer(tf)],zoom:5,maxBounds:rf,center:Yh}),this.map.attributionControl.addAttribution(ef);const r=Ot.Control.extend({options:{position:"topleft",callback:null,kind:"",html:""},onAdd:function(a){let l=Ot.DomUtil.create("div","leaflet-control leaflet-bar"),u=Ot.DomUtil.create("a","",l);return u.href="#",u.title="Create a new "+this.options.kind,u.innerHTML=this.options.html,Ot.DomEvent.on(u,"click",Ot.DomEvent.stop).on(u,"click",()=>{window.LAYER=this.options.callback.call(a.editTools)},this),l}});this.map.addControl(new(r.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startPolygon()},kind:"polygon",html:"▰"}}))),this.map.addControl(new(r.extend({options:{callback:()=>{this.displayedShape?.remove(),this.displayedShape=this.map?.editTools.startMarker(void 0,{icon:nf})},kind:"marker",html:"•"}}))),this.map.on("editable:drawing:end",()=>{this.saveChanges()}),this.map.on("editable:vertex:dragend",()=>{this.saveChanges()});const o=e.querySelector("#shaclMapDialog");return o.addEventListener("close",()=>{const a=document.body.style.top;document.body.style.position="",document.body.style.top="",window.scrollTo(0,parseInt(a||"0")*-1),this.currentEditor&&this.createdGeometry&&(this.currentEditor.value=D0(this.createdGeometry),this.currentEditor.dispatchEvent(new Event("change",{bubbles:!0})))}),o}createEditor(e,n){let r=e.config.form.querySelector("#shaclMapDialog");r||(r=this.initEditMode(e.config.form));const o=e.config.theme.createButton("Open&#160;map...",!1);o.style.marginLeft="5px",o.classList.add("open-map-button"),o.onclick=()=>{this.currentEditor=a.querySelector(".editor"),this.createdGeometry=void 0,this.displayedShape?.remove(),this.drawAndZoomToGeometry(sf(this.currentEditor.value||""),this.map),document.body.style.top=`-${window.scrollY}px`,document.body.style.position="fixed",r.showModal()};const a=Gf(e,n||null,!0);return a.appendChild(o),a}createViewer(e,n){const r=document.createElement("div"),o=sf(n.value);if(o?.coordinates?.length){const a=Ot.map(r,{fullscreenControl:!0,layers:[Ot.tileLayer(tf)],zoom:5,center:Yh,maxBounds:rf});a.attributionControl.addAttribution(ef),this.drawAndZoomToGeometry(o,a)}return r}drawAndZoomToGeometry(e,n){if(setTimeout(()=>{n.invalidateSize()}),e?.type==="Point"){const r={lng:e.coordinates[0],lat:e.coordinates[1]};this.displayedShape=Ot.marker(r,{icon:nf}).addTo(n),n.setView(r,15,{animate:!1})}else if(e?.type==="Polygon"){const r=e.coordinates[0].map(a=>({lng:a[0],lat:a[1]})),o=Ot.polygon(r).addTo(n);this.displayedShape=o,n.fitBounds(o.getBounds(),{animate:!1}),setTimeout(()=>{n.fitBounds(o.getBounds(),{animate:!1}),n.setView(o.getCenter(),void 0,{animate:!1})},1)}else n.setZoom(5)}saveChanges(){if(this.displayedShape instanceof Ot.Marker){const e=this.displayedShape.getLatLng();this.createdGeometry={type:"Point",coordinates:[e.lng,e.lat]}}else if(this.displayedShape instanceof Ot.Polygon){const 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(n=>[n.lng,n.lat])]}}else this.createdGeometry=void 0}}const rf=[[-90,-180],[90,180]];function sf(i){const e=i.match(/^POINT\((.*)\)$/);if(e?.length==2){const r=e[1].split(" ");if(r.length===2)return{type:"Point",coordinates:[parseFloat(r[0]),parseFloat(r[1])]}}const n=i.match(/^POLYGON[(]{2}(.*)[)]{2}$/);if(n?.length==2){const r=n[1].split(",");if(r.length>2){const o=[],a=[];o.push(a);for(const l of r){const u=l.split(" ");u.length===2&&a.push([parseFloat(u[0]),parseFloat(u[1])])}return{type:"Polygon",coordinates:o}}}}function D0(i){return i.type==="Point"?`POINT(${i.coordinates.join(" ")})`:i.type==="Polygon"?`POLYGON((${i.coordinates[0].map(e=>e.join(" ")).join(",")}))`:""}export{Xh as Config,ly as DefaultTheme,hw as FileUploadPlugin,fw as LeafletPlugin,Wf as Plugin,T0 as ShaclForm,Xm as Theme,Ya as classesCache,Qi as findLabel,D0 as geometryToWkt,S0 as initTimeout,Hm as loadGraphs,zi as prefixes,Vm as propertyMappers,xs as rdfCache,Ym as registerPlugin,sf as wktToGeometry,rf as worldBounds};
package/dist/exports.d.ts CHANGED
@@ -4,4 +4,5 @@ export { DefaultTheme } from './theme.default';
4
4
  export { Config } from './config';
5
5
  export { Plugin, registerPlugin } from './plugin';
6
6
  export { findLabel } from './util';
7
+ export { mappers as propertyMappers } from './property-template';
7
8
  export * from './loader';
package/dist/index.js CHANGED
@@ -76,4 +76,4 @@ h3 { margin-top: 0; }
76
76
  :scope shacl-node[data-node-id='${i.id}'] > .shacl-group > shacl-property > .shacl-group > .property-instance[data-path='${a.id}'] > .editor`);r.length===0&&(r=this.form.querySelectorAll(`
77
77
  :scope [data-node-id='${i.id}'] > shacl-property > .property-instance[data-path='${a.id}'],
78
78
  :scope [data-node-id='${i.id}'] > shacl-property > .shacl-group > .property-instance[data-path='${a.id}']`));for(const l of r)if(l.classList.contains("editor")){if(!e||l.value){let c=l.parentElement;c.classList.add("invalid"),c.classList.remove("valid"),c.appendChild(this.createValidationErrorDisplay(o));do c instanceof te&&(c.open=!0),c=c.parentElement;while(c)}}else e||(l.classList.add("invalid"),l.classList.remove("valid"),l.appendChild(this.createValidationErrorDisplay(o,"node")))}else e||this.form.querySelector(`:scope [data-node-id='${i.id}']`)?.prepend(this.createValidationErrorDisplay(o,"node"))}return s}catch(s){return console.error(s),!1}}createValidationErrorDisplay(e,s){const o=document.createElement("span");if(o.classList.add("validation-error"),s&&o.classList.add(s),e)if(e.message?.length>0)for(const n of e.message)o.title+=n.value+`
79
- `;else o.title=e.sourceConstraintComponent?.value;return o}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){const e=u.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(e,g,K,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,b)>0){const s=u.namedNode(this.config.attributes.valuesSubject),o=[...this.config.store.getQuads(s,g,null,b),...this.config.store.getQuads(s,F,null,b)];if(o.length===0)console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${g.id} nor ${F.id} statement`);else for(const i of o)if(this.config.store.getQuads(i.object,g,K,null).length>0)return i.object;const n=this.config.store.getObjects(s,g,b);for(const i of n)for(const a of this.config.store.getQuads(null,G,i,null))return a.subject}const e=this.config.store.getQuads(null,g,K,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){this.config.attributes.valuesSubject;for(const s of this.config.store.getQuads(e,null,null,b))this.config.store.delete(s),(s.object.termType==="NamedNode"||s.object.termType==="BlankNode")&&this.removeFromDataGraph(s.object)}}window.customElements.define("shacl-form",ut);export{pe as Config,ot as DefaultTheme,vt as Plugin,ut as ShaclForm,We as Theme,H as classesCache,P as findLabel,dt as initTimeout,ze as loadGraphs,$ as prefixes,_ as rdfCache,et as registerPlugin};
79
+ `;else o.title=e.sourceConstraintComponent?.value;return o}findRootShaclShapeSubject(){if(this.config.attributes.shapeSubject){const e=u.namedNode(this.config.attributes.shapeSubject);if(this.config.store.getQuads(e,g,K,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,b)>0){const s=u.namedNode(this.config.attributes.valuesSubject),o=[...this.config.store.getQuads(s,g,null,b),...this.config.store.getQuads(s,F,null,b)];if(o.length===0)console.warn(`value subject '${this.config.attributes.valuesSubject}' has neither ${g.id} nor ${F.id} statement`);else for(const i of o)if(this.config.store.getQuads(i.object,g,K,null).length>0)return i.object;const n=this.config.store.getObjects(s,g,b);for(const i of n)for(const a of this.config.store.getQuads(null,G,i,null))return a.subject}const e=this.config.store.getQuads(null,g,K,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){this.config.attributes.valuesSubject;for(const s of this.config.store.getQuads(e,null,null,b))this.config.store.delete(s),(s.object.termType==="NamedNode"||s.object.termType==="BlankNode")&&this.removeFromDataGraph(s.object)}}window.customElements.define("shacl-form",ut);export{pe as Config,ot as DefaultTheme,vt as Plugin,ut as ShaclForm,We as Theme,H as classesCache,P as findLabel,dt as initTimeout,ze as loadGraphs,$ as prefixes,Ge as propertyMappers,_ as rdfCache,et as registerPlugin};
@@ -2,6 +2,7 @@ import { Literal, NamedNode, Quad } from 'n3';
2
2
  import { Term } from '@rdfjs/types';
3
3
  import { Config } from './config';
4
4
  import { ShaclNodeTemplate } from './node-template';
5
+ export declare const mappers: Record<string, (template: ShaclPropertyTemplate, term: Term) => void>;
5
6
  export declare class ShaclPropertyTemplate {
6
7
  label: string;
7
8
  name: Literal | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulb-darmstadt/shacl-form",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "SHACL form generator",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",