@beeq/core 1.3.0 → 1.3.2

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 (253) hide show
  1. package/dist/beeq/beeq.esm.js +1 -1
  2. package/dist/beeq/beeq.esm.js.map +1 -1
  3. package/dist/beeq/{p-f5c46b74.entry.js → p-0af526fc.entry.js} +2 -2
  4. package/dist/beeq/{p-3d9f8f4c.entry.js → p-0b6e3137.entry.js} +2 -2
  5. package/dist/beeq/{p-2a599238.entry.js → p-1c789890.entry.js} +2 -2
  6. package/dist/beeq/{p-a0ac903c.entry.js → p-1f370b12.entry.js} +2 -2
  7. package/dist/beeq/p-250b8476.entry.js +6 -0
  8. package/dist/beeq/p-250b8476.entry.js.map +1 -0
  9. package/dist/beeq/{p-963d0c4f.entry.js → p-28a9a23d.entry.js} +2 -2
  10. package/dist/beeq/{p-46f7c4c1.entry.js → p-29f90224.entry.js} +2 -2
  11. package/dist/beeq/{p-1d5b1c02.entry.js → p-2f7137e0.entry.js} +2 -2
  12. package/dist/beeq/{p-a9d715ff.entry.js → p-31472c1f.entry.js} +2 -2
  13. package/dist/beeq/{p-58402996.entry.js → p-32134085.entry.js} +2 -2
  14. package/dist/beeq/{p-9d4cbf5d.entry.js → p-354f52d1.entry.js} +2 -2
  15. package/dist/beeq/{p-79ad9f38.entry.js → p-36eb59f9.entry.js} +2 -2
  16. package/dist/beeq/{p-72a87f8b.entry.js → p-3c37a62d.entry.js} +2 -2
  17. package/dist/beeq/{p-1b97db7b.entry.js → p-42c5530c.entry.js} +2 -2
  18. package/dist/beeq/{p-ee80837c.entry.js → p-47d89d61.entry.js} +2 -2
  19. package/dist/beeq/{p-fb77966e.entry.js → p-51603d69.entry.js} +2 -2
  20. package/dist/beeq/p-51603d69.entry.js.map +1 -0
  21. package/dist/beeq/{p-ce4381eb.entry.js → p-6c1ddc44.entry.js} +2 -2
  22. package/dist/beeq/{p-c751eaae.entry.js → p-6d5d2460.entry.js} +2 -2
  23. package/dist/beeq/{p-ff5975d9.entry.js → p-70d07837.entry.js} +2 -2
  24. package/dist/beeq/p-70d07837.entry.js.map +1 -0
  25. package/dist/beeq/{p-e058f266.entry.js → p-7d3c9c9a.entry.js} +2 -2
  26. package/dist/beeq/{p-0f4ba6f9.entry.js → p-81a34a07.entry.js} +2 -2
  27. package/dist/beeq/{p-b11bc216.entry.js → p-852c54d8.entry.js} +2 -2
  28. package/dist/beeq/{p-d9705a72.entry.js → p-8593ad98.entry.js} +2 -2
  29. package/dist/beeq/{p-2f03d7b8.entry.js → p-8b57cd5e.entry.js} +2 -2
  30. package/dist/beeq/{p-7a2583e7.entry.js → p-981797b1.entry.js} +2 -2
  31. package/dist/beeq/{p-71f52777.entry.js → p-a30ba2bd.entry.js} +2 -2
  32. package/dist/beeq/{p-a82da834.entry.js → p-ab632829.entry.js} +2 -2
  33. package/dist/beeq/{p-42215cd4.entry.js → p-ada3ca0a.entry.js} +2 -2
  34. package/dist/beeq/{p-39907ce1.entry.js → p-bb8f8b78.entry.js} +2 -2
  35. package/dist/beeq/{p-bce94669.entry.js → p-c14e94e0.entry.js} +2 -2
  36. package/dist/beeq/p-c6dd73ea.js +6 -0
  37. package/dist/beeq/p-c6dd73ea.js.map +1 -0
  38. package/dist/beeq/{p-98b445c2.entry.js → p-c893951f.entry.js} +2 -2
  39. package/dist/beeq/{p-91c11876.entry.js → p-cbca544b.entry.js} +2 -2
  40. package/dist/beeq/{p-c4dcf2ed.entry.js → p-d11fafe0.entry.js} +2 -2
  41. package/dist/beeq/{p-f0b04dd5.entry.js → p-d27ad8a0.entry.js} +2 -2
  42. package/dist/beeq/p-d27ad8a0.entry.js.map +1 -0
  43. package/dist/beeq/{p-63c1c8fc.entry.js → p-d58a7c27.entry.js} +2 -2
  44. package/dist/beeq/p-d5c5b299.entry.js +6 -0
  45. package/dist/beeq/p-d5c5b299.entry.js.map +1 -0
  46. package/dist/beeq/{p-e730f8dc.entry.js → p-de827971.entry.js} +2 -2
  47. package/dist/beeq/{p-fb1a243e.entry.js → p-e2b64861.entry.js} +2 -2
  48. package/dist/beeq/p-fbd8dd21.js +7 -0
  49. package/dist/beeq/p-fbd8dd21.js.map +1 -0
  50. package/dist/cjs/beeq.cjs.js +28 -30
  51. package/dist/cjs/beeq.cjs.js.map +1 -1
  52. package/dist/cjs/bq-accordion-group.cjs.entry.js +1 -1
  53. package/dist/cjs/bq-accordion.cjs.entry.js +1 -1
  54. package/dist/cjs/bq-alert.cjs.entry.js +1 -1
  55. package/dist/cjs/bq-avatar.cjs.entry.js +1 -1
  56. package/dist/cjs/bq-badge.cjs.entry.js +1 -1
  57. package/dist/cjs/bq-breadcrumb-item.cjs.entry.js +1 -1
  58. package/dist/cjs/bq-breadcrumb.cjs.entry.js +1 -1
  59. package/dist/cjs/bq-button.cjs.entry.js +2 -2
  60. package/dist/cjs/bq-button.cjs.entry.js.map +1 -1
  61. package/dist/cjs/bq-card.cjs.entry.js +1 -1
  62. package/dist/cjs/bq-checkbox.cjs.entry.js +4 -4
  63. package/dist/cjs/bq-checkbox.cjs.entry.js.map +1 -1
  64. package/dist/cjs/bq-dialog.cjs.entry.js +1 -1
  65. package/dist/cjs/bq-divider.cjs.entry.js +1 -1
  66. package/dist/cjs/bq-drawer.cjs.entry.js +2 -2
  67. package/dist/cjs/bq-dropdown_3.cjs.entry.js +1 -1
  68. package/dist/cjs/bq-empty-state.cjs.entry.js +1 -1
  69. package/dist/cjs/bq-icon.cjs.entry.js +5 -7
  70. package/dist/cjs/bq-icon.cjs.entry.js.map +1 -1
  71. package/dist/cjs/bq-input.cjs.entry.js +1 -1
  72. package/dist/cjs/bq-notification.cjs.entry.js +1 -1
  73. package/dist/cjs/bq-option-group.cjs.entry.js +1 -1
  74. package/dist/cjs/bq-option.cjs.entry.js +1 -1
  75. package/dist/cjs/bq-panel.cjs.entry.js +2 -2
  76. package/dist/cjs/bq-progress.cjs.entry.js +1 -1
  77. package/dist/cjs/bq-radio-group.cjs.entry.js +1 -1
  78. package/dist/cjs/bq-radio.cjs.entry.js +1 -1
  79. package/dist/cjs/bq-select.cjs.entry.js +19 -10
  80. package/dist/cjs/bq-select.cjs.entry.js.map +1 -1
  81. package/dist/cjs/bq-side-menu-item.cjs.entry.js +1 -1
  82. package/dist/cjs/bq-side-menu.cjs.entry.js +1 -1
  83. package/dist/cjs/bq-slider.cjs.entry.js +8 -6
  84. package/dist/cjs/bq-slider.cjs.entry.js.map +1 -1
  85. package/dist/cjs/bq-spinner.cjs.entry.js +1 -1
  86. package/dist/cjs/bq-status.cjs.entry.js +1 -1
  87. package/dist/cjs/bq-step-item.cjs.entry.js +1 -1
  88. package/dist/cjs/bq-steps.cjs.entry.js +1 -1
  89. package/dist/cjs/bq-switch.cjs.entry.js +1 -1
  90. package/dist/cjs/bq-tab-group.cjs.entry.js +1 -1
  91. package/dist/cjs/bq-tab.cjs.entry.js +1 -1
  92. package/dist/cjs/bq-textarea.cjs.entry.js +1 -1
  93. package/dist/cjs/bq-toast.cjs.entry.js +1 -1
  94. package/dist/cjs/bq-tooltip.cjs.entry.js +2 -2
  95. package/dist/cjs/{index-cf0d9d4d.js → index-32f757ed.js} +61 -23
  96. package/dist/cjs/index-32f757ed.js.map +1 -0
  97. package/dist/cjs/index-d55cdb65.js +1792 -0
  98. package/dist/cjs/index-d55cdb65.js.map +1 -0
  99. package/dist/cjs/loader.cjs.js +1 -1
  100. package/dist/collection/collection-manifest.json +1 -1
  101. package/dist/collection/components/button/scss/bq-button.css +1 -1
  102. package/dist/collection/components/checkbox/bq-checkbox.js +7 -6
  103. package/dist/collection/components/checkbox/bq-checkbox.js.map +1 -1
  104. package/dist/collection/components/drawer/scss/bq-drawer.css +1 -1
  105. package/dist/collection/components/icon/__tests__/bq-icon.e2e.js +18 -12
  106. package/dist/collection/components/icon/__tests__/bq-icon.e2e.js.map +1 -1
  107. package/dist/collection/components/icon/bq-icon.js +4 -6
  108. package/dist/collection/components/icon/bq-icon.js.map +1 -1
  109. package/dist/collection/components/icon/helper/request.js +1 -2
  110. package/dist/collection/components/icon/helper/request.js.map +1 -1
  111. package/dist/collection/components/select/__tests__/bq-select.e2e.js +37 -0
  112. package/dist/collection/components/select/__tests__/bq-select.e2e.js.map +1 -1
  113. package/dist/collection/components/select/bq-select.js +18 -9
  114. package/dist/collection/components/select/bq-select.js.map +1 -1
  115. package/dist/collection/components/slider/bq-slider.js +8 -6
  116. package/dist/collection/components/slider/bq-slider.js.map +1 -1
  117. package/dist/collection/components/slider/bq-slider.types.js.map +1 -1
  118. package/dist/collection/components/slider/scss/bq-slider.css +1 -1
  119. package/dist/collection/tools/angular-value-accessor-config.js +2 -2
  120. package/dist/collection/tools/angular-value-accessor-config.js.map +1 -1
  121. package/dist/components/bq-button2.js +1 -1
  122. package/dist/components/bq-button2.js.map +1 -1
  123. package/dist/components/bq-checkbox.js +3 -3
  124. package/dist/components/bq-checkbox.js.map +1 -1
  125. package/dist/components/bq-drawer.js +1 -1
  126. package/dist/components/bq-icon2.js +5 -7
  127. package/dist/components/bq-icon2.js.map +1 -1
  128. package/dist/components/bq-select.js +18 -8
  129. package/dist/components/bq-select.js.map +1 -1
  130. package/dist/components/bq-slider.js +7 -5
  131. package/dist/components/bq-slider.js.map +1 -1
  132. package/dist/components/index2.js +60 -22
  133. package/dist/components/index2.js.map +1 -1
  134. package/dist/esm/beeq.js +29 -31
  135. package/dist/esm/beeq.js.map +1 -1
  136. package/dist/esm/bq-accordion-group.entry.js +1 -1
  137. package/dist/esm/bq-accordion.entry.js +1 -1
  138. package/dist/esm/bq-alert.entry.js +1 -1
  139. package/dist/esm/bq-avatar.entry.js +1 -1
  140. package/dist/esm/bq-badge.entry.js +1 -1
  141. package/dist/esm/bq-breadcrumb-item.entry.js +1 -1
  142. package/dist/esm/bq-breadcrumb.entry.js +1 -1
  143. package/dist/esm/bq-button.entry.js +2 -2
  144. package/dist/esm/bq-button.entry.js.map +1 -1
  145. package/dist/esm/bq-card.entry.js +1 -1
  146. package/dist/esm/bq-checkbox.entry.js +4 -4
  147. package/dist/esm/bq-checkbox.entry.js.map +1 -1
  148. package/dist/esm/bq-dialog.entry.js +1 -1
  149. package/dist/esm/bq-divider.entry.js +1 -1
  150. package/dist/esm/bq-drawer.entry.js +2 -2
  151. package/dist/esm/bq-dropdown_3.entry.js +1 -1
  152. package/dist/esm/bq-empty-state.entry.js +1 -1
  153. package/dist/esm/bq-icon.entry.js +5 -7
  154. package/dist/esm/bq-icon.entry.js.map +1 -1
  155. package/dist/esm/bq-input.entry.js +1 -1
  156. package/dist/esm/bq-notification.entry.js +1 -1
  157. package/dist/esm/bq-option-group.entry.js +1 -1
  158. package/dist/esm/bq-option.entry.js +1 -1
  159. package/dist/esm/bq-panel.entry.js +2 -2
  160. package/dist/esm/bq-progress.entry.js +1 -1
  161. package/dist/esm/bq-radio-group.entry.js +1 -1
  162. package/dist/esm/bq-radio.entry.js +1 -1
  163. package/dist/esm/bq-select.entry.js +19 -10
  164. package/dist/esm/bq-select.entry.js.map +1 -1
  165. package/dist/esm/bq-side-menu-item.entry.js +1 -1
  166. package/dist/esm/bq-side-menu.entry.js +1 -1
  167. package/dist/esm/bq-slider.entry.js +8 -6
  168. package/dist/esm/bq-slider.entry.js.map +1 -1
  169. package/dist/esm/bq-spinner.entry.js +1 -1
  170. package/dist/esm/bq-status.entry.js +1 -1
  171. package/dist/esm/bq-step-item.entry.js +1 -1
  172. package/dist/esm/bq-steps.entry.js +1 -1
  173. package/dist/esm/bq-switch.entry.js +1 -1
  174. package/dist/esm/bq-tab-group.entry.js +1 -1
  175. package/dist/esm/bq-tab.entry.js +1 -1
  176. package/dist/esm/bq-textarea.entry.js +1 -1
  177. package/dist/esm/bq-toast.entry.js +1 -1
  178. package/dist/esm/bq-tooltip.entry.js +2 -2
  179. package/dist/esm/{index-506c67d0.js → index-5aabdd11.js} +61 -23
  180. package/dist/esm/index-5aabdd11.js.map +1 -0
  181. package/dist/esm/index-d71ec085.js +1762 -0
  182. package/dist/esm/index-d71ec085.js.map +1 -0
  183. package/dist/esm/loader.js +2 -2
  184. package/dist/hydrate/index.d.ts +1 -1
  185. package/dist/hydrate/index.js +25020 -15766
  186. package/dist/loader/cdn.js +1 -2
  187. package/dist/loader/index.cjs.js +1 -2
  188. package/dist/loader/index.es2017.js +1 -2
  189. package/dist/loader/index.js +1 -2
  190. package/dist/stencil.config.js +0 -3
  191. package/dist/stencil.config.js.map +1 -1
  192. package/dist/types/components/checkbox/bq-checkbox.d.ts +1 -1
  193. package/dist/types/components/select/bq-select.d.ts +0 -1
  194. package/dist/types/components/slider/bq-slider.types.d.ts +1 -1
  195. package/dist/types/components.d.ts +2 -2
  196. package/dist/types/shared/test-utils/setProperties.d.ts +1 -1
  197. package/dist/types/stencil-public-runtime.d.ts +1 -0
  198. package/package.json +1 -1
  199. package/dist/beeq/p-50709b47.js +0 -7
  200. package/dist/beeq/p-50709b47.js.map +0 -1
  201. package/dist/beeq/p-533aaa93.entry.js +0 -6
  202. package/dist/beeq/p-533aaa93.entry.js.map +0 -1
  203. package/dist/beeq/p-6a04c912.entry.js +0 -6
  204. package/dist/beeq/p-6a04c912.entry.js.map +0 -1
  205. package/dist/beeq/p-c5d2619c.js +0 -6
  206. package/dist/beeq/p-c5d2619c.js.map +0 -1
  207. package/dist/beeq/p-f0b04dd5.entry.js.map +0 -1
  208. package/dist/beeq/p-fb77966e.entry.js.map +0 -1
  209. package/dist/beeq/p-ff5975d9.entry.js.map +0 -1
  210. package/dist/cjs/index-48cab8dd.js +0 -2604
  211. package/dist/cjs/index-48cab8dd.js.map +0 -1
  212. package/dist/cjs/index-cf0d9d4d.js.map +0 -1
  213. package/dist/esm/index-506c67d0.js.map +0 -1
  214. package/dist/esm/index-fe861cd3.js +0 -2573
  215. package/dist/esm/index-fe861cd3.js.map +0 -1
  216. package/dist/esm/polyfills/core-js.js +0 -11
  217. package/dist/esm/polyfills/dom.js +0 -79
  218. package/dist/esm/polyfills/es5-html-element.js +0 -1
  219. package/dist/esm/polyfills/index.js +0 -34
  220. package/dist/esm/polyfills/system.js +0 -6
  221. /package/dist/beeq/{p-f5c46b74.entry.js.map → p-0af526fc.entry.js.map} +0 -0
  222. /package/dist/beeq/{p-3d9f8f4c.entry.js.map → p-0b6e3137.entry.js.map} +0 -0
  223. /package/dist/beeq/{p-2a599238.entry.js.map → p-1c789890.entry.js.map} +0 -0
  224. /package/dist/beeq/{p-a0ac903c.entry.js.map → p-1f370b12.entry.js.map} +0 -0
  225. /package/dist/beeq/{p-963d0c4f.entry.js.map → p-28a9a23d.entry.js.map} +0 -0
  226. /package/dist/beeq/{p-46f7c4c1.entry.js.map → p-29f90224.entry.js.map} +0 -0
  227. /package/dist/beeq/{p-1d5b1c02.entry.js.map → p-2f7137e0.entry.js.map} +0 -0
  228. /package/dist/beeq/{p-a9d715ff.entry.js.map → p-31472c1f.entry.js.map} +0 -0
  229. /package/dist/beeq/{p-58402996.entry.js.map → p-32134085.entry.js.map} +0 -0
  230. /package/dist/beeq/{p-9d4cbf5d.entry.js.map → p-354f52d1.entry.js.map} +0 -0
  231. /package/dist/beeq/{p-79ad9f38.entry.js.map → p-36eb59f9.entry.js.map} +0 -0
  232. /package/dist/beeq/{p-72a87f8b.entry.js.map → p-3c37a62d.entry.js.map} +0 -0
  233. /package/dist/beeq/{p-1b97db7b.entry.js.map → p-42c5530c.entry.js.map} +0 -0
  234. /package/dist/beeq/{p-ee80837c.entry.js.map → p-47d89d61.entry.js.map} +0 -0
  235. /package/dist/beeq/{p-ce4381eb.entry.js.map → p-6c1ddc44.entry.js.map} +0 -0
  236. /package/dist/beeq/{p-c751eaae.entry.js.map → p-6d5d2460.entry.js.map} +0 -0
  237. /package/dist/beeq/{p-e058f266.entry.js.map → p-7d3c9c9a.entry.js.map} +0 -0
  238. /package/dist/beeq/{p-0f4ba6f9.entry.js.map → p-81a34a07.entry.js.map} +0 -0
  239. /package/dist/beeq/{p-b11bc216.entry.js.map → p-852c54d8.entry.js.map} +0 -0
  240. /package/dist/beeq/{p-d9705a72.entry.js.map → p-8593ad98.entry.js.map} +0 -0
  241. /package/dist/beeq/{p-2f03d7b8.entry.js.map → p-8b57cd5e.entry.js.map} +0 -0
  242. /package/dist/beeq/{p-7a2583e7.entry.js.map → p-981797b1.entry.js.map} +0 -0
  243. /package/dist/beeq/{p-71f52777.entry.js.map → p-a30ba2bd.entry.js.map} +0 -0
  244. /package/dist/beeq/{p-a82da834.entry.js.map → p-ab632829.entry.js.map} +0 -0
  245. /package/dist/beeq/{p-42215cd4.entry.js.map → p-ada3ca0a.entry.js.map} +0 -0
  246. /package/dist/beeq/{p-39907ce1.entry.js.map → p-bb8f8b78.entry.js.map} +0 -0
  247. /package/dist/beeq/{p-bce94669.entry.js.map → p-c14e94e0.entry.js.map} +0 -0
  248. /package/dist/beeq/{p-98b445c2.entry.js.map → p-c893951f.entry.js.map} +0 -0
  249. /package/dist/beeq/{p-91c11876.entry.js.map → p-cbca544b.entry.js.map} +0 -0
  250. /package/dist/beeq/{p-c4dcf2ed.entry.js.map → p-d11fafe0.entry.js.map} +0 -0
  251. /package/dist/beeq/{p-63c1c8fc.entry.js.map → p-d58a7c27.entry.js.map} +0 -0
  252. /package/dist/beeq/{p-e730f8dc.entry.js.map → p-de827971.entry.js.map} +0 -0
  253. /package/dist/beeq/{p-fb1a243e.entry.js.map → p-e2b64861.entry.js.map} +0 -0
