@epa-wg/custom-element-dist 0.0.1

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.
Files changed (284) hide show
  1. package/.editorconfig +11 -0
  2. package/.gitignore +26 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/compiler.xml +6 -0
  5. package/.idea/custom-element-dist.iml +13 -0
  6. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  7. package/.idea/misc.xml +6 -0
  8. package/.idea/modules.xml +8 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/.storybook/main.ts +21 -0
  11. package/.storybook/preview.ts +17 -0
  12. package/.vscode/settings.json +24 -0
  13. package/LICENSE +201 -0
  14. package/README.md +32 -0
  15. package/bin/build.sh +8 -0
  16. package/bin/clean.sh +5 -0
  17. package/bin/postinstall.sh +17 -0
  18. package/bin/start.sh +2 -0
  19. package/coverage/base.css +224 -0
  20. package/coverage/block-navigation.js +87 -0
  21. package/coverage/coverage-final.json +16 -0
  22. package/coverage/favicon.png +0 -0
  23. package/coverage/index.html +161 -0
  24. package/coverage/prettify.css +1 -0
  25. package/coverage/prettify.js +2 -0
  26. package/coverage/sort-arrow-sprite.png +0 -0
  27. package/coverage/sorter.js +196 -0
  28. package/coverage/src/coverage.svg +10 -0
  29. package/coverage/src/custom-element/coverage.svg +10 -0
  30. package/coverage/src/custom-element/custom-element.js/coverage.svg +10 -0
  31. package/coverage/src/custom-element/custom-element.js.html +2149 -0
  32. package/coverage/src/custom-element/http-request.js/coverage.svg +10 -0
  33. package/coverage/src/custom-element/http-request.js.html +352 -0
  34. package/coverage/src/custom-element/index.html +161 -0
  35. package/coverage/src/custom-element/local-storage.js/coverage.svg +10 -0
  36. package/coverage/src/custom-element/local-storage.js.html +346 -0
  37. package/coverage/src/custom-element/location-element.js/coverage.svg +10 -0
  38. package/coverage/src/custom-element/location-element.js.html +343 -0
  39. package/coverage/src/index.html +116 -0
  40. package/coverage/src/mocks/coverage.svg +10 -0
  41. package/coverage/src/mocks/handlers.ts/coverage.svg +10 -0
  42. package/coverage/src/mocks/handlers.ts.html +172 -0
  43. package/coverage/src/mocks/index.html +116 -0
  44. package/coverage/src/stories/attributes.stories.ts/coverage.svg +10 -0
  45. package/coverage/src/stories/attributes.stories.ts.html +481 -0
  46. package/coverage/src/stories/coverage.svg +10 -0
  47. package/coverage/src/stories/css.stories.ts/coverage.svg +10 -0
  48. package/coverage/src/stories/css.stories.ts.html +397 -0
  49. package/coverage/src/stories/dom-merge.stories.ts/coverage.svg +10 -0
  50. package/coverage/src/stories/dom-merge.stories.ts.html +424 -0
  51. package/coverage/src/stories/external-template.stories.ts/coverage.svg +10 -0
  52. package/coverage/src/stories/external-template.stories.ts.html +820 -0
  53. package/coverage/src/stories/http-request.stories.ts/coverage.svg +10 -0
  54. package/coverage/src/stories/http-request.stories.ts.html +817 -0
  55. package/coverage/src/stories/index.html +236 -0
  56. package/coverage/src/stories/local-storage.stories.ts/coverage.svg +10 -0
  57. package/coverage/src/stories/local-storage.stories.ts.html +1249 -0
  58. package/coverage/src/stories/location-element.stories.ts/coverage.svg +10 -0
  59. package/coverage/src/stories/location-element.stories.ts.html +484 -0
  60. package/coverage/src/stories/renderPlay.ts/coverage.svg +10 -0
  61. package/coverage/src/stories/renderPlay.ts.html +151 -0
  62. package/coverage/src/stories/slice-events.stories.ts/coverage.svg +10 -0
  63. package/coverage/src/stories/slice-events.stories.ts.html +436 -0
  64. package/coverage/src/sum.ts/coverage.svg +10 -0
  65. package/coverage/src/sum.ts.html +94 -0
  66. package/dist/confused.svg +37 -0
  67. package/dist/custom-element-B4v-KaIh.cjs +53 -0
  68. package/dist/custom-element-_g0GTup2.js +436 -0
  69. package/dist/custom-element-bundle.cjs +1 -0
  70. package/dist/custom-element-bundle.js +31 -0
  71. package/dist/embed-1.html +3 -0
  72. package/dist/html-template.html +126 -0
  73. package/dist/html-template.xhtml +45 -0
  74. package/dist/html-template.xml +45 -0
  75. package/dist/http-request-BOvP4KTl.js +56 -0
  76. package/dist/http-request-DPrY7mGh.cjs +1 -0
  77. package/dist/local-storage-Boafngui.cjs +1 -0
  78. package/dist/local-storage-BqDEu2kF.js +59 -0
  79. package/dist/location-element-2m0gWq_d.cjs +1 -0
  80. package/dist/location-element-nA_wsqBt.js +49 -0
  81. package/dist/mockServiceWorker.js +284 -0
  82. package/dist/tree.xsl +33 -0
  83. package/dist/vite.svg +1 -0
  84. package/index.html +17 -0
  85. package/package.json +97 -0
  86. package/public/confused.svg +37 -0
  87. package/public/embed-1.html +3 -0
  88. package/public/html-template.html +126 -0
  89. package/public/html-template.xhtml +45 -0
  90. package/public/html-template.xml +45 -0
  91. package/public/mockServiceWorker.js +284 -0
  92. package/public/tree.xsl +33 -0
  93. package/public/vite.svg +1 -0
  94. package/src/assets/lit.svg +1 -0
  95. package/src/custom-element/custom-element.d.ts +36 -0
  96. package/src/custom-element/custom-element.js +688 -0
  97. package/src/custom-element/demo/a.html +63 -0
  98. package/src/custom-element/demo/confused.svg +37 -0
  99. package/src/custom-element/demo/data-slices.html +184 -0
  100. package/src/custom-element/demo/dce-social-preview.png +0 -0
  101. package/src/custom-element/demo/demo.css +22 -0
  102. package/src/custom-element/demo/dom-merge.html +123 -0
  103. package/src/custom-element/demo/embed-1.html +3 -0
  104. package/src/custom-element/demo/external-template.html +179 -0
  105. package/src/custom-element/demo/hex-grid-dce.html +183 -0
  106. package/src/custom-element/demo/hex-grid-transform.png +0 -0
  107. package/src/custom-element/demo/hex-grid.html +66 -0
  108. package/src/custom-element/demo/html-template.html +126 -0
  109. package/src/custom-element/demo/html-template.xhtml +45 -0
  110. package/src/custom-element/demo/html-template.xml +45 -0
  111. package/src/custom-element/demo/http-request.html +143 -0
  112. package/src/custom-element/demo/local-storage.html +218 -0
  113. package/src/custom-element/demo/location-element.html +155 -0
  114. package/src/custom-element/demo/logo.png +0 -0
  115. package/src/custom-element/demo/parameters.html +70 -0
  116. package/src/custom-element/demo/s.xml +14 -0
  117. package/src/custom-element/demo/s.xslt +76 -0
  118. package/src/custom-element/demo/scoped-css.html +169 -0
  119. package/src/custom-element/demo/ss.html +57 -0
  120. package/src/custom-element/demo/table.xml +25 -0
  121. package/src/custom-element/demo/table.xsl +293 -0
  122. package/src/custom-element/demo/template.xsl +46 -0
  123. package/src/custom-element/demo/tree.xml +25 -0
  124. package/src/custom-element/demo/tree.xsl +33 -0
  125. package/src/custom-element/demo/wc-square.svg +1 -0
  126. package/src/custom-element/demo/xhtml-template.xhtml +45 -0
  127. package/src/custom-element/demo/z.html +62 -0
  128. package/src/custom-element/demo/z.xml +60 -0
  129. package/src/custom-element/http-request.js +89 -0
  130. package/src/custom-element/ide/IDE.md +31 -0
  131. package/src/custom-element/ide/customData-dce.json +112 -0
  132. package/src/custom-element/ide/customData-xsl.json +1018 -0
  133. package/src/custom-element/ide/web-types-dce.json +111 -0
  134. package/src/custom-element/ide/web-types-xsl.json +867 -0
  135. package/src/custom-element/index.html +168 -0
  136. package/src/custom-element/index.js +7 -0
  137. package/src/custom-element/local-storage.js +87 -0
  138. package/src/custom-element/location-element.js +87 -0
  139. package/src/custom-element.test.ts +10 -0
  140. package/src/index.css +38 -0
  141. package/src/mocks/handlers.ts +29 -0
  142. package/src/mocks/pokemons.mock.ts +13 -0
  143. package/src/stories/Configure.mdx +364 -0
  144. package/src/stories/assets/accessibility.png +0 -0
  145. package/src/stories/assets/accessibility.svg +5 -0
  146. package/src/stories/assets/addon-library.png +0 -0
  147. package/src/stories/assets/assets.png +0 -0
  148. package/src/stories/assets/avif-test-image.avif +0 -0
  149. package/src/stories/assets/context.png +0 -0
  150. package/src/stories/assets/discord.svg +15 -0
  151. package/src/stories/assets/docs.png +0 -0
  152. package/src/stories/assets/figma-plugin.png +0 -0
  153. package/src/stories/assets/github.svg +3 -0
  154. package/src/stories/assets/share.png +0 -0
  155. package/src/stories/assets/styling.png +0 -0
  156. package/src/stories/assets/testing.png +0 -0
  157. package/src/stories/assets/theming.png +0 -0
  158. package/src/stories/assets/tutorials.svg +12 -0
  159. package/src/stories/assets/youtube.svg +4 -0
  160. package/src/stories/attributes.stories.ts +132 -0
  161. package/src/stories/attributes.test.ts +14 -0
  162. package/src/stories/css.stories.ts +104 -0
  163. package/src/stories/css.test.ts +12 -0
  164. package/src/stories/dom-merge.stories.ts +113 -0
  165. package/src/stories/dom-merge.test.ts +12 -0
  166. package/src/stories/external-template.stories.ts +245 -0
  167. package/src/stories/external-template.test.ts +12 -0
  168. package/src/stories/http-request.stories.ts +244 -0
  169. package/src/stories/http-request.test.ts +29 -0
  170. package/src/stories/local-storage.stories.ts +388 -0
  171. package/src/stories/local-storage.test.ts +12 -0
  172. package/src/stories/location-element.stories.ts +133 -0
  173. package/src/stories/location-element.test.ts +14 -0
  174. package/src/stories/renderPlay.ts +22 -0
  175. package/src/stories/slice-events.stories.ts +117 -0
  176. package/src/stories/slice-events.test.ts +12 -0
  177. package/src/sum.test.ts +6 -0
  178. package/src/sum.ts +4 -0
  179. package/src/vite-env.d.ts +1 -0
  180. package/storybook-static/assets/Color-RQJUDNI5-C4yZhNbM.js +1 -0
  181. package/storybook-static/assets/Configure-C7d36rng.js +173 -0
  182. package/storybook-static/assets/DocsRenderer-K4EAMTCU-BLMupvSb.js +2 -0
  183. package/storybook-static/assets/WithTooltip-Y7J54OF7-BAQSPSFk.js +1 -0
  184. package/storybook-static/assets/accessibility-W_h2acOZ.png +0 -0
  185. package/storybook-static/assets/addon-library-BWUCAmyN.png +0 -0
  186. package/storybook-static/assets/attributes.stories-ZB0RTY1d.js +151 -0
  187. package/storybook-static/assets/context-C0qIqeS4.png +0 -0
  188. package/storybook-static/assets/css.stories-CLSX-Xxd.js +86 -0
  189. package/storybook-static/assets/custom-element-BLZZ00dz.js +53 -0
  190. package/storybook-static/assets/docs---vsFbMi.png +0 -0
  191. package/storybook-static/assets/dom-merge.stories-CgHZUABU.js +138 -0
  192. package/storybook-static/assets/entry-preview-CQqNFx4W.js +8 -0
  193. package/storybook-static/assets/entry-preview-docs-CWgqLfd3.js +2 -0
  194. package/storybook-static/assets/external-template.stories-DtSLMxvg.js +316 -0
  195. package/storybook-static/assets/figma-plugin-CH2hELiO.png +0 -0
  196. package/storybook-static/assets/formatter-B5HCVTEV-tKeEfJA9.js +58 -0
  197. package/storybook-static/assets/http-request.stories-CUzlXO89.js +300 -0
  198. package/storybook-static/assets/iframe-gCvlWuoC.js +2 -0
  199. package/storybook-static/assets/index-CBQwM6ST.js +508 -0
  200. package/storybook-static/assets/index-CDavW7r9.js +193 -0
  201. package/storybook-static/assets/index-CQA5dlr6.js +13 -0
  202. package/storybook-static/assets/index-Cc7K62zD.js +3 -0
  203. package/storybook-static/assets/index-DgaNIR0t.js +1 -0
  204. package/storybook-static/assets/index-Dkj0J1ds.js +1 -0
  205. package/storybook-static/assets/index-DnEJ_bKa.js +1 -0
  206. package/storybook-static/assets/index-DrFu-skq.js +6 -0
  207. package/storybook-static/assets/lit-element-B4_0akdT.js +19 -0
  208. package/storybook-static/assets/local-storage.stories-BkO6djDz.js +415 -0
  209. package/storybook-static/assets/location-element.stories-DCIOUd0D.js +108 -0
  210. package/storybook-static/assets/preview-B4GcaC1c.js +1 -0
  211. package/storybook-static/assets/preview-B63p-W8V.js +20 -0
  212. package/storybook-static/assets/preview-BAz7FMXc.js +396 -0
  213. package/storybook-static/assets/preview-BDY5ThwJ.js +1 -0
  214. package/storybook-static/assets/preview-C6t8KBFr.js +1 -0
  215. package/storybook-static/assets/preview-CYD85dwb.js +7 -0
  216. package/storybook-static/assets/preview-CkgAD_DE.js +2 -0
  217. package/storybook-static/assets/preview-D8LadFCz.js +48 -0
  218. package/storybook-static/assets/preview-DNpCpRPf.js +1 -0
  219. package/storybook-static/assets/preview-PxUn-cIn.js +1 -0
  220. package/storybook-static/assets/share-DGA-UcQf.png +0 -0
  221. package/storybook-static/assets/slice-events.stories-DXKjXI37.js +115 -0
  222. package/storybook-static/assets/styling-Bk6zjRzU.png +0 -0
  223. package/storybook-static/assets/syntaxhighlighter-JOJW2KGS-C04pIVD3.js +1 -0
  224. package/storybook-static/assets/testing-cbzR9l9r.png +0 -0
  225. package/storybook-static/assets/theming-D6WJLNoW.png +0 -0
  226. package/storybook-static/assets/tiny-invariant-BxWVcicq.js +1 -0
  227. package/storybook-static/confused.svg +37 -0
  228. package/storybook-static/embed-1.html +3 -0
  229. package/storybook-static/favicon.svg +7 -0
  230. package/storybook-static/html-template.html +126 -0
  231. package/storybook-static/html-template.xhtml +45 -0
  232. package/storybook-static/html-template.xml +45 -0
  233. package/storybook-static/iframe.html +492 -0
  234. package/storybook-static/index.html +163 -0
  235. package/storybook-static/index.json +1 -0
  236. package/storybook-static/mockServiceWorker.js +284 -0
  237. package/storybook-static/project.json +1 -0
  238. package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js +327 -0
  239. package/storybook-static/sb-addons/chromatic-com-storybook-9/manager-bundle.js.LEGAL.txt +40 -0
  240. package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +3 -0
  241. package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js.LEGAL.txt +0 -0
  242. package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +12 -0
  243. package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js.LEGAL.txt +0 -0
  244. package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +60 -0
  245. package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js.LEGAL.txt +18 -0
  246. package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +3 -0
  247. package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js.LEGAL.txt +0 -0
  248. package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +3 -0
  249. package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js.LEGAL.txt +0 -0
  250. package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +3 -0
  251. package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js.LEGAL.txt +0 -0
  252. package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +3 -0
  253. package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js.LEGAL.txt +0 -0
  254. package/storybook-static/sb-addons/interactions-10/manager-bundle.js +33 -0
  255. package/storybook-static/sb-addons/interactions-10/manager-bundle.js.LEGAL.txt +0 -0
  256. package/storybook-static/sb-addons/links-1/manager-bundle.js +3 -0
  257. package/storybook-static/sb-addons/links-1/manager-bundle.js.LEGAL.txt +0 -0
  258. package/storybook-static/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +3 -0
  259. package/storybook-static/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
  260. package/storybook-static/sb-common-assets/fonts.css +31 -0
  261. package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
  262. package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
  263. package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
  264. package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
  265. package/storybook-static/sb-manager/WithTooltip-Y7J54OF7-CEHQ77YF.js +1 -0
  266. package/storybook-static/sb-manager/chunk-E3WK6ZOZ.js +234 -0
  267. package/storybook-static/sb-manager/chunk-E6ABNH5R.js +183 -0
  268. package/storybook-static/sb-manager/chunk-FEE35O7J.js +9 -0
  269. package/storybook-static/sb-manager/chunk-S4VOIVUE.js +347 -0
  270. package/storybook-static/sb-manager/chunk-XCO5HRLK.js +6 -0
  271. package/storybook-static/sb-manager/chunk-XP3HGWTR.js +1 -0
  272. package/storybook-static/sb-manager/formatter-B5HCVTEV-7DCBOGO6.js +58 -0
  273. package/storybook-static/sb-manager/globals-module-info.js +1 -0
  274. package/storybook-static/sb-manager/globals-runtime.js +1 -0
  275. package/storybook-static/sb-manager/globals.js +1 -0
  276. package/storybook-static/sb-manager/index.js +1 -0
  277. package/storybook-static/sb-manager/runtime.js +1 -0
  278. package/storybook-static/sb-manager/syntaxhighlighter-JOJW2KGS-VF6EEVPI.js +1 -0
  279. package/storybook-static/sb-preview/globals.js +1 -0
  280. package/storybook-static/sb-preview/runtime.js +139 -0
  281. package/storybook-static/tree.xsl +33 -0
  282. package/storybook-static/vite.svg +1 -0
  283. package/tsconfig.json +25 -0
  284. package/vite.config.js +55 -0
