sol-components 2.2.0 → 2.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
@@ -1,5 +1,7 @@
1
1
  # Solid Web Components
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/sol-components)](https://www.npmjs.com/package/sol-components)
4
+
3
5
  ## This is a Work In Progress!
4
6
 
5
7
  See the <a href="https://jeff-zucker.github.io/sol-components/">help pages</a> for details.
@@ -118,8 +118,22 @@ function fillSelect(el, vars, rows) {
118
118
  }
119
119
  }
120
120
 
121
- // The host's tag picks the shape. Unknown tags render nothing the W3C JSON is
122
- // left on `el.swcData` for the page to consume.
121
+ // While the query runs, show a loading indicator IN the host, shaped to its tag
122
+ // (a <li> in a list, an <option> in a select, else a <div>). aria-live announces it.
123
+ function setLoading(el) {
124
+ const tag = el.localName;
125
+ let node;
126
+ if (tag === 'ul' || tag === 'ol') node = document.createElement('li');
127
+ else if (tag === 'select') { node = document.createElement('option'); node.disabled = true; node.selected = true; }
128
+ else { node = document.createElement('div'); node.setAttribute('role', 'status'); }
129
+ node.className = 'swc-loading';
130
+ node.setAttribute('aria-live', 'polite');
131
+ node.textContent = 'Loading…';
132
+ el.replaceChildren(node);
133
+ }
134
+
135
+ // 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.
123
137
  function renderInto(el, data) {
124
138
  el.swcData = data;
125
139
  const vars = data.head.vars;
@@ -127,11 +141,12 @@ function renderInto(el, data) {
127
141
  const tag = el.localName;
128
142
  if (tag === 'ul' || tag === 'ol') return fillList(el, vars, rows);
129
143
  if (tag === 'select') return fillSelect(el, vars, rows);
130
- // anything else: leave the DOM untouched; the JSON is on el.swcData.
144
+ el.replaceChildren(); // clear the loading indicator; the JSON is on el.swcData
131
145
  }
132
146
 
133
147
  activate('[data-from-query]', (el) => {
134
148
  if (el.localName === 'sol-query') return; // the element handles itself
149
+ setLoading(el);
135
150
  buildData(el)
136
151
  .then((data) => renderInto(el, data))
137
152
  .catch((e) => { el.innerHTML = `<div class="error">${(e && e.message) || e}</div>`; console.error('[data-from-query]', e); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sol-components",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Web components and Node.js tools for querying, including, and editing RDF/Linked Data on Solid Pods",
5
5
  "type": "module",
6
6
  "exports": {