@sme.up/ketchup 6.5.0 → 6.7.0

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 (209) hide show
  1. package/README.md +7 -1
  2. package/dist/cjs/{f-button-4e2a0bb6.js → f-button-bf76ab95.js} +2 -2
  3. package/dist/cjs/{f-cell-1fc8a8b6.js → f-cell-b7a1524a.js} +25 -23
  4. package/dist/cjs/{f-checkbox-cd977193.js → f-checkbox-1097ca5d.js} +1 -1
  5. package/dist/cjs/{f-chip-7867f17b.js → f-chip-a5e100b1.js} +3 -3
  6. package/dist/cjs/{f-image-6b7a6168.js → f-image-d80a2749.js} +2 -2
  7. package/dist/cjs/{f-paginator-utils-b7712403.js → f-paginator-utils-c70812fe.js} +3 -5
  8. package/dist/cjs/{f-text-field-153e827c.js → f-text-field-48b8bb16.js} +2 -2
  9. package/dist/cjs/{index-31125378.js → index-ffdb46f6.js} +423 -252
  10. package/dist/cjs/ketchup.cjs.js +3 -3
  11. package/dist/cjs/kup-accordion.cjs.entry.js +3 -3
  12. package/dist/cjs/kup-autocomplete_25.cjs.entry.js +433 -163
  13. package/dist/cjs/kup-box.cjs.entry.js +27 -16
  14. package/dist/cjs/kup-calendar.cjs.entry.js +5 -5
  15. package/dist/cjs/kup-cell.cjs.entry.js +7 -7
  16. package/dist/cjs/kup-dash-list.cjs.entry.js +2 -2
  17. package/dist/cjs/kup-dash_2.cjs.entry.js +2 -2
  18. package/dist/cjs/kup-dashboard.cjs.entry.js +6 -6
  19. package/dist/cjs/kup-drawer.cjs.entry.js +2 -2
  20. package/dist/cjs/kup-echart.cjs.entry.js +2 -2
  21. package/dist/cjs/kup-family-tree.cjs.entry.js +19 -7
  22. package/dist/cjs/kup-form.cjs.entry.js +8 -8
  23. package/dist/cjs/kup-iframe.cjs.entry.js +2 -2
  24. package/dist/cjs/kup-image-list.cjs.entry.js +9 -9
  25. package/dist/cjs/kup-lazy.cjs.entry.js +2 -2
  26. package/dist/cjs/kup-magic-box.cjs.entry.js +3 -3
  27. package/dist/cjs/{kup-manager-cfe2f36e.js → kup-manager-0e38bf48.js} +39 -26
  28. package/dist/cjs/kup-nav-bar.cjs.entry.js +2 -2
  29. package/dist/cjs/kup-numeric-picker.cjs.entry.js +3 -3
  30. package/dist/cjs/kup-photo-frame.cjs.entry.js +2 -2
  31. package/dist/cjs/kup-probe.cjs.entry.js +2 -2
  32. package/dist/cjs/kup-qlik.cjs.entry.js +2 -2
  33. package/dist/cjs/kup-snackbar.cjs.entry.js +4 -4
  34. package/dist/cjs/loader.cjs.js +3 -3
  35. package/dist/collection/assets/box.js +9 -6
  36. package/dist/collection/assets/card.js +12 -2
  37. package/dist/collection/collection-manifest.json +3 -3
  38. package/dist/collection/components/kup-accordion/kup-accordion.js +239 -234
  39. package/dist/collection/components/kup-autocomplete/kup-autocomplete.js +545 -530
  40. package/dist/collection/components/kup-badge/kup-badge.js +176 -170
  41. package/dist/collection/components/kup-box/kup-box.js +907 -913
  42. package/dist/collection/components/kup-button/kup-button.css +1 -0
  43. package/dist/collection/components/kup-button/kup-button.js +379 -370
  44. package/dist/collection/components/kup-button-list/kup-button-list.js +251 -240
  45. package/dist/collection/components/kup-calendar/kup-calendar.js +301 -300
  46. package/dist/collection/components/kup-card/box/kup-card-box.js +115 -0
  47. package/dist/collection/components/kup-card/built-in/kup-card-calendar.js +14 -28
  48. package/dist/collection/components/kup-card/built-in/kup-card-clock.js +6 -19
  49. package/dist/collection/components/kup-card/built-in/kup-card-column-drop-menu.js +1 -2
  50. package/dist/collection/components/kup-card/built-in/kup-card-numeric.js +9 -44
  51. package/dist/collection/components/kup-card/collapsible/kup-card-collapsible.js +2 -21
  52. package/dist/collection/components/kup-card/dialog/kup-card-dialog.js +6 -33
  53. package/dist/collection/components/kup-card/kup-card-declarations.js +2 -0
  54. package/dist/collection/components/kup-card/kup-card-helper.js +3 -8
  55. package/dist/collection/components/kup-card/kup-card.css +140 -20
  56. package/dist/collection/components/kup-card/kup-card.js +352 -340
  57. package/dist/collection/components/kup-card/scalable/kup-card-scalable.js +68 -81
  58. package/dist/collection/components/kup-card/standard/kup-card-standard.js +96 -304
  59. package/dist/collection/components/kup-cell/kup-cell.js +221 -216
  60. package/dist/collection/components/kup-chart/kup-chart.js +547 -537
  61. package/dist/collection/components/kup-checkbox/kup-checkbox.js +275 -266
  62. package/dist/collection/components/kup-chip/kup-chip.js +240 -231
  63. package/dist/collection/components/kup-color-picker/kup-color-picker.js +274 -264
  64. package/dist/collection/components/kup-combobox/kup-combobox.js +458 -440
  65. package/dist/collection/components/kup-dash/kup-dash.js +110 -158
  66. package/dist/collection/components/kup-dash-list/kup-dash-list.js +210 -213
  67. package/dist/collection/components/kup-dashboard/kup-dashboard.js +196 -203
  68. package/dist/collection/components/kup-data-table/kup-data-table.js +1932 -1838
  69. package/dist/collection/components/kup-date-picker/kup-date-picker.js +408 -394
  70. package/dist/collection/components/kup-drawer/kup-drawer.js +244 -236
  71. package/dist/collection/components/kup-dropdown-button/kup-dropdown-button.js +474 -464
  72. package/dist/collection/components/kup-echart/kup-echart.js +436 -423
  73. package/dist/collection/components/kup-family-tree/kup-family-tree-declarations.js +1 -0
  74. package/dist/collection/components/kup-family-tree/kup-family-tree.js +420 -398
  75. package/dist/collection/components/kup-form/kup-form.js +223 -225
  76. package/dist/collection/components/kup-gauge/kup-gauge.js +445 -445
  77. package/dist/collection/components/kup-grid/kup-grid.js +156 -153
  78. package/dist/collection/components/kup-iframe/kup-iframe.js +181 -173
  79. package/dist/collection/components/kup-image/canvas/kup-image-canvas.js +9 -3
  80. package/dist/collection/components/kup-image/kup-image.js +300 -295
  81. package/dist/collection/components/kup-image-list/kup-image-list.js +292 -285
  82. package/dist/collection/components/kup-lazy/kup-lazy.js +253 -253
  83. package/dist/collection/components/kup-list/kup-list.js +541 -504
  84. package/dist/collection/components/kup-magic-box/kup-magic-box.js +145 -145
  85. package/dist/collection/components/kup-nav-bar/kup-nav-bar.js +190 -184
  86. package/dist/collection/components/kup-numeric-picker/kup-numeric-picker.js +490 -478
  87. package/dist/collection/components/kup-photo-frame/kup-photo-frame.js +254 -242
  88. package/dist/collection/components/kup-probe/kup-probe.js +87 -83
  89. package/dist/collection/components/kup-progress-bar/kup-progress-bar.js +237 -241
  90. package/dist/collection/components/kup-qlik/kup-qlik.js +178 -170
  91. package/dist/collection/components/kup-radio/kup-radio.js +258 -255
  92. package/dist/collection/components/kup-rating/kup-rating.js +208 -197
  93. package/dist/collection/components/kup-snackbar/kup-snackbar.js +249 -246
  94. package/dist/collection/components/kup-spinner/kup-spinner.js +274 -269
  95. package/dist/collection/components/kup-switch/kup-switch.js +255 -246
  96. package/dist/collection/components/kup-tab-bar/kup-tab-bar.js +265 -224
  97. package/dist/collection/components/kup-text-field/kup-text-field.js +814 -805
  98. package/dist/collection/components/kup-time-picker/kup-time-picker.js +464 -450
  99. package/dist/collection/components/kup-tree/kup-tree-declarations.js +0 -2
  100. package/dist/collection/components/kup-tree/kup-tree-faker.js +3 -2
  101. package/dist/collection/components/kup-tree/kup-tree.js +1134 -1133
  102. package/dist/collection/f-components/f-button/f-button.js +11 -20
  103. package/dist/collection/f-components/f-cell/f-cell.js +23 -23
  104. package/dist/collection/f-components/f-checkbox/f-checkbox.js +1 -9
  105. package/dist/collection/f-components/f-chip/f-chip.js +18 -31
  106. package/dist/collection/f-components/f-image/f-image.js +1 -3
  107. package/dist/collection/f-components/f-paginator/f-paginator.js +1 -6
  108. package/dist/collection/f-components/f-switch/f-switch.js +1 -8
  109. package/dist/collection/f-components/f-text-field/f-text-field.js +18 -40
  110. package/dist/collection/managers/kup-debug/kup-debug.js +10 -5
  111. package/dist/collection/managers/kup-scroll-on-hover/kup-scroll-on-hover.js +25 -10
  112. package/dist/collection/managers/kup-theme/kup-theme-declarations.js +1 -0
  113. package/dist/collection/managers/kup-toolbar/kup-toolbar.js +10 -5
  114. package/dist/collection/managers/kup-tooltip/kup-tooltip.js +10 -5
  115. package/dist/collection/utils/kup-column-menu/kup-column-menu.js +0 -21
  116. package/dist/esm/{f-button-a24e43dd.js → f-button-e79f7594.js} +2 -2
  117. package/dist/esm/{f-cell-ebbb0c06.js → f-cell-9400374e.js} +25 -23
  118. package/dist/esm/{f-checkbox-e06cf07b.js → f-checkbox-b721178e.js} +1 -1
  119. package/dist/esm/{f-chip-e2c38ba8.js → f-chip-bf740287.js} +3 -3
  120. package/dist/esm/{f-image-7e02e88f.js → f-image-ab3dc8cb.js} +2 -2
  121. package/dist/esm/{f-paginator-utils-e6d2638f.js → f-paginator-utils-6909e43b.js} +3 -5
  122. package/dist/esm/{f-text-field-8438a278.js → f-text-field-4841dfea.js} +2 -2
  123. package/dist/esm/{index-e41330a5.js → index-a2197376.js} +423 -252
  124. package/dist/esm/ketchup.js +3 -3
  125. package/dist/esm/kup-accordion.entry.js +3 -3
  126. package/dist/esm/kup-autocomplete_25.entry.js +433 -163
  127. package/dist/esm/kup-box.entry.js +27 -16
  128. package/dist/esm/kup-calendar.entry.js +5 -5
  129. package/dist/esm/kup-cell.entry.js +7 -7
  130. package/dist/esm/kup-dash-list.entry.js +2 -2
  131. package/dist/esm/kup-dash_2.entry.js +2 -2
  132. package/dist/esm/kup-dashboard.entry.js +6 -6
  133. package/dist/esm/kup-drawer.entry.js +2 -2
  134. package/dist/esm/kup-echart.entry.js +2 -2
  135. package/dist/esm/kup-family-tree.entry.js +19 -7
  136. package/dist/esm/kup-form.entry.js +8 -8
  137. package/dist/esm/kup-iframe.entry.js +2 -2
  138. package/dist/esm/kup-image-list.entry.js +9 -9
  139. package/dist/esm/kup-lazy.entry.js +2 -2
  140. package/dist/esm/kup-magic-box.entry.js +3 -3
  141. package/dist/esm/{kup-manager-7c27e90e.js → kup-manager-c54e6df5.js} +22 -9
  142. package/dist/esm/kup-nav-bar.entry.js +2 -2
  143. package/dist/esm/kup-numeric-picker.entry.js +3 -3
  144. package/dist/esm/kup-photo-frame.entry.js +2 -2
  145. package/dist/esm/kup-probe.entry.js +2 -2
  146. package/dist/esm/kup-qlik.entry.js +2 -2
  147. package/dist/esm/kup-snackbar.entry.js +4 -4
  148. package/dist/esm/loader.js +3 -3
  149. package/dist/esm/polyfills/css-shim.js +1 -1
  150. package/dist/ketchup/ketchup.esm.js +1 -1
  151. package/dist/ketchup/{p-191096ff.entry.js → p-182b869e.entry.js} +1 -1
  152. package/dist/ketchup/p-1dfd2a51.js +30 -0
  153. package/dist/ketchup/{p-b502b91b.entry.js → p-1f5c7f21.entry.js} +1 -1
  154. package/dist/ketchup/p-22ec1ba0.entry.js +9 -0
  155. package/dist/ketchup/{p-5552f156.js → p-23cd5a68.js} +1 -1
  156. package/dist/ketchup/{p-26acb448.js → p-25bf0cb6.js} +1 -1
  157. package/dist/ketchup/{p-601a50db.entry.js → p-260ff835.entry.js} +1 -1
  158. package/dist/ketchup/{p-5a703573.entry.js → p-2e184b57.entry.js} +1 -1
  159. package/dist/ketchup/{p-45415b72.entry.js → p-30a63b85.entry.js} +1 -1
  160. package/dist/ketchup/{p-cc663bad.entry.js → p-313e376b.entry.js} +1 -1
  161. package/dist/ketchup/{p-e0ed3fd7.entry.js → p-41620707.entry.js} +1 -1
  162. package/dist/ketchup/{p-25875aa1.entry.js → p-4a0ccf18.entry.js} +1 -1
  163. package/dist/ketchup/{p-3decc8e4.js → p-4f0d3062.js} +1 -1
  164. package/dist/ketchup/p-4fdb684f.js +2 -0
  165. package/dist/ketchup/{p-52590a90.entry.js → p-53d3ae80.entry.js} +1 -1
  166. package/dist/ketchup/{p-92595296.js → p-5bea2971.js} +1 -1
  167. package/dist/ketchup/{p-a782ebd1.entry.js → p-60fa0ccf.entry.js} +1 -1
  168. package/dist/ketchup/p-6333388c.js +1 -0
  169. package/dist/ketchup/{p-2003a841.entry.js → p-6bd57787.entry.js} +1 -1
  170. package/dist/ketchup/p-758d03f4.entry.js +1 -0
  171. package/dist/ketchup/{p-2f009c42.entry.js → p-7e7b6127.entry.js} +1 -1
  172. package/dist/ketchup/p-8386e3db.entry.js +1 -0
  173. package/dist/ketchup/{p-23111c8d.entry.js → p-859163c2.entry.js} +1 -1
  174. package/dist/ketchup/{p-97f28bbd.entry.js → p-8e1fa7a8.entry.js} +6 -6
  175. package/dist/ketchup/{p-ca98059c.entry.js → p-90860d9e.entry.js} +1 -1
  176. package/dist/ketchup/{p-b131b257.entry.js → p-b7fdc7aa.entry.js} +1 -1
  177. package/dist/ketchup/{p-3138cabb.entry.js → p-bffaef6e.entry.js} +1 -1
  178. package/dist/ketchup/p-c35c5e05.js +1 -0
  179. package/dist/ketchup/{p-1468bf09.js → p-e1d0ea71.js} +1 -1
  180. package/dist/ketchup/p-f9d5e553.entry.js +1 -0
  181. package/dist/ketchup/{p-69dd11da.entry.js → p-fb4d772a.entry.js} +1 -1
  182. package/dist/loader/package.json +1 -0
  183. package/dist/types/components/kup-box/kup-box-declarations.d.ts +3 -0
  184. package/dist/types/components/kup-card/box/kup-card-box.d.ts +26 -0
  185. package/dist/types/components/kup-card/kup-card-declarations.d.ts +2 -0
  186. package/dist/types/components/kup-card/scalable/kup-card-scalable.d.ts +6 -0
  187. package/dist/types/components/kup-card/standard/kup-card-standard.d.ts +0 -6
  188. package/dist/types/components/kup-combobox/kup-combobox-declarations.d.ts +3 -1
  189. package/dist/types/components/kup-data-table/kup-data-table.d.ts +15 -1
  190. package/dist/types/components/kup-family-tree/kup-family-tree-declarations.d.ts +1 -0
  191. package/dist/types/components/kup-family-tree/kup-family-tree.d.ts +5 -0
  192. package/dist/types/components/kup-list/kup-list.d.ts +5 -0
  193. package/dist/types/components/kup-tab-bar/kup-tab-bar.d.ts +5 -0
  194. package/dist/types/components/kup-tree/kup-tree-declarations.d.ts +0 -4
  195. package/dist/types/components/kup-tree/kup-tree.d.ts +18 -12
  196. package/dist/types/components.d.ts +43 -16
  197. package/dist/types/managers/kup-scroll-on-hover/kup-scroll-on-hover-declarations.d.ts +1 -0
  198. package/dist/types/managers/kup-scroll-on-hover/kup-scroll-on-hover.d.ts +2 -1
  199. package/dist/types/stencil-public-runtime.d.ts +15 -4
  200. package/package.json +3 -2
  201. package/CHANGELOG.md +0 -5
  202. package/dist/ketchup/p-753c82d8.js +0 -1
  203. package/dist/ketchup/p-77600efd.entry.js +0 -9
  204. package/dist/ketchup/p-88722265.js +0 -1
  205. package/dist/ketchup/p-9027e5ac.js +0 -30
  206. package/dist/ketchup/p-aa564df8.entry.js +0 -1
  207. package/dist/ketchup/p-b0b3989b.js +0 -2
  208. package/dist/ketchup/p-b238f9ea.entry.js +0 -1
  209. package/dist/ketchup/p-b4f85d34.entry.js +0 -1
