@epa-wg/custom-element-dist 0.0.21 → 0.0.22

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 (171) hide show
  1. package/README.md +4 -4
  2. package/coverage/coverage-final.json +15 -11
  3. package/coverage/index.html +25 -25
  4. package/coverage/src/custom-element/coverage.svg +1 -1
  5. package/coverage/src/custom-element/custom-element.js/coverage.svg +1 -1
  6. package/coverage/src/custom-element/custom-element.js.html +604 -421
  7. package/coverage/src/custom-element/custom-element1-1.js/coverage.svg +10 -0
  8. package/coverage/src/custom-element/custom-element1-1.js.html +2374 -0
  9. package/coverage/src/custom-element/custom-element1.js/coverage.svg +10 -0
  10. package/coverage/src/custom-element/custom-element1.js.html +2374 -0
  11. package/coverage/src/custom-element/http-request.js.html +10 -10
  12. package/coverage/src/custom-element/index.html +49 -19
  13. package/coverage/src/custom-element/local-storage.js.html +6 -6
  14. package/coverage/src/custom-element/location-element.js.html +1 -1
  15. package/coverage/src/index.html +1 -1
  16. package/coverage/src/mocks/handlers.ts.html +1 -1
  17. package/coverage/src/mocks/index.html +1 -1
  18. package/coverage/src/stories/{attributes.stories.ts.html → attributes.test.stories.ts.html} +51 -15
  19. package/coverage/src/stories/{css.stories.ts.html → css.test.stories.ts.html} +77 -17
  20. package/coverage/src/stories/{dom-merge.stories.ts.html → dom-merge.test.stories.ts.html} +60 -12
  21. package/coverage/src/stories/{external-template.stories.ts.html → external-template.test.stories.ts.html} +42 -12
  22. package/coverage/src/stories/form.test.stories.ts.html +658 -0
  23. package/coverage/src/stories/http-request.stories.ts.html +7 -7
  24. package/coverage/src/stories/index.html +71 -41
  25. package/coverage/src/stories/{local-storage.stories.ts.html → local-storage.test.stories.ts.html} +56 -20
  26. package/coverage/src/stories/{location-element.stories.ts.html → location-element.test.stories.ts.html} +53 -17
  27. package/coverage/src/stories/renderPlay.ts.html +12 -15
  28. package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +10 -0
  29. package/coverage/src/stories/{slice-events.stories.ts.html → slice-events.test.stories.ts.html} +264 -15
  30. package/coverage/src/stories/slots.test.stories.ts/coverage.svg +10 -0
  31. package/coverage/src/stories/slots.test.stories.ts.html +739 -0
  32. package/coverage/src/sum.ts.html +1 -1
  33. package/dist/custom-element-BISbI4SU.js +463 -0
  34. package/dist/custom-element-N-sWiqGK.cjs +53 -0
  35. package/dist/custom-element-bundle.cjs +1 -1
  36. package/dist/custom-element-bundle.js +2 -2
  37. package/dist/mockServiceWorker.js +1 -1
  38. package/package.json +4 -4
  39. package/public/mockServiceWorker.js +1 -1
  40. package/src/custom-element/custom-element.d.ts +4 -0
  41. package/src/custom-element/custom-element.js +103 -42
  42. package/src/custom-element/custom-element1-1.js +763 -0
  43. package/src/custom-element/custom-element1.js +763 -0
  44. package/src/custom-element/custom-element1.js0 +750 -0
  45. package/src/custom-element/custom-element2.js0 +759 -0
  46. package/src/custom-element/custom-element3.js0 +763 -0
  47. package/src/custom-element/demo/a.html +38 -41
  48. package/src/custom-element/demo/b.html +13 -0
  49. package/src/custom-element/demo/data-slices.html +32 -0
  50. package/src/custom-element/demo/form.html +193 -0
  51. package/src/custom-element/demo/s.xml +19 -14
  52. package/src/custom-element/demo/s.xslt +22 -38
  53. package/src/custom-element/demo/s1.xslt +60 -0
  54. package/src/custom-element/ide/customData-dce.json +14 -1
  55. package/src/custom-element/ide/web-types-dce.json +6 -1
  56. package/src/custom-element/ide/web-types-xsl.json +1 -1
  57. package/src/custom-element/index.html +1 -0
  58. package/src/custom-element.test.ts +24 -8
  59. package/src/stories/{attributes.stories.ts → attributes.test.stories.ts} +19 -7
  60. package/src/stories/{css.stories.ts → css.test.stories.ts} +29 -9
  61. package/src/stories/{dom-merge.stories.ts → dom-merge.test.stories.ts} +19 -3
  62. package/src/stories/{external-template.stories.ts → external-template.test.stories.ts} +13 -3
  63. package/src/stories/form.test.stories.ts +191 -0
  64. package/src/stories/http-request.stories.ts +6 -6
  65. package/src/stories/http-request.test.ts +0 -9
  66. package/src/stories/{local-storage.stories.ts → local-storage.test.stories.ts} +24 -12
  67. package/src/stories/{location-element.stories.ts → location-element.test.stories.ts} +21 -9
  68. package/src/stories/renderPlay.ts +1 -2
  69. package/src/stories/{slice-events.stories.ts → slice-events.test.stories.ts} +88 -5
  70. package/src/stories/slots.test.stories.ts +218 -0
  71. package/storybook-static/assets/{Color-RQJUDNI5-C4yZhNbM.js → Color-PRSJMWNM-e4s261EJ.js} +1 -1
  72. package/storybook-static/assets/{Configure-C7d36rng.js → Configure-DWut7txe.js} +1 -1
  73. package/storybook-static/assets/DocsRenderer-K4EAMTCU-CaXVGjCl.js +2 -0
  74. package/storybook-static/assets/WithTooltip-KJL26V4Q--B8vdnMi.js +1 -0
  75. package/storybook-static/assets/{attributes.stories-ZB0RTY1d.js → attributes.test.stories-IuwazrdL.js} +21 -21
  76. package/storybook-static/assets/css.test.stories-D9WaxrEv.js +96 -0
  77. package/storybook-static/assets/custom-element-BV8-hRQS.js +219 -0
  78. package/storybook-static/assets/{dom-merge.stories-CgHZUABU.js → dom-merge.test.stories-BhbNeum_.js} +5 -6
  79. package/storybook-static/assets/{entry-preview-CQqNFx4W.js → entry-preview-DrgzXgwT.js} +1 -1
  80. package/storybook-static/assets/{entry-preview-docs-CWgqLfd3.js → entry-preview-docs-Bxv0qQWs.js} +1 -1
  81. package/storybook-static/assets/{external-template.stories-DtSLMxvg.js → external-template.test.stories-Bpr_wxBo.js} +23 -24
  82. package/storybook-static/assets/form.test.stories-3tURbEdv.js +250 -0
  83. package/storybook-static/assets/{formatter-B5HCVTEV-tKeEfJA9.js → formatter-2WMMO6ZP-SJtgH3vM.js} +5 -5
  84. package/storybook-static/assets/http-request.stories-8K_qSs8C.js +300 -0
  85. package/storybook-static/assets/iframe-CM82WlGY.js +2 -0
  86. package/storybook-static/assets/index-CEZitmnt.js +548 -0
  87. package/storybook-static/assets/index-CVRyq5ci.js +27 -0
  88. package/storybook-static/assets/{index-DnEJ_bKa.js → index-D1MP-Zis.js} +1 -1
  89. package/storybook-static/assets/index-DNL-IEpS.js +1 -0
  90. package/storybook-static/assets/index-DXimoRZY.js +1 -0
  91. package/storybook-static/assets/index-DuIEV_9C.js +13 -0
  92. package/storybook-static/assets/{lit-element-B4_0akdT.js → lit-element-CenEXOuS.js} +2 -2
  93. package/storybook-static/assets/{local-storage.stories-BkO6djDz.js → local-storage.test.stories-CtisAQBB.js} +28 -24
  94. package/storybook-static/assets/{location-element.stories-DCIOUd0D.js → location-element.test.stories-5O_t_m4Y.js} +11 -11
  95. package/storybook-static/assets/preview-4Up_z4Em.js +7 -0
  96. package/storybook-static/assets/{preview-CkgAD_DE.js → preview-5Y0XiZgz.js} +2 -2
  97. package/storybook-static/assets/preview-BKCN0mOr.js +1 -0
  98. package/storybook-static/assets/preview-DRnyIGXK.js +48 -0
  99. package/storybook-static/assets/preview-FpHGYA1q.js +1 -0
  100. package/storybook-static/assets/{preview-PxUn-cIn.js → preview-TCN6m6T-.js} +1 -1
  101. package/storybook-static/assets/slice-events.test.stories-BSXCLIA5.js +231 -0
  102. package/storybook-static/assets/slots.test.stories-B1vqfHmN.js +214 -0
  103. package/storybook-static/assets/syntaxhighlighter-BP7B2CQK-BWFH_0wQ.js +1 -0
  104. package/storybook-static/iframe.html +153 -10
  105. package/storybook-static/index.html +1 -1
  106. package/storybook-static/index.json +1 -1
  107. package/storybook-static/mockServiceWorker.js +1 -1
  108. package/storybook-static/project.json +1 -1
  109. package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js +35 -29
  110. package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js.LEGAL.txt +1 -1
  111. package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +1 -1
  112. package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +5 -5
  113. package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +35 -35
  114. package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +1 -1
  115. package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +1 -1
  116. package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +1 -1
  117. package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +1 -1
  118. package/storybook-static/sb-addons/interactions-10/manager-bundle.js +18 -16
  119. package/storybook-static/sb-addons/links-1/manager-bundle.js +1 -1
  120. package/storybook-static/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +1 -1
  121. package/storybook-static/sb-manager/WithTooltip-KJL26V4Q-5LS5AN27.js +1 -0
  122. package/storybook-static/sb-manager/{chunk-S4VOIVUE.js → chunk-B3YDJJJH.js} +9 -9
  123. package/storybook-static/sb-manager/{chunk-FEE35O7J.js → chunk-BLWCBWKL.js} +3 -3
  124. package/storybook-static/sb-manager/{chunk-XCO5HRLK.js → chunk-GUVK2GTO.js} +3 -3
  125. package/storybook-static/sb-manager/chunk-LFRML3ZV.js +186 -0
  126. package/storybook-static/sb-manager/chunk-MC7RAF2B.js +274 -0
  127. package/storybook-static/sb-manager/{chunk-XP3HGWTR.js → chunk-ZR5JZWHI.js} +1 -1
  128. package/storybook-static/sb-manager/{formatter-B5HCVTEV-7DCBOGO6.js → formatter-2WMMO6ZP-JI7RHVTW.js} +1 -1
  129. package/storybook-static/sb-manager/globals-module-info.js +1 -1
  130. package/storybook-static/sb-manager/globals-runtime.js +1 -1
  131. package/storybook-static/sb-manager/index.js +1 -1
  132. package/storybook-static/sb-manager/runtime.js +1 -1
  133. package/storybook-static/sb-manager/{syntaxhighlighter-JOJW2KGS-VF6EEVPI.js → syntaxhighlighter-BP7B2CQK-WOJYHKQR.js} +1 -1
  134. package/storybook-static/sb-preview/runtime.js +28 -11
  135. package/vite.config.js +5 -5
  136. package/dist/custom-element-B4v-KaIh.cjs +0 -53
  137. package/dist/custom-element-_g0GTup2.js +0 -436
  138. package/src/stories/attributes.test.ts +0 -14
  139. package/src/stories/css.test.ts +0 -12
  140. package/src/stories/dom-merge.test.ts +0 -12
  141. package/src/stories/external-template.test.ts +0 -12
  142. package/src/stories/local-storage.test.ts +0 -12
  143. package/src/stories/location-element.test.ts +0 -14
  144. package/src/stories/slice-events.test.ts +0 -12
  145. package/storybook-static/assets/DocsRenderer-K4EAMTCU-BLMupvSb.js +0 -2
  146. package/storybook-static/assets/WithTooltip-Y7J54OF7-BAQSPSFk.js +0 -1
  147. package/storybook-static/assets/css.stories-CLSX-Xxd.js +0 -86
  148. package/storybook-static/assets/custom-element-BLZZ00dz.js +0 -53
  149. package/storybook-static/assets/http-request.stories-CUzlXO89.js +0 -300
  150. package/storybook-static/assets/iframe-gCvlWuoC.js +0 -2
  151. package/storybook-static/assets/index-CBQwM6ST.js +0 -508
  152. package/storybook-static/assets/index-CDavW7r9.js +0 -193
  153. package/storybook-static/assets/index-CQA5dlr6.js +0 -13
  154. package/storybook-static/assets/index-DgaNIR0t.js +0 -1
  155. package/storybook-static/assets/index-Dkj0J1ds.js +0 -1
  156. package/storybook-static/assets/preview-C6t8KBFr.js +0 -1
  157. package/storybook-static/assets/preview-CYD85dwb.js +0 -7
  158. package/storybook-static/assets/preview-D8LadFCz.js +0 -48
  159. package/storybook-static/assets/preview-DNpCpRPf.js +0 -1
  160. package/storybook-static/assets/slice-events.stories-DXKjXI37.js +0 -115
  161. package/storybook-static/assets/syntaxhighlighter-JOJW2KGS-C04pIVD3.js +0 -1
  162. package/storybook-static/sb-manager/WithTooltip-Y7J54OF7-CEHQ77YF.js +0 -1
  163. package/storybook-static/sb-manager/chunk-E3WK6ZOZ.js +0 -234
  164. package/storybook-static/sb-manager/chunk-E6ABNH5R.js +0 -183
  165. /package/coverage/src/stories/{attributes.stories.ts → attributes.test.stories.ts}/coverage.svg +0 -0
  166. /package/coverage/src/stories/{css.stories.ts → css.test.stories.ts}/coverage.svg +0 -0
  167. /package/coverage/src/stories/{dom-merge.stories.ts → dom-merge.test.stories.ts}/coverage.svg +0 -0
  168. /package/coverage/src/stories/{external-template.stories.ts → external-template.test.stories.ts}/coverage.svg +0 -0
  169. /package/coverage/src/stories/{local-storage.stories.ts → form.test.stories.ts}/coverage.svg +0 -0
  170. /package/coverage/src/stories/{location-element.stories.ts → local-storage.test.stories.ts}/coverage.svg +0 -0
  171. /package/coverage/src/stories/{slice-events.stories.ts → location-element.test.stories.ts}/coverage.svg +0 -0
