@ulb-darmstadt/shacl-form 1.10.1 → 1.10.3
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-bootstrap.js +57 -57
- package/dist/form-default.js +54 -54
- package/dist/form-material.js +81 -81
- package/dist/serialize.d.ts +1 -1
- package/package.json +2 -2
- package/src/form.ts +5 -2
- package/src/property-template.ts +9 -11
- package/src/property.ts +1 -3
- package/src/serialize.ts +12 -7
- package/src/themes/default.ts +3 -10
package/dist/serialize.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { NamedNode, Quad, Literal, Prefixes } from 'n3';
|
|
2
2
|
import { Editor } from './theme';
|
|
3
3
|
export declare function serialize(quads: Quad[], format: string, prefixes?: Prefixes): string;
|
|
4
|
-
export declare function toRDF(editor: Editor):
|
|
4
|
+
export declare function toRDF(editor: Editor): NamedNode | Literal | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ulb-darmstadt/shacl-form",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"description": "SHACL form generator",
|
|
5
5
|
"main": "dist/form-default.js",
|
|
6
6
|
"module": "dist/form-default.js",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"lit": "^3.3.1",
|
|
80
|
-
"@ro-kit/ui-widgets": "^0.0.
|
|
80
|
+
"@ro-kit/ui-widgets": "^0.0.44",
|
|
81
81
|
"mdui": "^2.1.4"
|
|
82
82
|
}
|
|
83
83
|
}
|
package/src/form.ts
CHANGED
|
@@ -43,9 +43,11 @@ export class ShaclForm extends HTMLElement {
|
|
|
43
43
|
|
|
44
44
|
private initialize() {
|
|
45
45
|
clearTimeout(this.initDebounceTimeout)
|
|
46
|
+
// set loading attribute on element so that hosting app can apply special css rules
|
|
47
|
+
this.setAttribute('loading', '')
|
|
48
|
+
// remove all child elements from form and show loading indicator
|
|
49
|
+
this.form.replaceChildren(document.createTextNode(this.config.attributes.loading))
|
|
46
50
|
this.initDebounceTimeout = setTimeout(async () => {
|
|
47
|
-
// remove all child elements from form and show loading indicator
|
|
48
|
-
this.form.replaceChildren(document.createTextNode(this.config.attributes.loading))
|
|
49
51
|
try {
|
|
50
52
|
await this.config.loader.loadGraphs()
|
|
51
53
|
// remove loading indicator
|
|
@@ -116,6 +118,7 @@ export class ShaclForm extends HTMLElement {
|
|
|
116
118
|
errorDisplay.innerText = String(e)
|
|
117
119
|
this.form.replaceChildren(errorDisplay)
|
|
118
120
|
}
|
|
121
|
+
this.removeAttribute('loading')
|
|
119
122
|
}, 200)
|
|
120
123
|
}
|
|
121
124
|
|
package/src/property-template.ts
CHANGED
|
@@ -115,17 +115,15 @@ export class ShaclPropertyTemplate {
|
|
|
115
115
|
if (!this.label && !this.shaclAnd) {
|
|
116
116
|
this.label = this.path ? removePrefixes(this.path, this.config.prefixes) : 'unknown'
|
|
117
117
|
}
|
|
118
|
-
//
|
|
119
|
-
if (this.node
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this.extendedShapes.push(node as NamedNode)
|
|
128
|
-
}
|
|
118
|
+
// register extended shapes
|
|
119
|
+
if (this.node) {
|
|
120
|
+
this.extendedShapes.push(this.node)
|
|
121
|
+
}
|
|
122
|
+
if (this.shaclAnd) {
|
|
123
|
+
const list = this.config.lists[this.shaclAnd]
|
|
124
|
+
if (list?.length) {
|
|
125
|
+
for (const node of list) {
|
|
126
|
+
this.extendedShapes.push(node as NamedNode)
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
129
|
}
|
package/src/property.ts
CHANGED
|
@@ -19,14 +19,13 @@ export class ShaclProperty extends HTMLElement {
|
|
|
19
19
|
constructor(shaclSubject: BlankNode | NamedNode, parent: ShaclNode, config: Config, valueSubject?: NamedNode | BlankNode) {
|
|
20
20
|
super()
|
|
21
21
|
this.template = new ShaclPropertyTemplate(config.store.getQuads(shaclSubject, null, null, null), parent, config)
|
|
22
|
+
this.container = this
|
|
22
23
|
if (this.template.extendedShapes.length && this.template.config.attributes.collapse !== null && (!this.template.maxCount || this.template.maxCount > 1)) {
|
|
23
24
|
const collapsible = new RokitCollapsible()
|
|
24
25
|
collapsible.classList.add('collapsible', 'shacl-group');
|
|
25
26
|
collapsible.open = config.attributes.collapse === 'open';
|
|
26
27
|
collapsible.label = this.template.label;
|
|
27
28
|
this.container = collapsible
|
|
28
|
-
} else {
|
|
29
|
-
this.container = this
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
if (this.template.order !== undefined) {
|
|
@@ -35,7 +34,6 @@ export class ShaclProperty extends HTMLElement {
|
|
|
35
34
|
if (this.template.cssClass) {
|
|
36
35
|
this.classList.add(this.template.cssClass)
|
|
37
36
|
}
|
|
38
|
-
|
|
39
37
|
if (config.editMode && !parent.linked) {
|
|
40
38
|
this.addButton = this.createAddButton()
|
|
41
39
|
this.container.appendChild(this.addButton)
|
package/src/serialize.ts
CHANGED
|
@@ -45,7 +45,7 @@ function serializeJsonld(quads: Quad[]): string {
|
|
|
45
45
|
return JSON.stringify(triples)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export function toRDF(editor: Editor):
|
|
48
|
+
export function toRDF(editor: Editor): NamedNode | Literal | undefined {
|
|
49
49
|
let languageOrDatatype: NamedNode<string> | string | undefined = editor.shaclDatatype
|
|
50
50
|
let value: number | string = editor.value
|
|
51
51
|
if (value) {
|
|
@@ -69,15 +69,20 @@ export function toRDF(editor: Editor): Literal | NamedNode | undefined {
|
|
|
69
69
|
// if seconds in value are 0, the input field omits them which is then not a valid xsd:dateTime
|
|
70
70
|
value = new Date(value).toISOString().slice(0, 19)
|
|
71
71
|
}
|
|
72
|
-
// check if value is a typed rdf literal
|
|
72
|
+
// check if value is a typed rdf literal or langString
|
|
73
73
|
if (!languageOrDatatype && typeof value === 'string') {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
tokens[1].split(':').length === 2
|
|
78
|
-
) {
|
|
74
|
+
// check for typed rdf literal
|
|
75
|
+
let tokens = value.split('^^')
|
|
76
|
+
if (tokens.length === 2 && tokens[0].startsWith('"') && tokens[0].endsWith('"') && tokens[1].split(':').length === 2) {
|
|
79
77
|
value = tokens[0].substring(1, tokens[0].length - 1)
|
|
80
78
|
languageOrDatatype = DataFactory.namedNode(tokens[1])
|
|
79
|
+
} else {
|
|
80
|
+
// check for langString
|
|
81
|
+
tokens = value.split('@')
|
|
82
|
+
if (tokens.length === 2 && tokens[0].startsWith('"') && tokens[0].endsWith('"')) {
|
|
83
|
+
value = tokens[0].substring(1, tokens[0].length - 1)
|
|
84
|
+
languageOrDatatype = tokens[1]
|
|
85
|
+
}
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
88
|
return DataFactory.literal(value, languageOrDatatype)
|
package/src/themes/default.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Term } from '@rdfjs/types'
|
|
2
2
|
import { ShaclPropertyTemplate } from "../property-template"
|
|
3
3
|
import { Editor, InputListEntry, Theme } from "../theme"
|
|
4
|
-
import { PREFIX_SHACL, PREFIX_XSD
|
|
4
|
+
import { PREFIX_SHACL, PREFIX_XSD } from '../constants'
|
|
5
5
|
import { Literal, NamedNode } from 'n3'
|
|
6
6
|
import { Term as N3Term } from 'n3'
|
|
7
7
|
import css from './default.css?raw'
|
|
@@ -218,14 +218,7 @@ export class DefaultTheme extends Theme {
|
|
|
218
218
|
li.dataset.value = entry.value
|
|
219
219
|
li.innerText = entry.label ? entry.label : entry.value
|
|
220
220
|
} else {
|
|
221
|
-
|
|
222
|
-
li.dataset.value = entry.value.value
|
|
223
|
-
} else if (entry.value instanceof NamedNode) {
|
|
224
|
-
li.dataset.value = '<' + entry.value.value + ">"
|
|
225
|
-
} else {
|
|
226
|
-
// this is needed for typed rdf literals e.g. "ex"^^xsd:anyUri
|
|
227
|
-
li.dataset.value = (entry.value as N3Term).id
|
|
228
|
-
}
|
|
221
|
+
li.dataset.value = (entry.value as N3Term).id
|
|
229
222
|
li.innerText = entry.label ? entry.label : entry.value.value
|
|
230
223
|
}
|
|
231
224
|
parent.appendChild(li)
|
|
@@ -248,7 +241,7 @@ export class DefaultTheme extends Theme {
|
|
|
248
241
|
|
|
249
242
|
editor.appendChild(ul)
|
|
250
243
|
if (value) {
|
|
251
|
-
editor.value = value.
|
|
244
|
+
editor.value = (value as N3Term).id
|
|
252
245
|
}
|
|
253
246
|
return result
|
|
254
247
|
}
|