@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
@@ -22,61 +22,18 @@ function _interopNamespace(e) {
22
22
 
23
23
  const NAMESPACE = 'dnn';
24
24
 
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
25
33
  let scopeId;
26
34
  let hostTagName;
27
35
  let isSvgMode = false;
28
36
  let queuePending = false;
29
- const win = typeof window !== 'undefined' ? window : {};
30
- const doc = win.document || { head: {} };
31
- const plt = {
32
- $flags$: 0,
33
- $resourcesUrl$: '',
34
- jmp: (h) => h(),
35
- raf: (h) => requestAnimationFrame(h),
36
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
37
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
38
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
39
- };
40
- const promiseResolve = (v) => Promise.resolve(v);
41
- const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
42
- try {
43
- new CSSStyleSheet();
44
- return typeof new CSSStyleSheet().replace === 'function';
45
- }
46
- catch (e) { }
47
- return false;
48
- })()
49
- ;
50
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
51
- if (listeners) {
52
- listeners.map(([flags, name, method]) => {
53
- const target = elm;
54
- const handler = hostListenerProxy(hostRef, method);
55
- const opts = hostListenerOpts(flags);
56
- plt.ael(target, name, handler, opts);
57
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
58
- });
59
- }
60
- };
61
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
62
- try {
63
- {
64
- if (hostRef.$flags$ & 256 /* isListenReady */) {
65
- // instance is ready, let's call it's member method for this event
66
- hostRef.$lazyInstance$[methodName](ev);
67
- }
68
- else {
69
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
70
- }
71
- }
72
- }
73
- catch (e) {
74
- consoleError(e);
75
- }
76
- };
77
- // prettier-ignore
78
- const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
79
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
80
37
  const createTime = (fnName, tagName = '') => {
81
38
  {
82
39
  return () => {
@@ -91,71 +48,7 @@ const uniqueTime = (key, measureText) => {
91
48
  };
92
49
  }
93
50
  };
94
- const rootAppliedStyles = new WeakMap();
95
- const registerStyle = (scopeId, cssText, allowCS) => {
96
- let style = styles.get(scopeId);
97
- if (supportsConstructibleStylesheets && allowCS) {
98
- style = (style || new CSSStyleSheet());
99
- style.replace(cssText);
100
- }
101
- else {
102
- style = cssText;
103
- }
104
- styles.set(scopeId, style);
105
- };
106
- const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
107
- let scopeId = getScopeId(cmpMeta);
108
- let style = styles.get(scopeId);
109
- // if an element is NOT connected then getRootNode() will return the wrong root node
110
- // so the fallback is to always use the document for the root node in those cases
111
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
112
- if (style) {
113
- if (typeof style === 'string') {
114
- styleContainerNode = styleContainerNode.head || styleContainerNode;
115
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
116
- let styleElm;
117
- if (!appliedStyles) {
118
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
119
- }
120
- if (!appliedStyles.has(scopeId)) {
121
- {
122
- {
123
- styleElm = doc.createElement('style');
124
- styleElm.innerHTML = style;
125
- }
126
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
127
- }
128
- if (appliedStyles) {
129
- appliedStyles.add(scopeId);
130
- }
131
- }
132
- }
133
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
134
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
135
- }
136
- }
137
- return scopeId;
138
- };
139
- const attachStyles = (hostRef) => {
140
- const cmpMeta = hostRef.$cmpMeta$;
141
- const elm = hostRef.$hostElement$;
142
- const flags = cmpMeta.$flags$;
143
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
144
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
145
- if (flags & 10 /* needsScopedEncapsulation */) {
146
- // only required when we're NOT using native shadow dom (slot)
147
- // or this browser doesn't support native shadow dom
148
- // and this host element was NOT created with SSR
149
- // let's pick out the inner content for slot projection
150
- // create a node to represent where the original
151
- // content was first placed, which is useful later on
152
- // DOM WRITE!!
153
- elm['s-sc'] = scopeId;
154
- elm.classList.add(scopeId + '-h');
155
- }
156
- endAttachStyles();
157
- };
158
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
51
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
159
52
  /**
160
53
  * Default style mode id
161
54
  */
