@ulb-darmstadt/shacl-form 1.7.4 → 1.8.1

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.
Files changed (51) hide show
  1. package/README.md +20 -7
  2. package/dist/config.d.ts +4 -5
  3. package/dist/constants.d.ts +13 -13
  4. package/dist/constraints.d.ts +2 -2
  5. package/dist/exports.d.ts +2 -1
  6. package/dist/form-bootstrap.d.ts +1 -1
  7. package/dist/form-bootstrap.js +361 -2
  8. package/dist/form-default.d.ts +1 -1
  9. package/dist/form-default.js +350 -2
  10. package/dist/form-material.d.ts +1 -1
  11. package/dist/form-material.js +670 -2
  12. package/dist/form.d.ts +3 -2
  13. package/dist/node.d.ts +2 -1
  14. package/dist/plugins/leaflet.d.ts +2 -4
  15. package/dist/plugins/leaflet.js +720 -2
  16. package/dist/plugins/mapbox.d.ts +2 -2
  17. package/dist/plugins/mapbox.js +2764 -2
  18. package/dist/property-template.d.ts +1 -1
  19. package/dist/property.d.ts +6 -2
  20. package/dist/theme.d.ts +3 -3
  21. package/dist/themes/default.d.ts +3 -3
  22. package/dist/themes/material.d.ts +2 -3
  23. package/dist/util.d.ts +2 -2
  24. package/package.json +26 -12
  25. package/src/config.ts +11 -10
  26. package/src/constants.ts +3 -3
  27. package/src/constraints.ts +15 -18
  28. package/src/exports.ts +2 -1
  29. package/src/form.ts +32 -17
  30. package/src/group.ts +1 -1
  31. package/src/loader.ts +12 -13
  32. package/src/node.ts +40 -38
  33. package/src/plugins/leaflet.ts +2 -2
  34. package/src/plugins/mapbox.ts +4 -4
  35. package/src/property-template.ts +4 -5
  36. package/src/property.ts +154 -56
  37. package/src/serialize.ts +14 -1
  38. package/src/styles.css +8 -10
  39. package/src/theme.ts +6 -6
  40. package/src/themes/bootstrap.ts +1 -1
  41. package/src/themes/default.css +2 -2
  42. package/src/themes/default.ts +38 -30
  43. package/src/themes/material.ts +37 -34
  44. package/src/util.ts +26 -20
  45. package/dist/form-bootstrap.js.LICENSE.txt +0 -69
  46. package/dist/form-default.js.LICENSE.txt +0 -69
  47. package/dist/form-material.js.LICENSE.txt +0 -69
  48. package/dist/plugins/file-upload.js +0 -1
  49. package/dist/plugins/fixed-list.js +0 -1
  50. package/dist/plugins/leaflet.js.LICENSE.txt +0 -4
  51. package/dist/plugins/mapbox.js.LICENSE.txt +0 -10
package/README.md CHANGED
@@ -141,11 +141,14 @@ Apart from setting the element attributes `data-shapes` or `data-shapes-url`, th
141
141
  In this case, the URL references an ontology which among other things defines instances of class `prov:Role` that are then used to populate the "Role" dropdown in the form.
142
142
 
143
143
  2. <a id="classInstanceProvider"></a>The `<shacl-form>` element has a function `setClassInstanceProvider((className: string) => Promise<string>)` that registers a callback function which is invoked when a SHACL property has
144
- an `sh:class` predicate. The expected return value is a (promise of a) string (e.g. in format `text/turtle`) that contains RDF class instance definitions of the given class. Instances can be defined e.g. like:
145
- - `example:Instance a example:Class`
146
- - `example:Instance a owl:NamedIndividual; skos:broader example:Class`
144
+ an `sh:class` predicate. The expected return value is a (promise of a) string (e.g. in format `text/turtle`) that contains RDF class instance definitions of the given class.
147
145
 
148
- Class hierarchies can be built using `rdfs:subClassOf` or `skos:broader`.
146
+ Class hierarchies can be built using `rdfs:subClassOf`. Instance hierarchies can be modeled e.g. like:
147
+ ```
148
+ ex:parent a ex:Class .
149
+ ex:child rdfs:subClassOf ex:parent; a ex:parent .
150
+ ex:grandchild rdfs:subClassOf ex:child; a ex:child .
151
+ ```
149
152
 