@@ -1,66 +1,22 @@
1
1
  const NAMESPACE = 'ketchup';
2
2
 
3
+ /**
4
+ * Virtual DOM patching algorithm based on Snabbdom by
5
+ * Simon Friis Vindum (@paldepind)
6
+ * Licensed under the MIT License
7
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
8
+ *
9
+ * Modified for Stencil's renderer and slot projection
10
+ */
3
11
  let scopeId;
4
12
  let hostTagName;
5
13
  let isSvgMode = false;
6
14
  let queuePending = false;
7
- const win = typeof window !== 'undefined' ? window : {};
8
- const doc = win.document || { head: {} };
9
- const plt = {
10
- $flags$: 0,
11
- $resourcesUrl$: '',
12
- jmp: (h) => h(),
13
- raf: (h) => requestAnimationFrame(h),
14
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
15
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
16
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
17
- };
18
- const promiseResolve = (v) => Promise.resolve(v);
19
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
20
- try {
21
- new CSSStyleSheet();
22
- return typeof new CSSStyleSheet().replaceSync === 'function';
23
- }
24
- catch (e) { }
25
- return false;
26
- })()
27
- ;
28
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
29
- if (listeners) {
30
- listeners.map(([flags, name, method]) => {
31
- const target = getHostListenerTarget(elm, flags) ;
32
- const handler = hostListenerProxy(hostRef, method);
33
- const opts = hostListenerOpts(flags);
34
- plt.ael(target, name, handler, opts);
35
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
36
- });
37
- }
38
- };
39
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
40
- try {
41
- {
42
- if (hostRef.$flags$ & 256 /* isListenReady */) {
43
- // instance is ready, let's call it's member method for this event
44
- hostRef.$lazyInstance$[methodName](ev);
45
- }
46
- else {
47
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
48
- }
49
- }
50
- }
51
- catch (e) {
52
- consoleError(e);
53
- }
54
- };
55
- const getHostListenerTarget = (elm, flags) => {
56
- if (flags & 4 /* TargetDocument */)
57
- return doc;
58
- return elm;
15
+ const getAssetPath = (path) => {
16
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
17
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
59
18
  };
60
- // prettier-ignore
61
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
62
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
63
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
19
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
64
20
  const createTime = (fnName, tagName = '') => {
65
21
  {
66
22
  return () => {
@@ -75,76 +31,8 @@ const uniqueTime = (key, measureText) => {
75
31
  };
76
32
  }
77
33
  };
78
- const rootAppliedStyles = new WeakMap();
79
- const registerStyle = (scopeId, cssText, allowCS) => {
80
- let style = styles.get(scopeId);
81
- if (supportsConstructableStylesheets && allowCS) {
82
- style = (style || new CSSStyleSheet());
83
- if (typeof style === 'string') {
84
- style = cssText;
85
- }
86
- else {
87
- style.replaceSync(cssText);
88
- }
89
- }
90
- else {
91
- style = cssText;
92
- }
93
- styles.set(scopeId, style);
94
- };
95
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
96
- let scopeId = getScopeId(cmpMeta);
97
- const style = styles.get(scopeId);
98
- // if an element is NOT connected then getRootNode() will return the wrong root node
99
- // so the fallback is to always use the document for the root node in those cases
100
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
101
- if (style) {
102
- if (typeof style === 'string') {
103
- styleContainerNode = styleContainerNode.head || styleContainerNode;
104
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
105
- let styleElm;
106
- if (!appliedStyles) {
107
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
108
- }
109
- if (!appliedStyles.has(scopeId)) {
110
- {
111
- {
112
- styleElm = doc.createElement('style');
113
- styleElm.innerHTML = style;
114
- }
115
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
116
- }
117
- if (appliedStyles) {
118
- appliedStyles.add(scopeId);
119
- }
120
- }
121
- }
122
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
123
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
124
- }
125
- }
126
- return scopeId;
127
- };
128
- const attachStyles = (hostRef) => {
129
- const cmpMeta = hostRef.$cmpMeta$;
130
- const elm = hostRef.$hostElement$;
131
- const flags = cmpMeta.$flags$;
132
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
133
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
134
- if (flags & 10 /* needsScopedEncapsulation */) {
135
- // only required when we're NOT using native shadow dom (slot)
136
- // or this browser doesn't support native shadow dom
137
- // and this host element was NOT created with SSR
138
- // let's pick out the inner content for slot projection
139
- // create a node to represent where the original
140
- // content was first placed, which is useful later on
141
- // DOM WRITE!!
142
- elm['s-sc'] = scopeId;
143
- elm.classList.add(scopeId + '-h');
144
- }
145
- endAttachStyles();
146
- };
147
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
34
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
35
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
148
36
  /**
149
37
  * Default style mode id
150
38
  */
