@epa-wg/custom-element-dist 0.0.29 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/custom-element-dist.iml +11 -0
- package/.idea/inspectionProfiles/Project_Default.xml +25 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.storybook/main.ts +21 -19
- package/.storybook/preview.ts +25 -25
- package/README.md +4 -4
- package/coverage/coverage-final.json +21 -21
- package/coverage/index.html +26 -26
- 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 +543 -441
- package/coverage/src/custom-element/http-request.js.html +12 -12
- package/coverage/src/custom-element/index.html +18 -18
- package/coverage/src/custom-element/local-storage.js.html +52 -52
- package/coverage/src/custom-element/location-element.js.html +4 -4
- package/coverage/src/custom-element/module-url.js.html +1 -1
- package/coverage/src/index.html +1 -1
- package/coverage/src/mocks/handlers.ts.html +1 -1
- package/coverage/src/mocks/index.html +1 -1
- package/coverage/src/stories/attributes.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/attributes.test.stories.ts.html +335 -35
- package/coverage/src/stories/coverage.svg +1 -1
- package/coverage/src/stories/css.test.stories.ts.html +1 -1
- package/coverage/src/stories/dom-merge.test.stories.ts.html +1 -1
- package/coverage/src/stories/external-template.test.stories.ts.html +2 -2
- package/coverage/src/stories/form.test.stories.ts.html +1 -1
- package/coverage/src/stories/http-request.stories.ts.html +1 -1
- package/coverage/src/stories/index.html +22 -22
- package/coverage/src/stories/local-storage.test.stories.ts.html +17 -17
- package/coverage/src/stories/location-element.test.stories.ts.html +3 -6
- package/coverage/src/stories/module-url.test.stories.ts.html +1 -1
- package/coverage/src/stories/set-url.test.stories.ts.html +1 -1
- package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/slice-events.test.stories.ts.html +284 -23
- package/coverage/src/stories/slots.test.stories.ts.html +1 -1
- package/coverage/src/stories/testStoryBook.ts.html +12 -12
- package/coverage/src/stories/version-select.test.stories.ts.html +3 -3
- package/coverage/src/sum.ts.html +1 -1
- package/dist/custom-element-D2wf_rqP.js +576 -0
- package/dist/custom-element-Dtzhbjkc.cjs +97 -0
- package/dist/custom-element-bundle.cjs +1 -1
- package/dist/custom-element-bundle.js +30 -28
- package/dist/demo/a.html +51 -38
- package/dist/demo/a.svg +26 -26
- package/dist/demo/data-slices.html +37 -0
- package/dist/demo/external-template.html +1 -0
- package/dist/demo/form.html +42 -0
- package/dist/demo/hex-grid-dce.html +1 -1
- package/dist/demo/hex-grid.html +1 -1
- package/dist/demo/parameters.html +20 -1
- package/dist/demo/s.xml +6 -12
- package/dist/demo/s.xslt +64 -15
- package/dist/demo/ss.html +4 -23
- package/package.json +13 -13
- package/public/demo/a.html +51 -38
- package/public/demo/a.svg +26 -26
- package/public/demo/data-slices.html +37 -0
- package/public/demo/external-template.html +1 -0
- package/public/demo/form.html +42 -0
- package/public/demo/hex-grid-dce.html +1 -1
- package/public/demo/hex-grid.html +1 -1
- package/public/demo/parameters.html +20 -1
- package/public/demo/s.xml +6 -12
- package/public/demo/s.xslt +64 -15
- package/public/demo/ss.html +4 -23
- package/src/custom-element/custom-element.js +76 -42
- package/src/custom-element/demo/a.html +51 -38
- package/src/custom-element/demo/a.svg +26 -26
- package/src/custom-element/demo/data-slices.html +37 -0
- package/src/custom-element/demo/external-template.html +1 -0
- package/src/custom-element/demo/form.html +42 -0
- package/src/custom-element/demo/hex-grid-dce.html +1 -1
- package/src/custom-element/demo/hex-grid.html +1 -1
- package/src/custom-element/demo/parameters.html +20 -1
- package/src/custom-element/demo/s.xml +6 -12
- package/src/custom-element/demo/s.xslt +64 -15
- package/src/custom-element/demo/ss.html +4 -23
- package/src/custom-element/ide/web-types-dce.json +1 -1
- package/src/custom-element/ide/web-types-xsl.json +1 -1
- package/src/material/angular.css +987 -987
- package/src/material/components/autocomplete.html +239 -240
- package/src/material/components/dropdown.html +110 -46
- package/src/material/components/icon-link.html +160 -160
- package/src/material/components/input.html +363 -0
- package/src/material/components/menu.html +234 -234
- package/src/material/components.html +121 -120
- package/src/material/demo.css +36 -31
- package/src/material/index.html +110 -110
- package/src/material/material.css +356 -356
- package/src/material/theme/README.md +17 -17
- package/src/material/theme/semantic.css +113 -112
- package/src/mocks/versions.mock.ts +8 -8
- package/src/stories/attributes.test.stories.ts +123 -23
- package/src/stories/external-template.test.stories.ts +1 -1
- package/src/stories/location-element.test.stories.ts +1 -2
- package/src/stories/slice-events.test.stories.ts +87 -0
- package/storybook-static/assets/Color-F6OSRLHC-BU3iy8jH.js +1 -0
- package/storybook-static/assets/{Configure-DOhzHFEs.js → Configure-DN6ifayP.js} +1 -1
- package/storybook-static/assets/{DocsRenderer-CFRXHY34-BSJkbsd6.js → DocsRenderer-CFRXHY34-BaVEufDj.js} +2 -2
- package/storybook-static/assets/attributes.test.stories-D1X6EBrd.js +278 -0
- package/storybook-static/assets/{css.test.stories-pgbBc17d.js → css.test.stories-Cp_g2hE1.js} +1 -1
- package/storybook-static/assets/custom-element-uuAtIYWS.js +97 -0
- package/storybook-static/assets/{dom-merge.test.stories-CXcYP_-J.js → dom-merge.test.stories-hbpdCka0.js} +1 -1
- package/storybook-static/assets/entry-preview-DHVXbf3x.js +26 -0
- package/storybook-static/assets/entry-preview-docs-BbcIMweR.js +2 -0
- package/storybook-static/assets/{external-template.test.stories-CpJ68Ghy.js → external-template.test.stories-BK89h6sk.js} +3 -3
- package/storybook-static/assets/{form.test.stories-D35lyqd8.js → form.test.stories-BfoLe_rw.js} +1 -1
- package/storybook-static/assets/{handlers-CW9pDZnt.js → handlers-yVPwH_Nz.js} +21 -21
- package/storybook-static/assets/{http-request.stories-CBbknCOO.js → http-request.stories-CBFJS2Ws.js} +1 -1
- package/storybook-static/assets/iframe-CJEL_4Nu.js +2 -0
- package/storybook-static/assets/index-BcZLpTeD.js +8 -0
- package/storybook-static/assets/{index-BSz1w4Gl.js → index-CxRwF5Or.js} +130 -130
- package/storybook-static/assets/index-D5fBh-7N.js +1 -0
- package/storybook-static/assets/{index-YxUFxnQR.js → index-DM-KBPdl.js} +1 -1
- package/storybook-static/assets/{index-B3QjF0Ed.js → index-RSFf30w1.js} +1 -1
- package/storybook-static/assets/index-SnjB5uV8.js +769 -0
- package/storybook-static/assets/{local-storage.test.stories-BY-PWhuk.js → local-storage.test.stories-C0Yzy6Am.js} +1 -1
- package/storybook-static/assets/{location-element.test.stories-3auBYEaU.js → location-element.test.stories-DNFrEu5A.js} +1 -1
- package/storybook-static/assets/{module-url.test.stories-B7L9cL60.js → module-url.test.stories-CXibF5Ta.js} +1 -1
- package/storybook-static/assets/{preview-CfWMRsRq.js → preview-Bnd0XhaF.js} +2 -2
- package/storybook-static/assets/{preview-BRPR-UXC.js → preview-CNKoaWES.js} +1 -1
- package/storybook-static/assets/preview-DAeyCMnM.js +1 -0
- package/storybook-static/assets/preview-DJMlNTk8.js +2 -0
- package/storybook-static/assets/{set-url.test.stories-CuSuDLIx.js → set-url.test.stories-BBfLxv2u.js} +1 -1
- package/storybook-static/assets/{slice-events.test.stories-BkRKsKem.js → slice-events.test.stories-HcXF8XQI.js} +138 -13
- package/storybook-static/assets/{slots.test.stories-BJCUWFkE.js → slots.test.stories-i6mnIFM2.js} +1 -1
- package/storybook-static/assets/tiny-invariant-CopsF_GD.js +1 -0
- package/storybook-static/assets/{version-select.test.stories-B3ybJn_Z.js → version-select.test.stories-BsUFH6Va.js} +1 -1
- package/storybook-static/demo/a.html +51 -38
- package/storybook-static/demo/a.svg +26 -26
- package/storybook-static/demo/data-slices.html +37 -0
- package/storybook-static/demo/external-template.html +1 -0
- package/storybook-static/demo/form.html +42 -0
- package/storybook-static/demo/hex-grid-dce.html +1 -1
- package/storybook-static/demo/hex-grid.html +1 -1
- package/storybook-static/demo/parameters.html +20 -1
- package/storybook-static/demo/s.xml +6 -12
- package/storybook-static/demo/s.xslt +64 -15
- package/storybook-static/demo/ss.html +4 -23
- package/storybook-static/iframe.html +2 -2
- package/storybook-static/index.html +4 -0
- package/storybook-static/index.json +1 -1
- package/storybook-static/project.json +1 -1
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +333 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js.LEGAL.txt +40 -0
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +8 -8
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +82 -85
- 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-viewport-5/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/interactions-9/manager-bundle.js +66 -67
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +1 -1
- package/storybook-static/sb-manager/globals-module-info.js +25 -3
- package/storybook-static/sb-manager/globals-runtime.js +29585 -43124
- package/storybook-static/sb-manager/runtime.js +10647 -9399
- package/storybook-static/sb-preview/runtime.js +3536 -5860
- package/test-runner-jest.config.js +15 -0
- package/dist/custom-element-BOIPgtxz.js +0 -565
- package/dist/custom-element-CUsSENWc.cjs +0 -97
- package/src/stories/__screenshots__/http-request.test.ts/http-request-url-change-1.png +0 -0
- package/storybook-static/assets/Color-ERTF36HU-CQkSD2nd.js +0 -1
- package/storybook-static/assets/attributes.test.stories-BJBuuXgZ.js +0 -150
- package/storybook-static/assets/custom-element-BDGsYgbP.js +0 -97
- package/storybook-static/assets/entry-preview-C313OLrj.js +0 -26
- package/storybook-static/assets/entry-preview-docs-B7ORr9w5.js +0 -2
- package/storybook-static/assets/iframe-DOi4N7qI.js +0 -2
- package/storybook-static/assets/index-BdcJ-iJ7.js +0 -8
- package/storybook-static/assets/index-CaL3Qp7t.js +0 -634
- package/storybook-static/assets/index-DgFM0Ce3.js +0 -1
- package/storybook-static/assets/preview-C992A1Y-.js +0 -2
- package/storybook-static/assets/preview-CcS4DQh8.js +0 -1
- package/storybook-static/assets/tiny-invariant-BxWVcicq.js +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";const Z="http://www.w3.org/1999/XSL/Transform",O="http://www.w3.org/1999/xhtml",Se="http://exslt.org/common",f=(e,l)=>e.getAttribute?.(l),oe=e=>e.nodeType===3,Ce=e=>typeof e=="string",De=e=>e&&typeof e.nodeType=="number",$=(e,l)=>(e.ownerDocument||e).createTextNode(l),re=e=>{for(;e.firstChild;)e.firstChild.remove();return e},J=e=>(e.getAttributeNames().map(l=>e.removeAttribute(l)),re(e)),ce=e=>(e?.setAttribute("xmlns:xsl",Z),e),me=e=>(e?.setAttribute("xmlns:xhtml",O),ce(e)),ue=e=>/^[_a-zA-Z][-_:a-zA-Z0-9]*$/.test(e),K=(e,l)=>(Object.keys(l).map(t=>e[t]=l[t]),e),S=(e,l="",t=document)=>{const s=i=>(r=>(l&&r.append($(t.ownerDocument||t,l)),r))((t.ownerDocument||t).createElement(i));if(ue(e))return s(e);const n=s("dce-object");return n.setAttribute("dce-object-name",e),n},Q=(e,l)=>{const t=e.ownerDocument.createElementNS(e.namespaceURI,l);for(let s of e.attributes)t.setAttribute(s.name,s.value);for(let s of e.childNodes)t.append(s.cloneNode(!0));return t};function P(e){return new DOMParser().parseFromString(e,"application/xml")}function M(e){return new XMLSerializer().serializeToString(e)}function H(e,l,t,s){const n=x=>e.ownerDocument.createElement(x),r=((x,h,v)=>(h.append(v=n(x)),v))(l,e);return[...t].forEach(x=>r.append(s(x))),r}function Le(e){return e.slot||(e.setAttribute||(e=S("span",e.textContent.replaceAll(`
|
|
2
|
+
`,""))),e.setAttribute("slot","")),e}function G(e,l){e.getAttributeNames().forEach(t=>l.includes(t)||e.removeAttribute(t))}const ee=e=>[...e].filter(l=>!(l.nodeType===3&&l.data.trim()===""));function z(e,l,t){const s=typeof e;if(s==="string")return S(l,e,t);if(s==="number")return S(l,""+e,t);if(e instanceof Array){const i=S("array","",t);return e.map(r=>i.append(z(r,l,t))),i}if(e instanceof FormData){const i=S("form-data","",t);for(const r of e)i.append(z(r[1],r[0],t));return i}const n=S(l,"",t);for(let i in e)De(e[i])||typeof e[i]=="function"||e[i]instanceof Window||(typeof e[i]!="object"&&ue(i)?n.setAttribute(i,e[i]):n.append(z(e[i],i,t)));return n}function te(e){if(L(e,"*",l=>[...l.childNodes].filter(t=>t.nodeType===3&&t.parentNode.localName!=="style"&&t.data).forEach(t=>{const s=t.data,n=s.matchAll(/{([^}]*)}/g);if(n){let i=0,r=h=>$(t,h),x=[];if([...n].forEach(h=>{h.index>i&&x.push(r(h.input.substring(i,h.index)));const v=e.querySelector("value-of").cloneNode();v.setAttribute("select",h[1]),x.push(v),i=h.index+h[0].length}),i<s.length&&x.push(r(s.substring(i,s.length))),x.length){for(let h of x)l.insertBefore(h,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 de(e,l="xsl:stylesheet"){const t=[],s={},n={};if(e.tagName===l||e.documentElement?.tagName===l)return te(K(e,{declaredAttributes:t,hardcodedAttributes:s,exposedAttributes:n}));const i=P(`<xsl:stylesheet version="1.0" xmlns:xsl="${Z}" xmlns:xhtml="${O}" xmlns:exsl="${Se}" exclude-result-prefixes="exsl" >
|
|
3
|
+
<xsl:output method="xml"/>
|
|
4
|
+
<xsl:template match="/"><dce-root xmlns="${O}"><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>`),r=new XSLTProcessor,x=(a=>{L(a,"custom-element",y=>{y.firstElementChild.localName==="template"&&([...y.firstElementChild.content.childNodes].forEach(g=>y.append(g)),y.firstElementChild.remove())}),L(a,"script",y=>y.remove());const c=a.content??a.firstElementChild?.content??a.body??a;Ee.forEach(y=>L(c,y,g=>Ae(g,c)));const N=a.firstElementChild?.content||a.content,A=y=>{const g=P("<xhtml/>"),U=g.importNode(y,!0);return g.replaceChild(U,g.documentElement),me(U)};if(N){const y=S("div");return[...N.childNodes].map(g=>y.append(g.cloneNode(!0))),A(y)}return A(a.documentElement||a.body||a)})(e),h=P(`<xsl:stylesheet version="1.0"
|
|
59
|
+
xmlns:xsl="${Z}"
|
|
60
|
+
xmlns:xhtml="${O}"
|
|
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>`);r.importStylesheet(i);const v=r.transformToFragment(x,document),u=(a,c)=>a.querySelector(c),T=u(h,'template[mode="payload"]');if(!v)return console.error("transformation error",{xml:x.outerHTML,xsl:M(i)});if(v.firstElementChild.localName!=="dce-root"){const a=v.ownerDocument.createElement("dce-root");[...v.childNodes].forEach(c=>a.append(c)),v.append(a)}[...v.querySelectorAll("dce-root>attribute")].forEach(a=>{G(a,"namespace,name,select");const c=Q(a,"xsl:param"),N=f(a,"name");if(t.push(N),a.childNodes.length&&(s[N]=a.textContent),T.append(c),a.hasAttribute("select")){n[N]=f(a,"select"),G(c,"select,name");let A=f(a,"select").split("??"),y;if(A?.length>1){c.removeAttribute("select");const g=u(h,'template[match="ignore"]>choose').cloneNode(!0);J(g.firstElementChild).append($(g,"{"+A[0]+"}")),J(g.lastElementChild).append($(g,"{"+A[1]+"}")),g.firstElementChild.setAttribute("test","string-length("+A[0]+")"),c.append(g),y=g.cloneNode(!0)}else y=Q(a,"xsl:value-of");y.removeAttribute("name"),a.append(y),a.removeAttribute("select")}else G(c,"name"),c.setAttribute("select","/datadom/attributes/"+N)}),[...v.querySelectorAll("[value]")].filter(a=>a.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach(a=>{const c=f(a,"value");c&&a.setAttribute("value",ve(c))});for(const a of v.childNodes)T.append(h.importNode(a,!0));[...T.getElementsByTagName("xsl:template")].forEach(a=>T.ownerDocument.documentElement.append(a));const q=u(h,'call-template[name="slot"]'),p=a=>{const c=q.cloneNode(!0),N=f(a,"name");N&&c.firstElementChild.setAttribute("select",`'${N}'`);for(let A of a.childNodes)c.lastElementChild.append(A);return c};L(T,"slot",a=>a.parentNode.replaceChild(p(a),a));const d=te(h);return K(d,{declaredAttributes:t,hardcodedAttributes:s,exposedAttributes:n}),d}async function pe(e){return await new Promise((t,s)=>{const n=new XMLHttpRequest;n.open("GET",e),n.responseType="document",n.onload=()=>{n.readyState===n.DONE&&n.status===200?t(n.responseXML?.body||n.responseXML||S("div",n.responseText)):s(`${n.statusText} - ${e}`)},n.addEventListener("error",i=>s(i)),n.send()})}function fe(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)||!fe(e[s],l[s]))return t;return!0}const he=e=>e.split("|").map(l=>l.trim()).filter(l=>l),xe=(e,l)=>he(l).map(t=>{let s=e.ownerDocument,n=i=>(e.append(i),i);if(t.includes("/")){const i=[],r=s.evaluate(t,e);for(let x;x=r.iterateNext();)i.push(x);return i}return[...e.childNodes].find(i=>i.localName===t)||n(S(t,"",s))}).flat();function se(e,l,t,s){if(!t.sliceProcessed)return t.sliceProcessed=1,xe(e,l??"").map(n=>{const i=e.ownerDocument,r=t.sliceEventSource,x=t.sliceElement,h=()=>[...n.childNodes].filter(u=>u.nodeType===3||u.localName==="value"||u.localName==="form-data").map(u=>u.remove());r.getAttributeNames().map(u=>n.setAttribute(u,f(r,u))),[...n.childNodes].filter(u=>u.localName==="event").map(u=>u.remove()),"validationMessage"in r&&n.setAttribute("validation-message",r.validationMessage),t.type==="init"&&h(),n.append(z(t,"event",i));const v=(r.type==="checkbox"||r.type==="radio")&&!r.checked;if(x.hasAttribute("slice-value")){r.value===void 0?n.removeAttribute("value"):n.setAttribute("value",r.value);const u=v?"":j(f(x,"slice-value"),n);h(),n.append($(i,u))}else{if("elements"in r)return h(),n.append(z(new FormData(r),"value",n.ownerDocument)),n;const u=v?"":r.value??f(r,"value");h(),u==null?[...n.childNodes].filter(T=>T.localName!=="event").map(T=>T.remove()):Ce(u)?n.append($(i,u)):n.append(z(u,"value",n.ownerDocument))}return n})}function L(e,l,t){e.querySelectorAll&&[...e.querySelectorAll(l)].forEach(t)}const $e=async(e,l)=>{if(!e||!e.trim())return[l];if(e.startsWith("#"))return(t=>{const s=t.querySelectorAll(e);return[...s.length?s:t.getRootNode().querySelectorAll(e)]})(l.parentElement);try{const[t,s]=e.split("#");if(e.charAt(0)===".")e=new URL(t,l.closest("[base]")?.getAttribute("base")||location).href;else try{e=(void 0)(t),s&&(e+="#"+s)}catch(i){console.error(i.message)}const n=await pe(e);if(l.setAttributeNS("xml","base",e),s){const i=n.querySelectorAll("#"+s);return i.length?[...i]:(console.error("template not found",e+"#"+s),[l])}return[n]}catch{return[l]}};function be(e,l){for(let t of e.attributes)try{t.namespaceURI?l.setAttributeNS(t.namespaceURI,t.name,t.value):l.setAttribute(t.name,t.value),t.name==="value"&&(l.value=t.value)}catch(s){console.warn("attribute assignment error",s?.message||s)}}function le(e,l=0){const t={};for(const s of e.childNodes){const n=f(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&&le(s)}}function ye(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 ne(e,l){if(e.firstElementChild?.localName==="dce-root"&&l[0]?.localName!=="dce-root")return;if(!l.length)return e.firstElementChild?.localName!=="dce-root"&&re(e);const t={};for(let s of e.childNodes)t[s.dceId],oe(s)?(s.data.trim(),t[s.dceId||0]=s):t[f(s,"data-dce-id")||0]=s;for(let s of[...l]){const n=f(s,"data-dce-id")||s.dceId,i=t[n];i?(oe(s)?i.nodeValue!==s.nodeValue&&(i.nodeValue=s.nodeValue):(be(s,i),(i.childNodes.length||s.childNodes.length)&&ne(i,s.childNodes)),delete t[n]):ye(e,s,n)}for(let s of Object.values(t))s.localName!=="dce-root"&&s.remove()}function ge(e,l){return e.hasAttribute(l)||e.setAttribute(l,crypto.randomUUID()),e.getAttribute(l)}const ve=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},j=(e,l)=>{const t=e.split("??");if(t.length>1)return j(t[0],l)||j(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},Ee="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(","),Ae=(e,l)=>{const t=S("xsl:"+e.localName);for(let s of e.attributes)t.setAttribute(s.name,s.value);for(;e.firstChild;)t.append(e.firstChild);if(e.parentElement)e.parentElement.replaceChild(t,e);else{const s=e.parentElement||l,n=[...s.childNodes];n.forEach((i,r)=>{i===e&&(n[r]=t)}),s.replaceChildren(...n)}};class Ne extends HTMLElement{static observedAttributes=["src","tag","hidden"];async connectedCallback(){this.firstElementChild&&this.firstElementChild.localName!=="template"&&console.warn(`custom-element used without template wrapping content
|
|
93
|
+
`,this.outerHTML);const l=await $e(f(this,"src"),this),t=f(this,"tag"),s=t||"dce-"+crypto.randomUUID();for(const p of l)L(p.templateNode||p.content||p,"style",d=>{const a=d.closest("slot"),c=a?`slot[name="${a.name}"]`:"";d.innerHTML=`${s} ${c}{${d.innerHTML}}`,this.append(d)});const n=l.map(p=>de(p)),i=n.map((p,d)=>{d=new XSLTProcessor;try{d.importStylesheet(p)}catch(a){console.error(a,M(p))}return d});Object.defineProperty(this,"xsltString",{get:()=>n.map(p=>M(p)).join(`
|
|
94
|
+
`)});const r=this,x=[...this.templateNode.querySelectorAll("[slice]")],h=x.map(p=>f(p,"slice")).filter(p=>!p.includes("/")).filter((p,d,a)=>a.indexOf(p)===d).map(he).flat(),{declaredAttributes:v,hardcodedAttributes:u,exposedAttributes:T}=n[0];class _ extends HTMLElement{static get observedAttributes(){return v}#e=0;connectedCallback(){let d=ee(this.childNodes);if(this.firstElementChild?.tagName==="TEMPLATE"){this.firstElementChild!==this.lastElementChild&&console.error("payload should have TEMPLATE as only child",this.outerHTML);const m=this.firstElementChild;m.remove(),d=ee(m.content.childNodes);for(const E of d)if(E.localName==="style"){const o=ge(this,"data-dce-style");E.innerHTML=`${s}[data-dce-style="${o}"]{${E.innerHTML}}`,m.insertAdjacentElement("beforebegin",E)}else E.nodeType===1?m.insertAdjacentElement("beforebegin",E):E.nodeType===3&&m.insertAdjacentText("beforebegin",E.data)}const a=P("<datadom/>").documentElement,c=(m,E="")=>(o=>(E&&o.append($(a,E)),o))(a.ownerDocument.createElement(m)),N=H(a,"payload",d,Le);ce(N),me(N),this.innerHTML="";const A=H(a,"attributes",this.attributes,m=>c(m.nodeName,m.value)),y=m=>this.hasAttribute(m)||[...A.children].find(E=>E.localName===m);Object.keys(u).map(m=>y(m)||A.append(c(m,u[m]))),v.map(m=>y(m)||A.append(c(m))),H(a,"dataset",Object.keys(this.dataset),m=>c(m,this.dataset[m]));const g=H(a,"slice",h,m=>c(m,"")),U=m=>j(m,g);this.xml=a;const ae=[],ie=()=>{const m={};for(let E;E=ae.pop();){const o=f(E.sliceElement,"slice");m[o]||(se(g,o,E),m[o]=E)}Object.keys(m).length!==0&&k()};let B;this.onSlice=m=>{ae.push(m),B||(B=setTimeout(()=>{ie(),B=0},1))};const k=this.transform=()=>{if(this.#e)debugger;this.#e=1,i.map((o,b)=>{const C=o.transformToFragment(a.ownerDocument,document);return C||console.error(`XSLT transformation error. xsl:
|
|
95
|
+
`,M(n[b]),`
|
|
96
|
+
xml:
|
|
97
|
+
`,M(a)),C}).map(o=>{o&&(le(o),ne(this,o.childNodes))}),Object.entries(u).map(([o,b])=>{!this.hasAttribute(o)&&b!==f(this,o)&&(this.setAttribute(o,b),this.#t(o,b))}),Object.keys(T).map(o=>{let b=f(this.firstElementChild,o);b!==f(this,o)&&(this.setAttribute(o,b),this.#t(o,b))});function E(o){let b=o;if(o.localName==="slice"){const C=f(o,"for");if(C||(b=o.parentElement),C==="^")do b=b.previousElementSibling;while(b.localName==="slice");else b=this.querySelector(C);if(!b)return console.warn(`can not find selector in "slice for=${C}" `,o.outerHTML);f(o,"slice")||o.setAttribute("slice",f(o,"name"))}return b}L(this,"[slice],[slice-event]",o=>{let b=f(o,"slice-event");const C=o.hasAttribute("slice-value")||o.hasAttribute("value")||o.value,I=E(o);o.dceInitialized||(o.dceInitialized=1,I.hasAttribute("custom-validity")&&(b+=" change submit"),[...new Set((b||"change").split(" "))].forEach(Te=>I.addEventListener(Te,w=>{w.sliceElement=o,w.sliceEventSource=w.currentTarget||w.target,w.sliceProcessed=0;const we=se(g,f(w.sliceElement,"slice"),w);L(this,"[custom-validity]",X=>{if(!X.setCustomValidity)return;const Y=f(X,"custom-validity");try{const R=Y&&j(Y,A);X.setCustomValidity(R===!0?"":R===!1?"invalid":R)}catch(R){console.error(R,"xPath",Y)}});const F=f(I,"custom-validity"),D=F&&j(F,A),W=D===!0?"":D;if(F){if(o.setCustomValidity?o.setCustomValidity(W):o.validationMessage=W,we.map(X=>X.setAttribute("validation-message",W)),w.type==="submit")return D===!0?void 0:(setTimeout(k,1),!!D===D?(D||w.preventDefault(),D):D?(w.preventDefault(),!1):void 0);setTimeout(k,1)}this.onSlice(w)})),(!b||b.includes("init"))&&(C?this.onSlice({type:"init",target:I,sliceElement:o,sliceEventSource:I}):o.value=U(f(o,"slice"))))}),this.#e=0};k(),ie()}#t(d,a){d==="value"&&(this.value=a);let c=this.xml.querySelector(`attributes>${d}`);c?J(c).append($(c,a)):(c=S(d,a,this.xml),this.xml.querySelector("attributes").append(c)),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:{[d]:a}}))}attributeChangedCallback(d,a,c){!this.xml||this.#e||(this.#t(d,c),this.transform())}get dce(){return r}}const q=p=>{window.customElements.get(p)!==_&&window.customElements.define(p,_)};if(t)q(t);else{const p=s;this.setAttribute("tag",p),q(p);const d=document.createElement(p);this.getAttributeNames().forEach(a=>d.setAttribute(a,this.getAttribute(a))),d.append(...[...this.childNodes].filter(a=>a.localName!=="style")),this.append(d)}}get templateNode(){return this.firstElementChild?.tagName==="TEMPLATE"?this.firstElementChild.content:this}get dce(){return this}get xslt(){return P(this.xsltString)}}window.customElements.define("custom-element",Ne);exports.CustomElement=Ne;exports.appendByDceId=ye;exports.assureSlices=xe;exports.assureUID=ge;exports.assureUnique=le;exports.cloneAs=Q;exports.createXsltFromDom=de;exports.deepEqual=fe;exports.evalCurly=ve;exports.event2slice=se;exports.merge=ne;exports.mergeAttr=be;exports.mix=K;exports.obj2node=z;exports.sanitizeBlankText=ee;exports.tagUid=te;exports.toXsl=Ae;exports.xPath=j;exports.xPathDefaults=V;exports.xhrTemplate=pe;exports.xml2dom=P;exports.xmlString=M;exports.xslTags=Ee;
|
|
@@ -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-Dtzhbjkc.cjs"),l=require("./http-request-DPrY7mGh.cjs"),t=require("./local-storage-78EivJ_B.cjs"),a=require("./location-element-DRB7hCwA.cjs");exports.CustomElement=e.CustomElement;exports.appendByDceId=e.appendByDceId;exports.assureSlices=e.assureSlices;exports.assureUID=e.assureUID;exports.assureUnique=e.assureUnique;exports.cloneAs=e.cloneAs;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.mix=e.mix;exports.obj2node=e.obj2node;exports.sanitizeBlankText=e.sanitizeBlankText;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.localStorage_clear=t.localStorage_clear;exports.localStorage_removeItem=t.localStorage_removeItem;exports.localStorage_setItem=t.localStorage_setItem;exports.LocationElement=a.LocationElement;
|
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
import { C as e } from "./custom-element-
|
|
2
|
-
import {
|
|
3
|
-
import { H as
|
|
4
|
-
import { L as
|
|
5
|
-
import { L as
|
|
1
|
+
import { C as e } from "./custom-element-D2wf_rqP.js";
|
|
2
|
+
import { j as o, f as l, l as r, i as m, c, b as n, e as x, n as p, g, k as i, h as u, m as d, o as f, s as S, t as E, u as I, q as h, p as q, d as D, x as L, a as b, r as v } from "./custom-element-D2wf_rqP.js";
|
|
3
|
+
import { H as T } from "./http-request-BOvP4KTl.js";
|
|
4
|
+
import { L as _, c as j, b as k, a as y, l as A } from "./local-storage-DzmNKzgN.js";
|
|
5
|
+
import { L as H } from "./location-element-FJlONi2n.js";
|
|
6
6
|
export {
|
|
7
7
|
e as CustomElement,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
T as HttpRequestElement,
|
|
9
|
+
_ as LocalStorageElement,
|
|
10
|
+
H as LocationElement,
|
|
11
11
|
o as appendByDceId,
|
|
12
12
|
l as assureSlices,
|
|
13
13
|
r as assureUID,
|
|
14
14
|
m as assureUnique,
|
|
15
|
-
c as
|
|
16
|
-
n as
|
|
15
|
+
c as cloneAs,
|
|
16
|
+
n as createXsltFromDom,
|
|
17
|
+
x as deepEqual,
|
|
17
18
|
e as default,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
p as evalCurly,
|
|
20
|
+
g as event2slice,
|
|
21
|
+
j as localStorageSetItem,
|
|
22
|
+
k as localStorage_clear,
|
|
23
|
+
y as localStorage_removeItem,
|
|
24
|
+
A as localStorage_setItem,
|
|
25
|
+
i as merge,
|
|
26
|
+
u as mergeAttr,
|
|
27
|
+
d as mix,
|
|
28
|
+
f as obj2node,
|
|
29
|
+
S as sanitizeBlankText,
|
|
30
|
+
E as tagUid,
|
|
31
|
+
I as toXsl,
|
|
32
|
+
h as xPath,
|
|
33
|
+
q as xPathDefaults,
|
|
34
|
+
D as xhrTemplate,
|
|
35
|
+
L as xml2dom,
|
|
36
|
+
b as xmlString,
|
|
37
|
+
v as xslTags
|
|
36
38
|
};
|
package/dist/demo/a.html
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html lang="en"
|
|
2
|
+
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
5
|
-
<title>
|
|
5
|
+
<title>http-request Declarative Custom Element implementation demo</title>
|
|
6
6
|
<link rel="icon" href="./wc-square.svg"/>
|
|
7
7
|
|
|
8
8
|
<script type="module" src="../http-request.js"></script>
|
|
@@ -10,51 +10,64 @@
|
|
|
10
10
|
<style>
|
|
11
11
|
@import "./demo.css";
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
display: flex;
|
|
13
|
+
button {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
align-items: center;
|
|
17
|
+
flex: auto;
|
|
18
|
+
box-shadow: inset silver 0 0 1rem;
|
|
19
|
+
min-width: 12rem;
|
|
20
|
+
padding: 1rem;
|
|
21
|
+
color: coral;
|
|
22
|
+
text-shadow: 1px 1px silver;
|
|
23
|
+
font-weight: bolder;
|
|
15
24
|
}
|
|
16
25
|
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
button img {
|
|
27
|
+
max-height: 10vw;
|
|
28
|
+
min-height: 4rem;
|
|
19
29
|
}
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
table {
|
|
32
|
+
min-width: 16rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
td {
|
|
36
|
+
border-bottom: 1px solid silver;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
tfoot td {
|
|
40
|
+
border-bottom: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
td, th {
|
|
44
|
+
text-align: right;
|
|
23
45
|
}
|
|
24
|
-
</style>
|
|
25
|
-
<!-- https://github.com/mdn/learning-area/blob/main/html/forms/form-validation/custom-error-message.html
|
|
26
|
-
todo: apply setCustomValidity( warningStr )
|
|
27
|
-
-->
|
|
28
46
|
|
|
47
|
+
caption {
|
|
48
|
+
padding: 1rem;
|
|
49
|
+
font-weight: bolder;
|
|
50
|
+
font-family: sans-serif;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
code {
|
|
54
|
+
text-align: right;
|
|
55
|
+
min-width: 3rem;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
svg {
|
|
59
|
+
max-height: 3rem;
|
|
60
|
+
}
|
|
61
|
+
</style>
|
|
29
62
|
</head>
|
|
30
63
|
<body>
|
|
31
64
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
<u>
|
|
39
|
-
<slot>is green</slot>
|
|
40
|
-
</u>
|
|
41
|
-
</template>
|
|
42
|
-
<style>dce-3 {
|
|
43
|
-
color: green
|
|
44
|
-
}</style>
|
|
45
|
-
</custom-element>
|
|
46
|
-
<u>should be</u> <i style="color:red">red</i>:
|
|
47
|
-
<dce-3 id="dce32">
|
|
48
|
-
<template>
|
|
49
|
-
<style> color:red; </style>
|
|
50
|
-
<u>red</u>
|
|
51
|
-
</template>
|
|
52
|
-
</dce-3> <br/>
|
|
53
|
-
should be GREEN:
|
|
54
|
-
<dce-3 id="dce31">green</dce-3>
|
|
55
|
-
</fieldset>
|
|
56
|
-
|
|
57
|
-
<script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
<custom-element src="./html-template.html#dwc-logo">
|
|
68
|
+
<template><i>loading SVG from templates file ...</i></template>
|
|
69
|
+
</custom-element>
|
|
70
|
+
|
|
58
71
|
|
|
59
72
|
</body>
|
|
60
73
|
</html>
|
package/dist/demo/a.svg
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
<svg id="dwc-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 216 209.18" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
2
|
-
<defs>
|
|
3
|
-
|
|
4
|
-
</defs>
|
|
5
|
-
<polygon class="cls-3" points="0 82.47 0 126.71 34.84 146.83 34.84 187.06 73.16 209.18 108 189.07 142.84 209.18 181.16 187.06 181.16 146.83 216 126.71 216 82.47 181.16 62.35 181.16 22.12 142.84 0 108 20.12 73.16 0 34.84 22.12 34.84 62.35 0 82.47"/>
|
|
6
|
-
<path class="cls-2" d="m114.33,56.69l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
7
|
-
<path class="cls-2" d="m98.19,62.71h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
8
|
-
<path class="cls-1" d="m48.12,66.01l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97Z"/>
|
|
9
|
-
<path class="cls-2" d="m46.18,24.66l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0s20.64-11.92,20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06Z"/>
|
|
10
|
-
<path class="cls-2" d="m115.87,24.66l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0s20.64-11.92,20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06Z"/>
|
|
11
|
-
<path class="cls-2" d="m152.65,42.59c-4.44,2.56-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0Z"/>
|
|
12
|
-
<path class="cls-2" d="m77.55,158.4l20.65-11.92h0c4.44-2.57,6.33-5.84,6.33-10.97v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92c-4.44,2.57-6.33,5.84-6.33,10.97h0s0,23.84,0,23.84c0,.54.45.8.92.54Z"/>
|
|
13
|
-
<path class="cls-4" d="m146.31,134.03v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0s0-23.84,0-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97Z"/>
|
|
14
|
-
<path class="cls-4" d="m63.35,123.06h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
15
|
-
<path class="cls-4" d="m103.61,151.37l-20.64,11.92c-4.44,2.57-6.33,5.84-6.33,10.97h0s0,23.84,0,23.84c0,.54.45.8.92.54l20.65-11.92h0c4.44-2.57,6.33-5.84,6.33-10.97v-23.84c0-.54-.45-.8-.92-.53Z"/>
|
|
16
|
-
<path class="cls-4" d="m63.35,163.29h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
17
|
-
<path class="cls-4" d="m28.51,102.94h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
18
|
-
<path class="cls-4" d="m133.04,163.29l-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84c0,5.13,1.89,8.4,6.33,10.97h0s20.65,11.92,20.65,11.92c.47.27.92,0,.92-.54v-23.84s0,0,0,0c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
19
|
-
<path class="cls-4" d="m173.29,151.37l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0s0-23.84,0-23.84c0-.54-.45-.8-.92-.53Z"/>
|
|
20
|
-
<path class="cls-4" d="m209.06,91.55c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84Z"/>
|
|
21
|
-
<path class="cls-2" d="m149.18,117.04l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
22
|
-
<path class="cls-1" d="m112.39,98.05l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54Z"/>
|
|
23
|
-
<path class="cls-1" d="m100.13,105.12c.47-.27.47-.79,0-1.06l-20.65-11.92c-4.44-2.57-8.22-2.57-12.67,0h0s-20.65,11.92-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92h0c4.44,2.57,8.22,2.57,12.67,0l20.64-11.92Z"/>
|
|
24
|
-
<path class="cls-2" d="m65.29,85.01c.47-.27.47-.79,0-1.06l-20.65-11.92c-4.44-2.57-8.22-2.57-12.67,0h0s-20.65,11.92-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92h0c4.44,2.57,8.22,2.57,12.67,0l20.64-11.92Z"/>
|
|
25
|
-
<path class="cls-1" d="m133.04,123.06l-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84c0,5.13,1.89,8.4,6.33,10.97h0s20.65,11.92,20.65,11.92c.47.27.92,0,.92-.54v-23.84s0,0,0,0c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
26
|
-
<path class="cls-1" d="m184.02,96.93l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
1
|
+
<svg id="dwc-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 216 209.18" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
2
|
+
<defs>
|
|
3
|
+
|
|
4
|
+
</defs>
|
|
5
|
+
<polygon class="cls-3" points="0 82.47 0 126.71 34.84 146.83 34.84 187.06 73.16 209.18 108 189.07 142.84 209.18 181.16 187.06 181.16 146.83 216 126.71 216 82.47 181.16 62.35 181.16 22.12 142.84 0 108 20.12 73.16 0 34.84 22.12 34.84 62.35 0 82.47"/>
|
|
6
|
+
<path class="cls-2" d="m114.33,56.69l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
7
|
+
<path class="cls-2" d="m98.19,62.71h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
8
|
+
<path class="cls-1" d="m48.12,66.01l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97Z"/>
|
|
9
|
+
<path class="cls-2" d="m46.18,24.66l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0s20.64-11.92,20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06Z"/>
|
|
10
|
+
<path class="cls-2" d="m115.87,24.66l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0s20.64-11.92,20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06Z"/>
|
|
11
|
+
<path class="cls-2" d="m152.65,42.59c-4.44,2.56-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0Z"/>
|
|
12
|
+
<path class="cls-2" d="m77.55,158.4l20.65-11.92h0c4.44-2.57,6.33-5.84,6.33-10.97v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92c-4.44,2.57-6.33,5.84-6.33,10.97h0s0,23.84,0,23.84c0,.54.45.8.92.54Z"/>
|
|
13
|
+
<path class="cls-4" d="m146.31,134.03v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0s0-23.84,0-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97Z"/>
|
|
14
|
+
<path class="cls-4" d="m63.35,123.06h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
15
|
+
<path class="cls-4" d="m103.61,151.37l-20.64,11.92c-4.44,2.57-6.33,5.84-6.33,10.97h0s0,23.84,0,23.84c0,.54.45.8.92.54l20.65-11.92h0c4.44-2.57,6.33-5.84,6.33-10.97v-23.84c0-.54-.45-.8-.92-.53Z"/>
|
|
16
|
+
<path class="cls-4" d="m63.35,163.29h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
17
|
+
<path class="cls-4" d="m28.51,102.94h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
18
|
+
<path class="cls-4" d="m133.04,163.29l-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84c0,5.13,1.89,8.4,6.33,10.97h0s20.65,11.92,20.65,11.92c.47.27.92,0,.92-.54v-23.84s0,0,0,0c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
19
|
+
<path class="cls-4" d="m173.29,151.37l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0s0-23.84,0-23.84c0-.54-.45-.8-.92-.53Z"/>
|
|
20
|
+
<path class="cls-4" d="m209.06,91.55c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84Z"/>
|
|
21
|
+
<path class="cls-2" d="m149.18,117.04l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
22
|
+
<path class="cls-1" d="m112.39,98.05l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54Z"/>
|
|
23
|
+
<path class="cls-1" d="m100.13,105.12c.47-.27.47-.79,0-1.06l-20.65-11.92c-4.44-2.57-8.22-2.57-12.67,0h0s-20.65,11.92-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92h0c4.44,2.57,8.22,2.57,12.67,0l20.64-11.92Z"/>
|
|
24
|
+
<path class="cls-2" d="m65.29,85.01c.47-.27.47-.79,0-1.06l-20.65-11.92c-4.44-2.57-8.22-2.57-12.67,0h0s-20.65,11.92-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92h0c4.44,2.57,8.22,2.57,12.67,0l20.64-11.92Z"/>
|
|
25
|
+
<path class="cls-1" d="m133.04,123.06l-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84c0,5.13,1.89,8.4,6.33,10.97h0s20.65,11.92,20.65,11.92c.47.27.92,0,.92-.54v-23.84s0,0,0,0c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
26
|
+
<path class="cls-1" d="m184.02,96.93l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
27
27
|
</svg>
|
|
@@ -210,6 +210,43 @@
|
|
|
210
210
|
</template>
|
|
211
211
|
</html-demo-element>
|
|
212
212
|
|
|
213
|
+
<html-demo-element legend="12. checkbox use"
|
|
214
|
+
description="The value is empty when unchecked. Otherwise taken either from slice-value or value attribute.">
|
|
215
|
+
<p>Check the box to see the value in slice</p>
|
|
216
|
+
<template>
|
|
217
|
+
<custom-element>
|
|
218
|
+
<template>
|
|
219
|
+
<input type="checkbox" slice="is-checked" value="V0" checked/>
|
|
220
|
+
slice: {/datadom/slice/is-checked} <br/>
|
|
221
|
+
<xsl:variable name="v1">V1</xsl:variable> <br/>
|
|
222
|
+
$v1={$v1}<br/>
|
|
223
|
+
|
|
224
|
+
<!-- slice-variable is XPath. $v1 is available only in template, embedding trick -->
|
|
225
|
+
<input type="checkbox" slice="s2" slice-value="'{$v1}'"/>
|
|
226
|
+
slice 2: {//s2} <br/>
|
|
227
|
+
|
|
228
|
+
<!-- variable is used in template scope -->
|
|
229
|
+
<input type="checkbox" slice="s3" value="{$v1}"/>
|
|
230
|
+
slice 3: {//s3}
|
|
231
|
+
</template>
|
|
232
|
+
</custom-element>
|
|
233
|
+
</template>
|
|
234
|
+
</html-demo-element>
|
|
235
|
+
|
|
236
|
+
<html-demo-element legend="13. Radio group"
|
|
237
|
+
description="The value propagated into slice from the last checked radiobutton.">
|
|
238
|
+
<p>Check the radiobutton to see the value in slice</p>
|
|
239
|
+
<template>
|
|
240
|
+
<custom-element>
|
|
241
|
+
<template>
|
|
242
|
+
V0: <input type="radio" slice="radio-group" value="V0" name="g1"/> <br/>
|
|
243
|
+
V1: <input type="radio" slice="radio-group" value="V1" name="g1" checked/> <br/>
|
|
244
|
+
slice: {//radio-group} <br/>
|
|
245
|
+
</template>
|
|
246
|
+
</custom-element>
|
|
247
|
+
</template>
|
|
248
|
+
</html-demo-element>
|
|
249
|
+
|
|
213
250
|
<script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
|
|
214
251
|
|
|
215
252
|
</body>
|
package/dist/demo/form.html
CHANGED
|
@@ -233,6 +233,48 @@
|
|
|
233
233
|
</template>
|
|
234
234
|
</html-demo-element>
|
|
235
235
|
|
|
236
|
+
<html-demo-element legend="5. using custom-element as form input"
|
|
237
|
+
description="bypass value to container form "
|
|
238
|
+
id="sample-5"
|
|
239
|
+
>
|
|
240
|
+
<ol>
|
|
241
|
+
<li> select radio in top group</li>
|
|
242
|
+
<li> observe the fruit selected on the left</li>
|
|
243
|
+
<li> observe the warning message bellow button</li>
|
|
244
|
+
<li> next button does not submit the form</li>
|
|
245
|
+
<li> select radio in bottom group</li>
|
|
246
|
+
<li> observe the fruit selected on the right</li>
|
|
247
|
+
<li> same fruit selection would eliminate the warning and
|
|
248
|
+
allow the form submission</li>
|
|
249
|
+
<li> after submit, observe the URL parameters 'inp-1=🍏&inp-2=🍏' </li>
|
|
250
|
+
</ol>
|
|
251
|
+
<template>
|
|
252
|
+
<custom-element tag="sample-input">
|
|
253
|
+
<template>
|
|
254
|
+
<attribute name="name" ></attribute>
|
|
255
|
+
<attribute name="value" select="//val"></attribute>
|
|
256
|
+
{$name}
|
|
257
|
+
<label><input type="radio" name="{$name}" slice="val" value="🍏">Apple</label>
|
|
258
|
+
<label><input type="radio" name="{$name}" slice="val" value="🍌">Banana</label>
|
|
259
|
+
</template>
|
|
260
|
+
</custom-element>
|
|
261
|
+
<custom-element>
|
|
262
|
+
<template>
|
|
263
|
+
<form slice="cart-form" action="#sample-5"
|
|
264
|
+
custom-validity="(//inp1 = //inp2) ?? 'pick same fruit'"
|
|
265
|
+
>
|
|
266
|
+
<sample-input slice="inp1" name="inp-1"></sample-input>
|
|
267
|
+
<sample-input slice="inp2" name="inp-2"></sample-input>
|
|
268
|
+
<button>Next</button>
|
|
269
|
+
Picked :{//inp1} and {//inp2}
|
|
270
|
+
|
|
271
|
+
<p>{//cart-form/@validation-message}</p>
|
|
272
|
+
</form>
|
|
273
|
+
</template>
|
|
274
|
+
</custom-element>
|
|
275
|
+
</template>
|
|
276
|
+
</html-demo-element>
|
|
277
|
+
|
|
236
278
|
<script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
|
|
237
279
|
|
|
238
280
|
</body>
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
<img src="https://upload.wikimedia.org/wikipedia/commons/1/1b/Svelte_Logo.svg" alt="Svelte"/>
|
|
108
108
|
<img src="https://www.solidjs.com/img/logo/without-wordmark/logo.svg" alt="SolidJS"/>
|
|
109
109
|
<img src="https://www.svgrepo.com/show/354113/nextjs-icon.svg" alt="NextJS"/>
|
|
110
|
-
<img src="https://
|
|
110
|
+
<img src="https://threejs.org/files/favicon.ico" alt="ThreeJS" href="https://threejs.org/"/>
|
|
111
111
|
<img src="https://www.blazejs.org/logo/icon.png" alt="BlazeJS"/>
|
|
112
112
|
<img src="https://dmtgy0px4zdqn.cloudfront.net/images/integrations/tailwindcss.webp" alt="Tailwind CSS"/>
|
|
113
113
|
<img src="https://dmtgy0px4zdqn.cloudfront.net/images/integrations/flowbite.webp" alt="Flowbite"/>
|
package/dist/demo/hex-grid.html
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
<img src="https://semantic-ui.com/images/logo.png" alt="Semantic UI" href="https://semantic-ui.com/"/>
|
|
53
53
|
<img src="https://open-wc.org/35ded306.svg" alt="Open WC" href="https://open-wc.org/"/>
|
|
54
54
|
<img src="https://storage.googleapis.com/cms-storage-bucket/4fd0db61df0567c0f352.png" alt="Flutter" href="https://flutter.dev/"/>
|
|
55
|
-
<img src="https://refine.dev/img/
|
|
55
|
+
<img src="https://refine.dev/img/favicon.ico" alt="Refine" href="https://refine.dev/"/>
|
|
56
56
|
<img src="https://getbootstrap.com/docs/5.3/assets/brand/bootstrap-logo-shadow.png" alt="Bootstrap" href="https://getbootstrap.com/"/>
|
|
57
57
|
<img src="https://upload.wikimedia.org/wikipedia/commons/9/95/Vue.js_Logo_2.svg" alt="Vue.JS" href="https://vuejs.org/"/>
|
|
58
58
|
<img src="https://lit.dev/images/logo.svg#flame" alt="Lit"/>
|
|
@@ -44,7 +44,7 @@ params needed to declare DCE attributes and track the attributes changes. It als
|
|
|
44
44
|
</template>
|
|
45
45
|
</html-demo-element>
|
|
46
46
|
|
|
47
|
-
<html-demo-element legend="
|
|
47
|
+
<html-demo-element legend="attribute from slice" description="
|
|
48
48
|
when slice value points to attribute, it would be populated on slice change
|
|
49
49
|
">
|
|
50
50
|
Type in the input field to see the variable $title change. <br/>
|
|
@@ -62,6 +62,25 @@ when slice value points to attribute, it would be populated on slice change
|
|
|
62
62
|
</template>
|
|
63
63
|
</html-demo-element>
|
|
64
64
|
|
|
65
|
+
<details>
|
|
66
|
+
<summary>Attributes processing</summary>
|
|
67
|
+
To be available in template, <code>custom-element</code> attributes should be
|
|
68
|
+
defined by <code>attribute</code> markup as shown above.
|
|
69
|
+
The value is taken from attribute text content or from <code>select</code> XPath expression<br/>
|
|
70
|
+
|
|
71
|
+
Declared in such way, attributes are exposed via <code><a
|
|
72
|
+
href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes"
|
|
73
|
+
>observedAttributes</a></code>. <br/>
|
|
74
|
+
The template exposes those attributes as <code>xsl:param</code> which makes the attribute value available as
|
|
75
|
+
xsl variable (as attribute name prefixed with $). <br/>
|
|
76
|
+
After transformation the attributes values are read from CE root and copied into DCE component. <br/>
|
|
77
|
+
The DCE attribute change from outside invokes <code>attributeChangedCallback</code> which triggers DCE re-render.
|
|
78
|
+
<p>
|
|
79
|
+
The <code>value</code> attribute is usual case to be propagated from within of <code>custom-element</code>.
|
|
80
|
+
See the <a href="./form.html#sample-5">using custom-element as form input</a> example.
|
|
81
|
+
</p>
|
|
82
|
+
• <a href="https://github.com/EPA-WG/custom-element/blob/main/docs/attributes.md">Design docs</a>
|
|
83
|
+
</details>
|
|
65
84
|
|
|
66
85
|
|
|
67
86
|
<script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
|
package/dist/demo/s.xml
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<datadom>
|
|
3
|
-
<payload xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
4
|
-
<a xmlns="http://www.w3.org/1999/xhtml" href="#" data-dce-id="4" slot="">link 1</a>
|
|
5
|
-
<a xmlns="http://www.w3.org/1999/xhtml" href="#" data-dce-id="5" slot="">link 2</a>
|
|
6
|
-
<a xmlns="http://www.w3.org/1999/xhtml" href="#" data-dce-id="6" slot="">link 3</a>
|
|
7
|
-
</payload>
|
|
3
|
+
<payload xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"/>
|
|
8
4
|
<attributes>
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
<
|
|
12
|
-
<
|
|
5
|
+
<id>dce1</id>
|
|
6
|
+
<p1>default_P1</p1>
|
|
7
|
+
<p2>always_p2</p2>
|
|
8
|
+
<p3></p3>
|
|
13
9
|
</attributes>
|
|
14
|
-
<dataset
|
|
15
|
-
<dceId>2</dceId>
|
|
16
|
-
</dataset>
|
|
10
|
+
<dataset/>
|
|
17
11
|
<slice/>
|
|
18
12
|
</datadom>
|