@epa-wg/custom-element-dist 0.0.36 → 0.0.38

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.
Files changed (99) hide show
  1. package/.ai/mcp/mcp.json +0 -0
  2. package/.yarn/install-state.gz +0 -0
  3. package/AGENTS.md +1 -0
  4. package/CLAUDE.md +89 -0
  5. package/README.md +5 -5
  6. package/bin/postinstall.sh +12 -9
  7. package/coverage/coverage-final.json +4 -4
  8. package/coverage/index.html +25 -25
  9. package/coverage/src/custom-element/coverage.svg +1 -1
  10. package/coverage/src/custom-element/custom-element.js/coverage.svg +1 -1
  11. package/coverage/src/custom-element/custom-element.js.html +175 -160
  12. package/coverage/src/custom-element/http-request.js.html +10 -10
  13. package/coverage/src/custom-element/index.html +14 -14
  14. package/coverage/src/custom-element/local-storage.js.html +1 -1
  15. package/coverage/src/custom-element/location-element.js.html +1 -1
  16. package/coverage/src/custom-element/module-url.js.html +1 -1
  17. package/coverage/src/index.html +1 -1
  18. package/coverage/src/material/theme/colors.js.html +1 -1
  19. package/coverage/src/material/theme/index.html +1 -1
  20. package/coverage/src/mocks/handlers.ts.html +1 -1
  21. package/coverage/src/mocks/index.html +1 -1
  22. package/coverage/src/stories/coverage.svg +1 -1
  23. package/coverage/src/stories/frame.canvas.ts/coverage.svg +1 -1
  24. package/coverage/src/stories/frame.canvas.ts.html +54 -12
  25. package/coverage/src/stories/http-request.stories.ts.html +1 -1
  26. package/coverage/src/stories/index.html +19 -19
  27. package/coverage/src/stories/testStoryBook.ts.html +7 -16
  28. package/coverage/src/sum.ts.html +1 -1
  29. package/dist/{custom-element-BqBcmDiN.js → custom-element-Cr_I3Xd-.js} +69 -65
  30. package/dist/custom-element-D5IF46oF.cjs +97 -0
  31. package/dist/custom-element-bundle.cjs +1 -1
  32. package/dist/custom-element-bundle.js +3 -3
  33. package/dist/demo/a.html +41 -64
  34. package/dist/demo/s.xslt +94 -350
  35. package/dist/{local-storage-DzmNKzgN.js → local-storage-w0k66UWM.js} +4 -4
  36. package/package.json +3 -2
  37. package/public/demo/a.html +41 -64
  38. package/public/demo/s.xslt +94 -350
  39. package/src/custom-element/custom-element.js +9 -4
  40. package/src/custom-element/demo/a.html +41 -64
  41. package/src/custom-element/demo/s.xslt +94 -350
  42. package/src/custom-element/ide/customData-dce.json +8 -8
  43. package/src/custom-element/ide/web-types-dce.json +8 -8
  44. package/src/custom-element/ide/web-types-xsl.json +1 -1
  45. package/src/material/components/action.html +77 -22
  46. package/src/material/components/autocomplete.html +7 -6
  47. package/src/material/components/badge.html +33 -34
  48. package/src/material/components/cem-theme-components.css +131 -0
  49. package/src/material/components/dropdown.html +27 -12
  50. package/src/material/components/icon-link.html +25 -18
  51. package/src/material/components/icon.html +15 -14
  52. package/src/material/components/input.html +27 -24
  53. package/src/material/components/menu.html +23 -18
  54. package/src/material/components.html +19 -18
  55. package/src/material/demo.css +24 -12
  56. package/src/material/index.html +15 -9
  57. package/src/material/theme/colors-native.html +32 -1
  58. package/src/material/theme/consumer-theme.css +0 -733
  59. package/src/material/theme/semantic.css +1 -85
  60. package/src/mocks/versions.mock.ts +1 -1
  61. package/src/stories/__screenshots__/http-request.test.ts/http-request-url-change-1.png +0 -0
  62. package/src/stories/__screenshots__/location-element.test.stories.ts/location-element-location-element-Demo-1.png +0 -0
  63. package/src/stories/frame.canvas.ts +17 -4
  64. package/src/stories/testStoryBook.ts +2 -5
  65. package/storybook-static/assets/{Color-F6OSRLHC-D1CN2nnQ.js → Color-F6OSRLHC-CGlEPECH.js} +1 -1
  66. package/storybook-static/assets/{Configure-BD0b2x9E.js → Configure-RleqRiQ0.js} +1 -1
  67. package/storybook-static/assets/{DocsRenderer-CFRXHY34-VjrP5Ir6.js → DocsRenderer-CFRXHY34-Bz2y61tp.js} +2 -2
  68. package/storybook-static/assets/{attributes.test.stories-CrDC-RXf.js → attributes.test.stories-Bs0zZtYO.js} +1 -1
  69. package/storybook-static/assets/{css.test.stories-ChWnZJwa.js → css.test.stories-CK4N9Fqq.js} +1 -1
  70. package/storybook-static/assets/custom-element-PxTx2W9y.js +97 -0
  71. package/storybook-static/assets/{dom-merge.test.stories-DkarPqD_.js → dom-merge.test.stories-DLFviA8F.js} +1 -1
  72. package/storybook-static/assets/{external-template.test.stories-DCboR8sG.js → external-template.test.stories-CqR1aaHv.js} +1 -1
  73. package/storybook-static/assets/{form.test.stories-BjeeUu0b.js → form.test.stories-Cinvg_DI.js} +1 -1
  74. package/storybook-static/assets/frame.canvas-BB4_DNn6.js +1 -0
  75. package/storybook-static/assets/handlers-CxSWbsdK.js +291 -0
  76. package/storybook-static/assets/{http-request.stories-Boz_yWek.js → http-request.stories-_1_UMvj-.js} +1 -1
  77. package/storybook-static/assets/{iframe-BN389ZL5.js → iframe-fXv0bS2C.js} +2 -2
  78. package/storybook-static/assets/{index-C4PGem3Z.js → index-Dm-gke4Y.js} +3 -3
  79. package/storybook-static/assets/{index-PzQAcTTK.js → index-DxjDM4Ny.js} +1 -1
  80. package/storybook-static/assets/{local-storage.test.stories-DLMK0p2s.js → local-storage.test.stories-M4WOSQC5.js} +1 -1
  81. package/storybook-static/assets/{location-element.test.stories-BroqoLMS.js → location-element.test.stories-Ce6Ma8hE.js} +1 -1
  82. package/storybook-static/assets/{module-url.test.stories-B-0dibET.js → module-url.test.stories-PwnZWqKL.js} +1 -1
  83. package/storybook-static/assets/{preview-idY559eZ.js → preview-Dq4-5PA5.js} +2 -2
  84. package/storybook-static/assets/{preview-DXd5xnQg.js → preview-kbHljohz.js} +1 -1
  85. package/storybook-static/assets/{set-url.test.stories-Dhq4YQyr.js → set-url.test.stories-BdNTYEwI.js} +1 -1
  86. package/storybook-static/assets/{slice-events.test.stories-BZJGIFku.js → slice-events.test.stories-BdvLtK0h.js} +1 -1
  87. package/storybook-static/assets/{slots.test.stories-DKivHwZH.js → slots.test.stories-CoTPvRog.js} +1 -1
  88. package/storybook-static/assets/{version-select.test.stories-Dntyd7qb.js → version-select.test.stories-hs-HsDVE.js} +1 -1
  89. package/storybook-static/assets/{xslt-conditionals.test.stories-Iq5iQNRj.js → xslt-conditionals.test.stories-C4oXVQWa.js} +1 -1
  90. package/storybook-static/assets/{xslt-for-each.test.stories-BMygBmj8.js → xslt-for-each.test.stories-Da4vCZe1.js} +1 -1
  91. package/storybook-static/assets/{xslt-if.test.stories-CVrFWdAX.js → xslt-if.test.stories-CMlnBGX2.js} +1 -1
  92. package/storybook-static/demo/a.html +41 -64
  93. package/storybook-static/demo/s.xslt +94 -350
  94. package/storybook-static/iframe.html +1 -1
  95. package/storybook-static/project.json +1 -1
  96. package/dist/custom-element-jpOyXHF6.cjs +0 -97
  97. package/storybook-static/assets/custom-element-wuk8gYiP.js +0 -97
  98. package/storybook-static/assets/frame.canvas-E5n9h6j1.js +0 -1
  99. package/storybook-static/assets/handlers-B8a2v6Dv.js +0 -291