@@ -283,6 +171,149 @@ const convertToPrivate = (node) => {
283
171
  vnode.$name$ = node.vname;
284
172
  return vnode;
285
173
  };
174
+ /**
175
+ * Parse a new property value for a given property type.
176
+ *
177
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
178
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
179
+ * 1. `any`, the type given to `propValue` in the function signature
180
+ * 2. the type stored from `propType`.
181
+ *
182
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
183
+ *
184
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
185
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
186
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
187
+ * ```tsx
188
+ * <my-cmp prop-val={0}></my-cmp>
189
+ * ```
190
+ *
191
+ * HTML prop values on the other hand, will always a string
192
+ *
193
+ * @param propValue the new value to coerce to some type
194
+ * @param propType the type of the prop, expressed as a binary number
195
+ * @returns the parsed/coerced value
196
+ */
197
+ const parsePropertyValue = (propValue, propType) => {
198
+ // ensure this value is of the correct prop type
199
+ if (propValue != null && !isComplexType(propValue)) {
200
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
201
+ // per the HTML spec, any string value means it is a boolean true value
202
+ // but we'll cheat here and say that the string "false" is the boolean false
203
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
204
+ }
205
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
206
+ // force it to be a number
207
+ return parseFloat(propValue);
208
+ }
209
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
210
+ // could have been passed as a number or boolean
211
+ // but we still want it as a string
212
+ return String(propValue);
213
+ }
214
+ // redundant return here for better minification
215
+ return propValue;
216
+ }
217
+ // not sure exactly what type we want
218
+ // so no need to change to a different type
219
+ return propValue;
220
+ };
221
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
222
+ const createEvent = (ref, name, flags) => {
223
+ const elm = getElement(ref);
224
+ return {
225
+ emit: (detail) => {
226
+ return emitEvent(elm, name, {
227
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
228
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
229
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
230
+ detail,
231
+ });
232
+ },
233
+ };
234
+ };
235
+ /**
236
+ * Helper function to create & dispatch a custom Event on a provided target
237
+ * @param elm the target of the Event
238
+ * @param name the name to give the custom Event
239
+ * @param opts options for configuring a custom Event
240
+ * @returns the custom Event
241
+ */
242
+ const emitEvent = (elm, name, opts) => {
243
+ const ev = plt.ce(name, opts);
244
+ elm.dispatchEvent(ev);
245
+ return ev;
246
+ };
247
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
248
+ const registerStyle = (scopeId, cssText, allowCS) => {
249
+ let style = styles.get(scopeId);
250
+ if (supportsConstructableStylesheets && allowCS) {
251
+ style = (style || new CSSStyleSheet());
252
+ if (typeof style === 'string') {
253
+ style = cssText;
254
+ }
255
+ else {
256
+ style.replaceSync(cssText);
257
+ }
258
+ }
259
+ else {
260
+ style = cssText;
261
+ }
262
+ styles.set(scopeId, style);
263
+ };
264
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
265
+ let scopeId = getScopeId(cmpMeta);
266
+ const style = styles.get(scopeId);
267
+ // if an element is NOT connected then getRootNode() will return the wrong root node
268
+ // so the fallback is to always use the document for the root node in those cases
269
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
270
+ if (style) {
271
+ if (typeof style === 'string') {
272
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
273
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
274
+ let styleElm;
275
+ if (!appliedStyles) {
276
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
277
+ }
278
+ if (!appliedStyles.has(scopeId)) {
279
+ {
280
+ {
281
+ styleElm = doc.createElement('style');
282
+ styleElm.innerHTML = style;
283
+ }
284
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
285
+ }
286
+ if (appliedStyles) {
287
+ appliedStyles.add(scopeId);
288
+ }
289
+ }
290
+ }
291
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
292
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
293
+ }
294
+ }
295
+ return scopeId;
296
+ };
297
+ const attachStyles = (hostRef) => {
298
+ const cmpMeta = hostRef.$cmpMeta$;
299
+ const elm = hostRef.$hostElement$;
300
+ const flags = cmpMeta.$flags$;
301
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
302
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
303
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
304
+ // only required when we're NOT using native shadow dom (slot)
305
+ // or this browser doesn't support native shadow dom
306
+ // and this host element was NOT created with SSR
307
+ // let's pick out the inner content for slot projection
308
+ // create a node to represent where the original
309
+ // content was first placed, which is useful later on
310
+ // DOM WRITE!!
311
+ elm['s-sc'] = scopeId;
312
+ elm.classList.add(scopeId + '-h');
313
+ }
314
+ endAttachStyles();
315
+ };
316
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
286
317
  /**
287
318
  * Production setAccessor() function based on Preact by
288
319
  * Jason Miller (@developit)
@@ -419,7 +450,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
419
450
  }
420
451
  }
421
452
  }
422
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
453
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
423
454
  newValue = newValue === true ? '' : newValue;
424
455
  if (xlink) {
425
456
  elm.setAttributeNS(XLINK_NS, memberName, newValue);
@@ -437,7 +468,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
437
468
  // if the element passed in is a shadow root, which is a document fragment
438
469
  // then we want to be adding attrs/props to the shadow root's "host" element
439
470
  // if it's not a shadow root, then we add attrs/props to the same element
440
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
471
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
441
472
  ? newVnode.$elm$.host
442
473
  : newVnode.$elm$;
443
474
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -455,6 +486,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
455
486
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
456
487
  }
457
488
  };
489
+ /**
490
+ * Create a DOM Node corresponding to one of the children of a given VNode.
491
+ *
492
+ * @param oldParentVNode the parent VNode from the previous render
493
+ * @param newParentVNode the parent VNode from the current render
494
+ * @param childIndex the index of the VNode, in the _new_ parent node's
495
+ * children, for which we will create a new DOM node
496
+ * @param parentElm the parent DOM node which our new node will be a child of
497
+ * @returns the newly created node
498
+ */
458
499
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
459
500
  // tslint:disable-next-line: prefer-const