150
153
  In [this example](https://ulb-darmstadt.github.io/shacl-form/#example), the code:
151
154
 
@@ -165,9 +168,9 @@ an `sh:class` predicate. The expected return value is a (promise of a) string (e
165
168
 
166
169
  A more realistic use case of this feature is calling some API endpoint to fetch class instance definitions from existing ontologies.
167
170
 
168
- ### SHACL "or" constraint
171
+ ### SHACL "or" and "xone" constraint
169
172
 
170
- `<shacl-form>` supports using [sh:or](https://www.w3.org/TR/shacl/#OrConstraintComponent) to let users select between different options on nodes or properties.
173
+ `<shacl-form>` supports using [sh:or](https://www.w3.org/TR/shacl/#OrConstraintComponent) and [sh:xone](https://www.w3.org/TR/shacl/#XoneConstraintComponent) to let users select between different options on nodes or properties.
171
174
  The [example shapes graph](https://ulb-darmstadt.github.io/shacl-form/#example) has the following triples:
172
175
  ```
173
176
  example:Attribution
@@ -184,10 +187,20 @@ example:Attribution
184
187
  ```
185
188
  When adding a new attribution, `<shacl-form>` renders a dropdown to let the user select between the two options Person/Organisation. After selecting one of the options, the dropdown is replaced by the input fields of the selected node shape.
186
189
 
187
- When binding an existing data graph to the form, the `sh:or` constraint is tried to be resolved depending on the respective data value:
190
+ When binding an existing data graph to the form, the constraint is tried to be resolved depending on the respective data value:
188
191
  - For RDF literals, an `sh:or` option with a matching `sh:datatype` is chosen
189
192
  - For blank nodes or named nodes, the `rdf:type` of the value is tried to be matched with a node shape having a corresponding `sh:targetClass` or with a property shape having a corresponding `sh:class`. If there is no `rdf:type` but a `sh:nodeKind` of `sh:IRI`, the id of the the node is used as the value.
190
193
 
194
+ ### Linking existing data
195
+
196
+ In case a node shape has a `sh:targetClass` and any graph, i.e.
197
+ - the shapes graph
198
+ - the data graph
199
+ - any graph loaded by `owl:imports`
200
+ - triples provided by [classInstanceProvider](#classInstanceProvider)
201
+
202
+ contains instances of that class, those can be linked in the respective SHACL property. In effect, the generated data graph will just contain a reference to the instance, but not the triples that the instance consists of.
203
+
191
204
  ### SHACL shape inheritance
192
205
 
193
206
  SHACL defines two ways of inheriting shapes: [sh:and](https://www.w3.org/TR/shacl/#AndConstraintComponent)
package/dist/config.d.ts CHANGED
@@ -32,18 +32,17 @@ export declare class Config {
32
32
  prefixes: Prefixes;
33
33
  editMode: boolean;
34
34
  languages: string[];
35
- dataGraph: Store<import("@rdfjs/types").Quad, import("n3").Quad, import("@rdfjs/types").Quad, import("@rdfjs/types").Quad>;
36
35
  lists: Record<string, Term[]>;
37
36
  groups: Array<string>;
38
37
  theme: Theme;
39
38
  form: HTMLElement;
40
39
  renderedNodes: Set<string>;
41
- valuesGraph: NamedNode | undefined;
42
- private _shapesGraph;
40
+ valuesGraphId: NamedNode | undefined;
41
+ private _store;
43
42
  constructor(theme: Theme, form: HTMLElement);
44
43
  updateAttributes(elem: HTMLElement): void;
45
44
  static dataAttributes(): Array<string>;
46
- get shapesGraph(): Store;
47
- set shapesGraph(graph: Store);
45
+ get store(): Store;
46
+ set store(store: Store);
48
47
  registerPrefixes(prefixes: Prefixes): void;
49
48
  }
@@ -7,16 +7,16 @@ export declare const PREFIX_SKOS = "http://www.w3.org/2004/02/skos/core#";
7
7
  export declare const PREFIX_OWL = "http://www.w3.org/2002/07/owl#";
8
8
  export declare const PREFIX_OA = "http://www.w3.org/ns/oa#";
9
9
  export declare const PREFIX_DCTERMS = "http://purl.org/dc/terms/";
10
- export declare const SHAPES_GRAPH: import("n3").NamedNode<"shapes">;
11
- export declare const RDF_PREDICATE_TYPE: import("n3").NamedNode<string>;
12
- export declare const DCTERMS_PREDICATE_CONFORMS_TO: import("n3").NamedNode<string>;
13
- export declare const RDFS_PREDICATE_SUBCLASS_OF: import("n3").NamedNode<string>;
14
- export declare const SKOS_PREDICATE_BROADER: import("n3").NamedNode<string>;
15
- export declare const OWL_PREDICATE_IMPORTS: import("n3").NamedNode<string>;
16
- export declare const OWL_OBJECT_NAMED_INDIVIDUAL: import("n3").NamedNode<string>;
17
- export declare const SHACL_OBJECT_NODE_SHAPE: import("n3").NamedNode<string>;
18
- export declare const SHACL_OBJECT_IRI: import("n3").NamedNode<string>;
19
- export declare const SHACL_PREDICATE_PROPERTY: import("n3").NamedNode<string>;
20
- export declare const SHACL_PREDICATE_CLASS: import("n3").NamedNode<string>;
21
- export declare const SHACL_PREDICATE_TARGET_CLASS: import("n3").NamedNode<string>;
22
- export declare const SHACL_PREDICATE_NODE_KIND: import("n3").NamedNode<string>;
10
+ export declare const PREFIX_FOAF = "http://xmlns.com/foaf/0.1/";
11
+ export declare const SHAPES_GRAPH: import('n3').NamedNode<"loaded-shapes">;
12
+ export declare const DATA_GRAPH: import('n3').NamedNode<"loaded-data">;
13
+ export declare const RDF_PREDICATE_TYPE: import('n3').NamedNode<string>;
14
+ export declare const DCTERMS_PREDICATE_CONFORMS_TO: import('n3').NamedNode<string>;
15
+ export declare const RDFS_PREDICATE_SUBCLASS_OF: import('n3').NamedNode<string>;
16
+ export declare const OWL_PREDICATE_IMPORTS: import('n3').NamedNode<string>;
17
+ export declare const SHACL_OBJECT_NODE_SHAPE: import('n3').NamedNode<string>;
18
+ export declare const SHACL_OBJECT_IRI: import('n3').NamedNode<string>;
19
+ export declare const SHACL_PREDICATE_PROPERTY: import('n3').NamedNode<string>;
20
+ export declare const SHACL_PREDICATE_CLASS: import('n3').NamedNode<string>;
21
+ export declare const SHACL_PREDICATE_TARGET_CLASS: import('n3').NamedNode<string>;
22
+ export declare const SHACL_PREDICATE_NODE_KIND: import('n3').NamedNode<string>;
@@ -1,7 +1,7 @@
1
1
  import { Quad } from 'n3';
2
2
  import { Term } from '@rdfjs/types';
3
- import { ShaclNode } from "./node";
4
- import { ShaclProperty } from "./property";
3
+ import { ShaclNode } from './node';
4
+ import { ShaclProperty } from './property';
5
5
  import { Config } from './config';
6
6
  export declare function createShaclOrConstraint(options: Term[], context: ShaclNode | ShaclProperty, config: Config): HTMLElement;
7
7
  export declare function resolveShaclOrConstraintOnProperty(subjects: Term[], value: Term, config: Config): Quad[];
package/dist/exports.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { Theme, InputListEntry, Editor } from './theme';
1
+ export type { InputListEntry, Editor } from './theme';
2
+ export { Theme } from './theme';
2
3
  export { Loader, setSharedShapesGraph } from './loader';
3
4
  export { Config } from './config';
4
5
  export { Plugin, registerPlugin } from './plugin';
@@ -1,4 +1,4 @@
1
- import { ShaclForm as FormBase } from "./form";
1
+ import { ShaclForm as FormBase } from './form';
2
2
  export * from './exports';
3
3
  export declare class ShaclForm extends FormBase {
4
4
  constructor();