@ulb-darmstadt/shacl-form 1.6.7 → 1.7.0

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/form.d.ts CHANGED
@@ -19,7 +19,7 @@ export declare class ShaclForm extends HTMLElement {
19
19
  setTheme(theme: Theme): void;
20
20
  setSharedShapesGraph(graph: Store): void;
21
21
  setClassInstanceProvider(provider: ClassInstanceProvider): void;
22
- validate(ignoreEmptyValues?: boolean): Promise<boolean>;
22
+ validate(ignoreEmptyValues?: boolean): Promise<any>;
23
23
  private createValidationErrorDisplay;
24
24
  private findRootShaclShapeSubject;
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulb-darmstadt/shacl-form",
3
- "version": "1.6.7",
3
+ "version": "1.7.0",
4
4
  "description": "SHACL form generator",
5
5
  "main": "dist/form-default.js",
6
6
  "module": "dist/form-default.js",
package/src/form.ts CHANGED
@@ -25,8 +25,8 @@ export class ShaclForm extends HTMLElement {
25
25
  this.form.addEventListener('change', ev => {
26
26
  ev.stopPropagation()
27
27
  if (this.config.editMode) {
28
- this.validate(true).then(valid => {
29
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, cancelable: false, composed: true, detail: { 'valid': valid } }))
28
+ this.validate(true).then(report => {
29
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, cancelable: false, composed: true, detail: { 'valid': report.conforms, 'report': report } }))
30
30
  }).catch(e => { console.warn(e) })
31
31
  }
32
32
  })
@@ -82,8 +82,8 @@ export class ShaclForm extends HTMLElement {
82
82
  // let browser check form validity first
83
83
  if (this.form.reportValidity()) {
84
84
  // now validate data graph
85
- this.validate().then(valid => {
86
- if (valid) {
85
+ this.validate().then(report => {
86
+ if (report?.conforms) {
87
87
  // form and data graph are valid, so fire submit event
88
88
  this.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }))
89
89
  } else {
@@ -140,7 +140,8 @@ export class ShaclForm extends HTMLElement {
140
140
  this.initialize()
141
141
  }
142
142
 
143
- public async validate(ignoreEmptyValues = false): Promise<boolean> {
143
+ /* Returns the validation report */
144
+ public async validate(ignoreEmptyValues = false): Promise<any> {
144
145
  for (const elem of this.form.querySelectorAll(':scope .validation-error')) {
145
146
  elem.remove()
146
147
  }
@@ -201,7 +202,7 @@ export class ShaclForm extends HTMLElement {
201
202
  }
202
203
  }
203
204
  }
204
- return report.conforms
205
+ return report
205
206
  } catch(e) {
206
207
  console.error(e)
207
208
  return false
package/src/property.ts CHANGED
@@ -126,7 +126,7 @@ export class ShaclProperty extends HTMLElement {
126
126
  const shapeSubject = instance.firstChild.toRDF(graph)
127
127
  graph.addQuad(subject, pathNode, shapeSubject, this.template.config.valuesGraph)
128
128
  } else {
129
- for (const editor of instance.querySelectorAll<Editor>('.editor')) {
129
+ for (const editor of instance.querySelectorAll<Editor>(':scope > .editor')) {
130
130
  const value = toRDF(editor)
131
131
  if (value) {
132
132
  graph.addQuad(subject, pathNode, value, this.template.config.valuesGraph)