460
501
  const newVNode = newParentVNode.$children$[childIndex];
@@ -534,6 +575,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
534
575
  }
535
576
  }
536
577
  };
578
+ /**
579
+ * Reconcile the children of a new VNode with the children of an old VNode by
580
+ * traversing the two collections of children, identifying nodes that are
581
+ * conserved or changed, calling out to `patch` to make any necessary
582
+ * updates to the DOM, and rearranging DOM nodes as needed.
583
+ *
584
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
585
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
586
+ * 'windows' by storing start and end indices and references to the
587
+ * corresponding array entries. Initially the two 'windows' are basically equal
588
+ * to the entire array, but we progressively narrow the windows until there are
589
+ * no children left to update by doing the following:
590
+ *
591
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
592
+ * that if we have an initial array like the following we'll end up dealing
593
+ * only with a window bounded by the highlighted elements:
594
+ *
595
+ * [null, null, VNode1 , ... , VNode2, null, null]
596
+ * ^^^^^^ ^^^^^^
597
+ *
598
+ * 2. Check to see if the elements at the head and tail positions are equal
599
+ * across the windows. This will basically detect elements which haven't
600
+ * been added, removed, or changed position, i.e. if you had the following
601
+ * VNode elements (represented as HTML):
602
+ *
603
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
604
+ * newVNode: `<div><p><span>THERE</span></p></div>`
605
+ *
606
+ * Then when comparing the children of the `<div>` tag we check the equality
607
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
608
+ * same tag in the same position, we'd be able to avoid completely
609
+ * re-rendering the subtree under them with a new DOM element and would just
610
+ * call out to `patch` to handle reconciling their children and so on.
611
+ *
612
+ * 3. Check, for both windows, to see if the element at the beginning of the
613
+ * window corresponds to the element at the end of the other window. This is
614
+ * a heuristic which will let us identify _some_ situations in which
615
+ * elements have changed position, for instance it _should_ detect that the
616
+ * children nodes themselves have not changed but merely moved in the
617
+ * following example:
618
+ *
619
+ * oldVNode: `<div><element-one /><element-two /></div>`
620
+ * newVNode: `<div><element-two /><element-one /></div>`
621
+ *
622
+ * If we find cases like this then we also need to move the concrete DOM
623
+ * elements corresponding to the moved children to write the re-order to the
624
+ * DOM.
625
+ *
626
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
627
+ * nodes in the old children which have the same key as the first element in
628
+ * our window on the new children. If we find such a node we handle calling
629
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
630
+ * what we find.
631
+ *
632
+ * Finally, once we've narrowed our 'windows' to the point that either of them
633
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
634
+ * insertion or deletion that needs to happen to get a DOM state that correctly
635
+ * reflects the new child VNodes. If, for instance, after our window on the old
636
+ * children has collapsed we still have more nodes on the new children that
637
+ * we haven't dealt with yet then we need to add them, or if the new children
638
+ * collapse but we still have unhandled _old_ children then we need to make
639
+ * sure the corresponding DOM nodes are removed.
640
+ *
641
+ * @param parentElm the node into which the parent VNode is rendered
642
+ * @param oldCh the old children of the parent node
643
+ * @param newVNode the new VNode which will replace the parent
644
+ * @param newCh the new children of the parent node
645
+ */
537
646
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
538
647
  let oldStartIdx = 0;
