Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
s-tittel committed Aug 20, 2023
1 parent 34e7e67 commit 4f93b72
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,34 @@ This library provides an HTML5 web component that renders [SHACL shapes](https:/
Attribute | Description
---|---
data-shapes | SHACL shape definitions (e.g. a turtle string) to generate the form from
data-shapes-url | When `data-shapes` is not set, load the shapes graph from this URL
data-shapes-url | When `data-shapes` is not set, the shapes graph is loaded from this URL
data-shape-subject | Optional subject (id) of the shacl node shape to use as root for the form. If not set, the first found shacl node shape will be used
data-values | RDF triples (e.g. a turtle string) to use as existing data values in the generated form
data-values-url | When `data-values` is not set, load the data graph from this URL
data-values-url | When `data-values` is not set, the data graph is loaded from this URL
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
data-language | Language to use if shapes contain langStrings
data‑ignore‑owl‑imports | By default, `owl:imports` are fetched and the resulting triples are added to the shapes graph. Set this attribute to disable this feature.
data-submit-button | Whether to append a submit button to the form. The string value of this attribute is used as the button label. Submit events will only fire after successful validation
data-language | Language to use if shapes contain langStrings, e.g. in `sh:name` or `rdfs:label`
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
data-submit-button | Whether to append a submit button to the form. The string value of this attribute is used as the button label. `submit` events will only fire after successful validation
### Element functions
Function | Description
---|---
`serialize(format?: string): string \| {}[]` | Serializes the form data as RDF triples. Supported formats: `text/turtle` (default), `application/ld+json`, `application/n-triples`, `application/n-quads`, `application/trig`
`validate(ignoreEmptyValues: boolean): Promise\<boolean\>` | Validates the form data against the SHACL shapes graph and displays validation results as icons. If `ignoreEmptyValues` is true, empty form fields will not be marked as having validation errors
`registerPlugin(plugin: Plugin)` | TBD
```typescript
serialize(format?: string): string | []
```
Serializes the form data as RDF triples. Supported formats: `text/turtle` (default), `application/ld+json`, `application/n-triples`, `application/n-quads`, `application/trig`. Format `application/ld+json` returns a JSON array, all other formats return a string.
```typescript
validate(ignoreEmptyValues: boolean): Promise<boolean>
```
Validates the form data against the SHACL shapes graph and displays validation results as icons next to the respective inut fields. If `ignoreEmptyValues` is true, empty form fields will not be marked as invalid. This function is also internally called on `change` and `submit` events.
```typescript
registerPlugin(plugin: Plugin)
```
WIP / TBD
## Theming
TBD
```typescript
setClassInstanceResolver((className: string) => Promise<string>)
```
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 name.

0 comments on commit 4f93b72

Please sign in to comment.