@@ -1,8 +1,8 @@
1
- const K = "http://www.w3.org/1999/XSL/Transform", R = "http://www.w3.org/1999/xhtml", ye = "http://exslt.org/common", d = (e, s) => e?.getAttribute?.(s), se = (e) => e.nodeType === 3, ge = (e) => typeof e == "string", le = (e) => e && typeof e.nodeType == "number", L = (e, s) => (e.ownerDocument || e).createTextNode(s), ce = (e) => {
1
+ const K = "http://www.w3.org/1999/XSL/Transform", R = "http://www.w3.org/1999/xhtml", ye = "http://exslt.org/common", d = (e, s) => e?.getAttribute?.(s), se = (e) => e.nodeType === 3, ge = (e) => typeof e == "string", le = (e) => e && typeof e.nodeType == "number", D = (e, s) => (e.ownerDocument || e).createTextNode(s), ce = (e) => {
2
2
  for (; e.firstChild; ) e.firstChild.remove();
3
3
  return e;
4
4
  }, F = (e) => (e.getAttributeNames().map((s) => e.removeAttribute(s)), ce(e)), me = (e) => (e?.setAttribute("xmlns:xsl", K), e), ue = (e) => (e?.setAttribute("xmlns:xhtml", R), me(e)), de = (e) => /^[_a-zA-Z][-_:a-zA-Z0-9]*$/.test(e), ne = (e, s) => (Object.keys(s).map((t) => e[t] = s[t]), e), C = (e, s = "", t = document) => {
5
- const l = (n) => ((o) => (s && o.append(L(t.ownerDocument || t, s)), o))((t.ownerDocument || t).createElement(n));
5
+ const l = (n) => ((o) => (s && o.append(D(t.ownerDocument || t, s)), o))((t.ownerDocument || t).createElement(n));
6
6
  if (de(e))
7
7
  return l(e);
8
8
  const a = l("dce-object");
@@ -18,7 +18,7 @@ const K = "http://www.w3.org/1999/XSL/Transform", R = "http://www.w3.org/1999/xh
18
18
  function U(e) {
19
19
  return new DOMParser().parseFromString(e, "application/xml");
20
20
  }
21
- function q(e) {
21
+ function O(e) {
22
22
  return new XMLSerializer().serializeToString(e);
23
23
  }
24
24
  function B(e, s, t, l) {
@@ -33,7 +33,7 @@ function J(e, s) {
33
33
  e.getAttributeNames().forEach((t) => s.includes(t) || e.removeAttribute(t));
34
34
  }
35
35
  const ie = (e) => [...e].filter((s) => !(s.nodeType === 3 && s.data.trim() === ""));
36
- function I(e, s, t) {
36
+ function P(e, s, t) {
37
37
  const l = typeof e;
38
38
  if (l === "string")
39
39
  return C(s, e, t);
@@ -45,24 +45,24 @@ function I(e, s, t) {
45
45
  }
46
46
  if (e instanceof Array) {
47
47
  const n = C("array", "", t);
48
- return e.map((o) => n.append(I(o, s, t))), n;
48
+ return e.map((o) => n.append(P(o, s, t))), n;
49
49
  }
50
50
  if (e instanceof FormData) {
51
51
  const n = C("form-data", "", t);
52
52
  for (const o of e)
53
- n.append(I(o[1], o[0], t));
53
+ n.append(P(o[1], o[0], t));
54
54
  return n;
55
55
  }
56
56
  const a = C(s, "", t);
57
57
  for (let n in e)
58
- typeof e[n] == "function" || e[n] instanceof Window || le(e[n]) && !(n === "data" || n === "value") || (typeof e[n] != "object" && de(n) ? a.setAttribute(n, e[n]) : a.append(I(e[n], n, t)));
58
+ typeof e[n] == "function" || e[n] instanceof Window || le(e[n]) && !(n === "data" || n === "value") || (typeof e[n] != "object" && de(n) ? a.setAttribute(n, e[n]) : a.append(P(e[n], n, t)));
59
59
  return a;
60
60
  }
61
61
  function re(e) {
62
62
  if (z(e, "*", (s) => [...s.childNodes].filter((t) => t.nodeType === 3 && t.parentNode.localName !== "style" && t.data).forEach((t) => {
63
63
  const l = t.data, a = l.matchAll(/{([^}]*)}/g);
64
64
  if (a) {
65
- let n = 0, o = (x) => L(t, x), y = [];
65
+ let n = 0, o = (x) => D(t, x), y = [];
66
66
  if ([...a].forEach((x) => {
67
67
  x.index > n && y.push(o(x.input.substring(n, x.index)));
68
68
  const v = e.querySelector("value-of").cloneNode();
@@ -145,7 +145,7 @@ function ve(e, s = "xsl:stylesheet") {
145
145
  h.firstElementChild.localName === "template" && ([...h.firstElementChild.content.childNodes].forEach((b) => h.append(b)), h.firstElementChild.remove());
146
146
  }), z(i, "script", (h) => h.remove());
147
147
  const r = i.content ?? i.firstElementChild?.content ?? i.body ?? i;
148
- Le.forEach((h) => z(r, h, (b) => De(b, r)));
148
+ De.forEach((h) => z(r, h, (b) => Le(b, r)));
149
149
  const f = i.firstElementChild?.content || i.content, g = (h) => {
150
150
  const b = U("<xhtml/>"), T = b.importNode(h, !0);
151
151
  return b.replaceChild(T, b.documentElement), T.namespaceURI === R && !d(T, "xmlns") && T.setAttribute("xmlns", R), ue(T);
@@ -193,9 +193,9 @@ function ve(e, s = "xsl:stylesheet") {
193
193
  </xsl:stylesheet>`
194
194
  );
195
195
  o.importStylesheet(n);
196
- const v = o.transformToFragment(y, document), u = (i, r) => i.querySelector(r), w = u(x, 'template[mode="payload"]');
196
+ const v = o.transformToFragment(y, document.implementation.createHTMLDocument("")), u = (i, r) => i.querySelector(r), w = u(x, 'template[mode="payload"]');
197
197
  if (!v)
198
- return console.error("transformation error", { xml: y.outerHTML, xsl: q(n) });
198
+ return console.error("transformation error", { xml: y.outerHTML, xsl: O(n) });
199
199
  if (v.firstElementChild.localName !== "dce-root") {
200
200
  const i = v.ownerDocument.createElement("dce-root");
201
201
  [...v.childNodes].forEach((r) => i.append(r)), v.append(i);
@@ -204,8 +204,8 @@ function ve(e, s = "xsl:stylesheet") {
204
204
  const r = d(i, "test"), f = r.replace(
205
205
  /hasBoolAttribute\((.*?)\)/g,
206
206
  (g, h, b, T, M) => {
207
- const D = h.substring(1);
208
- return `(not($${D} = 'false') and ($${D} = '' or $${D} = '${D}' or $${D} = 'true' ))`;
207
+ const L = h.substring(1);
208
+ return `(not($${L} = 'false') and ($${L} = '' or $${L} = '${L}' or $${L} = 'true' ))`;
209
209
  }
210
210
  );
211
211
  r !== f && i.setAttribute("test", f);
@@ -218,12 +218,12 @@ function ve(e, s = "xsl:stylesheet") {
218
218
  if (g?.length > 1) {
219
219
  r.removeAttribute("select");
220
220
  const b = u(x, 'template[match="ignore"]>choose').cloneNode(!0);
221
- F(b.firstElementChild).append(L(b, "{" + g[0] + "}")), b.firstElementChild.setAttribute("test", g[0]);
221
+ F(b.firstElementChild).append(D(b, "{" + g[0] + "}")), b.firstElementChild.setAttribute("test", g[0]);
222
222
  for (let T = 1; T < g.length - 1; T++) {
223
223
  const M = b.firstElementChild.cloneNode(!0);
224
- F(M).append(L(b, "{" + g[T] + "}")), M.setAttribute("test", g[T]), b.insertBefore(M, b.lastElementChild);
224
+ F(M).append(D(b, "{" + g[T] + "}")), M.setAttribute("test", g[T]), b.insertBefore(M, b.lastElementChild);
225
225
  }
226
- F(b.lastElementChild).append(L(b, "{" + g[g.length - 1] + "}")), r.append(b), h = b.cloneNode(!0);
226
+ F(b.lastElementChild).append(D(b, "{" + g[g.length - 1] + "}")), r.append(b), h = b.cloneNode(!0);
227
227
  } else
228
228
  h = ae(i, "xsl:value-of");
229
229
  h.removeAttribute("name"), i.append(h), i.removeAttribute("select");
@@ -236,8 +236,8 @@ function ve(e, s = "xsl:stylesheet") {
236
236
  for (const i of v.childNodes)
237
237
  w.append(x.importNode(i, !0));
238
238
  [...w.getElementsByTagName("xsl:template")].forEach((i) => w.ownerDocument.documentElement.append(i));
239
- const O = u(x, 'call-template[name="slot"]'), H = (i) => {
240
- const r = O.cloneNode(!0), f = d(i, "name");
239
+ const X = u(x, 'call-template[name="slot"]'), H = (i) => {
240
+ const r = X.cloneNode(!0), f = d(i, "name");
241
241
  f && r.firstElementChild.setAttribute("select", `'${f}'`);
242
242
  for (let g of i.childNodes)
243
243
  r.lastElementChild.append(g);
@@ -250,8 +250,12 @@ function ve(e, s = "xsl:stylesheet") {
250
250
  async function Ee(e) {
251
251
  return await new Promise((t, l) => {
252
252
  const a = new XMLHttpRequest();
253
- a.open("GET", e), a.responseType = "document", a.onload = () => {
254
- a.readyState === a.DONE && a.status === 200 ? t(a.responseXML?.body || a.responseXML || C("div", a.responseText)) : l(`${a.statusText} - ${e}`);
253
+ a.open("GET", e), a.onload = () => {
254
+ if (a.readyState === a.DONE && a.status === 200) {
255
+ const n = a.getResponseHeader("content-type")?.includes("xml") ? "text/xml" : "text/html", o = new DOMParser().parseFromString(a.responseText, n);
256
+ t(n === "text/html" ? o.body : o);
257
+ } else
258
+ l(`${a.statusText} - ${e}`);
255
259
  }, a.addEventListener("error", (n) => l(n)), a.send();
256
260
  });
257
261
  }
@@ -279,20 +283,20 @@ function oe(e, s, t, l) {
279
283
  if (!t.sliceProcessed)
280
284
  return t.sliceProcessed = 1, we(e, s ?? "").map((a) => {
281
285
  const n = e.ownerDocument, o = t.sliceEventSource, y = t.sliceElement, x = () => [...a.childNodes].filter((u) => u.nodeType === 3 || u.localName === "value" || u.localName === "form-data").map((u) => u.remove());
282
- o.getAttributeNames().map((u) => a.setAttribute(u, d(o, u))), [...a.childNodes].filter((u) => u.localName === "event").map((u) => u.remove()), "validationMessage" in o && a.setAttribute("validation-message", o.validationMessage), t.type === "init" && x(), a.append(I(t, "event", n));
286
+ o.getAttributeNames().map((u) => a.setAttribute(u, d(o, u))), [...a.childNodes].filter((u) => u.localName === "event").map((u) => u.remove()), "validationMessage" in o && a.setAttribute("validation-message", o.validationMessage), t.type === "init" && x(), a.append(P(t, "event", n));
283
287
  const v = (o.type === "checkbox" || o.type === "radio") && !o.checked;
284
288
  if (y.hasAttribute("slice-value")) {
285
289
  o.value === void 0 ? a.removeAttribute("value") : a.setAttribute("value", o.value);
286
- const u = v ? "" : P(d(y, "slice-value"), a);
287
- x(), a.append(L(n, u));
290
+ const u = v ? "" : I(d(y, "slice-value"), a);
291
+ x(), a.append(D(n, u));
288
292
  } else {
289
293
  if ("elements" in o)
290
- return x(), a.append(I(new FormData(o), "value", a.ownerDocument)), a;
294
+ return x(), a.append(P(new FormData(o), "value", a.ownerDocument)), a;
291
295
  const u = v ? "" : o.value ?? d(o, "value");
292
296
  if (x(), u == null)
293
297
  [...a.childNodes].filter((w) => w.localName !== "event").map((w) => w.remove()), a.removeAttribute("value");
294
298
  else {
295
- const w = ge(u) ? L(n, u) : I(u, "value", a.ownerDocument);
299
+ const w = ge(u) ? D(n, u) : P(u, "value", a.ownerDocument);
296
300
  a.append(w), a.setAttribute("value", u);
297
301
  }
298
302
  }
@@ -387,10 +391,10 @@ const $e = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `
387
391
  return e;
388
392
  const s = e.split("??"), t = s.shift(), l = Q(s.join("??"));
389
393
  return s.length ? `concat( ${t} , substring( ${l} , (1+string-length( ${l} )) * string-length( ${t} ) ) )` : e;
390
- }, P = (e, s) => {
394
+ }, I = (e, s) => {
391
395
  const t = e.split("??");
392
396
  if (t.length > 1)
393
- return P(t[0], s) || P(t[1], s);
397
+ return I(t[0], s) || I(t[1], s);
394
398
  e = Q(e);
395
399
  const l = s.ownerDocument.evaluate(e, s);
396
400
  switch (l.resultType) {
@@ -405,7 +409,7 @@ const $e = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `
405
409
  for (let n; n = l.iterateNext(); )
406
410
  a += n.textContent;
407
411
  return a;
408
- }, Le = "stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback".split(","), De = (e, s) => {
412
+ }, De = "stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback".split(","), Le = (e, s) => {
409
413
  const t = C("xsl:" + e.localName);
410
414
  for (let a of e.attributes)
411
415
  t.setAttribute(a.name, a.value);
@@ -443,14 +447,14 @@ class je extends HTMLElement {
443
447
  try {
444
448
  i.importStylesheet(p);
445
449
  } catch (r) {
446
- console.error(r, q(p));
450
+ console.error(r, O(p));
447
451
  }
448
452
  return i;
449
453
  });
450
- Object.defineProperty(this, "xsltString", { get: () => a.map((p) => q(p)).join(`
454
+ Object.defineProperty(this, "xsltString", { get: () => a.map((p) => O(p)).join(`
451
455
  `) });
452
456
  const o = this, y = [...this.templateNode.querySelectorAll("[slice]")], x = y.map((p) => d(p, "slice")).filter((p) => !p.includes("/")).filter((p, i, r) => r.indexOf(p) === i).map(pe).flat(), { declaredAttributes: v, hardcodedAttributes: u, exposedAttributes: w } = a[0], ee = /* @__PURE__ */ new Set([...Object.keys(u), ...Object.keys(w)]);
453
- class O extends HTMLElement {
457
+ class X extends HTMLElement {
454
458
  static get observedAttributes() {
455
459
  return v;
456
460
  }
@@ -471,23 +475,23 @@ class je extends HTMLElement {
471
475
  } else
472
476
  E.nodeType === 1 ? c.insertAdjacentElement("beforebegin", E) : E.nodeType === 3 && c.insertAdjacentText("beforebegin", E.data);
473
477
  }
474
- const r = U("<datadom/>").documentElement, f = (c, E = "") => ((m) => (E && m.append(L(r, E)), m))(r.ownerDocument.createElement(c)), g = B(r, "payload", i, Ae);
478
+ const r = U("<datadom/>").documentElement, f = (c, E = "") => ((m) => (E && m.append(D(r, E)), m))(r.ownerDocument.createElement(c)), g = B(r, "payload", i, Ae);
475
479
  me(g), ue(g), this.innerHTML = "";
476
480
  const h = B(r, "attributes", this.attributes, (c) => f(c.nodeName, c.value)), b = (c) => this.hasAttribute(c) || [...h.children].find((E) => E.localName === c);
477
481
  fe(this, h), Object.keys(u).map((c) => b(c) || h.append(f(c, u[c]))), Object.keys(w).map((c) => b(c) || h.append(f(c))), B(r, "dataset", Object.keys(this.dataset), (c) => f(c, this.dataset[c]));
478
- const T = B(r, "slice", x, (c) => f(c, "")), M = (c) => P(c, T);
482
+ const T = B(r, "slice", x, (c) => f(c, "")), M = (c) => I(c, T);
479
483
  this.xml = r;
480
- const D = [], te = () => {
484
+ const L = [], te = () => {
481
485
  const c = {};
482
- for (let E; E = D.pop(); ) {
486
+ for (let E; E = L.pop(); ) {
483
487
  const m = d(E.sliceElement, "slice");
484
488
  c[m] || (oe(T, m, E), c[m] = E);
485
489
  }
486
- Object.keys(c).length !== 0 && V();
490
+ Object.keys(c).length !== 0 && V(), this.customElementRegistry?.initialize(this);
487
491
  };
488
492
  let W;
489
493
  this.onSlice = (c) => {
490
- D.push(c), W || (W = setTimeout(() => {
494
+ L.push(c), W || (W = setTimeout(() => {
491
495
  te(), W = 0;
492
496
  }, 1));
493
497
  };
@@ -499,9 +503,9 @@ class je extends HTMLElement {
499
503
  n.map((A, S) => {
500
504
  const _ = A.transformToFragment(r.ownerDocument, document);
501
505
  return _ || console.error(`XSLT transformation error. xsl:
502
- `, q(a[S]), `
506
+ `, O(a[S]), `
503
507
  xml:
504
- `, q(r)), _;
508
+ `, O(r)), _;
505
509
  }).map((A) => {
506
510
  A && (he(A), xe(this, A.childNodes));
507
511
  });
@@ -541,13 +545,13 @@ xml:
541
545
  return;
542
546
  const Z = d(k, "custom-validity");
543
547
  try {
544
- const X = Z && P(Z, h);
545
- k.setCustomValidity(X === !0 ? "" : X === !1 ? "invalid" : X);
546
- } catch (X) {
547
- console.error(X, "xPath", Z);
548
+ const q = Z && I(Z, h);
549
+ k.setCustomValidity(q === !0 ? "" : q === !1 ? "invalid" : q);
550
+ } catch (q) {
551
+ console.error(q, "xPath", Z);
548
552
  }
549
553
  });
550
- const Y = d(S, "custom-validity"), j = Y && P(Y, h), G = j === !0 ? "" : j;
554
+ const Y = d(S, "custom-validity"), j = Y && I(Y, h), G = j === !0 ? "" : j;
551
555
  if (Y) {
552
556
  if (m.setCustomValidity ? m.setCustomValidity(G) : m.validationMessage = G, be.map((k) => k.setAttribute("validation-message", G)), $.type === "submit")
553
557
  return j === !0 ? void 0 : (setTimeout(V, 1), !!j === j ? (j || $.preventDefault(), j) : j ? ($.preventDefault(), !1) : void 0);
@@ -563,7 +567,7 @@ xml:
563
567
  i === "value" && (this.value = r);
564
568
  const f = this.xml.querySelector("attributes");
565
569
  let g = this.xml.querySelector(`attributes>${i}`);
566
- g ? F(g).append(L(g, r)) : (g = C(i, r, this.xml), f.append(g)), this.#e || f.setAttribute(i, r), this.dispatchEvent(new CustomEvent("change", { bubbles: !0, detail: { [i]: r } }));
570
+ g ? F(g).append(D(g, r)) : (g = C(i, r, this.xml), f.append(g)), this.#e || f.setAttribute(i, r), this.dispatchEvent(new CustomEvent("change", { bubbles: !0, detail: { [i]: r } }));
567
571
  }
568
572
  attributeChangedCallback(i, r, f) {
569
573
  !this.xml || this.#e || (this.#t(i, f), this.transform());
@@ -573,7 +577,7 @@ xml:
573
577
  }
574
578
  }
575
579
  const H = (p) => {
576
- window.customElements.get(p) !== O && window.customElements.define(p, O);
580
+ window.customElements.get(p) !== X && window.customElements.define(p, X);
577
581
  };
578
582
  if (t)
579
583
  H(t);
@@ -597,26 +601,26 @@ xml:
597
601
  window.customElements.define("custom-element", je);
598
602
  export {
599
603
  je as C,
600
- q as a,
601
- ve as b,
602
- ae as c,
603
- Ee as d,
604
- Ne as e,
605
- we as f,
606
- oe as g,
607
- fe as h,
608
- he as i,
609
- Se as j,
610
- xe as k,
611
- Ce as l,
612
- ne as m,
613
- $e as n,
614
- I as o,
615
- Q as p,
616
- P as q,
617
- Le as r,
604
+ Se as a,
605
+ we as b,
606
+ Ce as c,
607
+ he as d,
608
+ ae as e,
609
+ ve as f,
610
+ Ne as g,
611
+ $e as h,
612
+ oe as i,
613
+ fe as j,
614
+ ne as k,
615
+ Le as l,
616
+ xe as m,
617
+ Q as n,
618
+ P as o,
619
+ Ee as p,
620
+ U as q,
621
+ O as r,
618
622
  ie as s,
619
623
  re as t,
620
624
  De as u,
621
- U as x
625
+ I as x
622
626
  };
@@ -0,0 +1,97 @@
1
+ "use strict";const Q="http://www.w3.org/1999/XSL/Transform",I="http://www.w3.org/1999/xhtml",$e="http://exslt.org/common",d=(e,s)=>e?.getAttribute?.(s),me=e=>e.nodeType===3,De=e=>typeof e=="string",ue=e=>e&&typeof e.nodeType=="number",D=(e,s)=>(e.ownerDocument||e).createTextNode(s),de=e=>{for(;e.firstChild;)e.firstChild.remove();return e},F=e=>(e.getAttributeNames().map(s=>e.removeAttribute(s)),de(e)),pe=e=>(e?.setAttribute("xmlns:xsl",Q),e),he=e=>(e?.setAttribute("xmlns:xhtml",I),pe(e)),fe=e=>/^[_a-zA-Z][-_:a-zA-Z0-9]*$/.test(e),ee=(e,s)=>(Object.keys(s).map(t=>e[t]=s[t]),e),C=(e,s="",t=document)=>{const l=n=>(o=>(s&&o.append(D(t.ownerDocument||t,s)),o))((t.ownerDocument||t).createElement(n));if(fe(e))return l(e);const a=l("dce-object");return a.setAttribute("dce-object-name",e),a},te=(e,s)=>{const t=e.ownerDocument.createElementNS(e.namespaceURI,s);for(let l of e.attributes)t.setAttribute(l.name,l.value);for(let l of e.childNodes)t.append(l.cloneNode(!0));return t};function k(e){return new DOMParser().parseFromString(e,"application/xml")}function U(e){return new XMLSerializer().serializeToString(e)}function _(e,s,t,l){const a=y=>e.ownerDocument.createElement(y),o=((y,x,v)=>(x.append(v=a(y)),v))(s,e);return[...t].forEach(y=>o.append(l(y))),o}function Le(e){return e.slot||(e.setAttribute||(e=C("span",e.textContent.replaceAll(`
2
+ `,""))),e.setAttribute("slot","")),e}function K(e,s){e.getAttributeNames().forEach(t=>s.includes(t)||e.removeAttribute(t))}const se=e=>[...e].filter(s=>!(s.nodeType===3&&s.data.trim()===""));function M(e,s,t){const l=typeof e;if(l==="string")return C(s,e,t);if(l==="number")return C(s,""+e,t);if(ue(e)){const n=C(s);return n.append(e),n}if(e instanceof Array){const n=C("array","",t);return e.map(o=>n.append(M(o,s,t))),n}if(e instanceof FormData){const n=C("form-data","",t);for(const o of e)n.append(M(o[1],o[0],t));return n}const a=C(s,"",t);for(let n in e)typeof e[n]=="function"||e[n]instanceof Window||ue(e[n])&&!(n==="data"||n==="value")||(typeof e[n]!="object"&&fe(n)?a.setAttribute(n,e[n]):a.append(M(e[n],n,t)));return a}function le(e){if(z(e,"*",s=>[...s.childNodes].filter(t=>t.nodeType===3&&t.parentNode.localName!=="style"&&t.data).forEach(t=>{const l=t.data,a=l.matchAll(/{([^}]*)}/g);if(a){let n=0,o=x=>D(t,x),y=[];if([...a].forEach(x=>{x.index>n&&y.push(o(x.input.substring(n,x.index)));const v=e.querySelector("value-of").cloneNode();v.setAttribute("select",x[1]),y.push(v),n=x.index+x[0].length}),n<l.length&&y.push(o(l.substring(n,l.length))),y.length){for(let x of y)s.insertBefore(x,t);s.removeChild(t)}}})),"all"in e){let s=1;for(let t of e.all)t.setAttribute&&!t.tagName.startsWith("xsl:")&&t.setAttribute("data-dce-id",""+s++)}return e}function xe(e,s="xsl:stylesheet"){const t=[],l={},a={};if(e.tagName===s||e.documentElement?.tagName===s)return le(ee(e,{declaredAttributes:t,hardcodedAttributes:l,exposedAttributes:a}));const n=k(`<xsl:stylesheet version="1.0" xmlns:xsl="${Q}" xmlns:xhtml="${I}" xmlns:exsl="${$e}" exclude-result-prefixes="exsl" >
3
+ <xsl:output method="xml"/>
4
+ <xsl:template match="/"><dce-root xmlns="${I}"><xsl:apply-templates select="*" /></dce-root></xsl:template>
5
+ <xsl:template match="*[name()='template']">
6
+ <xsl:apply-templates mode="sanitize" select="*|text()"/>
7
+ </xsl:template>
8
+ <xsl:template match="*">
9
+ <xsl:apply-templates mode="sanitize" select="*|text()"/>
10
+ </xsl:template>
11
+ <xsl:template match="*[name()='svg']|*[name()='math']">
12
+ <xsl:apply-templates mode="sanitize" select="."/>
13
+ </xsl:template>
14
+ <xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]">
15
+ <xsl:copy>
16
+ <xsl:apply-templates mode="sanitize" select="@*"/>
17
+ <xsl:value-of select="text()"></xsl:value-of>
18
+ </xsl:copy>
19
+ </xsl:template>
20
+ <xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]">
21
+ <xsl:element name="{local-name()}">
22
+ <xsl:apply-templates mode="sanitize" select="@*"/>
23
+ <xsl:value-of select="text()"></xsl:value-of>
24
+ </xsl:element>
25
+ </xsl:template>
26
+ <xsl:template mode="sanitize" match="*|@*">
27
+ <xsl:copy>
28
+ <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
29
+ </xsl:copy>
30
+ </xsl:template>
31
+ <xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
32
+ <xsl:template mode="sanitize" match="text()">
33
+ <dce-text>
34
+ <xsl:copy/>
35
+ </dce-text>
36
+ </xsl:template>
37
+ <xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']">
38
+ <xsl:copy>
39
+ <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
40
+ </xsl:copy>
41
+ </xsl:template>
42
+ <xsl:template mode="sanitize" match="xhtml:*">
43
+ <xsl:element name="{local-name()}">
44
+ <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
45
+ </xsl:element>
46
+ </xsl:template>
47
+ <xsl:template mode="sanitize" match="xhtml:input">
48
+ <xsl:element name="{local-name()}">
49
+ <xsl:apply-templates mode="sanitize" select="*[not(name()='slice')]|@*|text()"/>
50
+ </xsl:element>
51
+ <xsl:for-each select="slice">
52
+ <xsl:copy>
53
+ <xsl:attribute name="for" >^</xsl:attribute>
54
+ <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
55
+ </xsl:copy>
56
+ </xsl:for-each>
57
+ </xsl:template>
58
+ </xsl:stylesheet>`),o=new XSLTProcessor,y=(i=>{z(i,"custom-element",f=>{f.firstElementChild.localName==="template"&&([...f.firstElementChild.content.childNodes].forEach(b=>f.append(b)),f.firstElementChild.remove())}),z(i,"script",f=>f.remove());const r=i.content??i.firstElementChild?.content??i.body??i;we.forEach(f=>z(r,f,b=>Te(b,r)));const h=i.firstElementChild?.content||i.content,g=f=>{const b=k("<xhtml/>"),T=b.importNode(f,!0);return b.replaceChild(T,b.documentElement),T.namespaceURI===I&&!d(T,"xmlns")&&T.setAttribute("xmlns",I),he(T)};if(h){const f=C("div");return[...h.childNodes].map(b=>f.append(b.cloneNode(!0))),g(f)}return g(i.documentElement||i.body||i)})(e),x=k(`<xsl:stylesheet version="1.0"
59
+ xmlns:xsl="${Q}"
60
+ xmlns:xhtml="${I}"
61
+ xmlns:dce="urn:schemas-epa-wg:dce"
62
+ xmlns:exsl="http://exslt.org/common"
63
+ exclude-result-prefixes="exsl"
64
+ >
65
+ <xsl:template match="ignore">
66
+ <xsl:choose>
67
+ <xsl:when test="//attr">{//attr}</xsl:when>
68
+ <xsl:otherwise>{def}</xsl:otherwise>
69
+ </xsl:choose><xsl:value-of select="."></xsl:value-of></xsl:template>
70
+ <xsl:template mode="payload" match="attributes"></xsl:template>
71
+ <xsl:template match="/">
72
+ <xsl:apply-templates mode="payload" select="/datadom/attributes"/>
73
+ </xsl:template>
74
+ <xsl:template name="slot" >
75
+ <xsl:param name="slotname" />
76
+ <xsl:param name="defaultvalue" />
77
+ <xsl:choose>
78
+ <xsl:when test="//payload/*[@slot=$slotname]">
79
+ <xsl:copy-of select="//payload/*[@slot=$slotname]"/>
80
+ </xsl:when>
81
+ <xsl:otherwise>
82
+ <xsl:copy-of select="$defaultvalue"/>
83
+ </xsl:otherwise>
84
+ </xsl:choose>
85
+ </xsl:template>
86
+ <xsl:variable name="js-injected-body">
87
+ <xsl:call-template name="slot" >
88
+ <xsl:with-param name="slotname" select="''"/>
89
+ <xsl:with-param name="defaultvalue"/>
90
+ </xsl:call-template>
91
+ </xsl:variable>
92
+ </xsl:stylesheet>`);o.importStylesheet(n);const v=o.transformToFragment(y,document.implementation.createHTMLDocument("")),u=(i,r)=>i.querySelector(r),w=u(x,'template[mode="payload"]');if(!v)return console.error("transformation error",{xml:y.outerHTML,xsl:U(n)});if(v.firstElementChild.localName!=="dce-root"){const i=v.ownerDocument.createElement("dce-root");[...v.childNodes].forEach(r=>i.append(r)),v.append(i)}[...v.querySelectorAll("[test]")].forEach(i=>{const r=d(i,"test"),h=r.replace(/hasBoolAttribute\((.*?)\)/g,(g,f,b,T,R)=>{const L=f.substring(1);return`(not($${L} = 'false') and ($${L} = '' or $${L} = '${L}' or $${L} = 'true' ))`});r!==h&&i.setAttribute("test",h)}),[...v.querySelectorAll("dce-root>attribute")].forEach(i=>{K(i,"namespace,name,select");const r=te(i,"xsl:param"),h=d(i,"name");if(t.push(h),i.childNodes.length&&(l[h]=i.textContent),w.append(r),i.hasAttribute("select")){a[h]=d(i,"select"),K(r,"select,name");let g=d(i,"select").split("??"),f;if(g?.length>1){r.removeAttribute("select");const b=u(x,'template[match="ignore"]>choose').cloneNode(!0);F(b.firstElementChild).append(D(b,"{"+g[0]+"}")),b.firstElementChild.setAttribute("test",g[0]);for(let T=1;T<g.length-1;T++){const R=b.firstElementChild.cloneNode(!0);F(R).append(D(b,"{"+g[T]+"}")),R.setAttribute("test",g[T]),b.insertBefore(R,b.lastElementChild)}F(b.lastElementChild).append(D(b,"{"+g[g.length-1]+"}")),r.append(b),f=b.cloneNode(!0)}else f=te(i,"xsl:value-of");f.removeAttribute("name"),i.append(f),i.removeAttribute("select")}else K(r,"name"),r.setAttribute("select","/datadom/attributes/"+h),l[h]||i.remove()}),[...v.querySelectorAll("[value]")].filter(i=>i.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach(i=>{const r=d(i,"value");r&&i.setAttribute("value",Ne(r))});for(const i of v.childNodes)w.append(x.importNode(i,!0));[...w.getElementsByTagName("xsl:template")].forEach(i=>w.ownerDocument.documentElement.append(i));const O=u(x,'call-template[name="slot"]'),H=i=>{const r=O.cloneNode(!0),h=d(i,"name");h&&r.firstElementChild.setAttribute("select",`'${h}'`);for(let g of i.childNodes)r.lastElementChild.append(g);return r};z(w,"slot",i=>i.parentNode.replaceChild(H(i),i));const p=le(x);return ee(p,{declaredAttributes:t,hardcodedAttributes:l,exposedAttributes:a}),p}async function be(e){return await new Promise((t,l)=>{const a=new XMLHttpRequest;a.open("GET",e),a.onload=()=>{if(a.readyState===a.DONE&&a.status===200){const n=a.getResponseHeader("content-type")?.includes("xml")?"text/xml":"text/html",o=new DOMParser().parseFromString(a.responseText,n);t(n==="text/html"?o.body:o)}else l(`${a.statusText} - ${e}`)},a.addEventListener("error",n=>l(n)),a.send()})}function ye(e,s,t=!1){if(e===s)return!0;if(typeof e!="object"||e===null||typeof s!="object"||s===null||Object.keys(e).length!==Object.keys(s).length)return t;for(let l in e)if(!(l in s)||!ye(e[l],s[l]))return t;return!0}const ge=e=>e.split("|").map(s=>s.trim()).filter(s=>s),Ae=(e,s)=>ge(s).map(t=>{let l=e.ownerDocument,a=n=>(e.append(n),n);if(t.includes("/")){const n=[],o=l.evaluate(t,e);for(let y;y=o.iterateNext();)n.push(y);return n}return[...e.childNodes].find(n=>n.localName===t)||a(C(t,"",l))}).flat();function ne(e,s,t,l){if(!t.sliceProcessed)return t.sliceProcessed=1,Ae(e,s??"").map(a=>{const n=e.ownerDocument,o=t.sliceEventSource,y=t.sliceElement,x=()=>[...a.childNodes].filter(u=>u.nodeType===3||u.localName==="value"||u.localName==="form-data").map(u=>u.remove());o.getAttributeNames().map(u=>a.setAttribute(u,d(o,u))),[...a.childNodes].filter(u=>u.localName==="event").map(u=>u.remove()),"validationMessage"in o&&a.setAttribute("validation-message",o.validationMessage),t.type==="init"&&x(),a.append(M(t,"event",n));const v=(o.type==="checkbox"||o.type==="radio")&&!o.checked;if(y.hasAttribute("slice-value")){o.value===void 0?a.removeAttribute("value"):a.setAttribute("value",o.value);const u=v?"":P(d(y,"slice-value"),a);x(),a.append(D(n,u))}else{if("elements"in o)return x(),a.append(M(new FormData(o),"value",a.ownerDocument)),a;const u=v?"":o.value??d(o,"value");if(x(),u==null)[...a.childNodes].filter(w=>w.localName!=="event").map(w=>w.remove()),a.removeAttribute("value");else{const w=De(u)?D(n,u):M(u,"value",a.ownerDocument);a.append(w),a.setAttribute("value",u)}}return a})}function z(e,s,t){e.querySelectorAll&&[...e.querySelectorAll(s)].forEach(t)}const je=async(e,s)=>{if(!e||!e.trim())return[s];if(e.startsWith("#"))return(t=>{const l=t.querySelectorAll(e);return[...l.length?l:t.getRootNode().querySelectorAll(e)]})(s.parentElement);try{const[t,l]=e.split("#");if(e.charAt(0)===".")e=new URL(t,s.closest("[base]")?.getAttribute("base")||location).href;else try{e=(void 0)(t),l&&(e+="#"+l)}catch(n){console.error(n.message)}const a=await be(e);if(s.setAttributeNS("xml","base",e),l){const n=a.querySelectorAll("#"+l);return n.length?[...n]:(console.error("template not found",e+"#"+l),[s])}return[a]}catch{return[s]}};function ae(e,s){for(let n of e.attributes)try{const o=n.name;if(o.startsWith("xmlns"))continue;n.namespaceURI?(!s.hasAttributeNS(n.namespaceURI,o)||s.getAttributeNS(n.namespaceURI,o)!==n.value)&&s.setAttributeNS(n.namespaceURI,o,n.value):(!s.hasAttribute(o)||s.getAttribute(o)!==n.value)&&s.setAttribute(n.name,n.value),n.name==="value"&&(s.value=n.value)}catch(o){console.warn("attribute assignment error",o?.message||o)}const t=s.dceExportedAttributes,l=s.getAttribute("dce-exported-attributes"),a=l?new Set(l.split(" ")):null;for(let n of s.getAttributeNames())!e.hasAttribute(n)&&!t?.has(n)&&!a?.has(n)&&s.removeAttribute(n)}function ie(e,s=0){const t={};for(const l of e.childNodes){const a=d(l,"data-dce-id")||l.dceId||0;if(!t[a])a?t[a]=1:(t[a]=l.dceId=++s,l.setAttribute&&l.setAttribute("data-dce-id",l.dceId));else{const n=l.dceId=a+"-"+t[a]++;l.setAttribute&&l.setAttribute("data-dce-id",n)}l.childNodes.length&&ie(l)}}function ve(e,s,t){t=1*t;for(let l of e.childNodes)if((l.dceId??l.getAttribute("data-dce-id")*1)>t)return e.insertBefore(s,l);e.append(s)}function re(e,s){if(e.firstElementChild?.localName==="dce-root"&&s[0]?.localName!=="dce-root")return;if(!s.length)return e.firstElementChild?.localName!=="dce-root"&&de(e);const t={};for(let l of e.childNodes)t[l.dceId],me(l)?(l.data.trim(),t[l.dceId||0]=l):t[d(l,"data-dce-id")||0]=l;for(let l of[...s]){const a=d(l,"data-dce-id")||l.dceId,n=t[a];n?(me(l)?n.nodeValue!==l.nodeValue&&(n.nodeValue=l.nodeValue):(ae(l,n),(n.childNodes.length||l.childNodes.length)&&re(n,l.childNodes)),delete t[a]):ve(e,l,a)}for(let l of Object.values(t))l.localName!=="dce-root"&&l.remove()}function Ee(e,s){return e.hasAttribute(s)||e.setAttribute(s,crypto.randomUUID()),e.getAttribute(s)}const Ne=e=>[...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map(t=>`${t[1]}{${W(t[3])}}${t[4]}`).join(""),W=e=>{if(!e.trim())return e;const s=e.split("??"),t=s.shift(),l=W(s.join("??"));return s.length?`concat( ${t} , substring( ${l} , (1+string-length( ${l} )) * string-length( ${t} ) ) )`:e},P=(e,s)=>{const t=e.split("??");if(t.length>1)return P(t[0],s)||P(t[1],s);e=W(e);const l=s.ownerDocument.evaluate(e,s);switch(l.resultType){case XPathResult.NUMBER_TYPE:return l.numberValue;case XPathResult.STRING_TYPE:return l.stringValue;case XPathResult.BOOLEAN_TYPE:return l.booleanValue}let a="";for(let n;n=l.iterateNext();)a+=n.textContent;return a},we="stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback".split(","),Te=(e,s)=>{const t=C("xsl:"+e.localName);for(let a of e.attributes)t.setAttribute(a.name,a.value);for(;e.firstChild;)t.append(e.firstChild);const l="if,choose,for-each".includes(e.localName)?(()=>{const a=e.parentElement;if(!a||a.childNodes.length===1)return t;const n=C("span");return n.append(t),n})():t;if(e.parentElement)e.parentElement.replaceChild(l,e);else{const a=e.parentElement||s,n=[...a.childNodes];n.forEach((o,y)=>{o===e&&(n[y]=l)}),a.replaceChildren(...n)}};class Se extends HTMLElement{static observedAttributes=["src","tag","hidden"];async connectedCallback(){this.firstElementChild&&this.firstElementChild.localName!=="template"&&console.log(`custom-element used without template wrapping content
93
+ `,this.outerHTML);const s=await je(d(this,"src"),this),t=d(this,"tag"),l=t||"dce-"+crypto.randomUUID();for(const p of s)z(p.templateNode||p.content||p,"style",i=>{const r=i.closest("slot"),h=r?`slot[name="${r.name}"]`:"";i.innerHTML=`${l} ${h}{${i.innerHTML}}`,this.append(i)});const a=s.map(p=>xe(p)),n=a.map((p,i)=>{i=new XSLTProcessor;try{i.importStylesheet(p)}catch(r){console.error(r,U(p))}return i});Object.defineProperty(this,"xsltString",{get:()=>a.map(p=>U(p)).join(`
94
+ `)});const o=this,y=[...this.templateNode.querySelectorAll("[slice]")],x=y.map(p=>d(p,"slice")).filter(p=>!p.includes("/")).filter((p,i,r)=>r.indexOf(p)===i).map(ge).flat(),{declaredAttributes:v,hardcodedAttributes:u,exposedAttributes:w}=a[0],oe=new Set([...Object.keys(u),...Object.keys(w)]);class O extends HTMLElement{static get observedAttributes(){return v}#e=0;get dceExportedAttributes(){return oe}connectedCallback(){let i=se(this.childNodes);if(this.firstElementChild?.tagName==="TEMPLATE"){this.firstElementChild!==this.lastElementChild&&console.error("payload should have TEMPLATE as only child",this.outerHTML);const c=this.firstElementChild;c.remove(),i=se(c.content.childNodes);for(const E of i)if(E.localName==="style"){const m=Ee(this,"data-dce-style");E.innerHTML=`${l}[data-dce-style="${m}"]{${E.innerHTML}}`,c.insertAdjacentElement("beforebegin",E)}else E.nodeType===1?c.insertAdjacentElement("beforebegin",E):E.nodeType===3&&c.insertAdjacentText("beforebegin",E.data)}const r=k("<datadom/>").documentElement,h=(c,E="")=>(m=>(E&&m.append(D(r,E)),m))(r.ownerDocument.createElement(c)),g=_(r,"payload",i,Le);pe(g),he(g),this.innerHTML="";const f=_(r,"attributes",this.attributes,c=>h(c.nodeName,c.value)),b=c=>this.hasAttribute(c)||[...f.children].find(E=>E.localName===c);ae(this,f),Object.keys(u).map(c=>b(c)||f.append(h(c,u[c]))),Object.keys(w).map(c=>b(c)||f.append(h(c))),_(r,"dataset",Object.keys(this.dataset),c=>h(c,this.dataset[c]));const T=_(r,"slice",x,c=>h(c,"")),R=c=>P(c,T);this.xml=r;const L=[],ce=()=>{const c={};for(let E;E=L.pop();){const m=d(E.sliceElement,"slice");c[m]||(ne(T,m,E),c[m]=E)}Object.keys(c).length!==0&&B(),this.customElementRegistry?.initialize(this)};let Y;this.onSlice=c=>{L.push(c),Y||(Y=setTimeout(()=>{ce(),Y=0},1))};const B=this.transform=()=>{if(this.#e)debugger;this.#e=1;const c=()=>{n.map((A,S)=>{const V=A.transformToFragment(r.ownerDocument,document);return V||console.error(`XSLT transformation error. xsl:
95
+ `,U(a[S]),`
96
+ xml:
97
+ `,U(r)),V}).map(A=>{A&&(ie(A),re(this,A.childNodes))});let N=0;return Object.entries(u).map(([A,S])=>{!this.hasAttribute(A)&&S!==d(this,A)&&(this.setAttribute(A,S),this.#t(A,S),N++)}),Object.keys(w).map(A=>{let S=d(this.firstElementChild,A);S!==d(this,A)&&(this.setAttribute(A,S),this.#t(A,S),N++)}),N};c()&&c()&&console.warn("model update should not be the result of transform more than once");function E(m){let N=m;if(m.localName==="slice"){const A=d(m,"for");if(A||(N=m.parentElement),A==="^")do N=N.previousElementSibling;while(N.localName==="slice");else N=this.querySelector(A);if(!N)return console.warn(`can not find selector in "slice for=${A}" `,m.outerHTML);d(m,"slice")||m.setAttribute("slice",d(m,"name"))}return N}z(this,"[slice],[slice-event]",m=>{let N=d(m,"slice-event");const A=m.hasAttribute("slice-value")||m.hasAttribute("value")||m.value,S=E(m);m.dceInitialized||(m.dceInitialized=1,S.hasAttribute("custom-validity")&&(N+=" change submit"),[...new Set((N||"change").split(" "))].forEach(V=>S.addEventListener(V,$=>{$.sliceElement=m,$.sliceEventSource=$.currentTarget||$.target,$.sliceProcessed=0;const Ce=ne(T,d($.sliceElement,"slice"),$);z(this,"[custom-validity]",q=>{if(!q.setCustomValidity)return;const J=d(q,"custom-validity");try{const X=J&&P(J,f);q.setCustomValidity(X===!0?"":X===!1?"invalid":X)}catch(X){console.error(X,"xPath",J)}});const G=d(S,"custom-validity"),j=G&&P(G,f),Z=j===!0?"":j;if(G){if(m.setCustomValidity?m.setCustomValidity(Z):m.validationMessage=Z,Ce.map(q=>q.setAttribute("validation-message",Z)),$.type==="submit")return j===!0?void 0:(setTimeout(B,1),!!j===j?(j||$.preventDefault(),j):j?($.preventDefault(),!1):void 0);setTimeout(B,1)}this.onSlice($)})),(!N||N.includes("init"))&&(A?this.onSlice({type:"init",target:S,sliceElement:m,sliceEventSource:S}):m.value=R(d(m,"slice"))))}),this.#e=0};B(),ce()}#t(i,r){i==="value"&&(this.value=r);const h=this.xml.querySelector("attributes");let g=this.xml.querySelector(`attributes>${i}`);g?F(g).append(D(g,r)):(g=C(i,r,this.xml),h.append(g)),this.#e||h.setAttribute(i,r),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{[i]:r}}))}attributeChangedCallback(i,r,h){!this.xml||this.#e||(this.#t(i,h),this.transform())}get dce(){return o}}const H=p=>{window.customElements.get(p)!==O&&window.customElements.define(p,O)};if(t)H(t);else{const p=l;this.setAttribute("tag",p),H(p);const i=document.createElement(p);this.getAttributeNames().forEach(r=>i.setAttribute(r,this.getAttribute(r))),i.append(...[...this.childNodes].filter(r=>r.localName!=="style")),this.append(i)}}get templateNode(){return this.firstElementChild?.tagName==="TEMPLATE"?this.firstElementChild.content:this}get dce(){return this}get xslt(){return k(this.xsltString)}}window.customElements.define("custom-element",Se);exports.CustomElement=Se;exports.appendByDceId=ve;exports.assureSlices=Ae;exports.assureUID=Ee;exports.assureUnique=ie;exports.cloneAs=te;exports.createXsltFromDom=xe;exports.deepEqual=ye;exports.evalCurly=Ne;exports.event2slice=ne;exports.merge=re;exports.mergeAttr=ae;exports.mix=ee;exports.obj2node=M;exports.sanitizeBlankText=se;exports.tagUid=le;exports.toXsl=Te;exports.xPath=P;exports.xPathDefaults=W;exports.xhrTemplate=be;exports.xml2dom=k;exports.xmlString=U;exports.xslTags=we;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./custom-element-jpOyXHF6.cjs"),l=require("./http-request-DSaowcG1.cjs"),t=require("./local-storage-78EivJ_B.cjs"),a=require("./location-element-DRB7hCwA.cjs");exports.CustomElement=e.CustomElement;exports.appendByDceId=e.appendByDceId;exports.assureSlices=e.assureSlices;exports.assureUID=e.assureUID;exports.assureUnique=e.assureUnique;exports.cloneAs=e.cloneAs;exports.createXsltFromDom=e.createXsltFromDom;exports.deepEqual=e.deepEqual;exports.default=e.CustomElement;exports.evalCurly=e.evalCurly;exports.event2slice=e.event2slice;exports.merge=e.merge;exports.mergeAttr=e.mergeAttr;exports.mix=e.mix;exports.obj2node=e.obj2node;exports.sanitizeBlankText=e.sanitizeBlankText;exports.tagUid=e.tagUid;exports.toXsl=e.toXsl;exports.xPath=e.xPath;exports.xPathDefaults=e.xPathDefaults;exports.xhrTemplate=e.xhrTemplate;exports.xml2dom=e.xml2dom;exports.xmlString=e.xmlString;exports.xslTags=e.xslTags;exports.HttpRequestElement=l.HttpRequestElement;exports.LocalStorageElement=t.LocalStorageElement;exports.localStorageSetItem=t.localStorageSetItem;exports.localStorage_clear=t.localStorage_clear;exports.localStorage_removeItem=t.localStorage_removeItem;exports.localStorage_setItem=t.localStorage_setItem;exports.LocationElement=a.LocationElement;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./custom-element-D5IF46oF.cjs"),l=require("./http-request-DSaowcG1.cjs"),t=require("./local-storage-78EivJ_B.cjs"),a=require("./location-element-DRB7hCwA.cjs");exports.CustomElement=e.CustomElement;exports.appendByDceId=e.appendByDceId;exports.assureSlices=e.assureSlices;exports.assureUID=e.assureUID;exports.assureUnique=e.assureUnique;exports.cloneAs=e.cloneAs;exports.createXsltFromDom=e.createXsltFromDom;exports.deepEqual=e.deepEqual;exports.default=e.CustomElement;exports.evalCurly=e.evalCurly;exports.event2slice=e.event2slice;exports.merge=e.merge;exports.mergeAttr=e.mergeAttr;exports.mix=e.mix;exports.obj2node=e.obj2node;exports.sanitizeBlankText=e.sanitizeBlankText;exports.tagUid=e.tagUid;exports.toXsl=e.toXsl;exports.xPath=e.xPath;exports.xPathDefaults=e.xPathDefaults;exports.xhrTemplate=e.xhrTemplate;exports.xml2dom=e.xml2dom;exports.xmlString=e.xmlString;exports.xslTags=e.xslTags;exports.HttpRequestElement=l.HttpRequestElement;exports.LocalStorageElement=t.LocalStorageElement;exports.localStorageSetItem=t.localStorageSetItem;exports.localStorage_clear=t.localStorage_clear;exports.localStorage_removeItem=t.localStorage_removeItem;exports.localStorage_setItem=t.localStorage_setItem;exports.LocationElement=a.LocationElement;
@@ -1,7 +1,7 @@
1
- import { C as e } from "./custom-element-BqBcmDiN.js";
2
- import { j as o, f as l, l as r, i as m, c, b as n, e as x, n as p, g, k as i, h as u, m as d, o as f, s as S, t as E, u as I, q as h, p as q, d as D, x as L, a as b, r as v } from "./custom-element-BqBcmDiN.js";
1
+ import { C as e } from "./custom-element-Cr_I3Xd-.js";
2
+ import { a as o, b as l, c as r, d as m, e as c, f as n, g as x, h as p, i as g, m as i, j as u, k as d, o as f, s as S, t as E, l as I, x as h, n as q, p as D, q as L, r as b, u as v } from "./custom-element-Cr_I3Xd-.js";
3
3
  import { H as T } from "./http-request-DTCzZ1gc.js";
4
- import { L as _, c as j, b as k, a as y, l as A } from "./local-storage-DzmNKzgN.js";
4
+ import { L as _, l as j, a as k, b as y, c as A } from "./local-storage-w0k66UWM.js";
5
5
  import { L as H } from "./location-element-FJlONi2n.js";
6
6
  export {
7
7
  e as CustomElement,
package/dist/demo/a.html CHANGED
@@ -1,80 +1,57 @@
1
1
  <!DOCTYPE html>
2
- <html lang="en">
2
+ <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:html="http://www.w3.org/1999/xhtml">
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
5
  <title>http-request Declarative Custom Element implementation demo</title>
6
- <link rel="icon" href="./wc-square.svg"/>
6
+ <link rel="icon" href="./wc-square.svg" />
7
7
 
8
8
  <script type="module" src="../http-request.js"></script>
9
9
  <script type="module" src="../custom-element.js"></script>
10
10
  <style>
11
11
  @import "./demo.css";
12
12
 
13
- button {
14
- display: inline-flex;
15
- flex-direction: column;
16
- align-items: center;
17
- flex: auto;
18
- box-shadow: inset silver 0 0 1rem;
19
- min-width: 12rem;
20
- padding: 1rem;
21
- color: coral;
22
- text-shadow: 1px 1px silver;
23
- font-weight: bolder;
24
- }
25
-
26
- button img {
27
- max-height: 10vw;
28
- min-height: 4rem;
29
- }
30
-
31
- table {
32
- min-width: 16rem;
33
- }
34
-
35
- td {
36
- border-bottom: 1px solid silver;
37
- }
38
-
39
- tfoot td {
40
- border-bottom: none;
41
- }
42
-
43
- td, th {
44
- text-align: right;
45
- }
46
-
47
- caption {
48
- padding: 1rem;
49
- font-weight: bolder;
50
- font-family: sans-serif;
51
- }
52
-
53
- code {
54
- text-align: right;
55
- min-width: 3rem;
56
- }
57
-
58
- svg {
59
- max-height: 3rem;
60
- }
13
+ button
14
+ { display: inline-flex; flex-direction: column; align-items: center; flex: auto;
15
+ box-shadow: inset silver 0px 0px 1rem; min-width: 12rem; padding: 1rem;
16
+ color: coral; text-shadow: 1px 1px silver; font-weight: bolder;
17
+ }
18
+ button img{ max-height: 10vw; min-height: 4rem;}
19
+ table{ min-width: 16rem; }
20
+ td{ border-bottom: 1px solid silver; }
21
+ tfoot td{ border-bottom: none; }
22
+ td,th{text-align: right; }
23
+ caption{ padding: 1rem; font-weight: bolder; font-family: sans-serif; }
24
+ dce-1{ padding: 0; display: flex; flex-wrap: wrap;}
25
+ code{ text-align: right; min-width: 3rem;}
61
26
  </style>
62
27
  </head>
63
28
  <body>
64
29
 
65
-
66
- <custom-element tag="dce-link2" >
67
- <template>
68
-
69
- <attribute name="p3" select="//attributes/p3 ?? 'def_P3' "></attribute>
70
-
71
- p3: <code data-testid="t3">{$p3}</code>
72
- </template>
73
- </custom-element>
74
- <section>
75
- <dce-link2 id="dce2" p1="123" p2="override ignored as select is defined"></dce-link2>
76
-
77
- </section>
78
-
30
+ <custom-element>
31
+ <template><!-- wrapping into template to prevent images loading within DCE declaration -->
32
+ <p>Pokemon buttons from API</p>
33
+ <http-request
34
+ url="https://pokeapi.co/api/v2/pokemon?limit=6&offset=0"
35
+ slice="page"
36
+ method="GET"
37
+ header-accept="application/json"
38
+ ></http-request>
39
+ <variable name="slides-url"
40
+ >https://unpkg.com/pokeapi-sprites@2.0.2/sprites/pokemon/other/dream-world</variable>
41
+ {count(//results)}
42
+ <div><for-each select="//results">
43
+ <variable name="pokeid"
44
+ select="substring-before( substring-after( @url, 'https://pokeapi.co/api/v2/pokemon/'),'/')"
45
+ ></variable>
46
+ <button>
47
+ <img src="{$slides-url}/{$pokeid}.svg"
48
+ alt="{@name}"/>
49
+ {@name}
50
+ </button>
51
+ </for-each>
52
+ </div>
53
+ </template>
54
+ </custom-element>
55
+ <button onclick="window.customElements.upgrade(document.body);console.log(9);">window.customElements.upgrade(document.body)</button>
79
56
  </body>
80
57
  </html>