@ulb-darmstadt/shacl-form 1.6.4 → 1.6.6
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/README.md +1 -0
- package/dist/config.d.ts +3 -1
- package/dist/form-bootstrap.js +1 -1
- package/dist/form-default.js +1 -1
- package/dist/form-material.js +1 -1
- package/dist/property-template.d.ts +1 -0
- package/package.json +1 -1
- package/src/config.ts +4 -1
- package/src/node.ts +2 -2
- package/src/property-template.ts +2 -0
- package/src/property.ts +2 -3
- package/src/themes/default.ts +1 -1
- package/src/themes/material.ts +1 -1
|
@@ -19,6 +19,7 @@ export declare class ShaclPropertyTemplate {
|
|
|
19
19
|
minExclusive: number | undefined;
|
|
20
20
|
maxExclusive: number | undefined;
|
|
21
21
|
singleLine: boolean | undefined;
|
|
22
|
+
readonly: boolean | undefined;
|
|
22
23
|
cssClass: string | undefined;
|
|
23
24
|
defaultValue: Term | undefined;
|
|
24
25
|
pattern: string | undefined;
|
package/package.json
CHANGED
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-template.ts
CHANGED
|
@@ -23,6 +23,7 @@ const mappers: Record<string, (template: ShaclPropertyTemplate, term: Term) => v
|
|
|
23
23
|
[`${PREFIX_SHACL}pattern`]: (template, term) => { template.pattern = term.value },
|
|
24
24
|
[`${PREFIX_SHACL}order`]: (template, term) => { template.order = parseInt(term.value) },
|
|
25
25
|
[`${PREFIX_DASH}singleLine`]: (template, term) => { template.singleLine = term.value === 'true' },
|
|
26
|
+
[`${PREFIX_DASH}readonly`]: (template, term) => { template.readonly = term.value === 'true' },
|
|
26
27
|
[`${PREFIX_OA}styleClass`]: (template, term) => { template.cssClass = term.value },
|
|
27
28
|
[`${PREFIX_SHACL}and`]: (template, term) => { template.shaclAnd = term.value },
|
|
28
29
|
[`${PREFIX_SHACL}in`]: (template, term) => { template.shaclIn = term.value },
|
|
@@ -66,6 +67,7 @@ export class ShaclPropertyTemplate {
|
|
|
66
67
|
minExclusive: number | undefined
|
|
67
68
|
maxExclusive: number | undefined
|
|
68
69
|
singleLine: boolean | undefined
|
|
70
|
+
readonly: boolean | undefined
|
|
69
71
|
cssClass: string | undefined
|
|
70
72
|
defaultValue: Term | undefined
|
|
71
73
|
pattern: string | undefined
|
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
|
}
|
package/src/themes/default.ts
CHANGED
|
@@ -28,7 +28,7 @@ export class DefaultTheme extends Theme {
|
|
|
28
28
|
if (template?.nodeKind) {
|
|
29
29
|
editor.dataset.nodeKind = template.nodeKind.value
|
|
30
30
|
}
|
|
31
|
-
if (template?.hasValue) {
|
|
31
|
+
if (template?.hasValue || template?.readonly) {
|
|
32
32
|
editor.disabled = true
|
|
33
33
|
}
|
|
34
34
|
editor.value = value?.value || template?.defaultValue?.value || ''
|
package/src/themes/material.ts
CHANGED
|
@@ -27,7 +27,7 @@ export class MaterialTheme extends Theme {
|
|
|
27
27
|
if (template?.nodeKind) {
|
|
28
28
|
editor.dataset.nodeKind = template.nodeKind.value
|
|
29
29
|
}
|
|
30
|
-
if (template?.hasValue) {
|
|
30
|
+
if (template?.hasValue || template?.readonly) {
|
|
31
31
|
editor.disabled = true
|
|
32
32
|
}
|
|
33
33
|
editor.value = value?.value || template?.defaultValue?.value || ''
|