@@ -1,2573 +0,0 @@
1
- /*!
2
- * Built by Endavans
3
- * © https://beeq.design - Apache 2 License.
4
- */
5
- const NAMESPACE = 'beeq';
6
- const Env = /* beeq */ {};
7
-
8
- /**
9
- * Virtual DOM patching algorithm based on Snabbdom by
10
- * Simon Friis Vindum (@paldepind)
11
- * Licensed under the MIT License
12
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
13
- *
14
- * Modified for Stencil's renderer and slot projection
15
- */
16
- let scopeId;
17
- let hostTagName;
18
- let useNativeShadowDom = false;
19
- let isSvgMode = false;
20
- let queuePending = false;
21
- const createTime = (fnName, tagName = '') => {
22
- {
23
- return () => {
24
- return;
25
- };
26
- }
27
- };
28
- const uniqueTime = (key, measureText) => {
29
- {
30
- return () => {
31
- return;
32
- };
33
- }
34
- };
35
- const CONTENT_REF_ID = 'r';
36
- const ORG_LOCATION_ID = 'o';
37
- const SLOT_NODE_ID = 's';
38
- const TEXT_NODE_ID = 't';
39
- const HYDRATE_ID = 's-id';
40
- const HYDRATED_STYLE_ID = 'sty-id';
41
- const HYDRATE_CHILD_ID = 'c-id';
42
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
43
- /**
44
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
45
- *
46
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
47
- * support as of Stencil v4.
48
- */
49
- const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
50
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
51
- /**
52
- * Default style mode id
53
- */
54
- /**
55
- * Reusable empty obj/array
56
- * Don't add values to these!!
57
- */
58
- const EMPTY_OBJ = {};
59
- /**
60
- * Namespaces
61
- */
62
- const SVG_NS = 'http://www.w3.org/2000/svg';
63
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
64
- const isDef = (v) => v != null;
65
- /**
66
- * Check whether a value is a 'complex type', defined here as an object or a
67
- * function.
68
- *
69
- * @param o the value to check
70
- * @returns whether it's a complex type or not
71
- */
72
- const isComplexType = (o) => {
73
- // https://jsperf.com/typeof-fn-object/5
74
- o = typeof o;
75
- return o === 'object' || o === 'function';
76
- };
77
- /**
78
- * Helper method for querying a `meta` tag that contains a nonce value
79
- * out of a DOM's head.
80
- *
81
- * @param doc The DOM containing the `head` to query against
82
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
83
- * exists or the tag has no content.
84
- */
85
- function queryNonceMetaTagContent(doc) {
86
- var _a, _b, _c;
87
- return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
88
- }
89
- /**
90
- * Production h() function based on Preact by
91
- * Jason Miller (@developit)
92
- * Licensed under the MIT License
93
- * https://github.com/developit/preact/blob/master/LICENSE
94
- *
95
- * Modified for Stencil's compiler and vdom
96
- */
97
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
98
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
99
- const h = (nodeName, vnodeData, ...children) => {
100
- let child = null;
101
- let key = null;
102
- let simple = false;
103
- let lastSimple = false;
104
- const vNodeChildren = [];
105
- const walk = (c) => {
106
- for (let i = 0; i < c.length; i++) {
107
- child = c[i];
108
- if (Array.isArray(child)) {
109
- walk(child);
110
- }
111
- else if (child != null && typeof child !== 'boolean') {
112
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
113
- child = String(child);
114
- }
115
- if (simple && lastSimple) {
116
- // If the previous child was simple (string), we merge both
117
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
118
- }
119
- else {
120
- // Append a new vNode, if it's text, we create a text vNode
121
- vNodeChildren.push(simple ? newVNode(null, child) : child);
122
- }
123
- lastSimple = simple;
124
- }
125
- }
126
- };
127
- walk(children);
128
- if (vnodeData) {
129
- if (vnodeData.key) {
130
- key = vnodeData.key;
131
- }
132
- // normalize class / className attributes
133
- {
134
- const classData = vnodeData.className || vnodeData.class;
135
- if (classData) {
136
- vnodeData.class =
137
- typeof classData !== 'object'
138
- ? classData
139
- : Object.keys(classData)
140
- .filter((k) => classData[k])
141
- .join(' ');
142
- }
143
- }
144
- }
145
- if (typeof nodeName === 'function') {
146
- // nodeName is a functional component
147
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
148
- }
149
- const vnode = newVNode(nodeName, null);
150
- vnode.$attrs$ = vnodeData;
151
- if (vNodeChildren.length > 0) {
152
- vnode.$children$ = vNodeChildren;
153
- }
154
- {
155
- vnode.$key$ = key;
156
- }
157
- return vnode;
158
- };
159
- /**
160
- * A utility function for creating a virtual DOM node from a tag and some
161
- * possible text content.
162
- *
163
- * @param tag the tag for this element
164
- * @param text possible text content for the node
165
- * @returns a newly-minted virtual DOM node
166
- */
167
- const newVNode = (tag, text) => {
168
- const vnode = {
169
- $flags$: 0,
170
- $tag$: tag,
171
- $text$: text,
172
- $elm$: null,
173
- $children$: null,
174
- };
175
- {
176
- vnode.$attrs$ = null;
177
- }
178
- {
179
- vnode.$key$ = null;
180
- }
181
- return vnode;
182
- };
183
- const Host = {};
184
- /**
185
- * Check whether a given node is a Host node or not
186
- *
187
- * @param node the virtual DOM node to check
188
- * @returns whether it's a Host node or not
189
- */
190
- const isHost = (node) => node && node.$tag$ === Host;
191
- /**
192
- * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
193
- *
194
- * Note that these functions convert from {@link d.VNode} to
195
- * {@link d.ChildNode} to give functional component developers a friendly
196
- * interface.
197
- */
198
- const vdomFnUtils = {
199
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
200
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
201
- };
202
- /**
203
- * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
204
- * friendlier public interface (hence, 'convertToPublic').
205
- *
206
- * @param node the virtual DOM node to convert
207
- * @returns a converted child node
208
- */
209
- const convertToPublic = (node) => ({
210
- vattrs: node.$attrs$,
211
- vchildren: node.$children$,
212
- vkey: node.$key$,
213
- vname: node.$name$,
214
- vtag: node.$tag$,
215
- vtext: node.$text$,
216
- });
217
- /**
218
- * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
219
- * order to use the resulting object in the virtual DOM. The initial object was
220
- * likely created as part of presenting a public API, so converting it back
221
- * involved making it 'private' again (hence, `convertToPrivate`).
222
- *
223
- * @param node the child node to convert
224
- * @returns a converted virtual DOM node
225
- */
226
- const convertToPrivate = (node) => {
227
- if (typeof node.vtag === 'function') {
228
- const vnodeData = Object.assign({}, node.vattrs);
229
- if (node.vkey) {
230
- vnodeData.key = node.vkey;
231
- }
232
- if (node.vname) {
233
- vnodeData.name = node.vname;
234
- }
235
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
236
- }
237
- const vnode = newVNode(node.vtag, node.vtext);
238
- vnode.$attrs$ = node.vattrs;
239
- vnode.$children$ = node.vchildren;
240
- vnode.$key$ = node.vkey;
241
- vnode.$name$ = node.vname;
242
- return vnode;
243
- };
244
- /**
245
- * Entrypoint of the client-side hydration process. Facilitates calls to hydrate the
246
- * document and all its nodes.
247
- *
248
- * This process will also reconstruct the shadow root and slot DOM nodes for components using shadow DOM.
249
- *
250
- * @param hostElm The element to hydrate.
251
- * @param tagName The element's tag name.
252
- * @param hostId The host ID assigned to the element by the server.
253
- * @param hostRef The host reference for the element.
254
- */
255
- const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
256
- const endHydrate = createTime('hydrateClient', tagName);
257
- const shadowRoot = hostElm.shadowRoot;
258
- const childRenderNodes = [];
259
- const slotNodes = [];
260
- const shadowRootNodes = shadowRoot ? [] : null;
261
- const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
262
- if (!plt.$orgLocNodes$) {
263
- initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
264
- }
265
- hostElm[HYDRATE_ID] = hostId;
266
- hostElm.removeAttribute(HYDRATE_ID);
267
- clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
268
- childRenderNodes.map((c) => {
269
- const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
270
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
271
- const node = c.$elm$;
272
- // Put the node back in its original location since the native Shadow DOM
273
- // can handle rendering it its correct location now
274
- if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
275
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
276
- }
277
- if (!shadowRoot) {
278
- node['s-hn'] = tagName;
279
- if (orgLocationNode) {
280
- node['s-ol'] = orgLocationNode;
281
- node['s-ol']['s-nr'] = node;
282
- }
283
- }
284
- plt.$orgLocNodes$.delete(orgLocationId);
285
- });
286
- if (shadowRoot) {
287
- shadowRootNodes.map((shadowRootNode) => {
288
- if (shadowRootNode) {
289
- shadowRoot.appendChild(shadowRootNode);
290
- }
291
- });
292
- }
293
- endHydrate();
294
- };
295
- /**
296
- * Recursively constructs the virtual node tree for a host element and its children.
297
- * The tree is constructed by parsing the annotations set on the nodes by the server.
298
- *
299
- * In addition to constructing the vNode tree, we also track information about the node's
300
- * descendants like which are slots, which should exist in the shadow root, and which
301
- * are nodes that should be rendered as children of the parent node.
302
- *
303
- * @param parentVNode The vNode representing the parent node.
304
- * @param childRenderNodes An array of all child nodes in the parent's node tree.
305
- * @param slotNodes An array of all slot nodes in the parent's node tree.
306
- * @param shadowRootNodes An array all nodes that should be rendered in the shadow root in the parent's node tree.
307
- * @param hostElm The parent element.
308
- * @param node The node to construct the vNode tree for.
309
- * @param hostId The host ID assigned to the element by the server.
310
- */
311
- const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
312
- let childNodeType;
313
- let childIdSplt;
314
- let childVNode;
315
- let i;
316
- if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
317
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
318
- if (childNodeType) {
319
- // got the node data from the element's attribute
320
- // `${hostId}.${nodeId}.${depth}.${index}`
321
- childIdSplt = childNodeType.split('.');
322
- if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
323
- childVNode = {
324
- $flags$: 0,
325
- $hostId$: childIdSplt[0],
326
- $nodeId$: childIdSplt[1],
327
- $depth$: childIdSplt[2],
328
- $index$: childIdSplt[3],
329
- $tag$: node.tagName.toLowerCase(),
330
- $elm$: node,
331
- $attrs$: null,
332
- $children$: null,
333
- $key$: null,
334
- $name$: null,
335
- $text$: null,
336
- };
337
- childRenderNodes.push(childVNode);
338
- node.removeAttribute(HYDRATE_CHILD_ID);
339
- // this is a new child vnode
340
- // so ensure its parent vnode has the vchildren array
341
- if (!parentVNode.$children$) {
342
- parentVNode.$children$ = [];
343
- }
344
- // add our child vnode to a specific index of the vnode's children
345
- parentVNode.$children$[childVNode.$index$] = childVNode;
346
- // this is now the new parent vnode for all the next child checks
347
- parentVNode = childVNode;
348
- if (shadowRootNodes && childVNode.$depth$ === '0') {
349
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
350
- }
351
- }
352
- }
353
- // recursively drill down, end to start so we can remove nodes
354
- for (i = node.childNodes.length - 1; i >= 0; i--) {
355
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
356
- }
357
- if (node.shadowRoot) {
358
- // keep drilling down through the shadow root nodes
359
- for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
360
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
361
- }
362
- }
363
- }
364
- else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
365
- // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
366
- childIdSplt = node.nodeValue.split('.');
367
- if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
368
- // comment node for either the host id or a 0 host id
369
- childNodeType = childIdSplt[0];
370
- childVNode = {
371
- $flags$: 0,
372
- $hostId$: childIdSplt[1],
373
- $nodeId$: childIdSplt[2],
374
- $depth$: childIdSplt[3],
375
- $index$: childIdSplt[4],
376
- $elm$: node,
377
- $attrs$: null,
378
- $children$: null,
379
- $key$: null,
380
- $name$: null,
381
- $tag$: null,
382
- $text$: null,
383
- };
384
- if (childNodeType === TEXT_NODE_ID) {
385
- childVNode.$elm$ = node.nextSibling;
386
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
387
- childVNode.$text$ = childVNode.$elm$.textContent;
388
- childRenderNodes.push(childVNode);
389
- // remove the text comment since it's no longer needed
390
- node.remove();
391
- if (!parentVNode.$children$) {
392
- parentVNode.$children$ = [];
393
- }
394
- parentVNode.$children$[childVNode.$index$] = childVNode;
395
- if (shadowRootNodes && childVNode.$depth$ === '0') {
396
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
397
- }
398
- }
399
- }
400
- else if (childVNode.$hostId$ === hostId) {
401
- // this comment node is specifically for this host id
402
- if (childNodeType === SLOT_NODE_ID) {
403
- // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
404
- childVNode.$tag$ = 'slot';
405
- if (childIdSplt[5]) {
406
- node['s-sn'] = childVNode.$name$ = childIdSplt[5];
407
- }
408
- else {
409
- node['s-sn'] = '';
410
- }
411
- node['s-sr'] = true;
412
- if (shadowRootNodes) {
413
- // browser support shadowRoot and this is a shadow dom component
414
- // create an actual slot element
415
- childVNode.$elm$ = doc.createElement(childVNode.$tag$);
416
- if (childVNode.$name$) {
417
- // add the slot name attribute
418
- childVNode.$elm$.setAttribute('name', childVNode.$name$);
419
- }
420
- // insert the new slot element before the slot comment
421
- node.parentNode.insertBefore(childVNode.$elm$, node);
422
- // remove the slot comment since it's not needed for shadow
423
- node.remove();
424
- if (childVNode.$depth$ === '0') {
425
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
426
- }
427
- }
428
- slotNodes.push(childVNode);
429
- if (!parentVNode.$children$) {
430
- parentVNode.$children$ = [];
431
- }
432
- parentVNode.$children$[childVNode.$index$] = childVNode;
433
- }
434
- else if (childNodeType === CONTENT_REF_ID) {
435
- // `${CONTENT_REF_ID}.${hostId}`;
436
- if (shadowRootNodes) {
437
- // remove the content ref comment since it's not needed for shadow
438
- node.remove();
439
- }
440
- }
441
- }
442
- }
443
- }
444
- else if (parentVNode && parentVNode.$tag$ === 'style') {
445
- const vnode = newVNode(null, node.textContent);
446
- vnode.$elm$ = node;
447
- vnode.$index$ = '0';
448
- parentVNode.$children$ = [vnode];
449
- }
450
- };
451
- /**
452
- * Recursively locate any comments representing an original location for a node in a node's
453
- * children or shadowRoot children.
454
- *
455
- * @param node The node to search.
456
- * @param orgLocNodes A map of the original location annotation and the current node being searched.
457
- */
458
- const initializeDocumentHydrate = (node, orgLocNodes) => {
459
- if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
460
- let i = 0;
461
- for (; i < node.childNodes.length; i++) {
462
- initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
463
- }
464
- if (node.shadowRoot) {
465
- for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
466
- initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
467
- }
468
- }
469
- }
470
- else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
471
- const childIdSplt = node.nodeValue.split('.');
472
- if (childIdSplt[0] === ORG_LOCATION_ID) {
473
- orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
474
- node.nodeValue = '';
475
- // useful to know if the original location is
476
- // the root light-dom of a shadow dom component
477
- node['s-en'] = childIdSplt[3];
478
- }
479
- }
480
- };
481
- /**
482
- * Parse a new property value for a given property type.
483
- *
484
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
485
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
486
- * 1. `any`, the type given to `propValue` in the function signature
487
- * 2. the type stored from `propType`.
488
- *
489
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
490
- *
491
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
492
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
493
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
494
- * ```tsx
495
- * <my-cmp prop-val={0}></my-cmp>
496
- * ```
497
- *
498
- * HTML prop values on the other hand, will always a string
499
- *
500
- * @param propValue the new value to coerce to some type
501
- * @param propType the type of the prop, expressed as a binary number
502
- * @returns the parsed/coerced value
503
- */
504
- const parsePropertyValue = (propValue, propType) => {
505
- // ensure this value is of the correct prop type
506
- if (propValue != null && !isComplexType(propValue)) {
507
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
508
- // per the HTML spec, any string value means it is a boolean true value
509
- // but we'll cheat here and say that the string "false" is the boolean false
510
- return propValue === 'false' ? false : propValue === '' || !!propValue;
511
- }
512
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
513
- // force it to be a number
514
- return parseFloat(propValue);
515
- }
516
- if (propType & 1 /* MEMBER_FLAGS.String */) {
517
- // could have been passed as a number or boolean
518
- // but we still want it as a string
519
- return String(propValue);
520
- }
521
- // redundant return here for better minification
522
- return propValue;
523
- }
524
- // not sure exactly what type we want
525
- // so no need to change to a different type
526
- return propValue;
527
- };
528
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
529
- const createEvent = (ref, name, flags) => {
530
- const elm = getElement(ref);
531
- return {
532
- emit: (detail) => {
533
- return emitEvent(elm, name, {
534
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
535
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
536
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
537
- detail,
538
- });
539
- },
540
- };
541
- };
542
- /**
543
- * Helper function to create & dispatch a custom Event on a provided target
544
- * @param elm the target of the Event
545
- * @param name the name to give the custom Event
546
- * @param opts options for configuring a custom Event
547
- * @returns the custom Event
548
- */
549
- const emitEvent = (elm, name, opts) => {
550
- const ev = plt.ce(name, opts);
551
- elm.dispatchEvent(ev);
552
- return ev;
553
- };
554
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
555
- const registerStyle = (scopeId, cssText, allowCS) => {
556
- let style = styles.get(scopeId);
557
- if (supportsConstructableStylesheets && allowCS) {
558
- style = (style || new CSSStyleSheet());
559
- if (typeof style === 'string') {
560
- style = cssText;
561
- }
562
- else {
563
- style.replaceSync(cssText);
564
- }
565
- }
566
- else {
567
- style = cssText;
568
- }
569
- styles.set(scopeId, style);
570
- };
571
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
572
- var _a;
573
- const scopeId = getScopeId(cmpMeta);
574
- const style = styles.get(scopeId);
575
- // if an element is NOT connected then getRootNode() will return the wrong root node
576
- // so the fallback is to always use the document for the root node in those cases
577
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
578
- if (style) {
579
- if (typeof style === 'string') {
580
- styleContainerNode = styleContainerNode.head || styleContainerNode;
581
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
582
- let styleElm;
583
- if (!appliedStyles) {
584
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
585
- }
586
- if (!appliedStyles.has(scopeId)) {
587
- if (styleContainerNode.host &&
588
- (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
589
- // This is only happening on native shadow-dom, do not needs CSS var shim
590
- styleElm.innerHTML = style;
591
- }
592
- else {
593
- styleElm = doc.createElement('style');
594
- styleElm.innerHTML = style;
595
- // Apply CSP nonce to the style tag if it exists
596
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
597
- if (nonce != null) {
598
- styleElm.setAttribute('nonce', nonce);
599
- }
600
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
601
- }
602
- // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
603
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
604
- styleElm.innerHTML += SLOT_FB_CSS;
605
- }
606
- if (appliedStyles) {
607
- appliedStyles.add(scopeId);
608
- }
609
- }
610
- }
611
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
612
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
613
- }
614
- }
615
- return scopeId;
616
- };
617
- const attachStyles = (hostRef) => {
618
- const cmpMeta = hostRef.$cmpMeta$;
619
- const elm = hostRef.$hostElement$;
620
- const flags = cmpMeta.$flags$;
621
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
622
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
623
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
624
- // only required when we're NOT using native shadow dom (slot)
625
- // or this browser doesn't support native shadow dom
626
- // and this host element was NOT created with SSR
627
- // let's pick out the inner content for slot projection
628
- // create a node to represent where the original
629
- // content was first placed, which is useful later on
630
- // DOM WRITE!!
631
- elm['s-sc'] = scopeId;
632
- elm.classList.add(scopeId + '-h');
633
- }
634
- endAttachStyles();
635
- };
636
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
637
- const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
638
- /**
639
- * Production setAccessor() function based on Preact by
640
- * Jason Miller (@developit)
641
- * Licensed under the MIT License
642
- * https://github.com/developit/preact/blob/master/LICENSE
643
- *
644
- * Modified for Stencil's compiler and vdom
645
- */
646
- /**
647
- * When running a VDom render set properties present on a VDom node onto the
648
- * corresponding HTML element.
649
- *
650
- * Note that this function has special functionality for the `class`,
651
- * `style`, `key`, and `ref` attributes, as well as event handlers (like
652
- * `onClick`, etc). All others are just passed through as-is.
653
- *
654
- * @param elm the HTMLElement onto which attributes should be set
655
- * @param memberName the name of the attribute to set
656
- * @param oldValue the old value for the attribute
657
- * @param newValue the new value for the attribute
658
- * @param isSvg whether we're in an svg context or not
659
- * @param flags bitflags for Vdom variables
660
- */
661
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
662
- if (oldValue !== newValue) {
663
- let isProp = isMemberInElement(elm, memberName);
664
- let ln = memberName.toLowerCase();
665
- if (memberName === 'class') {
666
- const classList = elm.classList;
667
- const oldClasses = parseClassList(oldValue);
668
- const newClasses = parseClassList(newValue);
669
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
670
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
671
- }
672
- else if (memberName === 'style') {
673
- // update style attribute, css properties and values
674
- {
675
- for (const prop in oldValue) {
676
- if (!newValue || newValue[prop] == null) {
677
- if (prop.includes('-')) {
678
- elm.style.removeProperty(prop);
679
- }
680
- else {
681
- elm.style[prop] = '';
682
- }
683
- }
684
- }
685
- }
686
- for (const prop in newValue) {
687
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
688
- if (prop.includes('-')) {
689
- elm.style.setProperty(prop, newValue[prop]);
690
- }
691
- else {
692
- elm.style[prop] = newValue[prop];
693
- }
694
- }
695
- }
696
- }
697
- else if (memberName === 'key')
698
- ;
699
- else if (memberName === 'ref') {
700
- // minifier will clean this up
701
- if (newValue) {
702
- newValue(elm);
703
- }
704
- }
705
- else if ((!isProp ) &&
706
- memberName[0] === 'o' &&
707
- memberName[1] === 'n') {
708
- // Event Handlers
709
- // so if the member name starts with "on" and the 3rd characters is
710
- // a capital letter, and it's not already a member on the element,
711
- // then we're assuming it's an event listener
712
- if (memberName[2] === '-') {
713
- // on- prefixed events
714
- // allows to be explicit about the dom event to listen without any magic
715
- // under the hood:
716
- // <my-cmp on-click> // listens for "click"
717
- // <my-cmp on-Click> // listens for "Click"
718
- // <my-cmp on-ionChange> // listens for "ionChange"
719
- // <my-cmp on-EVENTS> // listens for "EVENTS"
720
- memberName = memberName.slice(3);
721
- }
722
- else if (isMemberInElement(win, ln)) {
723
- // standard event
724
- // the JSX attribute could have been "onMouseOver" and the
725
- // member name "onmouseover" is on the window's prototype
726
- // so let's add the listener "mouseover", which is all lowercased
727
- memberName = ln.slice(2);
728
- }
729
- else {
730
- // custom event
731
- // the JSX attribute could have been "onMyCustomEvent"
732
- // so let's trim off the "on" prefix and lowercase the first character
733
- // and add the listener "myCustomEvent"
734
- // except for the first character, we keep the event name case
735
- memberName = ln[2] + memberName.slice(3);
736
- }
737
- if (oldValue || newValue) {
738
- // Need to account for "capture" events.
739
- // If the event name ends with "Capture", we'll update the name to remove
740
- // the "Capture" suffix and make sure the event listener is setup to handle the capture event.
741
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
742
- // Make sure we only replace the last instance of "Capture"
743
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
744
- if (oldValue) {
745
- plt.rel(elm, memberName, oldValue, capture);
746
- }
747
- if (newValue) {
748
- plt.ael(elm, memberName, newValue, capture);
749
- }
750
- }
751
- }
752
- else {
753
- // Set property if it exists and it's not a SVG
754
- const isComplex = isComplexType(newValue);
755
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
756
- try {
757
- if (!elm.tagName.includes('-')) {
758
- const n = newValue == null ? '' : newValue;
759
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
760
- if (memberName === 'list') {
761
- isProp = false;
762
- }
763
- else if (oldValue == null || elm[memberName] != n) {
764
- elm[memberName] = n;
765
- }
766
- }
767
- else {
768
- elm[memberName] = newValue;
769
- }
770
- }
771
- catch (e) {
772
- /**
773
- * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
774
- */
775
- }
776
- }
777
- /**
778
- * Need to manually update attribute if:
779
- * - memberName is not an attribute
780
- * - if we are rendering the host element in order to reflect attribute
781
- * - if it's a SVG, since properties might not work in <svg>
782
- * - if the newValue is null/undefined or 'false'.
783
- */
784
- let xlink = false;
785
- {
786
- if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
787
- memberName = ln;
788
- xlink = true;
789
- }
790
- }
791
- if (newValue == null || newValue === false) {
792
- if (newValue !== false || elm.getAttribute(memberName) === '') {
793
- if (xlink) {
794
- elm.removeAttributeNS(XLINK_NS, memberName);
795
- }
796
- else {
797
- elm.removeAttribute(memberName);
798
- }
799
- }
800
- }
801
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
802
- newValue = newValue === true ? '' : newValue;
803
- if (xlink) {
804
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
805
- }
806
- else {
807
- elm.setAttribute(memberName, newValue);
808
- }
809
- }
810
- }
811
- }
812
- };
813
- const parseClassListRegex = /\s/;
814
- /**
815
- * Parsed a string of classnames into an array
816
- * @param value className string, e.g. "foo bar baz"
817
- * @returns list of classes, e.g. ["foo", "bar", "baz"]
818
- */
819
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
820
- const CAPTURE_EVENT_SUFFIX = 'Capture';
821
- const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
822
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
823
- // if the element passed in is a shadow root, which is a document fragment
824
- // then we want to be adding attrs/props to the shadow root's "host" element
825
- // if it's not a shadow root, then we add attrs/props to the same element
826
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
827
- ? newVnode.$elm$.host
828
- : newVnode.$elm$;
829
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
830
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
831
- {
832
- // remove attributes no longer present on the vnode by setting them to undefined
833
- for (memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
834
- if (!(memberName in newVnodeAttrs)) {
835
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
836
- }
837
- }
838
- }
839
- // add new & update changed attributes
840
- for (memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
841
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
842
- }
843
- };
844
- /**
845
- * Sort a list of attribute names to ensure that all the attribute names which
846
- * are _not_ `"ref"` come before `"ref"`. Preserve the order of the non-ref
847
- * attributes.
848
- *
849
- * **Note**: if the supplied attributes do not include `'ref'` then the same
850
- * (by reference) array will be returned without modification.
851
- *
852
- * @param attrNames attribute names to sort
853
- * @returns a list of attribute names, sorted if they include `"ref"`
854
- */
855
- function sortedAttrNames(attrNames) {
856
- return attrNames.includes('ref')
857
- ? // we need to sort these to ensure that `'ref'` is the last attr
858
- [...attrNames.filter((attr) => attr !== 'ref'), 'ref']
859
- : // no need to sort, return the original array
860
- attrNames;
861
- }
862
- /**
863
- * Create a DOM Node corresponding to one of the children of a given VNode.
864
- *
865
- * @param oldParentVNode the parent VNode from the previous render
866
- * @param newParentVNode the parent VNode from the current render
867
- * @param childIndex the index of the VNode, in the _new_ parent node's
868
- * children, for which we will create a new DOM node
869
- * @param parentElm the parent DOM node which our new node will be a child of
870
- * @returns the newly created node
871
- */
872
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
873
- // tslint:disable-next-line: prefer-const
874
- const newVNode = newParentVNode.$children$[childIndex];
875
- let i = 0;
876
- let elm;
877
- let childNode;
878
- if (newVNode.$text$ !== null) {
879
- // create text node
880
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
881
- }
882
- else {
883
- if (!isSvgMode) {
884
- isSvgMode = newVNode.$tag$ === 'svg';
885
- }
886
- // create element
887
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
888
- );
889
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
890
- isSvgMode = false;
891
- }
892
- // add css classes, attrs, props, listeners, etc.
893
- {
894
- updateElement(null, newVNode, isSvgMode);
895
- }
896
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
897
- // if there is a scopeId and this is the initial render
898
- // then let's add the scopeId as a css class
899
- elm.classList.add((elm['s-si'] = scopeId));
900
- }
901
- if (newVNode.$children$) {
902
- for (i = 0; i < newVNode.$children$.length; ++i) {
903
- // create the node
904
- childNode = createElm(oldParentVNode, newVNode, i);
905
- // return node could have been null
906
- if (childNode) {
907
- // append our new node
908
- elm.appendChild(childNode);
909
- }
910
- }
911
- }
912
- {
913
- if (newVNode.$tag$ === 'svg') {
914
- // Only reset the SVG context when we're exiting <svg> element
915
- isSvgMode = false;
916
- }
917
- else if (elm.tagName === 'foreignObject') {
918
- // Reenter SVG context when we're exiting <foreignObject> element
919
- isSvgMode = true;
920
- }
921
- }
922
- }
923
- // This needs to always happen so we can hide nodes that are projected
924
- // to another component but don't end up in a slot
925
- elm['s-hn'] = hostTagName;
926
- return elm;
927
- };
928
- /**
929
- * Relocates all child nodes of an element that were a part of a previous slot relocation
930
- * to the root of the Stencil component currently being rendered. This happens when a parent
931
- * element of a slot reference node dynamically changes and triggers a re-render. We cannot use
932
- * `putBackInOriginalLocation()` because that may relocate nodes to elements that will not be re-rendered
933
- * and so they will not be relocated again.
934
- *
935
- * @param parentElm The element potentially containing relocated nodes.
936
- */
937
- const relocateToHostRoot = (parentElm) => {
938
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
939
- const host = parentElm.closest(hostTagName.toLowerCase());
940
- if (host != null) {
941
- const contentRefNode = Array.from(host.childNodes).find((ref) => ref['s-cr']);
942
- const childNodeArray = Array.from(parentElm.childNodes);
943
- // If we have a content ref, we need to invert the order of the nodes we're relocating
944
- // to preserve the correct order of elements in the DOM on future relocations
945
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
946
- // Only relocate nodes that were slotted in
947
- if (childNode['s-sh'] != null) {
948
- host.insertBefore(childNode, contentRefNode !== null && contentRefNode !== void 0 ? contentRefNode : null);
949
- // Reset so we can correctly move the node around again.
950
- childNode['s-sh'] = undefined;
951
- }
952
- }
953
- }
954
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
955
- };
956
- /**
957
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
958
- * add them to the DOM in the appropriate place.
959
- *
960
- * @param parentElm the DOM node which should be used as a parent for the new
961
- * DOM nodes
962
- * @param before a child of the `parentElm` which the new children should be
963
- * inserted before (optional)
964
- * @param parentVNode the parent virtual DOM node
965
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
966
- * @param startIdx the index in the child virtual DOM nodes at which to start
967
- * creating DOM nodes (inclusive)
968
- * @param endIdx the index in the child virtual DOM nodes at which to stop
969
- * creating DOM nodes (inclusive)
970
- */
971
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
972
- let containerElm = (parentElm);
973
- let childNode;
974
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
975
- containerElm = containerElm.shadowRoot;
976
- }
977
- for (; startIdx <= endIdx; ++startIdx) {
978
- if (vnodes[startIdx]) {
979
- childNode = createElm(null, parentVNode, startIdx);
980
- if (childNode) {
981
- vnodes[startIdx].$elm$ = childNode;
982
- containerElm.insertBefore(childNode, before);
983
- }
984
- }
985
- }
986
- };
987
- /**
988
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
989
- * This can be used to, for instance, clean up after a list of children which
990
- * should no longer be shown.
991
- *
992
- * This function also handles some of Stencil's slot relocation logic.
993
- *
994
- * @param vnodes a list of virtual DOM nodes to remove
995
- * @param startIdx the index at which to start removing nodes (inclusive)
996
- * @param endIdx the index at which to stop removing nodes (inclusive)
997
- */
998
- const removeVnodes = (vnodes, startIdx, endIdx) => {
999
- for (let index = startIdx; index <= endIdx; ++index) {
1000
- const vnode = vnodes[index];
1001
- if (vnode) {
1002
- const elm = vnode.$elm$;
1003
- nullifyVNodeRefs(vnode);
1004
- if (elm) {
1005
- // remove the vnode's element from the dom
1006
- elm.remove();
1007
- }
1008
- }
1009
- }
1010
- };
1011
- /**
1012
- * Reconcile the children of a new VNode with the children of an old VNode by
1013
- * traversing the two collections of children, identifying nodes that are
1014
- * conserved or changed, calling out to `patch` to make any necessary
1015
- * updates to the DOM, and rearranging DOM nodes as needed.
1016
- *
1017
- * The algorithm for reconciling children works by analyzing two 'windows' onto
1018
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1019
- * 'windows' by storing start and end indices and references to the
1020
- * corresponding array entries. Initially the two 'windows' are basically equal
1021
- * to the entire array, but we progressively narrow the windows until there are
1022
- * no children left to update by doing the following:
1023
- *
1024
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1025
- * that if we have an initial array like the following we'll end up dealing
1026
- * only with a window bounded by the highlighted elements:
1027
- *
1028
- * [null, null, VNode1 , ... , VNode2, null, null]
1029
- * ^^^^^^ ^^^^^^
1030
- *
1031
- * 2. Check to see if the elements at the head and tail positions are equal
1032
- * across the windows. This will basically detect elements which haven't
1033
- * been added, removed, or changed position, i.e. if you had the following
1034
- * VNode elements (represented as HTML):
1035
- *
1036
- * oldVNode: `<div><p><span>HEY</span></p></div>`
1037
- * newVNode: `<div><p><span>THERE</span></p></div>`
1038
- *
1039
- * Then when comparing the children of the `<div>` tag we check the equality
1040
- * of the VNodes corresponding to the `<p>` tags and, since they are the
1041
- * same tag in the same position, we'd be able to avoid completely
1042
- * re-rendering the subtree under them with a new DOM element and would just
1043
- * call out to `patch` to handle reconciling their children and so on.
1044
- *
1045
- * 3. Check, for both windows, to see if the element at the beginning of the
1046
- * window corresponds to the element at the end of the other window. This is
1047
- * a heuristic which will let us identify _some_ situations in which
1048
- * elements have changed position, for instance it _should_ detect that the
1049
- * children nodes themselves have not changed but merely moved in the
1050
- * following example:
1051
- *
1052
- * oldVNode: `<div><element-one /><element-two /></div>`
1053
- * newVNode: `<div><element-two /><element-one /></div>`
1054
- *
1055
- * If we find cases like this then we also need to move the concrete DOM
1056
- * elements corresponding to the moved children to write the re-order to the
1057
- * DOM.
1058
- *
1059
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1060
- * nodes in the old children which have the same key as the first element in
1061
- * our window on the new children. If we find such a node we handle calling
1062
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1063
- * what we find.
1064
- *
1065
- * Finally, once we've narrowed our 'windows' to the point that either of them
1066
- * collapse (i.e. they have length 0) we then handle any remaining VNode
1067
- * insertion or deletion that needs to happen to get a DOM state that correctly
1068
- * reflects the new child VNodes. If, for instance, after our window on the old
1069
- * children has collapsed we still have more nodes on the new children that
1070
- * we haven't dealt with yet then we need to add them, or if the new children
1071
- * collapse but we still have unhandled _old_ children then we need to make
1072
- * sure the corresponding DOM nodes are removed.
1073
- *
1074
- * @param parentElm the node into which the parent VNode is rendered
1075
- * @param oldCh the old children of the parent node
1076
- * @param newVNode the new VNode which will replace the parent
1077
- * @param newCh the new children of the parent node
1078
- * @param isInitialRender whether or not this is the first render of the vdom
1079
- */
1080
- const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
1081
- let oldStartIdx = 0;
1082
- let newStartIdx = 0;
1083
- let idxInOld = 0;
1084
- let i = 0;
1085
- let oldEndIdx = oldCh.length - 1;
1086
- let oldStartVnode = oldCh[0];
1087
- let oldEndVnode = oldCh[oldEndIdx];
1088
- let newEndIdx = newCh.length - 1;
1089
- let newStartVnode = newCh[0];
1090
- let newEndVnode = newCh[newEndIdx];
1091
- let node;
1092
- let elmToMove;
1093
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1094
- if (oldStartVnode == null) {
1095
- // VNode might have been moved left
1096
- oldStartVnode = oldCh[++oldStartIdx];
1097
- }
1098
- else if (oldEndVnode == null) {
1099
- oldEndVnode = oldCh[--oldEndIdx];
1100
- }
1101
- else if (newStartVnode == null) {
1102
- newStartVnode = newCh[++newStartIdx];
1103
- }
1104
- else if (newEndVnode == null) {
1105
- newEndVnode = newCh[--newEndIdx];
1106
- }
1107
- else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1108
- // if the start nodes are the same then we should patch the new VNode
1109
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1110
- // indices to reflect that. We don't need to move any DOM Nodes around
1111
- // since things are matched up in order.
1112
- patch(oldStartVnode, newStartVnode, isInitialRender);
1113
- oldStartVnode = oldCh[++oldStartIdx];
1114
- newStartVnode = newCh[++newStartIdx];
1115
- }
1116
- else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1117
- // likewise, if the end nodes are the same we patch new onto old and
1118
- // decrement our end indices, and also likewise in this case we don't
1119
- // need to move any DOM Nodes.
1120
- patch(oldEndVnode, newEndVnode, isInitialRender);
1121
- oldEndVnode = oldCh[--oldEndIdx];
1122
- newEndVnode = newCh[--newEndIdx];
1123
- }
1124
- else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1125
- patch(oldStartVnode, newEndVnode, isInitialRender);
1126
- // We need to move the element for `oldStartVnode` into a position which
1127
- // will be appropriate for `newEndVnode`. For this we can use
1128
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1129
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1130
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1131
- //
1132
- // <old-start-node />
1133
- // <some-intervening-node />
1134
- // <old-end-node />
1135
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1136
- // <next-sibling />
1137
- //
1138
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1139
- // the node for `oldStartVnode` at the end of the children of
1140
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1141
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
1142
- // append it to the children of the parent element.
1143
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1144
- oldStartVnode = oldCh[++oldStartIdx];
1145
- newEndVnode = newCh[--newEndIdx];
1146
- }
1147
- else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1148
- patch(oldEndVnode, newStartVnode, isInitialRender);
1149
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
1150
- // the same node, so since we're here we know that they are not. Thus we
1151
- // can move the element for `oldEndVnode` _before_ the element for
1152
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1153
- // future.
1154
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1155
- oldEndVnode = oldCh[--oldEndIdx];
1156
- newStartVnode = newCh[++newStartIdx];
1157
- }
1158
- else {
1159
- // Here we do some checks to match up old and new nodes based on the
1160
- // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1161
- // in the JSX for a DOM element in the implementation of a Stencil
1162
- // component.
1163
- //
1164
- // First we check to see if there are any nodes in the array of old
1165
- // children which have the same key as the first node in the new
1166
- // children.
1167
- idxInOld = -1;
1168
- {
1169
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1170
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1171
- idxInOld = i;
1172
- break;
1173
- }
1174
- }
1175
- }
1176
- if (idxInOld >= 0) {
1177
- // We found a node in the old children which matches up with the first
1178
- // node in the new children! So let's deal with that
1179
- elmToMove = oldCh[idxInOld];
1180
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1181
- // the tag doesn't match so we'll need a new DOM element
1182
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
1183
- }
1184
- else {
1185
- patch(elmToMove, newStartVnode, isInitialRender);
1186
- // invalidate the matching old node so that we won't try to update it
1187
- // again later on
1188
- oldCh[idxInOld] = undefined;
1189
- node = elmToMove.$elm$;
1190
- }
1191
- newStartVnode = newCh[++newStartIdx];
1192
- }
1193
- else {
1194
- // We either didn't find an element in the old children that matches
1195
- // the key of the first new child OR the build is not using `key`
1196
- // attributes at all. In either case we need to create a new element
1197
- // for the new node.
1198
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
1199
- newStartVnode = newCh[++newStartIdx];
1200
- }
1201
- if (node) {
1202
- // if we created a new node then handle inserting it to the DOM
1203
- {
1204
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1205
- }
1206
- }
1207
- }
1208
- }
1209
- if (oldStartIdx > oldEndIdx) {
1210
- // we have some more new nodes to add which don't match up with old nodes
1211
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1212
- }
1213
- else if (newStartIdx > newEndIdx) {
1214
- // there are nodes in the `oldCh` array which no longer correspond to nodes
1215
- // in the new array, so lets remove them (which entails cleaning up the
1216
- // relevant DOM nodes)
1217
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1218
- }
1219
- };
1220
- /**
1221
- * Compare two VNodes to determine if they are the same
1222
- *
1223
- * **NB**: This function is an equality _heuristic_ based on the available
1224
- * information set on the two VNodes and can be misleading under certain
1225
- * circumstances. In particular, if the two nodes do not have `key` attrs
1226
- * (available under `$key$` on VNodes) then the function falls back on merely
1227
- * checking that they have the same tag.
1228
- *
1229
- * So, in other words, if `key` attrs are not set on VNodes which may be
1230
- * changing order within a `children` array or something along those lines then
1231
- * we could obtain a false negative and then have to do needless re-rendering
1232
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1233
- *
1234
- * @param leftVNode the first VNode to check
1235
- * @param rightVNode the second VNode to check
1236
- * @param isInitialRender whether or not this is the first render of the vdom
1237
- * @returns whether they're equal or not
1238
- */
1239
- const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1240
- // compare if two vnode to see if they're "technically" the same
1241
- // need to have the same element tag, and same key to be the same
1242
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1243
- // this will be set if JSX tags in the build have `key` attrs set on them
1244
- // we only want to check this if we're not on the first render since on
1245
- // first render `leftVNode.$key$` will always be `null`, so we can be led
1246
- // astray and, for instance, accidentally delete a DOM node that we want to
1247
- // keep around.
1248
- if (!isInitialRender) {
1249
- return leftVNode.$key$ === rightVNode.$key$;
1250
- }
1251
- return true;
1252
- }
1253
- return false;
1254
- };
1255
- /**
1256
- * Handle reconciling an outdated VNode with a new one which corresponds to
1257
- * it. This function handles flushing updates to the DOM and reconciling the
1258
- * children of the two nodes (if any).
1259
- *
1260
- * @param oldVNode an old VNode whose DOM element and children we want to update
1261
- * @param newVNode a new VNode representing an updated version of the old one
1262
- * @param isInitialRender whether or not this is the first render of the vdom
1263
- */
1264
- const patch = (oldVNode, newVNode, isInitialRender = false) => {
1265
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
1266
- const oldChildren = oldVNode.$children$;
1267
- const newChildren = newVNode.$children$;
1268
- const tag = newVNode.$tag$;
1269
- const text = newVNode.$text$;
1270
- if (text === null) {
1271
- {
1272
- // test if we're rendering an svg element, or still rendering nodes inside of one
1273
- // only add this to the when the compiler sees we're using an svg somewhere
1274
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1275
- }
1276
- {
1277
- if (tag === 'slot' && !useNativeShadowDom) {
1278
- if (oldVNode.$name$ !== newVNode.$name$) {
1279
- newVNode.$elm$['s-sn'] = newVNode.$name$ || '';
1280
- relocateToHostRoot(newVNode.$elm$.parentElement);
1281
- }
1282
- }
1283
- else {
1284
- // either this is the first render of an element OR it's an update
1285
- // AND we already know it's possible it could have changed
1286
- // this updates the element's css classes, attrs, props, listeners, etc.
1287
- updateElement(oldVNode, newVNode, isSvgMode);
1288
- }
1289
- }
1290
- if (oldChildren !== null && newChildren !== null) {
1291
- // looks like there's child vnodes for both the old and new vnodes
1292
- // so we need to call `updateChildren` to reconcile them
1293
- updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
1294
- }
1295
- else if (newChildren !== null) {
1296
- // no old child vnodes, but there are new child vnodes to add
1297
- if (oldVNode.$text$ !== null) {
1298
- // the old vnode was text, so be sure to clear it out
1299
- elm.textContent = '';
1300
- }
1301
- // add the new vnode children
1302
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1303
- }
1304
- else if (oldChildren !== null) {
1305
- // no new child vnodes, but there are old child vnodes to remove
1306
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1307
- }
1308
- if (isSvgMode && tag === 'svg') {
1309
- isSvgMode = false;
1310
- }
1311
- }
1312
- else if (oldVNode.$text$ !== text) {
1313
- // update the text content for the text only vnode
1314
- // and also only if the text is different than before
1315
- elm.data = text;
1316
- }
1317
- };
1318
- /**
1319
- * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
1320
- * them with `null`. This signals that the DOM element corresponding to the VDom
1321
- * node has been removed from the DOM.
1322
- *
1323
- * @param vNode a virtual DOM node
1324
- */
1325
- const nullifyVNodeRefs = (vNode) => {
1326
- {
1327
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1328
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1329
- }
1330
- };
1331
- /**
1332
- * The main entry point for Stencil's virtual DOM-based rendering engine
1333
- *
1334
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1335
- * function will handle creating a virtual DOM tree with a single root, patching
1336
- * the current virtual DOM tree onto an old one (if any), dealing with slot
1337
- * relocation, and reflecting attributes.
1338
- *
1339
- * @param hostRef data needed to root and render the virtual DOM tree, such as
1340
- * the DOM node into which it should be rendered.
1341
- * @param renderFnResults the virtual DOM nodes to be rendered
1342
- * @param isInitialLoad whether or not this is the first call after page load
1343
- */
1344
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1345
- var _e;
1346
- const hostElm = hostRef.$hostElement$;
1347
- const cmpMeta = hostRef.$cmpMeta$;
1348
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1349
- // if `renderFnResults` is a Host node then we can use it directly. If not,
1350
- // we need to call `h` again to wrap the children of our component in a
1351
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
1352
- // implicitly that the top-level vdom node is 1) an only child and 2)
1353
- // contains attrs that need to be set on the host element.
1354
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1355
- hostTagName = hostElm.tagName;
1356
- if (cmpMeta.$attrsToReflect$) {
1357
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1358
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1359
- }
1360
- // On the first render and *only* on the first render we want to check for
1361
- // any attributes set on the host element which are also set on the vdom
1362
- // node. If we find them, we override the value on the VDom node attrs with
1363
- // the value from the host element, which allows developers building apps
1364
- // with Stencil components to override e.g. the `role` attribute on a
1365
- // component even if it's already set on the `Host`.
1366
- if (isInitialLoad && rootVnode.$attrs$) {
1367
- for (const key of Object.keys(rootVnode.$attrs$)) {
1368
- // We have a special implementation in `setAccessor` for `style` and
1369
- // `class` which reconciles values coming from the VDom with values
1370
- // already present on the DOM element, so we don't want to override those
1371
- // attributes on the VDom tree with values from the host element if they
1372
- // are present.
1373
- //
1374
- // Likewise, `ref` and `key` are special internal values for the Stencil
1375
- // runtime and we don't want to override those either.
1376
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
1377
- rootVnode.$attrs$[key] = hostElm[key];
1378
- }
1379
- }
1380
- }
1381
- rootVnode.$tag$ = null;
1382
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1383
- hostRef.$vnode$ = rootVnode;
1384
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1385
- {
1386
- scopeId = hostElm['s-sc'];
1387
- }
1388
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1389
- // synchronous patch
1390
- patch(oldVNode, rootVnode, isInitialLoad);
1391
- // Hide any elements that were projected through, but don't have a slot to go to.
1392
- // Only an issue if there were no "slots" rendered. Otherwise, nodes are hidden correctly.
1393
- // This _only_ happens for `scoped` components!
1394
- if (cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1395
- for (const childNode of rootVnode.$elm$.childNodes) {
1396
- if (childNode['s-hn'] !== hostTagName && !childNode['s-sh']) {
1397
- // Store the initial value of `hidden` so we can reset it later when
1398
- // moving nodes around.
1399
- if (isInitialLoad && childNode['s-ih'] == null) {
1400
- childNode['s-ih'] = (_e = childNode.hidden) !== null && _e !== void 0 ? _e : false;
1401
- }
1402
- childNode.hidden = true;
1403
- }
1404
- }
1405
- }
1406
- };
1407
- const attachToAncestor = (hostRef, ancestorComponent) => {
1408
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1409
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1410
- }
1411
- };
1412
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1413
- {
1414
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1415
- }
1416
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1417
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1418
- return;
1419
- }
1420
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1421
- // there is no ancestor component or the ancestor component
1422
- // has already fired off its lifecycle update then
1423
- // fire off the initial update
1424
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1425
- return writeTask(dispatch) ;
1426
- };
1427
- /**
1428
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1429
- * component lifecycle methods like `componentWillLoad` as well as
1430
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
1431
- *
1432
- * @param hostRef a reference to a host DOM node
1433
- * @param isInitialLoad whether we're on the initial load or not
1434
- * @returns an empty Promise which is used to enqueue a series of operations for
1435
- * the component
1436
- */
1437
- const dispatchHooks = (hostRef, isInitialLoad) => {
1438
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1439
- const instance = hostRef.$lazyInstance$ ;
1440
- // We're going to use this variable together with `enqueue` to implement a
1441
- // little promise-based queue. We start out with it `undefined`. When we add
1442
- // the first function to the queue we'll set this variable to be that
1443
- // function's return value. When we attempt to add subsequent values to the
1444
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
1445
- // the new function off of that `Promise` using `.then()`. This will give our
1446
- // queue two nice properties:
1447
- //
1448
- // 1. If all functions added to the queue are synchronous they'll be called
1449
- // synchronously right away.
1450
- // 2. If all functions added to the queue are asynchronous they'll all be
1451
- // called in order after `dispatchHooks` exits.
1452
- let maybePromise;
1453
- if (isInitialLoad) {
1454
- {
1455
- hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1456
- if (hostRef.$queuedListeners$) {
1457
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1458
- hostRef.$queuedListeners$ = undefined;
1459
- }
1460
- }
1461
- {
1462
- // If `componentWillLoad` returns a `Promise` then we want to wait on
1463
- // whatever's going on in that `Promise` before we launch into
1464
- // rendering the component, doing other lifecycle stuff, etc. So
1465
- // in that case we assign the returned promise to the variable we
1466
- // declared above to hold a possible 'queueing' Promise
1467
- maybePromise = safeCall(instance, 'componentWillLoad');
1468
- }
1469
- }
1470
- endSchedule();
1471
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1472
- };
1473
- /**
1474
- * This function uses a Promise to implement a simple first-in, first-out queue
1475
- * of functions to be called.
1476
- *
1477
- * The queue is ordered on the basis of the first argument. If it's
1478
- * `undefined`, then nothing is on the queue yet, so the provided function can
1479
- * be called synchronously (although note that this function may return a
1480
- * `Promise`). The idea is that then the return value of that enqueueing
1481
- * operation is kept around, so that if it was a `Promise` then subsequent
1482
- * functions can be enqueued by calling this function again with that `Promise`
1483
- * as the first argument.
1484
- *
1485
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1486
- * @param fn a function to enqueue
1487
- * @returns either a `Promise` or the return value of the provided function
1488
- */
1489
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1490
- /**
1491
- * Check that a value is a `Promise`. To check, we first see if the value is an
1492
- * instance of the `Promise` global. In a few circumstances, in particular if
1493
- * the global has been overwritten, this is could be misleading, so we also do
1494
- * a little 'duck typing' check to see if the `.then` property of the value is
1495
- * defined and a function.
1496
- *
1497
- * @param maybePromise it might be a promise!
1498
- * @returns whether it is or not
1499
- */
1500
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1501
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1502
- /**
1503
- * Update a component given reference to its host elements and so on.
1504
- *
1505
- * @param hostRef an object containing references to the element's host node,
1506
- * VDom nodes, and other metadata
1507
- * @param instance a reference to the underlying host element where it will be
1508
- * rendered
1509
- * @param isInitialLoad whether or not this function is being called as part of
1510
- * the first render cycle
1511
- */
1512
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1513
- var _a;
1514
- const elm = hostRef.$hostElement$;
1515
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1516
- const rc = elm['s-rc'];
1517
- if (isInitialLoad) {
1518
- // DOM WRITE!
1519
- attachStyles(hostRef);
1520
- }
1521
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1522
- {
1523
- callRender(hostRef, instance, elm, isInitialLoad);
1524
- }
1525
- if (rc) {
1526
- // ok, so turns out there are some child host elements
1527
- // waiting on this parent element to load
1528
- // let's fire off all update callbacks waiting
1529
- rc.map((cb) => cb());
1530
- elm['s-rc'] = undefined;
1531
- }
1532
- endRender();
1533
- endUpdate();
1534
- {
1535
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1536
- const postUpdate = () => postUpdateComponent(hostRef);
1537
- if (childrenPromises.length === 0) {
1538
- postUpdate();
1539
- }
1540
- else {
1541
- Promise.all(childrenPromises).then(postUpdate);
1542
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1543
- childrenPromises.length = 0;
1544
- }
1545
- }
1546
- };
1547
- /**
1548
- * Handle making the call to the VDom renderer with the proper context given
1549
- * various build variables
1550
- *
1551
- * @param hostRef an object containing references to the element's host node,
1552
- * VDom nodes, and other metadata
1553
- * @param instance a reference to the underlying host element where it will be
1554
- * rendered
1555
- * @param elm the Host element for the component
1556
- * @param isInitialLoad whether or not this function is being called as part of
1557
- * @returns an empty promise
1558
- */
1559
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
1560
- try {
1561
- /**
1562
- * minification optimization: `allRenderFn` is `true` if all components have a `render`
1563
- * method, so we can call the method immediately. If not, check before calling it.
1564
- */
1565
- instance = instance.render() ;
1566
- {
1567
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1568
- }
1569
- {
1570
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1571
- }
1572
- {
1573
- {
1574
- // looks like we've got child nodes to render into this host element
1575
- // or we need to update the css class/attrs on the host element
1576
- // DOM WRITE!
1577
- {
1578
- renderVdom(hostRef, instance, isInitialLoad);
1579
- }
1580
- }
1581
- }
1582
- }
1583
- catch (e) {
1584
- consoleError(e, hostRef.$hostElement$);
1585
- }
1586
- return null;
1587
- };
1588
- const postUpdateComponent = (hostRef) => {
1589
- const tagName = hostRef.$cmpMeta$.$tagName$;
1590
- const elm = hostRef.$hostElement$;
1591
- const endPostUpdate = createTime('postUpdate', tagName);
1592
- const instance = hostRef.$lazyInstance$ ;
1593
- const ancestorComponent = hostRef.$ancestorComponent$;
1594
- {
1595
- safeCall(instance, 'componentDidRender');
1596
- }
1597
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1598
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1599
- {
1600
- // DOM WRITE!
1601
- addHydratedFlag(elm);
1602
- }
1603
- {
1604
- safeCall(instance, 'componentDidLoad');
1605
- }
1606
- endPostUpdate();
1607
- {
1608
- hostRef.$onReadyResolve$(elm);
1609
- if (!ancestorComponent) {
1610
- appDidLoad();
1611
- }
1612
- }
1613
- }
1614
- else {
1615
- {
1616
- safeCall(instance, 'componentDidUpdate');
1617
- }
1618
- endPostUpdate();
1619
- }
1620
- {
1621
- hostRef.$onInstanceResolve$(elm);
1622
- }
1623
- // load events fire from bottom to top
1624
- // the deepest elements load first then bubbles up
1625
- {
1626
- if (hostRef.$onRenderResolve$) {
1627
- hostRef.$onRenderResolve$();
1628
- hostRef.$onRenderResolve$ = undefined;
1629
- }
1630
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1631
- nextTick(() => scheduleUpdate(hostRef, false));
1632
- }
1633
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1634
- }
1635
- // ( •_•)
1636
- // ( •_•)>⌐■-■
1637
- // (⌐■_■)
1638
- };
1639
- const appDidLoad = (who) => {
1640
- // on appload
1641
- // we have finish the first big initial render
1642
- {
1643
- addHydratedFlag(doc.documentElement);
1644
- }
1645
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1646
- };
1647
- /**
1648
- * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
1649
- * e.g. custom element node. If a build figures out that e.g. no component
1650
- * has a `componentDidLoad` method, the instance method gets removed from the
1651
- * output bundle and this function returns `undefined`.
1652
- * @param instance any object that may or may not contain methods
1653
- * @param method method name
1654
- * @param arg single arbitrary argument
1655
- * @returns result of method call if it exists, otherwise `undefined`
1656
- */
1657
- const safeCall = (instance, method, arg) => {
1658
- if (instance && instance[method]) {
1659
- try {
1660
- return instance[method](arg);
1661
- }
1662
- catch (e) {
1663
- consoleError(e);
1664
- }
1665
- }
1666
- return undefined;
1667
- };
1668
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1669
- ;
1670
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1671
- const setValue = (ref, propName, newVal, cmpMeta) => {
1672
- // check our new property value against our internal value
1673
- const hostRef = getHostRef(ref);
1674
- const elm = hostRef.$hostElement$ ;
1675
- const oldVal = hostRef.$instanceValues$.get(propName);
1676
- const flags = hostRef.$flags$;
1677
- const instance = hostRef.$lazyInstance$ ;
1678
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1679
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1680
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1681
- const didValueChange = newVal !== oldVal && !areBothNaN;
1682
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1683
- // gadzooks! the property's value has changed!!
1684
- // set our new value!
1685
- hostRef.$instanceValues$.set(propName, newVal);
1686
- if (instance) {
1687
- // get an array of method names of watch functions to call
1688
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1689
- const watchMethods = cmpMeta.$watchers$[propName];
1690
- if (watchMethods) {
1691
- // this instance is watching for when this property changed
1692
- watchMethods.map((watchMethodName) => {
1693
- try {
1694
- // fire off each of the watch methods that are watching this property
1695
- instance[watchMethodName](newVal, oldVal, propName);
1696
- }
1697
- catch (e) {
1698
- consoleError(e, elm);
1699
- }
1700
- });
1701
- }
1702
- }
1703
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1704
- // looks like this value actually changed, so we've got work to do!
1705
- // but only if we've already rendered, otherwise just chill out
1706
- // queue that we need to do an update, but don't worry about queuing
1707
- // up millions cuz this function ensures it only runs once
1708
- scheduleUpdate(hostRef, false);
1709
- }
1710
- }
1711
- }
1712
- };
1713
- /**
1714
- * Attach a series of runtime constructs to a compiled Stencil component
1715
- * constructor, including getters and setters for the `@Prop` and `@State`
1716
- * decorators, callbacks for when attributes change, and so on.
1717
- *
1718
- * @param Cstr the constructor for a component that we need to process
1719
- * @param cmpMeta metadata collected previously about the component
1720
- * @param flags a number used to store a series of bit flags
1721
- * @returns a reference to the same constructor passed in (but now mutated)
1722
- */
1723
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1724
- var _a;
1725
- const prototype = Cstr.prototype;
1726
- if (cmpMeta.$members$) {
1727
- if (Cstr.watchers) {
1728
- cmpMeta.$watchers$ = Cstr.watchers;
1729
- }
1730
- // It's better to have a const than two Object.entries()
1731
- const members = Object.entries(cmpMeta.$members$);
1732
- members.map(([memberName, [memberFlags]]) => {
1733
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1734
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1735
- // proxyComponent - prop
1736
- Object.defineProperty(prototype, memberName, {
1737
- get() {
1738
- // proxyComponent, get value
1739
- return getValue(this, memberName);
1740
- },
1741
- set(newValue) {
1742
- // proxyComponent, set value
1743
- setValue(this, memberName, newValue, cmpMeta);
1744
- },
1745
- configurable: true,
1746
- enumerable: true,
1747
- });
1748
- }
1749
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1750
- memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1751
- // proxyComponent - method
1752
- Object.defineProperty(prototype, memberName, {
1753
- value(...args) {
1754
- var _a;
1755
- const ref = getHostRef(this);
1756
- return (_a = ref === null || ref === void 0 ? void 0 : ref.$onInstancePromise$) === null || _a === void 0 ? void 0 : _a.then(() => { var _a; return (_a = ref.$lazyInstance$) === null || _a === void 0 ? void 0 : _a[memberName](...args); });
1757
- },
1758
- });
1759
- }
1760
- });
1761
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1762
- const attrNameToPropName = new Map();
1763
- prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
1764
- plt.jmp(() => {
1765
- var _a;
1766
- const propName = attrNameToPropName.get(attrName);
1767
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1768
- // in the case where an attribute was set inline.
1769
- // ```html
1770
- // <my-component some-attribute="some-value"></my-component>
1771
- // ```
1772
- //
1773
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1774
- // programmatically changes it before it has been upgraded as shown below:
1775
- //
1776
- // ```html
1777
- // <!-- this component has _not_ been upgraded yet -->
1778
- // <my-component id="test" some-attribute="some-value"></my-component>
1779
- // <script>
1780
- // // grab non-upgraded component
1781
- // el = document.querySelector("#test");
1782
- // el.someAttribute = "another-value";
1783
- // // upgrade component
1784
- // customElements.define('my-component', MyComponent);
1785
- // </script>
1786
- // ```
1787
- // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
1788
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1789
- // to the value that was set inline i.e. "some-value" from above example. When
1790
- // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
1791
- //
1792
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
1793
- // by connectedCallback as this attributeChangedCallback will not fire.
1794
- //
1795
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1796
- //
1797
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1798
- // properties here given that this goes against best practices outlined here
1799
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1800
- if (this.hasOwnProperty(propName)) {
1801
- newValue = this[propName];
1802
- delete this[propName];
1803
- }
1804
- else if (prototype.hasOwnProperty(propName) &&
1805
- typeof this[propName] === 'number' &&
1806
- this[propName] == newValue) {
1807
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1808
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1809
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1810
- return;
1811
- }
1812
- else if (propName == null) {
1813
- // At this point we should know this is not a "member", so we can treat it like watching an attribute
1814
- // on a vanilla web component
1815
- const hostRef = getHostRef(this);
1816
- const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
1817
- // We only want to trigger the callback(s) if:
1818
- // 1. The instance is ready
1819
- // 2. The watchers are ready
1820
- // 3. The value has changed
1821
- if (flags &&
1822
- !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1823
- flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1824
- newValue !== oldValue) {
1825
- const instance = hostRef.$lazyInstance$ ;
1826
- const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1827
- entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1828
- if (instance[callbackName] != null) {
1829
- instance[callbackName].call(instance, newValue, oldValue, attrName);
1830
- }
1831
- });
1832
- }
1833
- return;
1834
- }
1835
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1836
- });
1837
- };
1838
- // Create an array of attributes to observe
1839
- // This list in comprised of all strings used within a `@Watch()` decorator
1840
- // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
1841
- // As such, there is no way to guarantee type-safety here that a user hasn't entered
1842
- // an invalid attribute.
1843
- Cstr.observedAttributes = Array.from(new Set([
1844
- ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
1845
- ...members
1846
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
1847
- .map(([propName, m]) => {
1848
- var _a;
1849
- const attrName = m[1] || propName;
1850
- attrNameToPropName.set(attrName, propName);
1851
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1852
- (_a = cmpMeta.$attrsToReflect$) === null || _a === void 0 ? void 0 : _a.push([propName, attrName]);
1853
- }
1854
- return attrName;
1855
- }),
1856
- ]));
1857
- }
1858
- }
1859
- return Cstr;
1860
- };
1861
- /**
1862
- * Initialize a Stencil component given a reference to its host element, its
1863
- * runtime bookkeeping data structure, runtime metadata about the component,
1864
- * and (optionally) an HMR version ID.
1865
- *
1866
- * @param elm a host element
1867
- * @param hostRef the element's runtime bookkeeping object
1868
- * @param cmpMeta runtime metadata for the Stencil component
1869
- * @param hmrVersionId an (optional) HMR version ID
1870
- */
1871
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1872
- let Cstr;
1873
- // initializeComponent
1874
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1875
- // Let the runtime know that the component has been initialized
1876
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1877
- const bundleId = cmpMeta.$lazyBundleId$;
1878
- if (bundleId) {
1879
- // lazy loaded components
1880
- // request the component's implementation to be
1881
- // wired up with the host element
1882
- Cstr = loadModule(cmpMeta);
1883
- if (Cstr.then) {
1884
- // Await creates a micro-task avoid if possible
1885
- const endLoad = uniqueTime();
1886
- Cstr = await Cstr;
1887
- endLoad();
1888
- }
1889
- if (!Cstr.isProxied) {
1890
- // we've never proxied this Constructor before
1891
- // let's add the getters/setters to its prototype before
1892
- // the first time we create an instance of the implementation
1893
- {
1894
- cmpMeta.$watchers$ = Cstr.watchers;
1895
- }
1896
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1897
- Cstr.isProxied = true;
1898
- }
1899
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1900
- // ok, time to construct the instance
1901
- // but let's keep track of when we start and stop
1902
- // so that the getters/setters don't incorrectly step on data
1903
- {
1904
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1905
- }
1906
- // construct the lazy-loaded component implementation
1907
- // passing the hostRef is very important during
1908
- // construction in order to directly wire together the
1909
- // host element and the lazy-loaded instance
1910
- try {
1911
- new Cstr(hostRef);
1912
- }
1913
- catch (e) {
1914
- consoleError(e);
1915
- }
1916
- {
1917
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1918
- }
1919
- {
1920
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1921
- }
1922
- endNewInstance();
1923
- fireConnectedCallback(hostRef.$lazyInstance$);
1924
- }
1925
- else {
1926
- // sync constructor component
1927
- Cstr = elm.constructor;
1928
- // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
1929
- // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
1930
- // Stencil has completed instantiating the component.
1931
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
1932
- }
1933
- if (Cstr.style) {
1934
- // this component has styles but we haven't registered them yet
1935
- let style = Cstr.style;
1936
- const scopeId = getScopeId(cmpMeta);
1937
- if (!styles.has(scopeId)) {
1938
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1939
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1940
- endRegisterStyles();
1941
- }
1942
- }
1943
- }
1944
- // we've successfully created a lazy instance
1945
- const ancestorComponent = hostRef.$ancestorComponent$;
1946
- const schedule = () => scheduleUpdate(hostRef, true);
1947
- if (ancestorComponent && ancestorComponent['s-rc']) {
1948
- // this is the initial load and this component it has an ancestor component
1949
- // but the ancestor component has NOT fired its will update lifecycle yet
1950
- // so let's just cool our jets and wait for the ancestor to continue first
1951
- // this will get fired off when the ancestor component
1952
- // finally gets around to rendering its lazy self
1953
- // fire off the initial update
1954
- ancestorComponent['s-rc'].push(schedule);
1955
- }
1956
- else {
1957
- schedule();
1958
- }
1959
- };
1960
- const fireConnectedCallback = (instance) => {
1961
- {
1962
- safeCall(instance, 'connectedCallback');
1963
- }
1964
- };
1965
- const connectedCallback = (elm) => {
1966
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1967
- const hostRef = getHostRef(elm);
1968
- const cmpMeta = hostRef.$cmpMeta$;
1969
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1970
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1971
- // first time this component has connected
1972
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1973
- let hostId;
1974
- {
1975
- hostId = elm.getAttribute(HYDRATE_ID);
1976
- if (hostId) {
1977
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1978
- const scopeId = addStyle(elm.shadowRoot, cmpMeta);
1979
- elm.classList.remove(scopeId + '-h', scopeId + '-s');
1980
- }
1981
- initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
1982
- }
1983
- }
1984
- {
1985
- // find the first ancestor component (if there is one) and register
1986
- // this component as one of the actively loading child components for its ancestor
1987
- let ancestorComponent = elm;
1988
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1989
- // climb up the ancestors looking for the first
1990
- // component that hasn't finished its lifecycle update yet
1991
- if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
1992
- ancestorComponent.hasAttribute('s-id') &&
1993
- ancestorComponent['s-p']) ||
1994
- ancestorComponent['s-p']) {
1995
- // we found this components first ancestor component
1996
- // keep a reference to this component's ancestor component
1997
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1998
- break;
1999
- }
2000
- }
2001
- }
2002
- // Lazy properties
2003
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2004
- if (cmpMeta.$members$) {
2005
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2006
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2007
- const value = elm[memberName];
2008
- delete elm[memberName];
2009
- elm[memberName] = value;
2010
- }
2011
- });
2012
- }
2013
- {
2014
- initializeComponent(elm, hostRef, cmpMeta);
2015
- }
2016
- }
2017
- else {
2018
- // not the first time this has connected
2019
- // reattach any event listeners to the host
2020
- // since they would have been removed when disconnected
2021
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2022
- // fire off connectedCallback() on component instance
2023
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
2024
- fireConnectedCallback(hostRef.$lazyInstance$);
2025
- }
2026
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2027
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
2028
- }
2029
- }
2030
- endConnected();
2031
- }
2032
- };
2033
- const disconnectInstance = (instance) => {
2034
- {
2035
- safeCall(instance, 'disconnectedCallback');
2036
- }
2037
- };
2038
- const disconnectedCallback = async (elm) => {
2039
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2040
- const hostRef = getHostRef(elm);
2041
- {
2042
- if (hostRef.$rmListeners$) {
2043
- hostRef.$rmListeners$.map((rmListener) => rmListener());
2044
- hostRef.$rmListeners$ = undefined;
2045
- }
2046
- }
2047
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
2048
- disconnectInstance(hostRef.$lazyInstance$);
2049
- }
2050
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2051
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
2052
- }
2053
- }
2054
- };
2055
- const bootstrapLazy = (lazyBundles, options = {}) => {
2056
- var _a;
2057
- const endBootstrap = createTime();
2058
- const cmpTags = [];
2059
- const exclude = options.exclude || [];
2060
- const customElements = win.customElements;
2061
- const head = doc.head;
2062
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2063
- const dataStyles = /*@__PURE__*/ doc.createElement('style');
2064
- const deferredConnectedCallbacks = [];
2065
- const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2066
- let appLoadFallback;
2067
- let isBootstrapping = true;
2068
- let i = 0;
2069
- Object.assign(plt, options);
2070
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2071
- {
2072
- // If the app is already hydrated there is not point to disable the
2073
- // async queue. This will improve the first input delay
2074
- plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2075
- }
2076
- {
2077
- for (; i < styles.length; i++) {
2078
- registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2079
- }
2080
- }
2081
- let hasSlotRelocation = false;
2082
- lazyBundles.map((lazyBundle) => {
2083
- lazyBundle[1].map((compactMeta) => {
2084
- var _a;
2085
- const cmpMeta = {
2086
- $flags$: compactMeta[0],
2087
- $tagName$: compactMeta[1],
2088
- $members$: compactMeta[2],
2089
- $listeners$: compactMeta[3],
2090
- };
2091
- // Check if we are using slots outside the shadow DOM in this component.
2092
- // We'll use this information later to add styles for `slot-fb` elements
2093
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
2094
- hasSlotRelocation = true;
2095
- }
2096
- {
2097
- cmpMeta.$members$ = compactMeta[2];
2098
- }
2099
- {
2100
- cmpMeta.$listeners$ = compactMeta[3];
2101
- }
2102
- {
2103
- cmpMeta.$attrsToReflect$ = [];
2104
- }
2105
- {
2106
- cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
2107
- }
2108
- const tagName = cmpMeta.$tagName$;
2109
- const HostElement = class extends HTMLElement {
2110
- // StencilLazyHost
2111
- constructor(self) {
2112
- // @ts-ignore
2113
- super(self);
2114
- self = this;
2115
- registerHost(self, cmpMeta);
2116
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2117
- // this component is using shadow dom
2118
- // and this browser supports shadow dom
2119
- // add the read-only property "shadowRoot" to the host element
2120
- // adding the shadow root build conditionals to minimize runtime
2121
- {
2122
- {
2123
- self.attachShadow({
2124
- mode: 'open',
2125
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2126
- });
2127
- }
2128
- }
2129
- }
2130
- }
2131
- connectedCallback() {
2132
- if (appLoadFallback) {
2133
- clearTimeout(appLoadFallback);
2134
- appLoadFallback = null;
2135
- }
2136
- if (isBootstrapping) {
2137
- // connectedCallback will be processed once all components have been registered
2138
- deferredConnectedCallbacks.push(this);
2139
- }
2140
- else {
2141
- plt.jmp(() => connectedCallback(this));
2142
- }
2143
- }
2144
- disconnectedCallback() {
2145
- plt.jmp(() => disconnectedCallback(this));
2146
- }
2147
- componentOnReady() {
2148
- return getHostRef(this).$onReadyPromise$;
2149
- }
2150
- };
2151
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
2152
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2153
- cmpTags.push(tagName);
2154
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2155
- }
2156
- });
2157
- });
2158
- // Only bother generating CSS if we have components
2159
- // TODO(STENCIL-1118): Add test cases for CSS content based on conditionals
2160
- if (cmpTags.length > 0) {
2161
- // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
2162
- if (hasSlotRelocation) {
2163
- dataStyles.textContent += SLOT_FB_CSS;
2164
- }
2165
- // Add hydration styles
2166
- {
2167
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
2168
- }
2169
- // If we have styles, add them to the DOM
2170
- if (dataStyles.innerHTML.length) {
2171
- dataStyles.setAttribute('data-styles', '');
2172
- // Apply CSP nonce to the style tag if it exists
2173
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2174
- if (nonce != null) {
2175
- dataStyles.setAttribute('nonce', nonce);
2176
- }
2177
- // Insert the styles into the document head
2178
- // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
2179
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
2180
- }
2181
- }
2182
- // Process deferred connectedCallbacks now all components have been registered
2183
- isBootstrapping = false;
2184
- if (deferredConnectedCallbacks.length) {
2185
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
2186
- }
2187
- else {
2188
- {
2189
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2190
- }
2191
- }
2192
- // Fallback appLoad event
2193
- endBootstrap();
2194
- };
2195
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2196
- if (listeners) {
2197
- listeners.map(([flags, name, method]) => {
2198
- const target = getHostListenerTarget(elm, flags) ;
2199
- const handler = hostListenerProxy(hostRef, method);
2200
- const opts = hostListenerOpts(flags);
2201
- plt.ael(target, name, handler, opts);
2202
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2203
- });
2204
- }
2205
- };
2206
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
2207
- try {
2208
- {
2209
- if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
2210
- // instance is ready, let's call it's member method for this event
2211
- hostRef.$lazyInstance$[methodName](ev);
2212
- }
2213
- else {
2214
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2215
- }
2216
- }
2217
- }
2218
- catch (e) {
2219
- consoleError(e);
2220
- }
2221
- };
2222
- const getHostListenerTarget = (elm, flags) => {
2223
- if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
2224
- return doc;
2225
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
2226
- return win;
2227
- if (flags & 16 /* LISTENER_FLAGS.TargetBody */)
2228
- return doc.body;
2229
- return elm;
2230
- };
2231
- // prettier-ignore
2232
- const hostListenerOpts = (flags) => supportsListenerOptions
2233
- ? ({
2234
- passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
2235
- capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
2236
- })
2237
- : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
2238
- /**
2239
- * Assigns the given value to the nonce property on the runtime platform object.
2240
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
2241
- * @param nonce The value to be assigned to the platform nonce property.
2242
- * @returns void
2243
- */
2244
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
2245
- /**
2246
- * A WeakMap mapping runtime component references to their corresponding host reference
2247
- * instances.
2248
- *
2249
- * **Note**: If we're in an HMR context we need to store a reference to this
2250
- * value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
2251
- * to {@link d.HostRef} across HMR updates.
2252
- *
2253
- * This is necessary because when HMR updates for a component are processed by
2254
- * the browser-side dev server client the JS bundle for that component is
2255
- * re-fetched. Since the module containing {@link hostRefs} is included in
2256
- * that bundle, if we do not store a reference to it the new iteration of the
2257
- * component will not have access to the previous hostRef map, leading to a
2258
- * bug where the new version of the component cannot properly initialize.
2259
- */
2260
- const hostRefs = new WeakMap();
2261
- /**
2262
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
2263
- *
2264
- * @param ref the runtime ref of interest
2265
- * @returns the Host reference (if found) or undefined
2266
- */
2267
- const getHostRef = (ref) => hostRefs.get(ref);
2268
- /**
2269
- * Register a lazy instance with the {@link hostRefs} object so it's
2270
- * corresponding {@link d.HostRef} can be retrieved later.
2271
- *
2272
- * @param lazyInstance the lazy instance of interest
2273
- * @param hostRef that instances `HostRef` object
2274
- * @returns a reference to the host ref WeakMap
2275
- */
2276
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2277
- /**
2278
- * Register a host element for a Stencil component, setting up various metadata
2279
- * and callbacks based on {@link BUILD} flags as well as the component's runtime
2280
- * metadata.
2281
- *
2282
- * @param hostElement the host element to register
2283
- * @param cmpMeta runtime metadata for that component
2284
- * @returns a reference to the host ref WeakMap
2285
- */
2286
- const registerHost = (hostElement, cmpMeta) => {
2287
- const hostRef = {
2288
- $flags$: 0,
2289
- $hostElement$: hostElement,
2290
- $cmpMeta$: cmpMeta,
2291
- $instanceValues$: new Map(),
2292
- };
2293
- {
2294
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
2295
- }
2296
- {
2297
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2298
- hostElement['s-p'] = [];
2299
- hostElement['s-rc'] = [];
2300
- }
2301
- addHostEventListeners(hostElement, hostRef, cmpMeta.$listeners$);
2302
- return hostRefs.set(hostElement, hostRef);
2303
- };
2304
- const isMemberInElement = (elm, memberName) => memberName in elm;
2305
- const consoleError = (e, el) => (0, console.error)(e, el);
2306
- const cmpModules = /*@__PURE__*/ new Map();
2307
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2308
- // loadModuleImport
2309
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2310
- const bundleId = cmpMeta.$lazyBundleId$;
2311
- const module = cmpModules.get(bundleId) ;
2312
- if (module) {
2313
- return module[exportName];
2314
- }
2315
-
2316
- if (!hmrVersionId || !BUILD.hotModuleReplacement) {
2317
- const processMod = importedModule => {
2318
- cmpModules.set(bundleId, importedModule);
2319
- return importedModule[exportName];
2320
- }
2321
- switch(bundleId) {
2322
-
2323
- case 'bq-accordion':
2324
- return import(
2325
- /* webpackMode: "lazy" */
2326
- './bq-accordion.entry.js').then(processMod, consoleError);
2327
- case 'bq-accordion-group':
2328
- return import(
2329
- /* webpackMode: "lazy" */
2330
- './bq-accordion-group.entry.js').then(processMod, consoleError);
2331
- case 'bq-alert':
2332
- return import(
2333
- /* webpackMode: "lazy" */
2334
- './bq-alert.entry.js').then(processMod, consoleError);
2335
- case 'bq-avatar':
2336
- return import(
2337
- /* webpackMode: "lazy" */
2338
- './bq-avatar.entry.js').then(processMod, consoleError);
2339
- case 'bq-breadcrumb':
2340
- return import(
2341
- /* webpackMode: "lazy" */
2342
- './bq-breadcrumb.entry.js').then(processMod, consoleError);
2343
- case 'bq-breadcrumb-item':
2344
- return import(
2345
- /* webpackMode: "lazy" */
2346
- './bq-breadcrumb-item.entry.js').then(processMod, consoleError);
2347
- case 'bq-card':
2348
- return import(
2349
- /* webpackMode: "lazy" */
2350
- './bq-card.entry.js').then(processMod, consoleError);
2351
- case 'bq-checkbox':
2352
- return import(
2353
- /* webpackMode: "lazy" */
2354
- './bq-checkbox.entry.js').then(processMod, consoleError);
2355
- case 'bq-dialog':
2356
- return import(
2357
- /* webpackMode: "lazy" */
2358
- './bq-dialog.entry.js').then(processMod, consoleError);
2359
- case 'bq-drawer':
2360
- return import(
2361
- /* webpackMode: "lazy" */
2362
- './bq-drawer.entry.js').then(processMod, consoleError);
2363
- case 'bq-empty-state':
2364
- return import(
2365
- /* webpackMode: "lazy" */
2366
- './bq-empty-state.entry.js').then(processMod, consoleError);
2367
- case 'bq-input':
2368
- return import(
2369
- /* webpackMode: "lazy" */
2370
- './bq-input.entry.js').then(processMod, consoleError);
2371
- case 'bq-notification':
2372
- return import(
2373
- /* webpackMode: "lazy" */
2374
- './bq-notification.entry.js').then(processMod, consoleError);
2375
- case 'bq-option':
2376
- return import(
2377
- /* webpackMode: "lazy" */
2378
- './bq-option.entry.js').then(processMod, consoleError);
2379
- case 'bq-option-group':
2380
- return import(
2381
- /* webpackMode: "lazy" */
2382
- './bq-option-group.entry.js').then(processMod, consoleError);
2383
- case 'bq-progress':
2384
- return import(
2385
- /* webpackMode: "lazy" */
2386
- './bq-progress.entry.js').then(processMod, consoleError);
2387
- case 'bq-radio':
2388
- return import(
2389
- /* webpackMode: "lazy" */
2390
- './bq-radio.entry.js').then(processMod, consoleError);
2391
- case 'bq-radio-group':
2392
- return import(
2393
- /* webpackMode: "lazy" */
2394
- './bq-radio-group.entry.js').then(processMod, consoleError);
2395
- case 'bq-select':
2396
- return import(
2397
- /* webpackMode: "lazy" */
2398
- './bq-select.entry.js').then(processMod, consoleError);
2399
- case 'bq-side-menu':
2400
- return import(
2401
- /* webpackMode: "lazy" */
2402
- './bq-side-menu.entry.js').then(processMod, consoleError);
2403
- case 'bq-side-menu-item':
2404
- return import(
2405
- /* webpackMode: "lazy" */
2406
- './bq-side-menu-item.entry.js').then(processMod, consoleError);
2407
- case 'bq-slider':
2408
- return import(
2409
- /* webpackMode: "lazy" */
2410
- './bq-slider.entry.js').then(processMod, consoleError);
2411
- case 'bq-spinner':
2412
- return import(
2413
- /* webpackMode: "lazy" */
2414
- './bq-spinner.entry.js').then(processMod, consoleError);
2415
- case 'bq-status':
2416
- return import(
2417
- /* webpackMode: "lazy" */
2418
- './bq-status.entry.js').then(processMod, consoleError);
2419
- case 'bq-step-item':
2420
- return import(
2421
- /* webpackMode: "lazy" */
2422
- './bq-step-item.entry.js').then(processMod, consoleError);
2423
- case 'bq-steps':
2424
- return import(
2425
- /* webpackMode: "lazy" */
2426
- './bq-steps.entry.js').then(processMod, consoleError);
2427
- case 'bq-switch':
2428
- return import(
2429
- /* webpackMode: "lazy" */
2430
- './bq-switch.entry.js').then(processMod, consoleError);
2431
- case 'bq-tab':
2432
- return import(
2433
- /* webpackMode: "lazy" */
2434
- './bq-tab.entry.js').then(processMod, consoleError);
2435
- case 'bq-tab-group':
2436
- return import(
2437
- /* webpackMode: "lazy" */
2438
- './bq-tab-group.entry.js').then(processMod, consoleError);
2439
- case 'bq-textarea':
2440
- return import(
2441
- /* webpackMode: "lazy" */
2442
- './bq-textarea.entry.js').then(processMod, consoleError);
2443
- case 'bq-toast':
2444
- return import(
2445
- /* webpackMode: "lazy" */
2446
- './bq-toast.entry.js').then(processMod, consoleError);
2447
- case 'bq-badge':
2448
- return import(
2449
- /* webpackMode: "lazy" */
2450
- './bq-badge.entry.js').then(processMod, consoleError);
2451
- case 'bq-dropdown_3':
2452
- return import(
2453
- /* webpackMode: "lazy" */
2454
- './bq-dropdown_3.entry.js').then(processMod, consoleError);
2455
- case 'bq-divider':
2456
- return import(
2457
- /* webpackMode: "lazy" */
2458
- './bq-divider.entry.js').then(processMod, consoleError);
2459
- case 'bq-panel':
2460
- return import(
2461
- /* webpackMode: "lazy" */
2462
- './bq-panel.entry.js').then(processMod, consoleError);
2463
- case 'bq-tooltip':
2464
- return import(
2465
- /* webpackMode: "lazy" */
2466
- './bq-tooltip.entry.js').then(processMod, consoleError);
2467
- case 'bq-button':
2468
- return import(
2469
- /* webpackMode: "lazy" */
2470
- './bq-button.entry.js').then(processMod, consoleError);
2471
- case 'bq-icon':
2472
- return import(
2473
- /* webpackMode: "lazy" */
2474
- './bq-icon.entry.js').then(processMod, consoleError);
2475
- }
2476
- }
2477
- return import(
2478
- /* @vite-ignore */
2479
- /* webpackInclude: /\.entry\.js$/ */
2480
- /* webpackExclude: /\.system\.entry\.js$/ */
2481
- /* webpackMode: "lazy" */
2482
- `./${bundleId}.entry.js${''}`).then((importedModule) => {
2483
- {
2484
- cmpModules.set(bundleId, importedModule);
2485
- }
2486
- return importedModule[exportName];
2487
- }, consoleError);
2488
- };
2489
- const styles = /*@__PURE__*/ new Map();
2490
- const win = typeof window !== 'undefined' ? window : {};
2491
- const doc = win.document || { head: {} };
2492
- const H = (win.HTMLElement || class {
2493
- });
2494
- const plt = {
2495
- $flags$: 0,
2496
- $resourcesUrl$: '',
2497
- jmp: (h) => h(),
2498
- raf: (h) => requestAnimationFrame(h),
2499
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
2500
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2501
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
2502
- };
2503
- const supportsShadow =
2504
- // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2505
- true;
2506
- const supportsListenerOptions = /*@__PURE__*/ (() => {
2507
- let supportsListenerOptions = false;
2508
- try {
2509
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
2510
- get() {
2511
- supportsListenerOptions = true;
2512
- },
2513
- }));
2514
- }
2515
- catch (e) { }
2516
- return supportsListenerOptions;
2517
- })();
2518
- const promiseResolve = (v) => Promise.resolve(v);
2519
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2520
- try {
2521
- new CSSStyleSheet();
2522
- return typeof new CSSStyleSheet().replaceSync === 'function';
2523
- }
2524
- catch (e) { }
2525
- return false;
2526
- })()
2527
- ;
2528
- const queueDomReads = [];
2529
- const queueDomWrites = [];
2530
- const queueTask = (queue, write) => (cb) => {
2531
- queue.push(cb);
2532
- if (!queuePending) {
2533
- queuePending = true;
2534
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2535
- nextTick(flush);
2536
- }
2537
- else {
2538
- plt.raf(flush);
2539
- }
2540
- }
2541
- };
2542
- const consume = (queue) => {
2543
- for (let i = 0; i < queue.length; i++) {
2544
- try {
2545
- queue[i](performance.now());
2546
- }
2547
- catch (e) {
2548
- consoleError(e);
2549
- }
2550
- }
2551
- queue.length = 0;
2552
- };
2553
- const flush = () => {
2554
- // always force a bunch of medium callbacks to run, but still have
2555
- // a throttle on how many can run in a certain time
2556
- // DOM READS!!!
2557
- consume(queueDomReads);
2558
- // DOM WRITES!!!
2559
- {
2560
- consume(queueDomWrites);
2561
- if ((queuePending = queueDomReads.length > 0)) {
2562
- // still more to do yet, but we've run out of time
2563
- // let's let this thing cool off and try again in the next tick
2564
- plt.raf(flush);
2565
- }
2566
- }
2567
- };
2568
- const nextTick = (cb) => promiseResolve().then(cb);
2569
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2570
-
2571
- export { Env as E, H, Host as a, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
2572
-
2573
- //# sourceMappingURL=index-fe861cd3.js.map