539
648
  let newStartIdx = 0;
@@ -549,7 +658,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
549
658
  let elmToMove;
550
659
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
551
660
  if (oldStartVnode == null) {
552
- // Vnode might have been moved left
661
+ // VNode might have been moved left
553
662
  oldStartVnode = oldCh[++oldStartIdx];
554
663
  }
555
664
  else if (oldEndVnode == null) {
@@ -562,29 +671,65 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
562
671
  newEndVnode = newCh[--newEndIdx];
563
672
  }
564
673
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
674
+ // if the start nodes are the same then we should patch the new VNode
675
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
676
+ // indices to reflect that. We don't need to move any DOM Nodes around
677
+ // since things are matched up in order.
565
678
  patch(oldStartVnode, newStartVnode);
566
679
  oldStartVnode = oldCh[++oldStartIdx];
567
680
  newStartVnode = newCh[++newStartIdx];
568
681
  }
569
682
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
683
+ // likewise, if the end nodes are the same we patch new onto old and
684
+ // decrement our end indices, and also likewise in this case we don't
685
+ // need to move any DOM Nodes.
570
686
  patch(oldEndVnode, newEndVnode);
571
687
  oldEndVnode = oldCh[--oldEndIdx];
572
688
  newEndVnode = newCh[--newEndIdx];
573
689
  }
574
690
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
575
691
  patch(oldStartVnode, newEndVnode);
692
+ // We need to move the element for `oldStartVnode` into a position which
693
+ // will be appropriate for `newEndVnode`. For this we can use
694
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
695
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
696
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
697
+ //
698
+ // <old-start-node />
699
+ // <some-intervening-node />
700
+ // <old-end-node />
701
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
702
+ // <next-sibling />
703
+ //
704
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
705
+ // the node for `oldStartVnode` at the end of the children of
706
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
707
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
708
+ // append it to the children of the parent element.
576
709
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
577
710
  oldStartVnode = oldCh[++oldStartIdx];
578
711
  newEndVnode = newCh[--newEndIdx];
579
712
  }
580
713
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
581
714
  patch(oldEndVnode, newStartVnode);
