@dnncommunity/dnn-elements 0.15.1 → 0.15.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 (102) hide show
  1. package/dist/cjs/dnn-button_17.cjs.entry.js +3 -3
  2. package/dist/cjs/dnn-button_17.cjs.entry.js.map +1 -1
  3. package/dist/cjs/dnn.cjs.js +2 -2
  4. package/dist/cjs/dnn.cjs.js.map +1 -1
  5. package/dist/cjs/{index-514ef6dd.js → index-81382452.js} +404 -239
  6. package/dist/cjs/index-81382452.js.map +1 -0
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/cjs/loader.cjs.js.map +1 -1
  9. package/dist/collection/collection-manifest.json +2 -2
  10. package/dist/collection/components/dnn-button/dnn-button.js +195 -192
  11. package/dist/collection/components/dnn-button/dnn-button.stories.js +1 -1
  12. package/dist/collection/components/dnn-checkbox/dnn-checkbox.js +85 -99
  13. package/dist/collection/components/dnn-checkbox/dnn-checkbox.stories.js +1 -1
  14. package/dist/collection/components/dnn-chevron/dnn-chevron.js +92 -87
  15. package/dist/collection/components/dnn-chevron/dnn-chevron.stories.js +1 -1
  16. package/dist/collection/components/dnn-collapsible/dnn-collapsible.js +102 -90
  17. package/dist/collection/components/dnn-collapsible/dnn-collapsible.stories.js +1 -1
  18. package/dist/collection/components/dnn-color-picker/dnn-color-picker.js +105 -141
  19. package/dist/collection/components/dnn-color-picker/dnn-color-picker.stories.js +1 -1
  20. package/dist/collection/components/dnn-dropzone/dnn-dropzone.js +122 -137
  21. package/dist/collection/components/dnn-dropzone/dnn-dropzone.stories.js +1 -1
  22. package/dist/collection/components/dnn-image-cropper/CornerType.js +1 -1
  23. package/dist/collection/components/dnn-image-cropper/dnn-image-cropper.js +129 -133
  24. package/dist/collection/components/dnn-image-cropper/dnn-image-cropper.stories.js +1 -1
  25. package/dist/collection/components/dnn-modal/dnn-modal.css +5 -0
  26. package/dist/collection/components/dnn-modal/dnn-modal.js +136 -133
  27. package/dist/collection/components/dnn-modal/dnn-modal.js.map +1 -1
  28. package/dist/collection/components/dnn-modal/dnn-modal.stories.js +1 -1
  29. package/dist/collection/components/dnn-permissions-grid/dnn-permissions-grid.js +164 -223
  30. package/dist/collection/components/dnn-permissions-grid/dnn-permissions-grid.stories.js +1 -1
  31. package/dist/collection/components/dnn-permissions-grid/localization-interface.js +1 -1
  32. package/dist/collection/components/dnn-permissions-grid/permissions-interface.js +1 -1
  33. package/dist/collection/components/dnn-permissions-grid/role-group-interface.js +1 -1
  34. package/dist/collection/components/dnn-permissions-grid/role-interface.js +1 -1
  35. package/dist/collection/components/dnn-permissions-grid/searched-user-interface.js +1 -1
  36. package/dist/collection/components/dnn-searchbox/dnn-searchbox.js +101 -94
  37. package/dist/collection/components/dnn-searchbox/dnn-searchbox.stories.js +1 -1
  38. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.js +55 -54
  39. package/dist/collection/components/dnn-sort-icon/dnn-sort-icon.stories.js +1 -1
  40. package/dist/collection/components/dnn-tab/dnn-tab.js +69 -59
  41. package/dist/collection/components/dnn-tab/dnn-tab.stories.js +1 -1
  42. package/dist/collection/components/dnn-tabs/dnn-tabs.js +19 -16
  43. package/dist/collection/components/dnn-tabs/dnn-tabs.stories.js +1 -1
  44. package/dist/collection/components/dnn-toggle/dnn-toggle.js +83 -75
  45. package/dist/collection/components/dnn-toggle/dnn-toggle.stories.js +1 -1
  46. package/dist/collection/components/dnn-toggle/toggle-interface.js +1 -1
  47. package/dist/collection/components/dnn-treeview-item/dnn-treeview-item.js +79 -77
  48. package/dist/collection/components/dnn-treeview-item/dnn-treeview-item.stories.js +1 -1
  49. package/dist/collection/components/dnn-vertical-overflow-menu/dnn-vertical-overflow-menu.js +20 -24
  50. package/dist/collection/components/dnn-vertical-overflow-menu/dnn-vertical-overflow-menu.stories.js +1 -1
  51. package/dist/collection/components/dnn-vertical-splitview/dnn-vertical-splitview.js +117 -111
  52. package/dist/collection/components/dnn-vertical-splitview/dnn-vertical-splitview.stories.js +1 -1
  53. package/dist/collection/index.js +1 -1
  54. package/dist/collection/utilities/colorInfo.js +1 -1
  55. package/dist/collection/utilities/debounce.js +1 -1
  56. package/dist/collection/utilities/dnnServicesFramework.js +1 -1
  57. package/dist/collection/utilities/mouseUtilities.js +1 -1
  58. package/dist/dnn/dnn.esm.js +1 -1
  59. package/dist/dnn/dnn.esm.js.map +1 -1
  60. package/dist/dnn/dnn.js +2 -1
  61. package/dist/dnn/p-21f18e37.system.js +3 -0
  62. package/dist/dnn/p-21f18e37.system.js.map +1 -0
  63. package/dist/dnn/p-2a79ad5b.system.entry.js +11 -0
  64. package/dist/dnn/p-2a79ad5b.system.entry.js.map +1 -0
  65. package/dist/dnn/{p-5bcf3629.system.js → p-52139080.system.js} +2 -2
  66. package/dist/dnn/{p-5bcf3629.system.js.map → p-52139080.system.js.map} +1 -1
  67. package/dist/dnn/{p-909f2db9.entry.js → p-6cc227ab.entry.js} +3 -3
  68. package/dist/dnn/p-6cc227ab.entry.js.map +1 -0
  69. package/dist/dnn/p-97d752ed.js +3 -0
  70. package/dist/dnn/p-97d752ed.js.map +1 -0
  71. package/dist/esm/dnn-button_17.entry.js +3 -3
  72. package/dist/esm/dnn-button_17.entry.js.map +1 -1
  73. package/dist/esm/dnn.js +2 -2
  74. package/dist/esm/dnn.js.map +1 -1
  75. package/dist/esm/{index-59e0950f.js → index-e9a3fcad.js} +404 -239
  76. package/dist/esm/index-e9a3fcad.js.map +1 -0
  77. package/dist/esm/loader.js +2 -2
  78. package/dist/esm/loader.js.map +1 -1
  79. package/dist/esm/polyfills/css-shim.js +1 -1
  80. package/dist/esm-es5/dnn-button_17.entry.js +2 -2
  81. package/dist/esm-es5/dnn-button_17.entry.js.map +1 -1
  82. package/dist/esm-es5/dnn.js +1 -1
  83. package/dist/esm-es5/dnn.js.map +1 -1
  84. package/dist/esm-es5/index-e9a3fcad.js +3 -0
  85. package/dist/esm-es5/index-e9a3fcad.js.map +1 -0
  86. package/dist/esm-es5/loader.js +1 -1
  87. package/dist/esm-es5/loader.js.map +1 -1
  88. package/dist/types/components.d.ts +73 -17
  89. package/dist/types/stencil-public-runtime.d.ts +15 -4
  90. package/loader/package.json +1 -0
  91. package/package.json +14 -14
  92. package/dist/cjs/index-514ef6dd.js.map +0 -1
  93. package/dist/dnn/p-3155c8a8.system.entry.js +0 -11
  94. package/dist/dnn/p-3155c8a8.system.entry.js.map +0 -1
  95. package/dist/dnn/p-7ffdbed1.js +0 -2
  96. package/dist/dnn/p-7ffdbed1.js.map +0 -1
  97. package/dist/dnn/p-909f2db9.entry.js.map +0 -1
  98. package/dist/dnn/p-b8064287.system.js +0 -2
  99. package/dist/dnn/p-b8064287.system.js.map +0 -1
  100. package/dist/esm/index-59e0950f.js.map +0 -1
  101. package/dist/esm-es5/index-59e0950f.js +0 -2
  102. package/dist/esm-es5/index-59e0950f.js.map +0 -1
