@epa-wg/custom-element-dist 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/coverage/coverage-final.json +15 -11
- package/coverage/index.html +25 -25
- 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 +604 -421
- package/coverage/src/custom-element/custom-element1-1.js/coverage.svg +10 -0
- package/coverage/src/custom-element/custom-element1-1.js.html +2374 -0
- package/coverage/src/custom-element/custom-element1.js/coverage.svg +10 -0
- package/coverage/src/custom-element/custom-element1.js.html +2374 -0
- package/coverage/src/custom-element/http-request.js.html +10 -10
- package/coverage/src/custom-element/index.html +49 -19
- package/coverage/src/custom-element/local-storage.js.html +6 -6
- package/coverage/src/custom-element/location-element.js.html +1 -1
- package/coverage/src/index.html +1 -1
- package/coverage/src/mocks/handlers.ts.html +1 -1
- package/coverage/src/mocks/index.html +1 -1
- package/coverage/src/stories/{attributes.stories.ts.html → attributes.test.stories.ts.html} +51 -15
- package/coverage/src/stories/{css.stories.ts.html → css.test.stories.ts.html} +77 -17
- package/coverage/src/stories/{dom-merge.stories.ts.html → dom-merge.test.stories.ts.html} +60 -12
- package/coverage/src/stories/{external-template.stories.ts.html → external-template.test.stories.ts.html} +42 -12
- package/coverage/src/stories/form.test.stories.ts.html +658 -0
- package/coverage/src/stories/http-request.stories.ts.html +7 -7
- package/coverage/src/stories/index.html +71 -41
- package/coverage/src/stories/{local-storage.stories.ts.html → local-storage.test.stories.ts.html} +56 -20
- package/coverage/src/stories/{location-element.stories.ts.html → location-element.test.stories.ts.html} +53 -17
- package/coverage/src/stories/renderPlay.ts.html +12 -15
- package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/{slice-events.stories.ts.html → slice-events.test.stories.ts.html} +264 -15
- package/coverage/src/stories/slots.test.stories.ts/coverage.svg +10 -0
- package/coverage/src/stories/slots.test.stories.ts.html +739 -0
- 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/custom-element1-1.js +763 -0
- package/src/custom-element/custom-element1.js +763 -0
- package/src/custom-element/custom-element1.js0 +750 -0
- package/src/custom-element/custom-element2.js0 +759 -0
- package/src/custom-element/custom-element3.js0 +763 -0
- 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 +193 -0
- package/src/custom-element/demo/s.xml +19 -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 -7
- package/src/stories/{css.stories.ts → css.test.stories.ts} +29 -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 +191 -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/renderPlay.ts +1 -2
- package/src/stories/{slice-events.stories.ts → slice-events.test.stories.ts} +88 -5
- package/src/stories/slots.test.stories.ts +218 -0
- package/storybook-static/assets/{Color-RQJUDNI5-C4yZhNbM.js → Color-PRSJMWNM-e4s261EJ.js} +1 -1
- package/storybook-static/assets/{Configure-C7d36rng.js → Configure-DWut7txe.js} +1 -1
- package/storybook-static/assets/DocsRenderer-K4EAMTCU-CaXVGjCl.js +2 -0
- package/storybook-static/assets/WithTooltip-KJL26V4Q--B8vdnMi.js +1 -0
- package/storybook-static/assets/{attributes.stories-ZB0RTY1d.js → attributes.test.stories-IuwazrdL.js} +21 -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-SJtgH3vM.js} +5 -5
- package/storybook-static/assets/http-request.stories-8K_qSs8C.js +300 -0
- package/storybook-static/assets/iframe-CM82WlGY.js +2 -0
- package/storybook-static/assets/index-CEZitmnt.js +548 -0
- package/storybook-static/assets/index-CVRyq5ci.js +27 -0
- package/storybook-static/assets/{index-DnEJ_bKa.js → index-D1MP-Zis.js} +1 -1
- package/storybook-static/assets/index-DNL-IEpS.js +1 -0
- package/storybook-static/assets/index-DXimoRZY.js +1 -0
- 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-CkgAD_DE.js → preview-5Y0XiZgz.js} +2 -2
- package/storybook-static/assets/preview-BKCN0mOr.js +1 -0
- 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-BWFH_0wQ.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/vite.config.js +5 -5
- 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/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 → attributes.test.stories.ts}/coverage.svg +0 -0
- /package/coverage/src/stories/{css.stories.ts → css.test.stories.ts}/coverage.svg +0 -0
- /package/coverage/src/stories/{dom-merge.stories.ts → dom-merge.test.stories.ts}/coverage.svg +0 -0
- /package/coverage/src/stories/{external-template.stories.ts → external-template.test.stories.ts}/coverage.svg +0 -0
- /package/coverage/src/stories/{local-storage.stories.ts → form.test.stories.ts}/coverage.svg +0 -0
- /package/coverage/src/stories/{location-element.stories.ts → local-storage.test.stories.ts}/coverage.svg +0 -0
- /package/coverage/src/stories/{slice-events.stories.ts → location-element.test.stories.ts}/coverage.svg +0 -0
|
@@ -1,63 +1,60 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
3
|
-
xmlns:html="http://www.w3.org/1999/xhtml">
|
|
2
|
+
<html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
|
4
3
|
<head>
|
|
5
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
6
|
-
<title>
|
|
5
|
+
<title>Data slices - Declarative Custom Element implementation demo</title>
|
|
7
6
|
<link rel="icon" href="./wc-square.svg"/>
|
|
7
|
+
|
|
8
8
|
<script type="module" src="../http-request.js"></script>
|
|
9
|
-
<script type="module" src="../local-storage.js"></script>
|
|
10
9
|
<script type="module" src="../custom-element.js"></script>
|
|
11
|
-
|
|
12
10
|
<style>
|
|
13
11
|
@import "./demo.css";
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
table {
|
|
20
|
-
min-width: 16rem;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
td {
|
|
24
|
-
border-bottom: 1px solid silver;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
tfoot td {
|
|
28
|
-
border-bottom: none;
|
|
13
|
+
label {
|
|
14
|
+
display: flex;
|
|
29
15
|
}
|
|
30
16
|
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
label:has(input[type="text"],input[type="password"],input:not([type]) ) {
|
|
18
|
+
flex-direction: column;
|
|
33
19
|
}
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
font-weight: bolder;
|
|
38
|
-
font-family: sans-serif;
|
|
21
|
+
nav {
|
|
22
|
+
max-width: 32em;
|
|
39
23
|
}
|
|
40
24
|
</style>
|
|
25
|
+
<!-- https://github.com/mdn/learning-area/blob/main/html/forms/form-validation/custom-error-message.html
|
|
26
|
+
todo: apply setCustomValidity( warningStr )
|
|
27
|
+
-->
|
|
28
|
+
|
|
41
29
|
</head>
|
|
42
30
|
<body>
|
|
43
31
|
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
<fieldset>
|
|
33
|
+
<legend><b style="color:green">green</b> in instance style can be overridden in payload as <i
|
|
34
|
+
style="color:red">red</i> in 1st instance
|
|
35
|
+
</legend>
|
|
36
|
+
<custom-element tag="dce-3">
|
|
37
|
+
<template>
|
|
38
|
+
<u>
|
|
39
|
+
<slot>is green</slot>
|
|
40
|
+
</u>
|
|
52
41
|
</template>
|
|
42
|
+
<style>dce-3 {
|
|
43
|
+
color: green
|
|
44
|
+
}</style>
|
|
53
45
|
</custom-element>
|
|
54
|
-
<
|
|
55
|
-
<dce-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
</
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
46
|
+
<u>should be</u> <i style="color:red">red</i>:
|
|
47
|
+
<dce-3 id="dce32">
|
|
48
|
+
<template>
|
|
49
|
+
<style> color:red; </style>
|
|
50
|
+
<u>red</u>
|
|
51
|
+
</template>
|
|
52
|
+
</dce-3> <br/>
|
|
53
|
+
should be GREEN:
|
|
54
|
+
<dce-3 id="dce31">green</dce-3>
|
|
55
|
+
</fieldset>
|
|
56
|
+
|
|
57
|
+
<script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
|
|
58
|
+
|
|
62
59
|
</body>
|
|
63
60
|
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<dce-root data-dce-id="1" xmlns="http://www.w3.org/1999/xhtml" xmlns:dce="urn:schemas-epa-wg:dce"
|
|
3
|
+
xmlns:xhtml="http://www.w3.org/1999/xhtml"><u data-dce-id="2" xmlns="">
|
|
4
|
+
<dce-text data-dce-id="3">
|
|
5
|
+
<xhtml:span xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot=""/>
|
|
6
|
+
<xhtml:style xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot="" title="ABC">
|
|
7
|
+
dce-3[data-dce-style="54f96d52-ce70-435d-83c4-b421357d9a17"]{ color:red; }
|
|
8
|
+
</xhtml:style>
|
|
9
|
+
<xhtml:span xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot=""/>
|
|
10
|
+
<xhtml:u xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot="">red</xhtml:u>
|
|
11
|
+
<xhtml:span xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot=""/>
|
|
12
|
+
</dce-text>
|
|
13
|
+
</u></dce-root>
|
|
@@ -178,6 +178,38 @@
|
|
|
178
178
|
</template>
|
|
179
179
|
</html-demo-element>
|
|
180
180
|
|
|
181
|
+
|
|
182
|
+
<html-demo-element legend="10. multiple slices by same field"
|
|
183
|
+
description="same element value sets s1 and s2 slice">
|
|
184
|
+
<template>
|
|
185
|
+
<custom-element>
|
|
186
|
+
<template>
|
|
187
|
+
<input slice="s1|s2"
|
|
188
|
+
slice-event="input"
|
|
189
|
+
data-testid="f1"
|
|
190
|
+
/><br/>
|
|
191
|
+
Type to update s1 and s2 slices <br/>
|
|
192
|
+
slice <code>s1: {//slice/s1}</code><br/>
|
|
193
|
+
slice <code>s2: {//slice/s2}</code><br/>
|
|
194
|
+
</template>
|
|
195
|
+
</custom-element>
|
|
196
|
+
</template>
|
|
197
|
+
</html-demo-element>
|
|
198
|
+
|
|
199
|
+
<html-demo-element legend="11. slices and attribute"
|
|
200
|
+
description="initial attribute value should be smile as emoji and :) on blur from input it should be updated from value">
|
|
201
|
+
<template>
|
|
202
|
+
<custom-element>
|
|
203
|
+
<template>
|
|
204
|
+
<attribute name="emotion">😃</attribute>
|
|
205
|
+
<input slice="/datadom/attributes/emotion | s1"/>
|
|
206
|
+
Type and unfocus to update emotion attribute: {emotion}
|
|
207
|
+
and slice: {//slice/s1}
|
|
208
|
+
</template>
|
|
209
|
+
</custom-element>
|
|
210
|
+
</template>
|
|
211
|
+
</html-demo-element>
|
|
212
|
+
|
|
181
213
|
<script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
|
|
182
214
|
|
|
183
215
|
</body>
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
5
|
+
<title>Forms - Declarative Custom Element implementation demo</title>
|
|
6
|
+
<link rel="icon" href="./wc-square.svg"/>
|
|
7
|
+
|
|
8
|
+
<script type="module" src="../local-storage.js"></script>
|
|
9
|
+
<script type="module" src="../custom-element.js"></script>
|
|
10
|
+
<style>
|
|
11
|
+
@import "./demo.css";
|
|
12
|
+
label{ display: flex; }
|
|
13
|
+
label:has(input[type="text"],input[type="password"],input:not([type]) ){flex-direction: column;}
|
|
14
|
+
nav{ max-width: 32em; }
|
|
15
|
+
</style>
|
|
16
|
+
<!-- https://github.com/mdn/learning-area/blob/main/html/forms/form-validation/custom-error-message.html
|
|
17
|
+
todo: apply setCustomValidity( warningStr )
|
|
18
|
+
-->
|
|
19
|
+
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
|
|
23
|
+
<nav>
|
|
24
|
+
<a href="../index.html"><h3><code>custom-element</code> demo</h3></a>
|
|
25
|
+
<h3>Forms handling.</h3>
|
|
26
|
+
<ul>
|
|
27
|
+
<li> The form triggers re-render on <code>change</code> event before submit</li>
|
|
28
|
+
<li> <code>disabled</code> form attribute is added when validation is not passed </li>
|
|
29
|
+
<li> Form action triggered on submit changing the hash in URL </li>
|
|
30
|
+
<li> URL hash hides the <var>signin</var> form from DOM and shown <var>signout</var> form </li>
|
|
31
|
+
<li> signout action reverse visibility of signin and signout </li>
|
|
32
|
+
<li> "remember" checkbox triggers <code>local-storage</code> with value set from <var>form-data/remember</var> slice </li>
|
|
33
|
+
<li> "username" initial value taken from <code>local-storage</code> <var>usernane</var> slice </li>
|
|
34
|
+
<li> <a href="https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation">Form Validation - MDN</a> </li>
|
|
35
|
+
</ul>
|
|
36
|
+
</nav>
|
|
37
|
+
|
|
38
|
+
<html-demo-element legend="1. Simple validation"
|
|
39
|
+
description="custom-validity boolean value prevents submission, username length switches Next to 'Sign In' button ">
|
|
40
|
+
<ol>
|
|
41
|
+
<li> Click Next, observe the warning </li>
|
|
42
|
+
<li> Fill input with 10+ characters </li>
|
|
43
|
+
<li> Click Next, the password and "Sign In" button should appear </li>
|
|
44
|
+
</ol>
|
|
45
|
+
<template>
|
|
46
|
+
<custom-element>
|
|
47
|
+
<template>
|
|
48
|
+
<form slice="signin-form"
|
|
49
|
+
custom-validity="
|
|
50
|
+
string-length(/datadom/slice/signin-form/form-data/username) > 10
|
|
51
|
+
and string-length(//form-data/password) > 3 "
|
|
52
|
+
>
|
|
53
|
+
<label> Email
|
|
54
|
+
<input name="username" autocomplete="username" placeholder="Email, phone, or username" required="">
|
|
55
|
+
</label>
|
|
56
|
+
<variable name="showpassword" select="string-length(//form-data/username) > 10 "></variable>
|
|
57
|
+
<if test="not($showpassword)">
|
|
58
|
+
<button slice="confirm" slice-event="click" slice-value="'password'">Next</button>
|
|
59
|
+
</if>
|
|
60
|
+
<if test="$showpassword">
|
|
61
|
+
<label>Enter password: <input name="password" type="password" required> </label>
|
|
62
|
+
<button>Sign In</button>
|
|
63
|
+
</if>
|
|
64
|
+
username {//username}
|
|
65
|
+
</form>
|
|
66
|
+
</template>
|
|
67
|
+
</custom-element>
|
|
68
|
+
</template>
|
|
69
|
+
</html-demo-element>
|
|
70
|
+
|
|
71
|
+
<html-demo-element legend="2. Form life cycle demo"
|
|
72
|
+
description="form-data in the form slice is the source of truth" >
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<custom-element>
|
|
76
|
+
<template>
|
|
77
|
+
<form slice="signin-form"
|
|
78
|
+
custom-validity="
|
|
79
|
+
string-length(/datadom/slice/signin-form/form-data/username) > 9
|
|
80
|
+
and ( ( //confirm-by = 'sms' )
|
|
81
|
+
or ( //confirm-by = 'email' )
|
|
82
|
+
or ( //confirm-by = 'password' and string-length(//form-data/password) > 3 )
|
|
83
|
+
)
|
|
84
|
+
"
|
|
85
|
+
>
|
|
86
|
+
<!-- form validity should be based on form-data -->
|
|
87
|
+
<variable name="warn">
|
|
88
|
+
<if test="string-length(//username-slice) < 9 ">
|
|
89
|
+
Should be 10 or more symbols.
|
|
90
|
+
<!-- updated by slice on input event -->
|
|
91
|
+
</if>
|
|
92
|
+
<if test="//form-data/confirm-by = 'sms'">
|
|
93
|
+
Message and Data Rates may apply.
|
|
94
|
+
<!-- updated by form change by radio select -->
|
|
95
|
+
</if>
|
|
96
|
+
</variable>
|
|
97
|
+
<label> Enter your email, phone, or user name
|
|
98
|
+
<input name="username" autocomplete="username"
|
|
99
|
+
placeholder="Email, phone, or username"
|
|
100
|
+
custom-validity="( string-length(//username-slice) > 9 ) ?? 'should be 10+ symbols'"
|
|
101
|
+
slice-event="input"
|
|
102
|
+
slice="username-slice"
|
|
103
|
+
required
|
|
104
|
+
/>
|
|
105
|
+
</label>
|
|
106
|
+
<var> {$warn} </var>
|
|
107
|
+
<fieldset>
|
|
108
|
+
<legend>Confirm by</legend>
|
|
109
|
+
<label><input type="radio" name="confirm-by" value="email" /> email </label>
|
|
110
|
+
<label><input type="radio" name="confirm-by" value="sms" /> text to phone </label>
|
|
111
|
+
<label><input type="radio" name="confirm-by" value="password" /> password </label>
|
|
112
|
+
<if test="/datadom/slice/signin-form/form-data/confirm-by = 'password'">
|
|
113
|
+
<label>Enter password: <input type="password" NAME="password"
|
|
114
|
+
custom-validity="( string-length(//form-data/password) > 3 ) ?? 'password is too short'"
|
|
115
|
+
/></label>
|
|
116
|
+
</if>
|
|
117
|
+
<if test="not(//confirm-by)">
|
|
118
|
+
Please select the auth method
|
|
119
|
+
</if>
|
|
120
|
+
</fieldset>
|
|
121
|
+
<section>
|
|
122
|
+
<button>Sign In</button>
|
|
123
|
+
</section>
|
|
124
|
+
</form>
|
|
125
|
+
//username-slice {//username-slice}<br/>
|
|
126
|
+
//username {//username}<br/>
|
|
127
|
+
//confirm-by {//confirm-by}<br/>
|
|
128
|
+
//password {//password}
|
|
129
|
+
</template>
|
|
130
|
+
</custom-element>
|
|
131
|
+
</template>
|
|
132
|
+
</html-demo-element>
|
|
133
|
+
|
|
134
|
+
<html-demo-element legend="3. read system validity message"
|
|
135
|
+
description="validationMessage propagated into slice as 'validation-message' attribute ">
|
|
136
|
+
<ol>
|
|
137
|
+
<li> type in input field</li>
|
|
138
|
+
<li> delete input field content</li>
|
|
139
|
+
<li> observe the warning in string bellow input</li>
|
|
140
|
+
<li> Click Next observe the system warning in dropdown and in string bellow input</li>
|
|
141
|
+
</ol>
|
|
142
|
+
<template>
|
|
143
|
+
<custom-element>
|
|
144
|
+
<template>
|
|
145
|
+
<form slice="email-form">
|
|
146
|
+
<label> Email
|
|
147
|
+
<input slice="username" slice-event="input" placeholder="non-empty" required>
|
|
148
|
+
</label>
|
|
149
|
+
<if test="//username/@validation-message">
|
|
150
|
+
<var>{//username/@validation-message}</var>
|
|
151
|
+
</if>
|
|
152
|
+
<button>Next</button>
|
|
153
|
+
<p>{//email-form/@validation-message}</p>
|
|
154
|
+
</form>
|
|
155
|
+
</template>
|
|
156
|
+
</custom-element>
|
|
157
|
+
</template>
|
|
158
|
+
</html-demo-element>
|
|
159
|
+
|
|
160
|
+
<html-demo-element legend="4. form validity message"
|
|
161
|
+
description="@validation-message propagated into form slice and ">
|
|
162
|
+
<ol>
|
|
163
|
+
<li> type up to 3 chars in input field </li>
|
|
164
|
+
<li> observe the slice value change </li>
|
|
165
|
+
<li> click next </li>
|
|
166
|
+
<li> observe the warning bellow the button </li>
|
|
167
|
+
</ol>
|
|
168
|
+
<template>
|
|
169
|
+
<custom-element>
|
|
170
|
+
<template>
|
|
171
|
+
<form slice="email-form"
|
|
172
|
+
custom-validity=" string-length(//slice/username) > 3 ??
|
|
173
|
+
concat('should be more than 3 characters, now is ',string-length(//slice/username) ) "
|
|
174
|
+
>
|
|
175
|
+
<label> Email
|
|
176
|
+
<input name="email" slice="username" slice-event="input" placeholder="non-empty" required />
|
|
177
|
+
</label>
|
|
178
|
+
<if test="//username/@validation-message">
|
|
179
|
+
<var>{//username/@validation-message}</var>
|
|
180
|
+
</if>
|
|
181
|
+
<button>Next</button>
|
|
182
|
+
<p>//email-form/@validation-message: {//email-form/@validation-message} </p>
|
|
183
|
+
<p>//slice/username: {//slice/username} </p>
|
|
184
|
+
</form>
|
|
185
|
+
</template>
|
|
186
|
+
</custom-element>
|
|
187
|
+
</template>
|
|
188
|
+
</html-demo-element>
|
|
189
|
+
|
|
190
|
+
<script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
|
|
191
|
+
|
|
192
|
+
</body>
|
|
193
|
+
</html>
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<datadom xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
3
|
+
xmlns:dce="urn:schemas-epa-wg:dce">
|
|
4
|
+
<payload>
|
|
5
|
+
<xhtml:span slot=""></xhtml:span>
|
|
6
|
+
<xhtml:style slot="" title="ABC">dce-3[data-dce-style="54f96d52-ce70-435d-83c4-b421357d9a17"]{ color:red; }</xhtml:style>
|
|
7
|
+
<xhtml:span slot=""></xhtml:span>
|
|
8
|
+
<xhtml:u slot="">red</xhtml:u>
|
|
9
|
+
<xhtml:span slot=""></xhtml:span>
|
|
10
|
+
</payload>
|
|
11
|
+
<attributes>
|
|
12
|
+
<id>dce32</id>
|
|
13
|
+
<data-dce-style>54f96d52-ce70-435d-83c4-b421357d9a17</data-dce-style>
|
|
14
|
+
</attributes>
|
|
15
|
+
<dataset>
|
|
16
|
+
<dceStyle>54f96d52-ce70-435d-83c4-b421357d9a17</dceStyle>
|
|
17
|
+
</dataset>
|
|
18
|
+
<slice/>
|
|
19
|
+
</datadom>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
1
2
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
2
3
|
xmlns:dce="urn:schemas-epa-wg:dce" xmlns:exsl="http://exslt.org/common" version="1.0"
|
|
3
4
|
exclude-result-prefixes="exsl">
|
|
@@ -14,56 +15,39 @@
|
|
|
14
15
|
</xsl:template>
|
|
15
16
|
<xsl:template mode="payload" match="attributes">
|
|
16
17
|
<dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" data-dce-id="1">
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<button xmlns="" data-dce-id="5">
|
|
28
|
-
<xsl:value-of select="@name">
|
|
29
|
-
</xsl:value-of>
|
|
30
|
-
</button>
|
|
31
|
-
</xsl:for-each>
|
|
32
|
-
<xsl:for-each xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="//slice/s/value/*">
|
|
33
|
-
<ul xmlns="" data-dce-id="6">
|
|
34
|
-
<var data-testid="request-section" data-dce-id="7">
|
|
35
|
-
<dce-text data-dce-id="8">
|
|
36
|
-
<xsl:value-of select="name(.)"/>
|
|
37
|
-
</dce-text>
|
|
38
|
-
</var>
|
|
39
|
-
<xsl:for-each select="@*">
|
|
40
|
-
<div data-dce-id="9">
|
|
41
|
-
<var data-dce-id="10">@<xsl:value-of select="local-name(.)"/>
|
|
42
|
-
</var>
|
|
43
|
-
<dce-text data-dce-id="11">
|
|
44
|
-
=
|
|
45
|
-
</dce-text>
|
|
46
|
-
<code data-testid="attr-{local-name(.)}" data-dce-id="12">
|
|
47
|
-
<xsl:value-of select="."/>
|
|
48
|
-
</code>
|
|
49
|
-
</div>
|
|
50
|
-
</xsl:for-each>
|
|
51
|
-
</ul>
|
|
52
|
-
</xsl:for-each>
|
|
18
|
+
<u xmlns="" data-dce-id="2">
|
|
19
|
+
<dce-text data-dce-id="3">
|
|
20
|
+
<xsl:call-template name="slot">
|
|
21
|
+
<xsl:with-param name="slotname" select="''"/>
|
|
22
|
+
<xsl:with-param name="defaultvalue">
|
|
23
|
+
<dce-text xmlns="" data-dce-id="4">is green</dce-text>
|
|
24
|
+
</xsl:with-param>
|
|
25
|
+
</xsl:call-template>
|
|
26
|
+
</dce-text>
|
|
27
|
+
</u>
|
|
53
28
|
</dce-root>
|
|
54
29
|
</xsl:template>
|
|
55
30
|
<xsl:template match="/">
|
|
56
31
|
<xsl:apply-templates mode="payload" select="/datadom/attributes"/>
|
|
57
32
|
</xsl:template>
|
|
33
|
+
|
|
34
|
+
<xsl:template match="@*|node()" mode="copy-html">
|
|
35
|
+
<xsl:copy><xsl:apply-templates select="@*|node()" mode="copy-html"/></xsl:copy>
|
|
36
|
+
</xsl:template>
|
|
37
|
+
<xsl:template match="node()[starts-with(name(),'xhtml:')]" mode="copy-html">
|
|
38
|
+
<xsl:element name="{local-name()}"><xsl:apply-templates select="@*|node()" mode="copy-html"/></xsl:element>
|
|
39
|
+
</xsl:template>
|
|
40
|
+
|
|
41
|
+
|
|
58
42
|
<xsl:template name="slot">
|
|
59
43
|
<xsl:param name="slotname"/>
|
|
60
44
|
<xsl:param name="defaultvalue"/>
|
|
61
45
|
<xsl:choose>
|
|
62
46
|
<xsl:when test="//payload/*[@slot=$slotname]">
|
|
63
|
-
<xsl:copy-
|
|
47
|
+
<xsl:apply-templates mode="copy-html" select="//payload/*[@slot=$slotname]"/>
|
|
64
48
|
</xsl:when>
|
|
65
49
|
<xsl:otherwise>
|
|
66
|
-
<xsl:copy-
|
|
50
|
+
<xsl:apply-templates mode="copy-html" select="$defaultvalue"/>
|
|
67
51
|
</xsl:otherwise>
|
|
68
52
|
</xsl:choose>
|
|
69
53
|
</xsl:template>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
3
|
+
xmlns:dce="urn:schemas-epa-wg:dce" xmlns:exsl="http://exslt.org/common" version="1.0"
|
|
4
|
+
exclude-result-prefixes="exsl">
|
|
5
|
+
<xsl:template match="ignore">
|
|
6
|
+
<xsl:choose>
|
|
7
|
+
<xsl:when test="//attr">
|
|
8
|
+
<xsl:value-of select="//attr"/>
|
|
9
|
+
</xsl:when>
|
|
10
|
+
<xsl:otherwise>
|
|
11
|
+
<xsl:value-of select="def"/>
|
|
12
|
+
</xsl:otherwise>
|
|
13
|
+
</xsl:choose>
|
|
14
|
+
<xsl:value-of select="."/>
|
|
15
|
+
</xsl:template>
|
|
16
|
+
<xsl:template mode="payload" match="attributes">
|
|
17
|
+
<dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" data-dce-id="1">
|
|
18
|
+
<u xmlns="" data-dce-id="2">
|
|
19
|
+
<dce-text data-dce-id="3">
|
|
20
|
+
<xsl:call-template name="slot">
|
|
21
|
+
<xsl:with-param name="slotname" select="''"/>
|
|
22
|
+
<xsl:with-param name="defaultvalue">
|
|
23
|
+
<dce-text xmlns="" data-dce-id="4">is green</dce-text>
|
|
24
|
+
</xsl:with-param>
|
|
25
|
+
</xsl:call-template>
|
|
26
|
+
</dce-text>
|
|
27
|
+
</u>
|
|
28
|
+
</dce-root>
|
|
29
|
+
</xsl:template>
|
|
30
|
+
<xsl:template match="/">
|
|
31
|
+
<xsl:apply-templates mode="payload" select="/datadom/attributes"/>
|
|
32
|
+
</xsl:template>
|
|
33
|
+
|
|
34
|
+
<xsl:template match="@*|node()" mode="copy-html">
|
|
35
|
+
<xsl:copy><xsl:apply-templates select="@*|node()" mode="copy-html"/></xsl:copy>
|
|
36
|
+
</xsl:template>
|
|
37
|
+
<xsl:template match="node()[starts-with(name(),'xhtml:')]" mode="copy-html">
|
|
38
|
+
<xsl:element name="{local-name()}"><xsl:apply-templates select="@*|node()" mode="copy-html"/></xsl:element>
|
|
39
|
+
</xsl:template>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
<xsl:template name="slot">
|
|
43
|
+
<xsl:param name="slotname"/>
|
|
44
|
+
<xsl:param name="defaultvalue"/>
|
|
45
|
+
<xsl:choose>
|
|
46
|
+
<xsl:when test="//payload/*[@slot=$slotname]">
|
|
47
|
+
<xsl:apply-templates mode="copy-html" select="//payload/*[@slot=$slotname]"/>
|
|
48
|
+
</xsl:when>
|
|
49
|
+
<xsl:otherwise>
|
|
50
|
+
<xsl:apply-templates mode="copy-html" select="$defaultvalue"/>
|
|
51
|
+
</xsl:otherwise>
|
|
52
|
+
</xsl:choose>
|
|
53
|
+
</xsl:template>
|
|
54
|
+
<xsl:variable name="js-injected-body">
|
|
55
|
+
<xsl:call-template name="slot">
|
|
56
|
+
<xsl:with-param name="slotname" select="''"/>
|
|
57
|
+
<xsl:with-param name="defaultvalue"/>
|
|
58
|
+
</xsl:call-template>
|
|
59
|
+
</xsl:variable>
|
|
60
|
+
</xsl:stylesheet>
|
|
@@ -27,6 +27,19 @@
|
|
|
27
27
|
}
|
|
28
28
|
]
|
|
29
29
|
},
|
|
30
|
+
{
|
|
31
|
+
"name": "custom-validity",
|
|
32
|
+
"description": {
|
|
33
|
+
"kind": "markdown",
|
|
34
|
+
"value": "XPath expression to return either boolean or error string to be shown by browser native UI on form validation event. Unless value is true, prevents the form submission."
|
|
35
|
+
},
|
|
36
|
+
"references": [
|
|
37
|
+
{
|
|
38
|
+
"name": "Demo",
|
|
39
|
+
"url": "https://unpkg.com/@epa-wg/custom-element/demo/form.html"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
30
43
|
{
|
|
31
44
|
"name": "slice-value",
|
|
32
45
|
"description": {
|
|
@@ -109,4 +122,4 @@
|
|
|
109
122
|
]
|
|
110
123
|
}
|
|
111
124
|
]
|
|
112
|
-
}
|
|
125
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@epa-wg/custom-element",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.22",
|
|
5
5
|
"js-types-syntax": "typescript",
|
|
6
6
|
"description-markup": "markdown",
|
|
7
7
|
"contributions": {
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"description": "Defines the event name on which `value` would be synchronized with DCE slice\n\nOn: any component with `value` and associated change event",
|
|
18
18
|
"doc-url": "https://unpkg.com/@epa-wg/custom-element/demo/dom-merge.html"
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
"name": "custom-validity",
|
|
22
|
+
"description": "XPath expression to return either boolean or error string to be shown by browser native UI on form validation event. Unless value is true, prevents the form submission.",
|
|
23
|
+
"doc-url": "https://unpkg.com/@epa-wg/custom-element/demo/form.html"
|
|
24
|
+
},
|
|
20
25
|
{
|
|
21
26
|
"name": "slice-value",
|
|
22
27
|
"description": "XPath expression to populate into the slice",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
<a href="./demo/scoped-css.html" >scoped CSS </a> |
|
|
36
36
|
<a href="./demo/parameters.html" >attributes </a> |
|
|
37
37
|
<a href="./demo/data-slices.html" >data slices/events </a> |
|
|
38
|
+
<a href="./demo/form.html" >Form validation </a> |
|
|
38
39
|
<a href="./demo/dom-merge.html" >DOM merge on dynamic update </a>
|
|
39
40
|
</section>
|
|
40
41
|
</nav>
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {expect, test} from 'vitest'
|
|
2
|
+
import {deepEqual, xml2dom, xmlString, obj2node } from './custom-element/custom-element.js'
|
|
3
3
|
|
|
4
|
-
test('deepEqual', () =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
test('deepEqual', () =>
|
|
5
|
+
{
|
|
6
|
+
expect(deepEqual(1, 1)).toBe(true);
|
|
7
|
+
expect(deepEqual({}, null)).toBe(false);
|
|
8
|
+
expect(deepEqual({a: 1}, {a: 1, b: 2})).toBe(false);
|
|
9
|
+
expect(deepEqual({a: 1}, {a: 2})).toBe(false);
|
|
10
|
+
expect(deepEqual({a: 1}, {a: 1})).toBe(true);
|
|
11
|
+
})
|
|
12
|
+
test('xml2dom', () =>
|
|
13
|
+
{
|
|
14
|
+
const dom = xml2dom('<a/>');
|
|
15
|
+
expect(dom.documentElement.localName).to.equal('a');
|
|
16
|
+
expect(dom.documentElement.childNodes.length).to.equal(0);
|
|
17
|
+
const xStr = xmlString(dom);
|
|
18
|
+
expect(xStr).to.include('<a');
|
|
19
|
+
})
|
|
20
|
+
test('obj2node', () =>
|
|
21
|
+
{
|
|
22
|
+
expect(obj2node(()=>{} , 'f',document).outerHTML).to.equal('<f></f>' );
|
|
23
|
+
expect(obj2node(9 , 'a',document).outerHTML).to.equal('<a>9</a>' );
|
|
24
|
+
expect(obj2node('abc' , 's',document).outerHTML).to.equal('<s>abc</s>' );
|
|
25
|
+
expect(obj2node({a:1,b:{c:'abc'}} , 's',document).outerHTML).to.equal('<s a="1"><b c="abc"></b></s>');
|
|
10
26
|
})
|