@epa-wg/custom-element-dist 0.0.32 → 0.0.33

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 (219) hide show
  1. package/.storybook/main.ts +3 -7
  2. package/.storybook/preview.ts +4 -6
  3. package/README.md +4 -4
  4. package/coverage/coverage-final.json +7 -18
  5. package/coverage/index.html +30 -30
  6. package/coverage/src/custom-element/coverage.svg +1 -1
  7. package/coverage/src/custom-element/custom-element.js/coverage.svg +1 -1
  8. package/coverage/src/custom-element/custom-element.js.html +579 -429
  9. package/coverage/src/custom-element/http-request.js/coverage.svg +1 -1
  10. package/coverage/src/custom-element/http-request.js.html +13 -13
  11. package/coverage/src/custom-element/index.html +29 -29
  12. package/coverage/src/custom-element/local-storage.js.html +1 -1
  13. package/coverage/src/custom-element/location-element.js.html +31 -31
  14. package/coverage/src/custom-element/module-url.js/coverage.svg +1 -1
  15. package/coverage/src/custom-element/module-url.js.html +20 -20
  16. package/coverage/src/index.html +1 -1
  17. package/coverage/src/mocks/handlers.ts.html +1 -1
  18. package/coverage/src/mocks/index.html +1 -1
  19. package/coverage/src/stories/coverage.svg +1 -1
  20. package/coverage/src/stories/{local-storage.test.stories.ts → frame.canvas.ts}/coverage.svg +1 -1
  21. package/coverage/src/stories/frame.canvas.ts.html +175 -0
  22. package/coverage/src/stories/http-request.stories.ts.html +1 -1
  23. package/coverage/src/stories/index.html +14 -179
  24. package/coverage/src/stories/testStoryBook.ts.html +8 -8
  25. package/coverage/src/sum.ts.html +1 -1
  26. package/dist/custom-element-6slVaFEs.cjs +97 -0
  27. package/dist/custom-element-WnOqmEOe.js +609 -0
  28. package/dist/custom-element-bundle.cjs +1 -1
  29. package/dist/custom-element-bundle.js +2 -2
  30. package/dist/demo/attributes.html +153 -0
  31. package/dist/demo/external-templates-sb-6.html +42 -0
  32. package/dist/demo/external-templates-sb-7.html +42 -0
  33. package/dist/demo/html-template.html +1 -1
  34. package/dist/demo/module-url-sb-2.html +46 -0
  35. package/dist/demo/module-url-sb-4.html +48 -0
  36. package/dist/demo/module-url-sb-5.html +53 -0
  37. package/dist/demo/s.xml +71 -8
  38. package/dist/demo/s.xslt +55 -31
  39. package/dist/demo/ss.html +13 -4
  40. package/dist/mockServiceWorker.js +31 -8
  41. package/package.json +25 -26
  42. package/public/demo/attributes.html +153 -0
  43. package/public/demo/external-templates-sb-6.html +42 -0
  44. package/public/demo/external-templates-sb-7.html +42 -0
  45. package/public/demo/html-template.html +1 -1
  46. package/public/demo/module-url-sb-2.html +46 -0
  47. package/public/demo/module-url-sb-4.html +48 -0
  48. package/public/demo/module-url-sb-5.html +53 -0
  49. package/public/demo/s.xml +71 -8
  50. package/public/demo/s.xslt +55 -31
  51. package/public/demo/ss.html +13 -4
  52. package/public/mockServiceWorker.js +31 -8
  53. package/src/custom-element/custom-element.d.ts +4 -0
  54. package/src/custom-element/custom-element.js +91 -41
  55. package/src/custom-element/demo/attributes.html +153 -0
  56. package/src/custom-element/demo/html-template.html +1 -1
  57. package/src/custom-element/demo/s.xml +71 -8
  58. package/src/custom-element/demo/s.xslt +55 -31
  59. package/src/custom-element/demo/ss.html +13 -4
  60. package/src/custom-element/ide/web-types-dce.json +1 -1
  61. package/src/custom-element/ide/web-types-xsl.json +1 -1
  62. package/src/custom-element/index.html +1 -1
  63. package/src/material/components/badge.html +240 -0
  64. package/src/material/components/dropdown.html +7 -12
  65. package/src/material/components/icon-link.html +1 -0
  66. package/src/material/components/icon.html +253 -0
  67. package/src/material/components/input.html +290 -82
  68. package/src/material/components/menu.html +7 -5
  69. package/src/material/components.html +48 -11
  70. package/src/material/theme/semantic.css +20 -1
  71. package/src/mocks/versions.mock.ts +1 -1
  72. package/src/stories/__screenshots__/attributes.test.stories.ts +1 -0
  73. package/src/stories/__screenshots__/external-template.test.stories.ts +1 -0
  74. package/src/stories/__screenshots__/module-url.test.stories.ts +1 -0
  75. package/src/stories/__screenshots__/stories.test.ts/attributes-Attributes-definition-1.png +0 -0
  76. package/src/stories/__screenshots__/stories.test.ts/attributes-Attributes-runtime-change-1.png +0 -0
  77. package/src/stories/__screenshots__/stories.test.ts/attributes-Instance-Attributes-1.png +0 -0
  78. package/src/stories/__screenshots__/stories.test.ts/attributes-Instance-Attributes-2.png +0 -0
  79. package/src/stories/__screenshots__/stories.test.ts/attributes-cloneAs-el-newTag--1.png +0 -0
  80. package/src/stories/__screenshots__/stories.test.ts/attributes-mergeAttr--from--to---1.png +0 -0
  81. package/src/stories/__screenshots__/stories.test.ts/attributes-mergeAttr--from--to---2.png +0 -0
  82. package/src/stories/__screenshots__/stories.test.ts/attributes-mergeAttr--from--to---3.png +0 -0
  83. package/src/stories/__screenshots__/stories.test.ts/attributes-mix-to-from--1.png +0 -0
  84. package/src/stories/__screenshots__/stories.test.ts/http-request-Attributes-definition-1.png +0 -0
  85. package/src/stories/__screenshots__/stories.test.ts/http-request-Attributes-runtime-change-1.png +0 -0
  86. package/src/stories/__screenshots__/stories.test.ts/http-request-Instance-Attributes-1.png +0 -0
  87. package/src/stories/__screenshots__/stories.test.ts/http-request-Instance-Attributes-2.png +0 -0
  88. package/src/stories/__screenshots__/stories.test.ts/http-request-cloneAs-el-newTag--1.png +0 -0
  89. package/src/stories/__screenshots__/stories.test.ts/http-request-http-request-headers-and-response-status-and-headers-1.png +0 -0
  90. package/src/stories/__screenshots__/stories.test.ts/http-request-http-request-with-delayed--5-seconds-response-1.png +0 -0
  91. package/src/stories/__screenshots__/stories.test.ts/http-request-http-request-with-error-1.png +0 -0
  92. package/src/stories/__screenshots__/stories.test.ts/http-request-mergeAttr--from--to---1.png +0 -0
  93. package/src/stories/__screenshots__/stories.test.ts/http-request-mergeAttr--from--to---2.png +0 -0
  94. package/src/stories/__screenshots__/stories.test.ts/http-request-mergeAttr--from--to---3.png +0 -0
  95. package/src/stories/__screenshots__/stories.test.ts/http-request-mix-to-from--1.png +0 -0
  96. package/src/stories/__screenshots__/stories.test.ts/http-request-url-and-slice-1.png +0 -0
  97. package/src/stories/__screenshots__/stories.test.ts/http-request-url-change-1.png +0 -0
  98. package/src/stories/attributes.test.stories.ts +83 -17
  99. package/src/stories/external-template.test.stories.ts +16 -14
  100. package/src/stories/frame.canvas.ts +31 -0
  101. package/src/stories/module-url.test.stories.ts +29 -61
  102. package/storybook-static/assets/Color-F6OSRLHC-Cbp293x2.js +1 -0
  103. package/storybook-static/assets/Configure-BrFr4SLE.js +165 -0
  104. package/storybook-static/assets/DocsRenderer-CFRXHY34-DhHzJiIO.js +2 -0
  105. package/storybook-static/assets/attributes.test.stories-CzWkKw0e.js +1 -0
  106. package/storybook-static/assets/{attributes.test.stories-D1X6EBrd.js → attributes.test.stories-Gg9LQTEK.js} +109 -38
  107. package/storybook-static/assets/{css.test.stories-Cp_g2hE1.js → css.test.stories-B_3ltOrx.js} +1 -1
  108. package/storybook-static/assets/custom-element-CPnvJnn8.js +97 -0
  109. package/storybook-static/assets/{dom-merge.test.stories-hbpdCka0.js → dom-merge.test.stories-nQxcgLoM.js} +1 -1
  110. package/storybook-static/assets/entry-preview-docs-Dwczwtsc.js +2 -0
  111. package/storybook-static/assets/external-template.test.stories-BivZqBTp.js +1 -0
  112. package/storybook-static/assets/{external-template.test.stories-BK89h6sk.js → external-template.test.stories-DZ-rjnfd.js} +38 -40
  113. package/storybook-static/assets/{form.test.stories-BfoLe_rw.js → form.test.stories-DQhPYtMj.js} +1 -1
  114. package/storybook-static/assets/frame.canvas-ClTqYyMN.js +1 -0
  115. package/storybook-static/assets/{handlers-yVPwH_Nz.js → handlers-CLkps6Nz.js} +17 -14
  116. package/storybook-static/assets/{http-request.stories-CBFJS2Ws.js → http-request.stories-jo0f73nw.js} +1 -1
  117. package/storybook-static/assets/iframe-CZwRpnn9.js +199 -0
  118. package/storybook-static/assets/index-B68YUdzy.js +621 -0
  119. package/storybook-static/assets/index-BwkS7JH_.js +8 -0
  120. package/storybook-static/assets/index-CJQtnF9V.js +1 -0
  121. package/storybook-static/assets/index-Dr4PwNfd.js +240 -0
  122. package/storybook-static/assets/{local-storage.test.stories-C0Yzy6Am.js → local-storage.test.stories-uA5EKRPf.js} +1 -1
  123. package/storybook-static/assets/{location-element.test.stories-DNFrEu5A.js → location-element.test.stories-Cu-6Elcg.js} +1 -1
  124. package/storybook-static/assets/module-url.test.stories-CD_wusXQ.js +142 -0
  125. package/storybook-static/assets/module-url.test.stories-CTjUAk3J.js +1 -0
  126. package/storybook-static/assets/preview-1xJJ3sKE.js +1 -0
  127. package/storybook-static/assets/preview-BFlNN3Wj.js +1 -0
  128. package/storybook-static/assets/preview-CTOeX_lO.js +1 -0
  129. package/storybook-static/assets/preview-Cm4PPhHS.js +50 -0
  130. package/storybook-static/assets/preview-CuCH40jj.js +2 -0
  131. package/storybook-static/assets/preview-DfTudP20.js +1 -0
  132. package/storybook-static/assets/{set-url.test.stories-BBfLxv2u.js → set-url.test.stories-CY7B9BVZ.js} +1 -1
  133. package/storybook-static/assets/{slice-events.test.stories-HcXF8XQI.js → slice-events.test.stories-BVnPXm6e.js} +1 -1
  134. package/storybook-static/assets/{slots.test.stories-i6mnIFM2.js → slots.test.stories-Dxsa9KdA.js} +1 -1
  135. package/storybook-static/assets/{version-select.test.stories-BsUFH6Va.js → version-select.test.stories-Buga1PAa.js} +1 -1
  136. package/storybook-static/demo/attributes.html +153 -0
  137. package/storybook-static/demo/external-templates-sb-6.html +42 -0
  138. package/storybook-static/demo/external-templates-sb-7.html +42 -0
  139. package/storybook-static/demo/html-template.html +1 -1
  140. package/storybook-static/demo/module-url-sb-2.html +46 -0
  141. package/storybook-static/demo/module-url-sb-4.html +48 -0
  142. package/storybook-static/demo/module-url-sb-5.html +53 -0
  143. package/storybook-static/demo/s.xml +71 -8
  144. package/storybook-static/demo/s.xslt +55 -31
  145. package/storybook-static/demo/ss.html +13 -4
  146. package/storybook-static/iframe.html +1 -1
  147. package/storybook-static/index.html +6 -10
  148. package/storybook-static/index.json +1 -1
  149. package/storybook-static/mockServiceWorker.js +31 -8
  150. package/storybook-static/project.json +1 -1
  151. package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +3 -0
  152. package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +8 -8
  153. package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +391 -0
  154. package/storybook-static/sb-addons/essentials-docs-3/manager-bundle.js +230 -0
  155. package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +1 -1
  156. package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +1 -1
  157. package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +1 -1
  158. package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +1 -1
  159. package/storybook-static/sb-addons/interactions-9/manager-bundle.js +58 -58
  160. package/storybook-static/sb-manager/globals-module-info.js +9 -0
  161. package/storybook-static/sb-manager/globals-runtime.js +10719 -10473
  162. package/storybook-static/sb-manager/runtime.js +4944 -6321
  163. package/coverage/src/stories/attributes.test.stories.ts/coverage.svg +0 -10
  164. package/coverage/src/stories/attributes.test.stories.ts.html +0 -814
  165. package/coverage/src/stories/css.test.stories.ts/coverage.svg +0 -10
  166. package/coverage/src/stories/css.test.stories.ts.html +0 -460
  167. package/coverage/src/stories/dom-merge.test.stories.ts/coverage.svg +0 -10
  168. package/coverage/src/stories/dom-merge.test.stories.ts.html +0 -706
  169. package/coverage/src/stories/external-template.test.stories.ts/coverage.svg +0 -10
  170. package/coverage/src/stories/external-template.test.stories.ts.html +0 -865
  171. package/coverage/src/stories/form.test.stories.ts/coverage.svg +0 -10
  172. package/coverage/src/stories/form.test.stories.ts.html +0 -661
  173. package/coverage/src/stories/local-storage.test.stories.ts.html +0 -1315
  174. package/coverage/src/stories/location-element.test.stories.ts/coverage.svg +0 -10
  175. package/coverage/src/stories/location-element.test.stories.ts.html +0 -523
  176. package/coverage/src/stories/module-url.test.stories.ts/coverage.svg +0 -10
  177. package/coverage/src/stories/module-url.test.stories.ts.html +0 -640
  178. package/coverage/src/stories/set-url.test.stories.ts/coverage.svg +0 -10
  179. package/coverage/src/stories/set-url.test.stories.ts.html +0 -433
  180. package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +0 -10
  181. package/coverage/src/stories/slice-events.test.stories.ts.html +0 -952
  182. package/coverage/src/stories/slots.test.stories.ts/coverage.svg +0 -10
  183. package/coverage/src/stories/slots.test.stories.ts.html +0 -742
  184. package/coverage/src/stories/version-select.test.stories.ts/coverage.svg +0 -10
  185. package/coverage/src/stories/version-select.test.stories.ts.html +0 -397
  186. package/dist/custom-element-D2wf_rqP.js +0 -576
  187. package/dist/custom-element-Dtzhbjkc.cjs +0 -97
  188. package/storybook-static/assets/Color-F6OSRLHC-BU3iy8jH.js +0 -1
  189. package/storybook-static/assets/Configure-DN6ifayP.js +0 -165
  190. package/storybook-static/assets/DocsRenderer-CFRXHY34-BaVEufDj.js +0 -2
  191. package/storybook-static/assets/custom-element-uuAtIYWS.js +0 -97
  192. package/storybook-static/assets/entry-preview-docs-BbcIMweR.js +0 -2
  193. package/storybook-static/assets/iframe-CJEL_4Nu.js +0 -2
  194. package/storybook-static/assets/index-BcZLpTeD.js +0 -8
  195. package/storybook-static/assets/index-CxRwF5Or.js +0 -234
  196. package/storybook-static/assets/index-D-8MO0q_.js +0 -1
  197. package/storybook-static/assets/index-D5fBh-7N.js +0 -1
  198. package/storybook-static/assets/index-DM-KBPdl.js +0 -1
  199. package/storybook-static/assets/index-RSFf30w1.js +0 -1
  200. package/storybook-static/assets/index-SnjB5uV8.js +0 -769
  201. package/storybook-static/assets/module-url.test.stories-CXibF5Ta.js +0 -208
  202. package/storybook-static/assets/preview-BhhEZcNS.js +0 -1
  203. package/storybook-static/assets/preview-Bnd0XhaF.js +0 -52
  204. package/storybook-static/assets/preview-CNKoaWES.js +0 -1
  205. package/storybook-static/assets/preview-DAeyCMnM.js +0 -1
  206. package/storybook-static/assets/preview-DHPc-V4N.js +0 -1
  207. package/storybook-static/assets/preview-DJMlNTk8.js +0 -2
  208. package/storybook-static/assets/preview-DYzi3Z2p.js +0 -1
  209. package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +0 -333
  210. package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js.LEGAL.txt +0 -40
  211. package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +0 -3
  212. package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +0 -391
  213. package/storybook-static/sb-addons/links-1/manager-bundle.js +0 -3
  214. package/storybook-static/sb-preview/globals.js +0 -33
  215. package/storybook-static/sb-preview/runtime.js +0 -7174
  216. package/test-runner-jest.config.js +0 -15
  217. /package/storybook-static/sb-addons/{essentials-actions-3 → essentials-actions-2}/manager-bundle.js.LEGAL.txt +0 -0
  218. /package/storybook-static/sb-addons/{essentials-controls-2 → essentials-controls-1}/manager-bundle.js.LEGAL.txt +0 -0
  219. /package/storybook-static/sb-addons/{links-1 → essentials-docs-3}/manager-bundle.js.LEGAL.txt +0 -0
