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