@@ -1,60 +1,17 @@
1
1
  const NAMESPACE = 'dnn';
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 supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
20
- try {
21
- new CSSStyleSheet();
22
- return typeof new CSSStyleSheet().replace === '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 = elm;
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
- // prettier-ignore
56
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
57
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
58
15
  const createTime = (fnName, tagName = '') => {
59
16
  {
60
17
  return () => {
@@ -69,71 +26,7 @@ const uniqueTime = (key, measureText) => {
69
26
  };
70
27
  }
71
28
  };
72
- const rootAppliedStyles = new WeakMap();
73
- const registerStyle = (scopeId, cssText, allowCS) => {
74
- let style = styles.get(scopeId);
75
- if (supportsConstructibleStylesheets && allowCS) {
76
- style = (style || new CSSStyleSheet());
77
- style.replace(cssText);
78
- }
79
- else {
80
- style = cssText;
81
- }
82
- styles.set(scopeId, style);
83
- };
84
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
85
- let scopeId = getScopeId(cmpMeta);
86
- let style = styles.get(scopeId);
87
- // if an element is NOT connected then getRootNode() will return the wrong root node
88
- // so the fallback is to always use the document for the root node in those cases
89
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
90
- if (style) {
91
- if (typeof style === 'string') {
92
- styleContainerNode = styleContainerNode.head || styleContainerNode;
93
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
94
- let styleElm;
95
- if (!appliedStyles) {
96
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
97
- }
98
- if (!appliedStyles.has(scopeId)) {
99
- {
100
- {
101
- styleElm = doc.createElement('style');
102
- styleElm.innerHTML = style;
103
- }
104
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
105
- }
106
- if (appliedStyles) {
107
- appliedStyles.add(scopeId);
108
- }
109
- }
110
- }
111
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
112
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
113
- }
114
- }
115
- return scopeId;
116
- };
117
- const attachStyles = (hostRef) => {
118
- const cmpMeta = hostRef.$cmpMeta$;
119
- const elm = hostRef.$hostElement$;
120
- const flags = cmpMeta.$flags$;
121
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
122
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
123
- if (flags & 10 /* needsScopedEncapsulation */) {
124
- // only required when we're NOT using native shadow dom (slot)
125
- // or this browser doesn't support native shadow dom
126
- // and this host element was NOT created with SSR
127
- // let's pick out the inner content for slot projection
128
- // create a node to represent where the original
129
- // content was first placed, which is useful later on
130
- // DOM WRITE!!
131
- elm['s-sc'] = scopeId;
132
- elm.classList.add(scopeId + '-h');
133
- }
134
- endAttachStyles();
135
- };
136
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
29
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
137
30
  /**
138
31
  * Default style mode id
139
32
  */
