@ulb-darmstadt/shacl-form 1.1.8 → 1.1.9
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 +18 -10
- package/dist/config.d.ts +5 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constraints.d.ts +2 -0
- package/dist/form.d.ts +3 -1
- package/dist/index-with-plugins.js +1 -1
- package/dist/index-with-plugins.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/fixed-list.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/mapbox.d.ts +1 -1
- package/dist/serialize.d.ts +1 -1
- package/dist/theme.d.ts +29 -0
- package/dist/util.d.ts +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,10 @@ This library provides an HTML5 web component that renders [SHACL shapes](https:/
|
|
|
16
16
|
<script src="https://cdn.jsdelivr.net/npm/@ulb-darmstadt/shacl-form/dist/index.js" type="module"></script>
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
|
-
<!--
|
|
19
|
+
<!--
|
|
20
|
+
SHACL shapes can be defined on the attribute 'data-shapes'
|
|
21
|
+
or can be loaded by setting attribute 'data-shapes-url'
|
|
22
|
+
-->
|
|
20
23
|
<shacl-form data-shapes="
|
|
21
24
|
@prefix sh: <http://www.w3.org/ns/shacl#> .
|
|
22
25
|
@prefix ex: <http://example.org#> .
|
|
@@ -35,7 +38,8 @@ This library provides an HTML5 web component that renders [SHACL shapes](https:/
|
|
|
35
38
|
form.addEventListener('change', event => {
|
|
36
39
|
// check if form validates according to the SHACL shapes
|
|
37
40
|
if (event.detail?.valid) {
|
|
38
|
-
// get data graph as RDF triples (default format is 'text/turtle')
|
|
41
|
+
// get data graph as RDF triples (default format is 'text/turtle')
|
|
42
|
+
// and log them to the browser console
|
|
39
43
|
const triples = form.serialize()
|
|
40
44
|
console.log('entered form data', triples)
|
|
41
45
|
// store the data somewhere, e.g. in a triple store
|
|
@@ -52,19 +56,19 @@ Attribute | Description
|
|
|
52
56
|
data-shapes | SHACL shape definitions (e.g. a turtle string) to generate the form from
|
|
53
57
|
data-shapes-url | When `data-shapes` is not set, the SHACL shapes are loaded from this URL
|
|
54
58
|
data-shape-subject | Optional subject (id) of the SHACL node shape to use as root for the form. If not set, the first found node shape will be used
|
|
55
|
-
data-values | RDF triples (e.g. a turtle string) to use as existing data values
|
|
59
|
+
data-values | RDF triples (e.g. a turtle string) to use as existing data values to fill the form
|
|
56
60
|
data-values-url | When `data-values` is not set, the data triples are loaded from this URL
|
|
57
61
|
data-value-subject | The subject (id) of the generated data. If this is not set, a blank node with a new UUID will be used. If `data-values` or `data-values-url` is set, this id is also used to find existing data in the data graph to fill the form
|
|
58
|
-
data-language | Language to use if shapes contain langStrings, e.g. in `sh:name` or `rdfs:label`
|
|
59
|
-
data‑ignore‑owl‑imports | By default, `owl:imports` IRIs are fetched and the resulting triples added to the shapes graph. Set this attribute in order to disable this feature
|
|
60
|
-
data-submit-button | Whether to
|
|
62
|
+
data-language | Language to use if shapes contain langStrings, e.g. in `sh:name` or `rdfs:label`. Default is [`navigator.language`](https://www.w3schools.com/jsref/prop_nav_language.asp)
|
|
63
|
+
data‑ignore‑owl‑imports | By default, `owl:imports` IRIs are fetched and the resulting triples added to the shapes graph. Set this attribute to any value in order to disable this feature
|
|
64
|
+
data-submit-button | Whether to add a submit button to the form. The value of this attribute is used as the button label. `submit` events will only fire after successful validation
|
|
61
65
|
|
|
62
66
|
### Element functions
|
|
63
67
|
```typescript
|
|
64
|
-
serialize(format?: string): string
|
|
68
|
+
serialize(format?: string): string
|
|
65
69
|
```
|
|
66
70
|
|
|
67
|
-
Serializes the form data to RDF triples. Supported formats: `text/turtle` (default), `application/ld+json`, `application/n-triples`, `application/n-quads`, `application/trig`.
|
|
71
|
+
Serializes the form data to RDF triples. Supported formats: `text/turtle` (default), `application/ld+json`, `application/n-triples`, `application/n-quads`, `application/trig`.
|
|
68
72
|
|
|
69
73
|
```typescript
|
|
70
74
|
validate(ignoreEmptyValues: boolean): Promise<boolean>
|
|
@@ -74,10 +78,14 @@ Validates the form data against the SHACL shapes graph and displays validation r
|
|
|
74
78
|
```typescript
|
|
75
79
|
registerPlugin(plugin: Plugin)
|
|
76
80
|
```
|
|
77
|
-
Register a plugin to customize editing certain property values. Examples: [Mapbox](./src/plugins/mapbox.ts), [FixedList](./src/plugins/fixed-list.ts)
|
|
81
|
+
Register a plugin to customize editing certain property values. Plugins can handle specific RDF predicates or `xsd:datatype`s or both. Examples: [Mapbox](./src/plugins/mapbox.ts), [FixedList](./src/plugins/fixed-list.ts)
|
|
78
82
|
|
|
79
83
|
```typescript
|
|
80
84
|
setClassInstanceProvider((className: string) => Promise<string>)
|
|
81
85
|
```
|
|
82
|
-
Sets a callback function that is called when a SHACL property has a `sh:class` definition. The expected return value is a string (e.g. in format `text/turtle`) that contains RDF instance definitions of the given class. Instances can be defined
|
|
86
|
+
Sets a callback function that is called when a SHACL property has a `sh:class` definition. The expected return value is a string (e.g. in format `text/turtle`) that contains RDF class instance definitions of the given class. Instances can be defined for example like:
|
|
87
|
+
- `example:Instance a example:Class`
|
|
88
|
+
- `example:Instance a owl:NamedIndividual; skos:broader example:Class`
|
|
89
|
+
|
|
90
|
+
You can also use `rdfs:subClassOf` or `skos:broader` to build class hierarchies.
|
|
83
91
|
|
package/dist/config.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Prefixes, Store } from 'n3';
|
|
|
2
2
|
import { Term } from '@rdfjs/types';
|
|
3
3
|
import { ClassInstanceProvider, Plugins } from './plugin';
|
|
4
4
|
import { Loader } from './loader';
|
|
5
|
+
import { Theme } from './theme';
|
|
5
6
|
export declare class ElementAttributes {
|
|
6
7
|
shapes: string | null;
|
|
7
8
|
shapesUrl: string | null;
|
|
@@ -9,7 +10,8 @@ export declare class ElementAttributes {
|
|
|
9
10
|
values: string | null;
|
|
10
11
|
valuesUrl: string | null;
|
|
11
12
|
valueSubject: string | null;
|
|
12
|
-
|
|
13
|
+
view: string | null;
|
|
14
|
+
language: string;
|
|
13
15
|
ignoreOwlImports: string | null;
|
|
14
16
|
submitButton: string | null;
|
|
15
17
|
}
|
|
@@ -19,9 +21,11 @@ export declare class Config {
|
|
|
19
21
|
classInstanceProvider: ClassInstanceProvider | undefined;
|
|
20
22
|
prefixes: Prefixes;
|
|
21
23
|
plugins: Plugins;
|
|
24
|
+
editMode: boolean;
|
|
22
25
|
dataGraph: Store<import("@rdfjs/types").Quad, import("n3").Quad, import("@rdfjs/types").Quad, import("@rdfjs/types").Quad>;
|
|
23
26
|
lists: Record<string, Term[]>;
|
|
24
27
|
groups: Array<string>;
|
|
28
|
+
theme: Theme;
|
|
25
29
|
private _shapesGraph;
|
|
26
30
|
updateAttributes(elem: HTMLElement): void;
|
|
27
31
|
static dataAttributes(): Array<string>;
|
package/dist/constants.d.ts
CHANGED
|
@@ -13,3 +13,4 @@ export declare const SKOS_PREDICATE_BROADER: import("n3").NamedNode<string>;
|
|
|
13
13
|
export declare const OWL_OBJECT_NAMED_INDIVIDUAL: import("n3").NamedNode<string>;
|
|
14
14
|
export declare const SHACL_OBJECT_NODE_SHAPE: import("n3").NamedNode<string>;
|
|
15
15
|
export declare const SHACL_PREDICATE_CLASS: import("n3").NamedNode<string>;
|
|
16
|
+
export declare const SHACL_PREDICATE_TARGET_CLASS: import("n3").NamedNode<string>;
|
package/dist/constraints.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ import { Term } from '@rdfjs/types';
|
|
|
2
2
|
import { ShaclNode } from "./node";
|
|
3
3
|
import { ShaclProperty } from "./property";
|
|
4
4
|
import { Config } from './config';
|
|
5
|
+
import { ShaclPropertyTemplate } from './property-template';
|
|
5
6
|
export declare function createShaclOrConstraint(options: Term[], context: ShaclNode | ShaclProperty, config: Config): HTMLElement;
|
|
7
|
+
export declare function resolveShaclOrConstraint(template: ShaclPropertyTemplate, value: Term): ShaclPropertyTemplate;
|
package/dist/form.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ShaclNode } from './node';
|
|
2
2
|
import { Config } from './config';
|
|
3
3
|
import { ClassInstanceProvider, Plugin } from './plugin';
|
|
4
|
+
import { Theme } from './theme';
|
|
4
5
|
import './styles.css';
|
|
5
6
|
export declare class ShaclForm extends HTMLElement {
|
|
6
7
|
static get observedAttributes(): string[];
|
|
@@ -12,9 +13,10 @@ export declare class ShaclForm extends HTMLElement {
|
|
|
12
13
|
connectedCallback(): void;
|
|
13
14
|
attributeChangedCallback(): void;
|
|
14
15
|
private initialize;
|
|
15
|
-
serialize(format?: string): string
|
|
16
|
+
serialize(format?: string): string;
|
|
16
17
|
registerPlugin(plugin: Plugin): void;
|
|
17
18
|
setClassInstanceProvider(provider: ClassInstanceProvider): void;
|
|
19
|
+
setTheme(theme: Theme): void;
|
|
18
20
|
validate(ignoreEmptyValues?: boolean): Promise<boolean>;
|
|
19
21
|
private createValidationErrorDisplay;
|
|
20
22
|
private findRootShaclShapeSubject;
|