@epa-wg/custom-element-dist 0.0.22 → 0.0.24
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/README.md +4 -4
- package/coverage/coverage-final.json +13 -15
- 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 +336 -312
- package/coverage/src/custom-element/http-request.js.html +10 -10
- package/coverage/src/custom-element/index.html +19 -49
- package/coverage/src/custom-element/local-storage.js.html +5 -5
- 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/attributes.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/attributes.test.stories.ts.html +85 -91
- package/coverage/src/stories/coverage.svg +1 -1
- package/coverage/src/stories/css.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/css.test.stories.ts.html +75 -78
- package/coverage/src/stories/dom-merge.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/dom-merge.test.stories.ts.html +302 -74
- package/coverage/src/stories/external-template.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/external-template.test.stories.ts.html +154 -154
- package/coverage/src/stories/form.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/form.test.stories.ts.html +83 -86
- package/coverage/src/stories/http-request.stories.ts.html +1 -1
- package/coverage/src/stories/index.html +104 -104
- package/coverage/src/stories/local-storage.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/local-storage.test.stories.ts.html +444 -444
- package/coverage/src/stories/location-element.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/location-element.test.stories.ts.html +96 -96
- package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/slice-events.test.stories.ts.html +141 -141
- package/coverage/src/stories/slots.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/slots.test.stories.ts.html +120 -123
- package/coverage/src/stories/{renderPlay.ts.html → testStoryBook.ts.html} +45 -24
- package/coverage/src/sum.ts.html +1 -1
- package/dist/{custom-element-N-sWiqGK.cjs → custom-element-BDK7dcJN.cjs} +8 -8
- package/dist/{custom-element-BISbI4SU.js → custom-element-DqtzLkTG.js} +74 -66
- package/dist/custom-element-bundle.cjs +1 -1
- package/dist/custom-element-bundle.js +23 -22
- package/package.json +3 -3
- package/src/custom-element/custom-element.js +9 -1
- package/src/custom-element/demo/form.html +92 -46
- package/src/custom-element/demo/s.xml +9 -17
- package/src/custom-element/ide/web-types-dce.json +1 -1
- package/src/custom-element/ide/web-types-xsl.json +1 -1
- package/src/stories/attributes.test.stories.ts +9 -11
- package/src/stories/css.test.stories.ts +6 -7
- package/src/stories/dom-merge.test.stories.ts +81 -5
- package/src/stories/external-template.test.stories.ts +6 -6
- package/src/stories/form.test.stories.ts +6 -7
- package/src/stories/local-storage.test.stories.ts +7 -7
- package/src/stories/location-element.test.stories.ts +6 -6
- package/src/stories/slice-events.test.stories.ts +6 -6
- package/src/stories/slots.test.stories.ts +6 -7
- package/src/stories/testStoryBook.ts +28 -0
- package/storybook-static/assets/{Color-PRSJMWNM-e4s261EJ.js → Color-PRSJMWNM-y4ZsI1hY.js} +1 -1
- package/storybook-static/assets/{Configure-DWut7txe.js → Configure-CyLVkwlf.js} +1 -1
- package/storybook-static/assets/{DocsRenderer-K4EAMTCU-CaXVGjCl.js → DocsRenderer-K4EAMTCU-VRGUwRrq.js} +2 -2
- package/storybook-static/assets/{WithTooltip-KJL26V4Q--B8vdnMi.js → WithTooltip-KJL26V4Q-xdXH9Ztt.js} +1 -1
- package/storybook-static/assets/{attributes.test.stories-IuwazrdL.js → attributes.test.stories-BckCcyrF.js} +3 -2
- package/storybook-static/assets/{css.test.stories-D9WaxrEv.js → css.test.stories-B-QcObCF.js} +1 -1
- package/storybook-static/assets/{custom-element-BV8-hRQS.js → custom-element-BIxkVg7K.js} +5 -5
- package/storybook-static/assets/dom-merge.test.stories-CjXhjTQY.js +258 -0
- package/storybook-static/assets/{external-template.test.stories-Bpr_wxBo.js → external-template.test.stories-BBqyi0az.js} +1 -1
- package/storybook-static/assets/{form.test.stories-3tURbEdv.js → form.test.stories-DsIo1B4n.js} +1 -1
- package/storybook-static/assets/{formatter-2WMMO6ZP-SJtgH3vM.js → formatter-2WMMO6ZP-CThVcQxM.js} +1 -1
- package/storybook-static/assets/{http-request.stories-8K_qSs8C.js → http-request.stories-sXA_Y-VM.js} +1 -1
- package/storybook-static/assets/{iframe-CM82WlGY.js → iframe-DcDTQOmA.js} +2 -2
- package/storybook-static/assets/{index-DNL-IEpS.js → index-CUFHd5VD.js} +1 -1
- package/storybook-static/assets/{index-CEZitmnt.js → index-DPPi9iZu.js} +5 -5
- package/storybook-static/assets/{index-D1MP-Zis.js → index-VWixWKZ7.js} +1 -1
- package/storybook-static/assets/{local-storage.test.stories-CtisAQBB.js → local-storage.test.stories-Cs2v3QTS.js} +1 -1
- package/storybook-static/assets/{location-element.test.stories-5O_t_m4Y.js → location-element.test.stories-WkrQDzJJ.js} +1 -1
- package/storybook-static/assets/{preview-5Y0XiZgz.js → preview-p-Bwze-K.js} +2 -2
- package/storybook-static/assets/{slice-events.test.stories-BSXCLIA5.js → slice-events.test.stories-BRBBc0JT.js} +1 -1
- package/storybook-static/assets/{slots.test.stories-B1vqfHmN.js → slots.test.stories-r-i91k3y.js} +1 -1
- package/storybook-static/assets/{syntaxhighlighter-BP7B2CQK-BWFH_0wQ.js → syntaxhighlighter-BP7B2CQK-OnioRcs9.js} +1 -1
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/index.json +1 -1
- package/storybook-static/project.json +1 -1
- package/tsconfig.json +31 -21
- package/coverage/src/custom-element/custom-element1-1.js/coverage.svg +0 -10
- package/coverage/src/custom-element/custom-element1-1.js.html +0 -2374
- package/coverage/src/custom-element/custom-element1.js/coverage.svg +0 -10
- package/coverage/src/custom-element/custom-element1.js.html +0 -2374
- package/src/custom-element/custom-element1-1.js +0 -763
- package/src/custom-element/custom-element1.js +0 -763
- package/src/custom-element/custom-element1.js0 +0 -750
- package/src/custom-element/custom-element2.js0 +0 -759
- package/src/custom-element/custom-element3.js0 +0 -763
- package/src/stories/renderPlay.ts +0 -21
- package/storybook-static/assets/dom-merge.test.stories-BhbNeum_.js +0 -137
- /package/coverage/src/stories/{renderPlay.ts → testStoryBook.ts}/coverage.svg +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
`,""))),e.setAttribute("slot","")),e}function C(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(c=>i.append(C(c,l,t))),i}if(e instanceof FormData){const i=N("form-data","",t);for(const c of e)i.append(C(c[1],c[0],t));return i}const n=N(l,"",t);for(let i in e)
|
|
1
|
+
"use strict";const F="http://www.w3.org/1999/XSL/Transform",q="http://www.w3.org/1999/xhtml",pe="http://exslt.org/common",x=(e,l)=>e.getAttribute?.(l),K=e=>e.nodeType===3,fe=e=>typeof e=="string",he=e=>e&&typeof e.nodeType=="number",N=(e,l="",t=document)=>(s=>(l&&s.append(S(t.ownerDocument||t,l)),s))((t.ownerDocument||t).createElement(e)),S=(e,l)=>(e.ownerDocument||e).createTextNode(l),Z=e=>{for(;e.firstChild;)e.firstChild.remove();return e},H=e=>(e.getAttributeNames().map(l=>e.removeAttribute(l)),Z(e)),xe=e=>(e?.setAttribute("xmlns:xsl",F),e),ye=e=>(e?.setAttribute("xmlns:xhtml",q),xe(e)),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 $(e){return new DOMParser().parseFromString(e,"application/xml")}function j(e){return new XMLSerializer().serializeToString(e)}function U(e,l,t,s){const n=h=>e.ownerDocument.createElement(h),c=((h,p,m)=>(p.append(m=n(h)),m))(l,e);return[...t].forEach(h=>c.append(s(h))),c}function be(e){return e.slot||(e.setAttribute||(e=N("span",e.textContent.replaceAll(`
|
|
2
|
+
`,""))),e.setAttribute("slot","")),e}function C(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(c=>i.append(C(c,l,t))),i}if(e instanceof FormData){const i=N("form-data","",t);for(const c of e)i.append(C(c[1],c[0],t));return i}const n=N(l,"",t);for(let i in e)he(e[i])||typeof e[i]=="function"||e[i]instanceof Window||(typeof e[i]!="object"?n.setAttribute(i,e[i]):n.append(C(e[i],i,t)));return n}function W(e){if(D(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,c=p=>S(t,p),h=[];if([...n].forEach(p=>{p.index>i&&h.push(c(p.input.substring(i,p.index)));const m=e.querySelector("value-of").cloneNode();m.setAttribute("select",p[1]),h.push(m),i=p.index+p[0].length}),i<s.length&&h.push(c(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 ee(e,l="xsl:stylesheet"){if(e.tagName===l||e.documentElement?.tagName===l)return W(e);const t=$(`<xsl:stylesheet version="1.0" xmlns:xsl="${F}" xmlns:xhtml="${q}" xmlns:exsl="${pe}" exclude-result-prefixes="exsl" >
|
|
3
3
|
<xsl:output method="xml" />
|
|
4
4
|
<xsl:template match="/"><dce-root xmlns="${q}"><xsl:apply-templates select="*"/></dce-root></xsl:template>
|
|
5
5
|
<xsl:template match="*[name()='template']"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
<xsl:template mode="sanitize" match="text()"><dce-text><xsl:copy/></dce-text></xsl:template>
|
|
13
13
|
<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>
|
|
14
14
|
<xsl:template mode="sanitize" match="xhtml:*"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:element></xsl:template>
|
|
15
|
-
</xsl:stylesheet>`),s=new XSLTProcessor,n=(a=>{D(a,"script",v=>v.remove());const o=a.content??a.firstElementChild?.content??a.body??a;
|
|
16
|
-
xmlns:xsl="${
|
|
15
|
+
</xsl:stylesheet>`),s=new XSLTProcessor,n=(a=>{D(a,"script",v=>v.remove());const o=a.content??a.firstElementChild?.content??a.body??a;ce.forEach(v=>D(o,v,b=>me(b,o)));const E=a.firstElementChild?.content||a.content,g=v=>{const b=$("<xhtml/>"),P=b.importNode(v,!0);return b.replaceChild(P,b.documentElement),ye(P)};if(E){const v=N("div");return[...E.childNodes].map(b=>v.append(b.cloneNode(!0))),g(v)}return g(a.documentElement||a.body||a)})(e),i=$(`<xsl:stylesheet version="1.0"
|
|
16
|
+
xmlns:xsl="${F}"
|
|
17
17
|
xmlns:xhtml="${q}"
|
|
18
18
|
xmlns:dce="urn:schemas-epa-wg:dce"
|
|
19
19
|
xmlns:exsl="http://exslt.org/common"
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
<xsl:with-param name="defaultvalue"/>
|
|
47
47
|
</xsl:call-template>
|
|
48
48
|
</xsl:variable>
|
|
49
|
-
</xsl:stylesheet>`);s.importStylesheet(t);const c=s.transformToFragment(n,document),h=(a,o)=>a.querySelector(o),p=h(i,'template[mode="payload"]');if(!c)return console.error("transformation error",{xml:n.outerHTML,xsl:
|
|
50
|
-
`)});const c=this,h=[...this.templateNode.querySelectorAll("[slice]")],p=h.map(d=>x(d,"slice")).filter(d=>!d.includes("/")).filter((d,u,a)=>a.indexOf(d)===u).map(le).flat(),m=n.reduce((d,u)=>(u.params&&d.push(...u.params),d),[]);class w extends HTMLElement{static get observedAttributes(){return m.map(u=>x(u,"name"))}#e=0;connectedCallback(){let u=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(),u=f.content.childNodes;for(const r of[...f.content.childNodes])if(r.localName==="style"){const y=
|
|
51
|
-
`,
|
|
49
|
+
</xsl:stylesheet>`);s.importStylesheet(t);const c=s.transformToFragment(n,document),h=(a,o)=>a.querySelector(o),p=h(i,'template[mode="payload"]');if(!c)return console.error("transformation error",{xml:n.outerHTML,xsl:j(t)});const m=[];[...c.querySelectorAll("dce-root>attribute")].forEach(a=>{const o=Q(a,"xsl:param"),E=x(a,"name");p.append(o);let g=x(o,"select")?.split("??");g||(g=["//"+E,`'${o.textContent}'`],H(o),o.setAttribute("name",E));let v;if(g?.length>1){o.removeAttribute("select");const b=h(i,'template[match="ignore"]>choose').cloneNode(!0);H(b.firstElementChild).append(S(b,"{"+g[0]+"}")),H(b.lastElementChild).append(S(b,"{"+g[1]+"}")),b.firstElementChild.setAttribute("test",g[0]),o.append(b),v=b.cloneNode(!0)}else v=Q(a,"xsl:value-of");v.removeAttribute("name"),a.append(v),a.removeAttribute("select"),m.push(o)}),[...c.querySelectorAll("[value]")].filter(a=>a.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach(a=>{const o=x(a,"value");o&&a.setAttribute("value",oe(o))});for(const a of c.childNodes)p.append(i.importNode(a,!0));[...p.querySelectorAll("template")].forEach(a=>p.ownerDocument.documentElement.append(a));const M=h(i,'call-template[name="slot"]'),d=a=>{const o=M.cloneNode(!0),E=x(a,"name");E&&o.firstElementChild.setAttribute("select",`'${E}'`);for(let g of a.childNodes)o.lastElementChild.append(g);return o};D(p,"slot",a=>a.parentNode.replaceChild(d(a),a));const u=W(i);return u.params=m,u}async function te(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||N("div",n.responseText)),s(n.statusText)},n.addEventListener("error",i=>s(i)),n.send()})}function se(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)||!se(e[s],l[s]))return t;return!0}const le=e=>e.split("|").map(l=>l.trim()).filter(l=>l),ne=(e,l)=>le(l).map(t=>{let s=e.ownerDocument,n=i=>(e.append(i),i);if(t.includes("/")){const i=[],c=s.evaluate(t,e);for(let h;h=c.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,ne(e,l??"").map(n=>{const i=e.ownerDocument,c=t.sliceEventSource,h=t.sliceElement,p=()=>[...n.childNodes].filter(m=>m.nodeType===3||m.localName==="value"||m.localName==="form-data").map(m=>m.remove());if(c.getAttributeNames().map(m=>n.setAttribute(m,x(c,m))),[...n.childNodes].filter(m=>m.localName==="event").map(m=>m.remove()),"validationMessage"in c&&n.setAttribute("validation-message",c.validationMessage),t.type==="init"&&p(),n.append(C(t,"event",i)),h.hasAttribute("slice-value")){c.value===void 0?n.removeAttribute("value"):n.setAttribute("value",c.value);const m=L(x(h,"slice-value"),n);p(),n.append(S(i,m))}else{if("elements"in c)return p(),n.append(C(new FormData(c),"value",n.ownerDocument)),n;const m=c.value??x(h,"value");p(),m==null?[...n.childNodes].filter(w=>w.localName!=="event").map(w=>w.remove()):fe(m)?n.append(S(i,m)):n.append(C(m,"value",n.ownerDocument))}return n})}function D(e,l,t){e.querySelectorAll&&[...e.querySelectorAll(l)].forEach(t)}const ge=async(e,l)=>{if(!e||!e.trim())return[l];if(e.startsWith("#"))return(t=>{if(!t)return[];const s=t.querySelectorAll(e);if(s.length)return[...s];const n=t.getRootNode();return n===t?[]:getByHashId(n)})(l.parentElement);try{const t=await te(e),s=new URL(e,location).hash;if(s){const n=t.querySelectorAll(s);return n.length?[...n]:[l]}return[t]}catch{return[l]}};function ae(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=x(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 ie(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 J(e,l){if(!l.length)return Z(e);const t={};for(let s of e.childNodes)t[s.dceId],K(s)?(s.data.trim(),t[s.dceId||0]=s):t[x(s,"data-dce-id")||0]=s;for(let s of[...l]){const n=x(s,"data-dce-id")||s.dceId,i=t[n];i?(K(s)?i.nodeValue!==s.nodeValue&&(i.nodeValue=s.nodeValue):(ae(s,i),(i.childNodes.length||s.childNodes.length)&&J(i,s.childNodes)),delete t[n]):ie(e,s,n)}for(let s of Object.values(t))s.remove()}function re(e,l){return e.hasAttribute(l)||e.setAttribute(l,crypto.randomUUID()),e.getAttribute(l)}const oe=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},L=(e,l)=>{const t=e.split("??");if(t.length>1)return L(t[0],l)||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},ce="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(","),me=(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,c)=>{i===e&&(n[c]=t)}),s.replaceChildren(...n)}};class ue extends HTMLElement{static observedAttributes=["src","tag","hidden"];async connectedCallback(){const l=await ge(x(this,"src"),this),t=x(this,"tag"),s=t||"dce-"+crypto.randomUUID();for(const d of l)D(d.templateNode||d.content||d,"style",u=>{const a=u.closest("slot"),o=a?`slot[name="${a.name}"]`:"";u.innerHTML=`${s} ${o}{${u.innerHTML}}`,this.append(u)});const n=l.map(d=>ee(d)),i=n.map((d,u)=>(u=new XSLTProcessor,u.importStylesheet(d),u));Object.defineProperty(this,"xsltString",{get:()=>n.map(d=>j(d)).join(`
|
|
50
|
+
`)});const c=this,h=[...this.templateNode.querySelectorAll("[slice]")],p=h.map(d=>x(d,"slice")).filter(d=>!d.includes("/")).filter((d,u,a)=>a.indexOf(d)===u).map(le).flat(),m=n.reduce((d,u)=>(u.params&&d.push(...u.params),d),[]);class w extends HTMLElement{static get observedAttributes(){return m.map(u=>x(u,"name"))}#e=0;connectedCallback(){let u=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(),u=f.content.childNodes;for(const r of[...f.content.childNodes])if(r.localName==="style"){const y=re(this,"data-dce-style");r.innerHTML=`${s}[data-dce-style="${y}"]{${r.innerHTML}}`,f.insertAdjacentElement("beforebegin",r)}else r.nodeType===1?f.insertAdjacentElement("beforebegin",r):r.nodeType===3&&f.insertAdjacentText("beforebegin",r.data)}const a=$("<datadom/>").documentElement,o=(f,r="")=>(y=>(r&&y.append(S(a,r)),y))(a.ownerDocument.createElement(f));U(a,"payload",u,be),this.innerHTML="";const E=U(a,"attributes",this.attributes,f=>o(f.nodeName,f.value));U(a,"dataset",Object.keys(this.dataset),f=>o(f,this.dataset[f]));const g=U(a,"slice",p,f=>o(f,"")),v=f=>L(f,g);this.xml=a;const b=[],P=()=>{const f={};for(let r;r=b.pop();){const y=x(r.sliceElement,"slice");f[y]||(Y(g,y,r),f[y]=r)}Object.keys(f).length!==0&&R()};let O;this.onSlice=f=>{b.push(f),O||(O=setTimeout(()=>{P(),O=0},1))};const R=this.transform=()=>{if(this.#e)debugger;this.#e=1,i.map((r,y)=>{const X=r.transformToFragment(a.ownerDocument,document);return X||console.error(`XSLT transformation error. xsl:
|
|
51
|
+
`,j(n[y]),`
|
|
52
52
|
xml:
|
|
53
|
-
`,
|
|
53
|
+
`,j(a)),X}).map(r=>{r&&(G(r),J(this,r.childNodes))}),w.observedAttributes.map(r=>{let y=x(this.firstElementChild,r);y!==x(this,r)&&(this.setAttribute(r,y),this.#t(r,y))}),D(this,"[slice],[slice-event]",r=>{if(!r.dceInitialized){r.dceInitialized=1;let y=x(r,"slice-event");x(r,"custom-validity")&&(y+=" change submit"),[...new Set((y||"change").split(" "))].forEach(X=>(r.localName==="slice"?r.parentElement:r).addEventListener(X,A=>{A.sliceElement=r,A.sliceEventSource=A.currentTarget||A.target;const de=Y(g,x(A.sliceElement,"slice"),A);D(this,"[custom-validity]",z=>{if(!z.setCustomValidity)return;const B=x(z,"custom-validity");try{const I=B&&L(B,E);z.setCustomValidity(I===!0?"":I===!1?"invalid":I)}catch(I){console.error(I,"xPath",B)}});const k=x(r,"custom-validity"),T=k&&L(k,E),_=T===!0?"":T;if(k){if(r.setCustomValidity?r.setCustomValidity(_):r.validationMessage=_,de.map(z=>z.setAttribute("validation-message",_)),A.type==="submit")return T===!0?void 0:(setTimeout(R,1),!!T===T?(T||A.preventDefault(),T):T?(A.preventDefault(),!1):void 0);setTimeout(R,1)}this.onSlice(A)})),(!y||y.includes("init"))&&(r.hasAttribute("slice-value")||r.hasAttribute("value")||r.value?this.onSlice({type:"init",target:r,sliceElement:r,sliceEventSource:r}):r.value=v(x(r,"slice")))}}),this.#e=0};R(),P()}#t(u,a){let o=this.xml.querySelector(`attributes>${u}`);o?H(o).append(S(o,a)):(o=N(u,a,this.xml),this.xml.querySelector("attributes").append(o))}attributeChangedCallback(u,a,o){!this.xml||this.#e||(this.#t(u,o),this.transform())}get dce(){return c}}const M=d=>{window.customElements.get(d)!==w&&window.customElements.define(d,w)};if(t)M(t);else{const d=s;this.setAttribute("tag",d),M(d);const u=document.createElement(d);this.getAttributeNames().forEach(a=>u.setAttribute(a,this.getAttribute(a))),u.append(...[...this.childNodes].filter(a=>a.localName!=="style")),this.append(u)}}get templateNode(){return this.firstElementChild?.tagName==="TEMPLATE"?this.firstElementChild.content:this}get dce(){return this}get xslt(){return $(this.xsltString)}}window.customElements.define("custom-element",ue);exports.CustomElement=ue;exports.appendByDceId=ie;exports.assureSlices=ne;exports.assureUID=re;exports.assureUnique=G;exports.createXsltFromDom=ee;exports.deepEqual=se;exports.evalCurly=oe;exports.event2slice=Y;exports.merge=J;exports.mergeAttr=ae;exports.obj2node=C;exports.tagUid=W;exports.toXsl=me;exports.xPath=L;exports.xPathDefaults=V;exports.xhrTemplate=te;exports.xml2dom=$;exports.xmlString=j;exports.xslTags=ce;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const B = "http://www.w3.org/1999/XSL/Transform", q = "http://www.w3.org/1999/xhtml", se = "http://exslt.org/common", x = (e, l) => e.getAttribute?.(l), W = (e) => e.nodeType === 3, le = (e) => typeof e == "string", ne = (e) => e && typeof e.nodeType == "number", N = (e, l = "", t = document) => ((s) => (l && s.append(S(t.ownerDocument || t, l)), s))((t.ownerDocument || t).createElement(e)), S = (e, l) => (e.ownerDocument || e).createTextNode(l), K = (e) => {
|
|
2
2
|
for (; e.firstChild; ) e.firstChild.remove();
|
|
3
3
|
return e;
|
|
4
|
-
}, U = (e) => (e.getAttributeNames().map((l) => e.removeAttribute(l)), K(e)), ae = (e) => (e?.setAttribute("xmlns:xsl",
|
|
4
|
+
}, U = (e) => (e.getAttributeNames().map((l) => e.removeAttribute(l)), K(e)), ae = (e) => (e?.setAttribute("xmlns:xsl", B), e), ie = (e) => (e?.setAttribute("xmlns:xhtml", q), ae(e)), Y = (e, l) => {
|
|
5
5
|
const t = e.ownerDocument.createElementNS(e.namespaceURI, l);
|
|
6
6
|
for (let s of e.attributes)
|
|
7
7
|
t.setAttribute(s.name, s.value);
|
|
@@ -23,7 +23,7 @@ function re(e) {
|
|
|
23
23
|
return e.slot || (e.setAttribute || (e = N("span", e.textContent.replaceAll(`
|
|
24
24
|
`, ""))), e.setAttribute("slot", "")), e;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function D(e, l, t) {
|
|
27
27
|
const s = typeof e;
|
|
28
28
|
if (s === "string")
|
|
29
29
|
return N(l, e, t);
|
|
@@ -31,17 +31,17 @@ function L(e, l, t) {
|
|
|
31
31
|
return N(l, "" + e, t);
|
|
32
32
|
if (e instanceof Array) {
|
|
33
33
|
const i = N("array", "", t);
|
|
34
|
-
return e.map((c) => i.append(
|
|
34
|
+
return e.map((c) => i.append(D(c, l, t))), i;
|
|
35
35
|
}
|
|
36
36
|
if (e instanceof FormData) {
|
|
37
37
|
const i = N("form-data", "", t);
|
|
38
38
|
for (const c of e)
|
|
39
|
-
i.append(
|
|
39
|
+
i.append(D(c[1], c[0], t));
|
|
40
40
|
return i;
|
|
41
41
|
}
|
|
42
42
|
const n = N(l, "", t);
|
|
43
43
|
for (let i in e)
|
|
44
|
-
ne(e[i]) || typeof e[i] == "function" || e[i] instanceof Window || (typeof e[i] != "object" ? n.setAttribute(i, e[i]) : n.append(
|
|
44
|
+
ne(e[i]) || typeof e[i] == "function" || e[i] instanceof Window || (typeof e[i] != "object" ? n.setAttribute(i, e[i]) : n.append(D(e[i], i, t)));
|
|
45
45
|
return n;
|
|
46
46
|
}
|
|
47
47
|
function G(e) {
|
|
@@ -69,7 +69,7 @@ function G(e) {
|
|
|
69
69
|
function oe(e, l = "xsl:stylesheet") {
|
|
70
70
|
if (e.tagName === l || e.documentElement?.tagName === l)
|
|
71
71
|
return G(e);
|
|
72
|
-
const t = M(`<xsl:stylesheet version="1.0" xmlns:xsl="${
|
|
72
|
+
const t = M(`<xsl:stylesheet version="1.0" xmlns:xsl="${B}" xmlns:xhtml="${q}" xmlns:exsl="${se}" exclude-result-prefixes="exsl" >
|
|
73
73
|
<xsl:output method="xml" />
|
|
74
74
|
<xsl:template match="/"><dce-root xmlns="${q}"><xsl:apply-templates select="*"/></dce-root></xsl:template>
|
|
75
75
|
<xsl:template match="*[name()='template']"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
|
|
@@ -83,21 +83,21 @@ function oe(e, l = "xsl:stylesheet") {
|
|
|
83
83
|
<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>
|
|
84
84
|
<xsl:template mode="sanitize" match="xhtml:*"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:element></xsl:template>
|
|
85
85
|
</xsl:stylesheet>`), s = new XSLTProcessor(), n = ((a) => {
|
|
86
|
-
C(a, "script", (
|
|
86
|
+
C(a, "script", (v) => v.remove());
|
|
87
87
|
const o = a.content ?? a.firstElementChild?.content ?? a.body ?? a;
|
|
88
|
-
|
|
89
|
-
const E = a.firstElementChild?.content || a.content,
|
|
90
|
-
const b = M("<xhtml/>"), $ = b.importNode(
|
|
88
|
+
ye.forEach((v) => C(o, v, (b) => be(b, o)));
|
|
89
|
+
const E = a.firstElementChild?.content || a.content, g = (v) => {
|
|
90
|
+
const b = M("<xhtml/>"), $ = b.importNode(v, !0);
|
|
91
91
|
return b.replaceChild($, b.documentElement), ie($);
|
|
92
92
|
};
|
|
93
93
|
if (E) {
|
|
94
|
-
const
|
|
95
|
-
return [...E.childNodes].map((b) =>
|
|
94
|
+
const v = N("div");
|
|
95
|
+
return [...E.childNodes].map((b) => v.append(b.cloneNode(!0))), g(v);
|
|
96
96
|
}
|
|
97
|
-
return
|
|
97
|
+
return g(a.documentElement || a.body || a);
|
|
98
98
|
})(e), i = M(
|
|
99
99
|
`<xsl:stylesheet version="1.0"
|
|
100
|
-
xmlns:xsl="${
|
|
100
|
+
xmlns:xsl="${B}"
|
|
101
101
|
xmlns:xhtml="${q}"
|
|
102
102
|
xmlns:dce="urn:schemas-epa-wg:dce"
|
|
103
103
|
xmlns:exsl="http://exslt.org/common"
|
|
@@ -140,19 +140,19 @@ function oe(e, l = "xsl:stylesheet") {
|
|
|
140
140
|
[...c.querySelectorAll("dce-root>attribute")].forEach((a) => {
|
|
141
141
|
const o = Y(a, "xsl:param"), E = x(a, "name");
|
|
142
142
|
p.append(o);
|
|
143
|
-
let
|
|
144
|
-
|
|
145
|
-
let
|
|
146
|
-
if (
|
|
143
|
+
let g = x(o, "select")?.split("??");
|
|
144
|
+
g || (g = ["//" + E, `'${o.textContent}'`], U(o), o.setAttribute("name", E));
|
|
145
|
+
let v;
|
|
146
|
+
if (g?.length > 1) {
|
|
147
147
|
o.removeAttribute("select");
|
|
148
148
|
const b = h(i, 'template[match="ignore"]>choose').cloneNode(!0);
|
|
149
|
-
U(b.firstElementChild).append(S(b, "{" +
|
|
149
|
+
U(b.firstElementChild).append(S(b, "{" + g[0] + "}")), U(b.lastElementChild).append(S(b, "{" + g[1] + "}")), b.firstElementChild.setAttribute("test", g[0]), o.append(b), v = b.cloneNode(!0);
|
|
150
150
|
} else
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
v = Y(a, "xsl:value-of");
|
|
152
|
+
v.removeAttribute("name"), a.append(v), a.removeAttribute("select"), m.push(o);
|
|
153
153
|
}), [...c.querySelectorAll("[value]")].filter((a) => a.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach((a) => {
|
|
154
154
|
const o = x(a, "value");
|
|
155
|
-
o && a.setAttribute("value",
|
|
155
|
+
o && a.setAttribute("value", xe(o));
|
|
156
156
|
});
|
|
157
157
|
for (const a of c.childNodes)
|
|
158
158
|
p.append(i.importNode(a, !0));
|
|
@@ -160,8 +160,8 @@ function oe(e, l = "xsl:stylesheet") {
|
|
|
160
160
|
const P = h(i, 'call-template[name="slot"]'), d = (a) => {
|
|
161
161
|
const o = P.cloneNode(!0), E = x(a, "name");
|
|
162
162
|
E && o.firstElementChild.setAttribute("select", `'${E}'`);
|
|
163
|
-
for (let
|
|
164
|
-
o.lastElementChild.append(
|
|
163
|
+
for (let g of a.childNodes)
|
|
164
|
+
o.lastElementChild.append(g);
|
|
165
165
|
return o;
|
|
166
166
|
};
|
|
167
167
|
C(p, "slot", (a) => a.parentNode.replaceChild(d(a), a));
|
|
@@ -200,15 +200,15 @@ function J(e, l, t, s) {
|
|
|
200
200
|
if (!t.sliceProcessed)
|
|
201
201
|
return t.sliceProcessed = 1, ue(e, l ?? "").map((n) => {
|
|
202
202
|
const i = e.ownerDocument, c = t.sliceEventSource, h = t.sliceElement, p = () => [...n.childNodes].filter((m) => m.nodeType === 3 || m.localName === "value" || m.localName === "form-data").map((m) => m.remove());
|
|
203
|
-
if (c.getAttributeNames().map((m) => n.setAttribute(m, x(c, m))), [...n.childNodes].filter((m) => m.localName === "event").map((m) => m.remove()), "validationMessage" in c && n.setAttribute("validation-message", c.validationMessage), t.type === "init" && p(), n.append(
|
|
203
|
+
if (c.getAttributeNames().map((m) => n.setAttribute(m, x(c, m))), [...n.childNodes].filter((m) => m.localName === "event").map((m) => m.remove()), "validationMessage" in c && n.setAttribute("validation-message", c.validationMessage), t.type === "init" && p(), n.append(D(t, "event", i)), h.hasAttribute("slice-value")) {
|
|
204
204
|
c.value === void 0 ? n.removeAttribute("value") : n.setAttribute("value", c.value);
|
|
205
|
-
const m =
|
|
205
|
+
const m = L(x(h, "slice-value"), n);
|
|
206
206
|
p(), n.append(S(i, m));
|
|
207
207
|
} else {
|
|
208
208
|
if ("elements" in c)
|
|
209
|
-
return p(), n.append(
|
|
209
|
+
return p(), n.append(D(new FormData(c), "value", n.ownerDocument)), n;
|
|
210
210
|
const m = c.value ?? x(h, "value");
|
|
211
|
-
p(), m == null ? [...n.childNodes].filter((w) => w.localName !== "event").map((w) => w.remove()) : le(m) ? n.append(S(i, m)) : n.append(
|
|
211
|
+
p(), m == null ? [...n.childNodes].filter((w) => w.localName !== "event").map((w) => w.remove()) : le(m) ? n.append(S(i, m)) : n.append(D(m, "value", n.ownerDocument));
|
|
212
212
|
}
|
|
213
213
|
return n;
|
|
214
214
|
});
|
|
@@ -256,6 +256,13 @@ function Z(e, l = 0) {
|
|
|
256
256
|
s.childNodes.length && Z(s);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
+
function fe(e, l, t) {
|
|
260
|
+
t = 1 * t;
|
|
261
|
+
for (let s of e.childNodes)
|
|
262
|
+
if ((s.dceId ?? s.getAttribute("data-dce-id") * 1) > t)
|
|
263
|
+
return e.insertBefore(l, s);
|
|
264
|
+
e.append(l);
|
|
265
|
+
}
|
|
259
266
|
function ee(e, l) {
|
|
260
267
|
if (!l.length)
|
|
261
268
|
return K(e);
|
|
@@ -264,24 +271,24 @@ function ee(e, l) {
|
|
|
264
271
|
t[s.dceId], W(s) ? (s.data.trim(), t[s.dceId || 0] = s) : t[x(s, "data-dce-id") || 0] = s;
|
|
265
272
|
for (let s of [...l]) {
|
|
266
273
|
const n = x(s, "data-dce-id") || s.dceId, i = t[n];
|
|
267
|
-
i ? (W(s) ? i.nodeValue !== s.nodeValue && (i.nodeValue = s.nodeValue) : (pe(s, i), (i.childNodes.length || s.childNodes.length) && ee(i, s.childNodes)), delete t[n]) : e
|
|
274
|
+
i ? (W(s) ? i.nodeValue !== s.nodeValue && (i.nodeValue = s.nodeValue) : (pe(s, i), (i.childNodes.length || s.childNodes.length) && ee(i, s.childNodes)), delete t[n]) : fe(e, s, n);
|
|
268
275
|
}
|
|
269
276
|
for (let s of Object.values(t))
|
|
270
277
|
s.remove();
|
|
271
278
|
}
|
|
272
|
-
function
|
|
279
|
+
function he(e, l) {
|
|
273
280
|
return e.hasAttribute(l) || e.setAttribute(l, crypto.randomUUID()), e.getAttribute(l);
|
|
274
281
|
}
|
|
275
|
-
const
|
|
282
|
+
const xe = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `${t[1]}{${F(t[3])}}${t[4]}`).join(""), F = (e) => {
|
|
276
283
|
if (!e.trim())
|
|
277
284
|
return e;
|
|
278
|
-
const l = e.split("??"), t = l.shift(), s =
|
|
285
|
+
const l = e.split("??"), t = l.shift(), s = F(l.join("??"));
|
|
279
286
|
return l.length ? `concat( ${t} , substring( ${s} , (1+string-length( ${s} )) * string-length( ${t} ) ) )` : e;
|
|
280
|
-
},
|
|
287
|
+
}, L = (e, l) => {
|
|
281
288
|
const t = e.split("??");
|
|
282
289
|
if (t.length > 1)
|
|
283
|
-
return
|
|
284
|
-
e =
|
|
290
|
+
return L(t[0], l) || L(t[1], l);
|
|
291
|
+
e = F(e);
|
|
285
292
|
const s = l.ownerDocument.evaluate(e, l);
|
|
286
293
|
switch (s.resultType) {
|
|
287
294
|
case XPathResult.NUMBER_TYPE:
|
|
@@ -295,7 +302,7 @@ const he = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `
|
|
|
295
302
|
for (let i; i = s.iterateNext(); )
|
|
296
303
|
n += i.textContent;
|
|
297
304
|
return n;
|
|
298
|
-
},
|
|
305
|
+
}, ye = "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(","), be = (e, l) => {
|
|
299
306
|
const t = N("xsl:" + e.localName);
|
|
300
307
|
for (let s of e.attributes)
|
|
301
308
|
t.setAttribute(s.name, s.value);
|
|
@@ -310,7 +317,7 @@ const he = (e) => [...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map((t) => `
|
|
|
310
317
|
}), s.replaceChildren(...n);
|
|
311
318
|
}
|
|
312
319
|
};
|
|
313
|
-
class
|
|
320
|
+
class ge extends HTMLElement {
|
|
314
321
|
static observedAttributes = ["src", "tag", "hidden"];
|
|
315
322
|
async connectedCallback() {
|
|
316
323
|
const l = await de(x(this, "src"), this), t = x(this, "tag"), s = t || "dce-" + crypto.randomUUID();
|
|
@@ -336,7 +343,7 @@ class be extends HTMLElement {
|
|
|
336
343
|
f.remove(), u = f.content.childNodes;
|
|
337
344
|
for (const r of [...f.content.childNodes])
|
|
338
345
|
if (r.localName === "style") {
|
|
339
|
-
const y =
|
|
346
|
+
const y = he(this, "data-dce-style");
|
|
340
347
|
r.innerHTML = `${s}[data-dce-style="${y}"]{${r.innerHTML}}`, f.insertAdjacentElement("beforebegin", r);
|
|
341
348
|
} else
|
|
342
349
|
r.nodeType === 1 ? f.insertAdjacentElement("beforebegin", r) : r.nodeType === 3 && f.insertAdjacentText("beforebegin", r.data);
|
|
@@ -345,31 +352,31 @@ class be extends HTMLElement {
|
|
|
345
352
|
X(a, "payload", u, re), this.innerHTML = "";
|
|
346
353
|
const E = X(a, "attributes", this.attributes, (f) => o(f.nodeName, f.value));
|
|
347
354
|
X(a, "dataset", Object.keys(this.dataset), (f) => o(f, this.dataset[f]));
|
|
348
|
-
const
|
|
355
|
+
const g = X(a, "slice", p, (f) => o(f, "")), v = (f) => L(f, g);
|
|
349
356
|
this.xml = a;
|
|
350
357
|
const b = [], $ = () => {
|
|
351
358
|
const f = {};
|
|
352
359
|
for (let r; r = b.pop(); ) {
|
|
353
360
|
const y = x(r.sliceElement, "slice");
|
|
354
|
-
f[y] || (J(
|
|
361
|
+
f[y] || (J(g, y, r), f[y] = r);
|
|
355
362
|
}
|
|
356
|
-
Object.keys(f).length !== 0 &&
|
|
363
|
+
Object.keys(f).length !== 0 && I();
|
|
357
364
|
};
|
|
358
|
-
let
|
|
365
|
+
let V;
|
|
359
366
|
this.onSlice = (f) => {
|
|
360
|
-
b.push(f),
|
|
361
|
-
$(),
|
|
367
|
+
b.push(f), V || (V = setTimeout(() => {
|
|
368
|
+
$(), V = 0;
|
|
362
369
|
}, 1));
|
|
363
370
|
};
|
|
364
|
-
const
|
|
371
|
+
const I = this.transform = () => {
|
|
365
372
|
if (this.#e)
|
|
366
373
|
debugger;
|
|
367
374
|
this.#e = 1, i.map((r, y) => {
|
|
368
|
-
const
|
|
369
|
-
return
|
|
375
|
+
const R = r.transformToFragment(a.ownerDocument, document);
|
|
376
|
+
return R || console.error(`XSLT transformation error. xsl:
|
|
370
377
|
`, H(n[y]), `
|
|
371
378
|
xml:
|
|
372
|
-
`, H(a)),
|
|
379
|
+
`, H(a)), R;
|
|
373
380
|
}).map((r) => {
|
|
374
381
|
r && (Z(r), ee(this, r.childNodes));
|
|
375
382
|
}), w.observedAttributes.map((r) => {
|
|
@@ -379,32 +386,32 @@ xml:
|
|
|
379
386
|
if (!r.dceInitialized) {
|
|
380
387
|
r.dceInitialized = 1;
|
|
381
388
|
let y = x(r, "slice-event");
|
|
382
|
-
x(r, "custom-validity") && (y += " change submit"), [...new Set((y || "change").split(" "))].forEach((
|
|
389
|
+
x(r, "custom-validity") && (y += " change submit"), [...new Set((y || "change").split(" "))].forEach((R) => (r.localName === "slice" ? r.parentElement : r).addEventListener(R, (A) => {
|
|
383
390
|
A.sliceElement = r, A.sliceEventSource = A.currentTarget || A.target;
|
|
384
|
-
const te = J(
|
|
391
|
+
const te = J(g, x(A.sliceElement, "slice"), A);
|
|
385
392
|
C(this, "[custom-validity]", (z) => {
|
|
386
393
|
if (!z.setCustomValidity)
|
|
387
394
|
return;
|
|
388
395
|
const _ = x(z, "custom-validity");
|
|
389
396
|
try {
|
|
390
|
-
const j = _ &&
|
|
397
|
+
const j = _ && L(_, E);
|
|
391
398
|
z.setCustomValidity(j === !0 ? "" : j === !1 ? "invalid" : j);
|
|
392
399
|
} catch (j) {
|
|
393
400
|
console.error(j, "xPath", _);
|
|
394
401
|
}
|
|
395
402
|
});
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
403
|
+
const k = x(r, "custom-validity"), T = k && L(k, E), O = T === !0 ? "" : T;
|
|
404
|
+
if (k) {
|
|
398
405
|
if (r.setCustomValidity ? r.setCustomValidity(O) : r.validationMessage = O, te.map((z) => z.setAttribute("validation-message", O)), A.type === "submit")
|
|
399
|
-
return T === !0 ? void 0 : (setTimeout(
|
|
400
|
-
setTimeout(
|
|
406
|
+
return T === !0 ? void 0 : (setTimeout(I, 1), !!T === T ? (T || A.preventDefault(), T) : T ? (A.preventDefault(), !1) : void 0);
|
|
407
|
+
setTimeout(I, 1);
|
|
401
408
|
}
|
|
402
409
|
this.onSlice(A);
|
|
403
|
-
})), (!y || y.includes("init")) && (r.hasAttribute("slice-value") || r.hasAttribute("value") || r.value ? this.onSlice({ type: "init", target: r, sliceElement: r, sliceEventSource: r }) : r.value =
|
|
410
|
+
})), (!y || y.includes("init")) && (r.hasAttribute("slice-value") || r.hasAttribute("value") || r.value ? this.onSlice({ type: "init", target: r, sliceElement: r, sliceEventSource: r }) : r.value = v(x(r, "slice")));
|
|
404
411
|
}
|
|
405
412
|
}), this.#e = 0;
|
|
406
413
|
};
|
|
407
|
-
|
|
414
|
+
I(), $();
|
|
408
415
|
}
|
|
409
416
|
#t(u, a) {
|
|
410
417
|
let o = this.xml.querySelector(`attributes>${u}`);
|
|
@@ -439,9 +446,9 @@ xml:
|
|
|
439
446
|
return M(this.xsltString);
|
|
440
447
|
}
|
|
441
448
|
}
|
|
442
|
-
window.customElements.define("custom-element",
|
|
449
|
+
window.customElements.define("custom-element", ge);
|
|
443
450
|
export {
|
|
444
|
-
|
|
451
|
+
ge as C,
|
|
445
452
|
H as a,
|
|
446
453
|
ce as b,
|
|
447
454
|
oe as c,
|
|
@@ -449,15 +456,16 @@ export {
|
|
|
449
456
|
ue as e,
|
|
450
457
|
J as f,
|
|
451
458
|
Z as g,
|
|
452
|
-
|
|
453
|
-
|
|
459
|
+
fe as h,
|
|
460
|
+
ee as i,
|
|
454
461
|
he as j,
|
|
455
|
-
|
|
456
|
-
|
|
462
|
+
xe as k,
|
|
463
|
+
F as l,
|
|
457
464
|
pe as m,
|
|
458
|
-
|
|
459
|
-
|
|
465
|
+
L as n,
|
|
466
|
+
D as o,
|
|
460
467
|
ye as p,
|
|
468
|
+
be as q,
|
|
461
469
|
G as t,
|
|
462
470
|
M as x
|
|
463
471
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./custom-element-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./custom-element-BDK7dcJN.cjs"),l=require("./http-request-DPrY7mGh.cjs"),t=require("./local-storage-Boafngui.cjs"),a=require("./location-element-2m0gWq_d.cjs");exports.CustomElement=e.CustomElement;exports.appendByDceId=e.appendByDceId;exports.assureSlices=e.assureSlices;exports.assureUID=e.assureUID;exports.assureUnique=e.assureUnique;exports.createXsltFromDom=e.createXsltFromDom;exports.deepEqual=e.deepEqual;exports.default=e.CustomElement;exports.evalCurly=e.evalCurly;exports.event2slice=e.event2slice;exports.merge=e.merge;exports.mergeAttr=e.mergeAttr;exports.obj2node=e.obj2node;exports.tagUid=e.tagUid;exports.toXsl=e.toXsl;exports.xPath=e.xPath;exports.xPathDefaults=e.xPathDefaults;exports.xhrTemplate=e.xhrTemplate;exports.xml2dom=e.xml2dom;exports.xmlString=e.xmlString;exports.xslTags=e.xslTags;exports.HttpRequestElement=l.HttpRequestElement;exports.LocalStorageElement=t.LocalStorageElement;exports.localStorageSetItem=t.localStorageSetItem;exports.LocationElement=a.LocationElement;
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import { C as e } from "./custom-element-
|
|
2
|
-
import {
|
|
3
|
-
import { H as
|
|
1
|
+
import { C as e } from "./custom-element-DqtzLkTG.js";
|
|
2
|
+
import { h as o, e as r, j as l, g as m, c as p, d as x, k as n, f as u, i as c, m as d, o as f, t as g, q as i, n as E, l as S, b as h, x as q, a as D, p as L } from "./custom-element-DqtzLkTG.js";
|
|
3
|
+
import { H as I } from "./http-request-BOvP4KTl.js";
|
|
4
4
|
import { L as b, l as j } from "./local-storage-BqDEu2kF.js";
|
|
5
|
-
import { L as
|
|
5
|
+
import { L as y } from "./location-element-nA_wsqBt.js";
|
|
6
6
|
export {
|
|
7
7
|
e as CustomElement,
|
|
8
|
-
|
|
8
|
+
I as HttpRequestElement,
|
|
9
9
|
b as LocalStorageElement,
|
|
10
|
-
|
|
11
|
-
o as
|
|
12
|
-
r as
|
|
13
|
-
l as
|
|
14
|
-
m as
|
|
10
|
+
y as LocationElement,
|
|
11
|
+
o as appendByDceId,
|
|
12
|
+
r as assureSlices,
|
|
13
|
+
l as assureUID,
|
|
14
|
+
m as assureUnique,
|
|
15
|
+
p as createXsltFromDom,
|
|
15
16
|
x as deepEqual,
|
|
16
17
|
e as default,
|
|
17
18
|
n as evalCurly,
|
|
18
|
-
|
|
19
|
+
u as event2slice,
|
|
19
20
|
j as localStorageSetItem,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
c as merge,
|
|
22
|
+
d as mergeAttr,
|
|
23
|
+
f as obj2node,
|
|
24
|
+
g as tagUid,
|
|
25
|
+
i as toXsl,
|
|
26
|
+
E as xPath,
|
|
27
|
+
S as xPathDefaults,
|
|
28
|
+
h as xhrTemplate,
|
|
29
|
+
q as xml2dom,
|
|
30
|
+
D as xmlString,
|
|
31
|
+
L as xslTags
|
|
31
32
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epa-wg/custom-element-dist",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"test:watch": "vitest --inspect-brk --no-file-parallelism --browser.headless=false --test-timeout=0",
|
|
15
15
|
"test:storybook": "test-storybook",
|
|
16
16
|
"sb": "yarn storybook",
|
|
17
|
-
"t": "vitest --no-file-parallelism --watch --browser.headless=false src/stories/
|
|
17
|
+
"t": "vitest --no-file-parallelism --watch --browser.headless=false src/stories/attributes.test.stories.ts"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@epa-wg/custom-element": "0.0.
|
|
20
|
+
"@epa-wg/custom-element": "0.0.24"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@chromatic-com/storybook": "^1.3.3",
|
|
@@ -434,6 +434,14 @@ export function assureUnique(n, id=0)
|
|
|
434
434
|
e.childNodes.length && assureUnique(e)
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
|
+
export function appendByDceId(parent,e,k)
|
|
438
|
+
{
|
|
439
|
+
k = 1*k;
|
|
440
|
+
for( let n of parent.childNodes )
|
|
441
|
+
if( (n.dceId ?? n.getAttribute('data-dce-id')*1) > k )
|
|
442
|
+
return parent.insertBefore(e,n);
|
|
443
|
+
parent.append(e)
|
|
444
|
+
}
|
|
437
445
|
export function merge( parent, fromArr )
|
|
438
446
|
{
|
|
439
447
|
if(!fromArr.length)
|
|
@@ -461,7 +469,7 @@ export function merge( parent, fromArr )
|
|
|
461
469
|
}
|
|
462
470
|
delete id2old[ k ]
|
|
463
471
|
}else
|
|
464
|
-
parent
|
|
472
|
+
appendByDceId(parent,e,k)
|
|
465
473
|
}
|
|
466
474
|
for( let v of Object.values(id2old) )
|
|
467
475
|
v.remove();
|