hemfixarna-web-components 1.6.1 → 1.6.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 (243) hide show
  1. package/dist/{collection/utils/api.js → hemfixarna-components/api-36f73d0d.js} +6 -4
  2. package/dist/hemfixarna-components/api-36f73d0d.js.map +1 -0
  3. package/dist/hemfixarna-components/app-globals-0f993ce5.js +5 -0
  4. package/dist/hemfixarna-components/app-globals-0f993ce5.js.map +1 -0
  5. package/dist/{collection/utils/calc.js → hemfixarna-components/calc-4c79b798.js} +6 -3
  6. package/dist/hemfixarna-components/calc-4c79b798.js.map +1 -0
  7. package/dist/hemfixarna-components/css-shim-62d2171c.js +6 -0
  8. package/dist/hemfixarna-components/css-shim-62d2171c.js.map +1 -0
  9. package/dist/hemfixarna-components/dom-46a68c9b.js +75 -0
  10. package/dist/hemfixarna-components/dom-46a68c9b.js.map +1 -0
  11. package/dist/{collection/utils/form.js → hemfixarna-components/form-c53dca29.js} +4 -2
  12. package/dist/hemfixarna-components/form-c53dca29.js.map +1 -0
  13. package/dist/{collection/components/hemfixarna-address/hemfixarna-address.js → hemfixarna-components/hemfixarna-address.entry.js} +14 -20
  14. package/dist/hemfixarna-components/hemfixarna-address.entry.js.map +1 -0
  15. package/dist/hemfixarna-components/hemfixarna-box.entry.js +49 -0
  16. package/dist/hemfixarna-components/hemfixarna-box.entry.js.map +1 -0
  17. package/dist/{collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js → hemfixarna-components/hemfixarna-breadcrumbs.entry.js} +13 -84
  18. package/dist/hemfixarna-components/hemfixarna-breadcrumbs.entry.js.map +1 -0
  19. package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js +27 -0
  20. package/dist/hemfixarna-components/hemfixarna-byggmax.entry.js.map +1 -0
  21. package/dist/{collection/components/hemfixarna-cart/hemfixarna-cart.js → hemfixarna-components/hemfixarna-cart.entry.js} +11 -31
  22. package/dist/hemfixarna-components/hemfixarna-cart.entry.js.map +1 -0
  23. package/dist/{collection/components/hemfixarna-category.tsx/hemfixarna-category.js → hemfixarna-components/hemfixarna-category.entry.js} +12 -6
  24. package/dist/hemfixarna-components/hemfixarna-category.entry.js.map +1 -0
  25. package/dist/{collection/components/hemfixarna-checkout/hemfixarna-checkout.js → hemfixarna-components/hemfixarna-checkout.entry.js} +38 -33
  26. package/dist/hemfixarna-components/hemfixarna-checkout.entry.js.map +1 -0
  27. package/dist/hemfixarna-components/hemfixarna-component.entry.js +248 -0
  28. package/dist/hemfixarna-components/hemfixarna-component.entry.js.map +1 -0
  29. package/dist/hemfixarna-components/hemfixarna-components.esm.js +162 -1
  30. package/dist/hemfixarna-components/hemfixarna-components.esm.js.map +1 -1
  31. package/dist/{collection/components/hemfixarna-contact/hemfixarna-contact.js → hemfixarna-components/hemfixarna-contact.entry.js} +10 -28
  32. package/dist/hemfixarna-components/hemfixarna-contact.entry.js.map +1 -0
  33. package/dist/{collection/components/hemfixarna-demo/hemfixarna-demo.js → hemfixarna-components/hemfixarna-demo.entry.js} +23 -46
  34. package/dist/hemfixarna-components/hemfixarna-demo.entry.js.map +1 -0
  35. package/dist/hemfixarna-components/hemfixarna-doro.entry.js +23 -0
  36. package/dist/hemfixarna-components/hemfixarna-doro.entry.js.map +1 -0
  37. package/dist/hemfixarna-components/hemfixarna-elfa.entry.js +24 -0
  38. package/dist/hemfixarna-components/hemfixarna-elfa.entry.js.map +1 -0
  39. package/dist/hemfixarna-components/hemfixarna-fargvaruhuset.entry.js +21 -0
  40. package/dist/hemfixarna-components/hemfixarna-fargvaruhuset.entry.js.map +1 -0
  41. package/dist/hemfixarna-components/hemfixarna-flyttsmart.entry.js +21 -0
  42. package/dist/hemfixarna-components/hemfixarna-flyttsmart.entry.js.map +1 -0
  43. package/dist/hemfixarna-components/hemfixarna-forebygg.entry.js +23 -0
  44. package/dist/hemfixarna-components/hemfixarna-forebygg.entry.js.map +1 -0
  45. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js +770 -0
  46. package/dist/hemfixarna-components/hemfixarna-getuser.entry.js.map +1 -0
  47. package/dist/hemfixarna-components/hemfixarna-hornbach.entry.js +24 -0
  48. package/dist/hemfixarna-components/hemfixarna-hornbach.entry.js.map +1 -0
  49. package/dist/{collection/components/hemfixarna-info/hemfixarna-info.js → hemfixarna-components/hemfixarna-info.entry.js} +11 -7
  50. package/dist/hemfixarna-components/hemfixarna-info.entry.js.map +1 -0
  51. package/dist/{collection/components/hemfixarna-invoice/hemfixarna-invoice.js → hemfixarna-components/hemfixarna-invoice.entry.js} +16 -27
  52. package/dist/hemfixarna-components/hemfixarna-invoice.entry.js.map +1 -0
  53. package/dist/hemfixarna-components/hemfixarna-kbygg.entry.js +21 -0
  54. package/dist/hemfixarna-components/hemfixarna-kbygg.entry.js.map +1 -0
  55. package/dist/hemfixarna-components/hemfixarna-klint.entry.js +20 -0
  56. package/dist/hemfixarna-components/hemfixarna-klint.entry.js.map +1 -0
  57. package/dist/hemfixarna-components/hemfixarna-kund.entry.js +20 -0
  58. package/dist/hemfixarna-components/hemfixarna-kund.entry.js.map +1 -0
  59. package/dist/hemfixarna-components/hemfixarna-norrgavel.entry.js +21 -0
  60. package/dist/hemfixarna-components/hemfixarna-norrgavel.entry.js.map +1 -0
  61. package/dist/{collection/components/hemfixarna-order/hemfixarna-order.js → hemfixarna-components/hemfixarna-order.entry.js} +11 -31
  62. package/dist/hemfixarna-components/hemfixarna-order.entry.js.map +1 -0
  63. package/dist/{collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js → hemfixarna-components/hemfixarna-orderrows.entry.js} +12 -50
  64. package/dist/hemfixarna-components/hemfixarna-orderrows.entry.js.map +1 -0
  65. package/dist/hemfixarna-components/hemfixarna-power.entry.js +21 -0
  66. package/dist/hemfixarna-components/hemfixarna-power.entry.js.map +1 -0
  67. package/dist/{collection/components/hemfixarna-product/hemfixarna-product.js → hemfixarna-components/hemfixarna-product.entry.js} +18 -27
  68. package/dist/hemfixarna-components/hemfixarna-product.entry.js.map +1 -0
  69. package/dist/{collection/components/hemfixarna-service/hemfixarna-service.js → hemfixarna-components/hemfixarna-service.entry.js} +12 -6
  70. package/dist/hemfixarna-components/hemfixarna-service.entry.js.map +1 -0
  71. package/dist/hemfixarna-components/hemfixarna-skanska.entry.js +24 -0
  72. package/dist/hemfixarna-components/hemfixarna-skanska.entry.js.map +1 -0
  73. package/dist/hemfixarna-components/hemfixarna-sparfonster.entry.js +21 -0
  74. package/dist/hemfixarna-components/hemfixarna-sparfonster.entry.js.map +1 -0
  75. package/dist/{collection/components/hemfixarna-start/hemfixarna-start.js → hemfixarna-components/hemfixarna-start.entry.js} +11 -48
  76. package/dist/hemfixarna-components/hemfixarna-start.entry.js.map +1 -0
  77. package/dist/hemfixarna-components/hemfixarna-string-furniture.entry.js +23 -0
  78. package/dist/hemfixarna-components/hemfixarna-string-furniture.entry.js.map +1 -0
  79. package/dist/hemfixarna-components/hemfixarna-superfront.entry.js +20 -0
  80. package/dist/hemfixarna-components/hemfixarna-superfront.entry.js.map +1 -0
  81. package/dist/hemfixarna-components/hemfixarna-tesla.entry.js +21 -0
  82. package/dist/hemfixarna-components/hemfixarna-tesla.entry.js.map +1 -0
  83. package/dist/hemfixarna-components/hemfixarna-traningspartner.entry.js +20 -0
  84. package/dist/hemfixarna-components/hemfixarna-traningspartner.entry.js.map +1 -0
  85. package/dist/hemfixarna-components/hemfixarna-zaptec.entry.js +21 -0
  86. package/dist/hemfixarna-components/hemfixarna-zaptec.entry.js.map +1 -0
  87. package/dist/hemfixarna-components/index-b6a6e994.js +256 -0
  88. package/dist/hemfixarna-components/index-b6a6e994.js.map +1 -0
  89. package/dist/{collection/types/index.js → hemfixarna-components/index-d90ad11b.js} +7 -4
  90. package/dist/hemfixarna-components/index-d90ad11b.js.map +1 -0
  91. package/dist/hemfixarna-components/index-f1a87cf1.js +3397 -0
  92. package/dist/{cjs/hemfixarna-address_36.cjs.entry.js.map → hemfixarna-components/index-f1a87cf1.js.map} +1 -1
  93. package/dist/hemfixarna-components/index.esm.js +1 -0
  94. package/dist/hemfixarna-components/index.esm.js.map +1 -1
  95. package/dist/{collection/utils/scroll.js → hemfixarna-components/scroll-6c26b5da.js} +4 -2
  96. package/dist/hemfixarna-components/scroll-6c26b5da.js.map +1 -0
  97. package/dist/hemfixarna-components/shadow-css-05e0c1f4.js +389 -0
  98. package/dist/hemfixarna-components/shadow-css-05e0c1f4.js.map +1 -0
  99. package/dist/{collection/utils/types.js → hemfixarna-components/types-641c9a1c.js} +6 -3
  100. package/dist/hemfixarna-components/types-641c9a1c.js.map +1 -0
  101. package/package.json +1 -1
  102. package/dist/cjs/hemfixarna-address_36.cjs.entry.js +0 -2763
  103. package/dist/cjs/hemfixarna-components.cjs.js +0 -28
  104. package/dist/cjs/hemfixarna-components.cjs.js.map +0 -1
  105. package/dist/cjs/index-b83343b9.js +0 -1687
  106. package/dist/cjs/index-b83343b9.js.map +0 -1
  107. package/dist/cjs/index.cjs.js +0 -4
  108. package/dist/cjs/index.cjs.js.map +0 -1
  109. package/dist/cjs/loader.cjs.js +0 -24
  110. package/dist/cjs/loader.cjs.js.map +0 -1
  111. package/dist/collection/assets/back.svg +0 -3
  112. package/dist/collection/assets/cart.svg +0 -10
  113. package/dist/collection/assets/checked.svg +0 -10
  114. package/dist/collection/assets/close.svg +0 -5
  115. package/dist/collection/assets/copy.png +0 -0
  116. package/dist/collection/assets/date.svg +0 -6
  117. package/dist/collection/assets/down.svg +0 -3
  118. package/dist/collection/assets/drag-drop.svg +0 -3
  119. package/dist/collection/assets/elfa.png +0 -0
  120. package/dist/collection/assets/gubbe-pensel.svg +0 -1
  121. package/dist/collection/assets/hemfixarna.svg +0 -11
  122. package/dist/collection/assets/hornbach/logo.svg +0 -42
  123. package/dist/collection/assets/hornbach/nav.jpg +0 -0
  124. package/dist/collection/assets/info.svg +0 -5
  125. package/dist/collection/assets/kbygg.svg +0 -29
  126. package/dist/collection/assets/minus.svg +0 -4
  127. package/dist/collection/assets/montering.svg +0 -15
  128. package/dist/collection/assets/norrgavel.svg +0 -1
  129. package/dist/collection/assets/pensel.svg +0 -1
  130. package/dist/collection/assets/plus.svg +0 -5
  131. package/dist/collection/assets/spinner.gif +0 -0
  132. package/dist/collection/assets/tesla.svg +0 -1
  133. package/dist/collection/assets/zaptec.svg +0 -1
  134. package/dist/collection/collection-manifest.json +0 -47
  135. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.css +0 -0
  136. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js +0 -184
  137. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js.map +0 -1
  138. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.css +0 -0
  139. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js +0 -123
  140. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js.map +0 -1
  141. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.css +0 -0
  142. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js +0 -142
  143. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js.map +0 -1
  144. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js +0 -132
  145. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js.map +0 -1
  146. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js +0 -132
  147. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js.map +0 -1
  148. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.css +0 -0
  149. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js +0 -123
  150. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js.map +0 -1
  151. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.css +0 -0
  152. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js +0 -142
  153. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js.map +0 -1
  154. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js +0 -132
  155. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js.map +0 -1
  156. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js +0 -113
  157. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js.map +0 -1
  158. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js +0 -113
  159. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js.map +0 -1
  160. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js +0 -132
  161. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js.map +0 -1
  162. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js +0 -131
  163. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js.map +0 -1
  164. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.css +0 -0
  165. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js +0 -141
  166. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js.map +0 -1
  167. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js +0 -131
  168. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js.map +0 -1
  169. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js +0 -123
  170. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js.map +0 -1
  171. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string.css +0 -0
  172. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js +0 -113
  173. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js.map +0 -1
  174. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js +0 -132
  175. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js.map +0 -1
  176. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js +0 -113
  177. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js.map +0 -1
  178. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js +0 -132
  179. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js.map +0 -1
  180. package/dist/collection/components/hemfixarna-address/hemfixarna-address.js.map +0 -1
  181. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js +0 -138
  182. package/dist/collection/components/hemfixarna-box/hemfixarna-box.js.map +0 -1
  183. package/dist/collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js.map +0 -1
  184. package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js.map +0 -1
  185. package/dist/collection/components/hemfixarna-category.tsx/hemfixarna-category.js.map +0 -1
  186. package/dist/collection/components/hemfixarna-checkout/hemfixarna-checkout.js.map +0 -1
  187. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js +0 -483
  188. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js.map +0 -1
  189. package/dist/collection/components/hemfixarna-component/hemfixarna.css +0 -1031
  190. package/dist/collection/components/hemfixarna-contact/hemfixarna-contact.js.map +0 -1
  191. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.css +0 -135
  192. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js.map +0 -1
  193. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js +0 -91
  194. package/dist/collection/components/hemfixarna-getuser/hemfixarna-getuser.js.map +0 -1
  195. package/dist/collection/components/hemfixarna-info/hemfixarna-info.js.map +0 -1
  196. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.css +0 -76
  197. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.js.map +0 -1
  198. package/dist/collection/components/hemfixarna-order/hemfixarna-order.js.map +0 -1
  199. package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js.map +0 -1
  200. package/dist/collection/components/hemfixarna-product/hemfixarna-product.css +0 -0
  201. package/dist/collection/components/hemfixarna-product/hemfixarna-product.js.map +0 -1
  202. package/dist/collection/components/hemfixarna-service/hemfixarna-service.js.map +0 -1
  203. package/dist/collection/components/hemfixarna-start/hemfixarna-start.js.map +0 -1
  204. package/dist/collection/index.js +0 -2
  205. package/dist/collection/index.js.map +0 -1
  206. package/dist/collection/store/index.js +0 -62
  207. package/dist/collection/store/index.js.map +0 -1
  208. package/dist/collection/types/felixtypes.js +0 -3
  209. package/dist/collection/types/felixtypes.js.map +0 -1
  210. package/dist/collection/types/index.js.map +0 -1
  211. package/dist/collection/utils/api.js.map +0 -1
  212. package/dist/collection/utils/calc.js.map +0 -1
  213. package/dist/collection/utils/creditSafe.js +0 -18
  214. package/dist/collection/utils/creditSafe.js.map +0 -1
  215. package/dist/collection/utils/felixApi.js +0 -18
  216. package/dist/collection/utils/felixApi.js.map +0 -1
  217. package/dist/collection/utils/felixFunctions.js +0 -189
  218. package/dist/collection/utils/felixFunctions.js.map +0 -1
  219. package/dist/collection/utils/form.js.map +0 -1
  220. package/dist/collection/utils/scroll.js.map +0 -1
  221. package/dist/collection/utils/types.js.map +0 -1
  222. package/dist/esm/hemfixarna-address_36.entry.js +0 -2724
  223. package/dist/esm/hemfixarna-address_36.entry.js.map +0 -1
  224. package/dist/esm/hemfixarna-components.js +0 -23
  225. package/dist/esm/hemfixarna-components.js.map +0 -1
  226. package/dist/esm/index-8c417125.js +0 -1656
  227. package/dist/esm/index-8c417125.js.map +0 -1
  228. package/dist/esm/index.js +0 -3
  229. package/dist/esm/index.js.map +0 -1
  230. package/dist/esm/loader.js +0 -20
  231. package/dist/esm/loader.js.map +0 -1
  232. package/dist/esm/polyfills/core-js.js +0 -11
  233. package/dist/esm/polyfills/css-shim.js +0 -1
  234. package/dist/esm/polyfills/dom.js +0 -79
  235. package/dist/esm/polyfills/es5-html-element.js +0 -1
  236. package/dist/esm/polyfills/index.js +0 -34
  237. package/dist/esm/polyfills/system.js +0 -6
  238. package/dist/hemfixarna-components/p-211cfa04.entry.js +0 -2
  239. package/dist/hemfixarna-components/p-211cfa04.entry.js.map +0 -1
  240. package/dist/hemfixarna-components/p-852e7173.js +0 -3
  241. package/dist/hemfixarna-components/p-852e7173.js.map +0 -1
  242. package/dist/index.cjs.js +0 -1
  243. package/dist/index.js +0 -1
