@epa-wg/custom-element-dist 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.ts +2 -2
- package/.storybook/preview.ts +1 -1
- package/README.md +4 -4
- package/bin/vitest/vitest-browser-importmaps.mjs +20 -20
- package/coverage/coverage-final.json +22 -22
- 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 +662 -380
- package/coverage/src/custom-element/demo/index.html +1 -1
- package/coverage/src/custom-element/demo/z.js.html +1 -1
- package/coverage/src/custom-element/http-request.js.html +12 -12
- package/coverage/src/custom-element/index.html +21 -21
- package/coverage/src/custom-element/local-storage.js.html +78 -63
- package/coverage/src/custom-element/location-element.js.html +4 -4
- package/coverage/src/custom-element/module-url.js/coverage.svg +1 -1
- package/coverage/src/custom-element/module-url.js.html +16 -10
- package/coverage/src/index.html +1 -1
- package/coverage/src/mocks/handlers.ts.html +1 -1
- package/coverage/src/mocks/index.html +1 -1
- package/coverage/src/stories/attributes.test.stories.ts.html +17 -11
- package/coverage/src/stories/coverage.svg +1 -1
- package/coverage/src/stories/css.test.stories.ts.html +8 -2
- package/coverage/src/stories/dom-merge.test.stories.ts.html +17 -11
- package/coverage/src/stories/external-template.test.stories.ts.html +13 -10
- package/coverage/src/stories/form.test.stories.ts.html +8 -2
- package/coverage/src/stories/http-request.stories.ts.html +1 -1
- package/coverage/src/stories/index.html +26 -26
- package/coverage/src/stories/local-storage.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/local-storage.test.stories.ts.html +106 -76
- package/coverage/src/stories/location-element.test.stories.ts.html +8 -2
- package/coverage/src/stories/module-url.test.stories.ts.html +8 -2
- package/coverage/src/stories/set-url.test.stories.ts.html +8 -2
- package/coverage/src/stories/slice-events.test.stories.ts.html +8 -2
- package/coverage/src/stories/slots.test.stories.ts.html +8 -2
- package/coverage/src/stories/testStoryBook.ts.html +12 -12
- package/coverage/src/stories/version-select.test.stories.ts.html +8 -2
- package/coverage/src/sum.ts.html +1 -1
- package/dist/custom-element-BOIPgtxz.js +565 -0
- package/dist/custom-element-CUsSENWc.cjs +97 -0
- package/dist/custom-element-bundle.cjs +1 -1
- package/dist/custom-element-bundle.js +25 -21
- package/dist/demo/a.svg +27 -0
- package/dist/demo/demo.css +6 -7
- package/dist/demo/external-template.html +3 -3
- package/dist/demo/npm-versions-demo.html +21 -8
- package/dist/demo/npm-versions.html +54 -25
- package/dist/demo/s.xml +11 -21
- package/dist/demo/s.xslt +16 -74
- package/dist/demo/s1.xslt +59 -59
- package/dist/demo/ss.html +24 -57
- package/dist/demo/z.html +33 -62
- package/dist/demo/z.xml +59 -59
- package/dist/demo/z1.html +34 -0
- package/dist/local-storage-78EivJ_B.cjs +1 -0
- package/dist/local-storage-DzmNKzgN.js +66 -0
- package/dist/mockServiceWorker.js +1 -1
- package/package.json +27 -25
- package/public/demo/a.svg +27 -0
- package/public/demo/demo.css +6 -7
- package/public/demo/external-template.html +3 -3
- package/public/demo/npm-versions-demo.html +21 -8
- package/public/demo/npm-versions.html +54 -25
- package/public/demo/s.xml +11 -21
- package/public/demo/s.xslt +16 -74
- package/public/demo/s1.xslt +59 -59
- package/public/demo/ss.html +24 -57
- package/public/demo/z.html +33 -62
- package/public/demo/z.xml +59 -59
- package/public/demo/z1.html +34 -0
- package/public/mockServiceWorker.js +1 -1
- package/src/custom-element/custom-element.js +123 -29
- package/src/custom-element/demo/a.svg +27 -0
- package/src/custom-element/demo/demo.css +6 -7
- package/src/custom-element/demo/external-template.html +3 -3
- package/src/custom-element/demo/npm-versions-demo.html +21 -8
- package/src/custom-element/demo/npm-versions.html +54 -25
- package/src/custom-element/demo/s.xml +11 -21
- package/src/custom-element/demo/s.xslt +16 -74
- package/src/custom-element/demo/s1.xslt +59 -59
- package/src/custom-element/demo/ss.html +24 -57
- package/src/custom-element/demo/z.html +33 -62
- package/src/custom-element/demo/z.xml +59 -59
- package/src/custom-element/demo/z1.html +34 -0
- package/src/custom-element/ide/web-types-dce.json +1 -1
- package/src/custom-element/ide/web-types-xsl.json +1 -1
- package/src/custom-element/index.html +19 -2
- package/src/custom-element/local-storage.js +19 -14
- package/src/custom-element/module-url.js +3 -2
- package/src/dce-social-preview.png +0 -0
- package/src/material/angular.css +987 -0
- package/src/material/components/autocomplete.html +241 -0
- package/src/material/components/dropdown.html +115 -0
- package/src/material/components/menu.html +235 -0
- package/src/material/components.html +109 -0
- package/src/material/demo.css +31 -0
- package/src/material/index.html +169 -0
- package/src/material/material.css +357 -0
- package/src/material/theme/README.md +18 -0
- package/src/material/theme/semantic.css +112 -0
- package/src/mocks/versions.mock.ts +8 -8
- package/src/stories/__screenshots__/http-request.test.ts/http-request-url-change-1.png +0 -0
- package/src/stories/attributes.test.stories.ts +6 -4
- package/src/stories/css.test.stories.ts +2 -0
- package/src/stories/dom-merge.test.stories.ts +11 -9
- package/src/stories/external-template.test.stories.ts +4 -3
- package/src/stories/form.test.stories.ts +2 -0
- package/src/stories/local-storage.test.stories.ts +63 -53
- package/src/stories/location-element.test.stories.ts +2 -0
- package/src/stories/module-url.test.stories.ts +2 -0
- package/src/stories/set-url.test.stories.ts +2 -0
- package/src/stories/slice-events.test.stories.ts +2 -0
- package/src/stories/slots.test.stories.ts +2 -0
- package/src/stories/version-select.test.stories.ts +2 -0
- package/src/sum.test.ts +5 -5
- package/src/sum.ts +3 -3
- package/storybook-static/assets/Color-ERTF36HU-ChyYtq0t.js +1 -0
- package/storybook-static/assets/Configure-CJVwFVjC.js +165 -0
- package/storybook-static/assets/DocsRenderer-CFRXHY34-Bz6q-OqD.js +2 -0
- package/storybook-static/assets/{attributes.test.stories-DIQXccHc.js → attributes.test.stories-BJBuuXgZ.js} +13 -14
- package/storybook-static/assets/{css.test.stories-BV2hi4CY.js → css.test.stories-pgbBc17d.js} +1 -1
- package/storybook-static/assets/custom-element-BDGsYgbP.js +97 -0
- package/storybook-static/assets/{dom-merge.test.stories-Dws0C2-g.js → dom-merge.test.stories-CXcYP_-J.js} +26 -24
- package/storybook-static/assets/entry-preview-C313OLrj.js +26 -0
- package/storybook-static/assets/{entry-preview-docs-BMKNVQXA.js → entry-preview-docs-B7ORr9w5.js} +2 -2
- package/storybook-static/assets/{external-template.test.stories-BHO48b0j.js → external-template.test.stories-CpJ68Ghy.js} +19 -20
- package/storybook-static/assets/{form.test.stories-dv9mwp24.js → form.test.stories-D35lyqd8.js} +2 -2
- package/storybook-static/assets/{handlers-CaCq2ZPF.js → handlers-B-OZtf2K.js} +13 -13
- package/storybook-static/assets/{http-request.stories-B2ke7LtS.js → http-request.stories-DccXgHyF.js} +6 -6
- package/storybook-static/assets/iframe-Ddc_axoC.js +2 -0
- package/storybook-static/assets/index-BSz1w4Gl.js +234 -0
- package/storybook-static/assets/index-BdcJ-iJ7.js +8 -0
- package/storybook-static/assets/index-CiCdFubk.js +634 -0
- package/storybook-static/assets/{index-Dz4OaB2k.js → index-f2MAjm2i.js} +1 -1
- package/storybook-static/assets/index-lY6s0fkU.js +1 -0
- package/storybook-static/assets/index-tfEkrhWr.js +1 -0
- package/storybook-static/assets/local-storage.test.stories-BY-PWhuk.js +420 -0
- package/storybook-static/assets/{location-element.test.stories-BiFvBop7.js → location-element.test.stories-3auBYEaU.js} +3 -3
- package/storybook-static/assets/{module-url.test.stories-BXoM34tX.js → module-url.test.stories-B7L9cL60.js} +6 -6
- package/storybook-static/assets/{preview-0Jj89qip.js → preview-BRPR-UXC.js} +1 -1
- package/storybook-static/assets/preview-BUQm51_C.js +52 -0
- package/storybook-static/assets/{preview-DB9FwMii.js → preview-BWzBA1C2.js} +1 -1
- package/storybook-static/assets/preview-BhhEZcNS.js +1 -0
- package/storybook-static/assets/preview-CcS4DQh8.js +1 -0
- package/storybook-static/assets/{preview-Cg7hXPRq.js → preview-CfH4_OzN.js} +2 -2
- package/storybook-static/assets/{preview-FpHGYA1q.js → preview-DHPc-V4N.js} +1 -1
- package/storybook-static/assets/preview-DYzi3Z2p.js +1 -0
- package/storybook-static/assets/{preview-4Up_z4Em.js → preview-caVMbCIR.js} +2 -2
- package/storybook-static/assets/preview-ncvtW_hb.js +34 -0
- package/storybook-static/assets/{set-url.test.stories-Cg5Z0r7x.js → set-url.test.stories-CuSuDLIx.js} +3 -3
- package/storybook-static/assets/{slice-events.test.stories-D_ttGp3g.js → slice-events.test.stories-BkRKsKem.js} +4 -4
- package/storybook-static/assets/{slots.test.stories-DBNXOm0T.js → slots.test.stories-BJCUWFkE.js} +8 -8
- package/storybook-static/assets/{version-select.test.stories-CgV3UCim.js → version-select.test.stories-B3ybJn_Z.js} +2 -2
- package/storybook-static/demo/a.svg +27 -0
- package/storybook-static/demo/demo.css +6 -7
- package/storybook-static/demo/external-template.html +3 -3
- package/storybook-static/demo/npm-versions-demo.html +21 -8
- package/storybook-static/demo/npm-versions.html +54 -25
- package/storybook-static/demo/s.xml +11 -21
- package/storybook-static/demo/s.xslt +16 -74
- package/storybook-static/demo/s1.xslt +59 -59
- package/storybook-static/demo/ss.html +24 -57
- package/storybook-static/demo/z.html +33 -62
- package/storybook-static/demo/z.xml +59 -59
- package/storybook-static/demo/z1.html +34 -0
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/index.html +3 -7
- package/storybook-static/mockServiceWorker.js +1 -1
- package/storybook-static/project.json +1 -1
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +9 -9
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +76 -94
- package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/interactions-9/manager-bundle.js +211 -0
- package/storybook-static/sb-addons/interactions-9/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +11 -0
- package/storybook-static/sb-manager/globals-runtime.js +27803 -26928
- package/storybook-static/sb-manager/runtime.js +10341 -10136
- package/storybook-static/sb-preview/runtime.js +3841 -3828
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/compiler.xml +0 -6
- package/.idea/custom-element-dist.iml +0 -13
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.vscode/settings.json +0 -24
- package/dist/custom-element-CckoVsvO.cjs +0 -53
- package/dist/custom-element-b7c_7Kz4.js +0 -485
- package/dist/local-storage-Boafngui.cjs +0 -1
- package/dist/local-storage-BqDEu2kF.js +0 -59
- package/storybook-static/assets/Color-KGDBMAHA-CH-YyWYq.js +0 -1
- package/storybook-static/assets/Configure-DFL_bm2M.js +0 -173
- package/storybook-static/assets/DocsRenderer-PKQXORMH-Bz-_1hmS.js +0 -2
- package/storybook-static/assets/custom-element-wn23PUwN.js +0 -231
- package/storybook-static/assets/entry-preview-BKQ8UCxI.js +0 -8
- package/storybook-static/assets/iframe-D4Sos1HO.js +0 -2
- package/storybook-static/assets/index-BnXBQqj9.js +0 -605
- package/storybook-static/assets/index-C8k3Z-3Y.js +0 -28
- package/storybook-static/assets/index-Cpxqn5iQ.js +0 -1
- package/storybook-static/assets/index-DGdNYaqV.js +0 -8
- package/storybook-static/assets/index-sm7QlJZE.js +0 -1
- package/storybook-static/assets/lit-element-DzhCn-8W.js +0 -19
- package/storybook-static/assets/local-storage.test.stories-BpogLNq-.js +0 -419
- package/storybook-static/assets/preview-BJPLiuSt.js +0 -1
- package/storybook-static/assets/preview-BMWqy4Bi.js +0 -1
- package/storybook-static/assets/preview-BnWGZYux.js +0 -1
- package/storybook-static/assets/preview-Djh1_Tal.js +0 -20
- package/storybook-static/assets/preview-oHxXRSIu.js +0 -48
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js +0 -333
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js.LEGAL.txt +0 -40
- package/storybook-static/sb-addons/interactions-10/manager-bundle.js +0 -234
- /package/{storybook-static/sb-addons/interactions-10/manager-bundle.js.LEGAL.txt → src/material/guide/getting-started/index.html} +0 -0
|
@@ -1,419 +0,0 @@
|
|
|
1
|
-
import{w as x,e as c}from"./custom-element-wn23PUwN.js";import"./index-C8k3Z-3Y.js";const p=(l,t)=>{if(l==="text")return t;if(l==="json")try{return JSON.parse(t)}catch{return null}const a=document.createElement("input");return a.setAttribute("type",l),l==="number"?(a.value=t,a.valueAsNumber):l==="date"?t?(a.valueAsDate=new Date(t),a.value):null:(a.value=t,a.value)};let b,v,g;function w(){b||(b=localStorage.setItem,localStorage.setItem=function(l,t,...a){b.apply(this,[l,t,...a]),window.dispatchEvent(new CustomEvent("local-storage",{detail:{key:l,value:t}}))},v=localStorage.removeItem,localStorage.removeItem=function(l,...t){v.apply(this,[l,...t]),window.dispatchEvent(new CustomEvent("local-storage",{detail:{key:l}}))},g=localStorage.clear,localStorage.clear=function(...l){g.apply(this,[...l]),window.dispatchEvent(new CustomEvent("local-storage",{detail:{}}))})}function I(l,t){localStorage.setItem(l,t),window.dispatchEvent(new CustomEvent("local-storage",{detail:{key:l,value:t}}))}class T extends HTMLElement{static observedAttributes=["value","slice","key","type","live"];#e;get value(){return this.#e===null?void 0:this.#e}set value(t){return this.#e=t}async connectedCallback(){const t=n=>this.getAttribute(n),a=()=>{this.#e=p(t("type"),localStorage.getItem(t("key"))),this.dispatchEvent(new Event("change"))};if(this.#e=p(t("type"),localStorage.getItem(t("key"))),this.hasAttribute("value")?I(t("key"),this.#e=t("value")):a(),this.hasAttribute("live")){const n=e=>(e.detail.key===t("key")||!e.detail.key)&&a();window.addEventListener("local-storage",n),w(),this._destroy=()=>window.removeEventListener("local-storage",n)}}disconnectedCallback(){this._destroy?.()}}window.customElements.define("local-storage",T);const s={title:"",slice:"ls-slice",key:"sb-ls-key",value:"",live:"",body:""};function o(l){return new Promise(t=>setTimeout(t,l))}function V(l){const{title:t,slice:a,key:n,value:e,live:i,body:y}={...s,...l};return`
|
|
2
|
-
<fieldset>
|
|
3
|
-
<legend>${t}</legend>
|
|
4
|
-
|
|
5
|
-
<custom-element>
|
|
6
|
-
<template><!-- wrapping into template to prevent images loading within DCE declaration -->
|
|
7
|
-
<local-storage
|
|
8
|
-
key="${n}"
|
|
9
|
-
slice="${a}"
|
|
10
|
-
${i?`live="${i}"`:""}
|
|
11
|
-
${e?`value="${e}"`:""}
|
|
12
|
-
></local-storage>
|
|
13
|
-
|
|
14
|
-
<br/>
|
|
15
|
-
<var>${n}</var>:<code data-testid="slice-value">{ //slice/${a} }</code>
|
|
16
|
-
<br/>
|
|
17
|
-
${y}
|
|
18
|
-
</template>
|
|
19
|
-
</custom-element>
|
|
20
|
-
</fieldset>
|
|
21
|
-
`}const E={title:"local-storage",render:V},u={args:{title:"live value",live:"live",body:`
|
|
22
|
-
<input placeholder="value for localStorage" id="textinput"
|
|
23
|
-
slice="${s.slice}"
|
|
24
|
-
value="{ //${s.slice} ?? '${s.value}' }"/>
|
|
25
|
-
<button onclick="localStorage.setItem('${s.key}',textinput.value )">set</button>
|
|
26
|
-
<button onclick="localStorage.setItem('${s.key}','text value' )">text value</button>
|
|
27
|
-
<button onclick="localStorage.setItem('${s.key}','another text')">another text</button>
|
|
28
|
-
<button onclick="localStorage.removeItem('${s.key}' )">set blank</button>
|
|
29
|
-
`},play:async({canvasElement:l})=>{const t=x(l);await t.findByText(u.args.title);const a=()=>t.getByTestId("slice-value").textContent,n=e=>t.getByText(e);n("set blank").click(),c(localStorage.getItem(s.key)).toEqual(null,"from localStorage"),c(a()).toEqual(""),n("text value").click(),await o(10),c(a()).toEqual("text value"),window.textinput.value="textinput.value",n("set").click(),await o(10),c(a()).toEqual("textinput.value"),n("another text").click(),await o(10),c(a()).toEqual("another text"),n("set blank").click(),await o(10),c(a()).toEqual("")}},k={args:{title:"AlwaysOverride",live:"",value:"ABC",body:`
|
|
30
|
-
buttons are changing the localStorage value, but without 'live' attribute slice ^^ from <i>local-storage</i> is not updated<br/>
|
|
31
|
-
<button onclick="localStorage.setItem('${s.key}','text value' )">text value</button>
|
|
32
|
-
<button onclick="localStorage.removeItem('${s.key}' )">set blank</button>
|
|
33
|
-
`},play:async({canvasElement:l})=>{const t=x(l);await t.findByText(k.args.title);const a=()=>t.getByTestId("slice-value").textContent,n=e=>t.getByText(e);c(localStorage.getItem(s.key)).toEqual("ABC","from localStorage"),n("set blank").click(),c(localStorage.getItem(s.key)).toEqual(null,"from localStorage"),await o(10),c(a()).toEqual("ABC"),n("text value").click(),await o(10),c(localStorage.getItem(s.key)).toEqual("text value","from localStorage"),c(a()).toEqual("ABC"),n("set blank").click(),await o(10),c(a()).toEqual("ABC")}},m={args:{title:"live value with defaults",live:"",value:"ABC",body:`
|
|
34
|
-
|
|
35
|
-
<local-storage key="attr2Key" slice="attr2-key" type="text" live="live" slice-value="@value ?? 'DEF2'"></local-storage>
|
|
36
|
-
<button onclick="localStorage.removeItem('attr2Key')">clear key</button>
|
|
37
|
-
<button onclick="localStorage.setItem('attr2Key','attr2Key value')">update attr2-key value</button>
|
|
38
|
-
//attr2-key: <code data-testid="key2-value">{//attr2-key}</code><br/>
|
|
39
|
-
|
|
40
|
-
<local-storage key="attr3Key" slice="attr3-key" type="text" live="live" slice-value="@value ?? 'DEF3'"></local-storage>
|
|
41
|
-
<button onclick="localStorage.removeItem('attr3Key')">clear attr3-key key</button>
|
|
42
|
-
<button onclick="localStorage.setItem('attr3Key','attr3Key value')">update attr3-key value</button>
|
|
43
|
-
//attr3-key: <code data-testid="key3-value">{//attr3-key}</code><br/>
|
|
44
|
-
<button onclick="localStorage.clear()">clear localStorage</button>
|
|
45
|
-
`},play:async({canvasElement:l})=>{const t=x(l);await t.findByText(m.args.title);const a=n=>t.getByText(n);c(localStorage.getItem(s.key)).toEqual("ABC","from localStorage"),a("clear localStorage").click(),c(t.getByTestId("slice-value").textContent).toEqual("ABC"),c(t.getByTestId("key2-value").textContent).toEqual("DEF2"),c(t.getByTestId("key3-value").textContent).toEqual("DEF3"),a("update attr2-key value").click(),c(localStorage.getItem("attr2Key")).toEqual("attr2Key value","from localStorage"),await o(10),c(t.getByTestId("slice-value").textContent).toEqual("ABC"),c(t.getByTestId("key2-value").textContent).toEqual("attr2Key value"),c(t.getByTestId("key3-value").textContent).toEqual("DEF3"),a("update attr3-key value").click(),c(localStorage.getItem("attr3Key")).toEqual("attr3Key value","from localStorage"),await o(10),c(t.getByTestId("slice-value").textContent).toEqual("ABC"),c(t.getByTestId("key2-value").textContent).toEqual("attr2Key value"),c(t.getByTestId("key3-value").textContent).toEqual("attr3Key value")}},d={args:{title:"local-storage type attribute variations",body:`
|
|
46
|
-
|
|
47
|
-
<local-storage key="textKey" slice="text-key" type="text" live="live"></local-storage>
|
|
48
|
-
<local-storage key="dateKey" slice="date-key" type="date" live="live"></local-storage>
|
|
49
|
-
<local-storage key="timeKey" slice="time-key" type="time" live="live"></local-storage>
|
|
50
|
-
<local-storage key="localDateTimeKey" slice="local-date-time" type="datetime-local" live="live"></local-storage>
|
|
51
|
-
<local-storage key="numberKey" slice="number-key" type="number" live="live"></local-storage>
|
|
52
|
-
<local-storage key="jsonKey" slice="json-key" type="json" live="live"></local-storage>
|
|
53
|
-
<input id="typesinput" placeholder="set value"><button onclick="
|
|
54
|
-
'textKey,dateKey,timeKey,localDateTimeKey,numberKey,jsonKey'.split(',')
|
|
55
|
-
.map( k=> localStorage.setItem(k, typesinput.value) )
|
|
56
|
-
"> set to all</button><br>
|
|
57
|
-
<hr>
|
|
58
|
-
text-key:
|
|
59
|
-
<button onclick="localStorage.setItem('textKey', 'ABC' )">ABC</button>
|
|
60
|
-
<code data-testid="text-key">{//text-key }</code><br>
|
|
61
|
-
date-key:
|
|
62
|
-
<button onclick="localStorage.setItem('dateKey', '2024-04-20T03:58:42.131Z')">2024-04-21T03:58:42.131Z </button>
|
|
63
|
-
<button onclick="localStorage.setItem('dateKey', new Date(Date.now()).toISOString())">now </button>
|
|
64
|
-
<button onclick="localStorage.setItem('dateKey', 'ABC' )">date ABC - invalid </button>
|
|
65
|
-
<code data-testid="date-key">{//date-key }</code><br>
|
|
66
|
-
time-key:
|
|
67
|
-
<button onclick="localStorage.setItem('timeKey', '13:30')">13:30 </button>
|
|
68
|
-
<code data-testid="time-key">{//time-key }</code><br>
|
|
69
|
-
local-date-time:
|
|
70
|
-
<button onclick="localStorage.setItem('localDateTimeKey', '1977-04-01T14:00:30')">1977-04-01T14:00:30 - local </button>
|
|
71
|
-
<code data-testid="local-date-time">{//local-date-time}</code><br>
|
|
72
|
-
number-key:
|
|
73
|
-
<button onclick="localStorage.setItem('numberKey', '2024' )">2024 - number </button>
|
|
74
|
-
<button onclick="localStorage.setItem('numberKey', '24' )">24 - number </button>
|
|
75
|
-
<button onclick="localStorage.setItem('numberKey', '1.23456e+5' )">1.23456e+5 </button>
|
|
76
|
-
<button onclick="localStorage.setItem('numberKey', '0001' )">0001 </button>
|
|
77
|
-
<button onclick="localStorage.setItem('numberKey', '000' )">000 </button>
|
|
78
|
-
<button onclick="localStorage.setItem('numberKey', '0' )">0 </button>
|
|
79
|
-
<button onclick="localStorage.setItem('numberKey', 'ABC' )">ABC - invalid, NaN </button>
|
|
80
|
-
<code data-testid="number-key">{//number-key }</code> <br>
|
|
81
|
-
<fieldset>
|
|
82
|
-
<legend>json-key: </legend>
|
|
83
|
-
|
|
84
|
-
<button onclick="localStorage.setItem('jsonKey', JSON.stringify('ABC'))">'ABC' - string </button>
|
|
85
|
-
<button onclick="localStorage.setItem('jsonKey', JSON.stringify(12.345))">12.345 - number </button>
|
|
86
|
-
<button onclick="localStorage.setItem('jsonKey', JSON.stringify(window.JsonSample) )">a:1,b:'B' -json </button>
|
|
87
|
-
<button onclick="localStorage.setItem('jsonKey', 'ABC' )">ABC - invalid </button><br>
|
|
88
|
-
json-key:<code data-testid="json-key"><xsl:apply-templates select="//json-key/value/@*|//json-key/text()|//json-key/value/text()" mode="json"></xsl:apply-templates></code>
|
|
89
|
-
</fieldset>
|
|
90
|
-
<xsl:template mode="json" match="*|@*">
|
|
91
|
-
<div>{name()} : {.}</div>
|
|
92
|
-
</xsl:template>
|
|
93
|
-
`},play:async({canvasElement:l})=>{window.JsonSample={a:1,b:"B"};const t=x(l);await t.findByText(d.args.title);const a=r=>t.getByText(r),n=r=>t.getByTestId(r).textContent,e=(r,S)=>{c(n(r)).toEqual(S,r)};localStorage.clear(),await o(10),e("text-key",""),e("date-key",""),e("time-key",""),e("local-date-time",""),e("number-key","NaN"),e("json-key","");const i=l.querySelector("input");i.value="ABC",a("set to all").click(),await o(10),e("text-key","ABC"),e("date-key",""),e("time-key",""),e("local-date-time",""),e("number-key","NaN"),e("json-key",""),i.value="22",a("set to all").click(),await o(10),e("text-key","22"),e("date-key",""),e("time-key",""),e("local-date-time",""),e("number-key","22"),e("json-key","22"),i.value="2024",a("set to all").click(),await o(10),e("text-key","2024"),e("date-key","2024-01-01"),e("time-key",""),e("local-date-time",""),e("number-key","2024"),e("json-key","2024"),i.value="2024-04-20T03:58:42.131Z",a("set to all").click(),await o(10),e("text-key","2024-04-20T03:58:42.131Z"),e("date-key","2024-04-20"),e("time-key",""),e("local-date-time",""),e("number-key","NaN"),e("json-key","");const y=new Date(Date.now()).toISOString();i.value=y,a("set to all").click(),await o(10),e("text-key",y),e("date-key",y.substring(0,10)),e("time-key",""),e("local-date-time",""),e("number-key","NaN"),e("json-key",""),i.value="23:25",a("set to all").click(),await o(10),e("text-key","23:25"),e("date-key",""),e("time-key","23:25"),e("local-date-time",""),e("number-key","NaN"),e("json-key",""),i.value="1977-04-01T14:00:30",a("set to all").click(),await o(10),e("text-key","1977-04-01T14:00:30"),e("date-key","1977-04-01"),e("time-key",""),e("local-date-time","1977-04-01T14:00:30"),e("number-key","NaN"),e("json-key",""),i.value="1.23456e+5",a("set to all").click(),await o(10),e("text-key","1.23456e+5"),e("date-key",""),e("time-key",""),e("local-date-time",""),e("number-key","123456"),e("json-key","123456"),i.value="0001",a("set to all").click(),await o(10),e("text-key","0001"),e("date-key","0001-01-01"),e("time-key",""),e("local-date-time",""),e("number-key","1"),e("json-key",""),i.value="001",a("set to all").click(),await o(10),e("text-key","001"),e("date-key","2001-01-01"),e("time-key",""),e("local-date-time",""),e("number-key","1"),e("json-key",""),i.value="000",a("set to all").click(),await o(10),e("text-key","000"),e("date-key","2000-01-01"),e("time-key",""),e("local-date-time",""),e("number-key","0"),e("json-key",""),i.value="0",a("set to all").click(),await o(10),e("text-key","0"),e("date-key","2000-01-01"),e("time-key",""),e("local-date-time",""),e("number-key","0"),e("json-key","0"),i.value='"abc"',a("set to all").click(),await o(10),e("text-key",'"abc"'),e("date-key",""),e("time-key",""),e("local-date-time",""),e("number-key","NaN"),e("json-key","abc"),i.value="12.345",a("set to all").click(),await o(10),e("text-key","12.345"),e("date-key",""),e("time-key",""),e("local-date-time",""),e("number-key","12.345"),e("json-key","12.345"),i.value='{"a":1,"b":"B"}',a("set to all").click(),await o(10),e("text-key",'{"a":1,"b":"B"}'),e("date-key",""),e("time-key",""),e("local-date-time",""),e("number-key","NaN"),e("json-key",`
|
|
94
|
-
a : 1b : B`)}};u.parameters={...u.parameters,docs:{...u.parameters?.docs,source:{originalSource:`{
|
|
95
|
-
args: {
|
|
96
|
-
title: 'live value',
|
|
97
|
-
live: 'live',
|
|
98
|
-
body: \`
|
|
99
|
-
<input placeholder="value for localStorage" id="textinput"
|
|
100
|
-
slice="\${defs.slice}"
|
|
101
|
-
value="{ //\${defs.slice} ?? '\${defs.value}' }"/>
|
|
102
|
-
<button onclick="localStorage.setItem('\${defs.key}',textinput.value )">set</button>
|
|
103
|
-
<button onclick="localStorage.setItem('\${defs.key}','text value' )">text value</button>
|
|
104
|
-
<button onclick="localStorage.setItem('\${defs.key}','another text')">another text</button>
|
|
105
|
-
<button onclick="localStorage.removeItem('\${defs.key}' )">set blank</button>
|
|
106
|
-
\`
|
|
107
|
-
},
|
|
108
|
-
play: async ({
|
|
109
|
-
canvasElement
|
|
110
|
-
}) => {
|
|
111
|
-
const canvas = within(canvasElement);
|
|
112
|
-
await canvas.findByText((Demo.args!.title as string));
|
|
113
|
-
const val = () => canvas.getByTestId('slice-value').textContent,
|
|
114
|
-
byText = txt => canvas.getByText(txt);
|
|
115
|
-
byText('set blank').click();
|
|
116
|
-
expect(localStorage.getItem(defs.key)).toEqual(null, 'from localStorage');
|
|
117
|
-
expect(val()).toEqual('');
|
|
118
|
-
byText('text value').click();
|
|
119
|
-
await sleep(10);
|
|
120
|
-
expect(val()).toEqual('text value');
|
|
121
|
-
window['textinput'].value = 'textinput.value';
|
|
122
|
-
byText('set').click();
|
|
123
|
-
await sleep(10);
|
|
124
|
-
expect(val()).toEqual('textinput.value');
|
|
125
|
-
byText('another text').click();
|
|
126
|
-
await sleep(10);
|
|
127
|
-
expect(val()).toEqual('another text');
|
|
128
|
-
byText('set blank').click();
|
|
129
|
-
await sleep(10);
|
|
130
|
-
expect(val()).toEqual('');
|
|
131
|
-
}
|
|
132
|
-
}`,...u.parameters?.docs?.source}}};k.parameters={...k.parameters,docs:{...k.parameters?.docs,source:{originalSource:`{
|
|
133
|
-
args: {
|
|
134
|
-
title: 'AlwaysOverride',
|
|
135
|
-
live: '',
|
|
136
|
-
value: 'ABC',
|
|
137
|
-
body: \`
|
|
138
|
-
buttons are changing the localStorage value, but without 'live' attribute slice ^^ from <i>local-storage</i> is not updated<br/>
|
|
139
|
-
<button onclick="localStorage.setItem('\${defs.key}','text value' )">text value</button>
|
|
140
|
-
<button onclick="localStorage.removeItem('\${defs.key}' )">set blank</button>
|
|
141
|
-
\`
|
|
142
|
-
},
|
|
143
|
-
play: async ({
|
|
144
|
-
canvasElement
|
|
145
|
-
}) => {
|
|
146
|
-
const canvas = within(canvasElement);
|
|
147
|
-
await canvas.findByText((AlwaysOverride.args!.title as string));
|
|
148
|
-
const val = () => canvas.getByTestId('slice-value').textContent,
|
|
149
|
-
byText = txt => canvas.getByText(txt);
|
|
150
|
-
expect(localStorage.getItem(defs.key)).toEqual('ABC', 'from localStorage');
|
|
151
|
-
byText('set blank').click();
|
|
152
|
-
expect(localStorage.getItem(defs.key)).toEqual(null, 'from localStorage');
|
|
153
|
-
await sleep(10);
|
|
154
|
-
expect(val()).toEqual('ABC');
|
|
155
|
-
byText('text value').click();
|
|
156
|
-
await sleep(10);
|
|
157
|
-
expect(localStorage.getItem(defs.key)).toEqual('text value', 'from localStorage');
|
|
158
|
-
expect(val()).toEqual('ABC');
|
|
159
|
-
byText('set blank').click();
|
|
160
|
-
await sleep(10);
|
|
161
|
-
expect(val()).toEqual('ABC');
|
|
162
|
-
}
|
|
163
|
-
}`,...k.parameters?.docs?.source}}};m.parameters={...m.parameters,docs:{...m.parameters?.docs,source:{originalSource:`{
|
|
164
|
-
args: {
|
|
165
|
-
title: 'live value with defaults',
|
|
166
|
-
live: '',
|
|
167
|
-
value: 'ABC',
|
|
168
|
-
body: \`
|
|
169
|
-
|
|
170
|
-
<local-storage key="attr2Key" slice="attr2-key" type="text" live="live" slice-value="@value ?? 'DEF2'"></local-storage>
|
|
171
|
-
<button onclick="localStorage.removeItem('attr2Key')">clear key</button>
|
|
172
|
-
<button onclick="localStorage.setItem('attr2Key','attr2Key value')">update attr2-key value</button>
|
|
173
|
-
//attr2-key: <code data-testid="key2-value">{//attr2-key}</code><br/>
|
|
174
|
-
|
|
175
|
-
<local-storage key="attr3Key" slice="attr3-key" type="text" live="live" slice-value="@value ?? 'DEF3'"></local-storage>
|
|
176
|
-
<button onclick="localStorage.removeItem('attr3Key')">clear attr3-key key</button>
|
|
177
|
-
<button onclick="localStorage.setItem('attr3Key','attr3Key value')">update attr3-key value</button>
|
|
178
|
-
//attr3-key: <code data-testid="key3-value">{//attr3-key}</code><br/>
|
|
179
|
-
<button onclick="localStorage.clear()">clear localStorage</button>
|
|
180
|
-
\`
|
|
181
|
-
},
|
|
182
|
-
play: async ({
|
|
183
|
-
canvasElement
|
|
184
|
-
}) => {
|
|
185
|
-
const canvas = within(canvasElement);
|
|
186
|
-
await canvas.findByText((FromStorageWithDefault.args!.title as string));
|
|
187
|
-
const byText = txt => canvas.getByText(txt);
|
|
188
|
-
expect(localStorage.getItem(defs.key)).toEqual('ABC', 'from localStorage');
|
|
189
|
-
byText('clear localStorage').click();
|
|
190
|
-
expect(canvas.getByTestId('slice-value').textContent).toEqual('ABC');
|
|
191
|
-
expect(canvas.getByTestId('key2-value').textContent).toEqual('DEF2');
|
|
192
|
-
expect(canvas.getByTestId('key3-value').textContent).toEqual('DEF3');
|
|
193
|
-
byText('update attr2-key value').click();
|
|
194
|
-
expect(localStorage.getItem('attr2Key')).toEqual('attr2Key value', 'from localStorage');
|
|
195
|
-
await sleep(10);
|
|
196
|
-
expect(canvas.getByTestId('slice-value').textContent).toEqual('ABC');
|
|
197
|
-
expect(canvas.getByTestId('key2-value').textContent).toEqual('attr2Key value');
|
|
198
|
-
expect(canvas.getByTestId('key3-value').textContent).toEqual('DEF3');
|
|
199
|
-
byText('update attr3-key value').click();
|
|
200
|
-
expect(localStorage.getItem('attr3Key')).toEqual('attr3Key value', 'from localStorage');
|
|
201
|
-
await sleep(10);
|
|
202
|
-
expect(canvas.getByTestId('slice-value').textContent).toEqual('ABC');
|
|
203
|
-
expect(canvas.getByTestId('key2-value').textContent).toEqual('attr2Key value');
|
|
204
|
-
expect(canvas.getByTestId('key3-value').textContent).toEqual('attr3Key value');
|
|
205
|
-
}
|
|
206
|
-
}`,...m.parameters?.docs?.source}}};d.parameters={...d.parameters,docs:{...d.parameters?.docs,source:{originalSource:`{
|
|
207
|
-
args: {
|
|
208
|
-
title: 'local-storage type attribute variations',
|
|
209
|
-
body: \`
|
|
210
|
-
|
|
211
|
-
<local-storage key="textKey" slice="text-key" type="text" live="live"></local-storage>
|
|
212
|
-
<local-storage key="dateKey" slice="date-key" type="date" live="live"></local-storage>
|
|
213
|
-
<local-storage key="timeKey" slice="time-key" type="time" live="live"></local-storage>
|
|
214
|
-
<local-storage key="localDateTimeKey" slice="local-date-time" type="datetime-local" live="live"></local-storage>
|
|
215
|
-
<local-storage key="numberKey" slice="number-key" type="number" live="live"></local-storage>
|
|
216
|
-
<local-storage key="jsonKey" slice="json-key" type="json" live="live"></local-storage>
|
|
217
|
-
<input id="typesinput" placeholder="set value"><button onclick="
|
|
218
|
-
'textKey,dateKey,timeKey,localDateTimeKey,numberKey,jsonKey'.split(',')
|
|
219
|
-
.map( k=> localStorage.setItem(k, typesinput.value) )
|
|
220
|
-
"> set to all</button><br>
|
|
221
|
-
<hr>
|
|
222
|
-
text-key:
|
|
223
|
-
<button onclick="localStorage.setItem('textKey', 'ABC' )">ABC</button>
|
|
224
|
-
<code data-testid="text-key">{//text-key }</code><br>
|
|
225
|
-
date-key:
|
|
226
|
-
<button onclick="localStorage.setItem('dateKey', '2024-04-20T03:58:42.131Z')">2024-04-21T03:58:42.131Z </button>
|
|
227
|
-
<button onclick="localStorage.setItem('dateKey', new Date(Date.now()).toISOString())">now </button>
|
|
228
|
-
<button onclick="localStorage.setItem('dateKey', 'ABC' )">date ABC - invalid </button>
|
|
229
|
-
<code data-testid="date-key">{//date-key }</code><br>
|
|
230
|
-
time-key:
|
|
231
|
-
<button onclick="localStorage.setItem('timeKey', '13:30')">13:30 </button>
|
|
232
|
-
<code data-testid="time-key">{//time-key }</code><br>
|
|
233
|
-
local-date-time:
|
|
234
|
-
<button onclick="localStorage.setItem('localDateTimeKey', '1977-04-01T14:00:30')">1977-04-01T14:00:30 - local </button>
|
|
235
|
-
<code data-testid="local-date-time">{//local-date-time}</code><br>
|
|
236
|
-
number-key:
|
|
237
|
-
<button onclick="localStorage.setItem('numberKey', '2024' )">2024 - number </button>
|
|
238
|
-
<button onclick="localStorage.setItem('numberKey', '24' )">24 - number </button>
|
|
239
|
-
<button onclick="localStorage.setItem('numberKey', '1.23456e+5' )">1.23456e+5 </button>
|
|
240
|
-
<button onclick="localStorage.setItem('numberKey', '0001' )">0001 </button>
|
|
241
|
-
<button onclick="localStorage.setItem('numberKey', '000' )">000 </button>
|
|
242
|
-
<button onclick="localStorage.setItem('numberKey', '0' )">0 </button>
|
|
243
|
-
<button onclick="localStorage.setItem('numberKey', 'ABC' )">ABC - invalid, NaN </button>
|
|
244
|
-
<code data-testid="number-key">{//number-key }</code> <br>
|
|
245
|
-
<fieldset>
|
|
246
|
-
<legend>json-key: </legend>
|
|
247
|
-
|
|
248
|
-
<button onclick="localStorage.setItem('jsonKey', JSON.stringify('ABC'))">'ABC' - string </button>
|
|
249
|
-
<button onclick="localStorage.setItem('jsonKey', JSON.stringify(12.345))">12.345 - number </button>
|
|
250
|
-
<button onclick="localStorage.setItem('jsonKey', JSON.stringify(window.JsonSample) )">a:1,b:'B' -json </button>
|
|
251
|
-
<button onclick="localStorage.setItem('jsonKey', 'ABC' )">ABC - invalid </button><br>
|
|
252
|
-
json-key:<code data-testid="json-key"><xsl:apply-templates select="//json-key/value/@*|//json-key/text()|//json-key/value/text()" mode="json"></xsl:apply-templates></code>
|
|
253
|
-
</fieldset>
|
|
254
|
-
<xsl:template mode="json" match="*|@*">
|
|
255
|
-
<div>{name()} : {.}</div>
|
|
256
|
-
</xsl:template>
|
|
257
|
-
\`
|
|
258
|
-
},
|
|
259
|
-
play: async ({
|
|
260
|
-
canvasElement
|
|
261
|
-
}) => {
|
|
262
|
-
window['JsonSample'] = {
|
|
263
|
-
a: 1,
|
|
264
|
-
b: 'B'
|
|
265
|
-
};
|
|
266
|
-
const canvas = within(canvasElement);
|
|
267
|
-
await canvas.findByText((TypeAttribute.args!.title as string));
|
|
268
|
-
const byText = txt => canvas.getByText(txt),
|
|
269
|
-
val = testId => canvas.getByTestId(testId).textContent,
|
|
270
|
-
expectVal = (key, value) => {
|
|
271
|
-
expect(val(key)).toEqual(value, key);
|
|
272
|
-
};
|
|
273
|
-
localStorage.clear(); // cleanup before test
|
|
274
|
-
await sleep(10);
|
|
275
|
-
expectVal('text-key', '');
|
|
276
|
-
expectVal('date-key', '');
|
|
277
|
-
expectVal('time-key', '');
|
|
278
|
-
expectVal('local-date-time', '');
|
|
279
|
-
expectVal('number-key', 'NaN');
|
|
280
|
-
expectVal('json-key', '');
|
|
281
|
-
const input = canvasElement.querySelector('input');
|
|
282
|
-
input.value = 'ABC';
|
|
283
|
-
byText('set to all').click();
|
|
284
|
-
await sleep(10);
|
|
285
|
-
expectVal('text-key', 'ABC');
|
|
286
|
-
expectVal('date-key', '');
|
|
287
|
-
expectVal('time-key', '');
|
|
288
|
-
expectVal('local-date-time', '');
|
|
289
|
-
expectVal('number-key', 'NaN');
|
|
290
|
-
expectVal('json-key', '');
|
|
291
|
-
input.value = '22';
|
|
292
|
-
byText('set to all').click();
|
|
293
|
-
await sleep(10);
|
|
294
|
-
expectVal('text-key', '22');
|
|
295
|
-
expectVal('date-key', '');
|
|
296
|
-
expectVal('time-key', '');
|
|
297
|
-
expectVal('local-date-time', '');
|
|
298
|
-
expectVal('number-key', '22');
|
|
299
|
-
expectVal('json-key', '22');
|
|
300
|
-
input.value = '2024';
|
|
301
|
-
byText('set to all').click();
|
|
302
|
-
await sleep(10);
|
|
303
|
-
expectVal('text-key', '2024');
|
|
304
|
-
expectVal('date-key', '2024-01-01');
|
|
305
|
-
expectVal('time-key', '');
|
|
306
|
-
expectVal('local-date-time', '');
|
|
307
|
-
expectVal('number-key', '2024');
|
|
308
|
-
expectVal('json-key', '2024');
|
|
309
|
-
input.value = '2024-04-20T03:58:42.131Z';
|
|
310
|
-
byText('set to all').click();
|
|
311
|
-
await sleep(10);
|
|
312
|
-
expectVal('text-key', '2024-04-20T03:58:42.131Z');
|
|
313
|
-
expectVal('date-key', '2024-04-20');
|
|
314
|
-
expectVal('time-key', '');
|
|
315
|
-
expectVal('local-date-time', '');
|
|
316
|
-
expectVal('number-key', 'NaN');
|
|
317
|
-
expectVal('json-key', '');
|
|
318
|
-
const nowStr = new Date(Date.now()).toISOString();
|
|
319
|
-
input.value = nowStr;
|
|
320
|
-
byText('set to all').click();
|
|
321
|
-
await sleep(10);
|
|
322
|
-
expectVal('text-key', nowStr);
|
|
323
|
-
expectVal('date-key', nowStr.substring(0, 10));
|
|
324
|
-
expectVal('time-key', '');
|
|
325
|
-
expectVal('local-date-time', '');
|
|
326
|
-
expectVal('number-key', 'NaN');
|
|
327
|
-
expectVal('json-key', '');
|
|
328
|
-
input.value = '23:25';
|
|
329
|
-
byText('set to all').click();
|
|
330
|
-
await sleep(10);
|
|
331
|
-
expectVal('text-key', '23:25');
|
|
332
|
-
expectVal('date-key', '');
|
|
333
|
-
expectVal('time-key', '23:25');
|
|
334
|
-
expectVal('local-date-time', '');
|
|
335
|
-
expectVal('number-key', 'NaN');
|
|
336
|
-
expectVal('json-key', '');
|
|
337
|
-
input.value = '1977-04-01T14:00:30';
|
|
338
|
-
byText('set to all').click();
|
|
339
|
-
await sleep(10);
|
|
340
|
-
expectVal('text-key', '1977-04-01T14:00:30');
|
|
341
|
-
expectVal('date-key', '1977-04-01');
|
|
342
|
-
expectVal('time-key', '');
|
|
343
|
-
expectVal('local-date-time', '1977-04-01T14:00:30');
|
|
344
|
-
expectVal('number-key', 'NaN');
|
|
345
|
-
expectVal('json-key', '');
|
|
346
|
-
input.value = '1.23456e+5';
|
|
347
|
-
byText('set to all').click();
|
|
348
|
-
await sleep(10);
|
|
349
|
-
expectVal('text-key', '1.23456e+5');
|
|
350
|
-
expectVal('date-key', '');
|
|
351
|
-
expectVal('time-key', '');
|
|
352
|
-
expectVal('local-date-time', '');
|
|
353
|
-
expectVal('number-key', '123456');
|
|
354
|
-
expectVal('json-key', '123456');
|
|
355
|
-
input.value = '0001'; // as YYYY for year
|
|
356
|
-
byText('set to all').click();
|
|
357
|
-
await sleep(10);
|
|
358
|
-
expectVal('text-key', '0001');
|
|
359
|
-
expectVal('date-key', '0001-01-01');
|
|
360
|
-
expectVal('time-key', '');
|
|
361
|
-
expectVal('local-date-time', '');
|
|
362
|
-
expectVal('number-key', '1');
|
|
363
|
-
expectVal('json-key', '');
|
|
364
|
-
input.value = '001'; // as 2001 year
|
|
365
|
-
byText('set to all').click();
|
|
366
|
-
await sleep(10);
|
|
367
|
-
expectVal('text-key', '001');
|
|
368
|
-
expectVal('date-key', '2001-01-01');
|
|
369
|
-
expectVal('time-key', '');
|
|
370
|
-
expectVal('local-date-time', '');
|
|
371
|
-
expectVal('number-key', '1');
|
|
372
|
-
expectVal('json-key', '');
|
|
373
|
-
input.value = '000'; // as 2001 year
|
|
374
|
-
byText('set to all').click();
|
|
375
|
-
await sleep(10);
|
|
376
|
-
expectVal('text-key', '000');
|
|
377
|
-
expectVal('date-key', '2000-01-01');
|
|
378
|
-
expectVal('time-key', '');
|
|
379
|
-
expectVal('local-date-time', '');
|
|
380
|
-
expectVal('number-key', '0');
|
|
381
|
-
expectVal('json-key', '');
|
|
382
|
-
input.value = '0'; // as 2000 year
|
|
383
|
-
byText('set to all').click();
|
|
384
|
-
await sleep(10);
|
|
385
|
-
expectVal('text-key', '0');
|
|
386
|
-
expectVal('date-key', '2000-01-01');
|
|
387
|
-
expectVal('time-key', '');
|
|
388
|
-
expectVal('local-date-time', '');
|
|
389
|
-
expectVal('number-key', '0');
|
|
390
|
-
expectVal('json-key', '0');
|
|
391
|
-
input.value = '"abc"';
|
|
392
|
-
byText('set to all').click();
|
|
393
|
-
await sleep(10);
|
|
394
|
-
expectVal('text-key', '"abc"');
|
|
395
|
-
expectVal('date-key', '');
|
|
396
|
-
expectVal('time-key', '');
|
|
397
|
-
expectVal('local-date-time', '');
|
|
398
|
-
expectVal('number-key', 'NaN');
|
|
399
|
-
expectVal('json-key', 'abc');
|
|
400
|
-
input.value = '12.345';
|
|
401
|
-
byText('set to all').click();
|
|
402
|
-
await sleep(10);
|
|
403
|
-
expectVal('text-key', '12.345');
|
|
404
|
-
expectVal('date-key', '');
|
|
405
|
-
expectVal('time-key', '');
|
|
406
|
-
expectVal('local-date-time', '');
|
|
407
|
-
expectVal('number-key', '12.345');
|
|
408
|
-
expectVal('json-key', '12.345');
|
|
409
|
-
input.value = '{"a":1,"b":"B"}';
|
|
410
|
-
byText('set to all').click();
|
|
411
|
-
await sleep(10);
|
|
412
|
-
expectVal('text-key', '{"a":1,"b":"B"}');
|
|
413
|
-
expectVal('date-key', '');
|
|
414
|
-
expectVal('time-key', '');
|
|
415
|
-
expectVal('local-date-time', '');
|
|
416
|
-
expectVal('number-key', 'NaN');
|
|
417
|
-
expectVal('json-key', '\\na : 1b : B');
|
|
418
|
-
}
|
|
419
|
-
}`,...d.parameters?.docs?.source}}};const f=["Demo","AlwaysOverride","FromStorageWithDefault","TypeAttribute"];export{k as AlwaysOverride,u as Demo,m as FromStorageWithDefault,d as TypeAttribute,f as __namedExportsOrder,E as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./index-D-8MO0q_.js";const{global:O}=__STORYBOOK_MODULE_GLOBAL__,{makeDecorator:E,addons:_}=__STORYBOOK_MODULE_PREVIEW_API__,{STORY_CHANGED:l,SELECT_STORY:L}=__STORYBOOK_MODULE_CORE_EVENTS__;var c="links",{document:i,HTMLElement:m}=O,v=e=>_.getChannel().emit(L,e),o=e=>{let{target:t}=e;if(!(t instanceof m))return;let s=t,{sbKind:a,sbStory:r}=s.dataset;(a||r)&&(e.preventDefault(),v({kind:a,story:r}))},n=!1,d=()=>{n||(n=!0,i.addEventListener("click",o))},k=()=>{n&&(n=!1,i.removeEventListener("click",o))},R=E({name:"withLinks",parameterName:c,wrapper:(e,t)=>(d(),_.getChannel().once(l,k),e(t))}),T=[R];export{T as decorators};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as S}from"./tiny-invariant-BxWVcicq.js";const{useEffect:T}=__STORYBOOK_MODULE_PREVIEW_API__,{global:d}=__STORYBOOK_MODULE_GLOBAL__;function Y(){let e=d.document.documentElement,t=Math.max(e.scrollHeight,e.offsetHeight);return{width:Math.max(e.scrollWidth,e.offsetWidth),height:t}}function j(){let e=d.document.createElement("canvas");e.id="storybook-addon-measure";let t=e.getContext("2d");S(t!=null);let{width:o,height:l}=Y();return A(e,t,{width:o,height:l}),e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.zIndex="2147483647",e.style.pointerEvents="none",d.document.body.appendChild(e),{canvas:e,context:t,width:o,height:l}}function A(e,t,{width:o,height:l}){e.style.width=`${o}px`,e.style.height=`${l}px`;let i=d.window.devicePixelRatio;e.width=Math.floor(o*i),e.height=Math.floor(l*i),t.scale(i,i)}var h={};function K(){h.canvas||(h=j())}function H(){h.context&&h.context.clearRect(0,0,h.width??0,h.height??0)}function G(e){H(),e(h.context)}function U(){S(h.canvas,"Canvas should exist in the state."),S(h.context,"Context should exist in the state."),A(h.canvas,h.context,{width:0,height:0});let{width:e,height:t}=Y();A(h.canvas,h.context,{width:e,height:t}),h.width=e,h.height=t}function V(){h.canvas&&(H(),h.canvas.parentNode?.removeChild(h.canvas),h={})}var w={margin:"#f6b26b",border:"#ffe599",padding:"#93c47d",content:"#6fa8dc",text:"#232020"},c=6;function W(e,{x:t,y:o,w:l,h:i,r:n}){t=t-l/2,o=o-i/2,l<2*n&&(n=l/2),i<2*n&&(n=i/2),e.beginPath(),e.moveTo(t+n,o),e.arcTo(t+l,o,t+l,o+i,n),e.arcTo(t+l,o+i,t,o+i,n),e.arcTo(t,o+i,t,o,n),e.arcTo(t,o,t+l,o,n),e.closePath()}function Z(e,{padding:t,border:o,width:l,height:i,top:n,left:r}){let f=l-o.left-o.right-t.left-t.right,a=i-t.top-t.bottom-o.top-o.bottom,s=r+o.left+t.left,u=n+o.top+t.top;return e==="top"?s+=f/2:e==="right"?(s+=f,u+=a/2):e==="bottom"?(s+=f/2,u+=a):e==="left"?u+=a/2:e==="center"&&(s+=f/2,u+=a/2),{x:s,y:u}}function J(e,t,{margin:o,border:l,padding:i},n,r){let f=m=>0,a=0,s=0,u=r?1:.5,g=r?n*2:0;return e==="padding"?f=m=>i[m]*u+g:e==="border"?f=m=>i[m]+l[m]*u+g:e==="margin"&&(f=m=>i[m]+l[m]+o[m]*u+g),t==="top"?s=-f("top"):t==="right"?a=f("right"):t==="bottom"?s=f("bottom"):t==="left"&&(a=-f("left")),{offsetX:a,offsetY:s}}function Q(e,t){return Math.abs(e.x-t.x)<Math.abs(e.w+t.w)/2&&Math.abs(e.y-t.y)<Math.abs(e.h+t.h)/2}function x(e,t,o){return e==="top"?t.y=o.y-o.h-c:e==="right"?t.x=o.x+o.w/2+c+t.w/2:e==="bottom"?t.y=o.y+o.h+c:e==="left"&&(t.x=o.x-o.w/2-c-t.w/2),{x:t.x,y:t.y}}function C(e,t,{x:o,y:l,w:i,h:n},r){return W(e,{x:o,y:l,w:i,h:n,r:3}),e.fillStyle=`${w[t]}dd`,e.fill(),e.strokeStyle=w[t],e.stroke(),e.fillStyle=w.text,e.fillText(r,o,l),W(e,{x:o,y:l,w:i,h:n,r:3}),e.fillStyle=`${w[t]}dd`,e.fill(),e.strokeStyle=w[t],e.stroke(),e.fillStyle=w.text,e.fillText(r,o,l),{x:o,y:l,w:i,h:n}}function X(e,t){e.font="600 12px monospace",e.textBaseline="middle",e.textAlign="center";let o=e.measureText(t),l=o.actualBoundingBoxAscent+o.actualBoundingBoxDescent,i=o.width+c*2,n=l+c*2;return{w:i,h:n}}function tt(e,t,{type:o,position:l="center",text:i},n,r=!1){let{x:f,y:a}=Z(l,t),{offsetX:s,offsetY:u}=J(o,l,t,c+1,r);f+=s,a+=u;let{w:g,h:m}=X(e,i);if(n&&Q({x:f,y:a,w:g,h:m},n)){let M=x(l,{x:f,y:a,w:g,h:m},n);f=M.x,a=M.y}return C(e,o,{x:f,y:a,w:g,h:m},i)}function et(e,{w:t,h:o}){let l=t*.5+c,i=o*.5+c;return{offsetX:(e.x==="left"?-1:1)*l,offsetY:(e.y==="top"?-1:1)*i}}function ot(e,t,{type:o,text:l}){let{floatingAlignment:i,extremities:n}=t,r=n[i.x],f=n[i.y],{w:a,h:s}=X(e,l),{offsetX:u,offsetY:g}=et(i,{w:a,h:s});return r+=u,f+=g,C(e,o,{x:r,y:f,w:a,h:s},l)}function E(e,t,o,l){let i=[];o.forEach((n,r)=>{let f=l&&n.position==="center"?ot(e,t,n):tt(e,t,n,i[r-1],l);i[r]=f})}function it(e,t,o,l){let i=o.reduce((n,r)=>(Object.prototype.hasOwnProperty.call(n,r.position)||(n[r.position]=[]),n[r.position]?.push(r),n),{});i.top&&E(e,t,i.top,l),i.right&&E(e,t,i.right,l),i.bottom&&E(e,t,i.bottom,l),i.left&&E(e,t,i.left,l),i.center&&E(e,t,i.center,l)}var L={margin:"#f6b26ba8",border:"#ffe599a8",padding:"#93c47d8c",content:"#6fa8dca8"},B=30;function p(e){return parseInt(e.replace("px",""),10)}function b(e){return Number.isInteger(e)?e:e.toFixed(2)}function P(e){return e.filter(t=>t.text!==0&&t.text!=="0")}function lt(e){let t={top:d.window.scrollY,bottom:d.window.scrollY+d.window.innerHeight,left:d.window.scrollX,right:d.window.scrollX+d.window.innerWidth},o={top:Math.abs(t.top-e.top),bottom:Math.abs(t.bottom-e.bottom),left:Math.abs(t.left-e.left),right:Math.abs(t.right-e.right)};return{x:o.left>o.right?"left":"right",y:o.top>o.bottom?"top":"bottom"}}function nt(e){let t=d.getComputedStyle(e),{top:o,left:l,right:i,bottom:n,width:r,height:f}=e.getBoundingClientRect(),{marginTop:a,marginBottom:s,marginLeft:u,marginRight:g,paddingTop:m,paddingBottom:M,paddingLeft:k,paddingRight:F,borderBottomWidth:D,borderTopWidth:I,borderLeftWidth:$,borderRightWidth:N}=t;o=o+d.window.scrollY,l=l+d.window.scrollX,n=n+d.window.scrollY,i=i+d.window.scrollX;let y={top:p(a),bottom:p(s),left:p(u),right:p(g)},q={top:p(m),bottom:p(M),left:p(k),right:p(F)},z={top:p(I),bottom:p(D),left:p($),right:p(N)},_={top:o-y.top,bottom:n+y.bottom,left:l-y.left,right:i+y.right};return{margin:y,padding:q,border:z,top:o,left:l,bottom:n,right:i,width:r,height:f,extremities:_,floatingAlignment:lt(_)}}function ft(e,{margin:t,width:o,height:l,top:i,left:n,bottom:r,right:f}){let a=l+t.bottom+t.top;e.fillStyle=L.margin,e.fillRect(n,i-t.top,o,t.top),e.fillRect(f,i-t.top,t.right,a),e.fillRect(n,r,o,t.bottom),e.fillRect(n-t.left,i-t.top,t.left,a);let s=[{type:"margin",text:b(t.top),position:"top"},{type:"margin",text:b(t.right),position:"right"},{type:"margin",text:b(t.bottom),position:"bottom"},{type:"margin",text:b(t.left),position:"left"}];return P(s)}function rt(e,{padding:t,border:o,width:l,height:i,top:n,left:r,bottom:f,right:a}){let s=l-o.left-o.right,u=i-t.top-t.bottom-o.top-o.bottom;e.fillStyle=L.padding,e.fillRect(r+o.left,n+o.top,s,t.top),e.fillRect(a-t.right-o.right,n+t.top+o.top,t.right,u),e.fillRect(r+o.left,f-t.bottom-o.bottom,s,t.bottom),e.fillRect(r+o.left,n+t.top+o.top,t.left,u);let g=[{type:"padding",text:t.top,position:"top"},{type:"padding",text:t.right,position:"right"},{type:"padding",text:t.bottom,position:"bottom"},{type:"padding",text:t.left,position:"left"}];return P(g)}function at(e,{border:t,width:o,height:l,top:i,left:n,bottom:r,right:f}){let a=l-t.top-t.bottom;e.fillStyle=L.border,e.fillRect(n,i,o,t.top),e.fillRect(n,r-t.bottom,o,t.bottom),e.fillRect(n,i+t.top,t.left,a),e.fillRect(f-t.right,i+t.top,t.right,a);let s=[{type:"border",text:t.top,position:"top"},{type:"border",text:t.right,position:"right"},{type:"border",text:t.bottom,position:"bottom"},{type:"border",text:t.left,position:"left"}];return P(s)}function st(e,{padding:t,border:o,width:l,height:i,top:n,left:r}){let f=l-o.left-o.right-t.left-t.right,a=i-t.top-t.bottom-o.top-o.bottom;return e.fillStyle=L.content,e.fillRect(r+o.left+t.left,n+o.top+t.top,f,a),[{type:"content",position:"center",text:`${b(f)} x ${b(a)}`}]}function ht(e){return t=>{if(e&&t){let o=nt(e),l=ft(t,o),i=rt(t,o),n=at(t,o),r=st(t,o),f=o.width<=B*3||o.height<=B;it(t,o,[...r,...i,...n,...l],f)}}}function ut(e){G(ht(e))}var dt=(e,t)=>{let o=d.document.elementFromPoint(e,t),l=i=>{if(i&&i.shadowRoot){let n=i.shadowRoot.elementFromPoint(e,t);return i.isEqualNode(n)?i:n.shadowRoot?l(n):n}return i};return l(o)||o},O,v={x:0,y:0};function R(e,t){O=dt(e,t),ut(O)}var mt=(e,t)=>{let{measureEnabled:o}=t.globals;return T(()=>{let l=i=>{window.requestAnimationFrame(()=>{i.stopPropagation(),v.x=i.clientX,v.y=i.clientY})};return document.addEventListener("pointermove",l),()=>{document.removeEventListener("pointermove",l)}},[]),T(()=>{let l=n=>{window.requestAnimationFrame(()=>{n.stopPropagation(),R(n.clientX,n.clientY)})},i=()=>{window.requestAnimationFrame(()=>{U()})};return t.viewMode==="story"&&o&&(document.addEventListener("pointerover",l),K(),window.addEventListener("resize",i),R(v.x,v.y)),()=>{window.removeEventListener("resize",i),V()}},[o,t.viewMode]),e()},gt="measureEnabled",ct=[mt],wt={[gt]:!1};export{ct as decorators,wt as initialGlobals};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t={viewport:"reset",viewportRotated:!1};export{t as initialGlobals};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import{d as _}from"./index-DrFu-skq.js";const{useMemo:b,useEffect:y}=__STORYBOOK_MODULE_PREVIEW_API__,{global:E}=__STORYBOOK_MODULE_GLOBAL__,{logger:M}=__STORYBOOK_MODULE_CLIENT_LOGGER__;var g="backgrounds",{document:l,window:h}=E,B=()=>h.matchMedia("(prefers-reduced-motion: reduce)").matches,x=(r,e=[],d)=>{if(r==="transparent")return"transparent";if(e.find(a=>a.value===r))return r;let n=e.find(a=>a.name===d);if(n)return n.value;if(d){let a=e.map(o=>o.name).join(", ");M.warn(_`
|
|
2
|
-
Backgrounds Addon: could not find the default color "${d}".
|
|
3
|
-
These are the available colors for your story based on your configuration:
|
|
4
|
-
${a}.
|
|
5
|
-
`)}return"transparent"},v=r=>{(Array.isArray(r)?r:[r]).forEach(O)},O=r=>{let e=l.getElementById(r);e&&e.parentElement?.removeChild(e)},S=(r,e)=>{let d=l.getElementById(r);if(d)d.innerHTML!==e&&(d.innerHTML=e);else{let n=l.createElement("style");n.setAttribute("id",r),n.innerHTML=e,l.head.appendChild(n)}},w=(r,e,d)=>{let n=l.getElementById(r);if(n)n.innerHTML!==e&&(n.innerHTML=e);else{let a=l.createElement("style");a.setAttribute("id",r),a.innerHTML=e;let o=`addon-backgrounds-grid${d?`-docs-${d}`:""}`,t=l.getElementById(o);t?t.parentElement?.insertBefore(a,t):l.head.appendChild(a)}},A=(r,e)=>{let{globals:d,parameters:n}=e,a=d[g]?.value,o=n[g],t=b(()=>o.disable?"transparent":x(a,o.values,o.default),[o,a]),i=b(()=>t&&t!=="transparent",[t]),s=e.viewMode==="docs"?`#anchor--${e.id} .docs-story`:".sb-show-main",p=b(()=>`
|
|
6
|
-
${s} {
|
|
7
|
-
background: ${t} !important;
|
|
8
|
-
${B()?"":"transition: background-color 0.3s;"}
|
|
9
|
-
}
|
|
10
|
-
`,[t,s]);return y(()=>{let u=e.viewMode==="docs"?`addon-backgrounds-docs-${e.id}`:"addon-backgrounds-color";if(!i){v(u);return}w(u,p,e.viewMode==="docs"?e.id:null)},[i,p,e]),r()},L=(r,e)=>{let{globals:d,parameters:n}=e,a=n[g].grid,o=d[g]?.grid===!0&&a.disable!==!0,{cellAmount:t,cellSize:i,opacity:s}=a,p=e.viewMode==="docs",u=n.layout===void 0||n.layout==="padded"?16:0,c=a.offsetX??(p?20:u),m=a.offsetY??(p?20:u),$=b(()=>{let f=e.viewMode==="docs"?`#anchor--${e.id} .docs-story`:".sb-show-main",k=[`${i*t}px ${i*t}px`,`${i*t}px ${i*t}px`,`${i}px ${i}px`,`${i}px ${i}px`].join(", ");return`
|
|
11
|
-
${f} {
|
|
12
|
-
background-size: ${k} !important;
|
|
13
|
-
background-position: ${c}px ${m}px, ${c}px ${m}px, ${c}px ${m}px, ${c}px ${m}px !important;
|
|
14
|
-
background-blend-mode: difference !important;
|
|
15
|
-
background-image: linear-gradient(rgba(130, 130, 130, ${s}) 1px, transparent 1px),
|
|
16
|
-
linear-gradient(90deg, rgba(130, 130, 130, ${s}) 1px, transparent 1px),
|
|
17
|
-
linear-gradient(rgba(130, 130, 130, ${s/2}) 1px, transparent 1px),
|
|
18
|
-
linear-gradient(90deg, rgba(130, 130, 130, ${s/2}) 1px, transparent 1px) !important;
|
|
19
|
-
}
|
|
20
|
-
`},[i]);return y(()=>{let f=e.viewMode==="docs"?`addon-backgrounds-grid-docs-${e.id}`:"addon-backgrounds-grid";if(!o){v(f);return}S(f,$)},[o,$,e]),r()},C=[L,A],I={[g]:{grid:{cellSize:20,opacity:.5,cellAmount:5},values:[{name:"light",value:"#F8F8F8"},{name:"dark",value:"#333333"}]}},G={[g]:null};export{C as decorators,G as initialGlobals,I as parameters};
|