sol-components 2.2.1 → 2.2.2
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/core/from-query.js +14 -4
- package/dist/sol-loader.manifest.json +46 -34
- package/package.json +1 -1
package/core/from-query.js
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
// row (+ a `sol-select` event on change); anything else → nothing is rendered and
|
|
15
15
|
// the W3C SPARQL 1.1 Query Results JSON is left on `el.swcData` for you to use.
|
|
16
16
|
//
|
|
17
|
+
// When the results land, the host fires a `sol-data-ready` event (bubbles/composed,
|
|
18
|
+
// detail.data = the W3C JSON), so a custom element or page can react on the event
|
|
19
|
+
// instead of reading el.swcData:
|
|
20
|
+
// el.addEventListener('sol-data-ready', (e) => render(e.detail.data.results.bindings));
|
|
21
|
+
//
|
|
17
22
|
// Config attributes (endpoint, pattern, sparql, query, var-<name>) may be written
|
|
18
23
|
// bare OR `data-`-prefixed (data-endpoint, …, data-var-<name>) to keep the markup
|
|
19
24
|
// spec-valid HTML; bare wins if both are given. `data-from-query` is the trigger.
|
|
@@ -133,15 +138,20 @@ function setLoading(el) {
|
|
|
133
138
|
}
|
|
134
139
|
|
|
135
140
|
// The host's tag picks the shape. Unknown tags render nothing into the DOM — the
|
|
136
|
-
// W3C JSON is left on `el.swcData` for the page to consume.
|
|
141
|
+
// W3C JSON is left on `el.swcData` for the page to consume. Either way, when the
|
|
142
|
+
// results land we fire a `sol-data-ready` event (detail.data = the W3C JSON) so a
|
|
143
|
+
// custom element / page can react without polling el.swcData.
|
|
137
144
|
function renderInto(el, data) {
|
|
138
145
|
el.swcData = data;
|
|
139
146
|
const vars = data.head.vars;
|
|
140
147
|
const rows = data.results.bindings;
|
|
141
148
|
const tag = el.localName;
|
|
142
|
-
if (tag === 'ul' || tag === 'ol')
|
|
143
|
-
if (tag === 'select')
|
|
144
|
-
el.replaceChildren(); // clear the loading indicator
|
|
149
|
+
if (tag === 'ul' || tag === 'ol') fillList(el, vars, rows);
|
|
150
|
+
else if (tag === 'select') fillSelect(el, vars, rows);
|
|
151
|
+
else el.replaceChildren(); // clear the loading indicator
|
|
152
|
+
el.dispatchEvent(new CustomEvent('sol-data-ready', {
|
|
153
|
+
bubbles: true, composed: true, detail: { data: data },
|
|
154
|
+
}));
|
|
145
155
|
}
|
|
146
156
|
|
|
147
157
|
activate('[data-from-query]', (el) => {
|
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sol-components",
|
|
3
|
-
|
|
3
|
+
"attributes": {
|
|
4
|
+
"data-from-query": "sol-components/core/from-query.js",
|
|
5
|
+
"data-handler": "sol-components/core/handler.js",
|
|
6
|
+
"data-edit-shape data-from-rdf": "rdf-bundle"
|
|
7
|
+
},
|
|
8
|
+
"objects": {
|
|
9
|
+
"provides": {
|
|
10
|
+
"store": {
|
|
11
|
+
"service": "rdf",
|
|
12
|
+
"sendValue": "store"
|
|
13
|
+
},
|
|
14
|
+
"auth": {
|
|
15
|
+
"service": "auth",
|
|
16
|
+
"sendValue": "fetch"
|
|
17
|
+
},
|
|
18
|
+
"navigation": {
|
|
19
|
+
"respondTo": "sol-navigate",
|
|
20
|
+
"sendValue": "detail.url"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"consumes": {
|
|
24
|
+
"store": {
|
|
25
|
+
"call": "rdf.useStore"
|
|
26
|
+
},
|
|
27
|
+
"auth": {
|
|
28
|
+
"call": "adoptFetch"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"accepts": {
|
|
32
|
+
"navigation": {
|
|
33
|
+
"onElement": "sol-query",
|
|
34
|
+
"applyValueTo": "endpoint"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"bundles": {
|
|
39
|
+
"rdf-bundle": [
|
|
40
|
+
"solid-logic",
|
|
41
|
+
"solid-ui",
|
|
42
|
+
"sol-tree-edit",
|
|
43
|
+
"sol-form",
|
|
44
|
+
"sol-settings",
|
|
45
|
+
"sol-components/core/edit-placements.js",
|
|
46
|
+
"sol-components/core/from-rdf.js"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
4
49
|
"stages": {
|
|
5
50
|
"local": {
|
|
6
51
|
"components": {
|
|
@@ -104,38 +149,5 @@
|
|
|
104
149
|
"sol-components/": "https://esm.sh/sol-components/web/"
|
|
105
150
|
}
|
|
106
151
|
}
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
"bundles": {
|
|
110
|
-
"rdf-bundle": [
|
|
111
|
-
"solid-logic",
|
|
112
|
-
"solid-ui",
|
|
113
|
-
"sol-tree-edit",
|
|
114
|
-
"sol-form",
|
|
115
|
-
"sol-settings",
|
|
116
|
-
"sol-components/core/edit-placements.js",
|
|
117
|
-
"sol-components/core/from-rdf.js"
|
|
118
|
-
]
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
"attributes": {
|
|
122
|
-
"data-from-query": "sol-components/core/from-query.js",
|
|
123
|
-
"data-handler": "sol-components/core/handler.js",
|
|
124
|
-
"data-edit-shape data-from-rdf": "rdf-bundle"
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
"objects": {
|
|
128
|
-
"provides": {
|
|
129
|
-
"store": { "service": "rdf", "sendValue": "store" },
|
|
130
|
-
"auth": { "service": "auth", "sendValue": "fetch" },
|
|
131
|
-
"navigation": { "respondTo": "sol-navigate", "sendValue": "detail.url" }
|
|
132
|
-
},
|
|
133
|
-
"consumes": {
|
|
134
|
-
"store": { "call": "rdf.useStore" },
|
|
135
|
-
"auth": { "call": "adoptFetch" }
|
|
136
|
-
},
|
|
137
|
-
"accepts": {
|
|
138
|
-
"navigation": { "onElement": "sol-query", "applyValueTo": "endpoint" }
|
|
139
|
-
}
|
|
140
152
|
}
|
|
141
153
|
}
|