@@ -79,7 +79,7 @@ export function sum(a: number, b: number) {
79
79
  <div class='footer quiet pad2 space-top1 center small'>
80
80
  Code coverage generated by
81
81
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
82
- at 2024-05-13T06:00:45.582Z
82
+ at 2024-06-25T03:55:40.964Z
83
83
  </div>
84
84
  <script src="../prettify.js"></script>
85
85
  <script>
@@ -0,0 +1,463 @@
1
+ const F = "http://www.w3.org/1999/XSL/Transform", q = "http://www.w3.org/1999/xhtml", se = "http://exslt.org/common", x = (e, l) => e.getAttribute?.(l), W = (e) => e.nodeType === 3, le = (e) => typeof e == "string", ne = (e) => e && typeof e.nodeType == "number", N = (e, l = "", t = document) => ((s) => (l && s.append(S(t.ownerDocument || t, l)), s))((t.ownerDocument || t).createElement(e)), S = (e, l) => (e.ownerDocument || e).createTextNode(l), K = (e) => {
2
+ for (; e.firstChild; ) e.firstChild.remove();
3
+ return e;
4
+ }, U = (e) => (e.getAttributeNames().map((l) => e.removeAttribute(l)), K(e)), ae = (e) => (e?.setAttribute("xmlns:xsl", F), e), ie = (e) => (e?.setAttribute("xmlns:xhtml", q), ae(e)), Y = (e, l) => {
5
+ const t = e.ownerDocument.createElementNS(e.namespaceURI, l);
6
+ for (let s of e.attributes)
7
+ t.setAttribute(s.name, s.value);
8
+ for (; e.firstChild; )
9
+ t.append(e.firstChild);
10
+ return t;
11
+ };
12
+ function M(e) {
13
+ return new DOMParser().parseFromString(e, "application/xml");
14
+ }
15
+ function H(e) {
16
+ return new XMLSerializer().serializeToString(e);
17
+ }
18
+ function X(e, l, t, s) {
19
+ const n = (h) => e.ownerDocument.createElement(h), c = ((h, p, m) => (p.append(m = n(h)), m))(l, e);
20
+ return [...t].forEach((h) => c.append(s(h))), c;
21
+ }
22
+ function re(e) {
23
+ return e.slot || (e.setAttribute || (e = N("span", e.textContent.replaceAll(`
24
+ `, ""))), e.setAttribute("slot", "")), e;
25
+ }
26
+ function L(e, l, t) {
27
+ const s = typeof e;
28
+ if (s === "string")
29
+ return N(l, e, t);
30
+ if (s === "number")
31
+ return N(l, "" + e, t);
32
+ if (e instanceof Array) {
33
+ const i = N("array", "", t);
34
+ return e.map((c) => i.append(L(c, l, t))), i;
35
+ }
36
+ if (e instanceof FormData) {
37
+ const i = N("form-data", "", t);
38
+ for (const c of e)
39
+ i.append(L(c[1], c[0], t));
40
+ return i;
41
+ }
42
+ const n = N(l, "", t);
43
+ for (let i in e)
44
+ ne(e[i]) || typeof e[i] == "function" || e[i] instanceof Window || (typeof e[i] != "object" ? n.setAttribute(i, e[i]) : n.append(L(e[i], i, t)));
45
+ return n;
46
+ }
47
+ function G(e) {
48
+ if (C(e, "*", (l) => [...l.childNodes].filter((t) => t.nodeType === 3 && t.parentNode.localName !== "style" && t.data).forEach((t) => {
49
+ const s = t.data, n = s.matchAll(/{([^}]*)}/g);
50
+ if (n) {
51
+ let i = 0, c = (p) => S(t, p), h = [];
52
+ if ([...n].forEach((p) => {
53
+ p.index > i && h.push(c(p.input.substring(i, p.index)));
54
+ const m = e.querySelector("value-of").cloneNode();
55
+ m.setAttribute("select", p[1]), h.push(m), i = p.index + p[0].length;
56
+ }), i < s.length && h.push(c(s.substring(i, s.length))), h.length) {
57
+ for (let p of h)
58
+ l.insertBefore(p, t);
59
+ l.removeChild(t);
60
+ }
61
+ }
62
+ })), "all" in e) {
63
+ let l = 1;
64
+ for (let t of e.all)
65
+ t.setAttribute && !t.tagName.startsWith("xsl:") && t.setAttribute("data-dce-id", "" + l++);
66
+ }
67
+ return e;
68
+ }
69
+ function oe(e, l = "xsl:stylesheet") {
70
+ if (e.tagName === l || e.documentElement?.tagName === l)
71
+ return G(e);
72
+ const t = M(`<xsl:stylesheet version="1.0" xmlns:xsl="${F}" xmlns:xhtml="${q}" xmlns:exsl="${se}" exclude-result-prefixes="exsl" >
73
+ <xsl:output method="xml" />
74
+ <xsl:template match="/"><dce-root xmlns="${q}"><xsl:apply-templates select="*"/></dce-root></xsl:template>
75
+ <xsl:template match="*[name()='template']"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
76
+ <xsl:template match="*"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
77
+ <xsl:template match="*[name()='svg']|*[name()='math']"><xsl:apply-templates mode="sanitize" select="."/></xsl:template>
78
+ <xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]"><xsl:copy><xsl:apply-templates mode="sanitize" select="@*"/><xsl:value-of select="text()"></xsl:value-of></xsl:copy></xsl:template>
79
+ <xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="@*"/><xsl:value-of select="text()"></xsl:value-of></xsl:element></xsl:template>
80
+ <xsl:template mode="sanitize" match="*|@*"><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></xsl:template>
81
+ <xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
82
+ <xsl:template mode="sanitize" match="text()"><dce-text><xsl:copy/></dce-text></xsl:template>
83
+ <xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']"><dce-text><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></dce-text></xsl:template>
84
+ <xsl:template mode="sanitize" match="xhtml:*"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:element></xsl:template>
85
+ </xsl:stylesheet>`), s = new XSLTProcessor(), n = ((a) => {
86
+ C(a, "script", (g) => g.remove());
87
+ const o = a.content ?? a.firstElementChild?.content ?? a.body ?? a;
88
+ xe.forEach((g) => C(o, g, (b) => ye(b, o)));
89
+ const E = a.firstElementChild?.content || a.content, v = (g) => {
90
+ const b = M("<xhtml/>"), $ = b.importNode(g, !0);
91
+ return b.replaceChild($, b.documentElement), ie($);
92
+ };
93
+ if (E) {
94
+ const g = N("div");
95
+ return [...E.childNodes].map((b) => g.append(b.cloneNode(!0))), v(g);
96
+ }
97
+ return v(a.documentElement || a.body || a);
98
+ })(e), i = M(
99
+ `<xsl:stylesheet version="1.0"
100
+ xmlns:xsl="${F}"
101
+ xmlns:xhtml="${q}"
102
+ xmlns:dce="urn:schemas-epa-wg:dce"
103
+ xmlns:exsl="http://exslt.org/common"
104
+ exclude-result-prefixes="exsl"
105
+ >
106
+ <xsl:template match="ignore">
107
+ <xsl:choose>
108
+ <xsl:when test="//attr">{//attr}</xsl:when>
109
+ <xsl:otherwise>{def}</xsl:otherwise>
110
+ </xsl:choose><xsl:value-of select="."></xsl:value-of></xsl:template>
111
+ <xsl:template mode="payload" match="attributes"></xsl:template>
112
+ <xsl:template match="/">
113
+ <xsl:apply-templates mode="payload" select="/datadom/attributes"/>
114
+ </xsl:template>
115
+ <xsl:template name="slot" >
116
+ <xsl:param name="slotname" />
117
+ <xsl:param name="defaultvalue" />
118
+ <xsl:choose>
119
+ <xsl:when test="//payload/*[@slot=$slotname]">
120
+ <xsl:copy-of select="//payload/*[@slot=$slotname]"/>
121
+ </xsl:when>
122
+ <xsl:otherwise>
123
+ <xsl:copy-of select="$defaultvalue"/>
124
+ </xsl:otherwise>
125
+ </xsl:choose>
126
+ </xsl:template>
127
+ <xsl:variable name="js-injected-body">
128
+ <xsl:call-template name="slot" >
129
+ <xsl:with-param name="slotname" select="''"/>
130
+ <xsl:with-param name="defaultvalue"/>
131
+ </xsl:call-template>
132
+ </xsl:variable>
133
+ </xsl:stylesheet>`
134
+ );
135
+ s.importStylesheet(t);
136
+ const c = s.transformToFragment(n, document), h = (a, o) => a.querySelector(o), p = h(i, 'template[mode="payload"]');
137
+ if (!c)
138
+ return console.error("transformation error", { xml: n.outerHTML, xsl: H(t) });
139
+ const m = [];
140
+ [...c.querySelectorAll("dce-root>attribute")].forEach((a) => {
141
+ const o = Y(a, "xsl:param"), E = x(a, "name");
142
+ p.append(o);
143
+ let v = x(o, "select")?.split("??");
144
+ v || (v = ["//" + E, `'${o.textContent}'`], U(o), o.setAttribute("name", E));
145
+ let g;
146
+ if (v?.length > 1) {
147
+ o.removeAttribute("select");
148
+ const b = h(i, 'template[match="ignore"]>choose').cloneNode(!0);
149
+ U(b.firstElementChild).append(S(b, "{" + v[0] + "}")), U(b.lastElementChild).append(S(b, "{" + v[1] + "}")), b.firstElementChild.setAttribute("test", v[0]), o.append(b), g = b.cloneNode(!0);
150
+ } else
151
+ g = Y(a, "xsl:value-of");
152
+ g.removeAttribute("name"), a.append(g), a.removeAttribute("select"), m.push(o);
153
+ }), [...c.querySelectorAll("[value]")].filter((a) => a.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach((a) => {
154
+ const o = x(a, "value");
155
+ o && a.setAttribute("value", he(o));
156
+ });
157
+ for (const a of c.childNodes)
158
+ p.append(i.importNode(a, !0));
159
+ [...p.querySelectorAll("template")].forEach((a) => p.ownerDocument.documentElement.append(a));
160
+ const P = h(i, 'call-template[name="slot"]'), d = (a) => {
161
+ const o = P.cloneNode(!0), E = x(a, "name");
162
+ E && o.firstElementChild.setAttribute("select", `'${E}'`);
163
+ for (let v of a.childNodes)
164
+ o.lastElementChild.append(v);
165
+ return o;
166
+ };
167
+ C(p, "slot", (a) => a.parentNode.replaceChild(d(a), a));
168
+ const u = G(i);
169
+ return u.params = m, u;
170
+ }
171
+ async function ce(e) {
172
+ return await new Promise((t, s) => {
173
+ const n = new XMLHttpRequest();
174
+ n.open("GET", e), n.responseType = "document", n.onload = () => {
175
+ n.readyState === n.DONE && n.status === 200 && t(n.responseXML || N("div", n.responseText)), s(n.statusText);
176
+ }, n.addEventListener("error", (i) => s(i)), n.send();
177
+ });
178
+ }
179
+ function me(e, l, t = !1) {
180
+ if (e === l)
181
+ return !0;
182
+ if (typeof e != "object" || e === null || typeof l != "object" || l === null || Object.keys(e).length !== Object.keys(l).length)
183
+ return t;
184
+ for (let s in e)
185
+ if (!(s in l) || !me(e[s], l[s]))
186
+ return t;
187
+ return !0;
188
+ }
189
+ const Q = (e) => e.split("|").map((l) => l.trim()).filter((l) => l), ue = (e, l) => Q(l).map((t) => {
190
+ let s = e.ownerDocument, n = (i) => (e.append(i), i);
191
+ if (t.includes("/")) {
192
+ const i = [], c = s.evaluate(t, e);
193
+ for (let h; h = c.iterateNext(); )
194
+ i.push(h);
195
+ return i;
196
+ }
197
+ return [...e.childNodes].find((i) => i.localName === t) || n(N(t, "", s));
198
+ }).flat();
199
+ function J(e, l, t, s) {
200
+ if (!t.sliceProcessed)
201
+ return t.sliceProcessed = 1, ue(e, l ?? "").map((n) => {
202
+ const i = e.ownerDocument, c = t.sliceEventSource, h = t.sliceElement, p = () => [...n.childNodes].filter((m) => m.nodeType === 3 || m.localName === "value" || m.localName === "form-data").map((m) => m.remove());
203
+ if (c.getAttributeNames().map((m) => n.setAttribute(m, x(c, m))), [...n.childNodes].filter((m) => m.localName === "event").map((m) => m.remove()), "validationMessage" in c && n.setAttribute("validation-message", c.validationMessage), t.type === "init" && p(), n.append(L(t, "event", i)), h.hasAttribute("slice-value")) {
204
+ c.value === void 0 ? n.removeAttribute("value") : n.setAttribute("value", c.value);
205
+ const m = D(x(h, "slice-value"), n);
206
+ p(), n.append(S(i, m));
207
+ } else {
208
+ if ("elements" in c)
209
+ return p(), n.append(L(new FormData(c), "value", n.ownerDocument)), n;
210
+ const m = c.value ?? x(h, "value");
211
+ p(), m == null ? [...n.childNodes].filter((w) => w.localName !== "event").map((w) => w.remove()) : le(m) ? n.append(S(i, m)) : n.append(L(m, "value", n.ownerDocument));
212
+ }
213
+ return n;
214
+ });
215
+ }
216
+ function C(e, l, t) {
217
+ e.querySelectorAll && [...e.querySelectorAll(l)].forEach(t);
218
+ }
219
+ const de = async (e, l) => {
220
+ if (!e || !e.trim())
221
+ return [l];
222
+ if (e.startsWith("#"))
223
+ return ((t) => {
224
+ if (!t) return [];
225
+ const s = t.querySelectorAll(e);
226
+ if (s.length)
227
+ return [...s];
228
+ const n = t.getRootNode();
229
+ return n === t ? [] : getByHashId(n);
230
+ })(l.parentElement);
231
+ try {
232
+ const t = await ce(e), s = new URL(e, location).hash;
233
+ if (s) {
234
+ const n = t.querySelectorAll(s);
235
+ return n.length ? [...n] : [l];
236
+ }
237
+ return [t];
238
+ } catch {
239
+ return [l];
240
+ }
241
+ };
242
+ function pe(e, l) {
243
+ for (let t of e.attributes)
244
+ t.namespaceURI ? l.setAttributeNS(t.namespaceURI, t.name, t.value) : l.setAttribute(t.name, t.value), t.name === "value" && (l.value = t.value);
245
+ }
246
+ function Z(e, l = 0) {
247
+ const t = {};
248
+ for (const s of e.childNodes) {
249
+ const n = x(s, "data-dce-id") || s.dceId || 0;
250
+ if (!t[n])
251
+ n ? t[n] = 1 : (t[n] = s.dceId = ++l, s.setAttribute && s.setAttribute("data-dce-id", s.dceId));
252
+ else {
253
+ const i = s.dceId = n + "-" + t[n]++;
254
+ s.setAttribute && s.setAttribute("data-dce-id", i);
255
+ }
256
+ s.childNodes.length && Z(s);
257
+ }
258
+ }
259
+ function ee(e, l) {
260
+ if (!l.length)
261
+ return K(e);
262
+ const t = {};
263
+ for (let s of e.childNodes)
264
+ t[s.dceId], W(s) ? (s.data.trim(), t[s.dceId || 0] = s) : t[x(s, "data-dce-id") || 0] = s;
265
+ for (let s of [...l]) {
266
+ const n = x(s, "data-dce-id") || s.dceId, i = t[n];
267
+ i ? (W(s) ? i.nodeValue !== s.nodeValue && (i.nodeValue = s.nodeValue) : (pe(s, i), (i.childNodes.length || s.childNodes.length) && ee(i, s.childNodes)), delete t[n]) : e.append(s);
268
+ }
269
+ for (let s of Object.values(t))
270
+ s.remove();
271
+ }
272
+ function fe(e, l) {
273
+ return e.hasAttribute(l) || e.setAttribute(l, crypto.randomUUID()), e.getAttribute(l);
274
+ }
275
+ const he = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `${t[1]}{${B(t[3])}}${t[4]}`).join(""), B = (e) => {
276
+ if (!e.trim())
277
+ return e;
278
+ const l = e.split("??"), t = l.shift(), s = B(l.join("??"));
279
+ return l.length ? `concat( ${t} , substring( ${s} , (1+string-length( ${s} )) * string-length( ${t} ) ) )` : e;
280
+ }, D = (e, l) => {
281
+ const t = e.split("??");
282
+ if (t.length > 1)
283
+ return D(t[0], l) || D(t[1], l);
284
+ e = B(e);
285
+ const s = l.ownerDocument.evaluate(e, l);
286
+ switch (s.resultType) {
287
+ case XPathResult.NUMBER_TYPE:
288
+ return s.numberValue;
289
+ case XPathResult.STRING_TYPE:
290
+ return s.stringValue;
291
+ case XPathResult.BOOLEAN_TYPE:
292
+ return s.booleanValue;
293
+ }
294
+ let n = "";
295
+ for (let i; i = s.iterateNext(); )
296
+ n += i.textContent;
297
+ return n;
298
+ }, xe = "stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,template,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(","), ye = (e, l) => {
299
+ const t = N("xsl:" + e.localName);
300
+ for (let s of e.attributes)
301
+ t.setAttribute(s.name, s.value);
302
+ for (; e.firstChild; )
303
+ t.append(e.firstChild);
304
+ if (e.parentElement)
305
+ e.parentElement.replaceChild(t, e);
306
+ else {
307
+ const s = e.parentElement || l, n = [...s.childNodes];
308
+ n.forEach((i, c) => {
309
+ i === e && (n[c] = t);
310
+ }), s.replaceChildren(...n);
311
+ }
312
+ };
313
+ class be extends HTMLElement {
314
+ static observedAttributes = ["src", "tag", "hidden"];
315
+ async connectedCallback() {
316
+ const l = await de(x(this, "src"), this), t = x(this, "tag"), s = t || "dce-" + crypto.randomUUID();
317
+ for (const d of l)
318
+ C(d.templateNode || d.content || d, "style", (u) => {
319
+ const a = u.closest("slot"), o = a ? `slot[name="${a.name}"]` : "";
320
+ u.innerHTML = `${s} ${o}{${u.innerHTML}}`, this.append(u);
321
+ });
322
+ const n = l.map((d) => oe(d)), i = n.map((d, u) => (u = new XSLTProcessor(), u.importStylesheet(d), u));
323
+ Object.defineProperty(this, "xsltString", { get: () => n.map((d) => H(d)).join(`
324
+ `) });
325
+ const c = this, h = [...this.templateNode.querySelectorAll("[slice]")], p = h.map((d) => x(d, "slice")).filter((d) => !d.includes("/")).filter((d, u, a) => a.indexOf(d) === u).map(Q).flat(), m = n.reduce((d, u) => (u.params && d.push(...u.params), d), []);
326
+ class w extends HTMLElement {
327
+ static get observedAttributes() {
328
+ return m.map((u) => x(u, "name"));
329
+ }
330
+ #e = 0;
331
+ connectedCallback() {
332
+ let u = this.childNodes;
333
+ if (this.firstElementChild?.tagName === "TEMPLATE") {
334
+ this.firstElementChild !== this.lastElementChild && console.error("payload should have TEMPLATE as only child", this.outerHTML);
335
+ const f = this.firstElementChild;
336
+ f.remove(), u = f.content.childNodes;
337
+ for (const r of [...f.content.childNodes])
338
+ if (r.localName === "style") {
339
+ const y = fe(this, "data-dce-style");
340
+ r.innerHTML = `${s}[data-dce-style="${y}"]{${r.innerHTML}}`, f.insertAdjacentElement("beforebegin", r);
341
+ } else
342
+ r.nodeType === 1 ? f.insertAdjacentElement("beforebegin", r) : r.nodeType === 3 && f.insertAdjacentText("beforebegin", r.data);
343
+ }
344
+ const a = M("<datadom/>").documentElement, o = (f, r = "") => ((y) => (r && y.append(S(a, r)), y))(a.ownerDocument.createElement(f));
345
+ X(a, "payload", u, re), this.innerHTML = "";
346
+ const E = X(a, "attributes", this.attributes, (f) => o(f.nodeName, f.value));
347
+ X(a, "dataset", Object.keys(this.dataset), (f) => o(f, this.dataset[f]));
348
+ const v = X(a, "slice", p, (f) => o(f, "")), g = (f) => D(f, v);
349
+ this.xml = a;
350
+ const b = [], $ = () => {
351
+ const f = {};
352
+ for (let r; r = b.pop(); ) {
353
+ const y = x(r.sliceElement, "slice");
354
+ f[y] || (J(v, y, r), f[y] = r);
355
+ }
356
+ Object.keys(f).length !== 0 && R();
357
+ };
358
+ let k;
359
+ this.onSlice = (f) => {
360
+ b.push(f), k || (k = setTimeout(() => {
361
+ $(), k = 0;
362
+ }, 1));
363
+ };
364
+ const R = this.transform = () => {
365
+ if (this.#e)
366
+ debugger;
367
+ this.#e = 1, i.map((r, y) => {
368
+ const I = r.transformToFragment(a.ownerDocument, document);
369
+ return I || console.error(`XSLT transformation error. xsl:
370
+ `, H(n[y]), `
371
+ xml:
372
+ `, H(a)), I;
373
+ }).map((r) => {
374
+ r && (Z(r), ee(this, r.childNodes));
375
+ }), w.observedAttributes.map((r) => {
376
+ let y = x(this.firstElementChild, r);
377
+ y !== x(this, r) && (this.setAttribute(r, y), this.#t(r, y));
378
+ }), C(this, "[slice],[slice-event]", (r) => {
379
+ if (!r.dceInitialized) {
380
+ r.dceInitialized = 1;
381
+ let y = x(r, "slice-event");
382
+ x(r, "custom-validity") && (y += " change submit"), [...new Set((y || "change").split(" "))].forEach((I) => (r.localName === "slice" ? r.parentElement : r).addEventListener(I, (A) => {
383
+ A.sliceElement = r, A.sliceEventSource = A.currentTarget || A.target;
384
+ const te = J(v, x(A.sliceElement, "slice"), A);
385
+ C(this, "[custom-validity]", (z) => {
386
+ if (!z.setCustomValidity)
387
+ return;
388
+ const _ = x(z, "custom-validity");
389
+ try {
390
+ const j = _ && D(_, E);
391
+ z.setCustomValidity(j === !0 ? "" : j === !1 ? "invalid" : j);
392
+ } catch (j) {
393
+ console.error(j, "xPath", _);
394
+ }
395
+ });
396
+ const V = x(r, "custom-validity"), T = V && D(V, E), O = T === !0 ? "" : T;
397
+ if (V) {
398
+ if (r.setCustomValidity ? r.setCustomValidity(O) : r.validationMessage = O, te.map((z) => z.setAttribute("validation-message", O)), A.type === "submit")
399
+ return T === !0 ? void 0 : (setTimeout(R, 1), !!T === T ? (T || A.preventDefault(), T) : T ? (A.preventDefault(), !1) : void 0);
400
+ setTimeout(R, 1);
401
+ }
402
+ this.onSlice(A);
403
+ })), (!y || y.includes("init")) && (r.hasAttribute("slice-value") || r.hasAttribute("value") || r.value ? this.onSlice({ type: "init", target: r, sliceElement: r, sliceEventSource: r }) : r.value = g(x(r, "slice")));
404
+ }
405
+ }), this.#e = 0;
406
+ };
407
+ R(), $();
408
+ }
409
+ #t(u, a) {
410
+ let o = this.xml.querySelector(`attributes>${u}`);
411
+ o ? U(o).append(S(o, a)) : (o = N(u, a, this.xml), this.xml.querySelector("attributes").append(o));
412
+ }
413
+ attributeChangedCallback(u, a, o) {
414
+ !this.xml || this.#e || (this.#t(u, o), this.transform());
415
+ }
416
+ get dce() {
417
+ return c;
418
+ }
419
+ }
420
+ const P = (d) => {
421
+ window.customElements.get(d) !== w && window.customElements.define(d, w);
422
+ };
423
+ if (t)
424
+ P(t);
425
+ else {
426
+ const d = s;
427
+ this.setAttribute("tag", d), P(d);
428
+ const u = document.createElement(d);
429
+ this.getAttributeNames().forEach((a) => u.setAttribute(a, this.getAttribute(a))), u.append(...[...this.childNodes].filter((a) => a.localName !== "style")), this.append(u);
430
+ }
431
+ }
432
+ get templateNode() {
433
+ return this.firstElementChild?.tagName === "TEMPLATE" ? this.firstElementChild.content : this;
434
+ }
435
+ get dce() {
436
+ return this;
437
+ }
438
+ get xslt() {
439
+ return M(this.xsltString);
440
+ }
441
+ }
442
+ window.customElements.define("custom-element", be);
443
+ export {
444
+ be as C,
445
+ H as a,
446
+ ce as b,
447
+ oe as c,
448
+ me as d,
449
+ ue as e,
450
+ J as f,
451
+ Z as g,
452
+ ee as h,
453
+ fe as i,
454
+ he as j,
455
+ B as k,
456
+ D as l,
457
+ pe as m,
458
+ xe as n,
459
+ L as o,
460
+ ye as p,
461
+ G as t,
462
+ M as x
463
+ };
@@ -0,0 +1,53 @@
1
+ "use strict";const B="http://www.w3.org/1999/XSL/Transform",q="http://www.w3.org/1999/xhtml",de="http://exslt.org/common",x=(e,l)=>e.getAttribute?.(l),K=e=>e.nodeType===3,pe=e=>typeof e=="string",fe=e=>e&&typeof e.nodeType=="number",N=(e,l="",t=document)=>(s=>(l&&s.append(S(t.ownerDocument||t,l)),s))((t.ownerDocument||t).createElement(e)),S=(e,l)=>(e.ownerDocument||e).createTextNode(l),Z=e=>{for(;e.firstChild;)e.firstChild.remove();return e},H=e=>(e.getAttributeNames().map(l=>e.removeAttribute(l)),Z(e)),he=e=>(e?.setAttribute("xmlns:xsl",B),e),xe=e=>(e?.setAttribute("xmlns:xhtml",q),he(e)),Q=(e,l)=>{const t=e.ownerDocument.createElementNS(e.namespaceURI,l);for(let s of e.attributes)t.setAttribute(s.name,s.value);for(;e.firstChild;)t.append(e.firstChild);return t};function $(e){return new DOMParser().parseFromString(e,"application/xml")}function M(e){return new XMLSerializer().serializeToString(e)}function U(e,l,t,s){const n=h=>e.ownerDocument.createElement(h),c=((h,p,m)=>(p.append(m=n(h)),m))(l,e);return[...t].forEach(h=>c.append(s(h))),c}function ye(e){return e.slot||(e.setAttribute||(e=N("span",e.textContent.replaceAll(`
2
+ `,""))),e.setAttribute("slot","")),e}function C(e,l,t){const s=typeof e;if(s==="string")return N(l,e,t);if(s==="number")return N(l,""+e,t);if(e instanceof Array){const i=N("array","",t);return e.map(c=>i.append(C(c,l,t))),i}if(e instanceof FormData){const i=N("form-data","",t);for(const c of e)i.append(C(c[1],c[0],t));return i}const n=N(l,"",t);for(let i in e)fe(e[i])||typeof e[i]=="function"||e[i]instanceof Window||(typeof e[i]!="object"?n.setAttribute(i,e[i]):n.append(C(e[i],i,t)));return n}function W(e){if(D(e,"*",l=>[...l.childNodes].filter(t=>t.nodeType===3&&t.parentNode.localName!=="style"&&t.data).forEach(t=>{const s=t.data,n=s.matchAll(/{([^}]*)}/g);if(n){let i=0,c=p=>S(t,p),h=[];if([...n].forEach(p=>{p.index>i&&h.push(c(p.input.substring(i,p.index)));const m=e.querySelector("value-of").cloneNode();m.setAttribute("select",p[1]),h.push(m),i=p.index+p[0].length}),i<s.length&&h.push(c(s.substring(i,s.length))),h.length){for(let p of h)l.insertBefore(p,t);l.removeChild(t)}}})),"all"in e){let l=1;for(let t of e.all)t.setAttribute&&!t.tagName.startsWith("xsl:")&&t.setAttribute("data-dce-id",""+l++)}return e}function ee(e,l="xsl:stylesheet"){if(e.tagName===l||e.documentElement?.tagName===l)return W(e);const t=$(`<xsl:stylesheet version="1.0" xmlns:xsl="${B}" xmlns:xhtml="${q}" xmlns:exsl="${de}" exclude-result-prefixes="exsl" >
3
+ <xsl:output method="xml" />
4
+ <xsl:template match="/"><dce-root xmlns="${q}"><xsl:apply-templates select="*"/></dce-root></xsl:template>
5
+ <xsl:template match="*[name()='template']"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
6
+ <xsl:template match="*"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
7
+ <xsl:template match="*[name()='svg']|*[name()='math']"><xsl:apply-templates mode="sanitize" select="."/></xsl:template>
8
+ <xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]"><xsl:copy><xsl:apply-templates mode="sanitize" select="@*"/><xsl:value-of select="text()"></xsl:value-of></xsl:copy></xsl:template>
9
+ <xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="@*"/><xsl:value-of select="text()"></xsl:value-of></xsl:element></xsl:template>
10
+ <xsl:template mode="sanitize" match="*|@*"><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></xsl:template>
11
+ <xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
12
+ <xsl:template mode="sanitize" match="text()"><dce-text><xsl:copy/></dce-text></xsl:template>
13
+ <xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']"><dce-text><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></dce-text></xsl:template>
14
+ <xsl:template mode="sanitize" match="xhtml:*"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:element></xsl:template>
15
+ </xsl:stylesheet>`),s=new XSLTProcessor,n=(a=>{D(a,"script",v=>v.remove());const o=a.content??a.firstElementChild?.content??a.body??a;oe.forEach(v=>D(o,v,b=>ce(b,o)));const E=a.firstElementChild?.content||a.content,g=v=>{const b=$("<xhtml/>"),P=b.importNode(v,!0);return b.replaceChild(P,b.documentElement),xe(P)};if(E){const v=N("div");return[...E.childNodes].map(b=>v.append(b.cloneNode(!0))),g(v)}return g(a.documentElement||a.body||a)})(e),i=$(`<xsl:stylesheet version="1.0"
16
+ xmlns:xsl="${B}"
17
+ xmlns:xhtml="${q}"
18
+ xmlns:dce="urn:schemas-epa-wg:dce"
19
+ xmlns:exsl="http://exslt.org/common"
20
+ exclude-result-prefixes="exsl"
21
+ >
22
+ <xsl:template match="ignore">
23
+ <xsl:choose>
24
+ <xsl:when test="//attr">{//attr}</xsl:when>
25
+ <xsl:otherwise>{def}</xsl:otherwise>
26
+ </xsl:choose><xsl:value-of select="."></xsl:value-of></xsl:template>
27
+ <xsl:template mode="payload" match="attributes"></xsl:template>
28
+ <xsl:template match="/">
29
+ <xsl:apply-templates mode="payload" select="/datadom/attributes"/>
30
+ </xsl:template>
31
+ <xsl:template name="slot" >
32
+ <xsl:param name="slotname" />
33
+ <xsl:param name="defaultvalue" />
34
+ <xsl:choose>
35
+ <xsl:when test="//payload/*[@slot=$slotname]">
36
+ <xsl:copy-of select="//payload/*[@slot=$slotname]"/>
37
+ </xsl:when>
38
+ <xsl:otherwise>
39
+ <xsl:copy-of select="$defaultvalue"/>
40
+ </xsl:otherwise>
41
+ </xsl:choose>
42
+ </xsl:template>
43
+ <xsl:variable name="js-injected-body">
44
+ <xsl:call-template name="slot" >
45
+ <xsl:with-param name="slotname" select="''"/>
46
+ <xsl:with-param name="defaultvalue"/>
47
+ </xsl:call-template>
48
+ </xsl:variable>
49
+ </xsl:stylesheet>`);s.importStylesheet(t);const c=s.transformToFragment(n,document),h=(a,o)=>a.querySelector(o),p=h(i,'template[mode="payload"]');if(!c)return console.error("transformation error",{xml:n.outerHTML,xsl:M(t)});const m=[];[...c.querySelectorAll("dce-root>attribute")].forEach(a=>{const o=Q(a,"xsl:param"),E=x(a,"name");p.append(o);let g=x(o,"select")?.split("??");g||(g=["//"+E,`'${o.textContent}'`],H(o),o.setAttribute("name",E));let v;if(g?.length>1){o.removeAttribute("select");const b=h(i,'template[match="ignore"]>choose').cloneNode(!0);H(b.firstElementChild).append(S(b,"{"+g[0]+"}")),H(b.lastElementChild).append(S(b,"{"+g[1]+"}")),b.firstElementChild.setAttribute("test",g[0]),o.append(b),v=b.cloneNode(!0)}else v=Q(a,"xsl:value-of");v.removeAttribute("name"),a.append(v),a.removeAttribute("select"),m.push(o)}),[...c.querySelectorAll("[value]")].filter(a=>a.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach(a=>{const o=x(a,"value");o&&a.setAttribute("value",re(o))});for(const a of c.childNodes)p.append(i.importNode(a,!0));[...p.querySelectorAll("template")].forEach(a=>p.ownerDocument.documentElement.append(a));const R=h(i,'call-template[name="slot"]'),d=a=>{const o=R.cloneNode(!0),E=x(a,"name");E&&o.firstElementChild.setAttribute("select",`'${E}'`);for(let g of a.childNodes)o.lastElementChild.append(g);return o};D(p,"slot",a=>a.parentNode.replaceChild(d(a),a));const u=W(i);return u.params=m,u}async function te(e){return await new Promise((t,s)=>{const n=new XMLHttpRequest;n.open("GET",e),n.responseType="document",n.onload=()=>{n.readyState===n.DONE&&n.status===200&&t(n.responseXML||N("div",n.responseText)),s(n.statusText)},n.addEventListener("error",i=>s(i)),n.send()})}function se(e,l,t=!1){if(e===l)return!0;if(typeof e!="object"||e===null||typeof l!="object"||l===null||Object.keys(e).length!==Object.keys(l).length)return t;for(let s in e)if(!(s in l)||!se(e[s],l[s]))return t;return!0}const le=e=>e.split("|").map(l=>l.trim()).filter(l=>l),ne=(e,l)=>le(l).map(t=>{let s=e.ownerDocument,n=i=>(e.append(i),i);if(t.includes("/")){const i=[],c=s.evaluate(t,e);for(let h;h=c.iterateNext();)i.push(h);return i}return[...e.childNodes].find(i=>i.localName===t)||n(N(t,"",s))}).flat();function Y(e,l,t,s){if(!t.sliceProcessed)return t.sliceProcessed=1,ne(e,l??"").map(n=>{const i=e.ownerDocument,c=t.sliceEventSource,h=t.sliceElement,p=()=>[...n.childNodes].filter(m=>m.nodeType===3||m.localName==="value"||m.localName==="form-data").map(m=>m.remove());if(c.getAttributeNames().map(m=>n.setAttribute(m,x(c,m))),[...n.childNodes].filter(m=>m.localName==="event").map(m=>m.remove()),"validationMessage"in c&&n.setAttribute("validation-message",c.validationMessage),t.type==="init"&&p(),n.append(C(t,"event",i)),h.hasAttribute("slice-value")){c.value===void 0?n.removeAttribute("value"):n.setAttribute("value",c.value);const m=L(x(h,"slice-value"),n);p(),n.append(S(i,m))}else{if("elements"in c)return p(),n.append(C(new FormData(c),"value",n.ownerDocument)),n;const m=c.value??x(h,"value");p(),m==null?[...n.childNodes].filter(w=>w.localName!=="event").map(w=>w.remove()):pe(m)?n.append(S(i,m)):n.append(C(m,"value",n.ownerDocument))}return n})}function D(e,l,t){e.querySelectorAll&&[...e.querySelectorAll(l)].forEach(t)}const be=async(e,l)=>{if(!e||!e.trim())return[l];if(e.startsWith("#"))return(t=>{if(!t)return[];const s=t.querySelectorAll(e);if(s.length)return[...s];const n=t.getRootNode();return n===t?[]:getByHashId(n)})(l.parentElement);try{const t=await te(e),s=new URL(e,location).hash;if(s){const n=t.querySelectorAll(s);return n.length?[...n]:[l]}return[t]}catch{return[l]}};function ae(e,l){for(let t of e.attributes)t.namespaceURI?l.setAttributeNS(t.namespaceURI,t.name,t.value):l.setAttribute(t.name,t.value),t.name==="value"&&(l.value=t.value)}function G(e,l=0){const t={};for(const s of e.childNodes){const n=x(s,"data-dce-id")||s.dceId||0;if(!t[n])n?t[n]=1:(t[n]=s.dceId=++l,s.setAttribute&&s.setAttribute("data-dce-id",s.dceId));else{const i=s.dceId=n+"-"+t[n]++;s.setAttribute&&s.setAttribute("data-dce-id",i)}s.childNodes.length&&G(s)}}function J(e,l){if(!l.length)return Z(e);const t={};for(let s of e.childNodes)t[s.dceId],K(s)?(s.data.trim(),t[s.dceId||0]=s):t[x(s,"data-dce-id")||0]=s;for(let s of[...l]){const n=x(s,"data-dce-id")||s.dceId,i=t[n];i?(K(s)?i.nodeValue!==s.nodeValue&&(i.nodeValue=s.nodeValue):(ae(s,i),(i.childNodes.length||s.childNodes.length)&&J(i,s.childNodes)),delete t[n]):e.append(s)}for(let s of Object.values(t))s.remove()}function ie(e,l){return e.hasAttribute(l)||e.setAttribute(l,crypto.randomUUID()),e.getAttribute(l)}const re=e=>[...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map(t=>`${t[1]}{${V(t[3])}}${t[4]}`).join(""),V=e=>{if(!e.trim())return e;const l=e.split("??"),t=l.shift(),s=V(l.join("??"));return l.length?`concat( ${t} , substring( ${s} , (1+string-length( ${s} )) * string-length( ${t} ) ) )`:e},L=(e,l)=>{const t=e.split("??");if(t.length>1)return L(t[0],l)||L(t[1],l);e=V(e);const s=l.ownerDocument.evaluate(e,l);switch(s.resultType){case XPathResult.NUMBER_TYPE:return s.numberValue;case XPathResult.STRING_TYPE:return s.stringValue;case XPathResult.BOOLEAN_TYPE:return s.booleanValue}let n="";for(let i;i=s.iterateNext();)n+=i.textContent;return n},oe="stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,template,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(","),ce=(e,l)=>{const t=N("xsl:"+e.localName);for(let s of e.attributes)t.setAttribute(s.name,s.value);for(;e.firstChild;)t.append(e.firstChild);if(e.parentElement)e.parentElement.replaceChild(t,e);else{const s=e.parentElement||l,n=[...s.childNodes];n.forEach((i,c)=>{i===e&&(n[c]=t)}),s.replaceChildren(...n)}};class me extends HTMLElement{static observedAttributes=["src","tag","hidden"];async connectedCallback(){const l=await be(x(this,"src"),this),t=x(this,"tag"),s=t||"dce-"+crypto.randomUUID();for(const d of l)D(d.templateNode||d.content||d,"style",u=>{const a=u.closest("slot"),o=a?`slot[name="${a.name}"]`:"";u.innerHTML=`${s} ${o}{${u.innerHTML}}`,this.append(u)});const n=l.map(d=>ee(d)),i=n.map((d,u)=>(u=new XSLTProcessor,u.importStylesheet(d),u));Object.defineProperty(this,"xsltString",{get:()=>n.map(d=>M(d)).join(`
50
+ `)});const c=this,h=[...this.templateNode.querySelectorAll("[slice]")],p=h.map(d=>x(d,"slice")).filter(d=>!d.includes("/")).filter((d,u,a)=>a.indexOf(d)===u).map(le).flat(),m=n.reduce((d,u)=>(u.params&&d.push(...u.params),d),[]);class w extends HTMLElement{static get observedAttributes(){return m.map(u=>x(u,"name"))}#e=0;connectedCallback(){let u=this.childNodes;if(this.firstElementChild?.tagName==="TEMPLATE"){this.firstElementChild!==this.lastElementChild&&console.error("payload should have TEMPLATE as only child",this.outerHTML);const f=this.firstElementChild;f.remove(),u=f.content.childNodes;for(const r of[...f.content.childNodes])if(r.localName==="style"){const y=ie(this,"data-dce-style");r.innerHTML=`${s}[data-dce-style="${y}"]{${r.innerHTML}}`,f.insertAdjacentElement("beforebegin",r)}else r.nodeType===1?f.insertAdjacentElement("beforebegin",r):r.nodeType===3&&f.insertAdjacentText("beforebegin",r.data)}const a=$("<datadom/>").documentElement,o=(f,r="")=>(y=>(r&&y.append(S(a,r)),y))(a.ownerDocument.createElement(f));U(a,"payload",u,ye),this.innerHTML="";const E=U(a,"attributes",this.attributes,f=>o(f.nodeName,f.value));U(a,"dataset",Object.keys(this.dataset),f=>o(f,this.dataset[f]));const g=U(a,"slice",p,f=>o(f,"")),v=f=>L(f,g);this.xml=a;const b=[],P=()=>{const f={};for(let r;r=b.pop();){const y=x(r.sliceElement,"slice");f[y]||(Y(g,y,r),f[y]=r)}Object.keys(f).length!==0&&X()};let k;this.onSlice=f=>{b.push(f),k||(k=setTimeout(()=>{P(),k=0},1))};const X=this.transform=()=>{if(this.#e)debugger;this.#e=1,i.map((r,y)=>{const I=r.transformToFragment(a.ownerDocument,document);return I||console.error(`XSLT transformation error. xsl:
51
+ `,M(n[y]),`
52
+ xml:
53
+ `,M(a)),I}).map(r=>{r&&(G(r),J(this,r.childNodes))}),w.observedAttributes.map(r=>{let y=x(this.firstElementChild,r);y!==x(this,r)&&(this.setAttribute(r,y),this.#t(r,y))}),D(this,"[slice],[slice-event]",r=>{if(!r.dceInitialized){r.dceInitialized=1;let y=x(r,"slice-event");x(r,"custom-validity")&&(y+=" change submit"),[...new Set((y||"change").split(" "))].forEach(I=>(r.localName==="slice"?r.parentElement:r).addEventListener(I,A=>{A.sliceElement=r,A.sliceEventSource=A.currentTarget||A.target;const ue=Y(g,x(A.sliceElement,"slice"),A);D(this,"[custom-validity]",z=>{if(!z.setCustomValidity)return;const F=x(z,"custom-validity");try{const j=F&&L(F,E);z.setCustomValidity(j===!0?"":j===!1?"invalid":j)}catch(j){console.error(j,"xPath",F)}});const O=x(r,"custom-validity"),T=O&&L(O,E),_=T===!0?"":T;if(O){if(r.setCustomValidity?r.setCustomValidity(_):r.validationMessage=_,ue.map(z=>z.setAttribute("validation-message",_)),A.type==="submit")return T===!0?void 0:(setTimeout(X,1),!!T===T?(T||A.preventDefault(),T):T?(A.preventDefault(),!1):void 0);setTimeout(X,1)}this.onSlice(A)})),(!y||y.includes("init"))&&(r.hasAttribute("slice-value")||r.hasAttribute("value")||r.value?this.onSlice({type:"init",target:r,sliceElement:r,sliceEventSource:r}):r.value=v(x(r,"slice")))}}),this.#e=0};X(),P()}#t(u,a){let o=this.xml.querySelector(`attributes>${u}`);o?H(o).append(S(o,a)):(o=N(u,a,this.xml),this.xml.querySelector("attributes").append(o))}attributeChangedCallback(u,a,o){!this.xml||this.#e||(this.#t(u,o),this.transform())}get dce(){return c}}const R=d=>{window.customElements.get(d)!==w&&window.customElements.define(d,w)};if(t)R(t);else{const d=s;this.setAttribute("tag",d),R(d);const u=document.createElement(d);this.getAttributeNames().forEach(a=>u.setAttribute(a,this.getAttribute(a))),u.append(...[...this.childNodes].filter(a=>a.localName!=="style")),this.append(u)}}get templateNode(){return this.firstElementChild?.tagName==="TEMPLATE"?this.firstElementChild.content:this}get dce(){return this}get xslt(){return $(this.xsltString)}}window.customElements.define("custom-element",me);exports.CustomElement=me;exports.assureSlices=ne;exports.assureUID=ie;exports.assureUnique=G;exports.createXsltFromDom=ee;exports.deepEqual=se;exports.evalCurly=re;exports.event2slice=Y;exports.merge=J;exports.mergeAttr=ae;exports.obj2node=C;exports.tagUid=W;exports.toXsl=ce;exports.xPath=L;exports.xPathDefaults=V;exports.xhrTemplate=te;exports.xml2dom=$;exports.xmlString=M;exports.xslTags=oe;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./custom-element-B4v-KaIh.cjs"),l=require("./http-request-DPrY7mGh.cjs"),t=require("./local-storage-Boafngui.cjs"),a=require("./location-element-2m0gWq_d.cjs");exports.CustomElement=e.CustomElement;exports.assureSlices=e.assureSlices;exports.assureUID=e.assureUID;exports.assureUnique=e.assureUnique;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.obj2node=e.obj2node;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.LocationElement=a.LocationElement;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./custom-element-N-sWiqGK.cjs"),l=require("./http-request-DPrY7mGh.cjs"),t=require("./local-storage-Boafngui.cjs"),a=require("./location-element-2m0gWq_d.cjs");exports.CustomElement=e.CustomElement;exports.assureSlices=e.assureSlices;exports.assureUID=e.assureUID;exports.assureUnique=e.assureUnique;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.obj2node=e.obj2node;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.LocationElement=a.LocationElement;
@@ -1,5 +1,5 @@
1
- import { C as e } from "./custom-element-_g0GTup2.js";
2
- import { e as o, i as r, g as l, c as m, d as x, j as n, f as p, h as u, m as f, o as g, t as i, p as c, l as d, k as E, b as S, x as h, a as L, n as q } from "./custom-element-_g0GTup2.js";
1
+ import { C as e } from "./custom-element-BISbI4SU.js";
2
+ import { e as o, i as r, g as l, c as m, d as x, j as n, f as p, h as u, m as f, o as g, t as i, p as c, l as d, k as E, b as S, x as h, a as L, n as q } from "./custom-element-BISbI4SU.js";
3
3
  import { H as D } from "./http-request-BOvP4KTl.js";
4
4
  import { L as b, l as j } from "./local-storage-BqDEu2kF.js";
5
5
  import { L as H } from "./location-element-nA_wsqBt.js";
@@ -8,7 +8,7 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.2.14'
11
+ const PACKAGE_VERSION = '2.3.1'
12
12
  const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
13
13
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
14
14
  const activeClientIds = new Set()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epa-wg/custom-element-dist",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -14,10 +14,10 @@
14
14
  "test:watch": "vitest --inspect-brk --no-file-parallelism --browser.headless=false --test-timeout=0",
15
15
  "test:storybook": "test-storybook",
16
16
  "sb": "yarn storybook",
17
- "t": "vitest --no-file-parallelism --watch=false src/stories/location-element.test.ts"
17
+ "t": "vitest --no-file-parallelism --watch --browser.headless=false src/stories/slots.test.stories.ts"
18
18
  },
19
19
  "dependencies": {
20
- "@epa-wg/custom-element": "0.0.21"
20
+ "@epa-wg/custom-element": "0.0.22"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@chromatic-com/storybook": "^1.3.3",
@@ -39,7 +39,7 @@
39
39
  "playwright": "^1.43.1",
40
40
  "storybook": "^8.0.10",
41
41
  "typescript": "^5.2.2",
42
- "vite": "^5.2.0",
42
+ "vite": "^5.3.1",
43
43
  "vitest": "^1.6.0",
44
44
  "webdriverio": "^8.36.1"
45
45
  },
@@ -8,7 +8,7 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.2.14'
11
+ const PACKAGE_VERSION = '2.3.1'
12
12
  const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
13
13
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
14
14
  const activeClientIds = new Set()
@@ -1,5 +1,9 @@
1
1
  export function log(x: any): void;
2
2
  export function deepEqual(a: any, b:any): boolean|0;
3
+ export function xml2dom(xmlString:string): Document;
4
+ export function xmlString(doc:Node|Document): string;
5
+ export function obj2node(o:any, tag:string, doc:Document): HTMLElement;
6
+ export function tagUid(node:HTMLElement): HTMLElement;
3
7
 
4
8
  /**
5
9
  * @summary Declarative Custom Element as W3C proposal PoC with native(XSLT) based templating