@ulb-darmstadt/shacl-form 1.1.9 → 1.2.0
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 +23 -8
- package/dist/bootstrap.js +2 -0
- package/dist/config.d.ts +3 -1
- package/dist/form-bootstrap.d.ts +4 -0
- package/dist/form-material.d.ts +4 -0
- package/dist/form-native.d.ts +4 -0
- package/dist/form.d.ts +4 -5
- package/dist/index.js +1 -1
- package/dist/loader.d.ts +0 -1
- package/dist/material.js +335 -0
- package/dist/material.js.LICENSE.txt +137 -0
- package/dist/plugin.d.ts +5 -2
- package/dist/plugins/fixed-list.d.ts +1 -1
- package/dist/plugins/fixed-list.js +1 -0
- package/dist/plugins/mapbox.d.ts +7 -14
- package/dist/plugins/mapbox.js +2 -0
- package/dist/plugins/mapbox.js.LICENSE.txt +1 -0
- package/dist/property.d.ts +1 -1
- package/dist/theme.d.ts +12 -16
- package/dist/themes/bootstrap.d.ts +10 -0
- package/dist/themes/material.d.ts +15 -0
- package/dist/themes/material.js +335 -0
- package/dist/themes/material.js.LICENSE.txt +65 -0
- package/dist/themes/native.d.ts +15 -0
- package/dist/util.d.ts +1 -0
- package/package.json +4 -6
- package/dist/editors.d.ts +0 -19
- package/dist/index-with-plugins.d.ts +0 -2
- package/dist/index-with-plugins.js +0 -3
- package/dist/index-with-plugins.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/plugins/index.d.ts +0 -3
- /package/dist/{index-with-plugins.js.LICENSE.txt → bootstrap.js.LICENSE.txt} +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
npm i @ulb-darmstadt/shacl-form
|
|
5
5
|
```
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
An HTML5 web component for editing/viewing [RDF](https://www.w3.org/RDF/) data that conform to [SHACL shapes](https://www.w3.org/TR/shacl/).
|
|
8
8
|
|
|
9
9
|
## [See demo here](https://ulb-darmstadt.github.io/shacl-form/)
|
|
10
10
|
|
|
@@ -36,7 +36,7 @@ This library provides an HTML5 web component that renders [SHACL shapes](https:/
|
|
|
36
36
|
<script>
|
|
37
37
|
const form = document.querySelector("shacl-form")
|
|
38
38
|
form.addEventListener('change', event => {
|
|
39
|
-
// check if form validates according to the SHACL shapes
|
|
39
|
+
// check if form data validates according to the SHACL shapes
|
|
40
40
|
if (event.detail?.valid) {
|
|
41
41
|
// get data graph as RDF triples (default format is 'text/turtle')
|
|
42
42
|
// and log them to the browser console
|
|
@@ -56,11 +56,12 @@ Attribute | Description
|
|
|
56
56
|
data-shapes | SHACL shape definitions (e.g. a turtle string) to generate the form from
|
|
57
57
|
data-shapes-url | When `data-shapes` is not set, the SHACL shapes are loaded from this URL
|
|
58
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
|
|
59
|
-
data-values | RDF triples (e.g. a turtle string) to use as existing data
|
|
60
|
-
data-values-url | When `data-values` is not set, the data triples are loaded from this URL
|
|
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
|
|
59
|
+
data-values | RDF triples (e.g. a turtle string) to use as existing data graph to fill the form
|
|
60
|
+
data-values-url | When `data-values` is not set, the data graph triples are loaded from this URL
|
|
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 the root node in the data graph to fill the form
|
|
62
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`
|
|
63
|
+
data‑ignore‑owl‑imports | By default, `owl:imports` URLs are fetched and the resulting RDF triples are added to the shapes graph. Set this attribute to any value in order to disable this feature
|
|
64
|
+
data-mode | When set to `"view"`, turns the web component into a viewer that displays the given data graph without editing functionality
|
|
64
65
|
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
|
|
65
66
|
|
|
66
67
|
### Element functions
|
|
@@ -78,14 +79,28 @@ Validates the form data against the SHACL shapes graph and displays validation r
|
|
|
78
79
|
```typescript
|
|
79
80
|
registerPlugin(plugin: Plugin)
|
|
80
81
|
```
|
|
81
|
-
Register a plugin to customize editing certain property values. Plugins
|
|
82
|
+
Register a [plugin](./src/plugin.ts) to customize editing/viewing certain property values. Plugins handle specific RDF predicates or `xsd:datatype`s or both. Examples: [Mapbox](./src/plugins/mapbox.ts), [FixedList](./src/plugins/fixed-list.ts)
|
|
82
83
|
|
|
84
|
+
```typescript
|
|
85
|
+
setTheme(theme: Theme)
|
|
86
|
+
```
|
|
87
|
+
Set a design theme to use for rendering. See section "Theming" below.
|
|
83
88
|
```typescript
|
|
84
89
|
setClassInstanceProvider((className: string) => Promise<string>)
|
|
85
90
|
```
|
|
86
|
-
Sets a callback function that is called when a SHACL property has
|
|
91
|
+
Sets a callback function that is called when a SHACL property has an `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 e.g. like:
|
|
87
92
|
- `example:Instance a example:Class`
|
|
88
93
|
- `example:Instance a owl:NamedIndividual; skos:broader example:Class`
|
|
89
94
|
|
|
90
95
|
You can also use `rdfs:subClassOf` or `skos:broader` to build class hierarchies.
|
|
91
96
|
|
|
97
|
+
## Theming
|
|
98
|
+
`<shacl-form>` comes in 3 different bundles, each providing a specific theme:
|
|
99
|
+
|
|
100
|
+
Theme | Import statement
|
|
101
|
+
--- | ---
|
|
102
|
+
Native (opinionated raw HTML) | `import '@ulb-darmstadt/shacl-form/index.js'`
|
|
103
|
+
[Bootstrap](./src/themes/bootstrap.ts) | `import '@ulb-darmstadt/shacl-form/bootstrap.js'`
|
|
104
|
+
[Material Design](./src/themes/material.ts) | `import '@ulb-darmstadt/shacl-form/material.js'`
|
|
105
|
+
|
|
106
|
+
Custom themes can be employed by implementing class [Theme](./src/theme.ts) yourself, then activating it with function `setTheme()` on the `<shacl-form>` element.
|