@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 CHANGED
@@ -4,7 +4,7 @@
4
4
  npm i @ulb-darmstadt/shacl-form
5
5
  ```
6
6
 
7
- This library provides an HTML5 web component that renders [SHACL shapes](https://www.w3.org/TR/shacl/) as a web form, outputting the entered data as RDF triples validated against these shapes.
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 values to fill the form
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 existing data in the data graph to fill the form
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&#x2011;ignore&#x2011;owl&#x2011;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
63
+ data-loading | Text to display while the web component is initializing. Default: `"Loading..."`
64
+ data&#x2011;ignore&#x2011;owl&#x2011;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 can handle specific RDF predicates or `xsd:datatype`s or both. Examples: [Mapbox](./src/plugins/mapbox.ts), [FixedList](./src/plugins/fixed-list.ts)
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 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:
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
- You can also use `rdfs:subClassOf` or `skos:broader` to build class hierarchies.
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.