@epa-wg/custom-element-dist 0.0.36 → 0.0.38
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/.ai/mcp/mcp.json +0 -0
- package/.yarn/install-state.gz +0 -0
- package/AGENTS.md +1 -0
- package/CLAUDE.md +89 -0
- package/README.md +5 -5
- package/bin/postinstall.sh +12 -9
- package/coverage/coverage-final.json +4 -4
- package/coverage/index.html +25 -25
- 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 +175 -160
- package/coverage/src/custom-element/http-request.js.html +10 -10
- package/coverage/src/custom-element/index.html +14 -14
- package/coverage/src/custom-element/local-storage.js.html +1 -1
- package/coverage/src/custom-element/location-element.js.html +1 -1
- package/coverage/src/custom-element/module-url.js.html +1 -1
- package/coverage/src/index.html +1 -1
- package/coverage/src/material/theme/colors.js.html +1 -1
- package/coverage/src/material/theme/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/coverage.svg +1 -1
- package/coverage/src/stories/frame.canvas.ts/coverage.svg +1 -1
- package/coverage/src/stories/frame.canvas.ts.html +54 -12
- package/coverage/src/stories/http-request.stories.ts.html +1 -1
- package/coverage/src/stories/index.html +19 -19
- package/coverage/src/stories/testStoryBook.ts.html +7 -16
- package/coverage/src/sum.ts.html +1 -1
- package/dist/{custom-element-BqBcmDiN.js → custom-element-Cr_I3Xd-.js} +69 -65
- package/dist/custom-element-D5IF46oF.cjs +97 -0
- package/dist/custom-element-bundle.cjs +1 -1
- package/dist/custom-element-bundle.js +3 -3
- package/dist/demo/a.html +41 -64
- package/dist/demo/s.xslt +94 -350
- package/dist/{local-storage-DzmNKzgN.js → local-storage-w0k66UWM.js} +4 -4
- package/package.json +3 -2
- package/public/demo/a.html +41 -64
- package/public/demo/s.xslt +94 -350
- package/src/custom-element/custom-element.js +9 -4
- package/src/custom-element/demo/a.html +41 -64
- package/src/custom-element/demo/s.xslt +94 -350
- package/src/custom-element/ide/customData-dce.json +8 -8
- package/src/custom-element/ide/web-types-dce.json +8 -8
- package/src/custom-element/ide/web-types-xsl.json +1 -1
- package/src/material/components/action.html +77 -22
- package/src/material/components/autocomplete.html +7 -6
- package/src/material/components/badge.html +33 -34
- package/src/material/components/cem-theme-components.css +131 -0
- package/src/material/components/dropdown.html +27 -12
- package/src/material/components/icon-link.html +25 -18
- package/src/material/components/icon.html +15 -14
- package/src/material/components/input.html +27 -24
- package/src/material/components/menu.html +23 -18
- package/src/material/components.html +19 -18
- package/src/material/demo.css +24 -12
- package/src/material/index.html +15 -9
- package/src/material/theme/colors-native.html +32 -1
- package/src/material/theme/consumer-theme.css +0 -733
- package/src/material/theme/semantic.css +1 -85
- package/src/mocks/versions.mock.ts +1 -1
- package/src/stories/__screenshots__/http-request.test.ts/http-request-url-change-1.png +0 -0
- package/src/stories/__screenshots__/location-element.test.stories.ts/location-element-location-element-Demo-1.png +0 -0
- package/src/stories/frame.canvas.ts +17 -4
- package/src/stories/testStoryBook.ts +2 -5
- package/storybook-static/assets/{Color-F6OSRLHC-D1CN2nnQ.js → Color-F6OSRLHC-CGlEPECH.js} +1 -1
- package/storybook-static/assets/{Configure-BD0b2x9E.js → Configure-RleqRiQ0.js} +1 -1
- package/storybook-static/assets/{DocsRenderer-CFRXHY34-VjrP5Ir6.js → DocsRenderer-CFRXHY34-Bz2y61tp.js} +2 -2
- package/storybook-static/assets/{attributes.test.stories-CrDC-RXf.js → attributes.test.stories-Bs0zZtYO.js} +1 -1
- package/storybook-static/assets/{css.test.stories-ChWnZJwa.js → css.test.stories-CK4N9Fqq.js} +1 -1
- package/storybook-static/assets/custom-element-PxTx2W9y.js +97 -0
- package/storybook-static/assets/{dom-merge.test.stories-DkarPqD_.js → dom-merge.test.stories-DLFviA8F.js} +1 -1
- package/storybook-static/assets/{external-template.test.stories-DCboR8sG.js → external-template.test.stories-CqR1aaHv.js} +1 -1
- package/storybook-static/assets/{form.test.stories-BjeeUu0b.js → form.test.stories-Cinvg_DI.js} +1 -1
- package/storybook-static/assets/frame.canvas-BB4_DNn6.js +1 -0
- package/storybook-static/assets/handlers-CxSWbsdK.js +291 -0
- package/storybook-static/assets/{http-request.stories-Boz_yWek.js → http-request.stories-_1_UMvj-.js} +1 -1
- package/storybook-static/assets/{iframe-BN389ZL5.js → iframe-fXv0bS2C.js} +2 -2
- package/storybook-static/assets/{index-C4PGem3Z.js → index-Dm-gke4Y.js} +3 -3
- package/storybook-static/assets/{index-PzQAcTTK.js → index-DxjDM4Ny.js} +1 -1
- package/storybook-static/assets/{local-storage.test.stories-DLMK0p2s.js → local-storage.test.stories-M4WOSQC5.js} +1 -1
- package/storybook-static/assets/{location-element.test.stories-BroqoLMS.js → location-element.test.stories-Ce6Ma8hE.js} +1 -1
- package/storybook-static/assets/{module-url.test.stories-B-0dibET.js → module-url.test.stories-PwnZWqKL.js} +1 -1
- package/storybook-static/assets/{preview-idY559eZ.js → preview-Dq4-5PA5.js} +2 -2
- package/storybook-static/assets/{preview-DXd5xnQg.js → preview-kbHljohz.js} +1 -1
- package/storybook-static/assets/{set-url.test.stories-Dhq4YQyr.js → set-url.test.stories-BdNTYEwI.js} +1 -1
- package/storybook-static/assets/{slice-events.test.stories-BZJGIFku.js → slice-events.test.stories-BdvLtK0h.js} +1 -1
- package/storybook-static/assets/{slots.test.stories-DKivHwZH.js → slots.test.stories-CoTPvRog.js} +1 -1
- package/storybook-static/assets/{version-select.test.stories-Dntyd7qb.js → version-select.test.stories-hs-HsDVE.js} +1 -1
- package/storybook-static/assets/{xslt-conditionals.test.stories-Iq5iQNRj.js → xslt-conditionals.test.stories-C4oXVQWa.js} +1 -1
- package/storybook-static/assets/{xslt-for-each.test.stories-BMygBmj8.js → xslt-for-each.test.stories-Da4vCZe1.js} +1 -1
- package/storybook-static/assets/{xslt-if.test.stories-CVrFWdAX.js → xslt-if.test.stories-CMlnBGX2.js} +1 -1
- package/storybook-static/demo/a.html +41 -64
- package/storybook-static/demo/s.xslt +94 -350
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/project.json +1 -1
- package/dist/custom-element-jpOyXHF6.cjs +0 -97
- package/storybook-static/assets/custom-element-wuk8gYiP.js +0 -97
- package/storybook-static/assets/frame.canvas-E5n9h6j1.js +0 -1
- package/storybook-static/assets/handlers-B8a2v6Dv.js +0 -291
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
const K="http://www.w3.org/1999/XSL/Transform",R="http://www.w3.org/1999/xhtml",ye="http://exslt.org/common",d=(e,l)=>e?.getAttribute?.(l),se=e=>e.nodeType===3,ge=e=>typeof e=="string",le=e=>e&&typeof e.nodeType=="number",L=(e,l)=>(e.ownerDocument||e).createTextNode(l),ce=e=>{for(;e.firstChild;)e.firstChild.remove();return e},F=e=>(e.getAttributeNames().map(l=>e.removeAttribute(l)),ce(e)),me=e=>(e?.setAttribute("xmlns:xsl",K),e),ue=e=>(e?.setAttribute("xmlns:xhtml",R),me(e)),de=e=>/^[_a-zA-Z][-_:a-zA-Z0-9]*$/.test(e),ne=(e,l)=>(Object.keys(l).map(t=>e[t]=l[t]),e),C=(e,l="",t=document)=>{const s=n=>(o=>(l&&o.append(L(t.ownerDocument||t,l)),o))((t.ownerDocument||t).createElement(n));if(de(e))return s(e);const a=s("dce-object");return a.setAttribute("dce-object-name",e),a},ae=(e,l)=>{const t=e.ownerDocument.createElementNS(e.namespaceURI,l);for(let s of e.attributes)t.setAttribute(s.name,s.value);for(let s of e.childNodes)t.append(s.cloneNode(!0));return t};function O(e){return new DOMParser().parseFromString(e,"application/xml")}function q(e){return new XMLSerializer().serializeToString(e)}function B(e,l,t,s){const a=y=>e.ownerDocument.createElement(y),o=((y,x,v)=>(x.append(v=a(y)),v))(l,e);return[...t].forEach(y=>o.append(s(y))),o}function Ae(e){return e.slot||(e.setAttribute||(e=C("span",e.textContent.replaceAll(`
|
|
2
|
-
`,""))),e.setAttribute("slot","")),e}function J(e,l){e.getAttributeNames().forEach(t=>l.includes(t)||e.removeAttribute(t))}const ie=e=>[...e].filter(l=>!(l.nodeType===3&&l.data.trim()===""));function I(e,l,t){const s=typeof e;if(s==="string")return C(l,e,t);if(s==="number")return C(l,""+e,t);if(le(e)){const n=C(l);return n.append(e),n}if(e instanceof Array){const n=C("array","",t);return e.map(o=>n.append(I(o,l,t))),n}if(e instanceof FormData){const n=C("form-data","",t);for(const o of e)n.append(I(o[1],o[0],t));return n}const a=C(l,"",t);for(let n in e)typeof e[n]=="function"||e[n]instanceof Window||le(e[n])&&!(n==="data"||n==="value")||(typeof e[n]!="object"&&de(n)?a.setAttribute(n,e[n]):a.append(I(e[n],n,t)));return a}function re(e){if(j(e,"*",l=>[...l.childNodes].filter(t=>t.nodeType===3&&t.parentNode.localName!=="style"&&t.data).forEach(t=>{const s=t.data,a=s.matchAll(/{([^}]*)}/g);if(a){let n=0,o=x=>L(t,x),y=[];if([...a].forEach(x=>{x.index>n&&y.push(o(x.input.substring(n,x.index)));const v=e.querySelector("value-of").cloneNode();v.setAttribute("select",x[1]),y.push(v),n=x.index+x[0].length}),n<s.length&&y.push(o(s.substring(n,s.length))),y.length){for(let x of y)l.insertBefore(x,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 ve(e,l="xsl:stylesheet"){const t=[],s={},a={};if(e.tagName===l||e.documentElement?.tagName===l)return re(ne(e,{declaredAttributes:t,hardcodedAttributes:s,exposedAttributes:a}));const n=O(`<xsl:stylesheet version="1.0" xmlns:xsl="${K}" xmlns:xhtml="${R}" xmlns:exsl="${ye}" exclude-result-prefixes="exsl" >
|
|
3
|
-
<xsl:output method="xml"/>
|
|
4
|
-
<xsl:template match="/"><dce-root xmlns="${R}"><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
|
-
<xsl:copy>
|
|
39
|
-
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
40
|
-
</xsl:copy>
|
|
41
|
-
</xsl:template>
|
|
42
|
-
<xsl:template mode="sanitize" match="xhtml:*">
|
|
43
|
-
<xsl:element name="{local-name()}">
|
|
44
|
-
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
45
|
-
</xsl:element>
|
|
46
|
-
</xsl:template>
|
|
47
|
-
<xsl:template mode="sanitize" match="xhtml:input">
|
|
48
|
-
<xsl:element name="{local-name()}">
|
|
49
|
-
<xsl:apply-templates mode="sanitize" select="*[not(name()='slice')]|@*|text()"/>
|
|
50
|
-
</xsl:element>
|
|
51
|
-
<xsl:for-each select="slice">
|
|
52
|
-
<xsl:copy>
|
|
53
|
-
<xsl:attribute name="for" >^</xsl:attribute>
|
|
54
|
-
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
55
|
-
</xsl:copy>
|
|
56
|
-
</xsl:for-each>
|
|
57
|
-
</xsl:template>
|
|
58
|
-
</xsl:stylesheet>`),o=new XSLTProcessor,y=(i=>{j(i,"custom-element",f=>{f.firstElementChild.localName==="template"&&([...f.firstElementChild.content.childNodes].forEach(b=>f.append(b)),f.firstElementChild.remove())}),j(i,"script",f=>f.remove());const r=i.content??i.firstElementChild?.content??i.body??i;$e.forEach(f=>j(r,f,b=>Le(b,r)));const h=i.firstElementChild?.content||i.content,g=f=>{const b=O("<xhtml/>"),T=b.importNode(f,!0);return b.replaceChild(T,b.documentElement),T.namespaceURI===R&&!d(T,"xmlns")&&T.setAttribute("xmlns",R),ue(T)};if(h){const f=C("div");return[...h.childNodes].map(b=>f.append(b.cloneNode(!0))),g(f)}return g(i.documentElement||i.body||i)})(e),x=O(`<xsl:stylesheet version="1.0"
|
|
59
|
-
xmlns:xsl="${K}"
|
|
60
|
-
xmlns:xhtml="${R}"
|
|
61
|
-
xmlns:dce="urn:schemas-epa-wg:dce"
|
|
62
|
-
xmlns:exsl="http://exslt.org/common"
|
|
63
|
-
exclude-result-prefixes="exsl"
|
|
64
|
-
>
|
|
65
|
-
<xsl:template match="ignore">
|
|
66
|
-
<xsl:choose>
|
|
67
|
-
<xsl:when test="//attr">{//attr}</xsl:when>
|
|
68
|
-
<xsl:otherwise>{def}</xsl:otherwise>
|
|
69
|
-
</xsl:choose><xsl:value-of select="."></xsl:value-of></xsl:template>
|
|
70
|
-
<xsl:template mode="payload" match="attributes"></xsl:template>
|
|
71
|
-
<xsl:template match="/">
|
|
72
|
-
<xsl:apply-templates mode="payload" select="/datadom/attributes"/>
|
|
73
|
-
</xsl:template>
|
|
74
|
-
<xsl:template name="slot" >
|
|
75
|
-
<xsl:param name="slotname" />
|
|
76
|
-
<xsl:param name="defaultvalue" />
|
|
77
|
-
<xsl:choose>
|
|
78
|
-
<xsl:when test="//payload/*[@slot=$slotname]">
|
|
79
|
-
<xsl:copy-of select="//payload/*[@slot=$slotname]"/>
|
|
80
|
-
</xsl:when>
|
|
81
|
-
<xsl:otherwise>
|
|
82
|
-
<xsl:copy-of select="$defaultvalue"/>
|
|
83
|
-
</xsl:otherwise>
|
|
84
|
-
</xsl:choose>
|
|
85
|
-
</xsl:template>
|
|
86
|
-
<xsl:variable name="js-injected-body">
|
|
87
|
-
<xsl:call-template name="slot" >
|
|
88
|
-
<xsl:with-param name="slotname" select="''"/>
|
|
89
|
-
<xsl:with-param name="defaultvalue"/>
|
|
90
|
-
</xsl:call-template>
|
|
91
|
-
</xsl:variable>
|
|
92
|
-
</xsl:stylesheet>`);o.importStylesheet(n);const v=o.transformToFragment(y,document),u=(i,r)=>i.querySelector(r),w=u(x,'template[mode="payload"]');if(!v)return console.error("transformation error",{xml:y.outerHTML,xsl:q(n)});if(v.firstElementChild.localName!=="dce-root"){const i=v.ownerDocument.createElement("dce-root");[...v.childNodes].forEach(r=>i.append(r)),v.append(i)}[...v.querySelectorAll("[test]")].forEach(i=>{const r=d(i,"test"),h=r.replace(/hasBoolAttribute\((.*?)\)/g,(g,f,b,T,M)=>{const D=f.substring(1);return`(not($${D} = 'false') and ($${D} = '' or $${D} = '${D}' or $${D} = 'true' ))`});r!==h&&i.setAttribute("test",h)}),[...v.querySelectorAll("dce-root>attribute")].forEach(i=>{J(i,"namespace,name,select");const r=ae(i,"xsl:param"),h=d(i,"name");if(t.push(h),i.childNodes.length&&(s[h]=i.textContent),w.append(r),i.hasAttribute("select")){a[h]=d(i,"select"),J(r,"select,name");let g=d(i,"select").split("??"),f;if(g?.length>1){r.removeAttribute("select");const b=u(x,'template[match="ignore"]>choose').cloneNode(!0);F(b.firstElementChild).append(L(b,"{"+g[0]+"}")),b.firstElementChild.setAttribute("test",g[0]);for(let T=1;T<g.length-1;T++){const M=b.firstElementChild.cloneNode(!0);F(M).append(L(b,"{"+g[T]+"}")),M.setAttribute("test",g[T]),b.insertBefore(M,b.lastElementChild)}F(b.lastElementChild).append(L(b,"{"+g[g.length-1]+"}")),r.append(b),f=b.cloneNode(!0)}else f=ae(i,"xsl:value-of");f.removeAttribute("name"),i.append(f),i.removeAttribute("select")}else J(r,"name"),r.setAttribute("select","/datadom/attributes/"+h),s[h]||i.remove()}),[...v.querySelectorAll("[value]")].filter(i=>i.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach(i=>{const r=d(i,"value");r&&i.setAttribute("value",Ce(r))});for(const i of v.childNodes)w.append(x.importNode(i,!0));[...w.getElementsByTagName("xsl:template")].forEach(i=>w.ownerDocument.documentElement.append(i));const k=u(x,'call-template[name="slot"]'),H=i=>{const r=k.cloneNode(!0),h=d(i,"name");h&&r.firstElementChild.setAttribute("select",`'${h}'`);for(let g of i.childNodes)r.lastElementChild.append(g);return r};j(w,"slot",i=>i.parentNode.replaceChild(H(i),i));const p=re(x);return ne(p,{declaredAttributes:t,hardcodedAttributes:s,exposedAttributes:a}),p}async function Ee(e){return await new Promise((t,s)=>{const a=new XMLHttpRequest;a.open("GET",e),a.responseType="document",a.onload=()=>{a.readyState===a.DONE&&a.status===200?t(a.responseXML?.body||a.responseXML||C("div",a.responseText)):s(`${a.statusText} - ${e}`)},a.addEventListener("error",n=>s(n)),a.send()})}const pe=e=>e.split("|").map(l=>l.trim()).filter(l=>l),Ne=(e,l)=>pe(l).map(t=>{let s=e.ownerDocument,a=n=>(e.append(n),n);if(t.includes("/")){const n=[],o=s.evaluate(t,e);for(let y;y=o.iterateNext();)n.push(y);return n}return[...e.childNodes].find(n=>n.localName===t)||a(C(t,"",s))}).flat();function oe(e,l,t,s){if(!t.sliceProcessed)return t.sliceProcessed=1,Ne(e,l??"").map(a=>{const n=e.ownerDocument,o=t.sliceEventSource,y=t.sliceElement,x=()=>[...a.childNodes].filter(u=>u.nodeType===3||u.localName==="value"||u.localName==="form-data").map(u=>u.remove());o.getAttributeNames().map(u=>a.setAttribute(u,d(o,u))),[...a.childNodes].filter(u=>u.localName==="event").map(u=>u.remove()),"validationMessage"in o&&a.setAttribute("validation-message",o.validationMessage),t.type==="init"&&x(),a.append(I(t,"event",n));const v=(o.type==="checkbox"||o.type==="radio")&&!o.checked;if(y.hasAttribute("slice-value")){o.value===void 0?a.removeAttribute("value"):a.setAttribute("value",o.value);const u=v?"":P(d(y,"slice-value"),a);x(),a.append(L(n,u))}else{if("elements"in o)return x(),a.append(I(new FormData(o),"value",a.ownerDocument)),a;const u=v?"":o.value??d(o,"value");if(x(),u==null)[...a.childNodes].filter(w=>w.localName!=="event").map(w=>w.remove()),a.removeAttribute("value");else{const w=ge(u)?L(n,u):I(u,"value",a.ownerDocument);a.append(w),a.setAttribute("value",u)}}return a})}function j(e,l,t){e.querySelectorAll&&[...e.querySelectorAll(l)].forEach(t)}const we=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=import.meta.resolve(t),s&&(e+="#"+s)}catch(n){console.error(n.message)}const a=await Ee(e);if(l.setAttributeNS("xml","base",e),s){const n=a.querySelectorAll("#"+s);return n.length?[...n]:(console.error("template not found",e+"#"+s),[l])}return[a]}catch{return[l]}};function he(e,l){for(let n of e.attributes)try{const o=n.name;if(o.startsWith("xmlns"))continue;n.namespaceURI?(!l.hasAttributeNS(n.namespaceURI,o)||l.getAttributeNS(n.namespaceURI,o)!==n.value)&&l.setAttributeNS(n.namespaceURI,o,n.value):(!l.hasAttribute(o)||l.getAttribute(o)!==n.value)&&l.setAttribute(n.name,n.value),n.name==="value"&&(l.value=n.value)}catch(o){console.warn("attribute assignment error",o?.message||o)}const t=l.dceExportedAttributes,s=l.getAttribute("dce-exported-attributes"),a=s?new Set(s.split(" ")):null;for(let n of l.getAttributeNames())!e.hasAttribute(n)&&!t?.has(n)&&!a?.has(n)&&l.removeAttribute(n)}function fe(e,l=0){const t={};for(const s of e.childNodes){const a=d(s,"data-dce-id")||s.dceId||0;if(!t[a])a?t[a]=1:(t[a]=s.dceId=++l,s.setAttribute&&s.setAttribute("data-dce-id",s.dceId));else{const n=s.dceId=a+"-"+t[a]++;s.setAttribute&&s.setAttribute("data-dce-id",n)}s.childNodes.length&&fe(s)}}function Te(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 xe(e,l){if(e.firstElementChild?.localName==="dce-root"&&l[0]?.localName!=="dce-root")return;if(!l.length)return e.firstElementChild?.localName!=="dce-root"&&ce(e);const t={};for(let s of e.childNodes)t[s.dceId],se(s)?(s.data.trim(),t[s.dceId||0]=s):t[d(s,"data-dce-id")||0]=s;for(let s of[...l]){const a=d(s,"data-dce-id")||s.dceId,n=t[a];n?(se(s)?n.nodeValue!==s.nodeValue&&(n.nodeValue=s.nodeValue):(he(s,n),(n.childNodes.length||s.childNodes.length)&&xe(n,s.childNodes)),delete t[a]):Te(e,s,a)}for(let s of Object.values(t))s.localName!=="dce-root"&&s.remove()}function Se(e,l){return e.hasAttribute(l)||e.setAttribute(l,crypto.randomUUID()),e.getAttribute(l)}const Ce=e=>[...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map(t=>`${t[1]}{${Q(t[3])}}${t[4]}`).join(""),Q=e=>{if(!e.trim())return e;const l=e.split("??"),t=l.shift(),s=Q(l.join("??"));return l.length?`concat( ${t} , substring( ${s} , (1+string-length( ${s} )) * string-length( ${t} ) ) )`:e},P=(e,l)=>{const t=e.split("??");if(t.length>1)return P(t[0],l)||P(t[1],l);e=Q(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 a="";for(let n;n=s.iterateNext();)a+=n.textContent;return a},$e="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(","),Le=(e,l)=>{const t=C("xsl:"+e.localName);for(let a of e.attributes)t.setAttribute(a.name,a.value);for(;e.firstChild;)t.append(e.firstChild);const s="if,choose,for-each".includes(e.localName)?(()=>{const a=e.parentElement;if(!a||a.childNodes.length===1)return t;const n=C("span");return n.append(t),n})():t;if(e.parentElement)e.parentElement.replaceChild(s,e);else{const a=e.parentElement||l,n=[...a.childNodes];n.forEach((o,y)=>{o===e&&(n[y]=s)}),a.replaceChildren(...n)}};class De extends HTMLElement{static observedAttributes=["src","tag","hidden"];async connectedCallback(){this.firstElementChild&&this.firstElementChild.localName!=="template"&&console.log(`custom-element used without template wrapping content
|
|
93
|
-
`,this.outerHTML);const l=await we(d(this,"src"),this),t=d(this,"tag"),s=t||"dce-"+crypto.randomUUID();for(const p of l)j(p.templateNode||p.content||p,"style",i=>{const r=i.closest("slot"),h=r?`slot[name="${r.name}"]`:"";i.innerHTML=`${s} ${h}{${i.innerHTML}}`,this.append(i)});const a=l.map(p=>ve(p)),n=a.map((p,i)=>{i=new XSLTProcessor;try{i.importStylesheet(p)}catch(r){console.error(r,q(p))}return i});Object.defineProperty(this,"xsltString",{get:()=>a.map(p=>q(p)).join(`
|
|
94
|
-
`)});const o=this,y=[...this.templateNode.querySelectorAll("[slice]")],x=y.map(p=>d(p,"slice")).filter(p=>!p.includes("/")).filter((p,i,r)=>r.indexOf(p)===i).map(pe).flat(),{declaredAttributes:v,hardcodedAttributes:u,exposedAttributes:w}=a[0],ee=new Set([...Object.keys(u),...Object.keys(w)]);class k extends HTMLElement{static get observedAttributes(){return v}#e=0;get dceExportedAttributes(){return ee}connectedCallback(){let i=ie(this.childNodes);if(this.firstElementChild?.tagName==="TEMPLATE"){this.firstElementChild!==this.lastElementChild&&console.error("payload should have TEMPLATE as only child",this.outerHTML);const c=this.firstElementChild;c.remove(),i=ie(c.content.childNodes);for(const E of i)if(E.localName==="style"){const m=Se(this,"data-dce-style");E.innerHTML=`${s}[data-dce-style="${m}"]{${E.innerHTML}}`,c.insertAdjacentElement("beforebegin",E)}else E.nodeType===1?c.insertAdjacentElement("beforebegin",E):E.nodeType===3&&c.insertAdjacentText("beforebegin",E.data)}const r=O("<datadom/>").documentElement,h=(c,E="")=>(m=>(E&&m.append(L(r,E)),m))(r.ownerDocument.createElement(c)),g=B(r,"payload",i,Ae);me(g),ue(g),this.innerHTML="";const f=B(r,"attributes",this.attributes,c=>h(c.nodeName,c.value)),b=c=>this.hasAttribute(c)||[...f.children].find(E=>E.localName===c);he(this,f),Object.keys(u).map(c=>b(c)||f.append(h(c,u[c]))),Object.keys(w).map(c=>b(c)||f.append(h(c))),B(r,"dataset",Object.keys(this.dataset),c=>h(c,this.dataset[c]));const T=B(r,"slice",x,c=>h(c,"")),M=c=>P(c,T);this.xml=r;const D=[],te=()=>{const c={};for(let E;E=D.pop();){const m=d(E.sliceElement,"slice");c[m]||(oe(T,m,E),c[m]=E)}Object.keys(c).length!==0&&V()};let W;this.onSlice=c=>{D.push(c),W||(W=setTimeout(()=>{te(),W=0},1))};const V=this.transform=()=>{if(this.#e)debugger;this.#e=1;const c=()=>{n.map((A,S)=>{const _=A.transformToFragment(r.ownerDocument,document);return _||console.error(`XSLT transformation error. xsl:
|
|
95
|
-
`,q(a[S]),`
|
|
96
|
-
xml:
|
|
97
|
-
`,q(r)),_}).map(A=>{A&&(fe(A),xe(this,A.childNodes))});let N=0;return Object.entries(u).map(([A,S])=>{!this.hasAttribute(A)&&S!==d(this,A)&&(this.setAttribute(A,S),this.#t(A,S),N++)}),Object.keys(w).map(A=>{let S=d(this.firstElementChild,A);S!==d(this,A)&&(this.setAttribute(A,S),this.#t(A,S),N++)}),N};c()&&c()&&console.warn("model update should not be the result of transform more than once");function E(m){let N=m;if(m.localName==="slice"){const A=d(m,"for");if(A||(N=m.parentElement),A==="^")do N=N.previousElementSibling;while(N.localName==="slice");else N=this.querySelector(A);if(!N)return console.warn(`can not find selector in "slice for=${A}" `,m.outerHTML);d(m,"slice")||m.setAttribute("slice",d(m,"name"))}return N}j(this,"[slice],[slice-event]",m=>{let N=d(m,"slice-event");const A=m.hasAttribute("slice-value")||m.hasAttribute("value")||m.value,S=E(m);m.dceInitialized||(m.dceInitialized=1,S.hasAttribute("custom-validity")&&(N+=" change submit"),[...new Set((N||"change").split(" "))].forEach(_=>S.addEventListener(_,$=>{$.sliceElement=m,$.sliceEventSource=$.currentTarget||$.target,$.sliceProcessed=0;const be=oe(T,d($.sliceElement,"slice"),$);j(this,"[custom-validity]",X=>{if(!X.setCustomValidity)return;const Z=d(X,"custom-validity");try{const U=Z&&P(Z,f);X.setCustomValidity(U===!0?"":U===!1?"invalid":U)}catch(U){console.error(U,"xPath",Z)}});const Y=d(S,"custom-validity"),z=Y&&P(Y,f),G=z===!0?"":z;if(Y){if(m.setCustomValidity?m.setCustomValidity(G):m.validationMessage=G,be.map(X=>X.setAttribute("validation-message",G)),$.type==="submit")return z===!0?void 0:(setTimeout(V,1),!!z===z?(z||$.preventDefault(),z):z?($.preventDefault(),!1):void 0);setTimeout(V,1)}this.onSlice($)})),(!N||N.includes("init"))&&(A?this.onSlice({type:"init",target:S,sliceElement:m,sliceEventSource:S}):m.value=M(d(m,"slice"))))}),this.#e=0};V(),te()}#t(i,r){i==="value"&&(this.value=r);const h=this.xml.querySelector("attributes");let g=this.xml.querySelector(`attributes>${i}`);g?F(g).append(L(g,r)):(g=C(i,r,this.xml),h.append(g)),this.#e||h.setAttribute(i,r),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{[i]:r}}))}attributeChangedCallback(i,r,h){!this.xml||this.#e||(this.#t(i,h),this.transform())}get dce(){return o}}const H=p=>{window.customElements.get(p)!==k&&window.customElements.define(p,k)};if(t)H(t);else{const p=s;this.setAttribute("tag",p),H(p);const i=document.createElement(p);this.getAttributeNames().forEach(r=>i.setAttribute(r,this.getAttribute(r))),i.append(...[...this.childNodes].filter(r=>r.localName!=="style")),this.append(i)}}get templateNode(){return this.firstElementChild?.tagName==="TEMPLATE"?this.firstElementChild.content:this}get dce(){return this}get xslt(){return O(this.xsltString)}}window.customElements.define("custom-element",De);export{he as a,ae as c,ne as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{w as a}from"./index-CGuyH0k-.js";async function r(t,e){const n=await e.findByTestId(t);return new Promise(o=>n.addEventListener("load",()=>{o(a(n.contentWindow?.document.documentElement))}))}export{r as f};
|