@ulb-darmstadt/shacl-form 1.6.4 → 1.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulb-darmstadt/shacl-form",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "SHACL form generator",
5
5
  "main": "dist/form-default.js",
6
6
  "module": "dist/form-default.js",
package/src/config.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Prefixes, Store } from 'n3'
1
+ import { DataFactory, NamedNode, Prefixes, Store } from 'n3'
2
2
  import { Term } from '@rdfjs/types'
3
3
  import { PREFIX_SHACL, RDF_PREDICATE_TYPE } from './constants'
4
4
  import { ClassInstanceProvider } from './plugin'
@@ -17,6 +17,7 @@ export class ElementAttributes {
17
17
  valueSubject: string | null = null // for backward compatibility
18
18
  valuesSubject: string | null = null
19
19
  valuesNamespace = ''
20
+ valuesGraph: string | null = null
20
21
  view: string | null = null
21
22
  language: string | null = null
22
23
  loading: string = 'Loading\u2026'
@@ -41,6 +42,7 @@ export class Config {
41
42
  theme: Theme
42
43
  form: HTMLElement
43
44
  renderedNodes = new Set<string>()
45
+ valuesGraph: NamedNode | undefined
44
46
  private _shapesGraph = new Store()
45
47
 
46
48
  constructor(theme: Theme, form: HTMLElement) {
@@ -78,6 +80,7 @@ export class Config {
78
80
  // now prepend preferred language at start of the list of languages
79
81
  this.languages.unshift(atts.language)
80
82
  }
83
+ this.valuesGraph = atts.valuesGraph ? DataFactory.namedNode(atts.valuesGraph) : undefined
81
84
  }
82
85
 
83
86
  static dataAttributes(): Array<string> {
package/src/node.ts CHANGED
@@ -154,11 +154,11 @@ export class ShaclNode extends HTMLElement {
154
154
  (shape as ShaclNode | ShaclProperty).toRDF(graph, subject)
155
155
  }
156
156
  if (this.targetClass) {
157
- graph.addQuad(subject, RDF_PREDICATE_TYPE, this.targetClass)
157
+ graph.addQuad(subject, RDF_PREDICATE_TYPE, this.targetClass, this.config.valuesGraph)
158
158
  }
159
159
  // if this is the root shacl node, check if we should add one of the rdf:type or dcterms:conformsTo predicates
160
160
  if (this.config.attributes.generateNodeShapeReference && !this.parent) {
161
- graph.addQuad(subject, DataFactory.namedNode(this.config.attributes.generateNodeShapeReference), this.shaclSubject)
161
+ graph.addQuad(subject, DataFactory.namedNode(this.config.attributes.generateNodeShapeReference), this.shaclSubject, this.config.valuesGraph)
162
162
  }
163
163
  return subject
164
164
  }
package/src/property.ts CHANGED
@@ -123,14 +123,13 @@ export class ShaclProperty extends HTMLElement {
123
123
  for (const instance of this.querySelectorAll(':scope > .property-instance')) {
124
124
  const pathNode = DataFactory.namedNode((instance as HTMLElement).dataset.path!)
125
125
  if (instance.firstChild instanceof ShaclNode) {
126
- const quadCount = graph.size
127
126
  const shapeSubject = instance.firstChild.toRDF(graph)
128
- graph.addQuad(subject, pathNode, shapeSubject)
127
+ graph.addQuad(subject, pathNode, shapeSubject, this.template.config.valuesGraph)
129
128
  } else {
130
129
  const editor = instance.querySelector('.editor') as Editor
131
130
  const value = toRDF(editor)
132
131
  if (value) {
133
- graph.addQuad(subject, pathNode, value)
132
+ graph.addQuad(subject, pathNode, value, this.template.config.valuesGraph)
134
133
  }
135
134
  }
136
135
  }