@@ -8,8 +8,8 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.4.5'
12
- const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
11
+ const PACKAGE_VERSION = '2.7.0'
12
+ const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
13
13
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
14
14
  const activeClientIds = new Set()
15
15
 
@@ -62,7 +62,12 @@ self.addEventListener('message', async function (event) {
62
62
 
63
63
  sendToClient(client, {
64
64
  type: 'MOCKING_ENABLED',
65
- payload: true,
65
+ payload: {
66
+ client: {
67
+ id: client.id,
68
+ frameType: client.frameType,
69
+ },
70
+ },
66
71
  })
67
72
  break
68
73
  }
@@ -155,6 +160,10 @@ async function handleRequest(event, requestId) {
155
160
  async function resolveMainClient(event) {
156
161
  const client = await self.clients.get(event.clientId)
157
162
 
163
+ if (activeClientIds.has(event.clientId)) {
164
+ return client
165
+ }
166
+
158
167
  if (client?.frameType === 'top-level') {
159
168
  return client
160
169
  }
@@ -183,12 +192,26 @@ async function getResponse(event, client, requestId) {
183
192
  const requestClone = request.clone()
184
193
 
185
194
  function passthrough() {
186
- const headers = Object.fromEntries(requestClone.headers.entries())
195
+ // Cast the request headers to a new Headers instance
196
+ // so the headers can be manipulated with.
197
+ const headers = new Headers(requestClone.headers)
198
+
199
+ // Remove the "accept" header value that marked this request as passthrough.
200
+ // This prevents request alteration and also keeps it compliant with the
201
+ // user-defined CORS policies.
202
+ const acceptHeader = headers.get('accept')
203
+ if (acceptHeader) {
204
+ const values = acceptHeader.split(',').map((value) => value.trim())
205
+ const filteredValues = values.filter(
206
+ (value) => value !== 'msw/passthrough',
207
+ )
187
208
 
188
- // Remove internal MSW request header so the passthrough request
189
- // complies with any potential CORS preflight checks on the server.
190
- // Some servers forbid unknown request headers.
191
- delete headers['x-msw-intention']
209
+ if (filteredValues.length > 0) {
210
+ headers.set('accept', filteredValues.join(', '))
211
+ } else {
212
+ headers.delete('accept')
213
+ }
214
+ }
192
215
 
193
216
  return fetch(requestClone, { headers })
194
217
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epa-wg/custom-element-dist",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -10,40 +10,39 @@
10
10
  "preview": "vite preview",
11
11
  "storybook": "storybook dev -p 6006",
12
12
  "build-storybook": "storybook build",
13
- "test": "node bin/vitest/vitest-browser-importmaps.mjs && vitest --coverage.enabled --coverage.all --no-file-parallelism --watch=false",
13
+ "test": "node bin/vitest/vitest-browser-importmaps.mjs && vitest --coverage.enabled --coverage.all --no-file-parallelism --watch=false ",
14
14
  "test:ff": "yarn test --browser.name=firefox",
15
15
  "test:watch": "vitest --inspect-brk --no-file-parallelism --browser.headless=false --test-timeout=0",
16
16
  "test:storybook": "test-storybook",
17
17
  "sb": "yarn storybook",
18
18
  "t": "node ./node_modules/vitest/vitest.mjs --no-file-parallelism --watch --browser.headless=false src/stories/module-url.test.stories.ts",
19
- "tf": "node ./node_modules/vitest/vitest.mjs --no-file-parallelism --browser.name=firefox --watch --browser.headless=false src/stories/module-url.test.stories.ts"
19
+ "tt": "vitest --coverage.enabled --coverage.all --no-file-parallelism --watch --browser.headless=false src/stories/external-template.test.stories.ts "
20
20
  },
21
21
  "dependencies": {
22
- "@epa-wg/custom-element": "0.0.32"
22
+ "@epa-wg/custom-element": "0.0.33"
23
23
  },
24
24
  "devDependencies": {
25
- "@chromatic-com/storybook": "^3.2.2",
26
- "@storybook/addon-essentials": "^8.4.2",
27
- "@storybook/addon-interactions": "^8.4.2",
28
- "@storybook/addon-links": "^8.4.2",
29
- "@storybook/addon-mdx-gfm": "^8.4.2",
30
- "@storybook/blocks": "^8.4.2",
31
- "@storybook/test": "^8.4.2",
32
- "@storybook/test-runner": "0.19.1",
33
- "@storybook/web-components": "^8.4.2",
34
- "@storybook/web-components-vite": "^8.4.2",
35
- "@vitest/browser": "2.0.5",
36
- "@vitest/coverage-istanbul": "2.0.5",
25
+ "@storybook/addon-essentials": "8.5.3",
26
+ "@storybook/addon-interactions": "8.5.3",
27
+ "@storybook/addon-links": "8.5.3",
28
+ "@storybook/addon-mdx-gfm": "8.5.3",
29
+ "@storybook/blocks": "8.5.3",
30
+ "@storybook/test": "8.5.3",
31
+ "@storybook/test-runner": "0.21.0",
32
+ "@storybook/web-components": "8.5.3",
33
+ "@storybook/web-components-vite": "8.5.3",
34
+ "@vitest/browser": "3.0.5",
35
+ "@vitest/coverage-istanbul": "3.0.5",
37
36
  "coverage-svg": "0.0.3",
38
- "lit": "3.2.0",
39
- "msw": "2.4.5",
40
- "msw-storybook-addon": "^2.0.4",
41
- "playwright": "1.47.0",
42
- "storybook": "^8.4.2",
43
- "typescript": "5.6.2",
44
- "vite": "5.4.8",
45
- "vitest": "2.0.5",
46
- "webdriverio": "9.0.9"
37
+ "lit": "3.2.1",
38
+ "msw": "2.7.0",
39
+ "msw-storybook-addon": "2.0.4",
40
+ "playwright": "1.50.1",
41
+ "storybook": "8.5.3",
42
+ "typescript": "5.7.3",
43
+ "vite": "6.1.0",
44
+ "vitest": "3.0.5",
45
+ "webdriverio": "9.9.0"
47
46
  },
48
47
  "msw": {
49
48
  "workerDirectory": [
@@ -96,4 +95,4 @@
96
95
  "./src/custom-element/ide/web-types-dce.json",
97
96
  "./src/custom-element/ide/web-types-xsl.json"
98
97
  ]
99
- }
98
+ }
@@ -0,0 +1,153 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
+ xmlns:xhtml="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
+ <title>parameters - custom-element Declarative Custom Element implementation demo</title>
7
+ <link rel="icon" href="./wc-square.svg" />
8
+ <script type="module" src="../location-element.js"></script>
9
+ <script type="module" src="../custom-element.js"></script>
10
+ <style>
11
+ @import "./demo.css";
12
+
13
+ button{ background: forestgreen; }
14
+ table{ min-width: 16rem; }
15
+ td{ border-bottom: 1px solid silver; }
16
+ tfoot td{ border-bottom: none; }
17
+ td,th{text-align: right; }
18
+ caption{ padding: 1rem; font-weight: bolder; font-family: sans-serif; }
19
+ </style>
20
+ </head>
21
+ <body>
22
+ <nav>
23
+ <a href="../index.html"><h3><code>custom-element</code> demo</h3></a>
24
+ </nav>
25
+ <main>
26
+ <p><code>attribute</code> is used for DCE attributes declaration and track the attributes changes. It also be used by IDE and validation.</p>
27
+ <p>The attribute can be changed by component itself and used as output to the container.
28
+ Usual case is when <code>value</code> attribute is updated from inside.</p>
29
+ <p>Initial value of attribute is available on the <code>attributes</code> node attribute as in <code>/datadom/attributes/@attr1</code></p>
30
+ <p>The current, i.e. including the changes by component itself, attribute value is a child node of <code>attributes</code> as in <code>/datadom/attributes/attr1</code>.</p>
31
+ <p>To define the attribute which is modified from within, the 3 parts are usually used as in <code>//s[//s/event] ?? //attributes/@v ?? 'def' </code>
32
+ <ol>
33
+ <li><code>//s[//s/event]</code> the slice <code>s</code> with event gives the slice value which was modified by user event like input</li>
34
+ <li><code>//attributes/@v</code> the attribute passed by container</li>
35
+ <li><code>'def' </code> the default value which used when no user input or attribute set by container</li>
36
+ </ol>
37
+ </p>
38
+ </main>
39
+ <html-demo-element legend="attributes definition" >
40
+ <p slot="description">
41
+ <code>attribute</code> is used for DCE attributes declaration and track the attributes changes. It also be used by IDE and validation.
42
+
43
+ </p>
44
+ <template>
45
+ <custom-element tag="dce-link" hidden>
46
+ <attribute name="p1" >default_P1 </attribute>
47
+ <attribute name="p2" select="'always_p2'" ></attribute>
48
+ <attribute name="p3" select="//attributes/@p3 ?? 'def_P3' " ></attribute>
49
+ p1:{$p1} <br/> p2: {$p2} <br/> p3: {$p3}
50
+ </custom-element>
51
+ <dce-link id="dce1" ></dce-link>
52
+ <section>
53
+ <dce-link id="dce2" p1="123" p2="override ignored as select is defined"></dce-link> <br/>
54
+ <div><input id="i1" value="p1" /> <button onclick="dce2.setAttribute('p1',i1.value)"> set p1</button> </div>
55
+ <div><input id="i2" value="p2" /> <button onclick="dce2.setAttribute('p2',i2.value)"> set p2</button> </div>
56
+ <div><input id="i3" value="p3" /> <button onclick="dce2.setAttribute('p3',i3.value)"> set p3</button> </div>
57
+ </section>
58
+ <dce-link id="dce3" p1="123" p3="qwe"></dce-link> |
59
+
60
+ </template>
61
+ </html-demo-element>
62
+
63
+ <html-demo-element legend="attribute from slice">
64
+ <p slot="description">
65
+ When slice value points to attribute, it would be populated on slice change.<br/>
66
+ Type in the input field to see the variable $title change. <br/>
67
+ Hover the mouse to see the title attribute text popup.<br/>
68
+ Inspect DCE node in dev tools to see `title` attribute updated while typing.
69
+
70
+ </p>
71
+
72
+ <template>
73
+ <custom-element>
74
+ <template>
75
+ <attribute name="title" select="//title ?? '😃'" ></attribute>
76
+ <input slice="/datadom/attributes/title" slice-event="keyup"/>
77
+ title attribute: {$title}
78
+ </template>
79
+ </custom-element>
80
+ </template>
81
+ </html-demo-element>
82
+
83
+
84
+ <html-demo-element legend="V attribute matches input value" description="
85
+ Type in the input field and observe in DevTools the V attribute changed.
86
+ ">
87
+ <template>
88
+ <custom-element tag="x-input" >
89
+ <template>
90
+ <attribute name="is-changed" select="count(//s/event) &gt; 0"></attribute>
91
+ <attribute name="v" select="//s[//s/event] ?? //attributes/@v ?? 'def' "></attribute>
92
+ /datadom/attributes/v='{/datadom/attributes/v}'<br/>
93
+ same as v='{v}'<br/>
94
+ same as $v='{$v}'<br/>
95
+ //attributes/@v='{//attributes/@v}'<br/>
96
+ //s='{//s}'<br/>
97
+ is-changed ={ is-changed }<br/>
98
+ <input slice="s" slice-event="input" value="{//attributes/v}"/>
99
+ </template>
100
+ </custom-element>
101
+ <x-input></x-input>
102
+ <x-input v="V1"></x-input>
103
+ </template>
104
+ </html-demo-element>
105
+
106
+ <html-demo-element legend="attribute defaults, from container, and from slice" description="
107
+ Type in the input field and observe in DevTools the V attribute changed.
108
+ ">
109
+ <template>
110
+ <custom-element tag="attr-demo">
111
+ <template>
112
+ <variable name="has-input" select="count(//s/*) &gt; 0"></variable>
113
+ <attribute name="v" select="//s[//s/event] ?? //attributes/@v ?? 'def' "></attribute>
114
+ //attributes/v='{//attributes/v}'<br/>
115
+ //attributes/@v='{//attributes/@v}'<br/>
116
+ $v='{$v}'<br/>
117
+ //s='{//s}'<br/>
118
+ A='{//s[//s/event] | //attributes/v[not(//s/event)]}'<br/>
119
+ has-input ={ $has-input }<br/>
120
+ <input slice="s" slice-event="input" />
121
+ </template>
122
+ </custom-element>
123
+
124
+ <attr-demo></attr-demo>
125
+ <attr-demo v="From Container"></attr-demo>
126
+ </template>
127
+ </html-demo-element>
128
+
129
+ <details>
130
+ <summary>Attributes processing</summary>
131
+ To be available in template, <code>custom-element</code> attributes should be
132
+ defined by <code>attribute</code> markup as shown above.
133
+ The value is taken from attribute text content or from <code>select</code> XPath expression<br/>
134
+
135
+ Declared in such way, attributes are exposed via <code><a
136
+ href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes"
137
+ >observedAttributes</a></code>. <br/>
138
+ The template exposes those attributes as <code>xsl:param</code> which makes the attribute value available as
139
+ xsl variable (as attribute name prefixed with $). <br/>
140
+ After transformation the attributes values are read from CE root and copied into DCE component. <br/>
141
+ The DCE attribute change from outside invokes <code>attributeChangedCallback</code> which triggers DCE re-render.
142
+ <p>
143
+ The <code>value</code> attribute is usual case to be propagated from within of <code>custom-element</code>.
144
+ See the <a href="./form.html#sample-5">using custom-element as form input</a> example.
145
+ </p>
146
+ &bull; <a href="https://github.com/EPA-WG/custom-element/blob/main/docs/attributes.md">Design docs</a>
147
+ </details>
148
+
149
+
150
+ <script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
151
+
152
+ </body>
153
+ </html>
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
+ xmlns:xhtml="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <!--
6
+
7
+ This page is part of src/stories/module-url.test.stories.ts, test #2
8
+
9
+ -->
10
+
11
+
12
+
13
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
14
+ <title>importmap custom-element Declarative Custom Element implementation demo</title>
15
+ <link rel="icon" href="./wc-square.svg"/>
16
+ <style>
17
+ dce-root {
18
+ box-shadow: 0 0 0.5rem lime;
19
+ padding: 1rem;
20
+ display: inline-block;
21
+ }
22
+ </style>
23
+ <script type="importmap">
24
+ {
25
+ "imports": {
26
+ "lib-root/": "./lib-dir/",
27
+ "embed-lib": "./lib-dir/embed-lib.html"
28
+ }
29
+ }
30
+ </script>
31
+ <script type="module" src="../src/custom-element/location-element.js"></script>
32
+ <script type="module" src="../src/custom-element/module-url.js"></script>
33
+ <script type="module" src="../src/custom-element/custom-element.js"></script>
34
+ </head>
35
+ <body>
36
+ <p>Should render formula</p>
37
+ <custom-element src="./html-template.html#sophomores-dream">
38
+ <template><i>loading MathML from HTML file ...</i></template>
39
+ </custom-element>
40
+
41
+ </body>
42
+ </html>
@@ -0,0 +1,42 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
+ xmlns:xhtml="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <!--
6
+
7
+ This page is part of src/stories/module-url.test.stories.ts, test #2
8
+
9
+ -->
10
+
11
+
12
+
13
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
14
+ <title>importmap custom-element Declarative Custom Element implementation demo</title>
15
+ <link rel="icon" href="./wc-square.svg"/>
16
+ <style>
17
+ dce-root {
18
+ box-shadow: 0 0 0.5rem lime;
19
+ padding: 1rem;
20
+ display: inline-block;
21
+ }
22
+ </style>
23
+ <script type="importmap">
24
+ {
25
+ "imports": {
26
+ "lib-root/": "./lib-dir/",
27
+ "embed-lib": "./lib-dir/embed-lib.html"
28
+ }
29
+ }
30
+ </script>
31
+ <script type="module" src="../src/custom-element/location-element.js"></script>
32
+ <script type="module" src="../src/custom-element/module-url.js"></script>
33
+ <script type="module" src="../src/custom-element/custom-element.js"></script>
34
+ </head>
35
+ <body>
36
+ <p>Should render tree</p>
37
+ <custom-element src="./html-template.xhtml#embedded-xsl">
38
+ <template>whole XSLT is embedded into HTML body</template>
39
+ </custom-element>
40
+
41
+ </body>
42
+ </html>
@@ -73,7 +73,7 @@
73
73
  <path class="cls-1"
74
74
  d="m184.02,96.93l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
75
75
  </svg>
76
- <math id="sophomores-dream" display="block">
76
+ <math id="sophomores-dream" data-testid="ml-test" display="block">
77
77
  <mrow>
78
78
  <msubsup>
79
79
  <mo>∫</mo>
@@ -0,0 +1,46 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
+ xmlns:xhtml="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <!--
6
+
7
+ This page is part of src/stories/module-url.test.stories.ts, test #2
8
+
9
+ -->
10
+
11
+
12
+
13
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
14
+ <title>importmap custom-element Declarative Custom Element implementation demo</title>
15
+ <link rel="icon" href="./wc-square.svg"/>
16
+ <script type="importmap">
17
+ {
18
+ "imports": {
19
+ "lib-root/": "./lib-dir/",
20
+ "embed-lib": "./lib-dir/embed-lib.html"
21
+ }
22
+ }
23
+ </script>
24
+ <script type="module" src="../src/custom-element/location-element.js"></script>
25
+ <script type="module" src="../src/custom-element/module-url.js"></script>
26
+ <script type="module" src="../src/custom-element/custom-element.js"></script>
27
+ </head>
28
+ <body>
29
+ <p><code>embed-lib</code> resolved to <code>./lib-dir/embed-lib.html</code> by page <i>importmap</i></p>
30
+ <custom-element>
31
+ <template>
32
+ <module-url slice="lib-url" src="embed-lib"></module-url>
33
+ <if test="//lib-url/@error">
34
+ <p>error: <b>{//lib-url/@error}</b></p>
35
+ </if>
36
+ <span data-testid="check">check the link:</span>
37
+ <a href="{//lib-url}">
38
+ <custom-element src="embed-lib#embed-lib-component">
39
+ failed to load
40
+ </custom-element>
41
+ </a>
42
+ </template>
43
+ </custom-element>
44
+
45
+ </body>
46
+ </html>
@@ -0,0 +1,48 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
+ xmlns:xhtml="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <!--
6
+
7
+ This page is part of src/stories/module-url.test.stories.ts, test #2
8
+
9
+ -->
10
+
11
+
12
+
13
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
14
+ <title>importmap custom-element Declarative Custom Element implementation demo</title>
15
+ <link rel="icon" href="./wc-square.svg"/>
16
+ <script type="importmap">
17
+ {
18
+ "imports": {
19
+ "lib-root/": "./lib-dir/",
20
+ "embed-lib": "./lib-dir/embed-lib.html"
21
+ }
22
+ }
23
+ </script>
24
+ <script type="module" src="../src/custom-element/location-element.js"></script>
25
+ <script type="module" src="../src/custom-element/module-url.js"></script>
26
+ <script type="module" src="../src/custom-element/custom-element.js"></script>
27
+ </head>
28
+ <body>
29
+ <p><code>lib-root</code> resolved to <code>lib-dir</code> by page <i>importmap</i></p>
30
+
31
+ <custom-element>
32
+ <template>
33
+ <module-url slice="lib-url" src="lib-root/embed-lib.html#embed-relative-hash"></module-url>
34
+ <module-url slice="img-url" src="lib-root/Smiley.svg"></module-url>
35
+ <if test="//lib-url/@error">
36
+ <p>error: <b>{//lib-url/@error}</b></p>
37
+ </if>
38
+ check the link:
39
+ <a href="{//lib-url}"> lib-root/embed-lib.html#embed-relative-hash <img src="{//img-url}" alt=""/></a>
40
+ <custom-element src="lib-root/embed-lib.html#embed-relative-hash">
41
+ failed to load
42
+ </custom-element>
43
+
44
+ </template>
45
+ </custom-element>
46
+
47
+ </body>
48
+ </html>
@@ -0,0 +1,53 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
+ xmlns:xhtml="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <!--
6
+
7
+ This page is part of src/stories/module-url.test.stories.ts, test #2
8
+
9
+ -->
10
+
11
+
12
+
13
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
14
+ <title>importmap custom-element Declarative Custom Element implementation demo</title>
15
+ <link rel="icon" href="./wc-square.svg"/>
16
+ <style>
17
+ dce-root {
18
+ box-shadow: 0 0 0.5rem lime;
19
+ padding: 1rem;
20
+ display: inline-block;
21
+ }
22
+ </style>
23
+ <script type="importmap">
24
+ {
25
+ "imports": {
26
+ "lib-root/": "./lib-dir/",
27
+ "embed-lib": "./lib-dir/embed-lib.html"
28
+ }
29
+ }
30
+ </script>
31
+ <script type="module" src="../src/custom-element/location-element.js"></script>
32
+ <script type="module" src="../src/custom-element/module-url.js"></script>
33
+ <script type="module" src="../src/custom-element/custom-element.js"></script>
34
+ </head>
35
+ <body>
36
+ <p>should render '👍 from embed-relative-file' and Vulcan Salute 🖖. Links should open matching page
37
+ </p>
38
+ <custom-element>
39
+ <template>
40
+ <module-url slice="lib-url" src="lib-root/embed-lib.html#embed-relative-file"></module-url>
41
+ <if test="//lib-url/@error">
42
+ <p>error: <b>{//lib-url/@error}</b></p>
43
+ </if>
44
+ check the link:
45
+ <a href="{//lib-url}"> lib-root/embed-lib.html#embed-relative-file </a>
46
+ <custom-element src="lib-root/embed-lib.html#embed-relative-file">
47
+ failed to load
48
+ </custom-element>
49
+ </template>
50
+ </custom-element>
51
+
52
+ </body>
53
+ </html>
package/public/demo/s.xml CHANGED
@@ -1,12 +1,75 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <datadom>
3
- <payload xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"/>
4
- <attributes>
5
- <id>dce1</id>
6
- <p1>default_P1</p1>
7
- <p2>always_p2</p2>
8
- <p3></p3>
3
+ <payload xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
4
+ <div xmlns="http://www.w3.org/1999/xhtml" slot="leading" data-dce-id="4">
5
+ <cem-icon image="history_edu" class="input-focused" data-dce-id="5">
6
+ <dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"
7
+ xmlns:dce="urn:schemas-epa-wg:dce" data-dce-id="1">
8
+ <span xmlns="" class="icon material-icons" data-dce-id="5">history_edu</span>
9
+ </dce-root>
10
+ </cem-icon>
11
+ <cem-icon image="edit" class="input-unfocused" data-dce-id="6">
12
+ <dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"
13
+ xmlns:dce="urn:schemas-epa-wg:dce" data-dce-id="1">
14
+ <span xmlns="" class="icon material-icons" data-dce-id="5">edit</span>
15
+ </dce-root>
16
+ </cem-icon>
17
+ </div>
18
+ <div xmlns="http://www.w3.org/1999/xhtml" slot="trailing" data-dce-id="7">
19
+ <label class="eye-contailer" for="visible-cb" data-dce-id="8">
20
+ <cem-icon image="visibility" class="visible-ico" tabindex="0" data-dce-id="9">
21
+ <dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"
22
+ xmlns:dce="urn:schemas-epa-wg:dce" data-dce-id="1">
23
+ <span xmlns="" class="icon material-icons" data-dce-id="5">visibility</span>
24
+ </dce-root>
25
+ </cem-icon>
26
+ <cem-icon image="visibility_off" class="invisible-ico" tabindex="0" data-dce-id="10">
27
+ <dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"
28
+ xmlns:dce="urn:schemas-epa-wg:dce" data-dce-id="1">
29
+ <span xmlns="" class="icon material-icons" data-dce-id="5">visibility_off</span>
30
+ </dce-root>
31
+ </cem-icon>
32
+ </label>
33
+ <cem-icon image="close" class="clear" tabindex="0" slice="password" slice-event="click" slice-value="''"
34
+ data-dce-id="11">
35
+ <dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"
36
+ xmlns:dce="urn:schemas-epa-wg:dce" data-dce-id="1">
37
+ <span xmlns="" class="icon material-icons" data-dce-id="5">close</span>
38
+ </dce-root>
39
+ </cem-icon>
40
+ <dce-text data-dce-id="12">️
41
+ </dce-text>
42
+ </div>
43
+ </payload>
44
+ <attributes xmlns="" label="password sample" value="secret word" slice="password" data-dce-id="3" type="">
45
+ <xmlns/>
46
+ <label>password sample</label>
47
+ <value>secret word</value>
48
+ <slice>password</slice>
49
+ <data-dce-id>3</data-dce-id>
50
+ <type></type>
9
51
  </attributes>
10
- <dataset/>
11
- <slice/>
52
+ <dataset>
53
+ <dceId>3</dceId>
54
+ </dataset>
55
+ <slice>
56
+ <selected/>
57
+ <password image="close" class="clear" tabindex="0" slice="password" slice-event="click" slice-value="''"
58
+ data-dce-id="11">
59
+ <event isTrusted="true" sliceProcessed="1" pointerId="1" width="1" height="1" pressure="0" tiltX="0"
60
+ tiltY="0" azimuthAngle="0" altitudeAngle="1.5707963267948966" tangentialPressure="0" twist="0"
61
+ pointerType="mouse" isPrimary="false" persistentDeviceId="0" screenX="345" screenY="682"
62
+ clientX="345" clientY="595" ctrlKey="false" shiftKey="false" altKey="false" metaKey="false"
63
+ button="0" buttons="0" pageX="345" pageY="4354" x="345" y="595" offsetX="14" offsetY="15"
64
+ movementX="0" movementY="0" layerX="248" layerY="27" detail="1" which="1" type="click" eventPhase="3"
65
+ bubbles="true" cancelable="true" defaultPrevented="false" composed="true"
66
+ timeStamp="1974517.2999999523" returnValue="true" cancelBubble="false" NONE="0" CAPTURING_PHASE="1"
67
+ AT_TARGET="2" BUBBLING_PHASE="3">
68
+ <relatedTarget/>
69
+ <fromElement/>
70
+ <toElement/>
71
+ <sourceCapabilities firesTouchEvents="false"/>
72
+ </event>
73
+ </password>
74
+ </slice>
12
75
  </datadom>