@epa-wg/custom-element-dist 0.0.25 → 0.0.27
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 +1 -5
- package/.storybook/main.ts +1 -3
- package/.storybook/preview-head.html +8 -0
- package/.storybook/preview.ts +13 -5
- package/README.md +4 -4
- package/bin/postinstall.sh +3 -2
- package/bin/vitest/vitest-browser-importmaps.mjs +20 -0
- package/coverage/coverage-final.json +14 -11
- package/coverage/index.html +51 -36
- 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 +596 -386
- package/coverage/src/custom-element/demo/coverage.svg +10 -0
- package/coverage/src/custom-element/demo/index.html +116 -0
- package/coverage/src/custom-element/demo/z.js/coverage.svg +10 -0
- package/coverage/src/custom-element/demo/z.js.html +112 -0
- package/coverage/src/custom-element/http-request.js.html +12 -12
- package/coverage/src/custom-element/index.html +33 -18
- package/coverage/src/custom-element/local-storage.js.html +56 -41
- package/coverage/src/custom-element/location-element.js.html +4 -4
- package/coverage/src/custom-element/module-url.js/coverage.svg +10 -0
- package/coverage/src/custom-element/module-url.js.html +187 -0
- package/coverage/src/index.html +1 -1
- package/coverage/src/mocks/coverage.svg +1 -1
- package/coverage/src/mocks/handlers.ts/coverage.svg +1 -1
- package/coverage/src/mocks/handlers.ts.html +36 -12
- package/coverage/src/mocks/index.html +19 -19
- package/coverage/src/stories/attributes.test.stories.ts.html +9 -15
- 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 +15 -9
- package/coverage/src/stories/external-template.test.stories.ts.html +27 -18
- 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 +48 -33
- package/coverage/src/stories/local-storage.test.stories.ts/coverage.svg +1 -1
- package/coverage/src/stories/local-storage.test.stories.ts.html +87 -63
- package/coverage/src/stories/location-element.test.stories.ts.html +1 -1
- package/coverage/src/stories/module-url.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/module-url.test.stories.ts.html +634 -0
- package/coverage/src/stories/set-url.test.stories.ts.html +1 -1
- package/coverage/src/stories/slice-events.test.stories.ts.html +1 -1
- 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 +98 -20
- package/coverage/src/sum.ts.html +1 -1
- package/dist/confused.svg +1 -0
- package/dist/custom-element-BMMsP1Dy.js +533 -0
- package/dist/custom-element-CPSk7s0j.cjs +87 -0
- package/dist/custom-element-bundle.cjs +1 -1
- package/dist/custom-element-bundle.js +28 -25
- package/dist/demo/a.html +60 -0
- package/dist/demo/a.svg +27 -0
- package/dist/demo/b.html +13 -0
- package/dist/demo/confused.svg +38 -0
- package/dist/demo/data-slices.html +216 -0
- package/dist/demo/dce-social-preview.png +0 -0
- package/dist/demo/demo.css +25 -0
- package/dist/demo/dom-merge.html +123 -0
- package/dist/demo/embed-1.html +2 -0
- package/dist/demo/external-template.html +239 -0
- package/dist/demo/form.html +239 -0
- package/dist/demo/hex-grid-dce.html +183 -0
- package/dist/demo/hex-grid-transform.png +0 -0
- package/dist/demo/hex-grid.html +66 -0
- package/dist/demo/html-template.html +126 -0
- package/dist/demo/html-template.xhtml +45 -0
- package/dist/demo/html-template.xml +45 -0
- package/dist/demo/http-request.html +143 -0
- package/dist/demo/lib-dir/Smiley.svg +24 -0
- package/dist/demo/lib-dir/embed-lib.html +34 -0
- package/dist/demo/local-storage.html +218 -0
- package/dist/demo/location-element.html +168 -0
- package/dist/demo/logo.png +0 -0
- package/dist/demo/module-url.html +215 -0
- package/dist/demo/npm-versions-demo.html +118 -0
- package/dist/demo/npm-versions.html +94 -0
- package/dist/demo/parameters.html +70 -0
- package/dist/demo/s.xml +3 -0
- package/dist/demo/s.xslt +56 -0
- package/dist/demo/s1.xslt +60 -0
- package/dist/demo/scoped-css.html +169 -0
- package/dist/demo/set-url.html +141 -0
- package/dist/demo/ss.html +57 -0
- package/dist/demo/table.xml +25 -0
- package/dist/demo/table.xsl +293 -0
- package/dist/demo/template.xsl +46 -0
- package/dist/demo/tree.xml +25 -0
- package/dist/demo/tree.xsl +33 -0
- package/dist/demo/wc-square.svg +1 -0
- package/dist/demo/xhtml-template.xhtml +45 -0
- package/dist/demo/z.html +33 -0
- package/dist/demo/z.js +9 -0
- package/dist/demo/z.xml +60 -0
- package/dist/demo/z1.html +34 -0
- package/dist/embed-1.html +1 -2
- 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 +95 -93
- package/public/confused.svg +1 -0
- package/public/demo/a.html +60 -0
- package/public/demo/a.svg +27 -0
- package/public/demo/b.html +13 -0
- package/public/demo/confused.svg +38 -0
- package/public/demo/data-slices.html +216 -0
- package/public/demo/dce-social-preview.png +0 -0
- package/public/demo/demo.css +25 -0
- package/public/demo/dom-merge.html +123 -0
- package/public/demo/embed-1.html +2 -0
- package/public/demo/external-template.html +239 -0
- package/public/demo/form.html +239 -0
- package/public/demo/hex-grid-dce.html +183 -0
- package/public/demo/hex-grid-transform.png +0 -0
- package/public/demo/hex-grid.html +66 -0
- package/public/demo/html-template.html +126 -0
- package/public/demo/html-template.xhtml +45 -0
- package/public/demo/html-template.xml +45 -0
- package/public/demo/http-request.html +143 -0
- package/public/demo/lib-dir/Smiley.svg +24 -0
- package/public/demo/lib-dir/embed-lib.html +34 -0
- package/public/demo/local-storage.html +218 -0
- package/public/demo/location-element.html +168 -0
- package/public/demo/logo.png +0 -0
- package/public/demo/module-url.html +215 -0
- package/public/demo/npm-versions-demo.html +118 -0
- package/public/demo/npm-versions.html +94 -0
- package/public/demo/parameters.html +70 -0
- package/public/demo/s.xml +3 -0
- package/public/demo/s.xslt +56 -0
- package/public/demo/s1.xslt +60 -0
- package/public/demo/scoped-css.html +169 -0
- package/public/demo/set-url.html +141 -0
- package/public/demo/ss.html +57 -0
- package/public/demo/table.xml +25 -0
- package/public/demo/table.xsl +293 -0
- package/public/demo/template.xsl +46 -0
- package/public/demo/tree.xml +25 -0
- package/public/demo/tree.xsl +33 -0
- package/public/demo/wc-square.svg +1 -0
- package/public/demo/xhtml-template.xhtml +45 -0
- package/public/demo/z.html +33 -0
- package/public/demo/z.js +9 -0
- package/public/demo/z.xml +60 -0
- package/public/demo/z1.html +34 -0
- package/public/embed-1.html +1 -2
- package/public/mockServiceWorker.js +1 -1
- package/src/custom-element/custom-element.js +103 -33
- package/src/custom-element/demo/a.svg +27 -0
- package/src/custom-element/demo/confused.svg +1 -0
- package/src/custom-element/demo/demo.css +11 -8
- package/src/custom-element/demo/embed-1.html +1 -2
- package/src/custom-element/demo/external-template.html +122 -62
- package/src/custom-element/demo/lib-dir/Smiley.svg +24 -0
- package/src/custom-element/demo/lib-dir/embed-lib.html +34 -0
- package/src/custom-element/demo/module-url.html +215 -0
- package/src/custom-element/demo/npm-versions-demo.html +118 -0
- package/src/custom-element/demo/npm-versions.html +94 -0
- package/src/custom-element/demo/s.xml +3 -36
- package/src/custom-element/demo/s.xslt +55 -96
- package/src/custom-element/demo/set-url.html +1 -1
- package/src/custom-element/demo/z.html +32 -61
- package/src/custom-element/demo/z.js +9 -0
- package/src/custom-element/demo/z1.html +34 -0
- package/src/custom-element/ide/customData-dce.json +215 -181
- package/src/custom-element/ide/web-types-dce.json +184 -159
- package/src/custom-element/ide/web-types-xsl.json +1 -1
- package/src/custom-element/index.html +21 -3
- package/src/custom-element/local-storage.js +19 -14
- package/src/custom-element/module-url.js +34 -0
- package/src/mocks/handlers.ts +10 -1
- package/src/mocks/versions.mock.ts +786 -0
- package/src/stories/__screenshots__/http-request.test.ts/http-request-url-change-1.png +0 -0
- package/src/stories/attributes.test.stories.ts +3 -5
- package/src/stories/dom-merge.test.stories.ts +9 -7
- package/src/stories/external-template.test.stories.ts +13 -10
- package/src/stories/local-storage.test.stories.ts +61 -53
- package/src/stories/module-url.test.stories.ts +183 -0
- package/src/stories/version-select.test.stories.ts +38 -12
- package/src/sum.test.ts +5 -5
- package/src/sum.ts +3 -3
- package/storybook-static/assets/Color-KGDBMAHA-CJo5gHY3.js +1 -0
- package/storybook-static/assets/{Configure-D0qG3gR9.js → Configure-DdXbGKhY.js} +2 -2
- package/storybook-static/assets/DocsRenderer-PKQXORMH-DLnpL5hE.js +2 -0
- package/storybook-static/assets/{attributes.test.stories-W34tZdUt.js → attributes.test.stories-Bt5V18qO.js} +10 -12
- package/storybook-static/assets/{css.test.stories-BZFYx1TQ.js → css.test.stories-CGYy2daE.js} +1 -1
- package/storybook-static/assets/custom-element-D8hcDZHh.js +265 -0
- package/storybook-static/assets/{dom-merge.test.stories-S-7U5N3h.js → dom-merge.test.stories-XlsZ0UvX.js} +22 -20
- package/storybook-static/assets/{entry-preview-DrgzXgwT.js → entry-preview-BKQ8UCxI.js} +1 -1
- package/storybook-static/assets/{entry-preview-docs-Bxv0qQWs.js → entry-preview-docs-BMKNVQXA.js} +2 -2
- package/storybook-static/assets/{external-template.test.stories-QIO3lAFz.js → external-template.test.stories-Bt_Pflu8.js} +23 -21
- package/storybook-static/assets/{form.test.stories-ClYhj9F1.js → form.test.stories-B0NoI8wm.js} +1 -1
- package/storybook-static/assets/handlers-B5969HUu.js +467 -0
- package/storybook-static/assets/http-request.stories-B2skuTFV.js +281 -0
- package/storybook-static/assets/iframe-Dfrt81rk.js +2 -0
- package/storybook-static/assets/index-Ay195x2L.js +605 -0
- package/storybook-static/assets/index-C3ChPTMh.js +1 -0
- package/storybook-static/assets/index-C7lvoJNv.js +1 -0
- package/storybook-static/assets/index-C8k3Z-3Y.js +28 -0
- package/storybook-static/assets/{index-DXimoRZY.js → index-D-8MO0q_.js} +1 -1
- package/storybook-static/assets/index-DGdNYaqV.js +8 -0
- package/storybook-static/assets/index-Gpdhz4ab.js +1 -0
- package/storybook-static/assets/lit-element-DzhCn-8W.js +19 -0
- package/storybook-static/assets/local-storage.test.stories-DfY6feqG.js +420 -0
- package/storybook-static/assets/{location-element.test.stories-DvH1TWK4.js → location-element.test.stories-944AotIJ.js} +1 -1
- package/storybook-static/assets/module-url.test.stories-DSKcwApl.js +208 -0
- package/storybook-static/assets/{preview-BKCN0mOr.js → preview-0Jj89qip.js} +1 -1
- package/storybook-static/assets/preview-AJR7rVPD.js +52 -0
- package/storybook-static/assets/{preview-TCN6m6T-.js → preview-BJPLiuSt.js} +1 -1
- package/storybook-static/assets/{preview-BDY5ThwJ.js → preview-BMWqy4Bi.js} +1 -1
- package/storybook-static/assets/preview-BnWGZYux.js +1 -0
- package/storybook-static/assets/preview-CadgX-4y.js +2 -0
- package/storybook-static/assets/{preview-BAz7FMXc.js → preview-DB9FwMii.js} +1 -1
- package/storybook-static/assets/preview-Djh1_Tal.js +20 -0
- package/storybook-static/assets/{set-url.test.stories-GlJOh31I.js → set-url.test.stories-DjLHKkEh.js} +1 -1
- package/storybook-static/assets/{slice-events.test.stories-VoNjuPCX.js → slice-events.test.stories-8I_BrHd6.js} +1 -1
- package/storybook-static/assets/{slots.test.stories-Da2j9YuO.js → slots.test.stories-CvZz4jyP.js} +1 -1
- package/storybook-static/assets/version-select.test.stories-DSxmJylI.js +109 -0
- package/storybook-static/confused.svg +1 -0
- package/storybook-static/demo/a.html +60 -0
- package/storybook-static/demo/a.svg +27 -0
- package/storybook-static/demo/b.html +13 -0
- package/storybook-static/demo/confused.svg +38 -0
- package/storybook-static/demo/data-slices.html +216 -0
- package/storybook-static/demo/dce-social-preview.png +0 -0
- package/storybook-static/demo/demo.css +25 -0
- package/storybook-static/demo/dom-merge.html +123 -0
- package/storybook-static/demo/embed-1.html +2 -0
- package/storybook-static/demo/external-template.html +239 -0
- package/storybook-static/demo/form.html +239 -0
- package/storybook-static/demo/hex-grid-dce.html +183 -0
- package/storybook-static/demo/hex-grid-transform.png +0 -0
- package/storybook-static/demo/hex-grid.html +66 -0
- package/storybook-static/demo/html-template.html +126 -0
- package/storybook-static/demo/html-template.xhtml +45 -0
- package/storybook-static/demo/html-template.xml +45 -0
- package/storybook-static/demo/http-request.html +143 -0
- package/storybook-static/demo/lib-dir/Smiley.svg +24 -0
- package/storybook-static/demo/lib-dir/embed-lib.html +34 -0
- package/storybook-static/demo/local-storage.html +218 -0
- package/storybook-static/demo/location-element.html +168 -0
- package/storybook-static/demo/logo.png +0 -0
- package/storybook-static/demo/module-url.html +215 -0
- package/storybook-static/demo/npm-versions-demo.html +118 -0
- package/storybook-static/demo/npm-versions.html +94 -0
- package/storybook-static/demo/parameters.html +70 -0
- package/storybook-static/demo/s.xml +3 -0
- package/storybook-static/demo/s.xslt +56 -0
- package/storybook-static/demo/s1.xslt +60 -0
- package/storybook-static/demo/scoped-css.html +169 -0
- package/storybook-static/demo/set-url.html +141 -0
- package/storybook-static/demo/ss.html +57 -0
- package/storybook-static/demo/table.xml +25 -0
- package/storybook-static/demo/table.xsl +293 -0
- package/storybook-static/demo/template.xsl +46 -0
- package/storybook-static/demo/tree.xml +25 -0
- package/storybook-static/demo/tree.xsl +33 -0
- package/storybook-static/demo/wc-square.svg +1 -0
- package/storybook-static/demo/xhtml-template.xhtml +45 -0
- package/storybook-static/demo/z.html +33 -0
- package/storybook-static/demo/z.js +9 -0
- package/storybook-static/demo/z.xml +60 -0
- package/storybook-static/demo/z1.html +34 -0
- package/storybook-static/embed-1.html +1 -2
- package/storybook-static/favicon.svg +1 -7
- package/storybook-static/iframe.html +42 -30
- package/storybook-static/index.html +36 -18
- package/storybook-static/index.json +1 -1
- package/storybook-static/mockServiceWorker.js +1 -1
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +1 -1
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js +39 -36
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js.LEGAL.txt +38 -1
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +395 -43
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js.LEGAL.txt +0 -18
- package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/interactions-10/manager-bundle.js +221 -22
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +3 -0
- package/storybook-static/sb-common-assets/favicon.svg +1 -0
- package/storybook-static/sb-manager/globals-module-info.js +995 -1
- package/storybook-static/sb-manager/globals-runtime.js +53525 -1
- package/storybook-static/sb-manager/globals.js +48 -1
- package/storybook-static/sb-manager/runtime.js +11884 -1
- package/storybook-static/sb-preview/globals.js +33 -1
- package/storybook-static/sb-preview/runtime.js +9437 -108
- package/vite.config.js +2 -1
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/compiler.xml +0 -6
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.vscode/settings.json +0 -24
- package/dist/custom-element-DAe7uvIt.js +0 -477
- package/dist/custom-element-DZvvhscI.cjs +0 -53
- package/dist/local-storage-Boafngui.cjs +0 -1
- package/dist/local-storage-BqDEu2kF.js +0 -59
- package/storybook-static/assets/Color-PRSJMWNM-CRSv4C7i.js +0 -1
- package/storybook-static/assets/DocsRenderer-K4EAMTCU-CG_P5zRZ.js +0 -2
- package/storybook-static/assets/WithTooltip-KJL26V4Q-CUqUi5E8.js +0 -1
- package/storybook-static/assets/custom-element-DpIq8E2p.js +0 -219
- package/storybook-static/assets/formatter-2WMMO6ZP-C-UiBIma.js +0 -58
- package/storybook-static/assets/http-request.stories-DCqY5s2i.js +0 -300
- package/storybook-static/assets/iframe-CURpvmVV.js +0 -2
- package/storybook-static/assets/index-CKw1EbdP.js +0 -1
- package/storybook-static/assets/index-CVRyq5ci.js +0 -27
- package/storybook-static/assets/index-Cc7K62zD.js +0 -3
- package/storybook-static/assets/index-DYpTqTNu.js +0 -1
- package/storybook-static/assets/index-DsWii_Ep.js +0 -548
- package/storybook-static/assets/index-DuIEV_9C.js +0 -13
- package/storybook-static/assets/lit-element-CenEXOuS.js +0 -19
- package/storybook-static/assets/local-storage.test.stories-BqgYwqr-.js +0 -419
- package/storybook-static/assets/preview-B4GcaC1c.js +0 -1
- package/storybook-static/assets/preview-B63p-W8V.js +0 -20
- package/storybook-static/assets/preview-DRnyIGXK.js +0 -48
- package/storybook-static/assets/preview-DjDbQHPa.js +0 -2
- package/storybook-static/assets/syntaxhighlighter-BP7B2CQK-CDpEe51g.js +0 -1
- package/storybook-static/assets/version-select.test.stories-DLwf-TPB.js +0 -60
- package/storybook-static/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +0 -3
- package/storybook-static/sb-common-assets/fonts.css +0 -31
- package/storybook-static/sb-manager/WithTooltip-KJL26V4Q-5LS5AN27.js +0 -1
- package/storybook-static/sb-manager/chunk-B3YDJJJH.js +0 -347
- package/storybook-static/sb-manager/chunk-BLWCBWKL.js +0 -9
- package/storybook-static/sb-manager/chunk-GUVK2GTO.js +0 -6
- package/storybook-static/sb-manager/chunk-LFRML3ZV.js +0 -186
- package/storybook-static/sb-manager/chunk-MC7RAF2B.js +0 -274
- package/storybook-static/sb-manager/chunk-ZR5JZWHI.js +0 -1
- package/storybook-static/sb-manager/formatter-2WMMO6ZP-JI7RHVTW.js +0 -58
- package/storybook-static/sb-manager/index.js +0 -1
- package/storybook-static/sb-manager/syntaxhighlighter-BP7B2CQK-WOJYHKQR.js +0 -1
- /package/storybook-static/sb-addons/{storybook-core-server-presets-0 → storybook-core-core-server-presets-0}/common-manager-bundle.js.LEGAL.txt +0 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import{w as x,u as y,e as c}from"./custom-element-D8hcDZHh.js";import"./http-request-DNq59pnj.js";import"./location-element-hKpcXCdn.js";import"./index-C8k3Z-3Y.js";const g=(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,S,w;function I(l,t){b.call(localStorage,l,t),window.dispatchEvent(new CustomEvent("local-storage",{detail:{key:l,value:t}}))}function B(l){S.call(localStorage,l),window.dispatchEvent(new CustomEvent("local-storage",{detail:{key:l}}))}function p(){w.call(localStorage),window.dispatchEvent(new CustomEvent("local-storage",{detail:{}}))}function T(){b||(b=localStorage.setItem,localStorage.setItem=I,S=localStorage.removeItem,localStorage.removeItem=B,w=localStorage.clear,localStorage.clear=p)}T();function V(l,t){I(l,t)}class K 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=i=>this.getAttribute(i),a=()=>{this.#e=g(t("type"),localStorage.getItem(t("key"))),this.dispatchEvent(new Event("change"))};if(this.#e=g(t("type"),localStorage.getItem(t("key"))),this.hasAttribute("value")?V(t("key"),this.#e=t("value")):a(),this.hasAttribute("live")){const i=e=>(e.detail.key===t("key")||!e.detail.key)&&a();window.addEventListener("local-storage",i),T(),this._destroy=()=>window.removeEventListener("local-storage",i)}}disconnectedCallback(){this._destroy?.()}}window.customElements.define("local-storage",K);const r={title:"",slice:"ls-slice",key:"sb-ls-key",value:"",live:"",body:""};function o(l){return new Promise(t=>setTimeout(t,l))}function f(l){const{title:t,slice:a,key:i,value:e,live:n,body:u}={...r,...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="${i}"
|
|
9
|
+
slice="${a}"
|
|
10
|
+
${n?`live="${n}"`:""}
|
|
11
|
+
${e?`value="${e}"`:""}
|
|
12
|
+
></local-storage>
|
|
13
|
+
|
|
14
|
+
<br/>
|
|
15
|
+
<var>${i}</var>:<code data-testid="slice-value">{ //slice/${a} }</code>
|
|
16
|
+
<br/>
|
|
17
|
+
${u}
|
|
18
|
+
</template>
|
|
19
|
+
</custom-element>
|
|
20
|
+
</fieldset>
|
|
21
|
+
`}const h={title:"local-storage",render:f};window.localStorageSetItem=V;window.localStorage_clear=p;window.localStorage_removeItem=B;const k={args:{title:"live value",live:"live",body:`
|
|
22
|
+
<input placeholder="value for localStorage" id="textinput"
|
|
23
|
+
slice="${r.slice}"
|
|
24
|
+
value="{ //${r.slice} ?? '${r.value}' }"/>
|
|
25
|
+
<button onclick="localStorageSetItem('${r.key}',textinput.value )">set</button>
|
|
26
|
+
<button onclick="localStorageSetItem('${r.key}','text value' )">text value</button>
|
|
27
|
+
<button onclick="localStorageSetItem('${r.key}','another text')">another text</button>
|
|
28
|
+
<button onclick="localStorage_removeItem('${r.key}' )">set blank</button>
|
|
29
|
+
`},play:async({canvasElement:l})=>{p();const t=x(l);await t.findByText(k.args.title);const a=()=>t.getByTestId("slice-value").textContent;await y.click(await t.findByText("set blank")),await c(localStorage.getItem(r.key)).toEqual(null,"from localStorage"),await c(a()).toEqual(""),await y.click(t.getByText("text value")),await o(10),await c(localStorage.getItem(r.key)).toEqual("text value","from localStorage"),await c(a()).toEqual("text value"),window.textinput.value="textinput.value",await y.click(t.getByText("set")),await o(10),c(a()).toEqual("textinput.value"),await y.click(t.getByText("another text")),await o(10),c(a()).toEqual("another text"),await y.click(t.getByText("set blank")),await o(10),c(a()).toEqual("")}},m={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="localStorageSetItem('${r.key}','text value')">text value</button>
|
|
32
|
+
<button onclick="localStorage_removeItem('${r.key}')">set blank</button>
|
|
33
|
+
`},play:async({canvasElement:l})=>{const t=x(l);await t.findByText(m.args.title);const a=()=>t.getByTestId("slice-value").textContent,i=async e=>await y.click(await t.findByText(e));await o(10),await c(localStorage.getItem(r.key)).toEqual("ABC"),await i("set blank"),await c(localStorage.getItem(r.key)).toEqual(null,"from localStorage"),await o(10),await c(a()).toEqual("ABC"),await i("text value"),await o(10),await c(localStorage.getItem(r.key)).toEqual("text value","from localStorage"),await c(a()).toEqual("ABC"),await i("set blank"),await o(10),await c(a()).toEqual("ABC")}},d={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="localStorageSetItem('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="localStorageSetItem('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(d.args.title);const a=i=>t.getByText(i);c(localStorage.getItem(r.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")}},v={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=> localStorageSetItem(k, typesinput.value) )
|
|
56
|
+
"> set to all</button><br>
|
|
57
|
+
<hr>
|
|
58
|
+
text-key:
|
|
59
|
+
<button onclick="localStorageSetItem('textKey', 'ABC' )">ABC</button>
|
|
60
|
+
<code data-testid="text-key">{//text-key }</code><br>
|
|
61
|
+
date-key:
|
|
62
|
+
<button onclick="localStorageSetItem('dateKey', '2024-04-20T03:58:42.131Z')">2024-04-21T03:58:42.131Z </button>
|
|
63
|
+
<button onclick="localStorageSetItem('dateKey', new Date(Date.now()).toISOString())">now </button>
|
|
64
|
+
<button onclick="localStorageSetItem('dateKey', 'ABC' )">date ABC - invalid </button>
|
|
65
|
+
<code data-testid="date-key">{//date-key }</code><br>
|
|
66
|
+
time-key:
|
|
67
|
+
<button onclick="localStorageSetItem('timeKey', '13:30')">13:30 </button>
|
|
68
|
+
<code data-testid="time-key">{//time-key }</code><br>
|
|
69
|
+
local-date-time:
|
|
70
|
+
<button onclick="localStorageSetItem('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="localStorageSetItem('numberKey', '2024' )">2024 - number </button>
|
|
74
|
+
<button onclick="localStorageSetItem('numberKey', '24' )">24 - number </button>
|
|
75
|
+
<button onclick="localStorageSetItem('numberKey', '1.23456e+5' )">1.23456e+5 </button>
|
|
76
|
+
<button onclick="localStorageSetItem('numberKey', '0001' )">0001 </button>
|
|
77
|
+
<button onclick="localStorageSetItem('numberKey', '000' )">000 </button>
|
|
78
|
+
<button onclick="localStorageSetItem('numberKey', '0' )">0 </button>
|
|
79
|
+
<button onclick="localStorageSetItem('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="localStorageSetItem('jsonKey', JSON.stringify('ABC'))">'ABC' - string </button>
|
|
85
|
+
<button onclick="localStorageSetItem('jsonKey', JSON.stringify(12.345))">12.345 - number </button>
|
|
86
|
+
<button onclick="localStorageSetItem('jsonKey', JSON.stringify(window.JsonSample) )">a:1,b:'B' -json </button>
|
|
87
|
+
<button onclick="localStorageSetItem('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(v.args.title);const a=s=>t.getByText(s),i=s=>t.getByTestId(s).textContent,e=(s,E)=>{c(i(s).trim()).toEqual(E,s)};p(),await o(10),e("text-key",""),e("date-key",""),e("time-key",""),e("local-date-time",""),e("number-key","NaN"),e("json-key","");const n=l.querySelector("input");n.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",""),n.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"),n.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"),n.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 u=new Date(Date.now()).toISOString();n.value=u,a("set to all").click(),await o(10),e("text-key",u),e("date-key",u.substring(0,10)),e("time-key",""),e("local-date-time",""),e("number-key","NaN"),e("json-key",""),n.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",""),n.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",""),n.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"),n.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",""),n.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",""),n.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",""),n.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"),n.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"),n.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"),n.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","a : 1b : B")}};k.parameters={...k.parameters,docs:{...k.parameters?.docs,source:{originalSource:`{
|
|
94
|
+
args: {
|
|
95
|
+
title: 'live value',
|
|
96
|
+
live: 'live',
|
|
97
|
+
body: \`
|
|
98
|
+
<input placeholder="value for localStorage" id="textinput"
|
|
99
|
+
slice="\${defs.slice}"
|
|
100
|
+
value="{ //\${defs.slice} ?? '\${defs.value}' }"/>
|
|
101
|
+
<button onclick="localStorageSetItem('\${defs.key}',textinput.value )">set</button>
|
|
102
|
+
<button onclick="localStorageSetItem('\${defs.key}','text value' )">text value</button>
|
|
103
|
+
<button onclick="localStorageSetItem('\${defs.key}','another text')">another text</button>
|
|
104
|
+
<button onclick="localStorage_removeItem('\${defs.key}' )">set blank</button>
|
|
105
|
+
\`
|
|
106
|
+
},
|
|
107
|
+
play: async ({
|
|
108
|
+
canvasElement
|
|
109
|
+
}) => {
|
|
110
|
+
localStorage_clear();
|
|
111
|
+
const canvas = within(canvasElement);
|
|
112
|
+
await canvas.findByText((Demo.args!.title as string));
|
|
113
|
+
const val = () => canvas.getByTestId('slice-value').textContent;
|
|
114
|
+
await userEvent.click(await canvas.findByText('set blank'));
|
|
115
|
+
await expect(localStorage.getItem(defs.key)).toEqual(null, 'from localStorage');
|
|
116
|
+
await expect(val()).toEqual('');
|
|
117
|
+
await userEvent.click(canvas.getByText('text value'));
|
|
118
|
+
await sleep(10);
|
|
119
|
+
await expect(localStorage.getItem(defs.key)).toEqual('text value', 'from localStorage');
|
|
120
|
+
await expect(val()).toEqual('text value');
|
|
121
|
+
window['textinput'].value = 'textinput.value';
|
|
122
|
+
await userEvent.click(canvas.getByText('set'));
|
|
123
|
+
await sleep(10);
|
|
124
|
+
expect(val()).toEqual('textinput.value');
|
|
125
|
+
await userEvent.click(canvas.getByText('another text'));
|
|
126
|
+
await sleep(10);
|
|
127
|
+
expect(val()).toEqual('another text');
|
|
128
|
+
await userEvent.click(canvas.getByText('set blank'));
|
|
129
|
+
await sleep(10);
|
|
130
|
+
expect(val()).toEqual('');
|
|
131
|
+
}
|
|
132
|
+
}`,...k.parameters?.docs?.source}}};m.parameters={...m.parameters,docs:{...m.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="localStorageSetItem('\${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
|
+
const click = async text => await userEvent.click(await canvas.findByText(text));
|
|
150
|
+
await sleep(10);
|
|
151
|
+
await expect(localStorage.getItem(defs.key)).toEqual('ABC');
|
|
152
|
+
await click('set blank');
|
|
153
|
+
await expect(localStorage.getItem(defs.key)).toEqual(null, 'from localStorage');
|
|
154
|
+
await sleep(10);
|
|
155
|
+
await expect(val()).toEqual('ABC');
|
|
156
|
+
await click('text value');
|
|
157
|
+
await sleep(10);
|
|
158
|
+
await expect(localStorage.getItem(defs.key)).toEqual('text value', 'from localStorage');
|
|
159
|
+
await expect(val()).toEqual('ABC');
|
|
160
|
+
await click('set blank');
|
|
161
|
+
await sleep(10);
|
|
162
|
+
await expect(val()).toEqual('ABC');
|
|
163
|
+
}
|
|
164
|
+
}`,...m.parameters?.docs?.source}}};d.parameters={...d.parameters,docs:{...d.parameters?.docs,source:{originalSource:`{
|
|
165
|
+
args: {
|
|
166
|
+
title: 'live value with defaults',
|
|
167
|
+
live: '',
|
|
168
|
+
value: 'ABC',
|
|
169
|
+
body: \`
|
|
170
|
+
|
|
171
|
+
<local-storage key="attr2Key" slice="attr2-key" type="text" live="live" slice-value="@value ?? 'DEF2'"></local-storage>
|
|
172
|
+
<button onclick="localStorage_removeItem('attr2Key')">clear key</button>
|
|
173
|
+
<button onclick="localStorageSetItem('attr2Key','attr2Key value')">update attr2-key value</button>
|
|
174
|
+
//attr2-key: <code data-testid="key2-value">{//attr2-key}</code><br/>
|
|
175
|
+
|
|
176
|
+
<local-storage key="attr3Key" slice="attr3-key" type="text" live="live" slice-value="@value ?? 'DEF3'"></local-storage>
|
|
177
|
+
<button onclick="localStorage_removeItem('attr3Key')">clear attr3-key key</button>
|
|
178
|
+
<button onclick="localStorageSetItem('attr3Key','attr3Key value')">update attr3-key value</button>
|
|
179
|
+
//attr3-key: <code data-testid="key3-value">{//attr3-key}</code><br/>
|
|
180
|
+
<button onclick="localStorage_clear()">clear localStorage</button>
|
|
181
|
+
\`
|
|
182
|
+
},
|
|
183
|
+
play: async ({
|
|
184
|
+
canvasElement
|
|
185
|
+
}) => {
|
|
186
|
+
const canvas = within(canvasElement);
|
|
187
|
+
await canvas.findByText((FromStorageWithDefault.args!.title as string));
|
|
188
|
+
const byText = txt => canvas.getByText(txt);
|
|
189
|
+
expect(localStorage.getItem(defs.key)).toEqual('ABC', 'from localStorage');
|
|
190
|
+
byText('clear localStorage').click();
|
|
191
|
+
expect(canvas.getByTestId('slice-value').textContent).toEqual('ABC');
|
|
192
|
+
expect(canvas.getByTestId('key2-value').textContent).toEqual('DEF2');
|
|
193
|
+
expect(canvas.getByTestId('key3-value').textContent).toEqual('DEF3');
|
|
194
|
+
byText('update attr2-key value').click();
|
|
195
|
+
expect(localStorage.getItem('attr2Key')).toEqual('attr2Key value', 'from localStorage');
|
|
196
|
+
await sleep(10);
|
|
197
|
+
expect(canvas.getByTestId('slice-value').textContent).toEqual('ABC');
|
|
198
|
+
expect(canvas.getByTestId('key2-value').textContent).toEqual('attr2Key value');
|
|
199
|
+
expect(canvas.getByTestId('key3-value').textContent).toEqual('DEF3');
|
|
200
|
+
byText('update attr3-key value').click();
|
|
201
|
+
expect(localStorage.getItem('attr3Key')).toEqual('attr3Key value', 'from localStorage');
|
|
202
|
+
await sleep(10);
|
|
203
|
+
expect(canvas.getByTestId('slice-value').textContent).toEqual('ABC');
|
|
204
|
+
expect(canvas.getByTestId('key2-value').textContent).toEqual('attr2Key value');
|
|
205
|
+
expect(canvas.getByTestId('key3-value').textContent).toEqual('attr3Key value');
|
|
206
|
+
}
|
|
207
|
+
}`,...d.parameters?.docs?.source}}};v.parameters={...v.parameters,docs:{...v.parameters?.docs,source:{originalSource:`{
|
|
208
|
+
args: {
|
|
209
|
+
title: 'local-storage type attribute variations',
|
|
210
|
+
body: \`
|
|
211
|
+
|
|
212
|
+
<local-storage key="textKey" slice="text-key" type="text" live="live"></local-storage>
|
|
213
|
+
<local-storage key="dateKey" slice="date-key" type="date" live="live"></local-storage>
|
|
214
|
+
<local-storage key="timeKey" slice="time-key" type="time" live="live"></local-storage>
|
|
215
|
+
<local-storage key="localDateTimeKey" slice="local-date-time" type="datetime-local" live="live"></local-storage>
|
|
216
|
+
<local-storage key="numberKey" slice="number-key" type="number" live="live"></local-storage>
|
|
217
|
+
<local-storage key="jsonKey" slice="json-key" type="json" live="live"></local-storage>
|
|
218
|
+
<input id="typesinput" placeholder="set value"><button onclick="
|
|
219
|
+
'textKey,dateKey,timeKey,localDateTimeKey,numberKey,jsonKey'.split(',')
|
|
220
|
+
.map( k=> localStorageSetItem(k, typesinput.value) )
|
|
221
|
+
"> set to all</button><br>
|
|
222
|
+
<hr>
|
|
223
|
+
text-key:
|
|
224
|
+
<button onclick="localStorageSetItem('textKey', 'ABC' )">ABC</button>
|
|
225
|
+
<code data-testid="text-key">{//text-key }</code><br>
|
|
226
|
+
date-key:
|
|
227
|
+
<button onclick="localStorageSetItem('dateKey', '2024-04-20T03:58:42.131Z')">2024-04-21T03:58:42.131Z </button>
|
|
228
|
+
<button onclick="localStorageSetItem('dateKey', new Date(Date.now()).toISOString())">now </button>
|
|
229
|
+
<button onclick="localStorageSetItem('dateKey', 'ABC' )">date ABC - invalid </button>
|
|
230
|
+
<code data-testid="date-key">{//date-key }</code><br>
|
|
231
|
+
time-key:
|
|
232
|
+
<button onclick="localStorageSetItem('timeKey', '13:30')">13:30 </button>
|
|
233
|
+
<code data-testid="time-key">{//time-key }</code><br>
|
|
234
|
+
local-date-time:
|
|
235
|
+
<button onclick="localStorageSetItem('localDateTimeKey', '1977-04-01T14:00:30')">1977-04-01T14:00:30 - local </button>
|
|
236
|
+
<code data-testid="local-date-time">{//local-date-time}</code><br>
|
|
237
|
+
number-key:
|
|
238
|
+
<button onclick="localStorageSetItem('numberKey', '2024' )">2024 - number </button>
|
|
239
|
+
<button onclick="localStorageSetItem('numberKey', '24' )">24 - number </button>
|
|
240
|
+
<button onclick="localStorageSetItem('numberKey', '1.23456e+5' )">1.23456e+5 </button>
|
|
241
|
+
<button onclick="localStorageSetItem('numberKey', '0001' )">0001 </button>
|
|
242
|
+
<button onclick="localStorageSetItem('numberKey', '000' )">000 </button>
|
|
243
|
+
<button onclick="localStorageSetItem('numberKey', '0' )">0 </button>
|
|
244
|
+
<button onclick="localStorageSetItem('numberKey', 'ABC' )">ABC - invalid, NaN </button>
|
|
245
|
+
<code data-testid="number-key">{//number-key }</code> <br>
|
|
246
|
+
<fieldset>
|
|
247
|
+
<legend>json-key: </legend>
|
|
248
|
+
|
|
249
|
+
<button onclick="localStorageSetItem('jsonKey', JSON.stringify('ABC'))">'ABC' - string </button>
|
|
250
|
+
<button onclick="localStorageSetItem('jsonKey', JSON.stringify(12.345))">12.345 - number </button>
|
|
251
|
+
<button onclick="localStorageSetItem('jsonKey', JSON.stringify(window.JsonSample) )">a:1,b:'B' -json </button>
|
|
252
|
+
<button onclick="localStorageSetItem('jsonKey', 'ABC' )">ABC - invalid </button><br>
|
|
253
|
+
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>
|
|
254
|
+
</fieldset>
|
|
255
|
+
<xsl:template mode="json" match="*|@*">
|
|
256
|
+
<div>{name()} : {.}</div>
|
|
257
|
+
</xsl:template>
|
|
258
|
+
\`
|
|
259
|
+
},
|
|
260
|
+
play: async ({
|
|
261
|
+
canvasElement
|
|
262
|
+
}) => {
|
|
263
|
+
window['JsonSample'] = {
|
|
264
|
+
a: 1,
|
|
265
|
+
b: 'B'
|
|
266
|
+
};
|
|
267
|
+
const canvas = within(canvasElement);
|
|
268
|
+
await canvas.findByText((TypeAttribute.args!.title as string));
|
|
269
|
+
const byText = txt => canvas.getByText(txt),
|
|
270
|
+
val = testId => canvas.getByTestId(testId).textContent,
|
|
271
|
+
expectVal = (key, value) => {
|
|
272
|
+
expect(val(key).trim()).toEqual(value, key);
|
|
273
|
+
};
|
|
274
|
+
localStorage_clear(); // cleanup before test
|
|
275
|
+
await sleep(10);
|
|
276
|
+
expectVal('text-key', '');
|
|
277
|
+
expectVal('date-key', '');
|
|
278
|
+
expectVal('time-key', '');
|
|
279
|
+
expectVal('local-date-time', '');
|
|
280
|
+
expectVal('number-key', 'NaN');
|
|
281
|
+
expectVal('json-key', '');
|
|
282
|
+
const input = canvasElement.querySelector('input');
|
|
283
|
+
input.value = 'ABC';
|
|
284
|
+
byText('set to all').click();
|
|
285
|
+
await sleep(10);
|
|
286
|
+
expectVal('text-key', 'ABC');
|
|
287
|
+
expectVal('date-key', '');
|
|
288
|
+
expectVal('time-key', '');
|
|
289
|
+
expectVal('local-date-time', '');
|
|
290
|
+
expectVal('number-key', 'NaN');
|
|
291
|
+
expectVal('json-key', '');
|
|
292
|
+
input.value = '22';
|
|
293
|
+
byText('set to all').click();
|
|
294
|
+
await sleep(10);
|
|
295
|
+
expectVal('text-key', '22');
|
|
296
|
+
expectVal('date-key', '');
|
|
297
|
+
expectVal('time-key', '');
|
|
298
|
+
expectVal('local-date-time', '');
|
|
299
|
+
expectVal('number-key', '22');
|
|
300
|
+
expectVal('json-key', '22');
|
|
301
|
+
input.value = '2024';
|
|
302
|
+
byText('set to all').click();
|
|
303
|
+
await sleep(10);
|
|
304
|
+
expectVal('text-key', '2024');
|
|
305
|
+
expectVal('date-key', '2024-01-01');
|
|
306
|
+
expectVal('time-key', '');
|
|
307
|
+
expectVal('local-date-time', '');
|
|
308
|
+
expectVal('number-key', '2024');
|
|
309
|
+
expectVal('json-key', '2024');
|
|
310
|
+
input.value = '2024-04-20T03:58:42.131Z';
|
|
311
|
+
byText('set to all').click();
|
|
312
|
+
await sleep(10);
|
|
313
|
+
expectVal('text-key', '2024-04-20T03:58:42.131Z');
|
|
314
|
+
expectVal('date-key', '2024-04-20');
|
|
315
|
+
expectVal('time-key', '');
|
|
316
|
+
expectVal('local-date-time', '');
|
|
317
|
+
expectVal('number-key', 'NaN');
|
|
318
|
+
expectVal('json-key', '');
|
|
319
|
+
const nowStr = new Date(Date.now()).toISOString();
|
|
320
|
+
input.value = nowStr;
|
|
321
|
+
byText('set to all').click();
|
|
322
|
+
await sleep(10);
|
|
323
|
+
expectVal('text-key', nowStr);
|
|
324
|
+
expectVal('date-key', nowStr.substring(0, 10));
|
|
325
|
+
expectVal('time-key', '');
|
|
326
|
+
expectVal('local-date-time', '');
|
|
327
|
+
expectVal('number-key', 'NaN');
|
|
328
|
+
expectVal('json-key', '');
|
|
329
|
+
input.value = '23:25';
|
|
330
|
+
byText('set to all').click();
|
|
331
|
+
await sleep(10);
|
|
332
|
+
expectVal('text-key', '23:25');
|
|
333
|
+
expectVal('date-key', '');
|
|
334
|
+
expectVal('time-key', '23:25');
|
|
335
|
+
expectVal('local-date-time', '');
|
|
336
|
+
expectVal('number-key', 'NaN');
|
|
337
|
+
expectVal('json-key', '');
|
|
338
|
+
input.value = '1977-04-01T14:00:30';
|
|
339
|
+
byText('set to all').click();
|
|
340
|
+
await sleep(10);
|
|
341
|
+
expectVal('text-key', '1977-04-01T14:00:30');
|
|
342
|
+
expectVal('date-key', '1977-04-01');
|
|
343
|
+
expectVal('time-key', '');
|
|
344
|
+
expectVal('local-date-time', '1977-04-01T14:00:30');
|
|
345
|
+
expectVal('number-key', 'NaN');
|
|
346
|
+
expectVal('json-key', '');
|
|
347
|
+
input.value = '1.23456e+5';
|
|
348
|
+
byText('set to all').click();
|
|
349
|
+
await sleep(10);
|
|
350
|
+
expectVal('text-key', '1.23456e+5');
|
|
351
|
+
expectVal('date-key', '');
|
|
352
|
+
expectVal('time-key', '');
|
|
353
|
+
expectVal('local-date-time', '');
|
|
354
|
+
expectVal('number-key', '123456');
|
|
355
|
+
expectVal('json-key', '123456');
|
|
356
|
+
input.value = '0001'; // as YYYY for year
|
|
357
|
+
byText('set to all').click();
|
|
358
|
+
await sleep(10);
|
|
359
|
+
expectVal('text-key', '0001');
|
|
360
|
+
expectVal('date-key', '0001-01-01');
|
|
361
|
+
expectVal('time-key', '');
|
|
362
|
+
expectVal('local-date-time', '');
|
|
363
|
+
expectVal('number-key', '1');
|
|
364
|
+
expectVal('json-key', '');
|
|
365
|
+
input.value = '001'; // as 2001 year
|
|
366
|
+
byText('set to all').click();
|
|
367
|
+
await sleep(10);
|
|
368
|
+
expectVal('text-key', '001');
|
|
369
|
+
expectVal('date-key', '2001-01-01');
|
|
370
|
+
expectVal('time-key', '');
|
|
371
|
+
expectVal('local-date-time', '');
|
|
372
|
+
expectVal('number-key', '1');
|
|
373
|
+
expectVal('json-key', '');
|
|
374
|
+
input.value = '000'; // as 2001 year
|
|
375
|
+
byText('set to all').click();
|
|
376
|
+
await sleep(10);
|
|
377
|
+
expectVal('text-key', '000');
|
|
378
|
+
expectVal('date-key', '2000-01-01');
|
|
379
|
+
expectVal('time-key', '');
|
|
380
|
+
expectVal('local-date-time', '');
|
|
381
|
+
expectVal('number-key', '0');
|
|
382
|
+
expectVal('json-key', '');
|
|
383
|
+
input.value = '0'; // as 2000 year
|
|
384
|
+
byText('set to all').click();
|
|
385
|
+
await sleep(10);
|
|
386
|
+
expectVal('text-key', '0');
|
|
387
|
+
expectVal('date-key', '2000-01-01');
|
|
388
|
+
expectVal('time-key', '');
|
|
389
|
+
expectVal('local-date-time', '');
|
|
390
|
+
expectVal('number-key', '0');
|
|
391
|
+
expectVal('json-key', '0');
|
|
392
|
+
input.value = '"abc"';
|
|
393
|
+
byText('set to all').click();
|
|
394
|
+
await sleep(10);
|
|
395
|
+
expectVal('text-key', '"abc"');
|
|
396
|
+
expectVal('date-key', '');
|
|
397
|
+
expectVal('time-key', '');
|
|
398
|
+
expectVal('local-date-time', '');
|
|
399
|
+
expectVal('number-key', 'NaN');
|
|
400
|
+
expectVal('json-key', 'abc');
|
|
401
|
+
input.value = '12.345';
|
|
402
|
+
byText('set to all').click();
|
|
403
|
+
await sleep(10);
|
|
404
|
+
expectVal('text-key', '12.345');
|
|
405
|
+
expectVal('date-key', '');
|
|
406
|
+
expectVal('time-key', '');
|
|
407
|
+
expectVal('local-date-time', '');
|
|
408
|
+
expectVal('number-key', '12.345');
|
|
409
|
+
expectVal('json-key', '12.345');
|
|
410
|
+
input.value = '{"a":1,"b":"B"}';
|
|
411
|
+
byText('set to all').click();
|
|
412
|
+
await sleep(10);
|
|
413
|
+
expectVal('text-key', '{"a":1,"b":"B"}');
|
|
414
|
+
expectVal('date-key', '');
|
|
415
|
+
expectVal('time-key', '');
|
|
416
|
+
expectVal('local-date-time', '');
|
|
417
|
+
expectVal('number-key', 'NaN');
|
|
418
|
+
expectVal('json-key', 'a : 1b : B');
|
|
419
|
+
}
|
|
420
|
+
}`,...v.parameters?.docs?.source}}};const N=["Demo","AlwaysOverride","FromStorageWithDefault","TypeAttribute"];export{m as AlwaysOverride,k as Demo,d as FromStorageWithDefault,v as TypeAttribute,N as __namedExportsOrder,h as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as m,e}from"./custom-element-
|
|
1
|
+
import{w as m,e}from"./custom-element-D8hcDZHh.js";import"./location-element-hKpcXCdn.js";import"./index-C8k3Z-3Y.js";const u={title:"",slice:"url-slice",href:"",live:"",body:""};function h(c){return new Promise(o=>setTimeout(o,c))}function x(c){const{title:o,slice:t,href:l,live:r,body:i}={...u,...c};return`
|
|
2
2
|
<fieldset>
|
|
3
3
|
<legend>${o}</legend>
|
|
4
4
|
|