@ulb-darmstadt/shacl-form 1.1.9 → 1.2.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.
- package/README.md +27 -10
- package/dist/bootstrap.js +2 -0
- package/dist/config.d.ts +5 -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 +8 -15
- 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,12 +56,15 @@ 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
|
|
64
|
-
data
|
|
63
|
+
data-loading | Text to display while the web component is initializing. Default: `"Loading..."`
|
|
64
|
+
data‑ignore‑owl‑imports | By default, `owl:imports` URLs are fetched and the resulting RDF triples are added to the shapes graph. Setting this attribute to any value disables this feature
|
|
65
|
+
data-mode | When set to `"view"`, turns the web component into a viewer that displays the given data graph without editing functionality
|
|
66
|
+
data-collapse | When this attribute is present or set to any value, `sh:group`s and properties with `sh:node` and `sh:maxCount` > 1 are displayed in a collapsible accordion-like widget. This enhances readability in edit and view mode
|
|
67
|
+
data-submit-button | [Only used in edit mode] 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
68
|
|
|
66
69
|
### Element functions
|
|
67
70
|
```typescript
|
|
@@ -78,14 +81,28 @@ Validates the form data against the SHACL shapes graph and displays validation r
|
|
|
78
81
|
```typescript
|
|
79
82
|
registerPlugin(plugin: Plugin)
|
|
80
83
|
```
|
|
81
|
-
Register a plugin to customize editing certain property values. Plugins
|
|
84
|
+
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
85
|
|
|
86
|
+
```typescript
|
|
87
|
+
setTheme(theme: Theme)
|
|
88
|
+
```
|
|
89
|
+
Set a design theme to use for rendering. See section "Theming" below.
|
|
83
90
|
```typescript
|
|
84
91
|
setClassInstanceProvider((className: string) => Promise<string>)
|
|
85
92
|
```
|
|
86
|
-
Sets a callback function that is called when a SHACL property has
|
|
93
|
+
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
94
|
- `example:Instance a example:Class`
|
|
88
95
|
- `example:Instance a owl:NamedIndividual; skos:broader example:Class`
|
|
89
96
|
|
|
90
|
-
|
|
97
|
+
Class hierarchies can be built using `rdfs:subClassOf` or `skos:broader`.
|
|
98
|
+
|
|
99
|
+
## Theming
|
|
100
|
+
`<shacl-form>` comes in 3 different bundles, each providing a specific theme:
|
|
101
|
+
|
|
102
|
+
Theme | Import statement
|
|
103
|
+
--- | ---
|
|
104
|
+
Default (custom CSS) | `import '@ulb-darmstadt/shacl-form/index.js'`
|
|
105
|
+
[Bootstrap](./src/themes/bootstrap.ts) [alpha status] | `import '@ulb-darmstadt/shacl-form/bootstrap.js'`
|
|
106
|
+
[Material Design](./src/themes/material.ts) [alpha status] | `import '@ulb-darmstadt/shacl-form/material.js'`
|
|
91
107
|
|
|
108
|
+
Custom themes can be employed by implementing class [Theme](./src/theme.ts), then activating it with function `setTheme()` on the `<shacl-form>` element.
|