@epa-wg/custom-element-dist 0.0.29 → 0.0.32

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 (175) hide show
  1. package/.idea/custom-element-dist.iml +11 -0
  2. package/.idea/inspectionProfiles/Project_Default.xml +25 -0
  3. package/.idea/misc.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/vcs.xml +6 -0
  6. package/.storybook/main.ts +21 -19
  7. package/.storybook/preview.ts +25 -25
  8. package/README.md +4 -4
  9. package/coverage/coverage-final.json +21 -21
  10. package/coverage/index.html +26 -26
  11. package/coverage/src/custom-element/coverage.svg +1 -1
  12. package/coverage/src/custom-element/custom-element.js/coverage.svg +1 -1
  13. package/coverage/src/custom-element/custom-element.js.html +543 -441
  14. package/coverage/src/custom-element/http-request.js.html +12 -12
  15. package/coverage/src/custom-element/index.html +18 -18
  16. package/coverage/src/custom-element/local-storage.js.html +52 -52
  17. package/coverage/src/custom-element/location-element.js.html +4 -4
  18. package/coverage/src/custom-element/module-url.js.html +1 -1
  19. package/coverage/src/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/attributes.test.stories.ts/coverage.svg +1 -1
  23. package/coverage/src/stories/attributes.test.stories.ts.html +335 -35
  24. package/coverage/src/stories/coverage.svg +1 -1
  25. package/coverage/src/stories/css.test.stories.ts.html +1 -1
  26. package/coverage/src/stories/dom-merge.test.stories.ts.html +1 -1
  27. package/coverage/src/stories/external-template.test.stories.ts.html +2 -2
  28. package/coverage/src/stories/form.test.stories.ts.html +1 -1
  29. package/coverage/src/stories/http-request.stories.ts.html +1 -1
  30. package/coverage/src/stories/index.html +22 -22
  31. package/coverage/src/stories/local-storage.test.stories.ts.html +17 -17
  32. package/coverage/src/stories/location-element.test.stories.ts.html +3 -6
  33. package/coverage/src/stories/module-url.test.stories.ts.html +1 -1
  34. package/coverage/src/stories/set-url.test.stories.ts.html +1 -1
  35. package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +1 -1
  36. package/coverage/src/stories/slice-events.test.stories.ts.html +284 -23
  37. package/coverage/src/stories/slots.test.stories.ts.html +1 -1
  38. package/coverage/src/stories/testStoryBook.ts.html +12 -12
  39. package/coverage/src/stories/version-select.test.stories.ts.html +3 -3
  40. package/coverage/src/sum.ts.html +1 -1
  41. package/dist/custom-element-D2wf_rqP.js +576 -0
  42. package/dist/custom-element-Dtzhbjkc.cjs +97 -0
  43. package/dist/custom-element-bundle.cjs +1 -1
  44. package/dist/custom-element-bundle.js +30 -28
  45. package/dist/demo/a.html +51 -38
  46. package/dist/demo/a.svg +26 -26
  47. package/dist/demo/data-slices.html +37 -0
  48. package/dist/demo/external-template.html +1 -0
  49. package/dist/demo/form.html +42 -0
  50. package/dist/demo/hex-grid-dce.html +1 -1
  51. package/dist/demo/hex-grid.html +1 -1
  52. package/dist/demo/parameters.html +20 -1
  53. package/dist/demo/s.xml +6 -12
  54. package/dist/demo/s.xslt +64 -15
  55. package/dist/demo/ss.html +4 -23
  56. package/package.json +13 -13
  57. package/public/demo/a.html +51 -38
  58. package/public/demo/a.svg +26 -26
  59. package/public/demo/data-slices.html +37 -0
  60. package/public/demo/external-template.html +1 -0
  61. package/public/demo/form.html +42 -0
  62. package/public/demo/hex-grid-dce.html +1 -1
  63. package/public/demo/hex-grid.html +1 -1
  64. package/public/demo/parameters.html +20 -1
  65. package/public/demo/s.xml +6 -12
  66. package/public/demo/s.xslt +64 -15
  67. package/public/demo/ss.html +4 -23
  68. package/src/custom-element/custom-element.js +76 -42
  69. package/src/custom-element/demo/a.html +51 -38
  70. package/src/custom-element/demo/a.svg +26 -26
  71. package/src/custom-element/demo/data-slices.html +37 -0
  72. package/src/custom-element/demo/external-template.html +1 -0
  73. package/src/custom-element/demo/form.html +42 -0
  74. package/src/custom-element/demo/hex-grid-dce.html +1 -1
  75. package/src/custom-element/demo/hex-grid.html +1 -1
  76. package/src/custom-element/demo/parameters.html +20 -1
  77. package/src/custom-element/demo/s.xml +6 -12
  78. package/src/custom-element/demo/s.xslt +64 -15
  79. package/src/custom-element/demo/ss.html +4 -23
  80. package/src/custom-element/ide/web-types-dce.json +1 -1
  81. package/src/custom-element/ide/web-types-xsl.json +1 -1
  82. package/src/material/angular.css +987 -987
  83. package/src/material/components/autocomplete.html +239 -240
  84. package/src/material/components/dropdown.html +110 -46
  85. package/src/material/components/icon-link.html +160 -160
  86. package/src/material/components/input.html +363 -0
  87. package/src/material/components/menu.html +234 -234
  88. package/src/material/components.html +121 -120
  89. package/src/material/demo.css +36 -31
  90. package/src/material/index.html +110 -110
  91. package/src/material/material.css +356 -356
  92. package/src/material/theme/README.md +17 -17
  93. package/src/material/theme/semantic.css +113 -112
  94. package/src/mocks/versions.mock.ts +8 -8
  95. package/src/stories/attributes.test.stories.ts +123 -23
  96. package/src/stories/external-template.test.stories.ts +1 -1
  97. package/src/stories/location-element.test.stories.ts +1 -2
  98. package/src/stories/slice-events.test.stories.ts +87 -0
  99. package/storybook-static/assets/Color-F6OSRLHC-BU3iy8jH.js +1 -0
  100. package/storybook-static/assets/{Configure-DOhzHFEs.js → Configure-DN6ifayP.js} +1 -1
  101. package/storybook-static/assets/{DocsRenderer-CFRXHY34-BSJkbsd6.js → DocsRenderer-CFRXHY34-BaVEufDj.js} +2 -2
  102. package/storybook-static/assets/attributes.test.stories-D1X6EBrd.js +278 -0
  103. package/storybook-static/assets/{css.test.stories-pgbBc17d.js → css.test.stories-Cp_g2hE1.js} +1 -1
  104. package/storybook-static/assets/custom-element-uuAtIYWS.js +97 -0
  105. package/storybook-static/assets/{dom-merge.test.stories-CXcYP_-J.js → dom-merge.test.stories-hbpdCka0.js} +1 -1
  106. package/storybook-static/assets/entry-preview-DHVXbf3x.js +26 -0
  107. package/storybook-static/assets/entry-preview-docs-BbcIMweR.js +2 -0
  108. package/storybook-static/assets/{external-template.test.stories-CpJ68Ghy.js → external-template.test.stories-BK89h6sk.js} +3 -3
  109. package/storybook-static/assets/{form.test.stories-D35lyqd8.js → form.test.stories-BfoLe_rw.js} +1 -1
  110. package/storybook-static/assets/{handlers-CW9pDZnt.js → handlers-yVPwH_Nz.js} +21 -21
  111. package/storybook-static/assets/{http-request.stories-CBbknCOO.js → http-request.stories-CBFJS2Ws.js} +1 -1
  112. package/storybook-static/assets/iframe-CJEL_4Nu.js +2 -0
  113. package/storybook-static/assets/index-BcZLpTeD.js +8 -0
  114. package/storybook-static/assets/{index-BSz1w4Gl.js → index-CxRwF5Or.js} +130 -130
  115. package/storybook-static/assets/index-D5fBh-7N.js +1 -0
  116. package/storybook-static/assets/{index-YxUFxnQR.js → index-DM-KBPdl.js} +1 -1
  117. package/storybook-static/assets/{index-B3QjF0Ed.js → index-RSFf30w1.js} +1 -1
  118. package/storybook-static/assets/index-SnjB5uV8.js +769 -0
  119. package/storybook-static/assets/{local-storage.test.stories-BY-PWhuk.js → local-storage.test.stories-C0Yzy6Am.js} +1 -1
  120. package/storybook-static/assets/{location-element.test.stories-3auBYEaU.js → location-element.test.stories-DNFrEu5A.js} +1 -1
  121. package/storybook-static/assets/{module-url.test.stories-B7L9cL60.js → module-url.test.stories-CXibF5Ta.js} +1 -1
  122. package/storybook-static/assets/{preview-CfWMRsRq.js → preview-Bnd0XhaF.js} +2 -2
  123. package/storybook-static/assets/{preview-BRPR-UXC.js → preview-CNKoaWES.js} +1 -1
  124. package/storybook-static/assets/preview-DAeyCMnM.js +1 -0
  125. package/storybook-static/assets/preview-DJMlNTk8.js +2 -0
  126. package/storybook-static/assets/{set-url.test.stories-CuSuDLIx.js → set-url.test.stories-BBfLxv2u.js} +1 -1
  127. package/storybook-static/assets/{slice-events.test.stories-BkRKsKem.js → slice-events.test.stories-HcXF8XQI.js} +138 -13
  128. package/storybook-static/assets/{slots.test.stories-BJCUWFkE.js → slots.test.stories-i6mnIFM2.js} +1 -1
  129. package/storybook-static/assets/tiny-invariant-CopsF_GD.js +1 -0
  130. package/storybook-static/assets/{version-select.test.stories-B3ybJn_Z.js → version-select.test.stories-BsUFH6Va.js} +1 -1
  131. package/storybook-static/demo/a.html +51 -38
  132. package/storybook-static/demo/a.svg +26 -26
  133. package/storybook-static/demo/data-slices.html +37 -0
  134. package/storybook-static/demo/external-template.html +1 -0
  135. package/storybook-static/demo/form.html +42 -0
  136. package/storybook-static/demo/hex-grid-dce.html +1 -1
  137. package/storybook-static/demo/hex-grid.html +1 -1
  138. package/storybook-static/demo/parameters.html +20 -1
  139. package/storybook-static/demo/s.xml +6 -12
  140. package/storybook-static/demo/s.xslt +64 -15
  141. package/storybook-static/demo/ss.html +4 -23
  142. package/storybook-static/iframe.html +2 -2
  143. package/storybook-static/index.html +4 -0
  144. package/storybook-static/index.json +1 -1
  145. package/storybook-static/project.json +1 -1
  146. package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +333 -0
  147. package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js.LEGAL.txt +40 -0
  148. package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +1 -1
  149. package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +8 -8
  150. package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +82 -85
  151. package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +1 -1
  152. package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +1 -1
  153. package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +1 -1
  154. package/storybook-static/sb-addons/interactions-9/manager-bundle.js +66 -67
  155. package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +1 -1
  156. package/storybook-static/sb-manager/globals-module-info.js +25 -3
  157. package/storybook-static/sb-manager/globals-runtime.js +29585 -43124
  158. package/storybook-static/sb-manager/runtime.js +10647 -9399
  159. package/storybook-static/sb-preview/runtime.js +3536 -5860
  160. package/test-runner-jest.config.js +15 -0
  161. package/dist/custom-element-BOIPgtxz.js +0 -565
  162. package/dist/custom-element-CUsSENWc.cjs +0 -97
  163. package/src/stories/__screenshots__/http-request.test.ts/http-request-url-change-1.png +0 -0
  164. package/storybook-static/assets/Color-ERTF36HU-CQkSD2nd.js +0 -1
  165. package/storybook-static/assets/attributes.test.stories-BJBuuXgZ.js +0 -150
  166. package/storybook-static/assets/custom-element-BDGsYgbP.js +0 -97
  167. package/storybook-static/assets/entry-preview-C313OLrj.js +0 -26
  168. package/storybook-static/assets/entry-preview-docs-B7ORr9w5.js +0 -2
  169. package/storybook-static/assets/iframe-DOi4N7qI.js +0 -2
  170. package/storybook-static/assets/index-BdcJ-iJ7.js +0 -8
  171. package/storybook-static/assets/index-CaL3Qp7t.js +0 -634
  172. package/storybook-static/assets/index-DgFM0Ce3.js +0 -1
  173. package/storybook-static/assets/preview-C992A1Y-.js +0 -2
  174. package/storybook-static/assets/preview-CcS4DQh8.js +0 -1
  175. package/storybook-static/assets/tiny-invariant-BxWVcicq.js +0 -1