@@ -168,7 +61,7 @@ const h = (nodeName, vnodeData, ...children) => {
168
61
  let child = null;
169
62
  let simple = false;
170
63
  let lastSimple = false;
171
- let vNodeChildren = [];
64
+ const vNodeChildren = [];
172
65
  const walk = (c) => {
173
66
  for (let i = 0; i < c.length; i++) {
174
67
  child = c[i];
@@ -227,6 +120,149 @@ const newVNode = (tag, text) => {
227
120
  };
228
121
  const Host = {};
229
122
  const isHost = (node) => node && node.$tag$ === Host;
123
+ /**
124
+ * Parse a new property value for a given property type.
125
+ *
126
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
127
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
128
+ * 1. `any`, the type given to `propValue` in the function signature
129
+ * 2. the type stored from `propType`.
130
+ *
131
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
132
+ *
133
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
134
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
135
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
136
+ * ```tsx
137
+ * <my-cmp prop-val={0}></my-cmp>
138
+ * ```
139
+ *
140
+ * HTML prop values on the other hand, will always a string
141
+ *
142
+ * @param propValue the new value to coerce to some type
143
+ * @param propType the type of the prop, expressed as a binary number
144
+ * @returns the parsed/coerced value
145
+ */
146
+ const parsePropertyValue = (propValue, propType) => {
147
+ // ensure this value is of the correct prop type
148
+ if (propValue != null && !isComplexType(propValue)) {
149
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
150
+ // per the HTML spec, any string value means it is a boolean true value
151
+ // but we'll cheat here and say that the string "false" is the boolean false
152
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
153
+ }
154
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
155
+ // force it to be a number
156
+ return parseFloat(propValue);
157
+ }
158
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
159
+ // could have been passed as a number or boolean
160
+ // but we still want it as a string
161
+ return String(propValue);
162
+ }
163
+ // redundant return here for better minification
164
+ return propValue;
165
+ }
166
+ // not sure exactly what type we want
167
+ // so no need to change to a different type
168
+ return propValue;
169
+ };
170
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
171
+ const createEvent = (ref, name, flags) => {
172
+ const elm = getElement(ref);
173
+ return {
174
+ emit: (detail) => {
175
+ return emitEvent(elm, name, {
176
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
177
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
178
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
179
+ detail,
180
+ });
181
+ },
182
+ };
183
+ };
184
+ /**
185
+ * Helper function to create & dispatch a custom Event on a provided target
186
+ * @param elm the target of the Event
187
+ * @param name the name to give the custom Event
188
+ * @param opts options for configuring a custom Event
189
+ * @returns the custom Event
190
+ */
191
+ const emitEvent = (elm, name, opts) => {
192
+ const ev = plt.ce(name, opts);
193
+ elm.dispatchEvent(ev);
194
+ return ev;
195
+ };
196
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
197
+ const registerStyle = (scopeId, cssText, allowCS) => {
198
+ let style = styles.get(scopeId);
199
+ if (supportsConstructableStylesheets && allowCS) {
200
+ style = (style || new CSSStyleSheet());
201
+ if (typeof style === 'string') {
202
+ style = cssText;
203
+ }
204
+ else {
205
+ style.replaceSync(cssText);
206
+ }
207
+ }
208
+ else {
209
+ style = cssText;
210
+ }
211
+ styles.set(scopeId, style);
212
+ };
213
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
214
+ let scopeId = getScopeId(cmpMeta);
215
+ const style = styles.get(scopeId);
216
+ // if an element is NOT connected then getRootNode() will return the wrong root node
217
+ // so the fallback is to always use the document for the root node in those cases
218
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
219
+ if (style) {
220
+ if (typeof style === 'string') {
221
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
222
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
223
+ let styleElm;
224
+ if (!appliedStyles) {
225
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
226
+ }
227
+ if (!appliedStyles.has(scopeId)) {
228
+ {
229
+ {
230
+ styleElm = doc.createElement('style');
231
+ styleElm.innerHTML = style;
232
+ }
233
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
234
+ }
235
+ if (appliedStyles) {
236
+ appliedStyles.add(scopeId);
237
+ }
238
+ }
239
+ }
240
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
241
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
242
+ }
243
+ }
244
+ return scopeId;
245
+ };
246
+ const attachStyles = (hostRef) => {
247
+ const cmpMeta = hostRef.$cmpMeta$;
248
+ const elm = hostRef.$hostElement$;
249
+ const flags = cmpMeta.$flags$;
250
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
251
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
252
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
253
+ // only required when we're NOT using native shadow dom (slot)
254
+ // or this browser doesn't support native shadow dom
255
+ // and this host element was NOT created with SSR
256
+ // let's pick out the inner content for slot projection
257
+ // create a node to represent where the original
258
+ // content was first placed, which is useful later on
259
+ // DOM WRITE!!
260
+ elm['s-sc'] = scopeId;
261
+ elm.classList.add(scopeId + '-h');
262
+ }
263
+ endAttachStyles();
264
+ };
265
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
230
266
  /**
231
267
  * Production setAccessor() function based on Preact by
232
268
  * Jason Miller (@developit)
@@ -322,7 +358,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
322
358
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
323
359
  try {
324
360
  if (!elm.tagName.includes('-')) {
325
- let n = newValue == null ? '' : newValue;
361
+ const n = newValue == null ? '' : newValue;
326
362
  // Workaround for Safari, moving the <input> caret when re-assigning the same valued
327
363
  if (memberName === 'list') {
328
364
  isProp = false;
@@ -344,7 +380,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
344
380
  }
345
381
  }
346
382
  }
347
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
383
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
348
384
  newValue = newValue === true ? '' : newValue;
349
385
  {
350
386
  elm.setAttribute(memberName, newValue);
@@ -359,7 +395,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
359
395
  // if the element passed in is a shadow root, which is a document fragment
360
396
  // then we want to be adding attrs/props to the shadow root's "host" element
361
397
  // if it's not a shadow root, then we add attrs/props to the same element
362
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
398
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
363
399
  ? newVnode.$elm$.host
364
400
  : newVnode.$elm$;
365
401
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -377,9 +413,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
377
413
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
378
414
  }
379
415
  };
416
+ /**
417
+ * Create a DOM Node corresponding to one of the children of a given VNode.
418
+ *
419
+ * @param oldParentVNode the parent VNode from the previous render
420
+ * @param newParentVNode the parent VNode from the current render
421
+ * @param childIndex the index of the VNode, in the _new_ parent node's
422
+ * children, for which we will create a new DOM node
423
+ * @param parentElm the parent DOM node which our new node will be a child of
424
+ * @returns the newly created node
425
+ */
380
426
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
381
427
  // tslint:disable-next-line: prefer-const
