@ulb-darmstadt/shacl-form 1.10.2 → 1.10.4

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.
@@ -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): Literal | NamedNode | undefined;
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.2",
3
+ "version": "1.10.4",
4
4
  "description": "SHACL form generator",
5
5
  "main": "dist/form-default.js",
6
6
  "module": "dist/form-default.js",
@@ -46,38 +46,39 @@
46
46
  "build-mapbox": "vite build -c ./vite.plugin-mapbox.config.ts"
47
47
  },
48
48
  "devDependencies": {
49
+ "@open-wc/testing": "^4.0.0",
49
50
  "@types/jsonld": "^1.5.15",
50
51
  "@types/leaflet": "^1.9.20",
51
- "@types/leaflet-editable": "^1.2.6",
52
- "@types/leaflet.fullscreen": "^3.0.2",
52
+ "@types/leaflet-editable": "^1.2.7",
53
+ "@types/leaflet.fullscreen": "^3.0.3",
53
54
  "@types/mapbox__mapbox-gl-draw": "^1.4.9",
54
55
  "@types/n3": "^1.26.0",
55
56
  "@types/uuid": "^10.0.0",
56
- "happy-dom": "^18.0.1",
57
- "jest": "^30.0.5",
57
+ "@web/dev-server-esbuild": "^1.0.4",
58
+ "@web/test-runner": "^0.20.2",
58
59
  "rdf-isomorphic": "^2.0.1",
59
60
  "rollup-plugin-peer-deps-external": "^2.2.4",
60
- "typescript": "^5.8.3",
61
- "vite": "^7.0.6",
61
+ "typescript": "^5.9.2",
62
+ "vite": "^7.1.5",
62
63
  "vite-plugin-dts": "^4.5.4",
63
64
  "vitest": "^3.2.4"
64
65
  },
65
66
  "dependencies": {
66
67
  "@mapbox/mapbox-gl-draw": "^1.5.0",
67
- "bootstrap": "^5.3.7",
68
+ "bootstrap": "^5.3.8",
68
69
  "jsonld": "^8.3.3",
69
70
  "leaflet": "^1.9.4",
70
71
  "leaflet-editable": "^1.3.2",
71
72
  "leaflet.fullscreen": "^4.0.0",
72
- "mapbox-gl": "^3.14.0",
73
+ "mapbox-gl": "^3.15.0",
73
74
  "n3": "^1.26.0",
74
75
  "rdfxml-streaming-parser": "^3.1.0",
75
76
  "shacl-engine": "^1.0.2",
76
- "uuid": "^11.1.0"
77
+ "uuid": "^13.0.0"
77
78
  },
78
79
  "peerDependencies": {
80
+ "@ro-kit/ui-widgets": "^0.0.44",
79
81
  "lit": "^3.3.1",
80
- "@ro-kit/ui-widgets": "^0.0.43",
81
82
  "mdui": "^2.1.4"
82
83
  }
83
84
  }
package/src/form.ts CHANGED
@@ -43,11 +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
- // set loading attribute on element so that hosting app can apply special css rules
48
- this.setAttribute('loading', '')
49
- // remove all child elements from form and show loading indicator
50
- this.form.replaceChildren(document.createTextNode(this.config.attributes.loading))
51
51
  try {
52
52
  await this.config.loader.loadGraphs()
53
53
  // remove loading indicator
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): Literal | NamedNode | undefined {
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
- const tokens = value.split('^^')
75
- if (tokens.length === 2 &&
76
- ((tokens[0].startsWith('"') && tokens[0].endsWith('"') || tokens[0].startsWith('\'') && tokens[0].endsWith('\''))) &&
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)
@@ -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, XSD_DATATYPE_STRING } from '../constants'
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,13 +218,9 @@ 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
- if (entry.value instanceof Literal && entry.value.datatype.equals(XSD_DATATYPE_STRING)) {
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
221
+ li.dataset.value = (entry.value as N3Term).id
222
+ if (entry.value instanceof NamedNode) {
223
+ li.dataset.value = '<' + li.dataset.value + ">"
228
224
  }
229
225
  li.innerText = entry.label ? entry.label : entry.value.value
230
226
  }
@@ -248,7 +244,7 @@ export class DefaultTheme extends Theme {
248
244
 
249
245
  editor.appendChild(ul)
250
246
  if (value) {
251
- editor.value = value.value
247
+ editor.value = (value as N3Term).id
252
248
  }
253
249
  return result
254
250
  }
@@ -71,6 +71,7 @@ export class MaterialTheme extends Theme {
71
71
  if (template.pattern) {
72
72
  editor.pattern = template.pattern
73
73
  }
74
+ // @ts-ignore
74
75
  return this.createDefaultTemplate('', value, required, editor, template)
75
76
  }
76
77
 
@@ -91,6 +92,7 @@ export class MaterialTheme extends Theme {
91
92
  if (template.datatype?.value !== PREFIX_XSD + 'integer') {
92
93
  editor.setAttribute('step', '0.1')
93
94
  }
95
+ // @ts-ignore
94
96
  return this.createDefaultTemplate('', value, required, editor, template)
95
97
  }
96
98
 
@@ -165,6 +167,7 @@ export class MaterialTheme extends Theme {
165
167
  editor.type = 'date'
166
168
  }
167
169
  editor.classList.add('pr-0')
170
+ // @ts-ignore
168
171
  const result = this.createDefaultTemplate('', null, required, editor, template)
169
172
  if (value) {
170
173
  try {