@epa-wg/custom-element-dist 0.0.21 → 0.0.23
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/.gitignore +8 -0
- package/README.md +4 -4
- package/coverage/coverage-final.json +13 -11
- package/coverage/index.html +30 -30
- 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 +603 -420
- 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 +2 -2
- package/coverage/src/custom-element/location-element.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/{css.stories.ts → attributes.test.stories.ts}/coverage.svg +1 -1
- package/coverage/src/stories/{attributes.stories.ts.html → attributes.test.stories.ts.html} +113 -83
- package/coverage/src/stories/coverage.svg +1 -1
- package/coverage/src/stories/css.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/{css.stories.ts.html → css.test.stories.ts.html} +122 -65
- package/coverage/src/stories/dom-merge.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/{dom-merge.stories.ts.html → dom-merge.test.stories.ts.html} +118 -70
- package/coverage/src/stories/external-template.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/{external-template.stories.ts.html → external-template.test.stories.ts.html} +180 -150
- package/coverage/src/stories/form.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/form.test.stories.ts.html +655 -0
- package/coverage/src/stories/http-request.stories.ts.html +7 -7
- package/coverage/src/stories/index.html +118 -88
- package/coverage/src/stories/{dom-merge.stories.ts → local-storage.test.stories.ts}/coverage.svg +1 -1
- package/coverage/src/stories/{local-storage.stories.ts.html → local-storage.test.stories.ts.html} +475 -439
- package/coverage/src/stories/{external-template.stories.ts → location-element.test.stories.ts}/coverage.svg +1 -1
- package/coverage/src/stories/{location-element.stories.ts.html → location-element.test.stories.ts.html} +134 -98
- package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/slice-events.test.stories.ts.html +685 -0
- package/coverage/src/stories/slots.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/slots.test.stories.ts.html +736 -0
- package/coverage/src/stories/{renderPlay.ts.html → testStoryBook.ts.html} +44 -26
- package/coverage/src/sum.ts.html +1 -1
- package/dist/custom-element-BISbI4SU.js +463 -0
- package/dist/custom-element-N-sWiqGK.cjs +53 -0
- package/dist/custom-element-bundle.cjs +1 -1
- package/dist/custom-element-bundle.js +2 -2
- package/dist/mockServiceWorker.js +1 -1
- package/package.json +4 -4
- package/public/mockServiceWorker.js +1 -1
- package/src/custom-element/custom-element.d.ts +4 -0
- package/src/custom-element/custom-element.js +103 -42
- package/src/custom-element/demo/a.html +38 -41
- package/src/custom-element/demo/b.html +13 -0
- package/src/custom-element/demo/data-slices.html +32 -0
- package/src/custom-element/demo/form.html +240 -0
- package/src/custom-element/demo/s.xml +11 -14
- package/src/custom-element/demo/s.xslt +22 -38
- package/src/custom-element/demo/s1.xslt +60 -0
- package/src/custom-element/ide/customData-dce.json +14 -1
- package/src/custom-element/ide/web-types-dce.json +6 -1
- package/src/custom-element/ide/web-types-xsl.json +1 -1
- package/src/custom-element/index.html +1 -0
- package/src/custom-element.test.ts +24 -8
- package/src/stories/{attributes.stories.ts → attributes.test.stories.ts} +19 -9
- package/src/stories/{css.stories.ts → css.test.stories.ts} +28 -9
- package/src/stories/{dom-merge.stories.ts → dom-merge.test.stories.ts} +19 -3
- package/src/stories/{external-template.stories.ts → external-template.test.stories.ts} +13 -3
- package/src/stories/form.test.stories.ts +190 -0
- package/src/stories/http-request.stories.ts +6 -6
- package/src/stories/http-request.test.ts +0 -9
- package/src/stories/{local-storage.stories.ts → local-storage.test.stories.ts} +24 -12
- package/src/stories/{location-element.stories.ts → location-element.test.stories.ts} +21 -9
- package/src/stories/{slice-events.stories.ts → slice-events.test.stories.ts} +88 -5
- package/src/stories/slots.test.stories.ts +217 -0
- package/src/stories/testStoryBook.ts +28 -0
- package/storybook-static/assets/{Color-RQJUDNI5-C4yZhNbM.js → Color-PRSJMWNM-BD_Ds9NW.js} +1 -1
- package/storybook-static/assets/{Configure-C7d36rng.js → Configure-70I_VApa.js} +1 -1
- package/storybook-static/assets/DocsRenderer-K4EAMTCU-9dn0-HCP.js +2 -0
- package/storybook-static/assets/WithTooltip-KJL26V4Q-C6g5GOU9.js +1 -0
- package/storybook-static/assets/{attributes.stories-ZB0RTY1d.js → attributes.test.stories-BEOraI4E.js} +22 -21
- package/storybook-static/assets/css.test.stories-D9WaxrEv.js +96 -0
- package/storybook-static/assets/custom-element-BV8-hRQS.js +219 -0
- package/storybook-static/assets/{dom-merge.stories-CgHZUABU.js → dom-merge.test.stories-BhbNeum_.js} +5 -6
- package/storybook-static/assets/{entry-preview-CQqNFx4W.js → entry-preview-DrgzXgwT.js} +1 -1
- package/storybook-static/assets/{entry-preview-docs-CWgqLfd3.js → entry-preview-docs-Bxv0qQWs.js} +1 -1
- package/storybook-static/assets/{external-template.stories-DtSLMxvg.js → external-template.test.stories-Bpr_wxBo.js} +23 -24
- package/storybook-static/assets/form.test.stories-3tURbEdv.js +250 -0
- package/storybook-static/assets/{formatter-B5HCVTEV-tKeEfJA9.js → formatter-2WMMO6ZP-6IvBq34u.js} +5 -5
- package/storybook-static/assets/http-request.stories-8K_qSs8C.js +300 -0
- package/storybook-static/assets/iframe-zdt9kuj6.js +2 -0
- package/storybook-static/assets/index-B3oZkK3F.js +1 -0
- package/storybook-static/assets/index-C30JwJMK.js +548 -0
- package/storybook-static/assets/index-CVRyq5ci.js +27 -0
- package/storybook-static/assets/index-DXimoRZY.js +1 -0
- package/storybook-static/assets/{index-DnEJ_bKa.js → index-DhXZyjEd.js} +1 -1
- package/storybook-static/assets/index-DuIEV_9C.js +13 -0
- package/storybook-static/assets/{lit-element-B4_0akdT.js → lit-element-CenEXOuS.js} +2 -2
- package/storybook-static/assets/{local-storage.stories-BkO6djDz.js → local-storage.test.stories-CtisAQBB.js} +28 -24
- package/storybook-static/assets/{location-element.stories-DCIOUd0D.js → location-element.test.stories-5O_t_m4Y.js} +11 -11
- package/storybook-static/assets/preview-4Up_z4Em.js +7 -0
- package/storybook-static/assets/preview-BKCN0mOr.js +1 -0
- package/storybook-static/assets/{preview-CkgAD_DE.js → preview-D0eCfQft.js} +2 -2
- package/storybook-static/assets/preview-DRnyIGXK.js +48 -0
- package/storybook-static/assets/preview-FpHGYA1q.js +1 -0
- package/storybook-static/assets/{preview-PxUn-cIn.js → preview-TCN6m6T-.js} +1 -1
- package/storybook-static/assets/slice-events.test.stories-BSXCLIA5.js +231 -0
- package/storybook-static/assets/slots.test.stories-B1vqfHmN.js +214 -0
- package/storybook-static/assets/syntaxhighlighter-BP7B2CQK-DpPBKyTO.js +1 -0
- package/storybook-static/iframe.html +153 -10
- package/storybook-static/index.html +1 -1
- package/storybook-static/index.json +1 -1
- package/storybook-static/mockServiceWorker.js +1 -1
- package/storybook-static/project.json +1 -1
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js +35 -29
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js.LEGAL.txt +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 +5 -5
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +35 -35
- 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-10/manager-bundle.js +18 -16
- package/storybook-static/sb-addons/links-1/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +1 -1
- package/storybook-static/sb-manager/WithTooltip-KJL26V4Q-5LS5AN27.js +1 -0
- package/storybook-static/sb-manager/{chunk-S4VOIVUE.js → chunk-B3YDJJJH.js} +9 -9
- package/storybook-static/sb-manager/{chunk-FEE35O7J.js → chunk-BLWCBWKL.js} +3 -3
- package/storybook-static/sb-manager/{chunk-XCO5HRLK.js → chunk-GUVK2GTO.js} +3 -3
- package/storybook-static/sb-manager/chunk-LFRML3ZV.js +186 -0
- package/storybook-static/sb-manager/chunk-MC7RAF2B.js +274 -0
- package/storybook-static/sb-manager/{chunk-XP3HGWTR.js → chunk-ZR5JZWHI.js} +1 -1
- package/storybook-static/sb-manager/{formatter-B5HCVTEV-7DCBOGO6.js → formatter-2WMMO6ZP-JI7RHVTW.js} +1 -1
- package/storybook-static/sb-manager/globals-module-info.js +1 -1
- package/storybook-static/sb-manager/globals-runtime.js +1 -1
- package/storybook-static/sb-manager/index.js +1 -1
- package/storybook-static/sb-manager/runtime.js +1 -1
- package/storybook-static/sb-manager/{syntaxhighlighter-JOJW2KGS-VF6EEVPI.js → syntaxhighlighter-BP7B2CQK-WOJYHKQR.js} +1 -1
- package/storybook-static/sb-preview/runtime.js +28 -11
- package/tsconfig.json +31 -21
- package/vite.config.js +5 -5
- package/yarn.lock +10242 -0
- package/.vscode/settings.json +0 -24
- package/coverage/src/stories/local-storage.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/location-element.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/renderPlay.ts/coverage.svg +0 -10
- package/coverage/src/stories/slice-events.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/slice-events.stories.ts.html +0 -436
- package/dist/custom-element-B4v-KaIh.cjs +0 -53
- package/dist/custom-element-_g0GTup2.js +0 -436
- package/src/stories/attributes.test.ts +0 -14
- package/src/stories/css.test.ts +0 -12
- package/src/stories/dom-merge.test.ts +0 -12
- package/src/stories/external-template.test.ts +0 -12
- package/src/stories/local-storage.test.ts +0 -12
- package/src/stories/location-element.test.ts +0 -14
- package/src/stories/renderPlay.ts +0 -22
- package/src/stories/slice-events.test.ts +0 -12
- package/storybook-static/assets/DocsRenderer-K4EAMTCU-BLMupvSb.js +0 -2
- package/storybook-static/assets/WithTooltip-Y7J54OF7-BAQSPSFk.js +0 -1
- package/storybook-static/assets/css.stories-CLSX-Xxd.js +0 -86
- package/storybook-static/assets/custom-element-BLZZ00dz.js +0 -53
- package/storybook-static/assets/http-request.stories-CUzlXO89.js +0 -300
- package/storybook-static/assets/iframe-gCvlWuoC.js +0 -2
- package/storybook-static/assets/index-CBQwM6ST.js +0 -508
- package/storybook-static/assets/index-CDavW7r9.js +0 -193
- package/storybook-static/assets/index-CQA5dlr6.js +0 -13
- package/storybook-static/assets/index-DgaNIR0t.js +0 -1
- package/storybook-static/assets/index-Dkj0J1ds.js +0 -1
- package/storybook-static/assets/preview-C6t8KBFr.js +0 -1
- package/storybook-static/assets/preview-CYD85dwb.js +0 -7
- package/storybook-static/assets/preview-D8LadFCz.js +0 -48
- package/storybook-static/assets/preview-DNpCpRPf.js +0 -1
- package/storybook-static/assets/slice-events.stories-DXKjXI37.js +0 -115
- package/storybook-static/assets/syntaxhighlighter-JOJW2KGS-C04pIVD3.js +0 -1
- package/storybook-static/sb-manager/WithTooltip-Y7J54OF7-CEHQ77YF.js +0 -1
- package/storybook-static/sb-manager/chunk-E3WK6ZOZ.js +0 -234
- package/storybook-static/sb-manager/chunk-E6ABNH5R.js +0 -183
- /package/coverage/src/stories/{attributes.stories.ts → testStoryBook.ts}/coverage.svg +0 -0
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
const q = "http://www.w3.org/1999/XSL/Transform", z = "http://www.w3.org/1999/xhtml", W = "http://exslt.org/common", h = (e, l) => e.getAttribute?.(l), I = (e) => e.nodeType === 3, G = (e) => typeof e == "string", Y = (e) => e && typeof e.nodeType == "number", E = (e, l = "", t = document) => ((s) => (l && s.append(w(t.ownerDocument || t, l)), s))((t.ownerDocument || t).createElement(e)), w = (e, l) => (e.ownerDocument || e).createTextNode(l), O = (e) => {
|
|
2
|
-
for (; e.firstChild; )
|
|
3
|
-
e.firstChild.remove();
|
|
4
|
-
return e;
|
|
5
|
-
}, j = (e) => (e.getAttributeNames().map((l) => e.removeAttribute(l)), O(e)), J = (e) => (e?.setAttribute("xmlns:xsl", q), e), K = (e) => (e?.setAttribute("xmlns:xhtml", z), J(e)), k = (e, l) => {
|
|
6
|
-
const t = e.ownerDocument.createElementNS(e.namespaceURI, l);
|
|
7
|
-
for (let s of e.attributes)
|
|
8
|
-
t.setAttribute(s.name, s.value);
|
|
9
|
-
for (; e.firstChild; )
|
|
10
|
-
t.append(e.firstChild);
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
function C(e) {
|
|
14
|
-
return new DOMParser().parseFromString(e, "application/xml");
|
|
15
|
-
}
|
|
16
|
-
function R(e) {
|
|
17
|
-
return new XMLSerializer().serializeToString(e);
|
|
18
|
-
}
|
|
19
|
-
function D(e, l, t, s) {
|
|
20
|
-
const n = (p) => e.ownerDocument.createElement(p), f = ((p, y, u) => (y.append(u = n(p)), u))(l, e);
|
|
21
|
-
return [...t].forEach((p) => f.append(s(p))), f;
|
|
22
|
-
}
|
|
23
|
-
function Q(e) {
|
|
24
|
-
return e.slot || (e.setAttribute || (e = E("span", e.textContent.replaceAll(`
|
|
25
|
-
`, ""))), e.setAttribute("slot", "")), e;
|
|
26
|
-
}
|
|
27
|
-
function X(e, l, t) {
|
|
28
|
-
const s = typeof e;
|
|
29
|
-
if (s === "function")
|
|
30
|
-
debugger;
|
|
31
|
-
if (s === "string")
|
|
32
|
-
return E(l, e, t);
|
|
33
|
-
if (s === "number")
|
|
34
|
-
return E(l, "" + e, t);
|
|
35
|
-
if (e instanceof Array) {
|
|
36
|
-
const r = E("array");
|
|
37
|
-
return e.map((f) => r.append(X(f, l, t))), r;
|
|
38
|
-
}
|
|
39
|
-
const n = E(l, "", t);
|
|
40
|
-
for (let r in e)
|
|
41
|
-
Y(e[r]) || typeof e[r] == "function" || e[r] instanceof Window || (typeof e[r] != "object" ? n.setAttribute(r, e[r]) : n.append(X(e[r], r, t)));
|
|
42
|
-
return n;
|
|
43
|
-
}
|
|
44
|
-
function H(e) {
|
|
45
|
-
if (S(e, "*", (l) => [...l.childNodes].filter((t) => t.nodeType === 3).forEach((t) => {
|
|
46
|
-
if (t.parentNode.localName === "style")
|
|
47
|
-
return;
|
|
48
|
-
const s = t.data.matchAll(/{([^}]*)}/g);
|
|
49
|
-
if (s) {
|
|
50
|
-
let n = 0, r = (p) => w(t, p || ""), f = [];
|
|
51
|
-
if ([...s].forEach((p) => {
|
|
52
|
-
p.index > n && f.push(r(p.input.substring(n, p.index)));
|
|
53
|
-
const y = e.querySelector("value-of").cloneNode();
|
|
54
|
-
y.setAttribute("select", p[1]), f.push(y), n = p.index + p[0].length;
|
|
55
|
-
}), n < t.data.length && f.push(r(t.data.substring(n, t.data.length))), f.length) {
|
|
56
|
-
for (let p of f)
|
|
57
|
-
l.insertBefore(p, t);
|
|
58
|
-
l.removeChild(t);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
})), "all" in e) {
|
|
62
|
-
let l = 1;
|
|
63
|
-
for (let t of e.all)
|
|
64
|
-
t.setAttribute && !t.tagName.startsWith("xsl:") && t.setAttribute("data-dce-id", "" + l++);
|
|
65
|
-
}
|
|
66
|
-
return e;
|
|
67
|
-
}
|
|
68
|
-
function Z(e, l = "xsl:stylesheet") {
|
|
69
|
-
if (e.tagName === l || e.documentElement?.tagName === l)
|
|
70
|
-
return H(e);
|
|
71
|
-
const t = C(`<xsl:stylesheet version="1.0" xmlns:xsl="${q}" xmlns:xhtml="${z}" xmlns:exsl="${W}" exclude-result-prefixes="exsl" >
|
|
72
|
-
<xsl:output method="xml" />
|
|
73
|
-
<xsl:template match="/"><dce-root xmlns="${z}"><xsl:apply-templates select="*"/></dce-root></xsl:template>
|
|
74
|
-
<xsl:template match="*[name()='template']"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
|
|
75
|
-
<xsl:template match="*"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
|
|
76
|
-
<xsl:template match="*[name()='svg']|*[name()='math']"><xsl:apply-templates mode="sanitize" select="."/></xsl:template>
|
|
77
|
-
<xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]"><xsl:copy><xsl:apply-templates mode="sanitize" select="@*"/><xsl:value-of select="text()"></xsl:value-of></xsl:copy></xsl:template>
|
|
78
|
-
<xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="@*"/><xsl:value-of select="text()"></xsl:value-of></xsl:element></xsl:template>
|
|
79
|
-
<xsl:template mode="sanitize" match="*|@*"><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></xsl:template>
|
|
80
|
-
<xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
|
|
81
|
-
<xsl:template mode="sanitize" match="text()"><dce-text><xsl:copy/></dce-text></xsl:template>
|
|
82
|
-
<xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']"><dce-text><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></dce-text></xsl:template>
|
|
83
|
-
<xsl:template mode="sanitize" match="xhtml:*"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:element></xsl:template>
|
|
84
|
-
</xsl:stylesheet>`), s = new XSLTProcessor(), n = ((a) => {
|
|
85
|
-
S(a, "script", (g) => g.remove());
|
|
86
|
-
const i = a.content ?? a.firstElementChild?.content ?? a.body ?? a;
|
|
87
|
-
ie.forEach((g) => S(i, g, (x) => ce(x, i)));
|
|
88
|
-
const N = a.firstElementChild?.content || a.content, v = (g) => {
|
|
89
|
-
const x = C("<xhtml/>"), T = x.importNode(g, !0);
|
|
90
|
-
return x.replaceChild(T, x.documentElement), K(T);
|
|
91
|
-
};
|
|
92
|
-
if (N) {
|
|
93
|
-
const g = E("div");
|
|
94
|
-
return [...N.childNodes].map((x) => g.append(x.cloneNode(!0))), v(g);
|
|
95
|
-
}
|
|
96
|
-
return v(a.documentElement || a.body || a);
|
|
97
|
-
})(e), r = C(
|
|
98
|
-
`<xsl:stylesheet version="1.0"
|
|
99
|
-
xmlns:xsl="${q}"
|
|
100
|
-
xmlns:xhtml="${z}"
|
|
101
|
-
xmlns:dce="urn:schemas-epa-wg:dce"
|
|
102
|
-
xmlns:exsl="http://exslt.org/common"
|
|
103
|
-
exclude-result-prefixes="exsl"
|
|
104
|
-
>
|
|
105
|
-
<xsl:template match="ignore">
|
|
106
|
-
<xsl:choose>
|
|
107
|
-
<xsl:when test="//attr">{//attr}</xsl:when>
|
|
108
|
-
<xsl:otherwise>{def}</xsl:otherwise>
|
|
109
|
-
</xsl:choose><xsl:value-of select="."></xsl:value-of></xsl:template>
|
|
110
|
-
<xsl:template mode="payload" match="attributes"></xsl:template>
|
|
111
|
-
<xsl:template match="/">
|
|
112
|
-
<xsl:apply-templates mode="payload" select="/datadom/attributes"/>
|
|
113
|
-
</xsl:template>
|
|
114
|
-
<xsl:template name="slot" >
|
|
115
|
-
<xsl:param name="slotname" />
|
|
116
|
-
<xsl:param name="defaultvalue" />
|
|
117
|
-
<xsl:choose>
|
|
118
|
-
<xsl:when test="//payload/*[@slot=$slotname]">
|
|
119
|
-
<xsl:copy-of select="//payload/*[@slot=$slotname]"/>
|
|
120
|
-
</xsl:when>
|
|
121
|
-
<xsl:otherwise>
|
|
122
|
-
<xsl:copy-of select="$defaultvalue"/>
|
|
123
|
-
</xsl:otherwise>
|
|
124
|
-
</xsl:choose>
|
|
125
|
-
</xsl:template>
|
|
126
|
-
<xsl:variable name="js-injected-body">
|
|
127
|
-
<xsl:call-template name="slot" >
|
|
128
|
-
<xsl:with-param name="slotname" select="''"/>
|
|
129
|
-
<xsl:with-param name="defaultvalue"/>
|
|
130
|
-
</xsl:call-template>
|
|
131
|
-
</xsl:variable>
|
|
132
|
-
</xsl:stylesheet>`
|
|
133
|
-
);
|
|
134
|
-
s.importStylesheet(t);
|
|
135
|
-
const f = s.transformToFragment(n, document), p = (a, i) => a.querySelector(i), y = p(r, 'template[mode="payload"]');
|
|
136
|
-
if (!f)
|
|
137
|
-
return console.error("transformation error", { xml: n.outerHTML, xsl: R(t) });
|
|
138
|
-
const u = [];
|
|
139
|
-
[...f.querySelectorAll("dce-root>attribute")].forEach((a) => {
|
|
140
|
-
const i = k(a, "xsl:param"), N = h(a, "name");
|
|
141
|
-
y.append(i);
|
|
142
|
-
let v = h(i, "select")?.split("??");
|
|
143
|
-
v || (v = ["//" + N, `'${i.textContent}'`], j(i), i.setAttribute("name", N));
|
|
144
|
-
let g;
|
|
145
|
-
if (v?.length > 1) {
|
|
146
|
-
i.removeAttribute("select");
|
|
147
|
-
const x = p(r, 'template[match="ignore"]>choose').cloneNode(!0);
|
|
148
|
-
j(x.firstElementChild).append(w(x, "{" + v[0] + "}")), j(x.lastElementChild).append(w(x, "{" + v[1] + "}")), x.firstElementChild.setAttribute("test", v[0]), i.append(x), g = x.cloneNode(!0);
|
|
149
|
-
} else
|
|
150
|
-
g = k(a, "xsl:value-of");
|
|
151
|
-
g.removeAttribute("name"), a.append(g), a.removeAttribute("select"), u.push(i);
|
|
152
|
-
}), [...f.querySelectorAll("[value]")].filter((a) => a.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach((a) => {
|
|
153
|
-
const i = h(a, "value");
|
|
154
|
-
i && a.setAttribute("value", oe(i));
|
|
155
|
-
});
|
|
156
|
-
for (const a of f.childNodes)
|
|
157
|
-
y.append(r.importNode(a, !0));
|
|
158
|
-
[...y.querySelectorAll("template")].forEach((a) => y.ownerDocument.documentElement.append(a));
|
|
159
|
-
const $ = p(r, 'call-template[name="slot"]'), d = (a) => {
|
|
160
|
-
const i = $.cloneNode(!0), N = h(a, "name") || "";
|
|
161
|
-
N && i.firstElementChild.setAttribute("select", `'${N}'`);
|
|
162
|
-
for (let v of a.childNodes)
|
|
163
|
-
i.lastElementChild.append(v);
|
|
164
|
-
return i;
|
|
165
|
-
};
|
|
166
|
-
S(y, "slot", (a) => a.parentNode.replaceChild(d(a), a));
|
|
167
|
-
const c = H(r);
|
|
168
|
-
return c.params = u, c;
|
|
169
|
-
}
|
|
170
|
-
async function ee(e) {
|
|
171
|
-
return await new Promise((t, s) => {
|
|
172
|
-
const n = new XMLHttpRequest();
|
|
173
|
-
n.open("GET", e), n.responseType = "document", n.onload = () => {
|
|
174
|
-
n.readyState === n.DONE && n.status === 200 && t(n.responseXML || E("div", n.responseText)), s(n.statusText);
|
|
175
|
-
}, n.addEventListener("error", (r) => s(r)), n.send();
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function te(e, l, t = !1) {
|
|
179
|
-
if (e === l)
|
|
180
|
-
return !0;
|
|
181
|
-
if (typeof e != "object" || e === null || typeof l != "object" || l === null || Object.keys(e).length !== Object.keys(l).length)
|
|
182
|
-
return t;
|
|
183
|
-
for (let s in e)
|
|
184
|
-
if (!(s in l) || !te(e[s], l[s]))
|
|
185
|
-
return t;
|
|
186
|
-
return !0;
|
|
187
|
-
}
|
|
188
|
-
const se = (e, l) => l.split("|").map((t) => t.trim()).map((t) => {
|
|
189
|
-
if (t.includes("/")) {
|
|
190
|
-
const s = [], n = e.ownerDocument.evaluate(t, e);
|
|
191
|
-
for (let r; r = n.iterateNext(); )
|
|
192
|
-
s.push(r);
|
|
193
|
-
return s;
|
|
194
|
-
}
|
|
195
|
-
return [...e.childNodes].find((s) => s.localName === t) || E(t);
|
|
196
|
-
}).flat();
|
|
197
|
-
function le(e, l, t, s) {
|
|
198
|
-
se(e, l).map((n) => {
|
|
199
|
-
const r = e.ownerDocument, f = t.sliceEventSource, p = t.sliceElement, y = () => [...n.childNodes].filter((u) => u.nodeType === 3 || u.localName === "value").map((u) => u.remove());
|
|
200
|
-
if (f.getAttributeNames().map((u) => n.setAttribute(u, h(f, u))), [...n.childNodes].filter((u) => u.localName === "event").map((u) => u.remove()), t.type === "init" && y(), n.append(X(t, "event", r)), p.hasAttribute("slice-value")) {
|
|
201
|
-
f.value === void 0 ? n.removeAttribute("value") : n.setAttribute("value", f.value);
|
|
202
|
-
const u = B(h(p, "slice-value"), n);
|
|
203
|
-
y(), n.append(w(r, u));
|
|
204
|
-
} else {
|
|
205
|
-
const u = f.value ?? h(p, "value");
|
|
206
|
-
y(), u == null ? [...n.childNodes].filter((A) => A.localName !== "event").map((A) => A.remove()) : G(u) ? n.append(w(r, u)) : n.append(X(u, "value", n.ownerDocument));
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
function S(e, l, t) {
|
|
211
|
-
e.querySelectorAll && [...e.querySelectorAll(l)].forEach(t);
|
|
212
|
-
}
|
|
213
|
-
const V = (e, l) => ((t) => e === t ? null : t && (t.querySelector(l) || V(t, l)))(e.getRootNode()), ne = async (e, l) => {
|
|
214
|
-
if (!e || !e.trim())
|
|
215
|
-
return [l];
|
|
216
|
-
if (e.startsWith("#"))
|
|
217
|
-
return ((t) => {
|
|
218
|
-
if (!t)
|
|
219
|
-
return [];
|
|
220
|
-
const s = t.querySelectorAll(e);
|
|
221
|
-
if (s.length)
|
|
222
|
-
return [...s];
|
|
223
|
-
const n = t.getRootNode();
|
|
224
|
-
return n === t ? [] : V(n);
|
|
225
|
-
})(l.parentElement);
|
|
226
|
-
try {
|
|
227
|
-
const t = await ee(e), s = new URL(e, location).hash;
|
|
228
|
-
if (s) {
|
|
229
|
-
const n = t.querySelectorAll(s);
|
|
230
|
-
return n.length ? [...n] : [l];
|
|
231
|
-
}
|
|
232
|
-
return [t];
|
|
233
|
-
} catch {
|
|
234
|
-
return [l];
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
function ae(e, l) {
|
|
238
|
-
if (I(e)) {
|
|
239
|
-
if (!I(l))
|
|
240
|
-
debugger;
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
for (let t of e.attributes)
|
|
244
|
-
t.namespaceURI ? l.setAttributeNS(t.namespaceURI, t.name, t.value) : l.setAttribute(t.name, t.value), t.name === "value" && (l.value = t.value);
|
|
245
|
-
}
|
|
246
|
-
function _(e, l = 0) {
|
|
247
|
-
const t = {};
|
|
248
|
-
for (const s of e.childNodes) {
|
|
249
|
-
const n = h(s, "data-dce-id") || s.dceId || 0;
|
|
250
|
-
if (!t[n])
|
|
251
|
-
n ? t[n] = 1 : (t[n] = s.dceId = ++l, s.setAttribute && s.setAttribute("data-dce-id", s.dceId));
|
|
252
|
-
else {
|
|
253
|
-
const r = s.dceId = n + "-" + t[n]++;
|
|
254
|
-
s.setAttribute && s.setAttribute("data-dce-id", r);
|
|
255
|
-
}
|
|
256
|
-
s.childNodes.length && _(s);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function F(e, l) {
|
|
260
|
-
if (!l.length)
|
|
261
|
-
return O(e);
|
|
262
|
-
const t = {};
|
|
263
|
-
for (let s of e.childNodes)
|
|
264
|
-
t[s.dceId], I(s) ? (s.data.trim(), t[s.dceId || 0] = s) : t[h(s, "data-dce-id") || 0] = s;
|
|
265
|
-
for (let s of [...l]) {
|
|
266
|
-
const n = h(s, "data-dce-id") || s.dceId, r = t[n];
|
|
267
|
-
r ? (I(s) ? r.nodeValue !== s.nodeValue && (r.nodeValue = s.nodeValue) : (ae(s, r), (r.childNodes.length || s.childNodes.length) && F(r, s.childNodes)), delete t[n]) : e.append(s);
|
|
268
|
-
}
|
|
269
|
-
for (let s of Object.values(t))
|
|
270
|
-
s.remove();
|
|
271
|
-
}
|
|
272
|
-
function re(e, l) {
|
|
273
|
-
return e.hasAttribute(l) || e.setAttribute(l, crypto.randomUUID()), e.getAttribute(l);
|
|
274
|
-
}
|
|
275
|
-
const oe = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `${t[1]}{${M(t[3])}}${t[4]}`).join(""), M = (e) => {
|
|
276
|
-
if (!e.trim())
|
|
277
|
-
return e;
|
|
278
|
-
const l = e.split("??"), t = l.shift(), s = M(l.join("??"));
|
|
279
|
-
return l.length ? `concat( ${t} , substring( ${s} , (1+string-length( ${s} )) * string-length( ${t} ) ) )` : e;
|
|
280
|
-
}, B = (e, l) => {
|
|
281
|
-
e = M(e);
|
|
282
|
-
const t = l.ownerDocument.evaluate(e, l);
|
|
283
|
-
switch (t.resultType) {
|
|
284
|
-
case XPathResult.NUMBER_TYPE:
|
|
285
|
-
return t.numberValue;
|
|
286
|
-
case XPathResult.STRING_TYPE:
|
|
287
|
-
return t.stringValue;
|
|
288
|
-
}
|
|
289
|
-
let s = "";
|
|
290
|
-
for (let n; n = t.iterateNext(); )
|
|
291
|
-
s += n.textContent;
|
|
292
|
-
return s;
|
|
293
|
-
}, ie = "stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,template,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback".split(","), ce = (e, l) => {
|
|
294
|
-
const t = E("xsl:" + e.localName);
|
|
295
|
-
for (let s of e.attributes)
|
|
296
|
-
t.setAttribute(s.name, s.value);
|
|
297
|
-
for (; e.firstChild; )
|
|
298
|
-
t.append(e.firstChild);
|
|
299
|
-
if (e.parentElement)
|
|
300
|
-
e.parentElement.replaceChild(t, e);
|
|
301
|
-
else {
|
|
302
|
-
const s = e.parentElement || l, n = [...s.childNodes];
|
|
303
|
-
n.forEach((r, f) => {
|
|
304
|
-
r === e && (n[f] = t);
|
|
305
|
-
}), s.replaceChildren(...n);
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
class me extends HTMLElement {
|
|
309
|
-
static observedAttributes = ["src", "tag", "hidden"];
|
|
310
|
-
async connectedCallback() {
|
|
311
|
-
const l = await ne(h(this, "src"), this), t = h(this, "tag"), s = t || "dce-" + crypto.randomUUID();
|
|
312
|
-
for (const d of l)
|
|
313
|
-
S(d.templateNode || d.content || d, "style", (c) => {
|
|
314
|
-
const a = c.closest("slot"), i = a ? `slot[name="${a.name}"]` : "";
|
|
315
|
-
c.innerHTML = `${s} ${i}{${c.innerHTML}}`, this.append(c);
|
|
316
|
-
});
|
|
317
|
-
const n = l.map((d) => Z(d)), r = n.map((d, c) => (c = new XSLTProcessor(), c.importStylesheet(d), c));
|
|
318
|
-
Object.defineProperty(this, "xsltString", { get: () => n.map((d) => R(d)).join(`
|
|
319
|
-
`) });
|
|
320
|
-
const f = this, p = [...this.templateNode.querySelectorAll("[slice]")], y = p.map((d) => h(d, "slice")).filter((d) => !d.includes("/")).filter((d, c, a) => a.indexOf(d) === c), u = n.reduce((d, c) => (c.params && d.push(...c.params), d), []);
|
|
321
|
-
class A extends HTMLElement {
|
|
322
|
-
static get observedAttributes() {
|
|
323
|
-
return u.map((c) => h(c, "name"));
|
|
324
|
-
}
|
|
325
|
-
#e = 0;
|
|
326
|
-
connectedCallback() {
|
|
327
|
-
let c = this.childNodes;
|
|
328
|
-
if (this.firstElementChild?.tagName === "TEMPLATE") {
|
|
329
|
-
const m = this.firstElementChild;
|
|
330
|
-
m.remove(), c = m.content.childNodes;
|
|
331
|
-
for (const o of [...m.content.childNodes])
|
|
332
|
-
if (o.localName === "style") {
|
|
333
|
-
const b = re(this, "data-dce-style");
|
|
334
|
-
o.innerHTML = `${s}[data-dce-style="${b}"]{${o.innerHTML}}`, m.insertAdjacentElement("beforebegin", o);
|
|
335
|
-
} else
|
|
336
|
-
o.nodeType === 1 ? m.insertAdjacentElement("beforebegin", o) : o.nodeType === 3 && m.insertAdjacentText("beforebegin", o.data);
|
|
337
|
-
}
|
|
338
|
-
const a = C("<datadom/>").documentElement, i = (m, o = "") => ((b) => (o && b.append(w(a, o)), b))(a.ownerDocument.createElement(m));
|
|
339
|
-
D(a, "payload", c, Q), this.innerHTML = "", D(a, "attributes", this.attributes, (m) => i(m.nodeName, m.value)), D(a, "dataset", Object.keys(this.dataset), (m) => i(m, this.dataset[m]));
|
|
340
|
-
const N = D(a, "slice", y, (m) => i(m, "")), v = (m) => B(m, N);
|
|
341
|
-
this.xml = a;
|
|
342
|
-
const g = [], x = () => {
|
|
343
|
-
const m = {};
|
|
344
|
-
for (let o; o = g.pop(); ) {
|
|
345
|
-
const b = h(o.sliceElement, "slice");
|
|
346
|
-
m[b] || (le(N, b, o), m[b] = o);
|
|
347
|
-
}
|
|
348
|
-
Object.keys(m).length !== 0 && P();
|
|
349
|
-
};
|
|
350
|
-
let T;
|
|
351
|
-
this.onSlice = (m) => {
|
|
352
|
-
m.stopPropagation?.(), m.sliceEventSource = m.currentTarget || m.target, g.push(m), T || (T = setTimeout(() => {
|
|
353
|
-
x(), T = 0;
|
|
354
|
-
}, 10));
|
|
355
|
-
};
|
|
356
|
-
const P = this.transform = () => {
|
|
357
|
-
if (this.#e)
|
|
358
|
-
debugger;
|
|
359
|
-
this.#e = 1, r.map((o, b) => {
|
|
360
|
-
const L = o.transformToFragment(a.ownerDocument, document);
|
|
361
|
-
return L || console.error(`XSLT transformation error. xsl:
|
|
362
|
-
`, R(n[b]), `
|
|
363
|
-
xml:
|
|
364
|
-
`, R(a)), L;
|
|
365
|
-
}).map((o) => {
|
|
366
|
-
o && (_(o), F(this, o.childNodes));
|
|
367
|
-
}), A.observedAttributes.map((o) => {
|
|
368
|
-
let b = h(this.firstElementChild, o);
|
|
369
|
-
b !== h(this, o) && (this.setAttribute(o, b), this.#t(o, b));
|
|
370
|
-
}), S(this, "[slice]", (o) => {
|
|
371
|
-
if (!o.dceInitialized) {
|
|
372
|
-
o.dceInitialized = 1;
|
|
373
|
-
const b = h(o, "slice-event");
|
|
374
|
-
(b || "change").split(" ").forEach((L) => (o.localName === "slice" ? o.parentElement : o).addEventListener(L, (U) => {
|
|
375
|
-
U.sliceElement = o, this.onSlice(U);
|
|
376
|
-
})), (!b || b.includes("init")) && (o.hasAttribute("slice-value") || o.hasAttribute("value") || o.value ? this.onSlice({ type: "init", target: o, sliceElement: o }) : o.value = v(h(o, "slice")));
|
|
377
|
-
}
|
|
378
|
-
}), this.#e = 0;
|
|
379
|
-
};
|
|
380
|
-
P(), x();
|
|
381
|
-
}
|
|
382
|
-
#t(c, a) {
|
|
383
|
-
let i = this.xml.querySelector(`attributes>${c}`);
|
|
384
|
-
i ? j(i).append(w(i, a)) : (i = E(c, a, this.xml), this.xml.querySelector("attributes").append(i));
|
|
385
|
-
}
|
|
386
|
-
attributeChangedCallback(c, a, i) {
|
|
387
|
-
!this.xml || this.#e || (this.#t(c, i), this.transform());
|
|
388
|
-
}
|
|
389
|
-
get dce() {
|
|
390
|
-
return f;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
const $ = (d) => {
|
|
394
|
-
window.customElements.get(d) !== A && window.customElements.define(d, A);
|
|
395
|
-
};
|
|
396
|
-
if (t)
|
|
397
|
-
$(t);
|
|
398
|
-
else {
|
|
399
|
-
const d = s;
|
|
400
|
-
this.setAttribute("tag", d), $(d);
|
|
401
|
-
const c = document.createElement(d);
|
|
402
|
-
this.getAttributeNames().forEach((a) => c.setAttribute(a, this.getAttribute(a))), c.append(...[...this.childNodes].filter((a) => a.localName !== "style")), this.append(c);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
get templateNode() {
|
|
406
|
-
return this.firstElementChild?.tagName === "TEMPLATE" ? this.firstElementChild.content : this;
|
|
407
|
-
}
|
|
408
|
-
get dce() {
|
|
409
|
-
return this;
|
|
410
|
-
}
|
|
411
|
-
get xslt() {
|
|
412
|
-
return C(this.xsltString);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
window.customElements.define("custom-element", me);
|
|
416
|
-
export {
|
|
417
|
-
me as C,
|
|
418
|
-
R as a,
|
|
419
|
-
ee as b,
|
|
420
|
-
Z as c,
|
|
421
|
-
te as d,
|
|
422
|
-
se as e,
|
|
423
|
-
le as f,
|
|
424
|
-
_ as g,
|
|
425
|
-
F as h,
|
|
426
|
-
re as i,
|
|
427
|
-
oe as j,
|
|
428
|
-
M as k,
|
|
429
|
-
B as l,
|
|
430
|
-
ae as m,
|
|
431
|
-
ie as n,
|
|
432
|
-
X as o,
|
|
433
|
-
ce as p,
|
|
434
|
-
H as t,
|
|
435
|
-
C as x
|
|
436
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {describe} from 'vitest';
|
|
2
|
-
|
|
3
|
-
import '../custom-element/custom-element.js';
|
|
4
|
-
import meta from "./attributes.stories.ts";
|
|
5
|
-
|
|
6
|
-
import * as Stories from "./attributes.stories.ts";
|
|
7
|
-
import {playStories} from './renderPlay';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe('attributes', () =>
|
|
11
|
-
{
|
|
12
|
-
localStorage.clear();
|
|
13
|
-
playStories( Stories, meta );
|
|
14
|
-
});
|
package/src/stories/css.test.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {describe} from 'vitest';
|
|
2
|
-
|
|
3
|
-
import '../custom-element/custom-element.js';
|
|
4
|
-
import meta from "./css.stories.ts";
|
|
5
|
-
|
|
6
|
-
import * as Stories from "./css.stories.ts";
|
|
7
|
-
import {playStories} from './renderPlay';
|
|
8
|
-
|
|
9
|
-
describe('Css', () =>
|
|
10
|
-
{
|
|
11
|
-
playStories( Stories, meta );
|
|
12
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {describe, it} from 'vitest';
|
|
2
|
-
|
|
3
|
-
import '../custom-element/custom-element.js';
|
|
4
|
-
import meta from "./dom-merge.stories.ts";
|
|
5
|
-
|
|
6
|
-
import * as Stories from "./dom-merge.stories.ts";
|
|
7
|
-
import {playStories} from './renderPlay';
|
|
8
|
-
|
|
9
|
-
describe('dom-merge', () => {
|
|
10
|
-
localStorage.clear();
|
|
11
|
-
playStories( Stories, meta );
|
|
12
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {describe, it} from 'vitest';
|
|
2
|
-
|
|
3
|
-
import '../custom-element/custom-element.js';
|
|
4
|
-
import meta from "./external-template.stories.ts";
|
|
5
|
-
|
|
6
|
-
import * as Stories from "./external-template.stories.ts";
|
|
7
|
-
import {playStories} from './renderPlay';
|
|
8
|
-
|
|
9
|
-
describe('external-template', () => {
|
|
10
|
-
localStorage.clear();
|
|
11
|
-
playStories( Stories, meta );
|
|
12
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {describe} from 'vitest';
|
|
2
|
-
|
|
3
|
-
import '../custom-element/custom-element.js';
|
|
4
|
-
import meta from "./local-storage.stories.ts";
|
|
5
|
-
|
|
6
|
-
import * as Stories from "./local-storage.stories.ts";
|
|
7
|
-
import {playStories} from './renderPlay';
|
|
8
|
-
|
|
9
|
-
describe('local-storage', () => {
|
|
10
|
-
localStorage.clear();
|
|
11
|
-
playStories( Stories, meta );
|
|
12
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {describe, it} from 'vitest';
|
|
2
|
-
import {type StoryObj} from "@storybook/web-components";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import '../custom-element/custom-element.js';
|
|
6
|
-
import meta from "./location-element.stories.ts";
|
|
7
|
-
|
|
8
|
-
import * as Stories from "./location-element.stories.ts";
|
|
9
|
-
import {playStories} from './renderPlay';
|
|
10
|
-
|
|
11
|
-
describe('location-element', () => {
|
|
12
|
-
localStorage.clear();
|
|
13
|
-
playStories( Stories, meta );
|
|
14
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type {StoryObj} from '@storybook/web-components';
|
|
2
|
-
import {it} from 'vitest';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export async function renderPlay<TProps>(story: StoryObj, meta:{render: (args: TProps)=>string })
|
|
6
|
-
{
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
document.body.innerHTML = meta.render(story.args);
|
|
9
|
-
await new Promise(resolve => setTimeout(async () =>
|
|
10
|
-
{
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
await story.play({canvasElement: document.body.firstElementChild as HTMLElement});
|
|
13
|
-
resolve(0);
|
|
14
|
-
}, 0));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function playStories<TProps>( Stories: any, meta:{ render: (args: TProps)=>string } )
|
|
18
|
-
{
|
|
19
|
-
for ( let story of Object.values(Stories) as StoryObj[] )
|
|
20
|
-
if( story.play )
|
|
21
|
-
it( story.args!.title, async () => renderPlay(story, meta) );
|
|
22
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {describe} from 'vitest';
|
|
2
|
-
|
|
3
|
-
import '../custom-element/custom-element.js';
|
|
4
|
-
import meta from "./slice-events.stories.ts";
|
|
5
|
-
|
|
6
|
-
import * as Stories from "./slice-events.stories.ts";
|
|
7
|
-
import {playStories} from './renderPlay';
|
|
8
|
-
|
|
9
|
-
describe('slice-events', () => {
|
|
10
|
-
localStorage.clear();
|
|
11
|
-
playStories( Stories, meta );
|
|
12
|
-
});
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__fileDeps=["./index-DgaNIR0t.js","./index-DnEJ_bKa.js","./index-CBQwM6ST.js","./iframe-gCvlWuoC.js","./index-Cc7K62zD.js","./index-Dkj0J1ds.js","./index-DrFu-skq.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
|
|
2
|
-
import{_ as l}from"./iframe-gCvlWuoC.js";import{r as h,R as o,d as a,C as E,A as R,H as x,D as y}from"./index-CBQwM6ST.js";import"../sb-preview/runtime.js";import"./index-Cc7K62zD.js";import"./index-Dkj0J1ds.js";import"./index-DrFu-skq.js";var c={},m=h;c.createRoot=m.createRoot,c.hydrateRoot=m.hydrateRoot;var n=new Map,D=({callback:e,children:t})=>{let r=a.useRef();return a.useLayoutEffect(()=>{r.current!==e&&(r.current=e,e())},[e]),t},_=async(e,t)=>{let r=await w(t);return new Promise(s=>{r.render(o.createElement(D,{callback:()=>s(null)},e))})},v=(e,t)=>{let r=n.get(e);r&&(r.unmount(),n.delete(e))},w=async e=>{let t=n.get(e);return t||(t=c.createRoot(e),n.set(e,t)),t},f={code:E,a:R,...x},g=class extends a.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){let{showException:t}=this.props;t(e)}render(){let{hasError:e}=this.state,{children:t}=this.props;return e?null:o.createElement(o.Fragment,null,t)}},L=class{constructor(){this.render=async(e,t,r)=>{let s={...f,...t?.components},u=y;return new Promise((i,d)=>{l(()=>import("./index-DgaNIR0t.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(({MDXProvider:p})=>_(o.createElement(g,{showException:d,key:Math.random()},o.createElement(p,{components:s},o.createElement(u,{context:e,docsParameter:t}))),r)).then(()=>i())})},this.unmount=e=>{v(e)}}};export{L as DocsRenderer,f as defaultComponents};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as a,W as T,b as e}from"./index-CBQwM6ST.js";import"./iframe-gCvlWuoC.js";import"../sb-preview/runtime.js";import"./index-Cc7K62zD.js";import"./index-Dkj0J1ds.js";import"./index-DrFu-skq.js";export{a as WithToolTipState,T as WithTooltip,e as WithTooltipPure};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import{w as u,e as n}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.js";const g={title:"",tag:"",style:"",slot:"",payload:""};function p(t){const{title:e,tag:o,style:s,slot:l,payload:y}={...g,...t};return`
|
|
2
|
-
<fieldset>
|
|
3
|
-
<legend>${e}</legend>
|
|
4
|
-
<custom-element ${o?`tag="${o}"`:""} >
|
|
5
|
-
<template>
|
|
6
|
-
<style>
|
|
7
|
-
${s}
|
|
8
|
-
</style>
|
|
9
|
-
<u><slot>${l}</slot></u>
|
|
10
|
-
</template>
|
|
11
|
-
</custom-element>
|
|
12
|
-
${y}
|
|
13
|
-
</fieldset>
|
|
14
|
-
`}const h={title:"Css",render:p},d='<b style="color:green">green</b>',i='<i style="color:red">red</i>',a={args:{title:`The default color should stay on this label, the message inside should be ${d}`,style:"color:green",slot:"text has to be green",payload:"<u>no tags</u>"},play:async({canvasElement:t})=>{const o=await u(t).findByText("text has to be green"),l=getComputedStyle(o).getPropertyValue("color");n(l).to.equal("rgb(0, 128, 0)")}},c={args:{title:`The default color should apply ${d} in all instances`,style:"color:green",slot:"text has to be green",tag:"dce-2",payload:'<u>2 instances:</u> <dce-2 id="dce21"></dce-2> * <dce-2 id="dce22"></dce-2>'},play:async({canvasElement:t})=>{await u(t).findByText("2 instances:");const e=o=>{const s=t.querySelector(o);return getComputedStyle(s).getPropertyValue("color")};n(e("legend")).to.not.equal(e("b")),n(e("legend")).to.not.equal(e("b")),n(e("#dce21 u")).to.equal(e("b")),n(e("#dce22 u")).to.equal(e("b"))}},r={args:{title:`${d} in instance style can be overridden in payload as ${i} in 1st instance`,style:"color:green",slot:"is green",tag:"dce-3",payload:` <u>should be</u> ${i}:<dce-3 id="dce32">
|
|
15
|
-
<template>
|
|
16
|
-
<style> color:red; </style>
|
|
17
|
-
<u>red</u>
|
|
18
|
-
</template>
|
|
19
|
-
</dce-3> <br/>
|
|
20
|
-
should be ${d}: <dce-3 id="dce31">green</dce-3> `},play:async({canvasElement:t})=>{await u(t).findByText("should be");const e=o=>{const s=t.querySelector(o);return getComputedStyle(s).getPropertyValue("color")};n(e("legend")).to.not.equal(e("b")),n(e("#dce31 u")).to.equal(e("b")),n(e("#dce32 u")).to.equal(e("i"))}};a.parameters={...a.parameters,docs:{...a.parameters?.docs,source:{originalSource:`{
|
|
21
|
-
args: {
|
|
22
|
-
title: \`The default color should stay on this label, the message inside should be \${GREEN}\`,
|
|
23
|
-
style: \`color:green\`,
|
|
24
|
-
slot: 'text has to be green',
|
|
25
|
-
payload: '<u>no tags</u>'
|
|
26
|
-
},
|
|
27
|
-
play: async ({
|
|
28
|
-
canvasElement
|
|
29
|
-
}) => {
|
|
30
|
-
const canvas = within(canvasElement);
|
|
31
|
-
const el = await canvas.findByText('text has to be green');
|
|
32
|
-
const st = getComputedStyle(el);
|
|
33
|
-
const color = st.getPropertyValue('color');
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
expect(color).to.equal('rgb(0, 128, 0)');
|
|
36
|
-
}
|
|
37
|
-
}`,...a.parameters?.docs?.source}}};c.parameters={...c.parameters,docs:{...c.parameters?.docs,source:{originalSource:`{
|
|
38
|
-
args: {
|
|
39
|
-
title: \`The default color should apply \${GREEN} in all instances\`,
|
|
40
|
-
style: \`color:green\`,
|
|
41
|
-
slot: 'text has to be green',
|
|
42
|
-
tag: 'dce-2',
|
|
43
|
-
payload: \`<u>2 instances:</u> <dce-2 id="dce21"></dce-2> * <dce-2 id="dce22"></dce-2>\`
|
|
44
|
-
},
|
|
45
|
-
play: async ({
|
|
46
|
-
canvasElement
|
|
47
|
-
}) => {
|
|
48
|
-
await within(canvasElement).findByText('2 instances:');
|
|
49
|
-
const color = (css: string) => {
|
|
50
|
-
const el = canvasElement.querySelector(css);
|
|
51
|
-
const st = getComputedStyle(el!);
|
|
52
|
-
return st.getPropertyValue('color');
|
|
53
|
-
};
|
|
54
|
-
expect(color('legend')).to.not.equal(color('b'));
|
|
55
|
-
expect(color('legend')).to.not.equal(color('b'));
|
|
56
|
-
expect(color('#dce21 u')).to.equal(color('b'));
|
|
57
|
-
expect(color('#dce22 u')).to.equal(color('b'));
|
|
58
|
-
}
|
|
59
|
-
}`,...c.parameters?.docs?.source}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
|
|
60
|
-
args: {
|
|
61
|
-
title: \`\${GREEN} in instance style can be overridden in payload as \${RED} in 1st instance\`,
|
|
62
|
-
style: \`color:green\`,
|
|
63
|
-
slot: 'is green',
|
|
64
|
-
tag: 'dce-3',
|
|
65
|
-
payload: \` <u>should be</u> \${RED}:<dce-3 id="dce32">
|
|
66
|
-
<template>
|
|
67
|
-
<style> color:red; </style>
|
|
68
|
-
<u>red</u>
|
|
69
|
-
</template>
|
|
70
|
-
</dce-3> <br/>
|
|
71
|
-
should be \${GREEN}: <dce-3 id="dce31">green</dce-3> \`
|
|
72
|
-
},
|
|
73
|
-
play: async ({
|
|
74
|
-
canvasElement
|
|
75
|
-
}) => {
|
|
76
|
-
await within(canvasElement).findByText('should be');
|
|
77
|
-
const color = (css: string) => {
|
|
78
|
-
const el = canvasElement.querySelector(css);
|
|
79
|
-
const st = getComputedStyle(el!);
|
|
80
|
-
return st.getPropertyValue('color');
|
|
81
|
-
};
|
|
82
|
-
expect(color('legend')).to.not.equal(color('b'));
|
|
83
|
-
expect(color('#dce31 u')).to.equal(color('b'));
|
|
84
|
-
expect(color('#dce32 u')).to.equal(color('i'));
|
|
85
|
-
}
|
|
86
|
-
}`,...r.parameters?.docs?.source}}};const x=["StyleDoesNotLeak","StyleIn2Instances","OverrideInPayload"];export{r as OverrideInPayload,a as StyleDoesNotLeak,c as StyleIn2Instances,x as __namedExportsOrder,h as default};
|