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