@@ -190,7 +83,7 @@ const h = (nodeName, vnodeData, ...children) => {
190
83
  let child = null;
191
84
  let simple = false;
192
85
  let lastSimple = false;
193
- let vNodeChildren = [];
86
+ const vNodeChildren = [];
194
87
  const walk = (c) => {
195
88
  for (let i = 0; i < c.length; i++) {
196
89
  child = c[i];
@@ -249,6 +142,149 @@ const newVNode = (tag, text) => {
249
142
  };
250
143
  const Host = {};
251
144
  const isHost = (node) => node && node.$tag$ === Host;
145
+ /**
146
+ * Parse a new property value for a given property type.
147
+ *
148
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
149
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
150
+ * 1. `any`, the type given to `propValue` in the function signature
151
+ * 2. the type stored from `propType`.
152
+ *
153
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
154
+ *
155
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
156
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
157
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
158
+ * ```tsx
159
+ * <my-cmp prop-val={0}></my-cmp>
160
+ * ```
161
+ *
162
+ * HTML prop values on the other hand, will always a string
163
+ *
164
+ * @param propValue the new value to coerce to some type
165
+ * @param propType the type of the prop, expressed as a binary number
166
+ * @returns the parsed/coerced value
167
+ */
168
+ const parsePropertyValue = (propValue, propType) => {
169
+ // ensure this value is of the correct prop type
170
+ if (propValue != null && !isComplexType(propValue)) {
171
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
172
+ // per the HTML spec, any string value means it is a boolean true value
173
+ // but we'll cheat here and say that the string "false" is the boolean false
174
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
175
+ }
176
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
177
+ // force it to be a number
178
+ return parseFloat(propValue);
179
+ }
180
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
181
+ // could have been passed as a number or boolean
182
+ // but we still want it as a string
183
+ return String(propValue);
184
+ }
185
+ // redundant return here for better minification
186
+ return propValue;
187
+ }
188
+ // not sure exactly what type we want
189
+ // so no need to change to a different type
190
+ return propValue;
191
+ };
192
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
193
+ const createEvent = (ref, name, flags) => {
194
+ const elm = getElement(ref);
195
+ return {
196
+ emit: (detail) => {
197
+ return emitEvent(elm, name, {
198
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
199
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
200
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
201
+ detail,
202
+ });
203
+ },
204
+ };
205
+ };
206
+ /**
207
+ * Helper function to create & dispatch a custom Event on a provided target
208
+ * @param elm the target of the Event
209
+ * @param name the name to give the custom Event
210
+ * @param opts options for configuring a custom Event
211
+ * @returns the custom Event
212
+ */
213
+ const emitEvent = (elm, name, opts) => {
214
+ const ev = plt.ce(name, opts);
215
+ elm.dispatchEvent(ev);
216
+ return ev;
217
+ };
218
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
219
+ const registerStyle = (scopeId, cssText, allowCS) => {
220
+ let style = styles.get(scopeId);
221
+ if (supportsConstructableStylesheets && allowCS) {
222
+ style = (style || new CSSStyleSheet());
223
+ if (typeof style === 'string') {
224
+ style = cssText;
225
+ }
226
+ else {
227
+ style.replaceSync(cssText);
228
+ }
229
+ }
230
+ else {
231
+ style = cssText;
232
+ }
233
+ styles.set(scopeId, style);
234
+ };
235
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
236
+ let scopeId = getScopeId(cmpMeta);
237
+ const style = styles.get(scopeId);
238
+ // if an element is NOT connected then getRootNode() will return the wrong root node
239
+ // so the fallback is to always use the document for the root node in those cases
240
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
241
+ if (style) {
242
+ if (typeof style === 'string') {
243
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
244
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
245
+ let styleElm;
246
+ if (!appliedStyles) {
247
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
248
+ }
249
+ if (!appliedStyles.has(scopeId)) {
250
+ {
251
+ {
252
+ styleElm = doc.createElement('style');
253
+ styleElm.innerHTML = style;
254
+ }
255
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
256
+ }
257
+ if (appliedStyles) {
258
+ appliedStyles.add(scopeId);
259
+ }
260
+ }
261
+ }
262
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
263
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
264
+ }
265
+ }
266
+ return scopeId;
267
+ };
268
+ const attachStyles = (hostRef) => {
269
+ const cmpMeta = hostRef.$cmpMeta$;
270
+ const elm = hostRef.$hostElement$;
271
+ const flags = cmpMeta.$flags$;
272
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
273
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
274
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
275
+ // only required when we're NOT using native shadow dom (slot)
276
+ // or this browser doesn't support native shadow dom
277
+ // and this host element was NOT created with SSR
278
+ // let's pick out the inner content for slot projection
279
+ // create a node to represent where the original
280
+ // content was first placed, which is useful later on
281
+ // DOM WRITE!!
282
+ elm['s-sc'] = scopeId;
283
+ elm.classList.add(scopeId + '-h');
284
+ }
285
+ endAttachStyles();
286
+ };
287
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
252
288
  /**
253
289
  * Production setAccessor() function based on Preact by
254
290
  * Jason Miller (@developit)
@@ -344,7 +380,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
344
380
  if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
345
381
  try {
346
382
  if (!elm.tagName.includes('-')) {
347
- let n = newValue == null ? '' : newValue;
383
+ const n = newValue == null ? '' : newValue;
348
384
  // Workaround for Safari, moving the <input> caret when re-assigning the same valued
349
385
  if (memberName === 'list') {
350
386
  isProp = false;
@@ -366,7 +402,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
366
402
  }
367
403
  }
368
404
  }
369
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
405
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
370
406
  newValue = newValue === true ? '' : newValue;
371
407
  {
372
408
  elm.setAttribute(memberName, newValue);
@@ -381,7 +417,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
381
417
  // if the element passed in is a shadow root, which is a document fragment
382
418
  // then we want to be adding attrs/props to the shadow root's "host" element
383
419
  // if it's not a shadow root, then we add attrs/props to the same element
384
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
420
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
385
421
  ? newVnode.$elm$.host
386
422
  : newVnode.$elm$;
387
423
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
@@ -399,9 +435,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
399
435
  setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
400
436
  }
401
437
  };
438
+ /**
439
+ * Create a DOM Node corresponding to one of the children of a given VNode.
440
+ *
441
+ * @param oldParentVNode the parent VNode from the previous render
442
+ * @param newParentVNode the parent VNode from the current render
443
+ * @param childIndex the index of the VNode, in the _new_ parent node's
444
+ * children, for which we will create a new DOM node
445
+ * @param parentElm the parent DOM node which our new node will be a child of
446
+ * @returns the newly created node
447
+ */
402
448
  const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