382
- let newVNode = newParentVNode.$children$[childIndex];
428
+ const newVNode = newParentVNode.$children$[childIndex];
383
429
  let i = 0;
384
430
  let elm;
385
431
  let childNode;
@@ -456,6 +502,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
456
502
  }
457
503
  }
458
504
  };
505
+ /**
506
+ * Reconcile the children of a new VNode with the children of an old VNode by
507
+ * traversing the two collections of children, identifying nodes that are
508
+ * conserved or changed, calling out to `patch` to make any necessary
509
+ * updates to the DOM, and rearranging DOM nodes as needed.
510
+ *
511
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
512
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
513
+ * 'windows' by storing start and end indices and references to the
514
+ * corresponding array entries. Initially the two 'windows' are basically equal
515
+ * to the entire array, but we progressively narrow the windows until there are
516
+ * no children left to update by doing the following:
517
+ *
518
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
519
+ * that if we have an initial array like the following we'll end up dealing
520
+ * only with a window bounded by the highlighted elements:
521
+ *
522
+ * [null, null, VNode1 , ... , VNode2, null, null]
523
+ * ^^^^^^ ^^^^^^
524
+ *
525
+ * 2. Check to see if the elements at the head and tail positions are equal
526
+ * across the windows. This will basically detect elements which haven't
527
+ * been added, removed, or changed position, i.e. if you had the following
528
+ * VNode elements (represented as HTML):
529
+ *
530
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
531
+ * newVNode: `<div><p><span>THERE</span></p></div>`
532
+ *
533
+ * Then when comparing the children of the `<div>` tag we check the equality
534
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
535
+ * same tag in the same position, we'd be able to avoid completely
536
+ * re-rendering the subtree under them with a new DOM element and would just
537
+ * call out to `patch` to handle reconciling their children and so on.
538
+ *
539
+ * 3. Check, for both windows, to see if the element at the beginning of the
540
+ * window corresponds to the element at the end of the other window. This is
541
+ * a heuristic which will let us identify _some_ situations in which
542
+ * elements have changed position, for instance it _should_ detect that the
543
+ * children nodes themselves have not changed but merely moved in the
544
+ * following example:
545
+ *
546
+ * oldVNode: `<div><element-one /><element-two /></div>`
547
+ * newVNode: `<div><element-two /><element-one /></div>`
548
+ *
549
+ * If we find cases like this then we also need to move the concrete DOM
550
+ * elements corresponding to the moved children to write the re-order to the
551
+ * DOM.
552
+ *
553
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
554
+ * nodes in the old children which have the same key as the first element in
555
+ * our window on the new children. If we find such a node we handle calling
556
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
557
+ * what we find.
558
+ *
559
+ * Finally, once we've narrowed our 'windows' to the point that either of them
560
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
561
+ * insertion or deletion that needs to happen to get a DOM state that correctly
562
+ * reflects the new child VNodes. If, for instance, after our window on the old
563
+ * children has collapsed we still have more nodes on the new children that
564
+ * we haven't dealt with yet then we need to add them, or if the new children
565
+ * collapse but we still have unhandled _old_ children then we need to make
566
+ * sure the corresponding DOM nodes are removed.
567
+ *
568
+ * @param parentElm the node into which the parent VNode is rendered
569
+ * @param oldCh the old children of the parent node
570
+ * @param newVNode the new VNode which will replace the parent
571
+ * @param newCh the new children of the parent node
572
+ */
459
573
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
460
574
  let oldStartIdx = 0;
