@epa-wg/custom-element-dist 0.0.21 → 0.0.23
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/.gitignore +8 -0
- package/README.md +4 -4
- package/coverage/coverage-final.json +13 -11
- package/coverage/index.html +30 -30
- package/coverage/src/custom-element/coverage.svg +1 -1
- package/coverage/src/custom-element/custom-element.js/coverage.svg +1 -1
- package/coverage/src/custom-element/custom-element.js.html +603 -420
- package/coverage/src/custom-element/http-request.js.html +10 -10
- package/coverage/src/custom-element/index.html +18 -18
- package/coverage/src/custom-element/local-storage.js.html +2 -2
- package/coverage/src/custom-element/location-element.js.html +1 -1
- package/coverage/src/index.html +1 -1
- package/coverage/src/mocks/handlers.ts.html +1 -1
- package/coverage/src/mocks/index.html +1 -1
- package/coverage/src/stories/{css.stories.ts → attributes.test.stories.ts}/coverage.svg +1 -1
- package/coverage/src/stories/{attributes.stories.ts.html → attributes.test.stories.ts.html} +113 -83
- package/coverage/src/stories/coverage.svg +1 -1
- package/coverage/src/stories/css.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/{css.stories.ts.html → css.test.stories.ts.html} +122 -65
- package/coverage/src/stories/dom-merge.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/{dom-merge.stories.ts.html → dom-merge.test.stories.ts.html} +118 -70
- package/coverage/src/stories/external-template.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/{external-template.stories.ts.html → external-template.test.stories.ts.html} +180 -150
- package/coverage/src/stories/form.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/form.test.stories.ts.html +655 -0
- package/coverage/src/stories/http-request.stories.ts.html +7 -7
- package/coverage/src/stories/index.html +118 -88
- package/coverage/src/stories/{dom-merge.stories.ts → local-storage.test.stories.ts}/coverage.svg +1 -1
- package/coverage/src/stories/{local-storage.stories.ts.html → local-storage.test.stories.ts.html} +475 -439
- package/coverage/src/stories/{external-template.stories.ts → location-element.test.stories.ts}/coverage.svg +1 -1
- package/coverage/src/stories/{location-element.stories.ts.html → location-element.test.stories.ts.html} +134 -98
- package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/slice-events.test.stories.ts.html +685 -0
- package/coverage/src/stories/slots.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/slots.test.stories.ts.html +736 -0
- package/coverage/src/stories/{renderPlay.ts.html → testStoryBook.ts.html} +44 -26
- package/coverage/src/sum.ts.html +1 -1
- package/dist/custom-element-BISbI4SU.js +463 -0
- package/dist/custom-element-N-sWiqGK.cjs +53 -0
- package/dist/custom-element-bundle.cjs +1 -1
- package/dist/custom-element-bundle.js +2 -2
- package/dist/mockServiceWorker.js +1 -1
- package/package.json +4 -4
- package/public/mockServiceWorker.js +1 -1
- package/src/custom-element/custom-element.d.ts +4 -0
- package/src/custom-element/custom-element.js +103 -42
- package/src/custom-element/demo/a.html +38 -41
- package/src/custom-element/demo/b.html +13 -0
- package/src/custom-element/demo/data-slices.html +32 -0
- package/src/custom-element/demo/form.html +240 -0
- package/src/custom-element/demo/s.xml +11 -14
- package/src/custom-element/demo/s.xslt +22 -38
- package/src/custom-element/demo/s1.xslt +60 -0
- package/src/custom-element/ide/customData-dce.json +14 -1
- package/src/custom-element/ide/web-types-dce.json +6 -1
- package/src/custom-element/ide/web-types-xsl.json +1 -1
- package/src/custom-element/index.html +1 -0
- package/src/custom-element.test.ts +24 -8
- package/src/stories/{attributes.stories.ts → attributes.test.stories.ts} +19 -9
- package/src/stories/{css.stories.ts → css.test.stories.ts} +28 -9
- package/src/stories/{dom-merge.stories.ts → dom-merge.test.stories.ts} +19 -3
- package/src/stories/{external-template.stories.ts → external-template.test.stories.ts} +13 -3
- package/src/stories/form.test.stories.ts +190 -0
- package/src/stories/http-request.stories.ts +6 -6
- package/src/stories/http-request.test.ts +0 -9
- package/src/stories/{local-storage.stories.ts → local-storage.test.stories.ts} +24 -12
- package/src/stories/{location-element.stories.ts → location-element.test.stories.ts} +21 -9
- package/src/stories/{slice-events.stories.ts → slice-events.test.stories.ts} +88 -5
- package/src/stories/slots.test.stories.ts +217 -0
- package/src/stories/testStoryBook.ts +28 -0
- package/storybook-static/assets/{Color-RQJUDNI5-C4yZhNbM.js → Color-PRSJMWNM-BD_Ds9NW.js} +1 -1
- package/storybook-static/assets/{Configure-C7d36rng.js → Configure-70I_VApa.js} +1 -1
- package/storybook-static/assets/DocsRenderer-K4EAMTCU-9dn0-HCP.js +2 -0
- package/storybook-static/assets/WithTooltip-KJL26V4Q-C6g5GOU9.js +1 -0
- package/storybook-static/assets/{attributes.stories-ZB0RTY1d.js → attributes.test.stories-BEOraI4E.js} +22 -21
- package/storybook-static/assets/css.test.stories-D9WaxrEv.js +96 -0
- package/storybook-static/assets/custom-element-BV8-hRQS.js +219 -0
- package/storybook-static/assets/{dom-merge.stories-CgHZUABU.js → dom-merge.test.stories-BhbNeum_.js} +5 -6
- package/storybook-static/assets/{entry-preview-CQqNFx4W.js → entry-preview-DrgzXgwT.js} +1 -1
- package/storybook-static/assets/{entry-preview-docs-CWgqLfd3.js → entry-preview-docs-Bxv0qQWs.js} +1 -1
- package/storybook-static/assets/{external-template.stories-DtSLMxvg.js → external-template.test.stories-Bpr_wxBo.js} +23 -24
- package/storybook-static/assets/form.test.stories-3tURbEdv.js +250 -0
- package/storybook-static/assets/{formatter-B5HCVTEV-tKeEfJA9.js → formatter-2WMMO6ZP-6IvBq34u.js} +5 -5
- package/storybook-static/assets/http-request.stories-8K_qSs8C.js +300 -0
- package/storybook-static/assets/iframe-zdt9kuj6.js +2 -0
- package/storybook-static/assets/index-B3oZkK3F.js +1 -0
- package/storybook-static/assets/index-C30JwJMK.js +548 -0
- package/storybook-static/assets/index-CVRyq5ci.js +27 -0
- package/storybook-static/assets/index-DXimoRZY.js +1 -0
- package/storybook-static/assets/{index-DnEJ_bKa.js → index-DhXZyjEd.js} +1 -1
- package/storybook-static/assets/index-DuIEV_9C.js +13 -0
- package/storybook-static/assets/{lit-element-B4_0akdT.js → lit-element-CenEXOuS.js} +2 -2
- package/storybook-static/assets/{local-storage.stories-BkO6djDz.js → local-storage.test.stories-CtisAQBB.js} +28 -24
- package/storybook-static/assets/{location-element.stories-DCIOUd0D.js → location-element.test.stories-5O_t_m4Y.js} +11 -11
- package/storybook-static/assets/preview-4Up_z4Em.js +7 -0
- package/storybook-static/assets/preview-BKCN0mOr.js +1 -0
- package/storybook-static/assets/{preview-CkgAD_DE.js → preview-D0eCfQft.js} +2 -2
- package/storybook-static/assets/preview-DRnyIGXK.js +48 -0
- package/storybook-static/assets/preview-FpHGYA1q.js +1 -0
- package/storybook-static/assets/{preview-PxUn-cIn.js → preview-TCN6m6T-.js} +1 -1
- package/storybook-static/assets/slice-events.test.stories-BSXCLIA5.js +231 -0
- package/storybook-static/assets/slots.test.stories-B1vqfHmN.js +214 -0
- package/storybook-static/assets/syntaxhighlighter-BP7B2CQK-DpPBKyTO.js +1 -0
- package/storybook-static/iframe.html +153 -10
- package/storybook-static/index.html +1 -1
- package/storybook-static/index.json +1 -1
- package/storybook-static/mockServiceWorker.js +1 -1
- package/storybook-static/project.json +1 -1
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js +35 -29
- package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js.LEGAL.txt +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 +5 -5
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +35 -35
- 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-10/manager-bundle.js +18 -16
- package/storybook-static/sb-addons/links-1/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +1 -1
- package/storybook-static/sb-manager/WithTooltip-KJL26V4Q-5LS5AN27.js +1 -0
- package/storybook-static/sb-manager/{chunk-S4VOIVUE.js → chunk-B3YDJJJH.js} +9 -9
- package/storybook-static/sb-manager/{chunk-FEE35O7J.js → chunk-BLWCBWKL.js} +3 -3
- package/storybook-static/sb-manager/{chunk-XCO5HRLK.js → chunk-GUVK2GTO.js} +3 -3
- package/storybook-static/sb-manager/chunk-LFRML3ZV.js +186 -0
- package/storybook-static/sb-manager/chunk-MC7RAF2B.js +274 -0
- package/storybook-static/sb-manager/{chunk-XP3HGWTR.js → chunk-ZR5JZWHI.js} +1 -1
- package/storybook-static/sb-manager/{formatter-B5HCVTEV-7DCBOGO6.js → formatter-2WMMO6ZP-JI7RHVTW.js} +1 -1
- package/storybook-static/sb-manager/globals-module-info.js +1 -1
- package/storybook-static/sb-manager/globals-runtime.js +1 -1
- package/storybook-static/sb-manager/index.js +1 -1
- package/storybook-static/sb-manager/runtime.js +1 -1
- package/storybook-static/sb-manager/{syntaxhighlighter-JOJW2KGS-VF6EEVPI.js → syntaxhighlighter-BP7B2CQK-WOJYHKQR.js} +1 -1
- package/storybook-static/sb-preview/runtime.js +28 -11
- package/tsconfig.json +31 -21
- package/vite.config.js +5 -5
- package/yarn.lock +10242 -0
- package/.vscode/settings.json +0 -24
- package/coverage/src/stories/local-storage.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/location-element.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/renderPlay.ts/coverage.svg +0 -10
- package/coverage/src/stories/slice-events.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/slice-events.stories.ts.html +0 -436
- package/dist/custom-element-B4v-KaIh.cjs +0 -53
- package/dist/custom-element-_g0GTup2.js +0 -436
- package/src/stories/attributes.test.ts +0 -14
- package/src/stories/css.test.ts +0 -12
- package/src/stories/dom-merge.test.ts +0 -12
- package/src/stories/external-template.test.ts +0 -12
- package/src/stories/local-storage.test.ts +0 -12
- package/src/stories/location-element.test.ts +0 -14
- package/src/stories/renderPlay.ts +0 -22
- package/src/stories/slice-events.test.ts +0 -12
- package/storybook-static/assets/DocsRenderer-K4EAMTCU-BLMupvSb.js +0 -2
- package/storybook-static/assets/WithTooltip-Y7J54OF7-BAQSPSFk.js +0 -1
- package/storybook-static/assets/css.stories-CLSX-Xxd.js +0 -86
- package/storybook-static/assets/custom-element-BLZZ00dz.js +0 -53
- package/storybook-static/assets/http-request.stories-CUzlXO89.js +0 -300
- package/storybook-static/assets/iframe-gCvlWuoC.js +0 -2
- package/storybook-static/assets/index-CBQwM6ST.js +0 -508
- package/storybook-static/assets/index-CDavW7r9.js +0 -193
- package/storybook-static/assets/index-CQA5dlr6.js +0 -13
- package/storybook-static/assets/index-DgaNIR0t.js +0 -1
- package/storybook-static/assets/index-Dkj0J1ds.js +0 -1
- package/storybook-static/assets/preview-C6t8KBFr.js +0 -1
- package/storybook-static/assets/preview-CYD85dwb.js +0 -7
- package/storybook-static/assets/preview-D8LadFCz.js +0 -48
- package/storybook-static/assets/preview-DNpCpRPf.js +0 -1
- package/storybook-static/assets/slice-events.stories-DXKjXI37.js +0 -115
- package/storybook-static/assets/syntaxhighlighter-JOJW2KGS-C04pIVD3.js +0 -1
- package/storybook-static/sb-manager/WithTooltip-Y7J54OF7-CEHQ77YF.js +0 -1
- package/storybook-static/sb-manager/chunk-E3WK6ZOZ.js +0 -234
- package/storybook-static/sb-manager/chunk-E6ABNH5R.js +0 -183
- /package/coverage/src/stories/{attributes.stories.ts → testStoryBook.ts}/coverage.svg +0 -0
package/storybook-static/assets/{dom-merge.stories-CgHZUABU.js → dom-merge.test.stories-BhbNeum_.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as l,e as
|
|
1
|
+
import{w as l,e as n,u as c}from"./custom-element-BV8-hRQS.js";import"./index-CVRyq5ci.js";function r(s){return new Promise(t=>setTimeout(t,s))}function d(s){const{title:t,body:e}=s;return`
|
|
2
2
|
<fieldset>
|
|
3
3
|
<legend>${t}</legend>
|
|
4
4
|
${e}
|
|
@@ -16,7 +16,7 @@ import{w as l,e as a,u as c}from"./index-CDavW7r9.js";import"./custom-element-BL
|
|
|
16
16
|
<br/><input placeholder="after textarea input, click here " data-testid="refocus-id" />
|
|
17
17
|
</form>
|
|
18
18
|
</custom-element>
|
|
19
|
-
`},play:async({canvasElement:s})=>{const t=o.args.title,e=l(s);await e.findByText(t),await r(100),
|
|
19
|
+
`},play:async({canvasElement:s})=>{const t=o.args.title,e=l(s);await e.findByText(t),await r(100),n(await e.findByTestId("textarea-id")).toBeInTheDocument();const a=e.getByTestId("textarea-id");a.value="",a.focus(),await c.keyboard(t),n(a.value).toEqual(t),n(a.value.length).toEqual(t.length),e.getByTestId("refocus-id").focus(),await r(10),n(e.getByTestId("counter-id").textContent).toEqual(""+t?.length,"counter of symbols")}},i={args:{title:"Word count in HTML input field",body:`
|
|
20
20
|
<p>Counter update happens on keyup event. The update should not interfere with the input</p>
|
|
21
21
|
<custom-element>
|
|
22
22
|
<form>
|
|
@@ -33,7 +33,7 @@ import{w as l,e as a,u as c}from"./index-CDavW7r9.js";import"./custom-element-BL
|
|
|
33
33
|
<code data-testid="words-id"
|
|
34
34
|
>{
|
|
35
35
|
string-length(normalize-space(//slice/txt)) -
|
|
36
|
-
string-length(translate(normalize-space(//slice/txt), ' ', '')) + 1
|
|
36
|
+
string-length(translate(normalize-space(//slice/txt), ' ', '')) + 1
|
|
37
37
|
}</code>
|
|
38
38
|
<!-- The expression first normalizes the string by removing leading and trailing whitespace and
|
|
39
39
|
collapsing internal whitespace into a single space. It then subtracts the length of the string
|
|
@@ -46,7 +46,7 @@ import{w as l,e as a,u as c}from"./index-CDavW7r9.js";import"./custom-element-BL
|
|
|
46
46
|
<p><b>txt</b> slice:</p> <blockquote> {//slice/txt} </blockquote>
|
|
47
47
|
</form>
|
|
48
48
|
</custom-element>
|
|
49
|
-
`},play:async({canvasElement:s})=>{const t=i.args.title,e=l(s);await e.findByText(t);const
|
|
49
|
+
`},play:async({canvasElement:s})=>{const t=i.args.title,e=l(s);await e.findByText(t);const a=await e.findByTestId("input-id");a.value="",a.focus(),n(a).toBeInTheDocument(),await c.keyboard(t),await r(10),n(a.value).toEqual(t),n(e.getByTestId("chars-id").textContent.trim()).toEqual(""+t.length,"counter of symbols"),n(t.split(" ").length).toEqual(6,"counter of words in text sample"),n(e.getByTestId("words-id").textContent.trim()).toEqual("6","counter of words in render")}};o.parameters={...o.parameters,docs:{...o.parameters?.docs,source:{originalSource:`{
|
|
50
50
|
args: {
|
|
51
51
|
title: 'Chars count in textarea',
|
|
52
52
|
body: \`
|
|
@@ -78,7 +78,6 @@ import{w as l,e as a,u as c}from"./index-CDavW7r9.js";import"./custom-element-BL
|
|
|
78
78
|
await userEvent.keyboard(titleText);
|
|
79
79
|
expect(textarea.value).toEqual(titleText);
|
|
80
80
|
expect(textarea.value.length).toEqual(titleText.length);
|
|
81
|
-
debugger;
|
|
82
81
|
canvas.getByTestId('refocus-id').focus();
|
|
83
82
|
await sleep(10);
|
|
84
83
|
expect(canvas.getByTestId('counter-id').textContent).toEqual('' + titleText?.length, 'counter of symbols');
|
|
@@ -103,7 +102,7 @@ import{w as l,e as a,u as c}from"./index-CDavW7r9.js";import"./custom-element-BL
|
|
|
103
102
|
<code data-testid="words-id"
|
|
104
103
|
>{
|
|
105
104
|
string-length(normalize-space(//slice/txt)) -
|
|
106
|
-
string-length(translate(normalize-space(//slice/txt), ' ', '')) + 1
|
|
105
|
+
string-length(translate(normalize-space(//slice/txt), ' ', '')) + 1
|
|
107
106
|
}</code>
|
|
108
107
|
<!-- The expression first normalizes the string by removing leading and trailing whitespace and
|
|
109
108
|
collapsing internal whitespace into a single space. It then subtracts the length of the string
|
package/storybook-static/assets/{entry-preview-docs-CWgqLfd3.js → entry-preview-docs-Bxv0qQWs.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{S as u,e as O,a as y}from"./index-Cc7K62zD.js";import{i as S}from"./tiny-invariant-BxWVcicq.js";import{j as p}from"./lit-element-
|
|
1
|
+
import{S as u,e as O,a as y}from"./index-Cc7K62zD.js";import{i as S}from"./tiny-invariant-BxWVcicq.js";import{j as p}from"./lit-element-CenEXOuS.js";const{global:i}=__STORYBOOK_MODULE_GLOBAL__;var{window:g}=i;g.STORYBOOK_ENV="web-components";function d(e){if(!e)return!1;if(typeof e=="string")return!0;throw new Error('Provided component needs to be a string. e.g. component: "my-element"')}function l(e){if(!e)return!1;if(e.tags&&Array.isArray(e.tags)||e.modules&&Array.isArray(e.modules))return!0;throw new Error(`You need to setup valid meta data in your config.js via setCustomElements().
|
|
2
2
|
See the readme of addon-docs for web components for more details.`)}function c(){return i.__STORYBOOK_CUSTOM_ELEMENTS__||i.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__}var{window:w,EventSource:h}=i;typeof module<"u"&&module?.hot?.decline&&(module.hot.decline(),new h("__webpack_hmr").addEventListener("message",function(e){try{let{action:r}=JSON.parse(e.data);r==="built"&&w.location.reload()}catch{}}));const{logger:m}=__STORYBOOK_MODULE_CLIENT_LOGGER__,{useEffect:v,addons:b}=__STORYBOOK_MODULE_PREVIEW_API__;function _(e,r){let t;switch(r){case"attributes":case"properties":t={name:e.type?.text||e.type};break;case"slots":t={name:"string"};break;default:t={name:"void"};break}return{name:e.name,required:!1,description:e.description,type:t,table:{category:r,type:{summary:e.type?.text||e.type},defaultValue:{summary:e.default!==void 0?e.default:e.defaultValue}}}}function D(e){let r=e.name.replace(/(-|_|:|\.|\s)+(.)?/g,(t,n,a)=>a?a.toUpperCase():"").replace(/^([A-Z])/,t=>t.toLowerCase());return r=`on${r.charAt(0).toUpperCase()+r.substr(1)}`,[{name:r,action:{name:e.name},table:{disable:!0}},_(e,"events")]}function o(e,r){return e&&e.filter(t=>t&&t.name).reduce((t,n)=>{if(n.kind==="method")return t;switch(r){case"events":D(n).forEach(a=>{S(a.name,`${a} should have a name property.`),t[a.name]=a});break;default:t[n.name]=_(n,r);break}return t},{})}var C=(e,r)=>{if(!d(e)||!l(r))return null;let t=r.tags.find(n=>n.name.toUpperCase()===e.toUpperCase());return t||m.warn(`Component not found in custom-elements.json: ${e}`),t},T=(e,r)=>{if(!d(e)||!l(r))return null;let t;return r?.modules?.forEach(n=>{n?.declarations?.forEach(a=>{a.tagName===e&&(t=a)})}),t||m.warn(`Component not found in custom-elements.json: ${e}`),t},f=(e,r)=>r?.version==="experimental"?C(e,r):T(e,r),A=(e,r)=>{let t=f(e,r);return t&&{...o(t.members??[],"properties"),...o(t.properties??[],"properties"),...o(t.attributes??[],"attributes"),...o(t.events??[],"events"),...o(t.slots??[],"slots"),...o(t.cssProperties??[],"css custom properties"),...o(t.cssParts??[],"css shadow parts")}},M=e=>{let r=c();return A(e,r)},L=e=>{let r=f(e,c());return r&&r.description},R=/<!--\?lit\$[0-9]+\$-->|<!--\??-->/g;function I(e){let r=e?.parameters.docs?.source,t=e?.parameters.__isArgsStory;return r?.type===u.DYNAMIC?!1:!t||r?.code||r?.type===u.CODE}function P(e,r){let t=e(),n=r?.parameters.docs?.source?.excludeDecorators?r.originalStoryFn(r.args,r):t,a;if(v(()=>{let{id:s,unmappedArgs:E}=r;a&&b.getChannel().emit(y,{id:s,source:a,args:E})}),!I(r)){let s=window.document.createElement("div");n instanceof DocumentFragment?p(n.cloneNode(!0),s):p(n,s),a=s.innerHTML.replace(R,"")}return t}var N=[P],B={docs:{extractArgTypes:M,extractComponentDescription:L,story:{inline:!0},source:{type:u.DYNAMIC,language:"html"}}},V=[O];export{V as argTypesEnhancers,N as decorators,B as parameters};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import{w as l,e as
|
|
1
|
+
import{w as l,e as a}from"./custom-element-BV8-hRQS.js";import"./index-CVRyq5ci.js";function T(t){return new Promise(e=>setTimeout(e,t))}function v(t){const{title:e,body:n}=t;return`
|
|
2
2
|
<fieldset>
|
|
3
3
|
<legend>${e}</legend>
|
|
4
|
-
${
|
|
4
|
+
${n}
|
|
5
5
|
</fieldset>
|
|
6
|
-
`}const
|
|
6
|
+
`}const H={title:"external-templates",render:v},s={args:{title:"Template in page DOM",body:`
|
|
7
7
|
<template id="template1">
|
|
8
8
|
<slot>Hello</slot> World!
|
|
9
9
|
</template>
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
<custom-element tag="dce-internal" src="#template1"></custom-element>
|
|
12
12
|
<!-- no need for loading fallback as the template exists -->
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
<dce-internal data-testid="slot-override">👋</dce-internal>
|
|
15
15
|
<dce-internal data-testid="slot-default"></dce-internal>
|
|
16
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(s.args.title);const
|
|
16
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(s.args.title);const n=f=>e.getByTestId(f).textContent.trim();a(n("slot-override")).toEqual("👋 World!"),a(n("slot-default")).toEqual("Hello World!")}},i={args:{title:"no tag, template in same DOM",body:`
|
|
17
17
|
<template id="template2">
|
|
18
18
|
🏗️ construction
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<custom-element src="#template2"></custom-element>
|
|
22
|
-
<custom-element src="#template2"></custom-element>`},play:async({canvasElement:t})=>{await l(t).findByText(i.args.title),
|
|
22
|
+
<custom-element src="#template2"></custom-element>`},play:async({canvasElement:t})=>{await l(t).findByText(i.args.title),a(t.querySelectorAll("custom-element")[0].textContent.trim()).toEqual("🏗️ construction"),a(t.querySelectorAll("custom-element")[1].textContent.trim()).toEqual("🏗️ construction")}},m={args:{title:"External SVG as template",body:`
|
|
23
23
|
<custom-element tag="dce-external" src="/confused.svg">
|
|
24
24
|
<template><i>loading from SVG ...</i></template>
|
|
25
25
|
</custom-element>
|
|
@@ -30,7 +30,7 @@ import{w as l,e as n}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.
|
|
|
30
30
|
<custom-element src="no.svg">
|
|
31
31
|
<i>fallback for missing image</i>
|
|
32
32
|
</custom-element>
|
|
33
|
-
`},play:async({canvasElement:t})=>{await l(t).findByText(m.args.title),
|
|
33
|
+
`},play:async({canvasElement:t})=>{await l(t).findByText(m.args.title),a(t.querySelector('[src="confused.svg"]').innerHTML).to.include("loading from SVG ..."),await T(100),a(t.querySelector("dce-external").innerHTML).to.include("<svg"),a(t.querySelector('[src="no.svg"]').innerHTML).to.include("Vitest Browser Tester")}},o={args:{title:"External XSLT file",body:`
|
|
34
34
|
<custom-element tag="dce-external-4" src="/tree.xsl">
|
|
35
35
|
<template><i>loading from XSLT ...</i></template>
|
|
36
36
|
</custom-element>
|
|
@@ -39,50 +39,50 @@ import{w as l,e as n}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.
|
|
|
39
39
|
<custom-element src="/tree.xsl" data-smile="👼" data-basket="🍒">
|
|
40
40
|
<i>inline DCE loading from XSLT ...</i>
|
|
41
41
|
</custom-element>
|
|
42
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(o.args.title),
|
|
42
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(o.args.title),a(t.querySelector("dce-external-4").innerHTML).to.include("Hi"),a(t.querySelector('[data-smile="👼"]').innerHTML).to.include("loading from XSLT ..."),await T(100),a(e.getByTestId("data-fruit").innerHTML).to.include("🍌"),a(e.getByTestId("data-smile").innerHTML).to.include("👼")}},c={args:{title:"external HTML template",body:`
|
|
43
43
|
<custom-element tag="dce-external-5" src="/html-template.html">
|
|
44
44
|
<template><i>loading from HTML file ...</i></template>
|
|
45
45
|
</custom-element>
|
|
46
46
|
<dce-external-5 title="DCE with external XSLT template" data-fruit="🍌">Hi</dce-external-5>
|
|
47
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(c.args.title),await e.findByText("👋");const
|
|
47
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(c.args.title),await e.findByText("👋");const n=t.querySelector("dce-external-5").innerHTML;a(n).to.include("👋"),a(n).to.include("👌"),a(n).to.include("<svg"),a(n).to.include("<math")}},r={args:{title:"external HTML template",body:`
|
|
48
48
|
<custom-element src="/html-template.html" data-smile="👼" data-basket="🍒">
|
|
49
49
|
<i>inline DCE loading from HTML file ...</i>
|
|
50
50
|
</custom-element>
|
|
51
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(r.args.title),await e.findByText("👋");const
|
|
51
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(r.args.title),await e.findByText("👋");const n=t.innerHTML;a(n).to.include("👋"),a(n).to.include("👌"),a(n).to.include("<svg"),a(n).to.include("<math")}},d={args:{title:"external HTML template - html by id",body:`
|
|
52
52
|
<custom-element src="/html-template.html#wave">
|
|
53
53
|
<template><i>loading HTML from templates file ...</i></template>
|
|
54
54
|
</custom-element>
|
|
55
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(d.args.title),
|
|
55
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(d.args.title),a(await e.findByText("👋")).toBeInTheDocument()}},p={args:{title:"external HTML template - SVG by id",body:`
|
|
56
56
|
<custom-element src="/html-template.html#dwc-logo">
|
|
57
57
|
<template><i>loading SVG from templates file ...</i></template>
|
|
58
58
|
</custom-element>
|
|
59
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(
|
|
59
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(p.args.title),a(await e.findByTestId("svg-test")).toBeInTheDocument()}},u={args:{title:"external HTML template - MathML by id",body:`
|
|
60
60
|
<custom-element src="/html-template.html#sophomores-dream">
|
|
61
61
|
<template><i>loading MathML from HTML file ...</i></template>
|
|
62
62
|
</custom-element>
|
|
63
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(
|
|
63
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(u.args.title);const n=await e.findByTestId("ml-test");a(n.firstElementChild.localName).toEqual("mrow")}},g={args:{title:"external XHTML template - xsl by id",body:`
|
|
64
64
|
<custom-element src="/html-template.xhtml#embedded-xsl">
|
|
65
65
|
<template>whole XSLT is embedded into HTML body</template>
|
|
66
66
|
</custom-element>
|
|
67
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(g.args.title);const
|
|
67
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(g.args.title);const n=await e.findByTestId("src");a(n.textContent).to.include("/html-template.xhtml#embedded-xsl")}},y={args:{title:"external HTML template - missing id",body:`
|
|
68
68
|
<custom-element src="/html-template.html#none">
|
|
69
69
|
<template><i data-testid="no-id">element with id=none is missing in template</i></template>
|
|
70
70
|
</custom-element>
|
|
71
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(y.args.title),await T(100);const
|
|
71
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(y.args.title),await T(100);const n=await e.findByTestId("no-id");a(n.textContent).to.include("element with id=none is missing in template")}},x={args:{title:"external file with embedding of another external DCE",body:`
|
|
72
72
|
<custom-element src="/embed-1.html">
|
|
73
73
|
loading from embed-1.html ...
|
|
74
74
|
</custom-element>
|
|
75
|
-
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(x.args.title),await T(100),
|
|
75
|
+
`},play:async({canvasElement:t})=>{const e=l(t);await e.findByText(x.args.title),await T(100),a(await e.findByTestId("wave")).toBeInTheDocument(),a(e.getByTestId("wave").innerHTML).toEqual("🖖")}};s.parameters={...s.parameters,docs:{...s.parameters?.docs,source:{originalSource:`{
|
|
76
76
|
args: {
|
|
77
77
|
title: 'Template in page DOM',
|
|
78
78
|
body: \`
|
|
79
79
|
<template id="template1">
|
|
80
80
|
<slot>Hello</slot> World!
|
|
81
81
|
</template>
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
<custom-element tag="dce-internal" src="#template1"></custom-element>
|
|
84
84
|
<!-- no need for loading fallback as the template exists -->
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
<dce-internal data-testid="slot-override">👋</dce-internal>
|
|
87
87
|
<dce-internal data-testid="slot-default"></dce-internal>
|
|
88
88
|
\`
|
|
@@ -226,7 +226,7 @@ import{w as l,e as n}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.
|
|
|
226
226
|
await canvas.findByText((HtmlWithinHtmlFile.args!.title as string));
|
|
227
227
|
expect(await canvas.findByText('👋')).toBeInTheDocument();
|
|
228
228
|
}
|
|
229
|
-
}`,...d.parameters?.docs?.source}}};
|
|
229
|
+
}`,...d.parameters?.docs?.source}}};p.parameters={...p.parameters,docs:{...p.parameters?.docs,source:{originalSource:`{
|
|
230
230
|
args: {
|
|
231
231
|
title: 'external HTML template - SVG by id',
|
|
232
232
|
body: \`
|
|
@@ -242,7 +242,7 @@ import{w as l,e as n}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.
|
|
|
242
242
|
await canvas.findByText((SvgWithinHtmlFile.args!.title as string));
|
|
243
243
|
expect(await canvas.findByTestId('svg-test')).toBeInTheDocument();
|
|
244
244
|
}
|
|
245
|
-
}`,...
|
|
245
|
+
}`,...p.parameters?.docs?.source}}};u.parameters={...u.parameters,docs:{...u.parameters?.docs,source:{originalSource:`{
|
|
246
246
|
args: {
|
|
247
247
|
title: 'external HTML template - MathML by id',
|
|
248
248
|
body: \`
|
|
@@ -257,10 +257,9 @@ import{w as l,e as n}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.
|
|
|
257
257
|
const canvas = within(canvasElement);
|
|
258
258
|
await canvas.findByText((MathMLWithinHtmlFile.args!.title as string));
|
|
259
259
|
const ml = await canvas.findByTestId('ml-test');
|
|
260
|
-
debugger;
|
|
261
260
|
expect(ml.firstElementChild.localName).toEqual('mrow');
|
|
262
261
|
}
|
|
263
|
-
}`,...
|
|
262
|
+
}`,...u.parameters?.docs?.source}}};g.parameters={...g.parameters,docs:{...g.parameters?.docs,source:{originalSource:`{
|
|
264
263
|
args: {
|
|
265
264
|
title: 'external XHTML template - xsl by id',
|
|
266
265
|
body: \`
|
|
@@ -313,4 +312,4 @@ import{w as l,e as n}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.
|
|
|
313
312
|
expect(await canvas.findByTestId('wave')).toBeInTheDocument();
|
|
314
313
|
expect(canvas.getByTestId('wave').innerHTML).toEqual('🖖');
|
|
315
314
|
}
|
|
316
|
-
}`,...x.parameters?.docs?.source}}};const E=["TemplateInPage","NoTag","ExternalSvg","ExternalXsltFile","ExternalHtmlFile","ExternalHtmlFileInline","HtmlWithinHtmlFile","SvgWithinHtmlFile","MathMLWithinHtmlFile","ByIdWithinXsltFile","MissingIdWithinXsltFile","EmbeddingInAnotherFile"];export{g as ByIdWithinXsltFile,x as EmbeddingInAnotherFile,c as ExternalHtmlFile,r as ExternalHtmlFileInline,m as ExternalSvg,o as ExternalXsltFile,d as HtmlWithinHtmlFile,
|
|
315
|
+
}`,...x.parameters?.docs?.source}}};const E=["TemplateInPage","NoTag","ExternalSvg","ExternalXsltFile","ExternalHtmlFile","ExternalHtmlFileInline","HtmlWithinHtmlFile","SvgWithinHtmlFile","MathMLWithinHtmlFile","ByIdWithinXsltFile","MissingIdWithinXsltFile","EmbeddingInAnotherFile"];export{g as ByIdWithinXsltFile,x as EmbeddingInAnotherFile,c as ExternalHtmlFile,r as ExternalHtmlFileInline,m as ExternalSvg,o as ExternalXsltFile,d as HtmlWithinHtmlFile,u as MathMLWithinHtmlFile,y as MissingIdWithinXsltFile,i as NoTag,p as SvgWithinHtmlFile,s as TemplateInPage,E as __namedExportsOrder,H as default};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import{w as i,e as n,u as e}from"./custom-element-BV8-hRQS.js";import"./index-CVRyq5ci.js";function l(a){const{title:t,body:s}=a;return`
|
|
2
|
+
<fieldset>
|
|
3
|
+
<legend>${t}</legend>
|
|
4
|
+
${s}
|
|
5
|
+
</fieldset>
|
|
6
|
+
`}const y={title:"form",render:l},o={args:{title:"custom-validity boolean",body:`
|
|
7
|
+
<p>type and then clear test in input should lead to system validation message shown next to input field.
|
|
8
|
+
Something like <q>Please fill out this field</q>.</p>
|
|
9
|
+
<custom-element>
|
|
10
|
+
<template>
|
|
11
|
+
<form>
|
|
12
|
+
<label> Email
|
|
13
|
+
<input slice="username" slice-event="input" placeholder="non-empty" required data-testid="input-1">
|
|
14
|
+
</label>
|
|
15
|
+
<if test="//username/@validation-message">
|
|
16
|
+
<var data-testid="validation-msg">{//username/@validation-message}</var>
|
|
17
|
+
</if>
|
|
18
|
+
<button>Next</button>
|
|
19
|
+
</form>
|
|
20
|
+
</template>
|
|
21
|
+
</custom-element>
|
|
22
|
+
`},play:async({canvasElement:a})=>{o.args.title;const t=i(a);await n(t.queryByTestId("validation-msg")).toBeNull();const s=await t.findByTestId("input-1");s.focus(),await e.keyboard("abc"),await e.clear(s),await n(t.queryByTestId("validation-msg")).toBeInTheDocument()}},d={args:{title:"form-data populated",body:`
|
|
23
|
+
<p>type and then clear test in input should lead to system validation message shown next to input field.
|
|
24
|
+
Something like <q>Please fill out this field</q>.</p>
|
|
25
|
+
<custom-element>
|
|
26
|
+
<template>
|
|
27
|
+
<form slice="signin-form" >
|
|
28
|
+
<input name="f1" placeholder="non-empty" required data-testid="input-1"/>
|
|
29
|
+
<input name="f2" placeholder="non-empty" required data-testid="input-2"/>
|
|
30
|
+
<input name="f3" placeholder="non-empty" required data-testid="input-3"/>
|
|
31
|
+
|
|
32
|
+
<button data-testid="next-button">Next</button><br/>
|
|
33
|
+
f1: <code data-testid="c1">{ /datadom/slice/signin-form/form-data/f1 }</code><br/>
|
|
34
|
+
f2: <code data-testid="c2">{ //form-data/f2 }</code><br/>
|
|
35
|
+
f3: <code data-testid="c3">{/datadom/slice/signin-form/form-data/f3}</code><br/>
|
|
36
|
+
</form>
|
|
37
|
+
</template>
|
|
38
|
+
</custom-element>
|
|
39
|
+
`},play:async({canvasElement:a})=>{const t=i(a);await e.type(t.getByTestId("input-1"),"ABC"),await e.click(t.getByRole("button")),await n(await t.findByText("ABC")).toBeInTheDocument(),await e.type(t.getByTestId("input-2"),"DCE"),await e.click(t.getByRole("button")),await n(await t.findByText("DCE")).toBeInTheDocument(),await e.type(t.getByTestId("input-3"),"XYZ"),t.getByTestId("input-1").focus(),await n(await t.findByText("XYZ")).toBeInTheDocument()}},r={args:{title:"setCustomValidity",body:`
|
|
40
|
+
<p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity">setCustomValidity()</a>
|
|
41
|
+
invoked by <code>custom-validity</code> attribute. Type in the input fiels to observe the chars count in
|
|
42
|
+
text, click "next" and observe same message in dropdown.
|
|
43
|
+
</p>
|
|
44
|
+
<custom-element>
|
|
45
|
+
<template>
|
|
46
|
+
<form>
|
|
47
|
+
<input slice="s1" slice-event="input keyup" placeholder="type to see the custom error"
|
|
48
|
+
custom-validity=" concat( 'char count ', string-length(//s1) ) "
|
|
49
|
+
data-testid="input-1"/><br/>
|
|
50
|
+
s1: <code data-testid="c1">{ //s1 }</code><br/>
|
|
51
|
+
@validation-message: <var data-testid="validation-msg">{//s1/@validation-message}</var>
|
|
52
|
+
<button>next</button>
|
|
53
|
+
</form>
|
|
54
|
+
</template>
|
|
55
|
+
</custom-element>
|
|
56
|
+
`},play:async({canvasElement:a})=>{const t=i(a);await e.type(t.getByTestId("input-1"),"ABC"),await n(t.getByText("ABC")).toBeInTheDocument(),await n(t.getByText("char count 3")).toBeInTheDocument()}},c={args:{title:"form custom-validity, boolean",body:`
|
|
57
|
+
<p> Form is valid only when input text length longer of 3 characters. </p>
|
|
58
|
+
<custom-element>
|
|
59
|
+
<template>
|
|
60
|
+
<form slice="form-1" custom-validity=" string-length(//form-1//f1) > 3 "
|
|
61
|
+
data-testid="form-1"
|
|
62
|
+
>
|
|
63
|
+
<input name="f1" data-testid="input-1"/><br/>
|
|
64
|
+
|
|
65
|
+
<input type="hidden" name="id" value="form--form-custom-validity-boolean"/>
|
|
66
|
+
<input type="hidden" name="viewMode" value="story"/>
|
|
67
|
+
//form-1//f1: <code data-testid="c1">{ //form-1//f1 }</code><br/>
|
|
68
|
+
<button>next</button>
|
|
69
|
+
</form>
|
|
70
|
+
</template>
|
|
71
|
+
</custom-element>
|
|
72
|
+
`},play:async({canvasElement:a})=>{const t=i(a);await e.type(t.getByTestId("input-1"),"AB"),await e.click(t.getByRole("button")),await n(t.getByText("AB")).toBeInTheDocument()}},m={args:{title:"form custom-validity, string",body:`
|
|
73
|
+
<p> Form is valid only when input text is longer of 3 characters, @validation-message propagated in form slot </p>
|
|
74
|
+
<custom-element>
|
|
75
|
+
<template>
|
|
76
|
+
<form slice="form-1"
|
|
77
|
+
custom-validity=" string-length(//form-1//f1) > 3 ?? concat('should be more than 3 characters, now is ',string-length(//form-1//f1) ) "
|
|
78
|
+
data-testid="form-1"
|
|
79
|
+
>
|
|
80
|
+
<input name="f1" data-testid="input-1"/><br/>
|
|
81
|
+
|
|
82
|
+
<input type="hidden" name="id" value="form--form-custom-validity-string"/>
|
|
83
|
+
<input type="hidden" name="viewMode" value="story"/>
|
|
84
|
+
//form-1//f1: <code data-testid="c1">{ //form-1//f1 }</code><br/>
|
|
85
|
+
//form-1/@validation-message: <code data-testid="c1">{ //@validation-message }</code><br/>
|
|
86
|
+
<button>next</button>
|
|
87
|
+
</form>
|
|
88
|
+
</template>
|
|
89
|
+
</custom-element>
|
|
90
|
+
`},play:async({canvasElement:a})=>{const t=i(a);await e.type(t.getByTestId("input-1"),"AB"),await e.click(t.getByRole("button")),await n(t.getByText("AB")).toBeInTheDocument(),await n(t.getByText("should be more than 3 characters, now is 2")).toBeInTheDocument()}};o.parameters={...o.parameters,docs:{...o.parameters?.docs,source:{originalSource:`{
|
|
91
|
+
args: {
|
|
92
|
+
title: 'custom-validity boolean',
|
|
93
|
+
body: \`
|
|
94
|
+
<p>type and then clear test in input should lead to system validation message shown next to input field.
|
|
95
|
+
Something like <q>Please fill out this field</q>.</p>
|
|
96
|
+
<custom-element>
|
|
97
|
+
<template>
|
|
98
|
+
<form>
|
|
99
|
+
<label> Email
|
|
100
|
+
<input slice="username" slice-event="input" placeholder="non-empty" required data-testid="input-1">
|
|
101
|
+
</label>
|
|
102
|
+
<if test="//username/@validation-message">
|
|
103
|
+
<var data-testid="validation-msg">{//username/@validation-message}</var>
|
|
104
|
+
</if>
|
|
105
|
+
<button>Next</button>
|
|
106
|
+
</form>
|
|
107
|
+
</template>
|
|
108
|
+
</custom-element>
|
|
109
|
+
\`
|
|
110
|
+
},
|
|
111
|
+
play: async ({
|
|
112
|
+
canvasElement
|
|
113
|
+
}) => {
|
|
114
|
+
const titleText = (SystemMessage.args!.title as string);
|
|
115
|
+
const canvas = within(canvasElement);
|
|
116
|
+
await expect(canvas.queryByTestId('validation-msg')).toBeNull();
|
|
117
|
+
const input = await canvas.findByTestId('input-1');
|
|
118
|
+
input.focus();
|
|
119
|
+
await userEvent.keyboard('abc');
|
|
120
|
+
await userEvent.clear(input);
|
|
121
|
+
await expect(canvas.queryByTestId('validation-msg')).toBeInTheDocument();
|
|
122
|
+
}
|
|
123
|
+
}`,...o.parameters?.docs?.source}}};d.parameters={...d.parameters,docs:{...d.parameters?.docs,source:{originalSource:`{
|
|
124
|
+
args: {
|
|
125
|
+
title: 'form-data populated',
|
|
126
|
+
body: \`
|
|
127
|
+
<p>type and then clear test in input should lead to system validation message shown next to input field.
|
|
128
|
+
Something like <q>Please fill out this field</q>.</p>
|
|
129
|
+
<custom-element>
|
|
130
|
+
<template>
|
|
131
|
+
<form slice="signin-form" >
|
|
132
|
+
<input name="f1" placeholder="non-empty" required data-testid="input-1"/>
|
|
133
|
+
<input name="f2" placeholder="non-empty" required data-testid="input-2"/>
|
|
134
|
+
<input name="f3" placeholder="non-empty" required data-testid="input-3"/>
|
|
135
|
+
|
|
136
|
+
<button data-testid="next-button">Next</button><br/>
|
|
137
|
+
f1: <code data-testid="c1">{ /datadom/slice/signin-form/form-data/f1 }</code><br/>
|
|
138
|
+
f2: <code data-testid="c2">{ //form-data/f2 }</code><br/>
|
|
139
|
+
f3: <code data-testid="c3">{/datadom/slice/signin-form/form-data/f3}</code><br/>
|
|
140
|
+
</form>
|
|
141
|
+
</template>
|
|
142
|
+
</custom-element>
|
|
143
|
+
\`
|
|
144
|
+
},
|
|
145
|
+
play: async ({
|
|
146
|
+
canvasElement
|
|
147
|
+
}) => {
|
|
148
|
+
const canvas = within(canvasElement);
|
|
149
|
+
await userEvent.type(canvas.getByTestId('input-1'), 'ABC');
|
|
150
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
151
|
+
await expect(await canvas.findByText('ABC')).toBeInTheDocument();
|
|
152
|
+
await userEvent.type(canvas.getByTestId('input-2'), 'DCE');
|
|
153
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
154
|
+
await expect(await canvas.findByText('DCE')).toBeInTheDocument();
|
|
155
|
+
await userEvent.type(canvas.getByTestId('input-3'), 'XYZ');
|
|
156
|
+
canvas.getByTestId('input-1').focus();
|
|
157
|
+
await expect(await canvas.findByText('XYZ')).toBeInTheDocument();
|
|
158
|
+
}
|
|
159
|
+
}`,...d.parameters?.docs?.source}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
|
|
160
|
+
args: {
|
|
161
|
+
title: 'setCustomValidity',
|
|
162
|
+
body: \`
|
|
163
|
+
<p><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity">setCustomValidity()</a>
|
|
164
|
+
invoked by <code>custom-validity</code> attribute. Type in the input fiels to observe the chars count in
|
|
165
|
+
text, click "next" and observe same message in dropdown.
|
|
166
|
+
</p>
|
|
167
|
+
<custom-element>
|
|
168
|
+
<template>
|
|
169
|
+
<form>
|
|
170
|
+
<input slice="s1" slice-event="input keyup" placeholder="type to see the custom error"
|
|
171
|
+
custom-validity=" concat( 'char count ', string-length(//s1) ) "
|
|
172
|
+
data-testid="input-1"/><br/>
|
|
173
|
+
s1: <code data-testid="c1">{ //s1 }</code><br/>
|
|
174
|
+
@validation-message: <var data-testid="validation-msg">{//s1/@validation-message}</var>
|
|
175
|
+
<button>next</button>
|
|
176
|
+
</form>
|
|
177
|
+
</template>
|
|
178
|
+
</custom-element>
|
|
179
|
+
\`
|
|
180
|
+
},
|
|
181
|
+
play: async ({
|
|
182
|
+
canvasElement
|
|
183
|
+
}) => {
|
|
184
|
+
const canvas = within(canvasElement);
|
|
185
|
+
await userEvent.type(canvas.getByTestId('input-1'), 'ABC');
|
|
186
|
+
await expect(canvas.getByText('ABC')).toBeInTheDocument();
|
|
187
|
+
await expect(canvas.getByText('char count 3')).toBeInTheDocument();
|
|
188
|
+
}
|
|
189
|
+
}`,...r.parameters?.docs?.source}}};c.parameters={...c.parameters,docs:{...c.parameters?.docs,source:{originalSource:`{
|
|
190
|
+
args: {
|
|
191
|
+
title: 'form custom-validity, boolean',
|
|
192
|
+
body: \`
|
|
193
|
+
<p> Form is valid only when input text length longer of 3 characters. </p>
|
|
194
|
+
<custom-element>
|
|
195
|
+
<template>
|
|
196
|
+
<form slice="form-1" custom-validity=" string-length(//form-1//f1) > 3 "
|
|
197
|
+
data-testid="form-1"
|
|
198
|
+
>
|
|
199
|
+
<input name="f1" data-testid="input-1"/><br/>
|
|
200
|
+
|
|
201
|
+
<input type="hidden" name="id" value="form--form-custom-validity-boolean"/>
|
|
202
|
+
<input type="hidden" name="viewMode" value="story"/>
|
|
203
|
+
//form-1//f1: <code data-testid="c1">{ //form-1//f1 }</code><br/>
|
|
204
|
+
<button>next</button>
|
|
205
|
+
</form>
|
|
206
|
+
</template>
|
|
207
|
+
</custom-element>
|
|
208
|
+
\`
|
|
209
|
+
},
|
|
210
|
+
play: async ({
|
|
211
|
+
canvasElement
|
|
212
|
+
}) => {
|
|
213
|
+
const canvas = within(canvasElement);
|
|
214
|
+
await userEvent.type(canvas.getByTestId('input-1'), 'AB');
|
|
215
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
216
|
+
await expect(canvas.getByText('AB')).toBeInTheDocument(); // i.e. not reloaded by form submit
|
|
217
|
+
}
|
|
218
|
+
}`,...c.parameters?.docs?.source}}};m.parameters={...m.parameters,docs:{...m.parameters?.docs,source:{originalSource:`{
|
|
219
|
+
args: {
|
|
220
|
+
title: 'form custom-validity, string',
|
|
221
|
+
body: \`
|
|
222
|
+
<p> Form is valid only when input text is longer of 3 characters, @validation-message propagated in form slot </p>
|
|
223
|
+
<custom-element>
|
|
224
|
+
<template>
|
|
225
|
+
<form slice="form-1"
|
|
226
|
+
custom-validity=" string-length(//form-1//f1) > 3 ?? concat('should be more than 3 characters, now is ',string-length(//form-1//f1) ) "
|
|
227
|
+
data-testid="form-1"
|
|
228
|
+
>
|
|
229
|
+
<input name="f1" data-testid="input-1"/><br/>
|
|
230
|
+
|
|
231
|
+
<input type="hidden" name="id" value="form--form-custom-validity-string"/>
|
|
232
|
+
<input type="hidden" name="viewMode" value="story"/>
|
|
233
|
+
//form-1//f1: <code data-testid="c1">{ //form-1//f1 }</code><br/>
|
|
234
|
+
//form-1/@validation-message: <code data-testid="c1">{ //@validation-message }</code><br/>
|
|
235
|
+
<button>next</button>
|
|
236
|
+
</form>
|
|
237
|
+
</template>
|
|
238
|
+
</custom-element>
|
|
239
|
+
\`
|
|
240
|
+
},
|
|
241
|
+
play: async ({
|
|
242
|
+
canvasElement
|
|
243
|
+
}) => {
|
|
244
|
+
const canvas = within(canvasElement);
|
|
245
|
+
await userEvent.type(canvas.getByTestId('input-1'), 'AB');
|
|
246
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
247
|
+
await expect(canvas.getByText('AB')).toBeInTheDocument(); // i.e. not reloaded by form submit
|
|
248
|
+
await expect(canvas.getByText('should be more than 3 characters, now is 2')).toBeInTheDocument();
|
|
249
|
+
}
|
|
250
|
+
}`,...m.parameters?.docs?.source}}};const f=["SystemMessage","FormData","SetValidityMessage","FormCustomValidityBoolean","FormCustomValidityString"];export{c as FormCustomValidityBoolean,m as FormCustomValidityString,d as FormData,r as SetValidityMessage,o as SystemMessage,f as __namedExportsOrder,y as default};
|