@@ -0,0 +1,15 @@
1
+ const { getJestConfig } = require('@storybook/test-runner');
2
+
3
+ // The default Jest configuration comes from @storybook/test-runner
4
+ const testRunnerConfig = getJestConfig();
5
+
6
+ /**
7
+ * @type {import('@jest/types').Config.InitialOptions}
8
+ */
9
+ module.exports = {
10
+ ...testRunnerConfig,
11
+ /** Add your own overrides below, and make sure
12
+ * to merge testRunnerConfig properties with your own
13
+ * @see https://jestjs.io/docs/configuration
14
+ */
15
+ };
@@ -1,565 +0,0 @@
1
- const W = "http://www.w3.org/1999/XSL/Transform", k = "http://www.w3.org/1999/xhtml", ue = "http://exslt.org/common", f = (e, l) => e.getAttribute?.(l), Z = (e) => e.nodeType === 3, de = (e) => typeof e == "string", pe = (e) => e && typeof e.nodeType == "number", $ = (e, l) => (e.ownerDocument || e).createTextNode(l), se = (e) => {
2
- for (; e.firstChild; ) e.firstChild.remove();
3
- return e;
4
- }, V = (e) => (e.getAttributeNames().map((l) => e.removeAttribute(l)), se(e)), le = (e) => (e?.setAttribute("xmlns:xsl", W), e), ae = (e) => (e?.setAttribute("xmlns:xhtml", k), le(e)), ne = (e) => /^[_a-zA-Z][-_:a-zA-Z0-9]*$/.test(e), w = (e, l = "", t = document) => {
5
- const s = (i) => ((r) => (l && r.append($(t.ownerDocument || t, l)), r))((t.ownerDocument || t).createElement(i));
6
- if (ne(e))
7
- return s(e);
8
- const a = s("dce-object");
9
- return a.setAttribute("dce-object-name", e), a;
10
- }, J = (e, l) => {
11
- const t = e.ownerDocument.createElementNS(e.namespaceURI, l);
12
- for (let s of e.attributes)
13
- t.setAttribute(s.name, s.value);
14
- for (; e.firstChild; )
15
- t.append(e.firstChild);
16
- return t;
17
- };
18
- function X(e) {
19
- return new DOMParser().parseFromString(e, "application/xml");
20
- }
21
- function I(e) {
22
- return new XMLSerializer().serializeToString(e);
23
- }
24
- function H(e, l, t, s) {
25
- const a = (x) => e.ownerDocument.createElement(x), r = ((x, p, u) => (p.append(u = a(x)), u))(l, e);
26
- return [...t].forEach((x) => r.append(s(x))), r;
27
- }
28
- function fe(e) {
29
- return e.slot || (e.setAttribute || (e = w("span", e.textContent.replaceAll(`
30
- `, ""))), e.setAttribute("slot", "")), e;
31
- }
32
- function K(e, l) {
33
- e.getAttributeNames().forEach((t) => l.includes(t) || e.removeAttribute(t));
34
- }
35
- const Q = (e) => [...e].filter((l) => !(l.nodeType === 3 && l.data.trim() === ""));
36
- function D(e, l, t) {
37
- const s = typeof e;
38
- if (s === "string")
39
- return w(l, e, t);
40
- if (s === "number")
41
- return w(l, "" + e, t);
42
- if (e instanceof Array) {
43
- const i = w("array", "", t);
44
- return e.map((r) => i.append(D(r, l, t))), i;
45
- }
46
- if (e instanceof FormData) {
47
- const i = w("form-data", "", t);
48
- for (const r of e)
49
- i.append(D(r[1], r[0], t));
50
- return i;
51
- }
52
- const a = w(l, "", t);
53
- for (let i in e)
54
- pe(e[i]) || typeof e[i] == "function" || e[i] instanceof Window || (typeof e[i] != "object" && ne(i) ? a.setAttribute(i, e[i]) : a.append(D(e[i], i, t)));
55
- return a;
56
- }
57
- function ee(e) {
58
- if (L(e, "*", (l) => [...l.childNodes].filter((t) => t.nodeType === 3 && t.parentNode.localName !== "style" && t.data).forEach((t) => {
59
- const s = t.data, a = s.matchAll(/{([^}]*)}/g);
60
- if (a) {
61
- let i = 0, r = (p) => $(t, p), x = [];
62
- if ([...a].forEach((p) => {
63
- p.index > i && x.push(r(p.input.substring(i, p.index)));
64
- const u = e.querySelector("value-of").cloneNode();
65
- u.setAttribute("select", p[1]), x.push(u), i = p.index + p[0].length;
66
- }), i < s.length && x.push(r(s.substring(i, s.length))), x.length) {
67
- for (let p of x)
68
- l.insertBefore(p, t);
69
- l.removeChild(t);
70
- }
71
- }
72
- })), "all" in e) {
73
- let l = 1;
74
- for (let t of e.all)
75
- t.setAttribute && !t.tagName.startsWith("xsl:") && t.setAttribute("data-dce-id", "" + l++);
76
- }
77
- return e;
78
- }
79
- function he(e, l = "xsl:stylesheet") {
80
- if (e.tagName === l || e.documentElement?.tagName === l)
81
- return ee(e);
82
- const t = X(`<xsl:stylesheet version="1.0" xmlns:xsl="${W}" xmlns:xhtml="${k}" xmlns:exsl="${ue}" exclude-result-prefixes="exsl" >
83
- <xsl:output method="xml"/>
84
- <xsl:template match="/"><dce-root xmlns="${k}"><xsl:apply-templates select="*" /></dce-root></xsl:template>
85
- <xsl:template match="*[name()='template']">
86
- <xsl:apply-templates mode="sanitize" select="*|text()"/>
87
- </xsl:template>
88
- <xsl:template match="*">
89
- <xsl:apply-templates mode="sanitize" select="*|text()"/>
90
- </xsl:template>
91
- <xsl:template match="*[name()='svg']|*[name()='math']">
92
- <xsl:apply-templates mode="sanitize" select="."/>
93
- </xsl:template>
94
- <xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]">
95
- <xsl:copy>
96
- <xsl:apply-templates mode="sanitize" select="@*"/>
97
- <xsl:value-of select="text()"></xsl:value-of>
98
- </xsl:copy>
99
- </xsl:template>
100
- <xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]">
101
- <xsl:element name="{local-name()}">
102
- <xsl:apply-templates mode="sanitize" select="@*"/>
103
- <xsl:value-of select="text()"></xsl:value-of>
104
- </xsl:element>
105
- </xsl:template>
106
- <xsl:template mode="sanitize" match="*|@*">
107
- <xsl:copy>
108
- <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
109
- </xsl:copy>
110
- </xsl:template>
111
- <xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
112
- <xsl:template mode="sanitize" match="text()">
113
- <dce-text>
114
- <xsl:copy/>
115
- </dce-text>
116
- </xsl:template>
117
- <xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']">
118
- <xsl:copy>
119
- <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
120
- </xsl:copy>
121
- </xsl:template>
122
- <xsl:template mode="sanitize" match="xhtml:*">
123
- <xsl:element name="{local-name()}">
124
- <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
125
- </xsl:element>
126
- </xsl:template>
127
- <xsl:template mode="sanitize" match="xhtml:input">
128
- <xsl:element name="{local-name()}">
129
- <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
130
- </xsl:element>
131
- <xsl:for-each select="*">
132
- <xsl:copy>
133
- <xsl:attribute name="for" >^</xsl:attribute>
134
- <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
135
- </xsl:copy>
136
- </xsl:for-each>
137
- </xsl:template>
138
- </xsl:stylesheet>`), s = new XSLTProcessor(), a = ((n) => {
139
- L(n, "custom-element", (b) => {
140
- b.firstElementChild.localName === "template" && ([...b.firstElementChild.content.childNodes].forEach((y) => b.append(y)), b.firstElementChild.remove());
141
- }), L(n, "script", (b) => b.remove());
142
- const c = n.content ?? n.firstElementChild?.content ?? n.body ?? n;
143
- we.forEach((b) => L(c, b, (y) => Te(y, c)));
144
- const N = n.firstElementChild?.content || n.content, E = (b) => {
145
- const y = X("<xhtml/>"), M = y.importNode(b, !0);
146
- return y.replaceChild(M, y.documentElement), ae(M);
147
- };
148
- if (N) {
149
- const b = w("div");
150
- return [...N.childNodes].map((y) => b.append(y.cloneNode(!0))), E(b);
151
- }
152
- return E(n.documentElement || n.body || n);
153
- })(e), i = X(
154
- `<xsl:stylesheet version="1.0"
155
- xmlns:xsl="${W}"
156
- xmlns:xhtml="${k}"
157
- xmlns:dce="urn:schemas-epa-wg:dce"
158
- xmlns:exsl="http://exslt.org/common"
159
- exclude-result-prefixes="exsl"
160
- >
161
- <xsl:template match="ignore">
162
- <xsl:choose>
163
- <xsl:when test="//attr">{//attr}</xsl:when>
164
- <xsl:otherwise>{def}</xsl:otherwise>
165
- </xsl:choose><xsl:value-of select="."></xsl:value-of></xsl:template>
166
- <xsl:template mode="payload" match="attributes"></xsl:template>
167
- <xsl:template match="/">
168
- <xsl:apply-templates mode="payload" select="/datadom/attributes"/>
169
- </xsl:template>
170
- <xsl:template name="slot" >
171
- <xsl:param name="slotname" />
172
- <xsl:param name="defaultvalue" />
173
- <xsl:choose>
174
- <xsl:when test="//payload/*[@slot=$slotname]">
175
- <xsl:copy-of select="//payload/*[@slot=$slotname]"/>
176
- </xsl:when>
177
- <xsl:otherwise>
178
- <xsl:copy-of select="$defaultvalue"/>
179
- </xsl:otherwise>
180
- </xsl:choose>
181
- </xsl:template>
182
- <xsl:variable name="js-injected-body">
183
- <xsl:call-template name="slot" >
184
- <xsl:with-param name="slotname" select="''"/>
185
- <xsl:with-param name="defaultvalue"/>
186
- </xsl:call-template>
187
- </xsl:variable>
188
- </xsl:stylesheet>`
189
- );
190
- s.importStylesheet(t);
191
- const r = s.transformToFragment(a, document), x = (n, c) => n.querySelector(c), p = x(i, 'template[mode="payload"]');
192
- if (!r)
193
- return console.error("transformation error", { xml: a.outerHTML, xsl: I(t) });
194
- if (r.firstElementChild.localName !== "dce-root") {
195
- const n = r.ownerDocument.createElement("dce-root");
196
- [...r.childNodes].forEach((c) => n.append(c)), r.append(n);
197
- }
198
- const u = [];
199
- [...r.querySelectorAll("dce-root>attribute")].forEach((n) => {
200
- K(n, "namespace,name,select");
201
- const c = J(n, "xsl:param"), N = f(n, "name");
202
- p.append(c), K(c, "select,name");
203
- let E = f(c, "select")?.split("??");
204
- E || (E = ["//" + N, `'${c.textContent}'`], V(c), c.setAttribute("name", N));
205
- let b;
206
- if (E?.length > 1) {
207
- c.removeAttribute("select");
208
- const y = x(i, 'template[match="ignore"]>choose').cloneNode(!0);
209
- V(y.firstElementChild).append($(y, "{" + E[0] + "}")), V(y.lastElementChild).append($(y, "{" + E[1] + "}")), y.firstElementChild.setAttribute("test", E[0]), c.append(y), b = y.cloneNode(!0);
210
- } else
211
- b = J(n, "xsl:value-of");
212
- b.removeAttribute("name"), n.append(b), n.removeAttribute("select"), u.push(c);
213
- }), [...r.querySelectorAll("[value]")].filter((n) => n.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach((n) => {
214
- const c = f(n, "value");
215
- c && n.setAttribute("value", Ae(c));
216
- });
217
- for (const n of r.childNodes)
218
- p.append(i.importNode(n, !0));
219
- [...p.getElementsByTagName("xsl:template")].forEach((n) => p.ownerDocument.documentElement.append(n));
220
- const q = x(i, 'call-template[name="slot"]'), d = (n) => {
221
- const c = q.cloneNode(!0), N = f(n, "name");
222
- N && c.firstElementChild.setAttribute("select", `'${N}'`);
223
- for (let E of n.childNodes)
224
- c.lastElementChild.append(E);
225
- return c;
226
- };
227
- L(p, "slot", (n) => n.parentNode.replaceChild(d(n), n));
228
- const m = ee(i);
229
- return m.params = u, m;
230
- }
231
- async function xe(e) {
232
- return await new Promise((t, s) => {
233
- const a = new XMLHttpRequest();
234
- a.open("GET", e), a.responseType = "document", a.onload = () => {
235
- a.readyState === a.DONE && a.status === 200 ? t(a.responseXML?.body || a.responseXML || w("div", a.responseText)) : s(`${a.statusText} - ${e}`);
236
- }, a.addEventListener("error", (i) => s(i)), a.send();
237
- });
238
- }
239
- function be(e, l, t = !1) {
240
- if (e === l)
241
- return !0;
242
- if (typeof e != "object" || e === null || typeof l != "object" || l === null || Object.keys(e).length !== Object.keys(l).length)
243
- return t;
244
- for (let s in e)
245
- if (!(s in l) || !be(e[s], l[s]))
246
- return t;
247
- return !0;
248
- }
249
- const ie = (e) => e.split("|").map((l) => l.trim()).filter((l) => l), ye = (e, l) => ie(l).map((t) => {
250
- let s = e.ownerDocument, a = (i) => (e.append(i), i);
251
- if (t.includes("/")) {
252
- const i = [], r = s.evaluate(t, e);
253
- for (let x; x = r.iterateNext(); )
254
- i.push(x);
255
- return i;
256
- }
257
- return [...e.childNodes].find((i) => i.localName === t) || a(w(t, "", s));
258
- }).flat();
259
- function te(e, l, t, s) {
260
- if (!t.sliceProcessed)
261
- return t.sliceProcessed = 1, ye(e, l ?? "").map((a) => {
262
- const i = e.ownerDocument, r = t.sliceEventSource, x = t.sliceElement, p = () => [...a.childNodes].filter((u) => u.nodeType === 3 || u.localName === "value" || u.localName === "form-data").map((u) => u.remove());
263
- if (r.getAttributeNames().map((u) => a.setAttribute(u, f(r, u))), [...a.childNodes].filter((u) => u.localName === "event").map((u) => u.remove()), "validationMessage" in r && a.setAttribute("validation-message", r.validationMessage), t.type === "init" && p(), a.append(D(t, "event", i)), x.hasAttribute("slice-value")) {
264
- r.value === void 0 ? a.removeAttribute("value") : a.setAttribute("value", r.value);
265
- const u = z(f(x, "slice-value"), a);
266
- p(), a.append($(i, u));
267
- } else {
268
- if ("elements" in r)
269
- return p(), a.append(D(new FormData(r), "value", a.ownerDocument)), a;
270
- const u = r.value ?? f(r, "value");
271
- p(), u == null ? [...a.childNodes].filter((T) => T.localName !== "event").map((T) => T.remove()) : de(u) ? a.append($(i, u)) : a.append(D(u, "value", a.ownerDocument));
272
- }
273
- return a;
274
- });
275
- }
276
- function L(e, l, t) {
277
- e.querySelectorAll && [...e.querySelectorAll(l)].forEach(t);
278
- }
279
- const ge = async (e, l) => {
280
- if (!e || !e.trim())
281
- return [l];
282
- if (e.startsWith("#"))
283
- return ((t) => {
284
- const s = t.querySelectorAll(e);
285
- return [...s.length ? s : t.getRootNode().querySelectorAll(e)];
286
- })(l.parentElement);
287
- try {
288
- const [t, s] = e.split("#");
289
- if (e.charAt(0) === ".")
290
- e = new URL(t, l.closest("[base]")?.getAttribute("base") || location).href;
291
- else
292
- try {
293
- e = import.meta.resolve(t), s && (e += "#" + s);
294
- } catch (i) {
295
- console.error(i.message);
296
- }
297
- const a = await xe(e);
298
- if (l.setAttributeNS("xml", "base", e), s) {
299
- const i = a.querySelectorAll("#" + s);
300
- return i.length ? [...i] : (console.error("template not found", e + "#" + s), [l]);
301
- }
302
- return [a];
303
- } catch {
304
- return [l];
305
- }
306
- };
307
- function ve(e, l) {
308
- for (let t of e.attributes)
309
- t.namespaceURI ? l.setAttributeNS(t.namespaceURI, t.name, t.value) : l.setAttribute(t.name, t.value), t.name === "value" && (l.value = t.value);
310
- }
311
- function oe(e, l = 0) {
312
- const t = {};
313
- for (const s of e.childNodes) {
314
- const a = f(s, "data-dce-id") || s.dceId || 0;
315
- if (!t[a])
316
- a ? t[a] = 1 : (t[a] = s.dceId = ++l, s.setAttribute && s.setAttribute("data-dce-id", s.dceId));
317
- else {
318
- const i = s.dceId = a + "-" + t[a]++;
319
- s.setAttribute && s.setAttribute("data-dce-id", i);
320
- }
321
- s.childNodes.length && oe(s);
322
- }
323
- }
324
- function Ee(e, l, t) {
325
- t = 1 * t;
326
- for (let s of e.childNodes)
327
- if ((s.dceId ?? s.getAttribute("data-dce-id") * 1) > t)
328
- return e.insertBefore(l, s);
329
- e.append(l);
330
- }
331
- function re(e, l) {
332
- if (e.firstElementChild?.localName === "dce-root" && l[0].localName !== "dce-root")
333
- return;
334
- if (!l.length)
335
- return e.firstElementChild?.localName !== "dce-root" && se(e);
336
- const t = {};
337
- for (let s of e.childNodes)
338
- t[s.dceId], Z(s) ? (s.data.trim(), t[s.dceId || 0] = s) : t[f(s, "data-dce-id") || 0] = s;
339
- for (let s of [...l]) {
340
- const a = f(s, "data-dce-id") || s.dceId, i = t[a];
341
- i ? (Z(s) ? i.nodeValue !== s.nodeValue && (i.nodeValue = s.nodeValue) : (ve(s, i), (i.childNodes.length || s.childNodes.length) && re(i, s.childNodes)), delete t[a]) : Ee(e, s, a);
342
- }
343
- for (let s of Object.values(t))
344
- s.localName !== "dce-root" && s.remove();
345
- }
346
- function Ne(e, l) {
347
- return e.hasAttribute(l) || e.setAttribute(l, crypto.randomUUID()), e.getAttribute(l);
348
- }
349
- const Ae = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `${t[1]}{${Y(t[3])}}${t[4]}`).join(""), Y = (e) => {
350
- if (!e.trim())
351
- return e;
352
- const l = e.split("??"), t = l.shift(), s = Y(l.join("??"));
353
- return l.length ? `concat( ${t} , substring( ${s} , (1+string-length( ${s} )) * string-length( ${t} ) ) )` : e;
354
- }, z = (e, l) => {
355
- const t = e.split("??");
356
- if (t.length > 1)
357
- return z(t[0], l) || z(t[1], l);
358
- e = Y(e);
359
- const s = l.ownerDocument.evaluate(e, l);
360
- switch (s.resultType) {
361
- case XPathResult.NUMBER_TYPE:
362
- return s.numberValue;
363
- case XPathResult.STRING_TYPE:
364
- return s.stringValue;
365
- case XPathResult.BOOLEAN_TYPE:
366
- return s.booleanValue;
367
- }
368
- let a = "";
369
- for (let i; i = s.iterateNext(); )
370
- a += i.textContent;
371
- return a;
372
- }, 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, l) => {
373
- const t = w("xsl:" + e.localName);
374
- for (let s of e.attributes)
375
- t.setAttribute(s.name, s.value);
376
- for (; e.firstChild; )
377
- t.append(e.firstChild);
378
- if (e.parentElement)
379
- e.parentElement.replaceChild(t, e);
380
- else {
381
- const s = e.parentElement || l, a = [...s.childNodes];
382
- a.forEach((i, r) => {
383
- i === e && (a[r] = t);
384
- }), s.replaceChildren(...a);
385
- }
386
- };
387
- class Se extends HTMLElement {
388
- static observedAttributes = ["src", "tag", "hidden"];
389
- async connectedCallback() {
390
- this.firstElementChild && this.firstElementChild.localName !== "template" && console.warn(`custom-element used without template wrapping content
391
- `, this.outerHTML);
392
- const l = await ge(f(this, "src"), this), t = f(this, "tag"), s = t || "dce-" + crypto.randomUUID();
393
- for (const d of l)
394
- L(d.templateNode || d.content || d, "style", (m) => {
395
- const n = m.closest("slot"), c = n ? `slot[name="${n.name}"]` : "";
396
- m.innerHTML = `${s} ${c}{${m.innerHTML}}`, this.append(m);
397
- });
398
- const a = l.map((d) => he(d)), i = a.map((d, m) => {
399
- m = new XSLTProcessor();
400
- try {
401
- m.importStylesheet(d);
402
- } catch (n) {
403
- console.error(n, I(d));
404
- }
405
- return m;
406
- });
407
- Object.defineProperty(this, "xsltString", { get: () => a.map((d) => I(d)).join(`
408
- `) });
409
- const r = this, x = [...this.templateNode.querySelectorAll("[slice]")], p = x.map((d) => f(d, "slice")).filter((d) => !d.includes("/")).filter((d, m, n) => n.indexOf(d) === m).map(ie).flat(), u = a.reduce((d, m) => (m.params && d.push(...m.params), d), []);
410
- class T extends HTMLElement {
411
- static get observedAttributes() {
412
- return u.map((m) => f(m, "name"));
413
- }
414
- #e = 0;
415
- connectedCallback() {
416
- let m = Q(this.childNodes);
417
- if (this.firstElementChild?.tagName === "TEMPLATE") {
418
- this.firstElementChild !== this.lastElementChild && console.error("payload should have TEMPLATE as only child", this.outerHTML);
419
- const h = this.firstElementChild;
420
- h.remove(), m = Q(h.content.childNodes);
421
- for (const g of m)
422
- if (g.localName === "style") {
423
- const o = Ne(this, "data-dce-style");
424
- g.innerHTML = `${s}[data-dce-style="${o}"]{${g.innerHTML}}`, h.insertAdjacentElement("beforebegin", g);
425
- } else
426
- g.nodeType === 1 ? h.insertAdjacentElement("beforebegin", g) : g.nodeType === 3 && h.insertAdjacentText("beforebegin", g.data);
427
- }
428
- const n = X("<datadom/>").documentElement, c = (h, g = "") => ((o) => (g && o.append($(n, g)), o))(n.ownerDocument.createElement(h)), N = H(n, "payload", m, fe);
429
- le(N), ae(N), this.innerHTML = "";
430
- const E = H(n, "attributes", this.attributes, (h) => c(h.nodeName, h.value));
431
- H(n, "dataset", Object.keys(this.dataset), (h) => c(h, this.dataset[h]));
432
- const b = H(n, "slice", p, (h) => c(h, "")), y = (h) => z(h, b);
433
- this.xml = n;
434
- const M = [], G = () => {
435
- const h = {};
436
- for (let g; g = M.pop(); ) {
437
- const o = f(g.sliceElement, "slice");
438
- h[o] || (te(b, o, g), h[o] = g);
439
- }
440
- Object.keys(h).length !== 0 && U();
441
- };
442
- let O;
443
- this.onSlice = (h) => {
444
- M.push(h), O || (O = setTimeout(() => {
445
- G(), O = 0;
446
- }, 1));
447
- };
448
- const U = this.transform = () => {
449
- if (this.#e)
450
- debugger;
451
- this.#e = 1, i.map((o, v) => {
452
- const S = o.transformToFragment(n.ownerDocument, document);
453
- return S || console.error(`XSLT transformation error. xsl:
454
- `, I(a[v]), `
455
- xml:
456
- `, I(n)), S;
457
- }).map((o) => {
458
- o && (oe(o), re(this, o.childNodes));
459
- }), T.observedAttributes.map((o) => {
460
- let v = f(this.firstElementChild, o);
461
- v !== f(this, o) && (this.setAttribute(o, v), this.#t(o, v));
462
- });
463
- function g(o) {
464
- let v = o;
465
- if (o.localName === "slice") {
466
- const S = f(o, "for");
467
- if (S || (v = o.parentElement), S === "^")
468
- do
469
- v = v.previousElementSibling;
470
- while (v.localName === "slice");
471
- else
472
- v = this.querySelector(S);
473
- if (!v)
474
- return console.warn(`can not find selector in "slice for=${S}" `, o.outerHTML);
475
- f(o, "slice") || o.setAttribute("slice", f(o, "name"));
476
- }
477
- return v;
478
- }
479
- L(this, "[slice],[slice-event]", (o) => {
480
- let v = f(o, "slice-event");
481
- const S = o.hasAttribute("slice-value") || o.hasAttribute("value") || o.value, j = g(o);
482
- o.dceInitialized || (o.dceInitialized = 1, j.hasAttribute("custom-validity") && (v += " change submit"), [...new Set((v || "change").split(" "))].forEach((ce) => j.addEventListener(ce, (A) => {
483
- A.sliceElement = o, A.sliceEventSource = A.currentTarget || A.target, A.sliceProcessed = 0;
484
- const me = te(b, f(A.sliceElement, "slice"), A);
485
- L(this, "[custom-validity]", (P) => {
486
- if (!P.setCustomValidity)
487
- return;
488
- const F = f(P, "custom-validity");
489
- try {
490
- const R = F && z(F, E);
491
- P.setCustomValidity(R === !0 ? "" : R === !1 ? "invalid" : R);
492
- } catch (R) {
493
- console.error(R, "xPath", F);
494
- }
495
- });
496
- const _ = f(j, "custom-validity"), C = _ && z(_, E), B = C === !0 ? "" : C;
497
- if (_) {
498
- if (o.setCustomValidity ? o.setCustomValidity(B) : o.validationMessage = B, me.map((P) => P.setAttribute("validation-message", B)), A.type === "submit")
499
- return C === !0 ? void 0 : (setTimeout(U, 1), !!C === C ? (C || A.preventDefault(), C) : C ? (A.preventDefault(), !1) : void 0);
500
- setTimeout(U, 1);
501
- }
502
- this.onSlice(A);
503
- })), (!v || v.includes("init")) && (S ? this.onSlice({ type: "init", target: j, sliceElement: o, sliceEventSource: j }) : o.value = y(f(o, "slice"))));
504
- }), this.#e = 0;
505
- };
506
- U(), G();
507
- }
508
- #t(m, n) {
509
- m === "value" && (this.value = n);
510
- let c = this.xml.querySelector(`attributes>${m}`);
511
- c ? V(c).append($(c, n)) : (c = w(m, n, this.xml), this.xml.querySelector("attributes").append(c)), this.dispatchEvent(new CustomEvent("change", { bubbles: !0, detail: { [m]: n } }));
512
- }
513
- attributeChangedCallback(m, n, c) {
514
- !this.xml || this.#e || (this.#t(m, c), this.transform());
515
- }
516
- get dce() {
517
- return r;
518
- }
519
- }
520
- const q = (d) => {
521
- window.customElements.get(d) !== T && window.customElements.define(d, T);
522
- };
523
- if (t)
524
- q(t);
525
- else {
526
- const d = s;
527
- this.setAttribute("tag", d), q(d);
528
- const m = document.createElement(d);
529
- this.getAttributeNames().forEach((n) => m.setAttribute(n, this.getAttribute(n))), m.append(...[...this.childNodes].filter((n) => n.localName !== "style")), this.append(m);
530
- }
531
- }
532
- get templateNode() {
533
- return this.firstElementChild?.tagName === "TEMPLATE" ? this.firstElementChild.content : this;
534
- }
535
- get dce() {
536
- return this;
537
- }
538
- get xslt() {
539
- return X(this.xsltString);
540
- }
541
- }
542
- window.customElements.define("custom-element", Se);
543
- export {
544
- Se as C,
545
- I as a,
546
- xe as b,
547
- he as c,
548
- be as d,
549
- ye as e,
550
- te as f,
551
- oe as g,
552
- Ee as h,
553
- re as i,
554
- Ne as j,
555
- Ae as k,
556
- Y as l,
557
- ve as m,
558
- z as n,
559
- D as o,
560
- we as p,
561
- Te as q,
562
- Q as s,
563
- ee as t,
564
- X as x
565
- };