Skip to content

Commit e722b2f

Browse files
committed
wip: instances select editor
1 parent c36924e commit e722b2f

54 files changed

Lines changed: 610 additions & 494 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

demos/storybook/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"@coreui/react": "^5.4.1",
1212
"@coreui/coreui": "^5.2.0",
1313
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
14+
"@hydrofoil/shaperone-core": "^0.12.1",
1415
"@hydrofoil/shaperone-wc": "^0.8.0",
1516
"@hydrofoil/shaperone-wc-material": "^0.6.1",
1617
"@hydrofoil/shaperone-wc-shoelace": "^0.4.1",
@@ -27,18 +28,21 @@
2728
"@storybook/components": "^8.4.5",
2829
"@storybook/web-components": "^8.4.5",
2930
"@storybook/web-components-vite": "^8.4.5",
31+
"@tpluscode/rdf-ns-builders": "^4.3.0",
3032
"@vitejs/plugin-react": "^4.3.3",
3133
"@zazuko/env": "^2",
3234
"lit": "^3",
3335
"onetime": "^7.0.0",
3436
"react-syntax-highlighter": "^15.6.1",
3537
"remark-gfm": "^4.0.0",
3638
"rollup-plugin-polyfill-node": "^0.13.0",
39+
"sparql-http-client": "^3.0.1",
3740
"storybook": "^8.4.5",
3841
"string-to-stream": "^3.0.1",
3942
"ts-deepmerge": "^7"
4043
},
4144
"devDependencies": {
42-
"@types/react-syntax-highlighter": "^15.5.13"
45+
"@types/react-syntax-highlighter": "^15.5.13",
46+
"@types/sparql-http-client": "^3"
4347
}
4448
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PREFIX ex: <http://example.org/>
2+
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3+
prefix wd: <http://www.wikidata.org/entity/>
4+
5+
ex:instance <http://schema.org/alumniOf> wd:Q184478 .
6+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
PREFIX dash: <http://datashapes.org/dash#>
2+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3+
PREFIX wd: <http://www.wikidata.org/entity/>
4+
PREFIX schema: <http://schema.org/>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
7+
<> a sh:NodeShape ;
8+
sh:property
9+
[
10+
sh:path schema:alumniOf ;
11+
sh:class wd:Q3918 ;
12+
sh:name "Alma mater" ;
13+
sh:minCount 1 ;
14+
sh:maxCount 1 ;
15+
dash:editor dash:InstancesSelectEditor ;
16+
] ;
17+
.
18+
19+
wd:Q184478 a wd:Q3918 .
20+
wd:Q1860208 a wd:Q3918 .
21+
wd:Q49108 a wd:Q3918 .
22+
wd:Q34433 a wd:Q3918 .
23+
wd:Q35794 a wd:Q3918 .
24+
wd:Q13371 a wd:Q3918 .

demos/storybook/shapes/editors/dash/InstancesSelect/wikidata.ttl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
PREFIX dash: <http://datashapes.org/dash#>
12
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
23
PREFIX wd: <http://www.wikidata.org/entity/>
34
PREFIX schema: <http://schema.org/>
@@ -11,6 +12,7 @@ PREFIX sh: <http://www.w3.org/ns/shacl#>
1112
sh:name "Alma mater" ;
1213
sh:minCount 1 ;
1314
sh:maxCount 1 ;
15+
dash:editor dash:InstancesSelectEditor ;
1416
] ;
1517
.
1618

demos/storybook/stories/DASH/EnumSelectEditor.stories.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

demos/storybook/stories/Design Systems/Material Design.stories.ts renamed to demos/storybook/stories/Design Systems/Material Design.stories._ts

File renamed without changes.

demos/storybook/stories/Design Systems/Shoelace.stories.ts renamed to demos/storybook/stories/Design Systems/Shoelace.stories._ts

File renamed without changes.

demos/storybook/stories/Design Systems/Vaadin.stories.ts renamed to demos/storybook/stories/Design Systems/Vaadin.stories._ts

File renamed without changes.

demos/storybook/stories/Editors/DASH.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ DASH is a set of auxiliary specifications by TopQuadrant's SHACL author Holger K
1515

1616
DASH defines two types of editors: `dash:SingleEditor` and `dash:MultiEditor` which represent a user input element of a form.
1717

18-
As the names imply, the former are editors for individual triple object while the latter replaces all values for a given property.
18+
As the names imply, the former are editors for individual triple's object while the latter replaces all values for a given property.
1919