403
449
  // tslint:disable-next-line: prefer-const
404
- let newVNode = newParentVNode.$children$[childIndex];
450
+ const newVNode = newParentVNode.$children$[childIndex];
405
451
  let i = 0;
406
452
  let elm;
407
453
  let childNode;
@@ -478,6 +524,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
478
524
  }
479
525
  }
480
526
  };
527
+ /**
528
+ * Reconcile the children of a new VNode with the children of an old VNode by
529
+ * traversing the two collections of children, identifying nodes that are
530
+ * conserved or changed, calling out to `patch` to make any necessary
531
+ * updates to the DOM, and rearranging DOM nodes as needed.
532
+ *
533
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
534
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
535
+ * 'windows' by storing start and end indices and references to the
536
+ * corresponding array entries. Initially the two 'windows' are basically equal
537
+ * to the entire array, but we progressively narrow the windows until there are
538
+ * no children left to update by doing the following:
539
+ *
540
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
541
+ * that if we have an initial array like the following we'll end up dealing
542
+ * only with a window bounded by the highlighted elements:
543
+ *
544
+ * [null, null, VNode1 , ... , VNode2, null, null]
545
+ * ^^^^^^ ^^^^^^
546
+ *
547
+ * 2. Check to see if the elements at the head and tail positions are equal
548
+ * across the windows. This will basically detect elements which haven't
549
+ * been added, removed, or changed position, i.e. if you had the following
550
+ * VNode elements (represented as HTML):
551
+ *
552
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
553
+ * newVNode: `<div><p><span>THERE</span></p></div>`
554
+ *
555
+ * Then when comparing the children of the `<div>` tag we check the equality
556
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
557
+ * same tag in the same position, we'd be able to avoid completely
558
+ * re-rendering the subtree under them with a new DOM element and would just
559
+ * call out to `patch` to handle reconciling their children and so on.
560
+ *
561
+ * 3. Check, for both windows, to see if the element at the beginning of the
562
+ * window corresponds to the element at the end of the other window. This is
563
+ * a heuristic which will let us identify _some_ situations in which
564
+ * elements have changed position, for instance it _should_ detect that the
565
+ * children nodes themselves have not changed but merely moved in the
566
+ * following example:
567
+ *
568
+ * oldVNode: `<div><element-one /><element-two /></div>`
569
+ * newVNode: `<div><element-two /><element-one /></div>`
570
+ *
571
+ * If we find cases like this then we also need to move the concrete DOM
572
+ * elements corresponding to the moved children to write the re-order to the
573
+ * DOM.
574
+ *
575
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
576
+ * nodes in the old children which have the same key as the first element in
577
+ * our window on the new children. If we find such a node we handle calling
578
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
579
+ * what we find.
580
+ *
581
+ * Finally, once we've narrowed our 'windows' to the point that either of them
582
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
583
+ * insertion or deletion that needs to happen to get a DOM state that correctly
584
+ * reflects the new child VNodes. If, for instance, after our window on the old
585
+ * children has collapsed we still have more nodes on the new children that
586
+ * we haven't dealt with yet then we need to add them, or if the new children
587
+ * collapse but we still have unhandled _old_ children then we need to make
588
+ * sure the corresponding DOM nodes are removed.
589
+ *
590
+ * @param parentElm the node into which the parent VNode is rendered
591
+ * @param oldCh the old children of the parent node
592
+ * @param newVNode the new VNode which will replace the parent
593
+ * @param newCh the new children of the parent node
594
+ */
481
595
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
482
596
  let oldStartIdx = 0;
