@ulb-darmstadt/shacl-form 1.6.0 → 1.6.2
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 +15 -14
- package/dist/exports.d.ts +1 -1
- package/dist/form-bootstrap.js +1 -1
- package/dist/form-default.js +1 -1
- package/dist/form-material.js +7 -358
- package/dist/form-material.js.LICENSE.txt +4 -40
- package/dist/form.d.ts +4 -3
- package/dist/loader.d.ts +1 -0
- package/dist/plugins/leaflet.d.ts +1 -0
- package/dist/plugins/leaflet.js +1 -1
- package/dist/plugins/mapbox.js +1 -1
- package/package.json +12 -13
package/README.md
CHANGED
|
@@ -22,9 +22,9 @@ HTML5 web component for editing/viewing [RDF](https://www.w3.org/RDF/) data that
|
|
|
22
22
|
or can be loaded by setting attribute 'data-shapes-url'
|
|
23
23
|
-->
|
|
24
24
|
<shacl-form data-shapes="
|
|
25
|
-
@prefix sh:
|
|
26
|
-
@prefix rdfs:
|
|
27
|
-
@prefix ex:
|
|
25
|
+
@prefix sh: <http://www.w3.org/ns/shacl#> .
|
|
26
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|
27
|
+
@prefix ex: <http://example.org#> .
|
|
28
28
|
|
|
29
29
|
ex:ExampleShape
|
|
30
30
|
a sh:NodeShape, rdfs:Class ;
|
|
@@ -74,16 +74,15 @@ data-show-node-ids | When this attribute is set, shacl node shapes will have the
|
|
|
74
74
|
|
|
75
75
|
### Element functions
|
|
76
76
|
|
|
77
|
+
<a id="toRDF"></a>
|
|
77
78
|
```typescript
|
|
78
79
|
toRDF(graph?: Store): Store
|
|
79
80
|
```
|
|
80
|
-
|
|
81
81
|
Adds the form values as RDF triples to the given graph. If no graph object is provided, creates a new [N3 Store](https://github.com/rdfjs/N3.js#storing).
|
|
82
82
|
|
|
83
83
|
```typescript
|
|
84
84
|
serialize(format?: string, graph?: Store): string
|
|
85
85
|
```
|
|
86
|
-
|
|
87
86
|
Serializes the given RDF graph to the given format. If no graph object is provided, this function calls toRDF() (see above) to construct the form data graph. <a name="formats"></a>Supported formats: `text/turtle` (default), `application/ld+json`, `application/n-triples`, `application/n-quads`, `application/trig`.
|
|
88
87
|
|
|
89
88
|
```typescript
|
|
@@ -100,14 +99,16 @@ Register a [plugin](./src/plugin.ts) to customize editing/viewing certain proper
|
|
|
100
99
|
setTheme(theme: Theme)
|
|
101
100
|
```
|
|
102
101
|
Set a design theme to use for rendering. See section [Theming](#Theming).
|
|
102
|
+
|
|
103
103
|
```typescript
|
|
104
104
|
setClassInstanceProvider((className: string) => Promise<string>)
|
|
105
105
|
```
|
|
106
|
-
Sets a callback function that is
|
|
107
|
-
- `example:Instance a example:Class`
|
|
108
|
-
- `example:Instance a owl:NamedIndividual; skos:broader example:Class`
|
|
106
|
+
Sets a callback function that is invoked when a SHACL property has an `sh:class` definition to retrieve class instances. See [below](#classInstanceProvider) for more information.
|
|
109
107
|
|
|
110
|
-
|
|
108
|
+
```typescript
|
|
109
|
+
setSharedShapesGraph(graph: Store)
|
|
110
|
+
```
|
|
111
|
+
Set an externally managed shapes graph to use. This improves performance When using multiple instances of `shacl-form` on the same page.
|
|
111
112
|
|
|
112
113
|
## Features
|
|
113
114
|
|
|
@@ -126,7 +127,7 @@ In edit mode, `<shacl-form>` validates the constructed data graph using the libr
|
|
|
126
127
|
### Providing additional data to the shapes graph
|
|
127
128
|
|
|
128
129
|
Apart from setting the element attributes `data-shapes` or `data-shapes-url`, there are two ways of adding RDF data to the shapes graph:
|
|
129
|
-
1. While parsing the triples of the shapes graph, any encountered `owl:imports` predicate that has a valid HTTP URL value will tried to
|
|
130
|
+
1. While parsing the triples of the shapes graph, any encountered `owl:imports` predicate that has a valid HTTP URL value will be tried to fetch with the HTTP Accept header set to all of the [supported](#formats) MIME types. A successful response will be parsed and added to the shapes graph. The [example shapes graph](https://ulb-darmstadt.github.io/shacl-form/#example) contains the following triples:
|
|
130
131
|
```
|
|
131
132
|
example:Attribution
|
|
132
133
|
owl:imports <https://w3id.org/nfdi4ing/metadata4ing/> ;
|
|
@@ -138,7 +139,7 @@ Apart from setting the element attributes `data-shapes` or `data-shapes-url`, th
|
|
|
138
139
|
```
|
|
139
140
|
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.
|
|
140
141
|
|
|
141
|
-
2. 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
|
|
142
|
+
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
|
|
142
143
|
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:
|
|
143
144
|
- `example:Instance a example:Class`
|
|
144
145
|
- `example:Instance a owl:NamedIndividual; skos:broader example:Class`
|
|
@@ -218,7 +219,7 @@ Apart from grouped properties, all properties having an `sh:node` predicate and
|
|
|
218
219
|
|
|
219
220
|
### Use with Solid Pods
|
|
220
221
|
|
|
221
|
-
`<shacl-form>` can easily be integrated with [Solid Pods](https://solidproject.org/about). The output of `toRDF()` being a
|
|
222
|
+
`<shacl-form>` can easily be integrated with [Solid Pods](https://solidproject.org/about). The output of `toRDF()` being a RDF/JS N3 Store, as explained [above](#toRDF), it can be presented to `solid-client`s `fromRdfJsDataset()` function, which converts the RDF graph into a Solid Dataset. The following example, based on Inrupt's basic [Solid Pod example](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/getting-started/) shows how to merge data from a `<shacl-form>` with a Solid data resource at `readingListDataResourceURI`:
|
|
222
223
|
|
|
223
224
|
```js
|
|
224
225
|
// Authentication is assumed, resulting in a fetch able to read and write into the Pod
|
|
@@ -226,7 +227,7 @@ Apart from grouped properties, all properties having an `sh:node` predicate and
|
|
|
226
227
|
// Get data out of the shacl-form
|
|
227
228
|
const form = document.querySelector('shacl-form')
|
|
228
229
|
|
|
229
|
-
// Extract the RDF
|
|
230
|
+
// Extract the RDF graph from the form
|
|
230
231
|
const shaclFormGraphStore = await form.toRDF()
|
|
231
232
|
|
|
232
233
|
// Convert RDF store into a Solid dataset
|
|
@@ -235,7 +236,7 @@ Apart from grouped properties, all properties having an `sh:node` predicate and
|
|
|
235
236
|
// First get the current dataset
|
|
236
237
|
myReadingList = await getSolidDataset(readingListDataResourceURI, { fetch: fetch })
|
|
237
238
|
|
|
238
|
-
// get all
|
|
239
|
+
// get all things from the shaclFormDataset
|
|
239
240
|
const shaclFormThings = getThingAll(shaclFormDataset)
|
|
240
241
|
|
|
241
242
|
// add the things from ShaclForm to the existing set
|
package/dist/exports.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Theme, InputListEntry, Editor } from './theme';
|
|
2
|
-
export { Loader } from './loader';
|
|
2
|
+
export { Loader, setSharedShapesGraph } from './loader';
|
|
3
3
|
export { Config } from './config';
|
|
4
4
|
export { Plugin, registerPlugin } from './plugin';
|
|
5
5
|
export { ShaclPropertyTemplate } from './property-template';
|