715
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
716
+ // the same node, so since we're here we know that they are not. Thus we
717
+ // can move the element for `oldEndVnode` _before_ the element for
718
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
719
+ // future.
582
720
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
583
721
  oldEndVnode = oldCh[--oldEndIdx];
584
722
  newStartVnode = newCh[++newStartIdx];
585
723
  }
586
724
  else {
587
- // createKeyToOldIdx
725
+ // Here we do some checks to match up old and new nodes based on the
726
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
727
+ // in the JSX for a DOM element in the implementation of a Stencil
728
+ // component.
729
+ //
730
+ // First we check to see if there are any nodes in the array of old
731
+ // children which have the same key as the first node in the new
732
+ // children.
588
733
  idxInOld = -1;
589
734
  {
590
735
  for (i = oldStartIdx; i <= oldEndIdx; ++i) {
@@ -595,23 +740,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
595
740
  }
596
741
  }
597
742
  if (idxInOld >= 0) {
743
+ // We found a node in the old children which matches up with the first
744
+ // node in the new children! So let's deal with that
598
745
  elmToMove = oldCh[idxInOld];
599
746
  if (elmToMove.$tag$ !== newStartVnode.$tag$) {
747
+ // the tag doesn't match so we'll need a new DOM element
600
748
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
601
749
  }
602
750
  else {
603
751
  patch(elmToMove, newStartVnode);
752
+ // invalidate the matching old node so that we won't try to update it
753
+ // again later on
604
754
  oldCh[idxInOld] = undefined;
605
755
  node = elmToMove.$elm$;
606
756
  }
607
757
  newStartVnode = newCh[++newStartIdx];
608
758
  }
609
759
  else {
610
- // new element
760
+ // We either didn't find an element in the old children that matches
761
+ // the key of the first new child OR the build is not using `key`
762
+ // attributes at all. In either case we need to create a new element
763
+ // for the new node.
611
764
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
612
765
  newStartVnode = newCh[++newStartIdx];
613
766
  }
614
767
  if (node) {
768
+ // if we created a new node then handle inserting it to the DOM
615
769
  {
616
770
  oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
617
771
  }
@@ -619,22 +773,52 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
619
773
  }
620
774
  }
621
775
  if (oldStartIdx > oldEndIdx) {
776
+ // we have some more new nodes to add which don't match up with old nodes
622
777
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
623
778
  }
624
779
  else if (newStartIdx > newEndIdx) {
780
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
781
+ // in the new array, so lets remove them (which entails cleaning up the
782
+ // relevant DOM nodes)
625
783
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
626
784
  }
627
785
  };