483
597
  let newStartIdx = 0;
@@ -490,7 +604,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
490
604
  let node;
491
605
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
492
606
  if (oldStartVnode == null) {
493
- // Vnode might have been moved left
607
+ // VNode might have been moved left
494
608
  oldStartVnode = oldCh[++oldStartIdx];
495
609
  }
496
610
  else if (oldEndVnode == null) {
@@ -503,34 +617,67 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
503
617
  newEndVnode = newCh[--newEndIdx];
504
618
  }
505
619
  else if (isSameVnode(oldStartVnode, newStartVnode)) {
620
+ // if the start nodes are the same then we should patch the new VNode
621
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
622
+ // indices to reflect that. We don't need to move any DOM Nodes around
623
+ // since things are matched up in order.
506
624
  patch(oldStartVnode, newStartVnode);
507
625
  oldStartVnode = oldCh[++oldStartIdx];
508
626
  newStartVnode = newCh[++newStartIdx];
509
627
  }
510
628
  else if (isSameVnode(oldEndVnode, newEndVnode)) {
629
+ // likewise, if the end nodes are the same we patch new onto old and
630
+ // decrement our end indices, and also likewise in this case we don't
631
+ // need to move any DOM Nodes.
511
632
  patch(oldEndVnode, newEndVnode);
512
633
  oldEndVnode = oldCh[--oldEndIdx];
513
634
  newEndVnode = newCh[--newEndIdx];
514
635
  }
515
636
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
516
637
  patch(oldStartVnode, newEndVnode);
638
+ // We need to move the element for `oldStartVnode` into a position which
639
+ // will be appropriate for `newEndVnode`. For this we can use
640
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
641
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
642
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
643
+ //
644
+ // <old-start-node />
645
+ // <some-intervening-node />
646
+ // <old-end-node />
647
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
648
+ // <next-sibling />
649
+ //
650
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
651
+ // the node for `oldStartVnode` at the end of the children of
652
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
653
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
654
+ // append it to the children of the parent element.
517
655
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
518
656
  oldStartVnode = oldCh[++oldStartIdx];
519
657
  newEndVnode = newCh[--newEndIdx];
520
658
  }
521
659
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
522
660
  patch(oldEndVnode, newStartVnode);
661
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
662
+ // the same node, so since we're here we know that they are not. Thus we
663
+ // can move the element for `oldEndVnode` _before_ the element for
664
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
665
+ // future.
523
666
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
524
667
  oldEndVnode = oldCh[--oldEndIdx];
525
668
  newStartVnode = newCh[++newStartIdx];
526
669
  }
527
670
  else {
528
671
  {
529
- // new element
672
+ // We either didn't find an element in the old children that matches
673
+ // the key of the first new child OR the build is not using `key`
674
+ // attributes at all. In either case we need to create a new element
675
+ // for the new node.
530
676
  node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
531
677
  newStartVnode = newCh[++newStartIdx];
532
678
  }
533
679
  if (node) {
680
+ // if we created a new node then handle inserting it to the DOM
534
681
  {
535
682
  oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
536
683
  }
@@ -538,20 +685,49 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
538
685
  }
539
686
  }
540
687
  if (oldStartIdx > oldEndIdx) {
688
+ // we have some more new nodes to add which don't match up with old nodes
541
689
  addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
542
690
  }
543
691
  else if (newStartIdx > newEndIdx) {
692
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
693
+ // in the new array, so lets remove them (which entails cleaning up the
694
+ // relevant DOM nodes)
544
695
  removeVnodes(oldCh, oldStartIdx, oldEndIdx);
545
696
  }
546
697
  };