461
575
  let newStartIdx = 0;
@@ -468,7 +582,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
468
582
  let node;
469
583
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
470
584
  if (oldStartVnode == null) {
471
- // Vnode might have been moved left
585
+ // VNode might have been moved left
472
586
  oldStartVnode = oldCh[++oldStartIdx];
473
587
  }
474
588
  else if (oldEndVnode == null) {
@@ -481,34 +595,67 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
481
595
  newEndVnode = newCh[--newEndIdx];
482
596
  }
483
597
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
598
+ // if the start nodes are the same then we should patch the new VNode
599
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
600
+ // indices to reflect that. We don't need to move any DOM Nodes around
601
+ // since things are matched up in order.
484
602
  patch(oldStartVnode, newStartVnode);
485
603
  oldStartVnode = oldCh[++oldStartIdx];
486
604
  newStartVnode = newCh[++newStartIdx];
487
605
  }
488
606
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
607
+ // likewise, if the end nodes are the same we patch new onto old and
608
+ // decrement our end indices, and also likewise in this case we don't
609
+ // need to move any DOM Nodes.
489
610
  patch(oldEndVnode, newEndVnode);
490
611
  oldEndVnode = oldCh[--oldEndIdx];
491
612
  newEndVnode = newCh[--newEndIdx];
492
613
  }
493
614
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
494
615
  patch(oldStartVnode, newEndVnode);
616
+ // We need to move the element for `oldStartVnode` into a position which
617
+ // will be appropriate for `newEndVnode`. For this we can use
618
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
619
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
620
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
621
+ //
622
+ // <old-start-node />
623
+ // <some-intervening-node />
624
+ // <old-end-node />
625
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
626
+ // <next-sibling />
627
+ //
628
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
629
+ // the node for `oldStartVnode` at the end of the children of
630
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
631
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
632
+ // append it to the children of the parent element.
495
633
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
496
634
  oldStartVnode = oldCh[++oldStartIdx];
497
635
  newEndVnode = newCh[--newEndIdx];
498
636
  }
499
637
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
500
638
  patch(oldEndVnode, newStartVnode);
639
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
640
+ // the same node, so since we're here we know that they are not. Thus we
641
+ // can move the element for `oldEndVnode` _before_ the element for
642
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
643
+ // future.
501
644
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
502
645
  oldEndVnode = oldCh[--oldEndIdx];
503
646
  newStartVnode = newCh[++newStartIdx];
504
647
  }
505
648
  else {
506
649
  {
507
- // new element
650
+ // We either didn't find an element in the old children that matches
651
+ // the key of the first new child OR the build is not using `key`
652
+ // attributes at all. In either case we need to create a new element
653
+ // for the new node.
508
654
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
509
655
  newStartVnode = newCh[++newStartIdx];
510
656
  }
511
657
  if (node) {
658
+ // if we created a new node then handle inserting it to the DOM
512
659
  {
513
660
  oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
514
661
  }
@@ -516,20 +663,49 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
516
663
  }
517
664
  }
518
665
  if (oldStartIdx > oldEndIdx) {
666
+ // we have some more new nodes to add which don't match up with old nodes
519
667
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
520
668
  }
521
669
  else if (newStartIdx > newEndIdx) {
670
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
671
+ // in the new array, so lets remove them (which entails cleaning up the
672
+ // relevant DOM nodes)
522
673
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
523
674
  }
524
675
  };