@@ -0,0 +1,244 @@
1
+ // noinspection DuplicatedCode
2
+
3
+ import type { StoryObj } from '@storybook/web-components';
4
+ import { expect, within } from '@storybook/test';
5
+
6
+ import '../custom-element/custom-element.js';
7
+ import '../custom-element/http-request.js';
8
+ import {handlers} from '../mocks/handlers.ts';
9
+
10
+ type TProps = { title: string; slice: string; url: string; };
11
+ const defs: TProps =
12
+ { title: ''
13
+ , slice: 'page'
14
+ , url: '/pokemon?limit=6'
15
+ };
16
+ type Story = StoryObj<TProps>;
17
+ function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); }
18
+
19
+ function Template({title, slice, url}: TProps)
20
+ {
21
+ return `
22
+ <fieldset>
23
+ <legend>${title}</legend>
24
+ <custom-element>
25
+ <template><!-- wrapping into template to prevent images loading within DCE declaration -->
26
+ <http-request
27
+ url="{ //slice/url }"
28
+ slice="${slice}"
29
+ ></http-request>
30
+ <input placeholder="URL for fetch" slice="url" value="{ //url ?? '${ url }' }"/>
31
+ <button>set</button>
32
+ <button slice="url" slice-value="''" slice-event="click">set blank</button>
33
+ <button slice="url" slice-value="'/reflect'" slice-event="click">/reflect</button>
34
+ <button slice="url" slice-value="'/pokemon'" slice-event="click">/pokemon</button>
35
+ <button slice="url" slice-value="'/pokemon?limit=6'" slice-event="click">/pokemon?limit=6</button>
36
+ <button slice="url" slice-value="'/pokemon?limit=3'" slice-event="click">/pokemon?limit=3</button>
37
+
38
+ <p>Pokemon Count: {count(/datadom/slice/${slice}//results)}</p>
39
+ <if test="count(/datadom/slice/${slice}//results) &lt; 0">
40
+ <h3>loading...</h3>
41
+ </if>
42
+ <for-each select="/datadom/slice/${slice}//results">
43
+ <variable name="pokeid"
44
+ select="substring-before( substring-after( @url, 'https://pokeapi.co/api/v2/pokemon/'),'/')"
45
+ ></variable>
46
+ <button>
47
+ <value-of select='@name'/>
48
+ </button>
49
+ </for-each>
50
+ <for-each select="//slice/${slice}/value/*">
51
+ <ul>
52
+ <var data-testid="request-section"><value-of select='name(.)'/></var>
53
+ <for-each select="@*">
54
+ <div>
55
+ <var>@{local-name(.)}</var>
56
+ =
57
+ <code data-testid="attr-{local-name(.)}">{.}</code>
58
+ </div>
59
+ </for-each>
60
+ </ul>
61
+ </for-each>
62
+ </template>
63
+ </custom-element>
64
+ </fieldset>
65
+ `;
66
+ }
67
+ const meta =
68
+ { title: 'http-request'
69
+ , render: (args: TProps) => Template(args)
70
+ , renderPlay: async function renderPlay(story: StoryObj)
71
+ {
72
+ // @ts-ignore
73
+ document.body.innerHTML = ( story.render ? story : meta ).render({...defs, ...story.args});
74
+ await new Promise(resolve => setTimeout(async () =>
75
+ {
76
+ // @ts-ignore
77
+ await story.play({canvasElement: document.body.firstElementChild as HTMLElement});
78
+ resolve(0);
79
+ }, 0));
80
+ },
81
+ };
82
+
83
+ export default meta;
84
+
85
+ export const Demo:Story =
86
+ { args : {title: 'url and slice',url:'/pokemon?limit=4'}
87
+ , play: async ({canvasElement}) =>
88
+ {
89
+ const canvas = within(canvasElement);
90
+ await canvas.findByText(Demo.args!.title as string);
91
+ expect( await canvas.findByText('bulbasaur')).toBeInTheDocument();
92
+ expect( await canvas.findByText('Pokemon Count: 4')).toBeInTheDocument(canvasElement);
93
+ },
94
+ parameters: { msw: handlers },
95
+ };
96
+
97
+ export const UrlChange:Story =
98
+ { args : {title: 'url change',url:''}
99
+ , play: async ({canvasElement}) =>
100
+ {
101
+ const canvas = within(canvasElement);
102
+ await canvas.findByText(UrlChange.args!.title as string);
103
+ const byText = txt => canvas.getByText(txt)
104
+ const requestElement = canvasElement.querySelector('http-request')
105
+ , urlAttr = () => requestElement.getAttribute('url');
106
+
107
+ expect( byText('Pokemon Count: 0') ).toBeInTheDocument();
108
+ expect( urlAttr() ).toEqual('');
109
+
110
+ byText( '/pokemon' ).click();
111
+ await sleep(100);
112
+ expect( urlAttr() ).toEqual('/pokemon');
113
+ expect( byText('Pokemon Count: 6') ).toBeInTheDocument();
114
+
115
+ byText( '/pokemon?limit=6' ).click();
116
+ await sleep(100);
117
+ expect( urlAttr() ).toEqual('/pokemon?limit=6');
118
+ expect( byText('Pokemon Count: 6') ).toBeInTheDocument();
119
+
120
+ byText( '/pokemon?limit=3' ).click();
121
+ await sleep(100);
122
+ expect( urlAttr() ).toEqual('/pokemon?limit=3');
123
+ expect( byText('Pokemon Count: 3') ).toBeInTheDocument();
124
+
125
+ byText( 'set blank' ).click();
126
+ await sleep(100);
127
+ expect( urlAttr() ).toEqual('');
128
+ expect( byText('Pokemon Count: 0') ).toBeInTheDocument();
129
+ },
130
+ parameters: { msw: handlers },
131
+ };
132
+
133
+ export const Http404:Story =
134
+ { args : {title: 'http-request with error', url: '/404'}
135
+ , play: async ({canvasElement}) =>
136
+ { const canvas = within(canvasElement)
137
+ , $t = async testId=> (await canvas.findByTestId(testId)).textContent;
138
+ await canvas.findByText(Http404.args!.title as string);
139
+ await sleep(200);
140
+ expect( await $t('attr-status')).to.include('404');
141
+ },
142
+ parameters: { msw: handlers },
143
+ };
144
+
145
+ export const LifecycleInitialized:Story =
146
+ { args: { title: 'http-request with delayed .5 seconds response', url: '/noreturn'}
147
+ , play: async ({canvasElement}) =>
148
+ { const canvas = within(canvasElement);
149
+ await canvas.findByText(LifecycleInitialized.args!.title as string);
150
+ expect( await canvas.findByText('request') ).toBeInTheDocument(); // after DCE initiated
151
+ expect( canvas.queryByText('response') ).toBe(null); // response is not available
152
+ // wait while response appears ~ 0.5 seconds
153
+ expect( await canvas.findByText('response') ).toBeInTheDocument(); // only after delay is shown
154
+
155
+ expect( await canvas.findByText('bulbasaur') ).toBeInTheDocument();
156
+ expect( await canvas.findByText('Pokemon Count: 6') ).toBeInTheDocument();
157
+ },
158
+ parameters: { msw: handlers },
159
+ };
160
+
161
+ export const RequestResponseHeaders:Story =
162
+ { args: { title: 'http-request headers and response status and headers', url: '/reflect'}
163
+ , play: async ({canvasElement}) =>
164
+ { const canvas = within(canvasElement);
165
+ await canvas.findByText(RequestResponseHeaders.args!.title as string);
166
+ await sleep(200);
167
+
168
+ // see response made by /reflect handler
169
+
170
+ const te = await canvas.findByTestId('section-request-attr-x-test');
171
+ expect( te ).toBeInTheDocument();
172
+ expect( te.textContent.trim() ).toEqual('testing');
173
+
174
+ const t1 = await canvas.findByTestId('section-response-attr-x-test');
175
+ expect( t1 ).toBeInTheDocument();
176
+ expect( t1.textContent.trim() ).toEqual('reflected-testing');
177
+
178
+ const tAdded = await canvas.findByTestId('section-response-attr-x-added');
179
+ expect( tAdded ).toBeInTheDocument();
180
+ expect( tAdded.textContent.trim() ).toEqual('abc');
181
+
182
+ },
183
+ parameters: { msw: handlers },
184
+ render : ({url,title}) => `
185
+ <fieldset>
186
+ <legend>${title}</legend>
187
+ <p> <b>request</b> headers are populated into dedicated <b>slice/request/headers</b></p>
188
+
189
+ <custom-element tag="headers-demo" >
190
+ <template>
191
+ <http-request
192
+ url="${url}"
193
+ slice="request_slice"
194
+ type="text"
195
+ mode="cors"
196
+ header-x-test="testing"
197
+ ></http-request>
198
+ Content of <code>//slice/request_slice</code> is filled by <b>request</b> and <b>response</b>
199
+ from <code>${url}</code>
200
+
201
+ <h3>Samples</h3>
202
+ <table>
203
+ <tr><th>//slice/request_slice/value/request/headers/@mode</th>
204
+ <td><value-of select="//slice/request_slice/value/request/@mode"/></td></tr>
205
+ <tr><th>//slice/request_slice/value/response/headers/@content-type</th>
206
+ <td><value-of select="//slice/request_slice/value/response/headers/@content-type"/></td></tr>
207
+ <tr><th>//slice/request_slice/value/response/@status</th>
208
+ <td><value-of select="//slice/request_slice/value/response/@status"/></td></tr>
209
+ </table>
210
+ <for-each select="//slice/request_slice/value/*">
211
+ <xsl:variable name="section">{name(.)}</xsl:variable>
212
+ <ul date-testid="section-{$section}">
213
+ <b data-testid="request-section"><value-of select='name(.)'/></b>
214
+ <for-each select="@*">
215
+ <div>
216
+ <var >@{local-name(.)}</var>
217
+ =
218
+ <code data-testid="section-{$section}-prop-{local-name(.)}">{.}</code>
219
+ </div>
220
+ </for-each>
221
+ <for-each select="*">
222
+ <div>
223
+ <b data-testid="section-deep"><value-of select='local-name(.)'/></b>
224
+ <ul>
225
+ <for-each select="@*">
226
+ <li>
227
+ <var data-testid="section-attribute">@{local-name(.)}</var>
228
+ =
229
+ <code data-testid="section-{$section}-attr-{local-name(.)}">{.}</code>
230
+ </li>
231
+ </for-each>
232
+ <code><value-of select='.'/></code>
233
+ </ul>
234
+ </div>
235
+ </for-each>
236
+ </ul>
237
+ </for-each>
238
+ </template>
239
+ </custom-element>
240
+ <headers-demo></headers-demo>
241
+ </fieldset>
242
+ `
243
+ };
244
+
@@ -0,0 +1,29 @@
1
+ import {describe, it,beforeAll, afterAll} from 'vitest';
2
+ import {type StoryObj} from "@storybook/web-components";
3
+ import {setupWorker } from 'msw/browser';
4
+
5
+
6
+ import '../custom-element/custom-element.js';
7
+ import meta from "./http-request.stories.ts";
8
+
9
+ import * as Stories from "./http-request.stories.ts";
10
+ import {handlers} from '../mocks/handlers.ts';
11
+
12
+ export const worker = setupWorker(...handlers);
13
+ await worker.start();
14
+
15
+
16
+ // worker.start({serviceWorker: { url: '/public/mockServiceWorker.js' } });
17
+ // worker.use(...handlers);
18
+
19
+ // beforeAll( () => {worker.start()});//{ onUnhandledRequest: 'error' }));
20
+ //
21
+ // afterAll(() => worker.stop());
22
+
23
+
24
+ const {renderPlay} = meta;
25
+ describe('http-request', () => {
26
+ for (let story of Object.values(Stories) as StoryObj[] )
27
+ if( story.play )
28
+ it(story.args!.title, async () => renderPlay(story));
29
+ });
@@ -0,0 +1,388 @@
1
+ // noinspection DuplicatedCode
2
+
3
+ import type { StoryObj } from '@storybook/web-components';
4
+ import {expect, getByTestId, within} from '@storybook/test';
5
+
6
+ import '../custom-element/custom-element.js';
7
+ import '../custom-element/local-storage.js';
8
+
9
+ type TProps = { title: string; slice: string; key: string; value:string; live:string; body:string};
10
+ const defs: TProps =
11
+ { title: ''
12
+ , slice: 'ls-slice'
13
+ , key: 'sb-ls-key'
14
+ , value: ''
15
+ , live: ''
16
+ , body: ``
17
+ };
18
+ type Story = StoryObj<TProps>;
19
+ function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); }
20
+
21
+ function render(args: TProps)
22
+ {
23
+ const {title, slice, key, value, live, body} = {...defs, ...args};
24
+ return `
25
+ <fieldset>
26
+ <legend>${ title }</legend>
27
+
28
+ <custom-element>
29
+ <template><!-- wrapping into template to prevent images loading within DCE declaration -->
30
+ <local-storage
31
+ key="${ key }"
32
+ slice="${ slice }"
33
+ ${ live ? `live="${live }"`:''}
34
+ ${ value ? `value="${value }"`:''}
35
+ ></local-storage>
36
+
37
+ <br/>
38
+ <var>${key}</var>:<code data-testid="slice-value">{ //slice/${slice} }</code>
39
+ <br/>
40
+ ${ body }
41
+ </template>
42
+ </custom-element>
43
+ </fieldset>
44
+ `;
45
+ }
46
+ const meta =
47
+ { title: 'local-storage'
48
+ , render
49
+ };
50
+
51
+ export default meta;
52
+
53
+ export const Demo:Story =
54
+ { args : {title: 'live value', live:'live', body:`
55
+ <input placeholder="value for localStorage" id="textinput"
56
+ slice="${defs.slice}"
57
+ value="{ //${defs.slice} ?? '${ defs.value }' }"/>
58
+ <button onclick="localStorage.setItem('${defs.key}',textinput.value )">set</button>
59
+ <button onclick="localStorage.setItem('${defs.key}','text value' )">text value</button>
60
+ <button onclick="localStorage.setItem('${defs.key}','another text')">another text</button>
61
+ <button onclick="localStorage.removeItem('${defs.key}' )">set blank</button>
62
+ `}
63
+ , play: async ({canvasElement}) =>
64
+ {
65
+ const canvas = within(canvasElement);
66
+ await canvas.findByText(Demo.args!.title as string);
67
+ const val = ()=> canvas.getByTestId('slice-value').textContent
68
+ , byText = txt => canvas.getByText(txt);
69
+
70
+ byText('set blank').click();
71
+ expect(localStorage.getItem(defs.key)).toEqual(null, 'from localStorage');
72
+ expect( val() ).toEqual('');
73
+ byText('text value').click();
74
+ await sleep(10);
75
+ expect( val() ).toEqual('text value');
76
+
77
+ window['textinput'].value = 'textinput.value';
78
+ byText('set').click();
79
+ await sleep(10);
80
+ expect( val() ).toEqual('textinput.value');
81
+
82
+ byText('another text').click();
83
+ await sleep(10);
84
+ expect( val() ).toEqual('another text');
85
+
86
+
87
+ byText('set blank').click();
88
+ await sleep(10);
89
+ expect( val() ).toEqual('');
90
+ },
91
+ };
92
+
93
+
94
+ export const AlwaysOverride:Story =
95
+ { args : {title: 'AlwaysOverride', live:'', value:'ABC', body:`
96
+ buttons are changing the localStorage value, but without 'live' attribute slice ^^ from <i>local-storage</i> is not updated<br/>
97
+ <button onclick="localStorage.setItem('${defs.key}','text value' )">text value</button>
98
+ <button onclick="localStorage.removeItem('${defs.key}' )">set blank</button>
99
+ `}
100
+ , play: async ({canvasElement}) =>
101
+ {
102
+ const canvas = within(canvasElement);
103
+ await canvas.findByText(AlwaysOverride.args!.title as string);
104
+ const val = ()=> canvas.getByTestId('slice-value').textContent
105
+ , byText = txt => canvas.getByText(txt);
106
+
107
+ expect(localStorage.getItem(defs.key)).toEqual('ABC', 'from localStorage');
108
+
109
+ byText('set blank').click();
110
+ expect(localStorage.getItem(defs.key)).toEqual(null, 'from localStorage');
111
+ await sleep(10);
112
+ expect( val() ).toEqual('ABC');
113
+
114
+ byText('text value').click();
115
+ await sleep(10);
116
+ expect(localStorage.getItem(defs.key)).toEqual('text value', 'from localStorage');
117
+ expect( val() ).toEqual('ABC');
118
+
119
+ byText('set blank').click();
120
+ await sleep(10);
121
+ expect( val() ).toEqual('ABC');
122
+ },
123
+ };
124
+
125
+ export const FromStorageWithDefault:Story =
126
+ { args : {title: 'live value with defaults', live:'', value:'ABC', body:`
127
+
128
+ <local-storage key="attr2Key" slice="attr2-key" type="text" live="live" slice-value="@value ?? 'DEF2'"></local-storage>
129
+ <button onclick="localStorage.removeItem('attr2Key')">clear key</button>
130
+ <button onclick="localStorage.setItem('attr2Key','attr2Key value')">update attr2-key value</button>
131
+ //attr2-key: <code data-testid="key2-value">{//attr2-key}</code><br/>
132
+
133
+ <local-storage key="attr3Key" slice="attr3-key" type="text" live="live" slice-value="@value ?? 'DEF3'"></local-storage>
134
+ <button onclick="localStorage.removeItem('attr3Key')">clear attr3-key key</button>
135
+ <button onclick="localStorage.setItem('attr3Key','attr3Key value')">update attr3-key value</button>
136
+ //attr3-key: <code data-testid="key3-value">{//attr3-key}</code><br/>
137
+ <button onclick="localStorage.clear()">clear localStorage</button>
138
+ `}
139
+ , play: async ({canvasElement}) =>
140
+ {
141
+ const canvas = within(canvasElement);
142
+ await canvas.findByText(FromStorageWithDefault.args!.title as string);
143
+ const byText = txt => canvas.getByText(txt);
144
+
145
+ expect(localStorage.getItem(defs.key)).toEqual('ABC', 'from localStorage');
146
+ byText('clear localStorage').click();
147
+
148
+ expect( canvas.getByTestId('slice-value').textContent).toEqual('ABC')
149
+ expect( canvas.getByTestId('key2-value' ).textContent).toEqual('DEF2')
150
+ expect( canvas.getByTestId('key3-value' ).textContent).toEqual('DEF3')
151
+
152
+ byText('update attr2-key value').click();
153
+ expect(localStorage.getItem('attr2Key')).toEqual('attr2Key value', 'from localStorage');
154
+ await sleep(10);
155
+ expect( canvas.getByTestId('slice-value').textContent).toEqual('ABC')
156
+ expect( canvas.getByTestId('key2-value' ).textContent).toEqual('attr2Key value')
157
+ expect( canvas.getByTestId('key3-value' ).textContent).toEqual('DEF3')
158
+
159
+ byText('update attr3-key value').click();
160
+ expect(localStorage.getItem('attr3Key')).toEqual('attr3Key value', 'from localStorage');
161
+ await sleep(10);
162
+ expect( canvas.getByTestId('slice-value').textContent).toEqual('ABC')
163
+ expect( canvas.getByTestId('key2-value' ).textContent).toEqual('attr2Key value')
164
+ expect( canvas.getByTestId('key3-value' ).textContent).toEqual('attr3Key value')
165
+
166
+ },
167
+ };
168
+
169
+ export const TypeAttribute:Story =
170
+ { args : {title: 'local-storage type attribute variations', body:`
171
+
172
+ <local-storage key="textKey" slice="text-key" type="text" live="live"></local-storage>
173
+ <local-storage key="dateKey" slice="date-key" type="date" live="live"></local-storage>
174
+ <local-storage key="timeKey" slice="time-key" type="time" live="live"></local-storage>
175
+ <local-storage key="localDateTimeKey" slice="local-date-time" type="datetime-local" live="live"></local-storage>
176
+ <local-storage key="numberKey" slice="number-key" type="number" live="live"></local-storage>
177
+ <local-storage key="jsonKey" slice="json-key" type="json" live="live"></local-storage>
178
+ <input id="typesinput" placeholder="set value"><button onclick="
179
+ 'textKey,dateKey,timeKey,localDateTimeKey,numberKey,jsonKey'.split(',')
180
+ .map( k=> localStorage.setItem(k, typesinput.value) )
181
+ "> set to all</button><br>
182
+ <hr>
183
+ text-key:
184
+ <button onclick="localStorage.setItem('textKey', 'ABC' )">ABC</button>
185
+ <code data-testid="text-key">{//text-key }</code><br>
186
+ date-key:
187
+ <button onclick="localStorage.setItem('dateKey', '2024-04-20T03:58:42.131Z')">2024-04-21T03:58:42.131Z </button>
188
+ <button onclick="localStorage.setItem('dateKey', new Date(Date.now()).toISOString())">now </button>
189
+ <button onclick="localStorage.setItem('dateKey', 'ABC' )">date ABC - invalid </button>
190
+ <code data-testid="date-key">{//date-key }</code><br>
191
+ time-key:
192
+ <button onclick="localStorage.setItem('timeKey', '13:30')">13:30 </button>
193
+ <code data-testid="time-key">{//time-key }</code><br>
194
+ local-date-time:
195
+ <button onclick="localStorage.setItem('localDateTimeKey', '1977-04-01T14:00:30')">1977-04-01T14:00:30 - local </button>
196
+ <code data-testid="local-date-time">{//local-date-time}</code><br>
197
+ number-key:
198
+ <button onclick="localStorage.setItem('numberKey', '2024' )">2024 - number </button>
199
+ <button onclick="localStorage.setItem('numberKey', '24' )">24 - number </button>
200
+ <button onclick="localStorage.setItem('numberKey', '1.23456e+5' )">1.23456e+5 </button>
201
+ <button onclick="localStorage.setItem('numberKey', '0001' )">0001 </button>
202
+ <button onclick="localStorage.setItem('numberKey', '000' )">000 </button>
203
+ <button onclick="localStorage.setItem('numberKey', '0' )">0 </button>
204
+ <button onclick="localStorage.setItem('numberKey', 'ABC' )">ABC - invalid, NaN </button>
205
+ <code data-testid="number-key">{//number-key }</code> <br>
206
+ <fieldset>
207
+ <legend>json-key: </legend>
208
+
209
+ <button onclick="localStorage.setItem('jsonKey', JSON.stringify('ABC'))">'ABC' - string </button>
210
+ <button onclick="localStorage.setItem('jsonKey', JSON.stringify(12.345))">12.345 - number </button>
211
+ <button onclick="localStorage.setItem('jsonKey', JSON.stringify(window.JsonSample) )">a:1,b:'B' -json </button>
212
+ <button onclick="localStorage.setItem('jsonKey', 'ABC' )">ABC - invalid </button><br>
213
+ 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>
214
+ </fieldset>
215
+ <xsl:template mode="json" match="*|@*">
216
+ <div>{name()} : {.}</div>
217
+ </xsl:template>
218
+ `}
219
+ , play: async ({canvasElement}) =>
220
+ {
221
+ const canvas = within(canvasElement);
222
+ await canvas.findByText(TypeAttribute.args!.title as string);
223
+ const byText = txt => canvas.getByText(txt)
224
+ , val = testId => canvas.getByTestId(testId).textContent
225
+ , expectVal = (key,value) => { expect(val( key )).toEqual( value, key ) };
226
+ localStorage.clear(); // cleanup before test
227
+ await sleep(10);
228
+
229
+ expectVal('text-key' ,'');
230
+ expectVal('date-key' ,'');
231
+ expectVal('time-key' ,'');
232
+ expectVal('local-date-time','');
233
+ expectVal('number-key' ,'NaN');
234
+ expectVal('json-key' ,'');
235
+
236
+ const input = canvasElement.querySelector('input');
237
+ input.value='ABC';
238
+ byText('set to all').click();
239
+ await sleep(10);
240
+ expectVal('text-key' ,'ABC');
241
+ expectVal('date-key' ,'' );
242
+ expectVal('time-key' ,'' );
243
+ expectVal('local-date-time','' );
244
+ expectVal('number-key' ,'NaN');
245
+ expectVal('json-key' ,'');
246
+
247
+ input.value='22';
248
+ byText('set to all').click();
249
+ await sleep(10);
250
+ expectVal('text-key' ,'22');
251
+ expectVal('date-key' ,'' );
252
+ expectVal('time-key' ,'' );
253
+ expectVal('local-date-time','' );
254
+ expectVal('number-key' ,'22');
255
+ expectVal('json-key' ,'22');
256
+
257
+ input.value='2024';
258
+ byText('set to all').click();
259
+ await sleep(10);
260
+ expectVal('text-key' ,'2024' );
261
+ expectVal('date-key' ,'2024-01-01' );
262
+ expectVal('time-key' ,'' );
263
+ expectVal('local-date-time','' );
264
+ expectVal('number-key' ,'2024' );
265
+ expectVal('json-key' ,'2024' );
266
+
267
+ input.value='2024-04-20T03:58:42.131Z';
268
+ byText('set to all').click();
269
+ await sleep(10);
270
+ expectVal('text-key' ,'2024-04-20T03:58:42.131Z' );
271
+ expectVal('date-key' ,'2024-04-20' );
272
+ expectVal('time-key' ,'' );
273
+ expectVal('local-date-time','' );
274
+ expectVal('number-key' ,'NaN' );
275
+ expectVal('json-key' ,'' );
276
+
277
+ const nowStr = new Date(Date.now()).toISOString();
278
+ input.value=nowStr;
279
+ byText('set to all').click();
280
+ await sleep(10);
281
+ expectVal('text-key' ,nowStr );
282
+ expectVal('date-key' ,nowStr.substring(0,10) );
283
+ expectVal('time-key' ,'' );
284
+ expectVal('local-date-time','' );
285
+ expectVal('number-key' ,'NaN' );
286
+ expectVal('json-key' ,'' );
287
+
288
+ input.value='23:25';
289
+ byText('set to all').click();
290
+ await sleep(10);
291
+ expectVal('text-key' ,'23:25' );
292
+ expectVal('date-key' ,'' );
293
+ expectVal('time-key' ,'23:25' );
294
+ expectVal('local-date-time','' );
295
+ expectVal('number-key' ,'NaN' );
296
+ expectVal('json-key' ,'' );
297
+
298
+ input.value='1977-04-01T14:00:30';
299
+ byText('set to all').click();
300
+ await sleep(10);
301
+ expectVal('text-key' ,'1977-04-01T14:00:30' );
302
+ expectVal('date-key' ,'1977-04-01' );
303
+ expectVal('time-key' ,'' );
304
+ expectVal('local-date-time','1977-04-01T14:00:30' );
305
+ expectVal('number-key' ,'NaN' );
306
+ expectVal('json-key' ,'' );
307
+
308
+ input.value='1.23456e+5';
309
+ byText('set to all').click();
310
+ await sleep(10);
311
+ expectVal('text-key' ,'1.23456e+5');
312
+ expectVal('date-key' ,'' );
313
+ expectVal('time-key' ,'' );
314
+ expectVal('local-date-time','' );
315
+ expectVal('number-key' ,'123456' );
316
+ expectVal('json-key' ,'123456' );
317
+
318
+ input.value='0001';// as YYYY for year
319
+ byText('set to all').click();
320
+ await sleep(10);
321
+ expectVal('text-key' ,'0001');
322
+ expectVal('date-key' ,'0001-01-01');
323
+ expectVal('time-key' ,'' );
324
+ expectVal('local-date-time','' );
325
+ expectVal('number-key' ,'1' );
326
+ expectVal('json-key' ,'' );
327
+
328
+ input.value='001'; // as 2001 year
329
+ byText('set to all').click();
330
+ await sleep(10);
331
+ expectVal('text-key' ,'001' );
332
+ expectVal('date-key' ,'2001-01-01');
333
+ expectVal('time-key' ,'' );
334
+ expectVal('local-date-time','' );
335
+ expectVal('number-key' ,'1' );
336
+ expectVal('json-key' ,'' );
337
+
338
+ input.value='000'; // as 2001 year
339
+ byText('set to all').click();
340
+ await sleep(10);
341
+ expectVal('text-key' ,'000' );
342
+ expectVal('date-key' ,'2000-01-01');
343
+ expectVal('time-key' ,'' );
344
+ expectVal('local-date-time','' );
345
+ expectVal('number-key' ,'0' );
346
+ expectVal('json-key' ,'' );
347
+
348
+ input.value='0'; // as 2000 year
349
+ byText('set to all').click();
350
+ await sleep(10);
351
+ expectVal('text-key' ,'0' );
352
+ expectVal('date-key' ,'2000-01-01');
353
+ expectVal('time-key' ,'' );
354
+ expectVal('local-date-time','' );
355
+ expectVal('number-key' ,'0' );
356
+ expectVal('json-key' ,'0' );
357
+
358
+ input.value='"abc"';
359
+ byText('set to all').click();
360
+ await sleep(10);
361
+ expectVal('text-key' ,'"abc"' );
362
+ expectVal('date-key' ,'' );
363
+ expectVal('time-key' ,'' );
364
+ expectVal('local-date-time','' );
365
+ expectVal('number-key' ,'NaN' );
366
+ expectVal('json-key' ,'abc' );
367
+
368
+ input.value='12.345';
369
+ byText('set to all').click();
370
+ await sleep(10);
371
+ expectVal('text-key' ,'12.345' );
372
+ expectVal('date-key' ,'' );
373
+ expectVal('time-key' ,'' );
374
+ expectVal('local-date-time','' );
375
+ expectVal('number-key' ,'12.345' );
376
+ expectVal('json-key' ,'12.345' );
377
+
378
+ input.value='{"a":1,"b":"B"}';
379
+ byText('set to all').click();
380
+ await sleep(10);
381
+ expectVal('text-key' ,'{"a":1,"b":"B"}' );
382
+ expectVal('date-key' ,'' );
383
+ expectVal('time-key' ,'' );
384
+ expectVal('local-date-time','' );
385
+ expectVal('number-key' ,'NaN' );
386
+ expectVal('json-key' ,'\na : 1b : B' );
387
+ },
388
+ };