@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,151 @@
1
+ import{w as o,e}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.js";function d(a){return new Promise(n=>setTimeout(n,a))}function r(a){const{title:n,body:t}=a;return`
2
+ <fieldset>
3
+ <legend>${n}</legend>
4
+ ${t}
5
+ </fieldset>
6
+ `}const b={title:"attributes",render:r},i={args:{title:"Attributes definition",body:`
7
+ <p>Params needed to declare DCE attributes and track the attributes changes. It also is used by IDE and validation.</p>
8
+ <custom-element tag="dce-link" >
9
+ <template>
10
+ <attribute name="p1">default_P1 </attribute>
11
+ <attribute name="p2" select="'always_p2'" ></attribute>
12
+ <attribute name="p3" select="//p3 ?? 'def_P3' "></attribute>
13
+ p1: <code data-testid="p1">{$p1}</code> <br/>
14
+ p2: <code data-testid="p2">{$p2}</code> <br/>
15
+ p3: <code data-testid="p3">{$p3}</code>
16
+ </template>
17
+ </custom-element>
18
+ <dce-link id="dce1"></dce-link>
19
+ `},play:async({canvasElement:a})=>{i.args.title;const n=o(a),t=async s=>(await n.findByTestId(s)).textContent.trim();await d(20),e(await t("p1")).toEqual("default_P1"),e(await t("p2")).toEqual("always_p2"),e(await t("p3")).toEqual("def_P3")}},c={args:{title:"Attributes runtime change",body:`
20
+ <p>Params needed to declare DCE attributes and track the attributes changes. It also be used by IDE and validation.</p>
21
+ <custom-element tag="dce-link2" >
22
+ <template>
23
+ <attribute name="p1">default_P1 </attribute>
24
+ <attribute name="p2" select="'always_p2'" ></attribute>
25
+ <attribute name="p3" select="//p3 ?? 'def_P3' "></attribute>
26
+ p1: <code data-testid="p1">{$p1}</code> <br/>
27
+ p2: <code data-testid="p2">{$p2}</code> <br/>
28
+ p3: <code data-testid="p3">{$p3}</code>
29
+ </template>
30
+ </custom-element>
31
+ <section>
32
+ <dce-link2 id="dce2" p1="123" p2="override ignored as select is defined"></dce-link2> <br>
33
+ <div><input id="i1" value="p1"> <button onclick="dce2.setAttribute('p1',i1.value)"> set p1</button> </div>
34
+ <div><input id="i2" value="p2"> <button onclick="dce2.setAttribute('p2',i2.value)"> set p2</button> </div>
35
+ <div><input id="i3" value="p3"> <button onclick="dce2.setAttribute('p3',i3.value)"> set p3</button> </div>
36
+ </section>
37
+ `},play:async({canvasElement:a})=>{i.args.title;const n=o(a),t=async s=>(await n.findByTestId(s)).textContent.trim();await d(20),e(await t("p1")).toEqual("123"),e(await t("p2")).toEqual("always_p2","no overrides due to value is hardcoded"),e(await t("p3")).toEqual("def_P3"),dce2.setAttribute("p1",i1.value),await d(10),e(await t("p1")).toEqual("p1","set p1 in runtime"),dce2.setAttribute("p2",i2.value),await d(10),e(await t("p2")).toEqual("always_p2","can not set p2 in runtime"),dce2.setAttribute("p3",i3.value),await d(10),e(await t("p3")).toEqual("p3","set p3 in runtime")}},p={args:{title:"Instance Attributes",body:`
38
+ <p>Params needed to declare DCE attributes and track the attributes changes. It also is used by IDE and validation.</p>
39
+ <custom-element tag="dce-link3" >
40
+ <template>
41
+ <attribute name="p1">default_P1 </attribute>
42
+ <attribute name="p2" select="'always_p2'" ></attribute>
43
+ <attribute name="p3" select="//p3 ?? 'def_P3' "></attribute>
44
+ p1: <code data-testid="p1">{$p1}</code> <br/>
45
+ p2: <code data-testid="p2">{$p2}</code> <br/>
46
+ p3: <code data-testid="p3">{$p3}</code>
47
+ </template>
48
+ </custom-element>
49
+ <dce-link3 id="dce3" p1="123" p3="qwe"></dce-link3> |
50
+ `},play:async({canvasElement:a})=>{i.args.title;const n=o(a),t=async s=>(await n.findByTestId(s)).textContent.trim();await d(20),e(await t("p1")).toEqual("123"),e(await t("p2")).toEqual("always_p2"),e(await t("p3")).toEqual("qwe")}};i.parameters={...i.parameters,docs:{...i.parameters?.docs,source:{originalSource:`{
51
+ args: {
52
+ title: 'Attributes definition',
53
+ body: \`
54
+ <p>Params needed to declare DCE attributes and track the attributes changes. It also is used by IDE and validation.</p>
55
+ <custom-element tag="dce-link" >
56
+ <template>
57
+ <attribute name="p1">default_P1 </attribute>
58
+ <attribute name="p2" select="'always_p2'" ></attribute>
59
+ <attribute name="p3" select="//p3 ?? 'def_P3' "></attribute>
60
+ p1: <code data-testid="p1">{$p1}</code> <br/>
61
+ p2: <code data-testid="p2">{$p2}</code> <br/>
62
+ p3: <code data-testid="p3">{$p3}</code>
63
+ </template>
64
+ </custom-element>
65
+ <dce-link id="dce1"></dce-link>
66
+ \`
67
+ },
68
+ play: async ({
69
+ canvasElement
70
+ }) => {
71
+ const titleText = (AttributeDefaults.args!.title as string);
72
+ const canvas = within(canvasElement),
73
+ code = async id => (await canvas.findByTestId(id)).textContent.trim();
74
+ await sleep(20);
75
+ expect(await code('p1')).toEqual('default_P1');
76
+ expect(await code('p2')).toEqual('always_p2');
77
+ expect(await code('p3')).toEqual('def_P3');
78
+ }
79
+ }`,...i.parameters?.docs?.source}}};c.parameters={...c.parameters,docs:{...c.parameters?.docs,source:{originalSource:`{
80
+ args: {
81
+ title: 'Attributes runtime change',
82
+ body: \`
83
+ <p>Params needed to declare DCE attributes and track the attributes changes. It also be used by IDE and validation.</p>
84
+ <custom-element tag="dce-link2" >
85
+ <template>
86
+ <attribute name="p1">default_P1 </attribute>
87
+ <attribute name="p2" select="'always_p2'" ></attribute>
88
+ <attribute name="p3" select="//p3 ?? 'def_P3' "></attribute>
89
+ p1: <code data-testid="p1">{$p1}</code> <br/>
90
+ p2: <code data-testid="p2">{$p2}</code> <br/>
91
+ p3: <code data-testid="p3">{$p3}</code>
92
+ </template>
93
+ </custom-element>
94
+ <section>
95
+ <dce-link2 id="dce2" p1="123" p2="override ignored as select is defined"></dce-link2> <br>
96
+ <div><input id="i1" value="p1"> <button onclick="dce2.setAttribute('p1',i1.value)"> set p1</button> </div>
97
+ <div><input id="i2" value="p2"> <button onclick="dce2.setAttribute('p2',i2.value)"> set p2</button> </div>
98
+ <div><input id="i3" value="p3"> <button onclick="dce2.setAttribute('p3',i3.value)"> set p3</button> </div>
99
+ </section>
100
+ \`
101
+ },
102
+ play: async ({
103
+ canvasElement
104
+ }) => {
105
+ const titleText = (AttributeDefaults.args!.title as string);
106
+ const canvas = within(canvasElement),
107
+ code = async id => (await canvas.findByTestId(id)).textContent.trim();
108
+ await sleep(20);
109
+ expect(await code('p1')).toEqual('123');
110
+ expect(await code('p2')).toEqual('always_p2', 'no overrides due to value is hardcoded');
111
+ expect(await code('p3')).toEqual('def_P3');
112
+ dce2.setAttribute('p1', i1.value);
113
+ await sleep(10);
114
+ expect(await code('p1')).toEqual('p1', 'set p1 in runtime');
115
+ dce2.setAttribute('p2', i2.value);
116
+ await sleep(10);
117
+ expect(await code('p2')).toEqual('always_p2', 'can not set p2 in runtime');
118
+ dce2.setAttribute('p3', i3.value);
119
+ await sleep(10);
120
+ expect(await code('p3')).toEqual('p3', 'set p3 in runtime');
121
+ }
122
+ }`,...c.parameters?.docs?.source}}};p.parameters={...p.parameters,docs:{...p.parameters?.docs,source:{originalSource:`{
123
+ args: {
124
+ title: 'Instance Attributes',
125
+ body: \`
126
+ <p>Params needed to declare DCE attributes and track the attributes changes. It also is used by IDE and validation.</p>
127
+ <custom-element tag="dce-link3" >
128
+ <template>
129
+ <attribute name="p1">default_P1 </attribute>
130
+ <attribute name="p2" select="'always_p2'" ></attribute>
131
+ <attribute name="p3" select="//p3 ?? 'def_P3' "></attribute>
132
+ p1: <code data-testid="p1">{$p1}</code> <br/>
133
+ p2: <code data-testid="p2">{$p2}</code> <br/>
134
+ p3: <code data-testid="p3">{$p3}</code>
135
+ </template>
136
+ </custom-element>
137
+ <dce-link3 id="dce3" p1="123" p3="qwe"></dce-link3> |
138
+ \`
139
+ },
140
+ play: async ({
141
+ canvasElement
142
+ }) => {
143
+ const titleText = (AttributeDefaults.args!.title as string);
144
+ const canvas = within(canvasElement),
145
+ code = async id => (await canvas.findByTestId(id)).textContent.trim();
146
+ await sleep(20);
147
+ expect(await code('p1')).toEqual('123');
148
+ expect(await code('p2')).toEqual('always_p2');
149
+ expect(await code('p3')).toEqual('qwe');
150
+ }
151
+ }`,...p.parameters?.docs?.source}}};const m=["AttributeDefaults","AttributesRuntimeChange","InstanceAttributes"];export{i as AttributeDefaults,c as AttributesRuntimeChange,p as InstanceAttributes,m as __namedExportsOrder,b as default};
@@ -0,0 +1,86 @@
1
+ import{w as u,e as n}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.js";const g={title:"",tag:"",style:"",slot:"",payload:""};function p(t){const{title:e,tag:o,style:s,slot:l,payload:y}={...g,...t};return`
2
+ <fieldset>
3
+ <legend>${e}</legend>
4
+ <custom-element ${o?`tag="${o}"`:""} >
5
+ <template>
6
+ <style>
7
+ ${s}
8
+ </style>
9
+ <u><slot>${l}</slot></u>
10
+ </template>
11
+ </custom-element>
12
+ ${y}
13
+ </fieldset>
14
+ `}const h={title:"Css",render:p},d='<b style="color:green">green</b>',i='<i style="color:red">red</i>',a={args:{title:`The default color should stay on this label, the message inside should be ${d}`,style:"color:green",slot:"text has to be green",payload:"<u>no tags</u>"},play:async({canvasElement:t})=>{const o=await u(t).findByText("text has to be green"),l=getComputedStyle(o).getPropertyValue("color");n(l).to.equal("rgb(0, 128, 0)")}},c={args:{title:`The default color should apply ${d} in all instances`,style:"color:green",slot:"text has to be green",tag:"dce-2",payload:'<u>2 instances:</u> <dce-2 id="dce21"></dce-2> * <dce-2 id="dce22"></dce-2>'},play:async({canvasElement:t})=>{await u(t).findByText("2 instances:");const e=o=>{const s=t.querySelector(o);return getComputedStyle(s).getPropertyValue("color")};n(e("legend")).to.not.equal(e("b")),n(e("legend")).to.not.equal(e("b")),n(e("#dce21 u")).to.equal(e("b")),n(e("#dce22 u")).to.equal(e("b"))}},r={args:{title:`${d} in instance style can be overridden in payload as ${i} in 1st instance`,style:"color:green",slot:"is green",tag:"dce-3",payload:` <u>should be</u> ${i}:<dce-3 id="dce32">
15
+ <template>
16
+ <style> color:red; </style>
17
+ <u>red</u>
18
+ </template>
19
+ </dce-3> <br/>
20
+ should be ${d}: <dce-3 id="dce31">green</dce-3> `},play:async({canvasElement:t})=>{await u(t).findByText("should be");const e=o=>{const s=t.querySelector(o);return getComputedStyle(s).getPropertyValue("color")};n(e("legend")).to.not.equal(e("b")),n(e("#dce31 u")).to.equal(e("b")),n(e("#dce32 u")).to.equal(e("i"))}};a.parameters={...a.parameters,docs:{...a.parameters?.docs,source:{originalSource:`{
21
+ args: {
22
+ title: \`The default color should stay on this label, the message inside should be \${GREEN}\`,
23
+ style: \`color:green\`,
24
+ slot: 'text has to be green',
25
+ payload: '<u>no tags</u>'
26
+ },
27
+ play: async ({
28
+ canvasElement
29
+ }) => {
30
+ const canvas = within(canvasElement);
31
+ const el = await canvas.findByText('text has to be green');
32
+ const st = getComputedStyle(el);
33
+ const color = st.getPropertyValue('color');
34
+ // @ts-ignore
35
+ expect(color).to.equal('rgb(0, 128, 0)');
36
+ }
37
+ }`,...a.parameters?.docs?.source}}};c.parameters={...c.parameters,docs:{...c.parameters?.docs,source:{originalSource:`{
38
+ args: {
39
+ title: \`The default color should apply \${GREEN} in all instances\`,
40
+ style: \`color:green\`,
41
+ slot: 'text has to be green',
42
+ tag: 'dce-2',
43
+ payload: \`<u>2 instances:</u> <dce-2 id="dce21"></dce-2> * <dce-2 id="dce22"></dce-2>\`
44
+ },
45
+ play: async ({
46
+ canvasElement
47
+ }) => {
48
+ await within(canvasElement).findByText('2 instances:');
49
+ const color = (css: string) => {
50
+ const el = canvasElement.querySelector(css);
51
+ const st = getComputedStyle(el!);
52
+ return st.getPropertyValue('color');
53
+ };
54
+ expect(color('legend')).to.not.equal(color('b'));
55
+ expect(color('legend')).to.not.equal(color('b'));
56
+ expect(color('#dce21 u')).to.equal(color('b'));
57
+ expect(color('#dce22 u')).to.equal(color('b'));
58
+ }
59
+ }`,...c.parameters?.docs?.source}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
60
+ args: {
61
+ title: \`\${GREEN} in instance style can be overridden in payload as \${RED} in 1st instance\`,
62
+ style: \`color:green\`,
63
+ slot: 'is green',
64
+ tag: 'dce-3',
65
+ payload: \` <u>should be</u> \${RED}:<dce-3 id="dce32">
66
+ <template>
67
+ <style> color:red; </style>
68
+ <u>red</u>
69
+ </template>
70
+ </dce-3> <br/>
71
+ should be \${GREEN}: <dce-3 id="dce31">green</dce-3> \`
72
+ },
73
+ play: async ({
74
+ canvasElement
75
+ }) => {
76
+ await within(canvasElement).findByText('should be');
77
+ const color = (css: string) => {
78
+ const el = canvasElement.querySelector(css);
79
+ const st = getComputedStyle(el!);
80
+ return st.getPropertyValue('color');
81
+ };
82
+ expect(color('legend')).to.not.equal(color('b'));
83
+ expect(color('#dce31 u')).to.equal(color('b'));
84
+ expect(color('#dce32 u')).to.equal(color('i'));
85
+ }
86
+ }`,...r.parameters?.docs?.source}}};const x=["StyleDoesNotLeak","StyleIn2Instances","OverrideInPayload"];export{r as OverrideInPayload,a as StyleDoesNotLeak,c as StyleIn2Instances,x as __namedExportsOrder,h as default};
@@ -0,0 +1,53 @@
1
+ const M="http://www.w3.org/1999/XSL/Transform",z="http://www.w3.org/1999/xhtml",W="http://exslt.org/common",f=(e,n)=>e.getAttribute?.(n),X=e=>e.nodeType===3,G=e=>typeof e=="string",Y=e=>e&&typeof e.nodeType=="number",E=(e,n="",t=document)=>(s=>(n&&s.append(w(t.ownerDocument||t,n)),s))((t.ownerDocument||t).createElement(e)),w=(e,n)=>(e.ownerDocument||e).createTextNode(n),O=e=>{for(;e.firstChild;)e.firstChild.remove();return e},R=e=>(e.getAttributeNames().map(n=>e.removeAttribute(n)),O(e)),J=e=>(e?.setAttribute("xmlns:xsl",M),e),K=e=>(e?.setAttribute("xmlns:xhtml",z),J(e)),H=(e,n)=>{const t=e.ownerDocument.createElementNS(e.namespaceURI,n);for(let s of e.attributes)t.setAttribute(s.name,s.value);for(;e.firstChild;)t.append(e.firstChild);return t};function C(e){return new DOMParser().parseFromString(e,"application/xml")}function I(e){return new XMLSerializer().serializeToString(e)}function D(e,n,t,s){const l=p=>e.ownerDocument.createElement(p),h=((p,y,d)=>(y.append(d=l(p)),d))(n,e);return[...t].forEach(p=>h.append(s(p))),h}function Q(e){return e.slot||(e.setAttribute||(e=E("span",e.textContent.replaceAll(`
2
+ `,""))),e.setAttribute("slot","")),e}function j(e,n,t){const s=typeof e;if(s==="function")debugger;if(s==="string")return E(n,e,t);if(s==="number")return E(n,""+e,t);if(e instanceof Array){const o=E("array");return e.map(h=>o.append(j(h,n,t))),o}const l=E(n,"",t);for(let o in e)Y(e[o])||typeof e[o]=="function"||e[o]instanceof Window||(typeof e[o]!="object"?l.setAttribute(o,e[o]):l.append(j(e[o],o,t)));return l}function k(e){if(S(e,"*",n=>[...n.childNodes].filter(t=>t.nodeType===3).forEach(t=>{if(t.parentNode.localName==="style")return;const s=t.data.matchAll(/{([^}]*)}/g);if(s){let l=0,o=p=>w(t,p||""),h=[];if([...s].forEach(p=>{p.index>l&&h.push(o(p.input.substring(l,p.index)));const y=e.querySelector("value-of").cloneNode();y.setAttribute("select",p[1]),h.push(y),l=p.index+p[0].length}),l<t.data.length&&h.push(o(t.data.substring(l,t.data.length))),h.length){for(let p of h)n.insertBefore(p,t);n.removeChild(t)}}})),"all"in e){let n=1;for(let t of e.all)t.setAttribute&&!t.tagName.startsWith("xsl:")&&t.setAttribute("data-dce-id",""+n++)}return e}function Z(e,n="xsl:stylesheet"){if(e.tagName===n||e.documentElement?.tagName===n)return k(e);const t=C(`<xsl:stylesheet version="1.0" xmlns:xsl="${M}" xmlns:xhtml="${z}" xmlns:exsl="${W}" exclude-result-prefixes="exsl" >
3
+ <xsl:output method="xml" />
4
+ <xsl:template match="/"><dce-root xmlns="${z}"><xsl:apply-templates select="*"/></dce-root></xsl:template>
5
+ <xsl:template match="*[name()='template']"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
6
+ <xsl:template match="*"><xsl:apply-templates mode="sanitize" select="*|text()"/></xsl:template>
7
+ <xsl:template match="*[name()='svg']|*[name()='math']"><xsl:apply-templates mode="sanitize" select="."/></xsl:template>
8
+ <xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]"><xsl:copy><xsl:apply-templates mode="sanitize" select="@*"/><xsl:value-of select="text()"></xsl:value-of></xsl:copy></xsl:template>
9
+ <xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="@*"/><xsl:value-of select="text()"></xsl:value-of></xsl:element></xsl:template>
10
+ <xsl:template mode="sanitize" match="*|@*"><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></xsl:template>
11
+ <xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
12
+ <xsl:template mode="sanitize" match="text()"><dce-text><xsl:copy/></dce-text></xsl:template>
13
+ <xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']"><dce-text><xsl:copy><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:copy></dce-text></xsl:template>
14
+ <xsl:template mode="sanitize" match="xhtml:*"><xsl:element name="{local-name()}"><xsl:apply-templates mode="sanitize" select="*|@*|text()"/></xsl:element></xsl:template>
15
+ </xsl:stylesheet>`),s=new XSLTProcessor,l=(a=>{S(a,"script",g=>g.remove());const i=a.content??a.firstElementChild?.content??a.body??a;re.forEach(g=>S(i,g,x=>ie(x,i)));const N=a.firstElementChild?.content||a.content,v=g=>{const x=C("<xhtml/>"),T=x.importNode(g,!0);return x.replaceChild(T,x.documentElement),K(T)};if(N){const g=E("div");return[...N.childNodes].map(x=>g.append(x.cloneNode(!0))),v(g)}return v(a.documentElement||a.body||a)})(e),o=C(`<xsl:stylesheet version="1.0"
16
+ xmlns:xsl="${M}"
17
+ xmlns:xhtml="${z}"
18
+ xmlns:dce="urn:schemas-epa-wg:dce"
19
+ xmlns:exsl="http://exslt.org/common"
20
+ exclude-result-prefixes="exsl"
21
+ >
22
+ <xsl:template match="ignore">
23
+ <xsl:choose>
24
+ <xsl:when test="//attr">{//attr}</xsl:when>
25
+ <xsl:otherwise>{def}</xsl:otherwise>
26
+ </xsl:choose><xsl:value-of select="."></xsl:value-of></xsl:template>
27
+ <xsl:template mode="payload" match="attributes"></xsl:template>
28
+ <xsl:template match="/">
29
+ <xsl:apply-templates mode="payload" select="/datadom/attributes"/>
30
+ </xsl:template>
31
+ <xsl:template name="slot" >
32
+ <xsl:param name="slotname" />
33
+ <xsl:param name="defaultvalue" />
34
+ <xsl:choose>
35
+ <xsl:when test="//payload/*[@slot=$slotname]">
36
+ <xsl:copy-of select="//payload/*[@slot=$slotname]"/>
37
+ </xsl:when>
38
+ <xsl:otherwise>
39
+ <xsl:copy-of select="$defaultvalue"/>
40
+ </xsl:otherwise>
41
+ </xsl:choose>
42
+ </xsl:template>
43
+ <xsl:variable name="js-injected-body">
44
+ <xsl:call-template name="slot" >
45
+ <xsl:with-param name="slotname" select="''"/>
46
+ <xsl:with-param name="defaultvalue"/>
47
+ </xsl:call-template>
48
+ </xsl:variable>
49
+ </xsl:stylesheet>`);s.importStylesheet(t);const h=s.transformToFragment(l,document),p=(a,i)=>a.querySelector(i),y=p(o,'template[mode="payload"]');if(!h)return console.error("transformation error",{xml:l.outerHTML,xsl:I(t)});const d=[];[...h.querySelectorAll("dce-root>attribute")].forEach(a=>{const i=H(a,"xsl:param"),N=f(a,"name");y.append(i);let v=f(i,"select")?.split("??");v||(v=["//"+N,`'${i.textContent}'`],R(i),i.setAttribute("name",N));let g;if(v?.length>1){i.removeAttribute("select");const x=p(o,'template[match="ignore"]>choose').cloneNode(!0);R(x.firstElementChild).append(w(x,"{"+v[0]+"}")),R(x.lastElementChild).append(w(x,"{"+v[1]+"}")),x.firstElementChild.setAttribute("test",v[0]),i.append(x),g=x.cloneNode(!0)}else g=H(a,"xsl:value-of");g.removeAttribute("name"),a.append(g),a.removeAttribute("select"),d.push(i)}),[...h.querySelectorAll("[value]")].filter(a=>a.getAttribute("value").match(/\{(.*)\?\?(.*)\}/g)).forEach(a=>{const i=f(a,"value");i&&a.setAttribute("value",oe(i))});for(const a of h.childNodes)y.append(o.importNode(a,!0));[...y.querySelectorAll("template")].forEach(a=>y.ownerDocument.documentElement.append(a));const $=p(o,'call-template[name="slot"]'),u=a=>{const i=$.cloneNode(!0),N=f(a,"name")||"";N&&i.firstElementChild.setAttribute("select",`'${N}'`);for(let v of a.childNodes)i.lastElementChild.append(v);return i};S(y,"slot",a=>a.parentNode.replaceChild(u(a),a));const c=k(o);return c.params=d,c}async function ee(e){return await new Promise((t,s)=>{const l=new XMLHttpRequest;l.open("GET",e),l.responseType="document",l.onload=()=>{l.readyState===l.DONE&&l.status===200&&t(l.responseXML||E("div",l.responseText)),s(l.statusText)},l.addEventListener("error",o=>s(o)),l.send()})}const te=(e,n)=>n.split("|").map(t=>t.trim()).map(t=>{if(t.includes("/")){const s=[],l=e.ownerDocument.evaluate(t,e);for(let o;o=l.iterateNext();)s.push(o);return s}return[...e.childNodes].find(s=>s.localName===t)||E(t)}).flat();function se(e,n,t,s){te(e,n).map(l=>{const o=e.ownerDocument,h=t.sliceEventSource,p=t.sliceElement,y=()=>[...l.childNodes].filter(d=>d.nodeType===3||d.localName==="value").map(d=>d.remove());if(h.getAttributeNames().map(d=>l.setAttribute(d,f(h,d))),[...l.childNodes].filter(d=>d.localName==="event").map(d=>d.remove()),t.type==="init"&&y(),l.append(j(t,"event",o)),p.hasAttribute("slice-value")){h.value===void 0?l.removeAttribute("value"):l.setAttribute("value",h.value);const d=B(f(p,"slice-value"),l);y(),l.append(w(o,d))}else{const d=h.value??f(p,"value");y(),d==null?[...l.childNodes].filter(A=>A.localName!=="event").map(A=>A.remove()):G(d)?l.append(w(o,d)):l.append(j(d,"value",l.ownerDocument))}})}function S(e,n,t){e.querySelectorAll&&[...e.querySelectorAll(n)].forEach(t)}const V=(e,n)=>(t=>e===t?null:t&&(t.querySelector(n)||V(t,n)))(e.getRootNode()),le=async(e,n)=>{if(!e||!e.trim())return[n];if(e.startsWith("#"))return(t=>{if(!t)return[];const s=t.querySelectorAll(e);if(s.length)return[...s];const l=t.getRootNode();return l===t?[]:V(l)})(n.parentElement);try{const t=await ee(e),s=new URL(e,location).hash;if(s){const l=t.querySelectorAll(s);return l.length?[...l]:[n]}return[t]}catch{return[n]}};function ne(e,n){if(X(e)){if(!X(n))debugger;return}for(let t of e.attributes)t.namespaceURI?n.setAttributeNS(t.namespaceURI,t.name,t.value):n.setAttribute(t.name,t.value),t.name==="value"&&(n.value=t.value)}function _(e,n=0){const t={};for(const s of e.childNodes){const l=f(s,"data-dce-id")||s.dceId||0;if(!t[l])l?t[l]=1:(t[l]=s.dceId=++n,s.setAttribute&&s.setAttribute("data-dce-id",s.dceId));else{const o=s.dceId=l+"-"+t[l]++;s.setAttribute&&s.setAttribute("data-dce-id",o)}s.childNodes.length&&_(s)}}function F(e,n){if(!n.length)return O(e);const t={};for(let s of e.childNodes)t[s.dceId],X(s)?(s.data.trim(),t[s.dceId||0]=s):t[f(s,"data-dce-id")||0]=s;for(let s of[...n]){const l=f(s,"data-dce-id")||s.dceId,o=t[l];o?(X(s)?o.nodeValue!==s.nodeValue&&(o.nodeValue=s.nodeValue):(ne(s,o),(o.childNodes.length||s.childNodes.length)&&F(o,s.childNodes)),delete t[l]):e.append(s)}for(let s of Object.values(t))s.remove()}function ae(e,n){return e.hasAttribute(n)||e.setAttribute(n,crypto.randomUUID()),e.getAttribute(n)}const oe=e=>[...e?.matchAll(/([^{}]*)(\{)([^}]+)}([^{}]*)/g)].map(t=>`${t[1]}{${P(t[3])}}${t[4]}`).join(""),P=e=>{if(!e.trim())return e;const n=e.split("??"),t=n.shift(),s=P(n.join("??"));return n.length?`concat( ${t} , substring( ${s} , (1+string-length( ${s} )) * string-length( ${t} ) ) )`:e},B=(e,n)=>{e=P(e);const t=n.ownerDocument.evaluate(e,n);switch(t.resultType){case XPathResult.NUMBER_TYPE:return t.numberValue;case XPathResult.STRING_TYPE:return t.stringValue}let s="";for(let l;l=t.iterateNext();)s+=l.textContent;return s},re="stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,template,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback".split(","),ie=(e,n)=>{const t=E("xsl:"+e.localName);for(let s of e.attributes)t.setAttribute(s.name,s.value);for(;e.firstChild;)t.append(e.firstChild);if(e.parentElement)e.parentElement.replaceChild(t,e);else{const s=e.parentElement||n,l=[...s.childNodes];l.forEach((o,h)=>{o===e&&(l[h]=t)}),s.replaceChildren(...l)}};class ce extends HTMLElement{static observedAttributes=["src","tag","hidden"];async connectedCallback(){const n=await le(f(this,"src"),this),t=f(this,"tag"),s=t||"dce-"+crypto.randomUUID();for(const u of n)S(u.templateNode||u.content||u,"style",c=>{const a=c.closest("slot"),i=a?`slot[name="${a.name}"]`:"";c.innerHTML=`${s} ${i}{${c.innerHTML}}`,this.append(c)});const l=n.map(u=>Z(u)),o=l.map((u,c)=>(c=new XSLTProcessor,c.importStylesheet(u),c));Object.defineProperty(this,"xsltString",{get:()=>l.map(u=>I(u)).join(`
50
+ `)});const h=this,p=[...this.templateNode.querySelectorAll("[slice]")],y=p.map(u=>f(u,"slice")).filter(u=>!u.includes("/")).filter((u,c,a)=>a.indexOf(u)===c),d=l.reduce((u,c)=>(c.params&&u.push(...c.params),u),[]);class A extends HTMLElement{static get observedAttributes(){return d.map(c=>f(c,"name"))}#e=0;connectedCallback(){let c=this.childNodes;if(this.firstElementChild?.tagName==="TEMPLATE"){const m=this.firstElementChild;m.remove(),c=m.content.childNodes;for(const r of[...m.content.childNodes])if(r.localName==="style"){const b=ae(this,"data-dce-style");r.innerHTML=`${s}[data-dce-style="${b}"]{${r.innerHTML}}`,m.insertAdjacentElement("beforebegin",r)}else r.nodeType===1?m.insertAdjacentElement("beforebegin",r):r.nodeType===3&&m.insertAdjacentText("beforebegin",r.data)}const a=C("<datadom/>").documentElement,i=(m,r="")=>(b=>(r&&b.append(w(a,r)),b))(a.ownerDocument.createElement(m));D(a,"payload",c,Q),this.innerHTML="",D(a,"attributes",this.attributes,m=>i(m.nodeName,m.value)),D(a,"dataset",Object.keys(this.dataset),m=>i(m,this.dataset[m]));const N=D(a,"slice",y,m=>i(m,"")),v=m=>B(m,N);this.xml=a;const g=[],x=()=>{const m={};for(let r;r=g.pop();){const b=f(r.sliceElement,"slice");m[b]||(se(N,b,r),m[b]=r)}Object.keys(m).length!==0&&q()};let T;this.onSlice=m=>{m.stopPropagation?.(),m.sliceEventSource=m.currentTarget||m.target,g.push(m),T||(T=setTimeout(()=>{x(),T=0},10))};const q=this.transform=()=>{if(this.#e)debugger;this.#e=1,o.map((r,b)=>{const L=r.transformToFragment(a.ownerDocument,document);return L||console.error(`XSLT transformation error. xsl:
51
+ `,I(l[b]),`
52
+ xml:
53
+ `,I(a)),L}).map(r=>{r&&(_(r),F(this,r.childNodes))}),A.observedAttributes.map(r=>{let b=f(this.firstElementChild,r);b!==f(this,r)&&(this.setAttribute(r,b),this.#t(r,b))}),S(this,"[slice]",r=>{if(!r.dceInitialized){r.dceInitialized=1;const b=f(r,"slice-event");(b||"change").split(" ").forEach(L=>(r.localName==="slice"?r.parentElement:r).addEventListener(L,U=>{U.sliceElement=r,this.onSlice(U)})),(!b||b.includes("init"))&&(r.hasAttribute("slice-value")||r.hasAttribute("value")||r.value?this.onSlice({type:"init",target:r,sliceElement:r}):r.value=v(f(r,"slice")))}}),this.#e=0};q(),x()}#t(c,a){let i=this.xml.querySelector(`attributes>${c}`);i?R(i).append(w(i,a)):(i=E(c,a,this.xml),this.xml.querySelector("attributes").append(i))}attributeChangedCallback(c,a,i){!this.xml||this.#e||(this.#t(c,i),this.transform())}get dce(){return h}}const $=u=>{window.customElements.get(u)!==A&&window.customElements.define(u,A)};if(t)$(t);else{const u=s;this.setAttribute("tag",u),$(u);const c=document.createElement(u);this.getAttributeNames().forEach(a=>c.setAttribute(a,this.getAttribute(a))),c.append(...[...this.childNodes].filter(a=>a.localName!=="style")),this.append(c)}}get templateNode(){return this.firstElementChild?.tagName==="TEMPLATE"?this.firstElementChild.content:this}get dce(){return this}get xslt(){return C(this.xsltString)}}window.customElements.define("custom-element",ce);
@@ -0,0 +1,138 @@
1
+ import{w as l,e as a,u as c}from"./index-CDavW7r9.js";import"./custom-element-BLZZ00dz.js";function r(s){return new Promise(t=>setTimeout(t,s))}function d(s){const{title:t,body:e}=s;return`
2
+ <fieldset>
3
+ <legend>${t}</legend>
4
+ ${e}
5
+ </fieldset>
6
+ `}const h={title:"dom-merge",render:d},o={args:{title:"Chars count in textarea",body:`
7
+ <p>Counter update happens on change event(focus change). The update should not interfere with the input</p>
8
+ <custom-element>
9
+ <form>
10
+ <label>
11
+ <textarea slice="text-container" data-testid="textarea-id">Hello world!</textarea>
12
+ <span> Chars count:
13
+ <code data-testid="counter-id">{string-length(//slice/text-container/text())}</code>
14
+ </span>
15
+ </label>
16
+ <br/><input placeholder="after textarea input, click here " data-testid="refocus-id" />
17
+ </form>
18
+ </custom-element>
19
+ `},play:async({canvasElement:s})=>{const t=o.args.title,e=l(s);await e.findByText(t),await r(100),a(await e.findByTestId("textarea-id")).toBeInTheDocument();const n=e.getByTestId("textarea-id");n.value="",n.focus(),await c.keyboard(t),a(n.value).toEqual(t),a(n.value.length).toEqual(t.length);debugger;e.getByTestId("refocus-id").focus(),await r(10),a(e.getByTestId("counter-id").textContent).toEqual(""+t?.length,"counter of symbols")}},i={args:{title:"Word count in HTML input field",body:`
20
+ <p>Counter update happens on keyup event. The update should not interfere with the input</p>
21
+ <custom-element>
22
+ <form>
23
+ <label>
24
+ <input type="text" value="{//txt ?? 'Type time update'}" slice="txt" slice-event="init input" data-testid="input-id">
25
+
26
+ <span> Character count:
27
+ <code data-testid="chars-id"
28
+ >{
29
+ string-length(//slice/txt)
30
+ }</code>
31
+ </span>
32
+ <span> Word count:
33
+ <code data-testid="words-id"
34
+ >{
35
+ string-length(normalize-space(//slice/txt)) -
36
+ string-length(translate(normalize-space(//slice/txt), ' ', '')) + 1
37
+ }</code>
38
+ <!-- The expression first normalizes the string by removing leading and trailing whitespace and
39
+ collapsing internal whitespace into a single space. It then subtracts the length of the string
40
+ with all spaces removed from the length of the original string,
41
+ and adds 1 to account for the last word.
42
+ -->
43
+ </span>
44
+
45
+ </label>
46
+ <p><b>txt</b> slice:</p> <blockquote> {//slice/txt} </blockquote>
47
+ </form>
48
+ </custom-element>
49
+ `},play:async({canvasElement:s})=>{const t=i.args.title,e=l(s);await e.findByText(t);const n=await e.findByTestId("input-id");n.value="",n.focus(),a(n).toBeInTheDocument(),await c.keyboard(t),await r(10),a(n.value).toEqual(t),a(e.getByTestId("chars-id").textContent.trim()).toEqual(""+t.length,"counter of symbols"),a(t.split(" ").length).toEqual(6,"counter of words in text sample"),a(e.getByTestId("words-id").textContent.trim()).toEqual("6","counter of words in render")}};o.parameters={...o.parameters,docs:{...o.parameters?.docs,source:{originalSource:`{
50
+ args: {
51
+ title: 'Chars count in textarea',
52
+ body: \`
53
+ <p>Counter update happens on change event(focus change). The update should not interfere with the input</p>
54
+ <custom-element>
55
+ <form>
56
+ <label>
57
+ <textarea slice="text-container" data-testid="textarea-id">Hello world!</textarea>
58
+ <span> Chars count:
59
+ <code data-testid="counter-id">{string-length(//slice/text-container/text())}</code>
60
+ </span>
61
+ </label>
62
+ <br/><input placeholder="after textarea input, click here " data-testid="refocus-id" />
63
+ </form>
64
+ </custom-element>
65
+ \`
66
+ },
67
+ play: async ({
68
+ canvasElement
69
+ }) => {
70
+ const titleText = (CharsCountInTextarea.args!.title as string);
71
+ const canvas = within(canvasElement);
72
+ await canvas.findByText(titleText);
73
+ await sleep(100);
74
+ expect(await canvas.findByTestId('textarea-id')).toBeInTheDocument();
75
+ const textarea = canvas.getByTestId('textarea-id');
76
+ textarea.value = '';
77
+ textarea.focus();
78
+ await userEvent.keyboard(titleText);
79
+ expect(textarea.value).toEqual(titleText);
80
+ expect(textarea.value.length).toEqual(titleText.length);
81
+ debugger;
82
+ canvas.getByTestId('refocus-id').focus();
83
+ await sleep(10);
84
+ expect(canvas.getByTestId('counter-id').textContent).toEqual('' + titleText?.length, 'counter of symbols');
85
+ }
86
+ }`,...o.parameters?.docs?.source}}};i.parameters={...i.parameters,docs:{...i.parameters?.docs,source:{originalSource:`{
87
+ args: {
88
+ title: 'Word count in HTML input field',
89
+ body: \`
90
+ <p>Counter update happens on keyup event. The update should not interfere with the input</p>
91
+ <custom-element>
92
+ <form>
93
+ <label>
94
+ <input type="text" value="{//txt ?? 'Type time update'}" slice="txt" slice-event="init input" data-testid="input-id">
95
+
96
+ <span> Character count:
97
+ <code data-testid="chars-id"
98
+ >{
99
+ string-length(//slice/txt)
100
+ }</code>
101
+ </span>
102
+ <span> Word count:
103
+ <code data-testid="words-id"
104
+ >{
105
+ string-length(normalize-space(//slice/txt)) -
106
+ string-length(translate(normalize-space(//slice/txt), ' ', '')) + 1
107
+ }</code>
108
+ <!-- The expression first normalizes the string by removing leading and trailing whitespace and
109
+ collapsing internal whitespace into a single space. It then subtracts the length of the string
110
+ with all spaces removed from the length of the original string,
111
+ and adds 1 to account for the last word.
112
+ -->
113
+ </span>
114
+
115
+ </label>
116
+ <p><b>txt</b> slice:</p> <blockquote> {//slice/txt} </blockquote>
117
+ </form>
118
+ </custom-element>
119
+ \`
120
+ },
121
+ play: async ({
122
+ canvasElement
123
+ }) => {
124
+ const titleText = (WordCountOnType.args!.title as string);
125
+ const canvas = within(canvasElement);
126
+ await canvas.findByText(titleText);
127
+ const input = await canvas.findByTestId('input-id');
128
+ input.value = '';
129
+ input.focus();
130
+ expect(input).toBeInTheDocument();
131
+ await userEvent.keyboard(titleText);
132
+ await sleep(10);
133
+ expect(input.value).toEqual(titleText);
134
+ expect(canvas.getByTestId('chars-id').textContent.trim()).toEqual('' + titleText.length, 'counter of symbols');
135
+ expect(titleText.split(' ').length).toEqual(6, 'counter of words in text sample');
136
+ expect(canvas.getByTestId('words-id').textContent.trim()).toEqual('6', 'counter of words in render');
137
+ }
138
+ }`,...i.parameters?.docs?.source}}};const x=["CharsCountInTextarea","WordCountOnType"];export{o as CharsCountInTextarea,i as WordCountOnType,x as __namedExportsOrder,h as default};
@@ -0,0 +1,8 @@
1
+ import{d as l}from"./index-DrFu-skq.js";import{j as _}from"./lit-element-B4_0akdT.js";/**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const O=(o,t)=>t===void 0?o?._$litType$!==void 0:o?._$litType$===t,{global:h}=__STORYBOOK_MODULE_GLOBAL__,{simulatePageLoad:s,simulateDOMContentLoaded:u}=__STORYBOOK_MODULE_PREVIEW_API__;var{Node:y}=h,m=(o,t)=>{let{id:p,component:i}=t;if(!i)throw new Error(`Unable to render story ${p} as the component annotation is missing from the default export`);let n=document.createElement(i);return Object.entries(o).forEach(([d,e])=>{n[d]=e}),n};function M({storyFn:o,kind:t,name:p,showMain:i,showError:n,forceRemount:d},e){let r=o();if(i(),O(r)){(d||!e.querySelector('[id="root-inner"]'))&&(e.innerHTML='<div id="root-inner"></div>');let f=e.querySelector('[id="root-inner"]');_(r,f),s(e)}else if(typeof r=="string")e.innerHTML=r,s(e);else if(r instanceof y){if(e.firstChild===r&&!d)return;e.innerHTML="",e.appendChild(r),u()}else n({title:`Expecting an HTML snippet or DOM node from the story: "${p}" of "${t}".`,description:l`
6
+ Did you forget to return the HTML snippet from the story?
7
+ Use "() => <your snippet or node>" or when defining the story.
8
+ `})}var a={renderer:"web-components"};export{a as parameters,m as render,M as renderToCanvas};
@@ -0,0 +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-B4_0akdT.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
+ 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};