525
- const isSameVnode = (vnode1, vnode2) => {
676
+ /**
677
+ * Compare two VNodes to determine if they are the same
678
+ *
679
+ * **NB**: This function is an equality _heuristic_ based on the available
680
+ * information set on the two VNodes and can be misleading under certain
681
+ * circumstances. In particular, if the two nodes do not have `key` attrs
682
+ * (available under `$key$` on VNodes) then the function falls back on merely
683
+ * checking that they have the same tag.
684
+ *
685
+ * So, in other words, if `key` attrs are not set on VNodes which may be
686
+ * changing order within a `children` array or something along those lines then
687
+ * we could obtain a false positive and then have to do needless re-rendering.
688
+ *
689
+ * @param leftVNode the first VNode to check
690
+ * @param rightVNode the second VNode to check
691
+ * @returns whether they're equal or not
692
+ */
693
+ const isSameVnode = (leftVNode, rightVNode) => {
526
694
  // compare if two vnode to see if they're "technically" the same
527
695
  // need to have the same element tag, and same key to be the same
528
- if (vnode1.$tag$ === vnode2.$tag$) {
696
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
529
697
  return true;
530
698
  }
531
699
  return false;
532
700
  };
701
+ /**
702
+ * Handle reconciling an outdated VNode with a new one which corresponds to
703
+ * it. This function handles flushing updates to the DOM and reconciling the
704
+ * children of the two nodes (if any).
705
+ *
706
+ * @param oldVNode an old VNode whose DOM element and children we want to update
707
+ * @param newVNode a new VNode representing an updated version of the old one
708
+ */
533
709
  const patch = (oldVNode, newVNode) => {
534
710
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
535
711
  const oldChildren = oldVNode.$children$;
@@ -542,7 +718,6 @@ const patch = (oldVNode, newVNode) => {
542
718
  // only add this to the when the compiler sees we're using an svg somewhere
543
719
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
544
720
  }
545
- // element node
546
721
  {
547
722
  if (tag === 'slot')
548
723
  ;
@@ -555,6 +730,7 @@ const patch = (oldVNode, newVNode) => {
555
730
  }
556
731
  if (oldChildren !== null && newChildren !== null) {
557
732
  // looks like there's child vnodes for both the old and new vnodes
733
+ // so we need to call `updateChildren` to reconcile them
558
734
  updateChildren(elm, oldChildren, newVNode, newChildren);
559
735
  }
560
736
  else if (newChildren !== null) {
@@ -597,7 +773,7 @@ const renderVdom = (hostRef, renderFnResults) => {
597
773
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
598
774
  }
599
775
  rootVnode.$tag$ = null;
600
- rootVnode.$flags$ |= 4 /* isHost */;
776
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
601
777
  hostRef.$vnode$ = rootVnode;
602
778
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
603
779
  {
@@ -606,32 +782,6 @@ const renderVdom = (hostRef, renderFnResults) => {
606
782
  // synchronous patch
607
783
  patch(oldVNode, rootVnode);
608
784
  };
609
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
610
- const createEvent = (ref, name, flags) => {
611
- const elm = getElement(ref);
612
- return {
613
- emit: (detail) => {
614
- return emitEvent(elm, name, {
615
- bubbles: !!(flags & 4 /* Bubbles */),
616
- composed: !!(flags & 2 /* Composed */),
617
- cancelable: !!(flags & 1 /* Cancellable */),
618
- detail,
619
- });
620
- },
621
- };
622
- };
623
- /**
624
- * Helper function to create & dispatch a custom Event on a provided target
625
- * @param elm the target of the Event
626
- * @param name the name to give the custom Event
627
- * @param opts options for configuring a custom Event
628
- * @returns the custom Event
629
- */
630
- const emitEvent = (elm, name, opts) => {
631
- const ev = plt.ce(name, opts);
632
- elm.dispatchEvent(ev);
633
- return ev;
634
- };
635
785
  const attachToAncestor = (hostRef, ancestorComponent) => {
636
786
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
637
787
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -639,10 +789,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
639
789
  };
640
790
  const scheduleUpdate = (hostRef, isInitialLoad) => {
641
791
  {
642
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
792
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
643
793
  }
644
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
645
- hostRef.$flags$ |= 512 /* needsRerender */;
794
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
795
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
646
796
  return;
647
797
  }
648
798
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -658,7 +808,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
658
808
  let promise;
659
809
  if (isInitialLoad) {
660
810
  {
661
- hostRef.$flags$ |= 256 /* isListenReady */;
811
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
662
812
  if (hostRef.$queuedListeners$) {
663
813
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
664
814
  hostRef.$queuedListeners$ = null;
@@ -701,7 +851,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
701
851
  }
702
852
  else {
703
853
  Promise.all(childrenPromises).then(postUpdate);
704
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
854
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
705
855
  childrenPromises.length = 0;
706
856
  }
707
857
  }
@@ -710,10 +860,10 @@ const callRender = (hostRef, instance, elm) => {
710
860
  try {
711
861
  instance = instance.render() ;
712
862
  {
713
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
863
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
714
864
  }
715
865
  {
716
- hostRef.$flags$ |= 2 /* hasRendered */;
866
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
717
867
  }
718
868
  {
719
869
  {
@@ -740,8 +890,8 @@ const postUpdateComponent = (hostRef) => {
740
890
  {
741
891
  safeCall(instance, 'componentDidRender');
742
892
  }
743
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
744
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
893
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
894
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
745
895
  {
746
896
  // DOM WRITE!
747
897
  addHydratedFlag(elm);
@@ -770,10 +920,10 @@ const postUpdateComponent = (hostRef) => {
770
920
  hostRef.$onRenderResolve$();
771
921
  hostRef.$onRenderResolve$ = undefined;
772
922
  }
773
- if (hostRef.$flags$ & 512 /* needsRerender */) {
923
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
774
924
  nextTick(() => scheduleUpdate(hostRef, false));
775
925
  }
776
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
926
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
777
927
  }
778
928
  // ( •_•)
779
929
  // ( •_•)>⌐■-■
@@ -803,53 +953,6 @@ const then = (promise, thenFn) => {
803
953
  };
804
954
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
805
955
  ;
806
- /**
807
- * Parse a new property value for a given property type.
808
- *
809
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
810
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
811
- * 1. `any`, the type given to `propValue` in the function signature
812
- * 2. the type stored from `propType`.
813
- *
814
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
815
- *
816
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
817
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
818
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
819
- * ```tsx
820
- * <my-cmp prop-val={0}></my-cmp>
821
- * ```
822
- *
823
- * HTML prop values on the other hand, will always a string
824
- *
825
- * @param propValue the new value to coerce to some type
826
- * @param propType the type of the prop, expressed as a binary number
827
- * @returns the parsed/coerced value
828
- */
829
- const parsePropertyValue = (propValue, propType) => {
830
- // ensure this value is of the correct prop type
831
- if (propValue != null && !isComplexType(propValue)) {
832
- if (propType & 4 /* Boolean */) {
833
- // per the HTML spec, any string value means it is a boolean true value
834
- // but we'll cheat here and say that the string "false" is the boolean false
835
- return propValue === 'false' ? false : propValue === '' || !!propValue;
836
- }
837
- if (propType & 2 /* Number */) {
838
- // force it to be a number
839
- return parseFloat(propValue);
840
- }
841
- if (propType & 1 /* String */) {
842
- // could have been passed as a number or boolean
843
- // but we still want it as a string
844
- return String(propValue);
845
- }
846
- // redundant return here for better minification
847
- return propValue;
848
- }
849
- // not sure exactly what type we want
850
- // so no need to change to a different type
851
- return propValue;
852
- };
853
956
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
854
957
  const setValue = (ref, propName, newVal, cmpMeta) => {
855
958
  // check our new property value against our internal value
@@ -862,13 +965,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
862
965
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
863
966
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
864
967
  const didValueChange = newVal !== oldVal && !areBothNaN;
865
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
968
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
866
969
  // gadzooks! the property's value has changed!!
867
970
  // set our new value!
868
971
  hostRef.$instanceValues$.set(propName, newVal);
869
972
  if (instance) {
870
973
  // get an array of method names of watch functions to call
871
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
974
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
872
975
  const watchMethods = cmpMeta.$watchers$[propName];
873
976
  if (watchMethods) {
874
977
  // this instance is watching for when this property changed
@@ -883,7 +986,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
883
986
  });
884
987
  }
885
988
  }
886
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
989
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
887
990
  // looks like this value actually changed, so we've got work to do!
888
991
  // but only if we've already rendered, otherwise just chill out
889
992
  // queue that we need to do an update, but don't worry about queuing
@@ -893,6 +996,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
893
996
  }
894
997
  }
895
998
  };
999
+ /**
1000
+ * Attach a series of runtime constructs to a compiled Stencil component
1001
+ * constructor, including getters and setters for the `@Prop` and `@State`
1002
+ * decorators, callbacks for when attributes change, and so on.
1003
+ *
1004
+ * @param Cstr the constructor for a component that we need to process
1005
+ * @param cmpMeta metadata collected previously about the component
1006
+ * @param flags a number used to store a series of bit flags
1007
+ * @returns a reference to the same constructor passed in (but now mutated)
1008
+ */
896
1009
  const proxyComponent = (Cstr, cmpMeta, flags) => {
897
1010
  if (cmpMeta.$members$) {
898
1011
  if (Cstr.watchers) {
@@ -902,8 +1015,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
902
1015
  const members = Object.entries(cmpMeta.$members$);
903
1016
  const prototype = Cstr.prototype;
904
1017
  members.map(([memberName, [memberFlags]]) => {
905
- if ((memberFlags & 31 /* Prop */ ||
906
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1018
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1019
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
907
1020
  // proxyComponent - prop
908
1021
  Object.defineProperty(prototype, memberName, {
909
1022
  get() {
@@ -918,8 +1031,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
918
1031
  enumerable: true,
919
1032
  });
920
1033
  }
921
- else if (flags & 1 /* isElementConstructor */ &&
922
- memberFlags & 64 /* Method */) {
1034
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1035
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
923
1036
  // proxyComponent - method
924
1037
  Object.defineProperty(prototype, memberName, {
925
1038
  value(...args) {
@@ -929,7 +1042,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
929
1042
  });
930
1043
  }
931
1044
  });
932
- if ((flags & 1 /* isElementConstructor */)) {
1045
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
933
1046
  const attrNameToPropName = new Map();
934
1047
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
935
1048
  plt.jmp(() => {
@@ -985,11 +1098,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
985
1098
  // create an array of attributes to observe
986
1099
  // and also create a map of html attribute name to js property name
987
1100
  Cstr.observedAttributes = members
988
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1101
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
989
1102
  .map(([propName, m]) => {
990
1103
  const attrName = m[1] || propName;
991
1104
  attrNameToPropName.set(attrName, propName);
992
- if (m[0] & 512 /* ReflectAttr */) {
1105
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
993
1106
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
994
1107
  }
995
1108
  return attrName;
@@ -1000,10 +1113,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1000
1113
  };
1001
1114
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1002
1115
  // initializeComponent
1003
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1116
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1004
1117
  {
1005
1118
  // we haven't initialized this element yet
1006
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1119
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1007
1120
  // lazy loaded components
1008
1121
  // request the component's implementation to be
1009
1122
  // wired up with the host element
@@ -1021,7 +1134,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1021
1134
  {
1022
1135
  cmpMeta.$watchers$ = Cstr.watchers;
1023
1136
  }
1024
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1137
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1025
1138
  Cstr.isProxied = true;
1026
1139
  }
1027
1140
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -1029,7 +1142,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1029
1142
  // but let's keep track of when we start and stop
1030
1143
  // so that the getters/setters don't incorrectly step on data
1031
1144
  {
1032
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1145
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1033
1146
  }
1034
1147
  // construct the lazy-loaded component implementation
1035
1148
  // passing the hostRef is very important during
@@ -1042,10 +1155,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1042
1155
  consoleError(e);
1043
1156
  }
1044
1157
  {
1045
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1158
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1046
1159
  }
1047
1160
  {
1048
- hostRef.$flags$ |= 128 /* isWatchReady */;
1161
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1049
1162
  }
1050
1163
  endNewInstance();
1051
1164
  }
@@ -1055,7 +1168,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1055
1168
  const scopeId = getScopeId(cmpMeta);
1056
1169
  if (!styles.has(scopeId)) {
1057
1170
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1058
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1171
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1059
1172
  endRegisterStyles();
1060
1173
  }
1061
1174
  }
@@ -1077,13 +1190,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1077
1190
  }
1078
1191
  };
1079
1192
  const connectedCallback = (elm) => {
1080
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1193
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1081
1194
  const hostRef = getHostRef(elm);
1082
1195
  const cmpMeta = hostRef.$cmpMeta$;
1083
1196
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1084
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1197
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1085
1198
  // first time this component has connected
1086
- hostRef.$flags$ |= 1 /* hasConnected */;
1199
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1087
1200
  {
1088
1201
  // find the first ancestor component (if there is one) and register
1089
1202
  // this component as one of the actively loading child components for its ancestor
@@ -1103,7 +1216,7 @@ const connectedCallback = (elm) => {
1103
1216
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1104
1217
  if (cmpMeta.$members$) {
1105
1218
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1106
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1219
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1107
1220
  const value = elm[memberName];
1108
1221
  delete elm[memberName];
1109
1222
  elm[memberName] = value;
@@ -1124,7 +1237,7 @@ const connectedCallback = (elm) => {
1124
1237
  }
1125
1238
  };
1126
1239
  const disconnectedCallback = (elm) => {
1127
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1240
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1128
1241
  const hostRef = getHostRef(elm);
1129
1242
  const instance = hostRef.$lazyInstance$ ;
1130
1243
  {
@@ -1179,7 +1292,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1179
1292
  super(self);
1180
1293
  self = this;
1181
1294
  registerHost(self, cmpMeta);
1182
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1295
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1183
1296
  // this component is using shadow dom
1184
1297
  // and this browser supports shadow dom
1185
1298
  // add the read-only property "shadowRoot" to the host element
@@ -1214,7 +1327,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1214
1327
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1215
1328
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1216
1329
  cmpTags.push(tagName);
1217
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1330
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1218
1331
  }
1219
1332
  });
1220
1333
  });
@@ -1236,7 +1349,36 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1236
1349
  // Fallback appLoad event
1237
1350
  endBootstrap();
1238
1351
  };
1239
- const hostRefs = new WeakMap();
1352
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1353
+ if (listeners) {
1354
+ listeners.map(([flags, name, method]) => {
1355
+ const target = elm;
1356
+ const handler = hostListenerProxy(hostRef, method);
1357
+ const opts = hostListenerOpts(flags);
1358
+ plt.ael(target, name, handler, opts);
1359
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1360
+ });
1361
+ }
1362
+ };
1363
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1364
+ try {
1365
+ {
1366
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1367
+ // instance is ready, let's call it's member method for this event
1368
+ hostRef.$lazyInstance$[methodName](ev);
1369
+ }
1370
+ else {
1371
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1372
+ }
1373
+ }
1374
+ }
1375
+ catch (e) {
1376
+ consoleError(e);
1377
+ }
1378
+ };
1379
+ // prettier-ignore
1380
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1381
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1240
1382
  const getHostRef = (ref) => hostRefs.get(ref);
1241
1383
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1242
1384
  const registerHost = (elm, cmpMeta) => {
@@ -1268,7 +1410,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1268
1410
  if (module) {
1269
1411
  return module[exportName];
1270
1412
  }
1413
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1271
1414
  return import(
1415
+ /* @vite-ignore */
1272
1416
  /* webpackInclude: /\.entry\.js$/ */
1273
1417
  /* webpackExclude: /\.system\.entry\.js$/ */
1274
1418
  /* webpackMode: "lazy" */
@@ -1279,14 +1423,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1279
1423
  return importedModule[exportName];
1280
1424
  }, consoleError);
1281
1425
  };
1282
- const styles = new Map();
1426
+ const styles = /*@__PURE__*/ new Map();
1427
+ const win = typeof window !== 'undefined' ? window : {};
1428
+ const doc = win.document || { head: {} };
1429
+ const plt = {
1430
+ $flags$: 0,
1431
+ $resourcesUrl$: '',
1432
+ jmp: (h) => h(),
1433
+ raf: (h) => requestAnimationFrame(h),
1434
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1435
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1436
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1437
+ };
1438
+ const promiseResolve = (v) => Promise.resolve(v);
1439
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1440
+ try {
1441
+ new CSSStyleSheet();
1442
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1443
+ }
1444
+ catch (e) { }
1445
+ return false;
1446
+ })()
1447
+ ;
1283
1448
  const queueDomReads = [];
1284
1449
  const queueDomWrites = [];
1285
1450
  const queueTask = (queue, write) => (cb) => {
1286
1451
  queue.push(cb);
1287
1452
  if (!queuePending) {
1288
1453
  queuePending = true;
1289
- if (write && plt.$flags$ & 4 /* queueSync */) {
1454
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1290
1455
  nextTick(flush);
1291
1456
  }
1292
1457
  else {
@@ -1325,4 +1490,4 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1325
1490
 
1326
1491
  export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r };
1327
1492
 
1328
- //# sourceMappingURL=index-59e0950f.js.map
1493
+ //# sourceMappingURL=index-e9a3fcad.js.map