2020
It also provides a set of instances of the `dash:SingleEditor` type. The table below lists them and indicates which are implemented as [matchers](editors/matchers.md) and [components](components/implement.md) by shaperone. Below you will also find some additional information about some of them.
2121

@@ -28,7 +28,7 @@ It also provides a set of instances of the `dash:SingleEditor` type. The table b
2828
| [`dash:DateTimePickerEditor`](http://datashapes.org/forms.html#DateTimePickerEditor) | A calendar for selecting date and time |||
2929
| [`dash:DetailsEditor`](http://datashapes.org/forms.html#DetailsEditor) | A drill-down-style editor for editing child focus nodes |||
3030
| [`dash:EnumSelectEditor`](http://datashapes.org/forms.html#EnumSelectEditor) | A dropdown with choices from a closed set of elements || 🐲 |
31-
| [`dash:InstancesSelectEditor`](http://datashapes.org/forms.html#InstancesSelectEditor) | A dropdown to choose among instances a specific type as indicated by `sh:class` shape property | | 🐉 |
31+
| [`dash:InstancesSelectEditor`](http://datashapes.org/forms.html#InstancesSelectEditor) | A dropdown to choose among instances a specific type as indicated by `sh:class` shape property | ⚠️ | 🐲 |
3232
| [`dash:RichTextEditor`](http://datashapes.org/forms.html#RichTextEditor) | A text editor with formatting, which returns HTML markup |||
3333
| [`dash:TextAreaEditor`](http://datashapes.org/forms.html#TextAreaEditor) | Multiline text box |||
3434
| [`dash:TextFieldEditor`](http://datashapes.org/forms.html#TextFieldEditor) | Single line text box |||
@@ -37,5 +37,5 @@ It also provides a set of instances of the `dash:SingleEditor` type. The table b
3737
| [`dash:URIEditor`](http://datashapes.org/forms.html#URIEditor) | A text box for typing in URIs |||
3838

3939
<CCallout color="info">
40-
Most of the default behaviour of components can be easily customized in your application. The [components page](components/implement.md) provides information about necessary implementation steps.
40+
Most of the default behaviour of components can be customized in your application. The [components page](components/implement.md) provides information about necessary implementation steps.
4141
</CCallout>

demos/storybook/stories/Editors/DASH/InstancesSelectEditor.mdx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Stories } from '@storybook/blocks';
1+
import { Markdown, Stories, Story } from '@storybook/blocks'
22
import { CCallout } from '@coreui/react';
33
import * as InstanceSelect from './InstancesSelectEditor.stories';
44
import { Meta } from '@storybook/blocks'
5+
import fetchDecoratorRaw from './InstancesSelectEditor/fetch.ts?raw'
56

67
# InstancesSelectEditor
78

@@ -12,6 +13,36 @@ an "instances selector" presents a dropdown, by default populated with instances
1213
[Hydra integration library](../?path=/docs/extensions-hydra--docs) can be used to extend the functionality of Instances Select editor so that instance data is dereferenced from external resources.
1314
</CCallout>
1415

16+
<CCallout color="warning">
17+
Because both the matcher of `dash:InstancesSelectEditor` and `dash:DetailsEditor` return `null` for similar
18+
objects, it is advised to always explicitly set the `dash:editor`, or decorate the matchers.
19+
</CCallout>
20+
21+
## Stories
22+
1523
<Meta of={InstanceSelect}/>
1624

17-
<Stories />
25+
### Resources by sh:class
26+
27+
Just as with enum select, `rdfs:label` is used for option text
28+
29+
<Story of={InstanceSelect.Wikidata} />
30+
31+
### Resources without labels
32+
33+
If the Shapes Graph does not contain `rdfs:label` for the options, the editor can request
34+
that the instance data can be fetched from the server and merged with the Shapes Graph.
35+
36+
To do that, the editor must be wrapped in a decorator that provides the instance data.
37+
38+
In the example below, such a decorator is presented which fetches instance data from Wikidata using its public SPARQL endpoint.
39+
40+
<Markdown>
41+
{`
42+
\`\`\`ts
43+
${fetchDecoratorRaw}
44+
\`\`\`
45+
`}
46+
</Markdown>
47+
48+
<Story of={InstanceSelect.WikidataNoLabels} />

0 commit comments

Comments
 (0)