628
- const isSameVnode = (vnode1, vnode2) => {
786
+ /**
787
+ * Compare two VNodes to determine if they are the same
788
+ *
789
+ * **NB**: This function is an equality _heuristic_ based on the available
790
+ * information set on the two VNodes and can be misleading under certain
791
+ * circumstances. In particular, if the two nodes do not have `key` attrs
792
+ * (available under `$key$` on VNodes) then the function falls back on merely
793
+ * checking that they have the same tag.
794
+ *
795
+ * So, in other words, if `key` attrs are not set on VNodes which may be
796
+ * changing order within a `children` array or something along those lines then
797
+ * we could obtain a false positive and then have to do needless re-rendering.
798
+ *
799
+ * @param leftVNode the first VNode to check
800
+ * @param rightVNode the second VNode to check
801
+ * @returns whether they're equal or not
802
+ */
803
+ const isSameVnode = (leftVNode, rightVNode) => {
629
804
  // compare if two vnode to see if they're "technically" the same
630
805
  // need to have the same element tag, and same key to be the same
631
- if (vnode1.$tag$ === vnode2.$tag$) {
806
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
807
+ // this will be set if components in the build have `key` attrs set on them
632
808
  {
633
- return vnode1.$key$ === vnode2.$key$;
809
+ return leftVNode.$key$ === rightVNode.$key$;
634
810
  }
635
811
  }
636
812
  return false;
637
813
  };
814
+ /**
815
+ * Handle reconciling an outdated VNode with a new one which corresponds to
816
+ * it. This function handles flushing updates to the DOM and reconciling the
817
+ * children of the two nodes (if any).
818
+ *
819
+ * @param oldVNode an old VNode whose DOM element and children we want to update
820
+ * @param newVNode a new VNode representing an updated version of the old one
821
+ */
638
822
  const patch = (oldVNode, newVNode) => {
639
823
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
640
824
  const oldChildren = oldVNode.$children$;
@@ -647,7 +831,6 @@ const patch = (oldVNode, newVNode) => {
647
831
  // only add this to the when the compiler sees we're using an svg somewhere
648
832
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
649
833
  }
650
- // element node
651
834
  {
652
835
  if (tag === 'slot')
653
836
  ;
@@ -660,6 +843,7 @@ const patch = (oldVNode, newVNode) => {
660
843
  }
661
844
  if (oldChildren !== null && newChildren !== null) {
662
845
  // looks like there's child vnodes for both the old and new vnodes
846
+ // so we need to call `updateChildren` to reconcile them
663
847
  updateChildren(elm, oldChildren, newVNode, newChildren);
664
848
  }
665
849
  else if (newChildren !== null) {
@@ -702,7 +886,7 @@ const renderVdom = (hostRef, renderFnResults) => {
702
886
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
703
887
  }
704
888
  rootVnode.$tag$ = null;
705
- rootVnode.$flags$ |= 4 /* isHost */;
889
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
706
890
  hostRef.$vnode$ = rootVnode;
707
891
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
708
892
  {
@@ -711,32 +895,6 @@ const renderVdom = (hostRef, renderFnResults) => {
711
895
  // synchronous patch
712
896
  patch(oldVNode, rootVnode);
713
897
  };
714
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
715
- const createEvent = (ref, name, flags) => {
716
- const elm = getElement(ref);
717
- return {
718
- emit: (detail) => {
719
- return emitEvent(elm, name, {
720
- bubbles: !!(flags & 4 /* Bubbles */),
721
- composed: !!(flags & 2 /* Composed */),
722
- cancelable: !!(flags & 1 /* Cancellable */),
723
- detail,
724
- });
725
- },
726
- };
727
- };
728
- /**
729
- * Helper function to create & dispatch a custom Event on a provided target
730
- * @param elm the target of the Event
731
- * @param name the name to give the custom Event
732
- * @param opts options for configuring a custom Event
733
- * @returns the custom Event
734
- */
735
- const emitEvent = (elm, name, opts) => {
736
- const ev = plt.ce(name, opts);
737
- elm.dispatchEvent(ev);
738
- return ev;
739
- };
740
898
  const attachToAncestor = (hostRef, ancestorComponent) => {
741
899
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
742
900
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -744,10 +902,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
744
902
  };
745
903
  const scheduleUpdate = (hostRef, isInitialLoad) => {
746
904
  {
747
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
905
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
748
906
  }
749
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
750
- hostRef.$flags$ |= 512 /* needsRerender */;
907
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
908
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
751
909
  return;
752
910
  }
753
911
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -763,7 +921,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
763
921
  let promise;
764
922
  if (isInitialLoad) {
765
923
  {
766
- hostRef.$flags$ |= 256 /* isListenReady */;
924
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
767
925
  if (hostRef.$queuedListeners$) {
768
926
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
769
927
  hostRef.$queuedListeners$ = null;
@@ -814,7 +972,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
814
972
  }
815
973
  else {
816
974
  Promise.all(childrenPromises).then(postUpdate);
817
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
975
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
818
976
  childrenPromises.length = 0;
819
977
  }
820
978
  }
@@ -823,10 +981,10 @@ const callRender = (hostRef, instance, elm) => {
823
981
  try {
824
982
  instance = instance.render() ;
825
983
  {
826
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
984
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
827
985
  }
828
986
  {
829
- hostRef.$flags$ |= 2 /* hasRendered */;
987
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
830
988
  }
831
989
  {
832
990
  {
@@ -853,8 +1011,8 @@ const postUpdateComponent = (hostRef) => {
853
1011
  {
854
1012
  safeCall(instance, 'componentDidRender');
855
1013
  }
856
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
857
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1014
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1015
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
858
1016
  {
859
1017
  // DOM WRITE!
860
1018
  addHydratedFlag(elm);
@@ -886,10 +1044,10 @@ const postUpdateComponent = (hostRef) => {
886
1044
  hostRef.$onRenderResolve$();
887
1045
  hostRef.$onRenderResolve$ = undefined;
888
1046
  }
889
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1047
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
890
1048
  nextTick(() => scheduleUpdate(hostRef, false));
891
1049
  }
892
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1050
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
893
1051
  }
894
1052
  // ( •_•)
895
1053
  // ( •_•)>⌐■-■
@@ -900,7 +1058,7 @@ const forceUpdate = (ref) => {
900
1058
  const hostRef = getHostRef(ref);
901
1059
  const isConnected = hostRef.$hostElement$.isConnected;
902
1060
  if (isConnected &&
903
- (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1061
+ (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
904
1062
  scheduleUpdate(hostRef, false);
905
1063
  }
906
1064
  // Returns "true" when the forced update was successfully scheduled
@@ -931,53 +1089,6 @@ const then = (promise, thenFn) => {
931
1089
  };
932
1090
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
933
1091
  ;
934
- /**
935
- * Parse a new property value for a given property type.
936
- *
937
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
938
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
939
- * 1. `any`, the type given to `propValue` in the function signature
940
- * 2. the type stored from `propType`.
941
- *
942
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
943
- *
944
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
945
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
946
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
947
- * ```tsx
948
- * <my-cmp prop-val={0}></my-cmp>
949
- * ```
950
- *
951
- * HTML prop values on the other hand, will always a string
952
- *
953
- * @param propValue the new value to coerce to some type
954
- * @param propType the type of the prop, expressed as a binary number
955
- * @returns the parsed/coerced value
956
- */
957
- const parsePropertyValue = (propValue, propType) => {
958
- // ensure this value is of the correct prop type
959
- if (propValue != null && !isComplexType(propValue)) {
960
- if (propType & 4 /* Boolean */) {
961
- // per the HTML spec, any string value means it is a boolean true value
962
- // but we'll cheat here and say that the string "false" is the boolean false
963
- return propValue === 'false' ? false : propValue === '' || !!propValue;
964
- }
965
- if (propType & 2 /* Number */) {
966
- // force it to be a number
967
- return parseFloat(propValue);
968
- }
969
- if (propType & 1 /* String */) {
970
- // could have been passed as a number or boolean
971
- // but we still want it as a string
972
- return String(propValue);
973
- }
974
- // redundant return here for better minification
975
- return propValue;
976
- }
977
- // not sure exactly what type we want
978
- // so no need to change to a different type
979
- return propValue;
980
- };
981
1092
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
982
1093
  const setValue = (ref, propName, newVal, cmpMeta) => {
983
1094
  // check our new property value against our internal value
@@ -990,13 +1101,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
990
1101
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
991
1102
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
992
1103
  const didValueChange = newVal !== oldVal && !areBothNaN;
993
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1104
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
994
1105
  // gadzooks! the property's value has changed!!
995
1106
  // set our new value!
996
1107
  hostRef.$instanceValues$.set(propName, newVal);
997
1108
  if (instance) {
998
1109
  // get an array of method names of watch functions to call
999
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1110
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1000
1111
  const watchMethods = cmpMeta.$watchers$[propName];
1001
1112
  if (watchMethods) {
1002
1113
  // this instance is watching for when this property changed
@@ -1011,7 +1122,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1011
1122
  });
1012
1123
  }
1013
1124
  }
1014
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1125
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1015
1126
  // looks like this value actually changed, so we've got work to do!
1016
1127
  // but only if we've already rendered, otherwise just chill out
1017
1128
  // queue that we need to do an update, but don't worry about queuing
@@ -1021,6 +1132,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
1021
1132
  }
1022
1133
  }
1023
1134
  };
1135
+ /**
1136
+ * Attach a series of runtime constructs to a compiled Stencil component
1137
+ * constructor, including getters and setters for the `@Prop` and `@State`
1138
+ * decorators, callbacks for when attributes change, and so on.
1139
+ *
1140
+ * @param Cstr the constructor for a component that we need to process
1141
+ * @param cmpMeta metadata collected previously about the component
1142
+ * @param flags a number used to store a series of bit flags
1143
+ * @returns a reference to the same constructor passed in (but now mutated)
1144
+ */
1024
1145
  const proxyComponent = (Cstr, cmpMeta, flags) => {
1025
1146
  if (cmpMeta.$members$) {
1026
1147
  if (Cstr.watchers) {
@@ -1030,8 +1151,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1030
1151
  const members = Object.entries(cmpMeta.$members$);
1031
1152
  const prototype = Cstr.prototype;
1032
1153
  members.map(([memberName, [memberFlags]]) => {
1033
- if ((memberFlags & 31 /* Prop */ ||
1034
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1154
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1155
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1035
1156
  // proxyComponent - prop
1036
1157
  Object.defineProperty(prototype, memberName, {
1037
1158
  get() {
@@ -1046,8 +1167,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1046
1167
  enumerable: true,
1047
1168
  });
1048
1169
  }
1049
- else if (flags & 1 /* isElementConstructor */ &&
1050
- memberFlags & 64 /* Method */) {
1170
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1171
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1051
1172
  // proxyComponent - method
1052
1173
  Object.defineProperty(prototype, memberName, {
1053
1174
  value(...args) {
@@ -1057,7 +1178,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1057
1178
  });
1058
1179
  }
1059
1180
  });
1060
- if ((flags & 1 /* isElementConstructor */)) {
1181
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1061
1182
  const attrNameToPropName = new Map();
1062
1183
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1063
1184
  plt.jmp(() => {
@@ -1113,11 +1234,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1113
1234
  // create an array of attributes to observe
1114
1235
  // and also create a map of html attribute name to js property name
1115
1236
  Cstr.observedAttributes = members
1116
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1237
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1117
1238
  .map(([propName, m]) => {
1118
1239
  const attrName = m[1] || propName;
1119
1240
  attrNameToPropName.set(attrName, propName);
1120
- if (m[0] & 512 /* ReflectAttr */) {
1241
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1121
1242
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1122
1243
  }
1123
1244
  return attrName;
@@ -1128,10 +1249,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1128
1249
  };
1129
1250
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1130
1251
  // initializeComponent
1131
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1252
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1132
1253
  {
1133
1254
  // we haven't initialized this element yet
1134
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1255
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1135
1256
  // lazy loaded components
1136
1257
  // request the component's implementation to be
1137
1258
  // wired up with the host element
@@ -1149,7 +1270,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1149
1270
  {
1150
1271
  cmpMeta.$watchers$ = Cstr.watchers;
1151
1272
  }
1152
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1273
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1153
1274
  Cstr.isProxied = true;
1154
1275
  }
1155
1276
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -1157,7 +1278,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1157
1278
  // but let's keep track of when we start and stop
1158
1279
  // so that the getters/setters don't incorrectly step on data
1159
1280
  {
1160
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1281
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1161
1282
  }
1162
1283
  // construct the lazy-loaded component implementation
1163
1284
  // passing the hostRef is very important during
@@ -1170,10 +1291,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1170
1291
  consoleError(e);
1171
1292
  }
1172
1293
  {
1173
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1294
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1174
1295
  }
1175
1296
  {
1176
- hostRef.$flags$ |= 128 /* isWatchReady */;
1297
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1177
1298
  }
1178
1299
  endNewInstance();
1179
1300
  }
@@ -1183,7 +1304,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1183
1304
  const scopeId = getScopeId(cmpMeta);
1184
1305
  if (!styles.has(scopeId)) {
1185
1306
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1186
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1307
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1187
1308
  endRegisterStyles();
1188
1309
  }
1189
1310
  }
@@ -1205,13 +1326,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1205
1326
  }
1206
1327
  };
1207
1328
  const connectedCallback = (elm) => {
1208
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1329
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1209
1330
  const hostRef = getHostRef(elm);
1210
1331
  const cmpMeta = hostRef.$cmpMeta$;
1211
1332
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1212
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1333
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1213
1334
  // first time this component has connected
1214
- hostRef.$flags$ |= 1 /* hasConnected */;
1335
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1215
1336
  {
1216
1337
  // find the first ancestor component (if there is one) and register
1217
1338
  // this component as one of the actively loading child components for its ancestor
@@ -1231,7 +1352,7 @@ const connectedCallback = (elm) => {
1231
1352
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1232
1353
  if (cmpMeta.$members$) {
1233
1354
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1234
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1355
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1235
1356
  const value = elm[memberName];
1236
1357
  delete elm[memberName];
1237
1358
  elm[memberName] = value;
@@ -1252,7 +1373,7 @@ const connectedCallback = (elm) => {
1252
1373
  }
1253
1374
  };
1254
1375
  const disconnectedCallback = (elm) => {
1255
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1376
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1256
1377
  const hostRef = getHostRef(elm);
1257
1378
  const instance = hostRef.$lazyInstance$ ;
1258
1379
  {
@@ -1307,7 +1428,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1307
1428
  super(self);
1308
1429
  self = this;
1309
1430
  registerHost(self, cmpMeta);
1310
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1431
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1311
1432
  // this component is using shadow dom
1312
1433
  // and this browser supports shadow dom
1313
1434
  // add the read-only property "shadowRoot" to the host element
@@ -1342,7 +1463,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1342
1463
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1343
1464
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1344
1465
  cmpTags.push(tagName);
1345
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1466
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1346
1467
  }
1347
1468
  });
1348
1469
  });
@@ -1364,12 +1485,41 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1364
1485
  // Fallback appLoad event
1365
1486
  endBootstrap();
1366
1487
  };
1367
- const getAssetPath = (path) => {
1368
- const assetUrl = new URL(path, plt.$resourcesUrl$);
1369
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
1488
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1489
+ if (listeners) {
1490
+ listeners.map(([flags, name, method]) => {
1491
+ const target = getHostListenerTarget(elm, flags) ;
1492
+ const handler = hostListenerProxy(hostRef, method);
1493
+ const opts = hostListenerOpts(flags);
1494
+ plt.ael(target, name, handler, opts);
1495
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1496
+ });
1497
+ }
1370
1498
  };
1371
- const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
1372
- const hostRefs = new WeakMap();
1499
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1500
+ try {
1501
+ {
1502
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1503
+ // instance is ready, let's call it's member method for this event
1504
+ hostRef.$lazyInstance$[methodName](ev);
1505
+ }
1506
+ else {
1507
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1508
+ }
1509
+ }
1510
+ }
1511
+ catch (e) {
1512
+ consoleError(e);
1513
+ }
1514
+ };
1515
+ const getHostListenerTarget = (elm, flags) => {
1516
+ if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
1517
+ return doc;
1518
+ return elm;
1519
+ };
1520
+ // prettier-ignore
1521
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1522
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1373
1523
  const getHostRef = (ref) => hostRefs.get(ref);
1374
1524
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1375
1525
  const registerHost = (elm, cmpMeta) => {
@@ -1414,14 +1564,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1414
1564
  return importedModule[exportName];
1415
1565
  }, consoleError);
1416
1566
  };
1417
- const styles = new Map();
1567
+ const styles = /*@__PURE__*/ new Map();
1568
+ const win = typeof window !== 'undefined' ? window : {};
1569
+ const doc = win.document || { head: {} };
1570
+ const plt = {
1571
+ $flags$: 0,
1572
+ $resourcesUrl$: '',
1573
+ jmp: (h) => h(),
1574
+ raf: (h) => requestAnimationFrame(h),
1575
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1576
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1577
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1578
+ };
1579
+ const promiseResolve = (v) => Promise.resolve(v);
1580
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1581
+ try {
1582
+ new CSSStyleSheet();
1583
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1584
+ }
1585
+ catch (e) { }
1586
+ return false;
1587
+ })()
1588
+ ;
1418
1589
  const queueDomReads = [];
1419
1590
  const queueDomWrites = [];
1420
1591
  const queueTask = (queue, write) => (cb) => {
1421
1592
  queue.push(cb);
1422
1593
  if (!queuePending) {
1423
1594
  queuePending = true;
1424
- if (write && plt.$flags$ & 4 /* queueSync */) {
1595
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1425
1596
  nextTick(flush);
1426
1597
  }
1427
1598
  else {