@maggioli-design-system/mds-input-select 2.0.0 → 2.0.1

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