547
- const isSameVnode = (vnode1, vnode2) => {
698
+ /**
699
+ * Compare two VNodes to determine if they are the same
700
+ *
701
+ * **NB**: This function is an equality _heuristic_ based on the available
702
+ * information set on the two VNodes and can be misleading under certain
703
+ * circumstances. In particular, if the two nodes do not have `key` attrs
704
+ * (available under `$key$` on VNodes) then the function falls back on merely
705
+ * checking that they have the same tag.
706
+ *
707
+ * So, in other words, if `key` attrs are not set on VNodes which may be
708
+ * changing order within a `children` array or something along those lines then
709
+ * we could obtain a false positive and then have to do needless re-rendering.
710
+ *
711
+ * @param leftVNode the first VNode to check
712
+ * @param rightVNode the second VNode to check
713
+ * @returns whether they're equal or not
714
+ */
715
+ const isSameVnode = (leftVNode, rightVNode) => {
548
716
  // compare if two vnode to see if they're "technically" the same
549
717
  // need to have the same element tag, and same key to be the same
550
- if (vnode1.$tag$ === vnode2.$tag$) {
718
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
551
719
  return true;
552
720
  }
553
721
  return false;
554
722
  };
723
+ /**
724
+ * Handle reconciling an outdated VNode with a new one which corresponds to
725
+ * it. This function handles flushing updates to the DOM and reconciling the
726
+ * children of the two nodes (if any).
727
+ *
728
+ * @param oldVNode an old VNode whose DOM element and children we want to update
729
+ * @param newVNode a new VNode representing an updated version of the old one
730
+ */
555
731
  const patch = (oldVNode, newVNode) => {
556
732
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
557
733
  const oldChildren = oldVNode.$children$;
@@ -564,7 +740,6 @@ const patch = (oldVNode, newVNode) => {
564
740
  // only add this to the when the compiler sees we're using an svg somewhere
565
741
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
566
742
  }
567
- // element node
568
743
  {
569
744
  if (tag === 'slot')
570
745
  ;
@@ -577,6 +752,7 @@ const patch = (oldVNode, newVNode) => {
577
752
  }
578
753
  if (oldChildren !== null && newChildren !== null) {
579
754
  // looks like there's child vnodes for both the old and new vnodes
755
+ // so we need to call `updateChildren` to reconcile them
580
756
  updateChildren(elm, oldChildren, newVNode, newChildren);
581
757
  }
582
758
  else if (newChildren !== null) {
@@ -619,7 +795,7 @@ const renderVdom = (hostRef, renderFnResults) => {
619
795
  cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
620
796
  }
621
797
  rootVnode.$tag$ = null;
622
- rootVnode.$flags$ |= 4 /* isHost */;
798
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
623
799
  hostRef.$vnode$ = rootVnode;
624
800
  rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
625
801
  {
@@ -628,32 +804,6 @@ const renderVdom = (hostRef, renderFnResults) => {
628
804
  // synchronous patch
629
805
  patch(oldVNode, rootVnode);
630
806
  };
631
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
632
- const createEvent = (ref, name, flags) => {
633
- const elm = getElement(ref);
634
- return {
635
- emit: (detail) => {
636
- return emitEvent(elm, name, {
637
- bubbles: !!(flags & 4 /* Bubbles */),
638
- composed: !!(flags & 2 /* Composed */),
639
- cancelable: !!(flags & 1 /* Cancellable */),
640
- detail,
641
- });
642
- },
643
- };
644
- };
645
- /**
646
- * Helper function to create & dispatch a custom Event on a provided target
647
- * @param elm the target of the Event
648
- * @param name the name to give the custom Event
649
- * @param opts options for configuring a custom Event
650
- * @returns the custom Event
651
- */
652
- const emitEvent = (elm, name, opts) => {
653
- const ev = plt.ce(name, opts);
654
- elm.dispatchEvent(ev);
655
- return ev;
656
- };
657
807
  const attachToAncestor = (hostRef, ancestorComponent) => {
658
808
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
659
809
  ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
@@ -661,10 +811,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
661
811
  };
662
812
  const scheduleUpdate = (hostRef, isInitialLoad) => {
663
813
  {
664
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
814
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
665
815
  }
666
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
667
- hostRef.$flags$ |= 512 /* needsRerender */;
816
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
817
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
668
818
  return;
669
819
  }
670
820
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
@@ -680,7 +830,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
680
830
  let promise;
681
831
  if (isInitialLoad) {
682
832
  {
683
- hostRef.$flags$ |= 256 /* isListenReady */;
833
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
684
834
  if (hostRef.$queuedListeners$) {
685
835
  hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
686
836
  hostRef.$queuedListeners$ = null;
@@ -723,7 +873,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
723
873
  }
724
874
  else {
725
875
  Promise.all(childrenPromises).then(postUpdate);
726
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
876
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
727
877
  childrenPromises.length = 0;
728
878
  }
729
879
  }
@@ -732,10 +882,10 @@ const callRender = (hostRef, instance, elm) => {
732
882
  try {
733
883
  instance = instance.render() ;
734
884
  {
735
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
885
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
736
886
  }
737
887
  {
738
- hostRef.$flags$ |= 2 /* hasRendered */;
888
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
739
889
  }
740
890
  {
741
891
  {
@@ -762,8 +912,8 @@ const postUpdateComponent = (hostRef) => {
762
912
  {
763
913
  safeCall(instance, 'componentDidRender');
764
914
  }
765
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
766
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
915
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
916
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
767
917
  {
768
918
  // DOM WRITE!
769
919
  addHydratedFlag(elm);
@@ -792,10 +942,10 @@ const postUpdateComponent = (hostRef) => {
792
942
  hostRef.$onRenderResolve$();
793
943
  hostRef.$onRenderResolve$ = undefined;
794
944
  }
795
- if (hostRef.$flags$ & 512 /* needsRerender */) {
945
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
796
946
  nextTick(() => scheduleUpdate(hostRef, false));
797
947
  }
798
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
948
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
799
949
  }
800
950
  // ( •_•)
801
951
  // ( •_•)>⌐■-■
@@ -825,53 +975,6 @@ const then = (promise, thenFn) => {
825
975
  };
826
976
  const addHydratedFlag = (elm) => elm.classList.add('hydrated')
827
977
  ;
828
- /**
829
- * Parse a new property value for a given property type.
830
- *
831
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
832
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
833
- * 1. `any`, the type given to `propValue` in the function signature
834
- * 2. the type stored from `propType`.
835
- *
836
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
837
- *
838
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
839
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
840
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
841
- * ```tsx
842
- * <my-cmp prop-val={0}></my-cmp>
843
- * ```
844
- *
845
- * HTML prop values on the other hand, will always a string
846
- *
847
- * @param propValue the new value to coerce to some type
848
- * @param propType the type of the prop, expressed as a binary number
849
- * @returns the parsed/coerced value
850
- */
851
- const parsePropertyValue = (propValue, propType) => {
852
- // ensure this value is of the correct prop type
853
- if (propValue != null && !isComplexType(propValue)) {
854
- if (propType & 4 /* Boolean */) {
855
- // per the HTML spec, any string value means it is a boolean true value
856
- // but we'll cheat here and say that the string "false" is the boolean false
857
- return propValue === 'false' ? false : propValue === '' || !!propValue;
858
- }
859
- if (propType & 2 /* Number */) {
860
- // force it to be a number
861
- return parseFloat(propValue);
862
- }
863
- if (propType & 1 /* String */) {
864
- // could have been passed as a number or boolean
865
- // but we still want it as a string
866
- return String(propValue);
867
- }
868
- // redundant return here for better minification
869
- return propValue;
870
- }
871
- // not sure exactly what type we want
872
- // so no need to change to a different type
873
- return propValue;
874
- };
875
978
  const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
876
979
  const setValue = (ref, propName, newVal, cmpMeta) => {
877
980
  // check our new property value against our internal value
@@ -884,13 +987,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
884
987
  // explicitly check for NaN on both sides, as `NaN === NaN` is always false
885
988
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
886
989
  const didValueChange = newVal !== oldVal && !areBothNaN;
887
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
990
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
888
991
  // gadzooks! the property's value has changed!!
889
992
  // set our new value!
890
993
  hostRef.$instanceValues$.set(propName, newVal);
891
994
  if (instance) {
892
995
  // get an array of method names of watch functions to call
893
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
996
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
894
997
  const watchMethods = cmpMeta.$watchers$[propName];
895
998
  if (watchMethods) {
896
999
  // this instance is watching for when this property changed
@@ -905,7 +1008,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
905
1008
  });
906
1009
  }
907
1010
  }
908
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1011
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
909
1012
  // looks like this value actually changed, so we've got work to do!
910
1013
  // but only if we've already rendered, otherwise just chill out
911
1014
  // queue that we need to do an update, but don't worry about queuing
@@ -915,6 +1018,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
915
1018
  }
916
1019
  }
917
1020
  };
1021
+ /**
1022
+ * Attach a series of runtime constructs to a compiled Stencil component
1023
+ * constructor, including getters and setters for the `@Prop` and `@State`
1024
+ * decorators, callbacks for when attributes change, and so on.
1025
+ *
1026
+ * @param Cstr the constructor for a component that we need to process
1027
+ * @param cmpMeta metadata collected previously about the component
1028
+ * @param flags a number used to store a series of bit flags
1029
+ * @returns a reference to the same constructor passed in (but now mutated)
1030
+ */
918
1031
  const proxyComponent = (Cstr, cmpMeta, flags) => {
919
1032
  if (cmpMeta.$members$) {
920
1033
  if (Cstr.watchers) {
@@ -924,8 +1037,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
924
1037
  const members = Object.entries(cmpMeta.$members$);
925
1038
  const prototype = Cstr.prototype;
926
1039
  members.map(([memberName, [memberFlags]]) => {
927
- if ((memberFlags & 31 /* Prop */ ||
928
- ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1040
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1041
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
929
1042
  // proxyComponent - prop
930
1043
  Object.defineProperty(prototype, memberName, {
931
1044
  get() {
@@ -940,8 +1053,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
940
1053
  enumerable: true,
941
1054
  });
942
1055
  }
943
- else if (flags & 1 /* isElementConstructor */ &&
944
- memberFlags & 64 /* Method */) {
1056
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1057
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
945
1058
  // proxyComponent - method
946
1059
  Object.defineProperty(prototype, memberName, {
947
1060
  value(...args) {
@@ -951,7 +1064,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
951
1064
  });
952
1065
  }
953
1066
  });
954
- if ((flags & 1 /* isElementConstructor */)) {
1067
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
955
1068
  const attrNameToPropName = new Map();
956
1069
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
957
1070
  plt.jmp(() => {
@@ -1007,11 +1120,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1007
1120
  // create an array of attributes to observe
1008
1121
  // and also create a map of html attribute name to js property name
1009
1122
  Cstr.observedAttributes = members
1010
- .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1123
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1011
1124
  .map(([propName, m]) => {
1012
1125
  const attrName = m[1] || propName;
1013
1126
  attrNameToPropName.set(attrName, propName);
1014
- if (m[0] & 512 /* ReflectAttr */) {
1127
+ if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1015
1128
  cmpMeta.$attrsToReflect$.push([propName, attrName]);
1016
1129
  }
1017
1130
  return attrName;
@@ -1022,10 +1135,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1022
1135
  };
1023
1136
  const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1024
1137
  // initializeComponent
1025
- if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1138
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1026
1139
  {
1027
1140
  // we haven't initialized this element yet
1028
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1141
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1029
1142
  // lazy loaded components
1030
1143
  // request the component's implementation to be
1031
1144
  // wired up with the host element
@@ -1043,7 +1156,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1043
1156
  {
1044
1157
  cmpMeta.$watchers$ = Cstr.watchers;
1045
1158
  }
1046
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1159
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1047
1160
  Cstr.isProxied = true;
1048
1161
  }
1049
1162
  const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
@@ -1051,7 +1164,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1051
1164
  // but let's keep track of when we start and stop
1052
1165
  // so that the getters/setters don't incorrectly step on data
1053
1166
  {
1054
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1167
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1055
1168
  }
1056
1169
  // construct the lazy-loaded component implementation
1057
1170
  // passing the hostRef is very important during
@@ -1064,10 +1177,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1064
1177
  consoleError(e);
1065
1178
  }
1066
1179
  {
1067
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1180
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1068
1181
  }
1069
1182
  {
1070
- hostRef.$flags$ |= 128 /* isWatchReady */;
1183
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1071
1184
  }
1072
1185
  endNewInstance();
1073
1186
  }
@@ -1077,7 +1190,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1077
1190
  const scopeId = getScopeId(cmpMeta);
1078
1191
  if (!styles.has(scopeId)) {
1079
1192
  const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1080
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1193
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1081
1194
  endRegisterStyles();
1082
1195
  }
1083
1196
  }
@@ -1099,13 +1212,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
1099
1212
  }
1100
1213
  };
1101
1214
  const connectedCallback = (elm) => {
1102
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1215
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1103
1216
  const hostRef = getHostRef(elm);
1104
1217
  const cmpMeta = hostRef.$cmpMeta$;
1105
1218
  const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1106
- if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1219
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1107
1220
  // first time this component has connected
1108
- hostRef.$flags$ |= 1 /* hasConnected */;
1221
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1109
1222
  {
1110
1223
  // find the first ancestor component (if there is one) and register
1111
1224
  // this component as one of the actively loading child components for its ancestor
@@ -1125,7 +1238,7 @@ const connectedCallback = (elm) => {
1125
1238
  // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1126
1239
  if (cmpMeta.$members$) {
1127
1240
  Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1128
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1241
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1129
1242
  const value = elm[memberName];
1130
1243
  delete elm[memberName];
1131
1244
  elm[memberName] = value;
@@ -1146,7 +1259,7 @@ const connectedCallback = (elm) => {
1146
1259
  }
1147
1260
  };
1148
1261
  const disconnectedCallback = (elm) => {
1149
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1262
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1150
1263
  const hostRef = getHostRef(elm);
1151
1264
  const instance = hostRef.$lazyInstance$ ;
1152
1265
  {
@@ -1201,7 +1314,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1201
1314
  super(self);
1202
1315
  self = this;
1203
1316
  registerHost(self, cmpMeta);
1204
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1317
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1205
1318
  // this component is using shadow dom
1206
1319
  // and this browser supports shadow dom
1207
1320
  // add the read-only property "shadowRoot" to the host element
@@ -1236,7 +1349,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1236
1349
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
1237
1350
  if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1238
1351
  cmpTags.push(tagName);
1239
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1352
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1240
1353
  }
1241
1354
  });
1242
1355
  });
@@ -1258,7 +1371,36 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1258
1371
  // Fallback appLoad event
1259
1372
  endBootstrap();
1260
1373
  };
1261
- const hostRefs = new WeakMap();
1374
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1375
+ if (listeners) {
1376
+ listeners.map(([flags, name, method]) => {
1377
+ const target = elm;
1378
+ const handler = hostListenerProxy(hostRef, method);
1379
+ const opts = hostListenerOpts(flags);
1380
+ plt.ael(target, name, handler, opts);
1381
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1382
+ });
1383
+ }
1384
+ };
1385
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1386
+ try {
1387
+ {
1388
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1389
+ // instance is ready, let's call it's member method for this event
1390
+ hostRef.$lazyInstance$[methodName](ev);
1391
+ }
1392
+ else {
1393
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1394
+ }
1395
+ }
1396
+ }
1397
+ catch (e) {
1398
+ consoleError(e);
1399
+ }
1400
+ };
1401
+ // prettier-ignore
1402
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1403
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1262
1404
  const getHostRef = (ref) => hostRefs.get(ref);
1263
1405
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1264
1406
  const registerHost = (elm, cmpMeta) => {
@@ -1290,7 +1432,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1290
1432
  if (module) {
1291
1433
  return module[exportName];
1292
1434
  }
1435
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1293
1436
  return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1437
+ /* @vite-ignore */
1294
1438
  /* webpackInclude: /\.entry\.js$/ */
1295
1439
  /* webpackExclude: /\.system\.entry\.js$/ */
1296
1440
  /* webpackMode: "lazy" */
@@ -1301,14 +1445,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1301
1445
  return importedModule[exportName];
1302
1446
  }, consoleError);
1303
1447
  };
1304
- const styles = new Map();
1448
+ const styles = /*@__PURE__*/ new Map();
1449
+ const win = typeof window !== 'undefined' ? window : {};
1450
+ const doc = win.document || { head: {} };
1451
+ const plt = {
1452
+ $flags$: 0,
1453
+ $resourcesUrl$: '',
1454
+ jmp: (h) => h(),
1455
+ raf: (h) => requestAnimationFrame(h),
1456
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1457
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1458
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1459
+ };
1460
+ const promiseResolve = (v) => Promise.resolve(v);
1461
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1462
+ try {
1463
+ new CSSStyleSheet();
1464
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1465
+ }
1466
+ catch (e) { }
1467
+ return false;
1468
+ })()
1469
+ ;
1305
1470
  const queueDomReads = [];
1306
1471
  const queueDomWrites = [];
1307
1472
  const queueTask = (queue, write) => (cb) => {
1308
1473
  queue.push(cb);
1309
1474
  if (!queuePending) {
1310
1475
  queuePending = true;
1311
- if (write && plt.$flags$ & 4 /* queueSync */) {
1476
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1312
1477
  nextTick(flush);
1313
1478
  }
1314
1479
  else {
@@ -1353,4 +1518,4 @@ exports.h = h;
1353
1518
  exports.promiseResolve = promiseResolve;
1354
1519
  exports.registerInstance = registerInstance;
1355
1520
 
1356
- //# sourceMappingURL=index-514ef6dd.js.map
1521
+ //# sourceMappingURL=index-81382452.js.map