@@ -1,1687 +0,0 @@
1
- 'use strict';
2
-
3
- function _interopNamespace(e) {
4
- if (e && e.__esModule) return e;
5
- var n = Object.create(null);
6
- if (e) {
7
- Object.keys(e).forEach(function (k) {
8
- if (k !== 'default') {
9
- var d = Object.getOwnPropertyDescriptor(e, k);
10
- Object.defineProperty(n, k, d.get ? d : {
11
- enumerable: true,
12
- get: function () {
13
- return e[k];
14
- }
15
- });
16
- }
17
- });
18
- }
19
- n['default'] = e;
20
- return Object.freeze(n);
21
- }
22
-
23
- const NAMESPACE = 'hemfixarna-components';
24
-
25
- /**
26
- * Virtual DOM patching algorithm based on Snabbdom by
27
- * Simon Friis Vindum (@paldepind)
28
- * Licensed under the MIT License
29
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
- *
31
- * Modified for Stencil's renderer and slot projection
32
- */
33
- let scopeId;
34
- let hostTagName;
35
- let isSvgMode = false;
36
- let renderingRef = null;
37
- let queuePending = false;
38
- const getAssetPath = (path) => {
39
- const assetUrl = new URL(path, plt.$resourcesUrl$);
40
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
41
- };
42
- const createTime = (fnName, tagName = '') => {
43
- {
44
- return () => {
45
- return;
46
- };
47
- }
48
- };
49
- const uniqueTime = (key, measureText) => {
50
- {
51
- return () => {
52
- return;
53
- };
54
- }
55
- };
56
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
57
- /**
58
- * Default style mode id
59
- */
60
- /**
61
- * Reusable empty obj/array
62
- * Don't add values to these!!
63
- */
64
- const EMPTY_OBJ = {};
65
- /**
66
- * Namespaces
67
- */
68
- const SVG_NS = 'http://www.w3.org/2000/svg';
69
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
70
- const isDef = (v) => v != null;
71
- /**
72
- * Check whether a value is a 'complex type', defined here as an object or a
73
- * function.
74
- *
75
- * @param o the value to check
76
- * @returns whether it's a complex type or not
77
- */
78
- const isComplexType = (o) => {
79
- // https://jsperf.com/typeof-fn-object/5
80
- o = typeof o;
81
- return o === 'object' || o === 'function';
82
- };
83
- /**
84
- * Helper method for querying a `meta` tag that contains a nonce value
85
- * out of a DOM's head.
86
- *
87
- * @param doc The DOM containing the `head` to query against
88
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
89
- * exists or the tag has no content.
90
- */
91
- function queryNonceMetaTagContent(doc) {
92
- var _a, _b, _c;
93
- 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;
94
- }
95
- /**
96
- * Production h() function based on Preact by
97
- * Jason Miller (@developit)
98
- * Licensed under the MIT License
99
- * https://github.com/developit/preact/blob/master/LICENSE
100
- *
101
- * Modified for Stencil's compiler and vdom
102
- */
103
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
104
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
105
- const h = (nodeName, vnodeData, ...children) => {
106
- let child = null;
107
- let key = null;
108
- let simple = false;
109
- let lastSimple = false;
110
- const vNodeChildren = [];
111
- const walk = (c) => {
112
- for (let i = 0; i < c.length; i++) {
113
- child = c[i];
114
- if (Array.isArray(child)) {
115
- walk(child);
116
- }
117
- else if (child != null && typeof child !== 'boolean') {
118
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
119
- child = String(child);
120
- }
121
- if (simple && lastSimple) {
122
- // If the previous child was simple (string), we merge both
123
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
124
- }
125
- else {
126
- // Append a new vNode, if it's text, we create a text vNode
127
- vNodeChildren.push(simple ? newVNode(null, child) : child);
128
- }
129
- lastSimple = simple;
130
- }
131
- }
132
- };
133
- walk(children);
134
- if (vnodeData) {
135
- // normalize class / classname attributes
136
- if (vnodeData.key) {
137
- key = vnodeData.key;
138
- }
139
- {
140
- const classData = vnodeData.className || vnodeData.class;
141
- if (classData) {
142
- vnodeData.class =
143
- typeof classData !== 'object'
144
- ? classData
145
- : Object.keys(classData)
146
- .filter((k) => classData[k])
147
- .join(' ');
148
- }
149
- }
150
- }
151
- if (typeof nodeName === 'function') {
152
- // nodeName is a functional component
153
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
154
- }
155
- const vnode = newVNode(nodeName, null);
156
- vnode.$attrs$ = vnodeData;
157
- if (vNodeChildren.length > 0) {
158
- vnode.$children$ = vNodeChildren;
159
- }
160
- {
161
- vnode.$key$ = key;
162
- }
163
- return vnode;
164
- };
165
- /**
166
- * A utility function for creating a virtual DOM node from a tag and some
167
- * possible text content.
168
- *
169
- * @param tag the tag for this element
170
- * @param text possible text content for the node
171
- * @returns a newly-minted virtual DOM node
172
- */
173
- const newVNode = (tag, text) => {
174
- const vnode = {
175
- $flags$: 0,
176
- $tag$: tag,
177
- $text$: text,
178
- $elm$: null,
179
- $children$: null,
180
- };
181
- {
182
- vnode.$attrs$ = null;
183
- }
184
- {
185
- vnode.$key$ = null;
186
- }
187
- return vnode;
188
- };
189
- const Host = {};
190
- /**
191
- * Check whether a given node is a Host node or not
192
- *
193
- * @param node the virtual DOM node to check
194
- * @returns whether it's a Host node or not
195
- */
196
- const isHost = (node) => node && node.$tag$ === Host;
197
- /**
198
- * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
199
- *
200
- * Note that these functions convert from {@link d.VNode} to
201
- * {@link d.ChildNode} to give functional component developers a friendly
202
- * interface.
203
- */
204
- const vdomFnUtils = {
205
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
206
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
207
- };
208
- /**
209
- * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
210
- * friendlier public interface (hence, 'convertToPublic').
211
- *
212
- * @param node the virtual DOM node to convert
213
- * @returns a converted child node
214
- */
215
- const convertToPublic = (node) => ({
216
- vattrs: node.$attrs$,
217
- vchildren: node.$children$,
218
- vkey: node.$key$,
219
- vname: node.$name$,
220
- vtag: node.$tag$,
221
- vtext: node.$text$,
222
- });
223
- /**
224
- * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
225
- * order to use the resulting object in the virtual DOM. The initial object was
226
- * likely created as part of presenting a public API, so converting it back
227
- * involved making it 'private' again (hence, `convertToPrivate`).
228
- *
229
- * @param node the child node to convert
230
- * @returns a converted virtual DOM node
231
- */
232
- const convertToPrivate = (node) => {
233
- if (typeof node.vtag === 'function') {
234
- const vnodeData = Object.assign({}, node.vattrs);
235
- if (node.vkey) {
236
- vnodeData.key = node.vkey;
237
- }
238
- if (node.vname) {
239
- vnodeData.name = node.vname;
240
- }
241
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
242
- }
243
- const vnode = newVNode(node.vtag, node.vtext);
244
- vnode.$attrs$ = node.vattrs;
245
- vnode.$children$ = node.vchildren;
246
- vnode.$key$ = node.vkey;
247
- vnode.$name$ = node.vname;
248
- return vnode;
249
- };
250
- /**
251
- * Parse a new property value for a given property type.
252
- *
253
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
254
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
255
- * 1. `any`, the type given to `propValue` in the function signature
256
- * 2. the type stored from `propType`.
257
- *
258
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
259
- *
260
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
261
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
262
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
263
- * ```tsx
264
- * <my-cmp prop-val={0}></my-cmp>
265
- * ```
266
- *
267
- * HTML prop values on the other hand, will always a string
268
- *
269
- * @param propValue the new value to coerce to some type
270
- * @param propType the type of the prop, expressed as a binary number
271
- * @returns the parsed/coerced value
272
- */
273
- const parsePropertyValue = (propValue, propType) => {
274
- // ensure this value is of the correct prop type
275
- if (propValue != null && !isComplexType(propValue)) {
276
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
277
- // per the HTML spec, any string value means it is a boolean true value
278
- // but we'll cheat here and say that the string "false" is the boolean false
279
- return propValue === 'false' ? false : propValue === '' || !!propValue;
280
- }
281
- if (propType & 1 /* MEMBER_FLAGS.String */) {
282
- // could have been passed as a number or boolean
283
- // but we still want it as a string
284
- return String(propValue);
285
- }
286
- // redundant return here for better minification
287
- return propValue;
288
- }
289
- // not sure exactly what type we want
290
- // so no need to change to a different type
291
- return propValue;
292
- };
293
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
294
- /**
295
- * Helper function to create & dispatch a custom Event on a provided target
296
- * @param elm the target of the Event
297
- * @param name the name to give the custom Event
298
- * @param opts options for configuring a custom Event
299
- * @returns the custom Event
300
- */
301
- const emitEvent = (elm, name, opts) => {
302
- const ev = plt.ce(name, opts);
303
- elm.dispatchEvent(ev);
304
- return ev;
305
- };
306
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
307
- const registerStyle = (scopeId, cssText, allowCS) => {
308
- let style = styles.get(scopeId);
309
- if (supportsConstructableStylesheets && allowCS) {
310
- style = (style || new CSSStyleSheet());
311
- if (typeof style === 'string') {
312
- style = cssText;
313
- }
314
- else {
315
- style.replaceSync(cssText);
316
- }
317
- }
318
- else {
319
- style = cssText;
320
- }
321
- styles.set(scopeId, style);
322
- };
323
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
324
- var _a;
325
- let scopeId = getScopeId(cmpMeta);
326
- const style = styles.get(scopeId);
327
- // if an element is NOT connected then getRootNode() will return the wrong root node
328
- // so the fallback is to always use the document for the root node in those cases
329
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
330
- if (style) {
331
- if (typeof style === 'string') {
332
- styleContainerNode = styleContainerNode.head || styleContainerNode;
333
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
334
- let styleElm;
335
- if (!appliedStyles) {
336
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
337
- }
338
- if (!appliedStyles.has(scopeId)) {
339
- {
340
- // TODO(STENCIL-659): Remove code implementing the CSS variable shim
341
- {
342
- styleElm = doc.createElement('style');
343
- styleElm.innerHTML = style;
344
- }
345
- // Apply CSP nonce to the style tag if it exists
346
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
347
- if (nonce != null) {
348
- styleElm.setAttribute('nonce', nonce);
349
- }
350
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
351
- }
352
- if (appliedStyles) {
353
- appliedStyles.add(scopeId);
354
- }
355
- }
356
- }
357
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
358
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
359
- }
360
- }
361
- return scopeId;
362
- };
363
- const attachStyles = (hostRef) => {
364
- const cmpMeta = hostRef.$cmpMeta$;
365
- const elm = hostRef.$hostElement$;
366
- const flags = cmpMeta.$flags$;
367
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
368
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
369
- // TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
370
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
371
- // only required when we're NOT using native shadow dom (slot)
372
- // or this browser doesn't support native shadow dom
373
- // and this host element was NOT created with SSR
374
- // let's pick out the inner content for slot projection
375
- // create a node to represent where the original
376
- // content was first placed, which is useful later on
377
- // DOM WRITE!!
378
- elm['s-sc'] = scopeId;
379
- elm.classList.add(scopeId + '-h');
380
- }
381
- endAttachStyles();
382
- };
383
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
384
- /**
385
- * Production setAccessor() function based on Preact by
386
- * Jason Miller (@developit)
387
- * Licensed under the MIT License
388
- * https://github.com/developit/preact/blob/master/LICENSE
389
- *
390
- * Modified for Stencil's compiler and vdom
391
- */
392
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
393
- if (oldValue !== newValue) {
394
- let isProp = isMemberInElement(elm, memberName);
395
- let ln = memberName.toLowerCase();
396
- if (memberName === 'class') {
397
- const classList = elm.classList;
398
- const oldClasses = parseClassList(oldValue);
399
- const newClasses = parseClassList(newValue);
400
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
401
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
402
- }
403
- else if (memberName === 'style') {
404
- // update style attribute, css properties and values
405
- {
406
- for (const prop in oldValue) {
407
- if (!newValue || newValue[prop] == null) {
408
- if (prop.includes('-')) {
409
- elm.style.removeProperty(prop);
410
- }
411
- else {
412
- elm.style[prop] = '';
413
- }
414
- }
415
- }
416
- }
417
- for (const prop in newValue) {
418
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
419
- if (prop.includes('-')) {
420
- elm.style.setProperty(prop, newValue[prop]);
421
- }
422
- else {
423
- elm.style[prop] = newValue[prop];
424
- }
425
- }
426
- }
427
- }
428
- else if (memberName === 'key')
429
- ;
430
- else if ((!isProp ) &&
431
- memberName[0] === 'o' &&
432
- memberName[1] === 'n') {
433
- // Event Handlers
434
- // so if the member name starts with "on" and the 3rd characters is
435
- // a capital letter, and it's not already a member on the element,
436
- // then we're assuming it's an event listener
437
- if (memberName[2] === '-') {
438
- // on- prefixed events
439
- // allows to be explicit about the dom event to listen without any magic
440
- // under the hood:
441
- // <my-cmp on-click> // listens for "click"
442
- // <my-cmp on-Click> // listens for "Click"
443
- // <my-cmp on-ionChange> // listens for "ionChange"
444
- // <my-cmp on-EVENTS> // listens for "EVENTS"
445
- memberName = memberName.slice(3);
446
- }
447
- else if (isMemberInElement(win, ln)) {
448
- // standard event
449
- // the JSX attribute could have been "onMouseOver" and the
450
- // member name "onmouseover" is on the window's prototype
451
- // so let's add the listener "mouseover", which is all lowercased
452
- memberName = ln.slice(2);
453
- }
454
- else {
455
- // custom event
456
- // the JSX attribute could have been "onMyCustomEvent"
457
- // so let's trim off the "on" prefix and lowercase the first character
458
- // and add the listener "myCustomEvent"
459
- // except for the first character, we keep the event name case
460
- memberName = ln[2] + memberName.slice(3);
461
- }
462
- if (oldValue) {
463
- plt.rel(elm, memberName, oldValue, false);
464
- }
465
- if (newValue) {
466
- plt.ael(elm, memberName, newValue, false);
467
- }
468
- }
469
- else {
470
- // Set property if it exists and it's not a SVG
471
- const isComplex = isComplexType(newValue);
472
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
473
- try {
474
- if (!elm.tagName.includes('-')) {
475
- const n = newValue == null ? '' : newValue;
476
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
477
- if (memberName === 'list') {
478
- isProp = false;
479
- }
480
- else if (oldValue == null || elm[memberName] != n) {
481
- elm[memberName] = n;
482
- }
483
- }
484
- else {
485
- elm[memberName] = newValue;
486
- }
487
- }
488
- catch (e) { }
489
- }
490
- if (newValue == null || newValue === false) {
491
- if (newValue !== false || elm.getAttribute(memberName) === '') {
492
- {
493
- elm.removeAttribute(memberName);
494
- }
495
- }
496
- }
497
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
498
- newValue = newValue === true ? '' : newValue;
499
- {
500
- elm.setAttribute(memberName, newValue);
501
- }
502
- }
503
- }
504
- }
505
- };
506
- const parseClassListRegex = /\s/;
507
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
508
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
509
- // if the element passed in is a shadow root, which is a document fragment
510
- // then we want to be adding attrs/props to the shadow root's "host" element
511
- // if it's not a shadow root, then we add attrs/props to the same element
512
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
513
- ? newVnode.$elm$.host
514
- : newVnode.$elm$;
515
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
516
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
517
- {
518
- // remove attributes no longer present on the vnode by setting them to undefined
519
- for (memberName in oldVnodeAttrs) {
520
- if (!(memberName in newVnodeAttrs)) {
521
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
522
- }
523
- }
524
- }
525
- // add new & update changed attributes
526
- for (memberName in newVnodeAttrs) {
527
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
528
- }
529
- };
530
- /**
531
- * Create a DOM Node corresponding to one of the children of a given VNode.
532
- *
533
- * @param oldParentVNode the parent VNode from the previous render
534
- * @param newParentVNode the parent VNode from the current render
535
- * @param childIndex the index of the VNode, in the _new_ parent node's
536
- * children, for which we will create a new DOM node
537
- * @param parentElm the parent DOM node which our new node will be a child of
538
- * @returns the newly created node
539
- */
540
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
541
- // tslint:disable-next-line: prefer-const
542
- const newVNode = newParentVNode.$children$[childIndex];
543
- let i = 0;
544
- let elm;
545
- let childNode;
546
- if (newVNode.$text$ !== null) {
547
- // create text node
548
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
549
- }
550
- else {
551
- if (!isSvgMode) {
552
- isSvgMode = newVNode.$tag$ === 'svg';
553
- }
554
- // create element
555
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
556
- );
557
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
558
- isSvgMode = false;
559
- }
560
- // add css classes, attrs, props, listeners, etc.
561
- {
562
- updateElement(null, newVNode, isSvgMode);
563
- }
564
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
565
- // if there is a scopeId and this is the initial render
566
- // then let's add the scopeId as a css class
567
- elm.classList.add((elm['s-si'] = scopeId));
568
- }
569
- if (newVNode.$children$) {
570
- for (i = 0; i < newVNode.$children$.length; ++i) {
571
- // create the node
572
- childNode = createElm(oldParentVNode, newVNode, i);
573
- // return node could have been null
574
- if (childNode) {
575
- // append our new node
576
- elm.appendChild(childNode);
577
- }
578
- }
579
- }
580
- {
581
- if (newVNode.$tag$ === 'svg') {
582
- // Only reset the SVG context when we're exiting <svg> element
583
- isSvgMode = false;
584
- }
585
- else if (elm.tagName === 'foreignObject') {
586
- // Reenter SVG context when we're exiting <foreignObject> element
587
- isSvgMode = true;
588
- }
589
- }
590
- }
591
- return elm;
592
- };
593
- /**
594
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
595
- * add them to the DOM in the appropriate place.
596
- *
597
- * @param parentElm the DOM node which should be used as a parent for the new
598
- * DOM nodes
599
- * @param before a child of the `parentElm` which the new children should be
600
- * inserted before (optional)
601
- * @param parentVNode the parent virtual DOM node
602
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
603
- * @param startIdx the index in the child virtual DOM nodes at which to start
604
- * creating DOM nodes (inclusive)
605
- * @param endIdx the index in the child virtual DOM nodes at which to stop
606
- * creating DOM nodes (inclusive)
607
- */
608
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
609
- let containerElm = (parentElm);
610
- let childNode;
611
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
612
- containerElm = containerElm.shadowRoot;
613
- }
614
- for (; startIdx <= endIdx; ++startIdx) {
615
- if (vnodes[startIdx]) {
616
- childNode = createElm(null, parentVNode, startIdx);
617
- if (childNode) {
618
- vnodes[startIdx].$elm$ = childNode;
619
- containerElm.insertBefore(childNode, before);
620
- }
621
- }
622
- }
623
- };
624
- /**
625
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
626
- * This can be used to, for instance, clean up after a list of children which
627
- * should no longer be shown.
628
- *
629
- * This function also handles some of Stencil's slot relocation logic.
630
- *
631
- * @param vnodes a list of virtual DOM nodes to remove
632
- * @param startIdx the index at which to start removing nodes (inclusive)
633
- * @param endIdx the index at which to stop removing nodes (inclusive)
634
- * @param vnode a VNode
635
- * @param elm an element
636
- */
637
- const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
638
- for (; startIdx <= endIdx; ++startIdx) {
639
- if ((vnode = vnodes[startIdx])) {
640
- elm = vnode.$elm$;
641
- // remove the vnode's element from the dom
642
- elm.remove();
643
- }
644
- }
645
- };
646
- /**
647
- * Reconcile the children of a new VNode with the children of an old VNode by
648
- * traversing the two collections of children, identifying nodes that are
649
- * conserved or changed, calling out to `patch` to make any necessary
650
- * updates to the DOM, and rearranging DOM nodes as needed.
651
- *
652
- * The algorithm for reconciling children works by analyzing two 'windows' onto
653
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
654
- * 'windows' by storing start and end indices and references to the
655
- * corresponding array entries. Initially the two 'windows' are basically equal
656
- * to the entire array, but we progressively narrow the windows until there are
657
- * no children left to update by doing the following:
658
- *
659
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
660
- * that if we have an initial array like the following we'll end up dealing
661
- * only with a window bounded by the highlighted elements:
662
- *
663
- * [null, null, VNode1 , ... , VNode2, null, null]
664
- * ^^^^^^ ^^^^^^
665
- *
666
- * 2. Check to see if the elements at the head and tail positions are equal
667
- * across the windows. This will basically detect elements which haven't
668
- * been added, removed, or changed position, i.e. if you had the following
669
- * VNode elements (represented as HTML):
670
- *
671
- * oldVNode: `<div><p><span>HEY</span></p></div>`
672
- * newVNode: `<div><p><span>THERE</span></p></div>`
673
- *
674
- * Then when comparing the children of the `<div>` tag we check the equality
675
- * of the VNodes corresponding to the `<p>` tags and, since they are the
676
- * same tag in the same position, we'd be able to avoid completely
677
- * re-rendering the subtree under them with a new DOM element and would just
678
- * call out to `patch` to handle reconciling their children and so on.
679
- *
680
- * 3. Check, for both windows, to see if the element at the beginning of the
681
- * window corresponds to the element at the end of the other window. This is
682
- * a heuristic which will let us identify _some_ situations in which
683
- * elements have changed position, for instance it _should_ detect that the
684
- * children nodes themselves have not changed but merely moved in the
685
- * following example:
686
- *
687
- * oldVNode: `<div><element-one /><element-two /></div>`
688
- * newVNode: `<div><element-two /><element-one /></div>`
689
- *
690
- * If we find cases like this then we also need to move the concrete DOM
691
- * elements corresponding to the moved children to write the re-order to the
692
- * DOM.
693
- *
694
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
695
- * nodes in the old children which have the same key as the first element in
696
- * our window on the new children. If we find such a node we handle calling
697
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
698
- * what we find.
699
- *
700
- * Finally, once we've narrowed our 'windows' to the point that either of them
701
- * collapse (i.e. they have length 0) we then handle any remaining VNode
702
- * insertion or deletion that needs to happen to get a DOM state that correctly
703
- * reflects the new child VNodes. If, for instance, after our window on the old
704
- * children has collapsed we still have more nodes on the new children that
705
- * we haven't dealt with yet then we need to add them, or if the new children
706
- * collapse but we still have unhandled _old_ children then we need to make
707
- * sure the corresponding DOM nodes are removed.
708
- *
709
- * @param parentElm the node into which the parent VNode is rendered
710
- * @param oldCh the old children of the parent node
711
- * @param newVNode the new VNode which will replace the parent
712
- * @param newCh the new children of the parent node
713
- */
714
- const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
715
- let oldStartIdx = 0;
716
- let newStartIdx = 0;
717
- let idxInOld = 0;
718
- let i = 0;
719
- let oldEndIdx = oldCh.length - 1;
720
- let oldStartVnode = oldCh[0];
721
- let oldEndVnode = oldCh[oldEndIdx];
722
- let newEndIdx = newCh.length - 1;
723
- let newStartVnode = newCh[0];
724
- let newEndVnode = newCh[newEndIdx];
725
- let node;
726
- let elmToMove;
727
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
728
- if (oldStartVnode == null) {
729
- // VNode might have been moved left
730
- oldStartVnode = oldCh[++oldStartIdx];
731
- }
732
- else if (oldEndVnode == null) {
733
- oldEndVnode = oldCh[--oldEndIdx];
734
- }
735
- else if (newStartVnode == null) {
736
- newStartVnode = newCh[++newStartIdx];
737
- }
738
- else if (newEndVnode == null) {
739
- newEndVnode = newCh[--newEndIdx];
740
- }
741
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
742
- // if the start nodes are the same then we should patch the new VNode
743
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
744
- // indices to reflect that. We don't need to move any DOM Nodes around
745
- // since things are matched up in order.
746
- patch(oldStartVnode, newStartVnode);
747
- oldStartVnode = oldCh[++oldStartIdx];
748
- newStartVnode = newCh[++newStartIdx];
749
- }
750
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
751
- // likewise, if the end nodes are the same we patch new onto old and
752
- // decrement our end indices, and also likewise in this case we don't
753
- // need to move any DOM Nodes.
754
- patch(oldEndVnode, newEndVnode);
755
- oldEndVnode = oldCh[--oldEndIdx];
756
- newEndVnode = newCh[--newEndIdx];
757
- }
758
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
759
- patch(oldStartVnode, newEndVnode);
760
- // We need to move the element for `oldStartVnode` into a position which
761
- // will be appropriate for `newEndVnode`. For this we can use
762
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
763
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
764
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
765
- //
766
- // <old-start-node />
767
- // <some-intervening-node />
768
- // <old-end-node />
769
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
770
- // <next-sibling />
771
- //
772
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
773
- // the node for `oldStartVnode` at the end of the children of
774
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
775
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
776
- // append it to the children of the parent element.
777
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
778
- oldStartVnode = oldCh[++oldStartIdx];
779
- newEndVnode = newCh[--newEndIdx];
780
- }
781
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
782
- patch(oldEndVnode, newStartVnode);
783
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
784
- // the same node, so since we're here we know that they are not. Thus we
785
- // can move the element for `oldEndVnode` _before_ the element for
786
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
787
- // future.
788
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
789
- oldEndVnode = oldCh[--oldEndIdx];
790
- newStartVnode = newCh[++newStartIdx];
791
- }
792
- else {
793
- // Here we do some checks to match up old and new nodes based on the
794
- // `$key$` attribute, which is set by putting a `key="my-key"` attribute
795
- // in the JSX for a DOM element in the implementation of a Stencil
796
- // component.
797
- //
798
- // First we check to see if there are any nodes in the array of old
799
- // children which have the same key as the first node in the new
800
- // children.
801
- idxInOld = -1;
802
- {
803
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
804
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
805
- idxInOld = i;
806
- break;
807
- }
808
- }
809
- }
810
- if (idxInOld >= 0) {
811
- // We found a node in the old children which matches up with the first
812
- // node in the new children! So let's deal with that
813
- elmToMove = oldCh[idxInOld];
814
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
815
- // the tag doesn't match so we'll need a new DOM element
816
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
817
- }
818
- else {
819
- patch(elmToMove, newStartVnode);
820
- // invalidate the matching old node so that we won't try to update it
821
- // again later on
822
- oldCh[idxInOld] = undefined;
823
- node = elmToMove.$elm$;
824
- }
825
- newStartVnode = newCh[++newStartIdx];
826
- }
827
- else {
828
- // We either didn't find an element in the old children that matches
829
- // the key of the first new child OR the build is not using `key`
830
- // attributes at all. In either case we need to create a new element
831
- // for the new node.
832
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
833
- newStartVnode = newCh[++newStartIdx];
834
- }
835
- if (node) {
836
- // if we created a new node then handle inserting it to the DOM
837
- {
838
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
839
- }
840
- }
841
- }
842
- }
843
- if (oldStartIdx > oldEndIdx) {
844
- // we have some more new nodes to add which don't match up with old nodes
845
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
846
- }
847
- else if (newStartIdx > newEndIdx) {
848
- // there are nodes in the `oldCh` array which no longer correspond to nodes
849
- // in the new array, so lets remove them (which entails cleaning up the
850
- // relevant DOM nodes)
851
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
852
- }
853
- };
854
- /**
855
- * Compare two VNodes to determine if they are the same
856
- *
857
- * **NB**: This function is an equality _heuristic_ based on the available
858
- * information set on the two VNodes and can be misleading under certain
859
- * circumstances. In particular, if the two nodes do not have `key` attrs
860
- * (available under `$key$` on VNodes) then the function falls back on merely
861
- * checking that they have the same tag.
862
- *
863
- * So, in other words, if `key` attrs are not set on VNodes which may be
864
- * changing order within a `children` array or something along those lines then
865
- * we could obtain a false negative and then have to do needless re-rendering
866
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
867
- *
868
- * @param leftVNode the first VNode to check
869
- * @param rightVNode the second VNode to check
870
- * @returns whether they're equal or not
871
- */
872
- const isSameVnode = (leftVNode, rightVNode) => {
873
- // compare if two vnode to see if they're "technically" the same
874
- // need to have the same element tag, and same key to be the same
875
- if (leftVNode.$tag$ === rightVNode.$tag$) {
876
- // this will be set if components in the build have `key` attrs set on them
877
- {
878
- return leftVNode.$key$ === rightVNode.$key$;
879
- }
880
- }
881
- return false;
882
- };
883
- /**
884
- * Handle reconciling an outdated VNode with a new one which corresponds to
885
- * it. This function handles flushing updates to the DOM and reconciling the
886
- * children of the two nodes (if any).
887
- *
888
- * @param oldVNode an old VNode whose DOM element and children we want to update
889
- * @param newVNode a new VNode representing an updated version of the old one
890
- */
891
- const patch = (oldVNode, newVNode) => {
892
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
893
- const oldChildren = oldVNode.$children$;
894
- const newChildren = newVNode.$children$;
895
- const tag = newVNode.$tag$;
896
- const text = newVNode.$text$;
897
- if (text === null) {
898
- {
899
- // test if we're rendering an svg element, or still rendering nodes inside of one
900
- // only add this to the when the compiler sees we're using an svg somewhere
901
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
902
- }
903
- {
904
- {
905
- // either this is the first render of an element OR it's an update
906
- // AND we already know it's possible it could have changed
907
- // this updates the element's css classes, attrs, props, listeners, etc.
908
- updateElement(oldVNode, newVNode, isSvgMode);
909
- }
910
- }
911
- if (oldChildren !== null && newChildren !== null) {
912
- // looks like there's child vnodes for both the old and new vnodes
913
- // so we need to call `updateChildren` to reconcile them
914
- updateChildren(elm, oldChildren, newVNode, newChildren);
915
- }
916
- else if (newChildren !== null) {
917
- // no old child vnodes, but there are new child vnodes to add
918
- if (oldVNode.$text$ !== null) {
919
- // the old vnode was text, so be sure to clear it out
920
- elm.textContent = '';
921
- }
922
- // add the new vnode children
923
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
924
- }
925
- else if (oldChildren !== null) {
926
- // no new child vnodes, but there are old child vnodes to remove
927
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
928
- }
929
- if (isSvgMode && tag === 'svg') {
930
- isSvgMode = false;
931
- }
932
- }
933
- else if (oldVNode.$text$ !== text) {
934
- // update the text content for the text only vnode
935
- // and also only if the text is different than before
936
- elm.data = text;
937
- }
938
- };
939
- /**
940
- * The main entry point for Stencil's virtual DOM-based rendering engine
941
- *
942
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
943
- * function will handle creating a virtual DOM tree with a single root, patching
944
- * the current virtual DOM tree onto an old one (if any), dealing with slot
945
- * relocation, and reflecting attributes.
946
- *
947
- * @param hostRef data needed to root and render the virtual DOM tree, such as
948
- * the DOM node into which it should be rendered.
949
- * @param renderFnResults the virtual DOM nodes to be rendered
950
- */
951
- const renderVdom = (hostRef, renderFnResults) => {
952
- const hostElm = hostRef.$hostElement$;
953
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
954
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
955
- hostTagName = hostElm.tagName;
956
- rootVnode.$tag$ = null;
957
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
958
- hostRef.$vnode$ = rootVnode;
959
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
960
- {
961
- scopeId = hostElm['s-sc'];
962
- }
963
- // synchronous patch
964
- patch(oldVNode, rootVnode);
965
- };
966
- const attachToAncestor = (hostRef, ancestorComponent) => {
967
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
968
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
969
- }
970
- };
971
- const scheduleUpdate = (hostRef, isInitialLoad) => {
972
- {
973
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
974
- }
975
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
976
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
977
- return;
978
- }
979
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
980
- // there is no ancestor component or the ancestor component
981
- // has already fired off its lifecycle update then
982
- // fire off the initial update
983
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
984
- return writeTask(dispatch) ;
985
- };
986
- const dispatchHooks = (hostRef, isInitialLoad) => {
987
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
988
- const instance = hostRef.$lazyInstance$ ;
989
- let promise;
990
- if (isInitialLoad) {
991
- {
992
- hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
993
- if (hostRef.$queuedListeners$) {
994
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
995
- hostRef.$queuedListeners$ = null;
996
- }
997
- }
998
- {
999
- promise = safeCall(instance, 'componentWillLoad');
1000
- }
1001
- }
1002
- endSchedule();
1003
- return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1004
- };
1005
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1006
- // updateComponent
1007
- const elm = hostRef.$hostElement$;
1008
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1009
- const rc = elm['s-rc'];
1010
- if (isInitialLoad) {
1011
- // DOM WRITE!
1012
- attachStyles(hostRef);
1013
- }
1014
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1015
- {
1016
- callRender(hostRef, instance);
1017
- }
1018
- if (rc) {
1019
- // ok, so turns out there are some child host elements
1020
- // waiting on this parent element to load
1021
- // let's fire off all update callbacks waiting
1022
- rc.map((cb) => cb());
1023
- elm['s-rc'] = undefined;
1024
- }
1025
- endRender();
1026
- endUpdate();
1027
- {
1028
- const childrenPromises = elm['s-p'];
1029
- const postUpdate = () => postUpdateComponent(hostRef);
1030
- if (childrenPromises.length === 0) {
1031
- postUpdate();
1032
- }
1033
- else {
1034
- Promise.all(childrenPromises).then(postUpdate);
1035
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1036
- childrenPromises.length = 0;
1037
- }
1038
- }
1039
- };
1040
- const callRender = (hostRef, instance, elm) => {
1041
- try {
1042
- renderingRef = instance;
1043
- instance = instance.render && instance.render();
1044
- {
1045
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1046
- }
1047
- {
1048
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1049
- }
1050
- {
1051
- {
1052
- // looks like we've got child nodes to render into this host element
1053
- // or we need to update the css class/attrs on the host element
1054
- // DOM WRITE!
1055
- {
1056
- renderVdom(hostRef, instance);
1057
- }
1058
- }
1059
- }
1060
- }
1061
- catch (e) {
1062
- consoleError(e, hostRef.$hostElement$);
1063
- }
1064
- renderingRef = null;
1065
- return null;
1066
- };
1067
- const getRenderingRef = () => renderingRef;
1068
- const postUpdateComponent = (hostRef) => {
1069
- const tagName = hostRef.$cmpMeta$.$tagName$;
1070
- const elm = hostRef.$hostElement$;
1071
- const endPostUpdate = createTime('postUpdate', tagName);
1072
- const instance = hostRef.$lazyInstance$ ;
1073
- const ancestorComponent = hostRef.$ancestorComponent$;
1074
- {
1075
- safeCall(instance, 'componentDidRender');
1076
- }
1077
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1078
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1079
- {
1080
- // DOM WRITE!
1081
- addHydratedFlag(elm);
1082
- }
1083
- endPostUpdate();
1084
- {
1085
- hostRef.$onReadyResolve$(elm);
1086
- if (!ancestorComponent) {
1087
- appDidLoad();
1088
- }
1089
- }
1090
- }
1091
- else {
1092
- endPostUpdate();
1093
- }
1094
- // load events fire from bottom to top
1095
- // the deepest elements load first then bubbles up
1096
- {
1097
- if (hostRef.$onRenderResolve$) {
1098
- hostRef.$onRenderResolve$();
1099
- hostRef.$onRenderResolve$ = undefined;
1100
- }
1101
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1102
- nextTick(() => scheduleUpdate(hostRef, false));
1103
- }
1104
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1105
- }
1106
- // ( •_•)
1107
- // ( •_•)>⌐■-■
1108
- // (⌐■_■)
1109
- };
1110
- const forceUpdate = (ref) => {
1111
- {
1112
- const hostRef = getHostRef(ref);
1113
- const isConnected = hostRef.$hostElement$.isConnected;
1114
- if (isConnected &&
1115
- (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1116
- scheduleUpdate(hostRef, false);
1117
- }
1118
- // Returns "true" when the forced update was successfully scheduled
1119
- return isConnected;
1120
- }
1121
- };
1122
- const appDidLoad = (who) => {
1123
- // on appload
1124
- // we have finish the first big initial render
1125
- {
1126
- addHydratedFlag(doc.documentElement);
1127
- }
1128
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1129
- };
1130
- const safeCall = (instance, method, arg) => {
1131
- if (instance && instance[method]) {
1132
- try {
1133
- return instance[method](arg);
1134
- }
1135
- catch (e) {
1136
- consoleError(e);
1137
- }
1138
- }
1139
- return undefined;
1140
- };
1141
- const then = (promise, thenFn) => {
1142
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1143
- };
1144
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1145
- ;
1146
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1147
- const setValue = (ref, propName, newVal, cmpMeta) => {
1148
- // check our new property value against our internal value
1149
- const hostRef = getHostRef(ref);
1150
- const elm = hostRef.$hostElement$ ;
1151
- const oldVal = hostRef.$instanceValues$.get(propName);
1152
- const flags = hostRef.$flags$;
1153
- const instance = hostRef.$lazyInstance$ ;
1154
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1155
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1156
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1157
- const didValueChange = newVal !== oldVal && !areBothNaN;
1158
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1159
- // gadzooks! the property's value has changed!!
1160
- // set our new value!
1161
- hostRef.$instanceValues$.set(propName, newVal);
1162
- if (instance) {
1163
- // get an array of method names of watch functions to call
1164
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1165
- const watchMethods = cmpMeta.$watchers$[propName];
1166
- if (watchMethods) {
1167
- // this instance is watching for when this property changed
1168
- watchMethods.map((watchMethodName) => {
1169
- try {
1170
- // fire off each of the watch methods that are watching this property
1171
- instance[watchMethodName](newVal, oldVal, propName);
1172
- }
1173
- catch (e) {
1174
- consoleError(e, elm);
1175
- }
1176
- });
1177
- }
1178
- }
1179
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1180
- // looks like this value actually changed, so we've got work to do!
1181
- // but only if we've already rendered, otherwise just chill out
1182
- // queue that we need to do an update, but don't worry about queuing
1183
- // up millions cuz this function ensures it only runs once
1184
- scheduleUpdate(hostRef, false);
1185
- }
1186
- }
1187
- }
1188
- };
1189
- /**
1190
- * Attach a series of runtime constructs to a compiled Stencil component
1191
- * constructor, including getters and setters for the `@Prop` and `@State`
1192
- * decorators, callbacks for when attributes change, and so on.
1193
- *
1194
- * @param Cstr the constructor for a component that we need to process
1195
- * @param cmpMeta metadata collected previously about the component
1196
- * @param flags a number used to store a series of bit flags
1197
- * @returns a reference to the same constructor passed in (but now mutated)
1198
- */
1199
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1200
- if (cmpMeta.$members$) {
1201
- if (Cstr.watchers) {
1202
- cmpMeta.$watchers$ = Cstr.watchers;
1203
- }
1204
- // It's better to have a const than two Object.entries()
1205
- const members = Object.entries(cmpMeta.$members$);
1206
- const prototype = Cstr.prototype;
1207
- members.map(([memberName, [memberFlags]]) => {
1208
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1209
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1210
- // proxyComponent - prop
1211
- Object.defineProperty(prototype, memberName, {
1212
- get() {
1213
- // proxyComponent, get value
1214
- return getValue(this, memberName);
1215
- },
1216
- set(newValue) {
1217
- // proxyComponent, set value
1218
- setValue(this, memberName, newValue, cmpMeta);
1219
- },
1220
- configurable: true,
1221
- enumerable: true,
1222
- });
1223
- }
1224
- });
1225
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1226
- const attrNameToPropName = new Map();
1227
- prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1228
- plt.jmp(() => {
1229
- const propName = attrNameToPropName.get(attrName);
1230
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1231
- // in the case where an attribute was set inline.
1232
- // ```html
1233
- // <my-component some-attribute="some-value"></my-component>
1234
- // ```
1235
- //
1236
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1237
- // programmatically changes it before it has been upgraded as shown below:
1238
- //
1239
- // ```html
1240
- // <!-- this component has _not_ been upgraded yet -->
1241
- // <my-component id="test" some-attribute="some-value"></my-component>
1242
- // <script>
1243
- // // grab non-upgraded component
1244
- // el = document.querySelector("#test");
1245
- // el.someAttribute = "another-value";
1246
- // // upgrade component
1247
- // customElements.define('my-component', MyComponent);
1248
- // </script>
1249
- // ```
1250
- // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1251
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1252
- // to the value that was set inline i.e. "some-value" from above example. When
1253
- // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1254
- //
1255
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1256
- // by connectedCallback as this attributeChangedCallback will not fire.
1257
- //
1258
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1259
- //
1260
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1261
- // properties here given that this goes against best practices outlined here
1262
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1263
- if (this.hasOwnProperty(propName)) {
1264
- newValue = this[propName];
1265
- delete this[propName];
1266
- }
1267
- else if (prototype.hasOwnProperty(propName) &&
1268
- typeof this[propName] === 'number' &&
1269
- this[propName] == newValue) {
1270
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1271
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1272
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1273
- return;
1274
- }
1275
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1276
- });
1277
- };
1278
- // create an array of attributes to observe
1279
- // and also create a map of html attribute name to js property name
1280
- Cstr.observedAttributes = members
1281
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1282
- .map(([propName, m]) => {
1283
- const attrName = m[1] || propName;
1284
- attrNameToPropName.set(attrName, propName);
1285
- return attrName;
1286
- });
1287
- }
1288
- }
1289
- return Cstr;
1290
- };
1291
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1292
- // initializeComponent
1293
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1294
- {
1295
- // we haven't initialized this element yet
1296
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1297
- // lazy loaded components
1298
- // request the component's implementation to be
1299
- // wired up with the host element
1300
- Cstr = loadModule(cmpMeta);
1301
- if (Cstr.then) {
1302
- // Await creates a micro-task avoid if possible
1303
- const endLoad = uniqueTime();
1304
- Cstr = await Cstr;
1305
- endLoad();
1306
- }
1307
- if (!Cstr.isProxied) {
1308
- // we've never proxied this Constructor before
1309
- // let's add the getters/setters to its prototype before
1310
- // the first time we create an instance of the implementation
1311
- {
1312
- cmpMeta.$watchers$ = Cstr.watchers;
1313
- }
1314
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1315
- Cstr.isProxied = true;
1316
- }
1317
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1318
- // ok, time to construct the instance
1319
- // but let's keep track of when we start and stop
1320
- // so that the getters/setters don't incorrectly step on data
1321
- {
1322
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1323
- }
1324
- // construct the lazy-loaded component implementation
1325
- // passing the hostRef is very important during
1326
- // construction in order to directly wire together the
1327
- // host element and the lazy-loaded instance
1328
- try {
1329
- new Cstr(hostRef);
1330
- }
1331
- catch (e) {
1332
- consoleError(e);
1333
- }
1334
- {
1335
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1336
- }
1337
- {
1338
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1339
- }
1340
- endNewInstance();
1341
- }
1342
- if (Cstr.style) {
1343
- // this component has styles but we haven't registered them yet
1344
- let style = Cstr.style;
1345
- const scopeId = getScopeId(cmpMeta);
1346
- if (!styles.has(scopeId)) {
1347
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1348
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1349
- endRegisterStyles();
1350
- }
1351
- }
1352
- }
1353
- // we've successfully created a lazy instance
1354
- const ancestorComponent = hostRef.$ancestorComponent$;
1355
- const schedule = () => scheduleUpdate(hostRef, true);
1356
- if (ancestorComponent && ancestorComponent['s-rc']) {
1357
- // this is the initial load and this component it has an ancestor component
1358
- // but the ancestor component has NOT fired its will update lifecycle yet
1359
- // so let's just cool our jets and wait for the ancestor to continue first
1360
- // this will get fired off when the ancestor component
1361
- // finally gets around to rendering its lazy self
1362
- // fire off the initial update
1363
- ancestorComponent['s-rc'].push(schedule);
1364
- }
1365
- else {
1366
- schedule();
1367
- }
1368
- };
1369
- const connectedCallback = (elm) => {
1370
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1371
- const hostRef = getHostRef(elm);
1372
- const cmpMeta = hostRef.$cmpMeta$;
1373
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1374
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1375
- // first time this component has connected
1376
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1377
- {
1378
- // find the first ancestor component (if there is one) and register
1379
- // this component as one of the actively loading child components for its ancestor
1380
- let ancestorComponent = elm;
1381
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1382
- // climb up the ancestors looking for the first
1383
- // component that hasn't finished its lifecycle update yet
1384
- if (ancestorComponent['s-p']) {
1385
- // we found this components first ancestor component
1386
- // keep a reference to this component's ancestor component
1387
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1388
- break;
1389
- }
1390
- }
1391
- }
1392
- // Lazy properties
1393
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1394
- if (cmpMeta.$members$) {
1395
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1396
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1397
- const value = elm[memberName];
1398
- delete elm[memberName];
1399
- elm[memberName] = value;
1400
- }
1401
- });
1402
- }
1403
- {
1404
- initializeComponent(elm, hostRef, cmpMeta);
1405
- }
1406
- }
1407
- else {
1408
- // not the first time this has connected
1409
- // reattach any event listeners to the host
1410
- // since they would have been removed when disconnected
1411
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1412
- }
1413
- endConnected();
1414
- }
1415
- };
1416
- const disconnectedCallback = (elm) => {
1417
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1418
- const hostRef = getHostRef(elm);
1419
- const instance = hostRef.$lazyInstance$ ;
1420
- {
1421
- if (hostRef.$rmListeners$) {
1422
- hostRef.$rmListeners$.map((rmListener) => rmListener());
1423
- hostRef.$rmListeners$ = undefined;
1424
- }
1425
- }
1426
- {
1427
- safeCall(instance, 'disconnectedCallback');
1428
- }
1429
- }
1430
- };
1431
- const bootstrapLazy = (lazyBundles, options = {}) => {
1432
- var _a;
1433
- const endBootstrap = createTime();
1434
- const cmpTags = [];
1435
- const exclude = options.exclude || [];
1436
- const customElements = win.customElements;
1437
- const head = doc.head;
1438
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1439
- const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1440
- const deferredConnectedCallbacks = [];
1441
- let appLoadFallback;
1442
- let isBootstrapping = true;
1443
- Object.assign(plt, options);
1444
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1445
- lazyBundles.map((lazyBundle) => {
1446
- lazyBundle[1].map((compactMeta) => {
1447
- const cmpMeta = {
1448
- $flags$: compactMeta[0],
1449
- $tagName$: compactMeta[1],
1450
- $members$: compactMeta[2],
1451
- $listeners$: compactMeta[3],
1452
- };
1453
- {
1454
- cmpMeta.$members$ = compactMeta[2];
1455
- }
1456
- {
1457
- cmpMeta.$listeners$ = compactMeta[3];
1458
- }
1459
- {
1460
- cmpMeta.$watchers$ = {};
1461
- }
1462
- const tagName = cmpMeta.$tagName$;
1463
- const HostElement = class extends HTMLElement {
1464
- // StencilLazyHost
1465
- constructor(self) {
1466
- // @ts-ignore
1467
- super(self);
1468
- self = this;
1469
- registerHost(self, cmpMeta);
1470
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1471
- // this component is using shadow dom
1472
- // and this browser supports shadow dom
1473
- // add the read-only property "shadowRoot" to the host element
1474
- // adding the shadow root build conditionals to minimize runtime
1475
- {
1476
- {
1477
- self.attachShadow({ mode: 'open' });
1478
- }
1479
- }
1480
- }
1481
- }
1482
- connectedCallback() {
1483
- if (appLoadFallback) {
1484
- clearTimeout(appLoadFallback);
1485
- appLoadFallback = null;
1486
- }
1487
- if (isBootstrapping) {
1488
- // connectedCallback will be processed once all components have been registered
1489
- deferredConnectedCallbacks.push(this);
1490
- }
1491
- else {
1492
- plt.jmp(() => connectedCallback(this));
1493
- }
1494
- }
1495
- disconnectedCallback() {
1496
- plt.jmp(() => disconnectedCallback(this));
1497
- }
1498
- componentOnReady() {
1499
- return getHostRef(this).$onReadyPromise$;
1500
- }
1501
- };
1502
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1503
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1504
- cmpTags.push(tagName);
1505
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1506
- }
1507
- });
1508
- });
1509
- {
1510
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1511
- visibilityStyle.setAttribute('data-styles', '');
1512
- // Apply CSP nonce to the style tag if it exists
1513
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1514
- if (nonce != null) {
1515
- visibilityStyle.setAttribute('nonce', nonce);
1516
- }
1517
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1518
- }
1519
- // Process deferred connectedCallbacks now all components have been registered
1520
- isBootstrapping = false;
1521
- if (deferredConnectedCallbacks.length) {
1522
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
1523
- }
1524
- else {
1525
- {
1526
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1527
- }
1528
- }
1529
- // Fallback appLoad event
1530
- endBootstrap();
1531
- };
1532
- const Fragment = (_, children) => children;
1533
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1534
- if (listeners) {
1535
- listeners.map(([flags, name, method]) => {
1536
- const target = elm;
1537
- const handler = hostListenerProxy(hostRef, method);
1538
- const opts = hostListenerOpts(flags);
1539
- plt.ael(target, name, handler, opts);
1540
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1541
- });
1542
- }
1543
- };
1544
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
1545
- try {
1546
- {
1547
- if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1548
- // instance is ready, let's call it's member method for this event
1549
- hostRef.$lazyInstance$[methodName](ev);
1550
- }
1551
- else {
1552
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1553
- }
1554
- }
1555
- }
1556
- catch (e) {
1557
- consoleError(e);
1558
- }
1559
- };
1560
- // prettier-ignore
1561
- const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1562
- /**
1563
- * Assigns the given value to the nonce property on the runtime platform object.
1564
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1565
- * @param nonce The value to be assigned to the platform nonce property.
1566
- * @returns void
1567
- */
1568
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
1569
- const hostRefs = /*@__PURE__*/ new WeakMap();
1570
- const getHostRef = (ref) => hostRefs.get(ref);
1571
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1572
- const registerHost = (elm, cmpMeta) => {
1573
- const hostRef = {
1574
- $flags$: 0,
1575
- $hostElement$: elm,
1576
- $cmpMeta$: cmpMeta,
1577
- $instanceValues$: new Map(),
1578
- };
1579
- {
1580
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1581
- elm['s-p'] = [];
1582
- elm['s-rc'] = [];
1583
- }
1584
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1585
- return hostRefs.set(elm, hostRef);
1586
- };
1587
- const isMemberInElement = (elm, memberName) => memberName in elm;
1588
- const consoleError = (e, el) => (0, console.error)(e, el);
1589
- const cmpModules = /*@__PURE__*/ new Map();
1590
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1591
- // loadModuleImport
1592
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1593
- const bundleId = cmpMeta.$lazyBundleId$;
1594
- const module = cmpModules.get(bundleId) ;
1595
- if (module) {
1596
- return module[exportName];
1597
- }
1598
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1599
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1600
- /* @vite-ignore */
1601
- /* webpackInclude: /\.entry\.js$/ */
1602
- /* webpackExclude: /\.system\.entry\.js$/ */
1603
- /* webpackMode: "lazy" */
1604
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1605
- {
1606
- cmpModules.set(bundleId, importedModule);
1607
- }
1608
- return importedModule[exportName];
1609
- }, consoleError);
1610
- };
1611
- const styles = /*@__PURE__*/ new Map();
1612
- const win = typeof window !== 'undefined' ? window : {};
1613
- const doc = win.document || { head: {} };
1614
- const plt = {
1615
- $flags$: 0,
1616
- $resourcesUrl$: '',
1617
- jmp: (h) => h(),
1618
- raf: (h) => requestAnimationFrame(h),
1619
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1620
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1621
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
1622
- };
1623
- const promiseResolve = (v) => Promise.resolve(v);
1624
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1625
- try {
1626
- new CSSStyleSheet();
1627
- return typeof new CSSStyleSheet().replaceSync === 'function';
1628
- }
1629
- catch (e) { }
1630
- return false;
1631
- })()
1632
- ;
1633
- const queueDomReads = [];
1634
- const queueDomWrites = [];
1635
- const queueTask = (queue, write) => (cb) => {
1636
- queue.push(cb);
1637
- if (!queuePending) {
1638
- queuePending = true;
1639
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1640
- nextTick(flush);
1641
- }
1642
- else {
1643
- plt.raf(flush);
1644
- }
1645
- }
1646
- };
1647
- const consume = (queue) => {
1648
- for (let i = 0; i < queue.length; i++) {
1649
- try {
1650
- queue[i](performance.now());
1651
- }
1652
- catch (e) {
1653
- consoleError(e);
1654
- }
1655
- }
1656
- queue.length = 0;
1657
- };
1658
- const flush = () => {
1659
- // always force a bunch of medium callbacks to run, but still have
1660
- // a throttle on how many can run in a certain time
1661
- // DOM READS!!!
1662
- consume(queueDomReads);
1663
- // DOM WRITES!!!
1664
- {
1665
- consume(queueDomWrites);
1666
- if ((queuePending = queueDomReads.length > 0)) {
1667
- // still more to do yet, but we've run out of time
1668
- // let's let this thing cool off and try again in the next tick
1669
- plt.raf(flush);
1670
- }
1671
- }
1672
- };
1673
- const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1674
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1675
-
1676
- exports.Fragment = Fragment;
1677
- exports.bootstrapLazy = bootstrapLazy;
1678
- exports.forceUpdate = forceUpdate;
1679
- exports.getAssetPath = getAssetPath;
1680
- exports.getElement = getElement;
1681
- exports.getRenderingRef = getRenderingRef;
1682
- exports.h = h;
1683
- exports.promiseResolve = promiseResolve;
1684
- exports.registerInstance = registerInstance;
1685
- exports.setNonce = setNonce;
1686
-
1687
- //# sourceMappingURL=index-b83343b9.js.map