@maggioli-design-system/mds-input 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/cjs/index-3aa055da.js +1207 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/mds-input.cjs.entry.js +162 -0
  5. package/dist/cjs/mds-input.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/mds-input/mds-input.css +482 -0
  8. package/dist/collection/components/mds-input/mds-input.js +586 -0
  9. package/dist/collection/components/mds-input/meta/interfaces.js +1 -0
  10. package/dist/collection/components/mds-input/test/mds-input.stories.js +165 -0
  11. package/dist/collection/dictionary/autocomplete.js +59 -0
  12. package/dist/collection/dictionary/button.js +26 -0
  13. package/dist/collection/dictionary/color.js +19 -0
  14. package/dist/collection/dictionary/icon.js +3 -0
  15. package/dist/collection/dictionary/input-text-type.js +13 -0
  16. package/dist/collection/dictionary/loading.js +5 -0
  17. package/dist/collection/dictionary/typography.js +43 -0
  18. package/dist/collection/dictionary/variant.js +65 -0
  19. package/dist/collection/fixtures/cities.js +110 -0
  20. package/dist/collection/interface/input-value.js +1 -0
  21. package/dist/collection/types/autocomplete.js +1 -0
  22. package/dist/collection/types/button.js +1 -0
  23. package/dist/collection/types/form-rel.js +1 -0
  24. package/dist/collection/types/input-text-type.js +1 -0
  25. package/dist/collection/types/input-value-type.js +1 -0
  26. package/dist/collection/types/loading.js +1 -0
  27. package/dist/collection/types/typography.js +1 -0
  28. package/dist/collection/types/variant.js +1 -0
  29. package/dist/components/index.d.ts +26 -0
  30. package/dist/components/index.js +1 -0
  31. package/dist/components/mds-input.d.ts +11 -0
  32. package/dist/components/mds-input.js +200 -0
  33. package/dist/esm/index-2cdf06e7.js +1179 -0
  34. package/dist/esm/index.js +1 -0
  35. package/dist/esm/loader.js +17 -0
  36. package/dist/esm/mds-input.entry.js +158 -0
  37. package/dist/esm/mds-input.js +17 -0
  38. package/dist/esm/polyfills/core-js.js +11 -0
  39. package/dist/esm/polyfills/css-shim.js +1 -0
  40. package/dist/esm/polyfills/dom.js +79 -0
  41. package/dist/esm/polyfills/es5-html-element.js +1 -0
  42. package/dist/esm/polyfills/index.js +34 -0
  43. package/dist/esm/polyfills/system.js +6 -0
  44. package/dist/esm-es5/index-2cdf06e7.js +1 -0
  45. package/dist/esm-es5/index.js +0 -0
  46. package/dist/esm-es5/loader.js +1 -0
  47. package/dist/esm-es5/mds-input.entry.js +1 -0
  48. package/dist/esm-es5/mds-input.js +1 -0
  49. package/dist/index.cjs.js +1 -0
  50. package/dist/index.js +1 -0
  51. package/dist/mds-input/index.esm.js +0 -0
  52. package/dist/mds-input/mds-input.esm.js +1 -0
  53. package/dist/mds-input/mds-input.js +130 -0
  54. package/dist/mds-input/p-132bdeae.system.entry.js +1 -0
  55. package/dist/mds-input/p-275873d7.entry.js +1 -0
  56. package/dist/mds-input/p-50ea2036.system.js +1 -0
  57. package/dist/mds-input/p-8bdf82a6.js +1 -0
  58. package/dist/mds-input/p-91d946fe.system.js +1 -0
  59. package/dist/mds-input/p-992602db.system.js +1 -0
  60. package/dist/stats.json +1424 -0
  61. package/dist/types/components/mds-input/meta/interfaces.d.ts +4 -0
  62. package/dist/types/components.d.ts +218 -0
  63. package/dist/types/dictionary/autocomplete.d.ts +2 -0
  64. package/dist/types/dictionary/button.d.ts +5 -0
  65. package/dist/types/dictionary/color.d.ts +3 -0
  66. package/dist/types/dictionary/icon.d.ts +2 -0
  67. package/dist/types/dictionary/input-text-type.d.ts +2 -0
  68. package/dist/types/dictionary/loading.d.ts +2 -0
  69. package/dist/types/dictionary/typography.d.ts +6 -0
  70. package/dist/types/dictionary/variant.d.ts +9 -0
  71. package/dist/types/fixtures/cities.d.ts +2 -0
  72. package/dist/types/interface/input-value.d.ts +4 -0
  73. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  74. package/dist/types/types/autocomplete.d.ts +2 -0
  75. package/dist/types/types/button.d.ts +4 -0
  76. package/dist/types/types/form-rel.d.ts +1 -0
  77. package/dist/types/types/input-text-type.d.ts +1 -0
  78. package/dist/types/types/input-value-type.d.ts +1 -0
  79. package/dist/types/types/loading.d.ts +1 -0
  80. package/dist/types/types/typography.d.ts +5 -0
  81. package/dist/types/types/variant.d.ts +10 -0
  82. package/loader/cdn.js +3 -0
  83. package/loader/index.cjs.js +3 -0
  84. package/loader/index.d.ts +12 -0
  85. package/loader/index.es2017.js +3 -0
  86. package/loader/index.js +4 -0
  87. package/loader/package.json +10 -0
  88. package/package.json +46 -0
  89. package/readme.md +97 -0
  90. package/src/components/mds-input/css/mds-input-variant.css +65 -0
  91. package/src/components/mds-input/mds-input.css +133 -0
  92. package/src/components/mds-input/mds-input.tsx +294 -0
  93. package/src/components/mds-input/meta/interfaces.ts +5 -0
  94. package/src/components/mds-input/readme.md +77 -0
  95. package/src/components/mds-input/test/mds-input.e2e.ts +12 -0
  96. package/src/components/mds-input/test/mds-input.spec.tsx +19 -0
  97. package/src/components/mds-input/test/mds-input.stories.js +165 -0
  98. package/src/components.d.ts +218 -0
  99. package/src/dictionary/autocomplete.ts +62 -0
  100. package/src/dictionary/button.ts +35 -0
  101. package/src/dictionary/color.ts +24 -0
  102. package/src/dictionary/icon.ts +5 -0
  103. package/src/dictionary/input-text-type.ts +17 -0
  104. package/src/dictionary/loading.ts +9 -0
  105. package/src/dictionary/typography.ts +54 -0
  106. package/src/dictionary/variant.ts +82 -0
  107. package/src/fixtures/cities.ts +116 -0
  108. package/src/interface/input-value.ts +5 -0
  109. package/src/types/autocomplete.ts +69 -0
  110. package/src/types/button.ts +24 -0
  111. package/src/types/form-rel.ts +11 -0
  112. package/src/types/input-text-type.ts +11 -0
  113. package/src/types/input-value-type.ts +5 -0
  114. package/src/types/loading.ts +3 -0
  115. package/src/types/typography.ts +41 -0
  116. package/src/types/variant.ts +73 -0
  117. package/www/build/index.esm.js +0 -0
  118. package/www/build/mds-input.esm.js +1 -0
  119. package/www/build/mds-input.js +130 -0
  120. package/www/build/p-132bdeae.system.entry.js +1 -0
  121. package/www/build/p-275873d7.entry.js +1 -0
  122. package/www/build/p-50ea2036.system.js +1 -0
  123. package/www/build/p-8bdf82a6.js +1 -0
  124. package/www/build/p-91d946fe.system.js +1 -0
  125. package/www/build/p-992602db.system.js +1 -0
  126. package/www/host.config.json +15 -0
@@ -0,0 +1,1207 @@
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';
24
+
25
+ let scopeId;
26
+ let hostTagName;
27
+ let isSvgMode = false;
28
+ 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 HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
51
+ const createTime = (fnName, tagName = '') => {
52
+ {
53
+ return () => {
54
+ return;
55
+ };
56
+ }
57
+ };
58
+ const uniqueTime = (key, measureText) => {
59
+ {
60
+ return () => {
61
+ return;
62
+ };
63
+ }
64
+ };
65
+ const rootAppliedStyles = new WeakMap();
66
+ const registerStyle = (scopeId, cssText, allowCS) => {
67
+ let style = styles.get(scopeId);
68
+ if (supportsConstructibleStylesheets && allowCS) {
69
+ style = (style || new CSSStyleSheet());
70
+ style.replace(cssText);
71
+ }
72
+ else {
73
+ style = cssText;
74
+ }
75
+ styles.set(scopeId, style);
76
+ };
77
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
78
+ let scopeId = getScopeId(cmpMeta);
79
+ let style = styles.get(scopeId);
80
+ // if an element is NOT connected then getRootNode() will return the wrong root node
81
+ // so the fallback is to always use the document for the root node in those cases
82
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
83
+ if (style) {
84
+ if (typeof style === 'string') {
85
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
86
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
87
+ let styleElm;
88
+ if (!appliedStyles) {
89
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
90
+ }
91
+ if (!appliedStyles.has(scopeId)) {
92
+ {
93
+ {
94
+ styleElm = doc.createElement('style');
95
+ styleElm.innerHTML = style;
96
+ }
97
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
98
+ }
99
+ if (appliedStyles) {
100
+ appliedStyles.add(scopeId);
101
+ }
102
+ }
103
+ }
104
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
105
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
106
+ }
107
+ }
108
+ return scopeId;
109
+ };
110
+ const attachStyles = (hostRef) => {
111
+ const cmpMeta = hostRef.$cmpMeta$;
112
+ const elm = hostRef.$hostElement$;
113
+ const flags = cmpMeta.$flags$;
114
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
115
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
116
+ if (flags & 10 /* needsScopedEncapsulation */) {
117
+ // only required when we're NOT using native shadow dom (slot)
118
+ // or this browser doesn't support native shadow dom
119
+ // and this host element was NOT created with SSR
120
+ // let's pick out the inner content for slot projection
121
+ // create a node to represent where the original
122
+ // content was first placed, which is useful later on
123
+ // DOM WRITE!!
124
+ elm['s-sc'] = scopeId;
125
+ elm.classList.add(scopeId + '-h');
126
+ }
127
+ endAttachStyles();
128
+ };
129
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
130
+ /**
131
+ * Default style mode id
132
+ */
133
+ /**
134
+ * Reusable empty obj/array
135
+ * Don't add values to these!!
136
+ */
137
+ const EMPTY_OBJ = {};
138
+ const isDef = (v) => v != null;
139
+ const isComplexType = (o) => {
140
+ // https://jsperf.com/typeof-fn-object/5
141
+ o = typeof o;
142
+ return o === 'object' || o === 'function';
143
+ };
144
+ /**
145
+ * Production h() function based on Preact by
146
+ * Jason Miller (@developit)
147
+ * Licensed under the MIT License
148
+ * https://github.com/developit/preact/blob/master/LICENSE
149
+ *
150
+ * Modified for Stencil's compiler and vdom
151
+ */
152
+ // const stack: any[] = [];
153
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
154
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
155
+ const h = (nodeName, vnodeData, ...children) => {
156
+ let child = null;
157
+ let simple = false;
158
+ let lastSimple = false;
159
+ let vNodeChildren = [];
160
+ const walk = (c) => {
161
+ for (let i = 0; i < c.length; i++) {
162
+ child = c[i];
163
+ if (Array.isArray(child)) {
164
+ walk(child);
165
+ }
166
+ else if (child != null && typeof child !== 'boolean') {
167
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
168
+ child = String(child);
169
+ }
170
+ if (simple && lastSimple) {
171
+ // If the previous child was simple (string), we merge both
172
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
173
+ }
174
+ else {
175
+ // Append a new vNode, if it's text, we create a text vNode
176
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
177
+ }
178
+ lastSimple = simple;
179
+ }
180
+ }
181
+ };
182
+ walk(children);
183
+ if (vnodeData) {
184
+ {
185
+ const classData = vnodeData.className || vnodeData.class;
186
+ if (classData) {
187
+ vnodeData.class =
188
+ typeof classData !== 'object'
189
+ ? classData
190
+ : Object.keys(classData)
191
+ .filter((k) => classData[k])
192
+ .join(' ');
193
+ }
194
+ }
195
+ }
196
+ const vnode = newVNode(nodeName, null);
197
+ vnode.$attrs$ = vnodeData;
198
+ if (vNodeChildren.length > 0) {
199
+ vnode.$children$ = vNodeChildren;
200
+ }
201
+ return vnode;
202
+ };
203
+ const newVNode = (tag, text) => {
204
+ const vnode = {
205
+ $flags$: 0,
206
+ $tag$: tag,
207
+ $text$: text,
208
+ $elm$: null,
209
+ $children$: null,
210
+ };
211
+ {
212
+ vnode.$attrs$ = null;
213
+ }
214
+ return vnode;
215
+ };
216
+ const Host = {};
217
+ const isHost = (node) => node && node.$tag$ === Host;
218
+ /**
219
+ * Production setAccessor() function based on Preact by
220
+ * Jason Miller (@developit)
221
+ * Licensed under the MIT License
222
+ * https://github.com/developit/preact/blob/master/LICENSE
223
+ *
224
+ * Modified for Stencil's compiler and vdom
225
+ */
226
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
227
+ if (oldValue !== newValue) {
228
+ let isProp = isMemberInElement(elm, memberName);
229
+ let ln = memberName.toLowerCase();
230
+ if (memberName === 'class') {
231
+ const classList = elm.classList;
232
+ const oldClasses = parseClassList(oldValue);
233
+ const newClasses = parseClassList(newValue);
234
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
235
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
236
+ }
237
+ else if (memberName === 'ref') {
238
+ // minifier will clean this up
239
+ if (newValue) {
240
+ newValue(elm);
241
+ }
242
+ }
243
+ else if ((!isProp ) &&
244
+ memberName[0] === 'o' &&
245
+ memberName[1] === 'n') {
246
+ // Event Handlers
247
+ // so if the member name starts with "on" and the 3rd characters is
248
+ // a capital letter, and it's not already a member on the element,
249
+ // then we're assuming it's an event listener
250
+ if (memberName[2] === '-') {
251
+ // on- prefixed events
252
+ // allows to be explicit about the dom event to listen without any magic
253
+ // under the hood:
254
+ // <my-cmp on-click> // listens for "click"
255
+ // <my-cmp on-Click> // listens for "Click"
256
+ // <my-cmp on-ionChange> // listens for "ionChange"
257
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
258
+ memberName = memberName.slice(3);
259
+ }
260
+ else if (isMemberInElement(win, ln)) {
261
+ // standard event
262
+ // the JSX attribute could have been "onMouseOver" and the
263
+ // member name "onmouseover" is on the window's prototype
264
+ // so let's add the listener "mouseover", which is all lowercased
265
+ memberName = ln.slice(2);
266
+ }
267
+ else {
268
+ // custom event
269
+ // the JSX attribute could have been "onMyCustomEvent"
270
+ // so let's trim off the "on" prefix and lowercase the first character
271
+ // and add the listener "myCustomEvent"
272
+ // except for the first character, we keep the event name case
273
+ memberName = ln[2] + memberName.slice(3);
274
+ }
275
+ if (oldValue) {
276
+ plt.rel(elm, memberName, oldValue, false);
277
+ }
278
+ if (newValue) {
279
+ plt.ael(elm, memberName, newValue, false);
280
+ }
281
+ }
282
+ else {
283
+ // Set property if it exists and it's not a SVG
284
+ const isComplex = isComplexType(newValue);
285
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
286
+ try {
287
+ if (!elm.tagName.includes('-')) {
288
+ let n = newValue == null ? '' : newValue;
289
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
290
+ if (memberName === 'list') {
291
+ isProp = false;
292
+ }
293
+ else if (oldValue == null || elm[memberName] != n) {
294
+ elm[memberName] = n;
295
+ }
296
+ }
297
+ else {
298
+ elm[memberName] = newValue;
299
+ }
300
+ }
301
+ catch (e) { }
302
+ }
303
+ if (newValue == null || newValue === false) {
304
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
305
+ {
306
+ elm.removeAttribute(memberName);
307
+ }
308
+ }
309
+ }
310
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
311
+ newValue = newValue === true ? '' : newValue;
312
+ {
313
+ elm.setAttribute(memberName, newValue);
314
+ }
315
+ }
316
+ }
317
+ }
318
+ };
319
+ const parseClassListRegex = /\s/;
320
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
321
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
322
+ // if the element passed in is a shadow root, which is a document fragment
323
+ // then we want to be adding attrs/props to the shadow root's "host" element
324
+ // if it's not a shadow root, then we add attrs/props to the same element
325
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
326
+ ? newVnode.$elm$.host
327
+ : newVnode.$elm$;
328
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
329
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
330
+ {
331
+ // remove attributes no longer present on the vnode by setting them to undefined
332
+ for (memberName in oldVnodeAttrs) {
333
+ if (!(memberName in newVnodeAttrs)) {
334
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
335
+ }
336
+ }
337
+ }
338
+ // add new & update changed attributes
339
+ for (memberName in newVnodeAttrs) {
340
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
341
+ }
342
+ };
343
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
344
+ // tslint:disable-next-line: prefer-const
345
+ let newVNode = newParentVNode.$children$[childIndex];
346
+ let i = 0;
347
+ let elm;
348
+ let childNode;
349
+ if (newVNode.$text$ !== null) {
350
+ // create text node
351
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
352
+ }
353
+ else {
354
+ // create element
355
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
356
+ // add css classes, attrs, props, listeners, etc.
357
+ {
358
+ updateElement(null, newVNode, isSvgMode);
359
+ }
360
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
361
+ // if there is a scopeId and this is the initial render
362
+ // then let's add the scopeId as a css class
363
+ elm.classList.add((elm['s-si'] = scopeId));
364
+ }
365
+ if (newVNode.$children$) {
366
+ for (i = 0; i < newVNode.$children$.length; ++i) {
367
+ // create the node
368
+ childNode = createElm(oldParentVNode, newVNode, i);
369
+ // return node could have been null
370
+ if (childNode) {
371
+ // append our new node
372
+ elm.appendChild(childNode);
373
+ }
374
+ }
375
+ }
376
+ }
377
+ return elm;
378
+ };
379
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
380
+ let containerElm = (parentElm);
381
+ let childNode;
382
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
383
+ containerElm = containerElm.shadowRoot;
384
+ }
385
+ for (; startIdx <= endIdx; ++startIdx) {
386
+ if (vnodes[startIdx]) {
387
+ childNode = createElm(null, parentVNode, startIdx);
388
+ if (childNode) {
389
+ vnodes[startIdx].$elm$ = childNode;
390
+ containerElm.insertBefore(childNode, before);
391
+ }
392
+ }
393
+ }
394
+ };
395
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
396
+ for (; startIdx <= endIdx; ++startIdx) {
397
+ if ((vnode = vnodes[startIdx])) {
398
+ elm = vnode.$elm$;
399
+ callNodeRefs(vnode);
400
+ // remove the vnode's element from the dom
401
+ elm.remove();
402
+ }
403
+ }
404
+ };
405
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
406
+ let oldStartIdx = 0;
407
+ let newStartIdx = 0;
408
+ let oldEndIdx = oldCh.length - 1;
409
+ let oldStartVnode = oldCh[0];
410
+ let oldEndVnode = oldCh[oldEndIdx];
411
+ let newEndIdx = newCh.length - 1;
412
+ let newStartVnode = newCh[0];
413
+ let newEndVnode = newCh[newEndIdx];
414
+ let node;
415
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
416
+ if (oldStartVnode == null) {
417
+ // Vnode might have been moved left
418
+ oldStartVnode = oldCh[++oldStartIdx];
419
+ }
420
+ else if (oldEndVnode == null) {
421
+ oldEndVnode = oldCh[--oldEndIdx];
422
+ }
423
+ else if (newStartVnode == null) {
424
+ newStartVnode = newCh[++newStartIdx];
425
+ }
426
+ else if (newEndVnode == null) {
427
+ newEndVnode = newCh[--newEndIdx];
428
+ }
429
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
430
+ patch(oldStartVnode, newStartVnode);
431
+ oldStartVnode = oldCh[++oldStartIdx];
432
+ newStartVnode = newCh[++newStartIdx];
433
+ }
434
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
435
+ patch(oldEndVnode, newEndVnode);
436
+ oldEndVnode = oldCh[--oldEndIdx];
437
+ newEndVnode = newCh[--newEndIdx];
438
+ }
439
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
440
+ patch(oldStartVnode, newEndVnode);
441
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
442
+ oldStartVnode = oldCh[++oldStartIdx];
443
+ newEndVnode = newCh[--newEndIdx];
444
+ }
445
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
446
+ patch(oldEndVnode, newStartVnode);
447
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
448
+ oldEndVnode = oldCh[--oldEndIdx];
449
+ newStartVnode = newCh[++newStartIdx];
450
+ }
451
+ else {
452
+ {
453
+ // new element
454
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
455
+ newStartVnode = newCh[++newStartIdx];
456
+ }
457
+ if (node) {
458
+ {
459
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
460
+ }
461
+ }
462
+ }
463
+ }
464
+ if (oldStartIdx > oldEndIdx) {
465
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
466
+ }
467
+ else if (newStartIdx > newEndIdx) {
468
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
469
+ }
470
+ };
471
+ const isSameVnode = (vnode1, vnode2) => {
472
+ // compare if two vnode to see if they're "technically" the same
473
+ // need to have the same element tag, and same key to be the same
474
+ if (vnode1.$tag$ === vnode2.$tag$) {
475
+ return true;
476
+ }
477
+ return false;
478
+ };
479
+ const patch = (oldVNode, newVNode) => {
480
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
481
+ const oldChildren = oldVNode.$children$;
482
+ const newChildren = newVNode.$children$;
483
+ const text = newVNode.$text$;
484
+ if (text === null) {
485
+ // element node
486
+ {
487
+ {
488
+ // either this is the first render of an element OR it's an update
489
+ // AND we already know it's possible it could have changed
490
+ // this updates the element's css classes, attrs, props, listeners, etc.
491
+ updateElement(oldVNode, newVNode, isSvgMode);
492
+ }
493
+ }
494
+ if (oldChildren !== null && newChildren !== null) {
495
+ // looks like there's child vnodes for both the old and new vnodes
496
+ updateChildren(elm, oldChildren, newVNode, newChildren);
497
+ }
498
+ else if (newChildren !== null) {
499
+ // no old child vnodes, but there are new child vnodes to add
500
+ if (oldVNode.$text$ !== null) {
501
+ // the old vnode was text, so be sure to clear it out
502
+ elm.textContent = '';
503
+ }
504
+ // add the new vnode children
505
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
506
+ }
507
+ else if (oldChildren !== null) {
508
+ // no new child vnodes, but there are old child vnodes to remove
509
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
510
+ }
511
+ }
512
+ else if (oldVNode.$text$ !== text) {
513
+ // update the text content for the text only vnode
514
+ // and also only if the text is different than before
515
+ elm.data = text;
516
+ }
517
+ };
518
+ const callNodeRefs = (vNode) => {
519
+ {
520
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
521
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
522
+ }
523
+ };
524
+ const renderVdom = (hostRef, renderFnResults) => {
525
+ const hostElm = hostRef.$hostElement$;
526
+ const cmpMeta = hostRef.$cmpMeta$;
527
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
528
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
529
+ hostTagName = hostElm.tagName;
530
+ if (cmpMeta.$attrsToReflect$) {
531
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
532
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
533
+ }
534
+ rootVnode.$tag$ = null;
535
+ rootVnode.$flags$ |= 4 /* isHost */;
536
+ hostRef.$vnode$ = rootVnode;
537
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
538
+ {
539
+ scopeId = hostElm['s-sc'];
540
+ }
541
+ // synchronous patch
542
+ patch(oldVNode, rootVnode);
543
+ };
544
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
545
+ const createEvent = (ref, name, flags) => {
546
+ const elm = getElement(ref);
547
+ return {
548
+ emit: (detail) => {
549
+ return emitEvent(elm, name, {
550
+ bubbles: !!(flags & 4 /* Bubbles */),
551
+ composed: !!(flags & 2 /* Composed */),
552
+ cancelable: !!(flags & 1 /* Cancellable */),
553
+ detail,
554
+ });
555
+ },
556
+ };
557
+ };
558
+ /**
559
+ * Helper function to create & dispatch a custom Event on a provided target
560
+ * @param elm the target of the Event
561
+ * @param name the name to give the custom Event
562
+ * @param opts options for configuring a custom Event
563
+ * @returns the custom Event
564
+ */
565
+ const emitEvent = (elm, name, opts) => {
566
+ const ev = plt.ce(name, opts);
567
+ elm.dispatchEvent(ev);
568
+ return ev;
569
+ };
570
+ const attachToAncestor = (hostRef, ancestorComponent) => {
571
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
572
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
573
+ }
574
+ };
575
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
576
+ {
577
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
578
+ }
579
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
580
+ hostRef.$flags$ |= 512 /* needsRerender */;
581
+ return;
582
+ }
583
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
584
+ // there is no ancestor component or the ancestor component
585
+ // has already fired off its lifecycle update then
586
+ // fire off the initial update
587
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
588
+ return writeTask(dispatch) ;
589
+ };
590
+ const dispatchHooks = (hostRef, isInitialLoad) => {
591
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
592
+ const instance = hostRef.$lazyInstance$ ;
593
+ let promise;
594
+ if (isInitialLoad) {
595
+ {
596
+ promise = safeCall(instance, 'componentWillLoad');
597
+ }
598
+ }
599
+ endSchedule();
600
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
601
+ };
602
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
603
+ // updateComponent
604
+ const elm = hostRef.$hostElement$;
605
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
606
+ const rc = elm['s-rc'];
607
+ if (isInitialLoad) {
608
+ // DOM WRITE!
609
+ attachStyles(hostRef);
610
+ }
611
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
612
+ {
613
+ callRender(hostRef, instance);
614
+ }
615
+ if (rc) {
616
+ // ok, so turns out there are some child host elements
617
+ // waiting on this parent element to load
618
+ // let's fire off all update callbacks waiting
619
+ rc.map((cb) => cb());
620
+ elm['s-rc'] = undefined;
621
+ }
622
+ endRender();
623
+ endUpdate();
624
+ {
625
+ const childrenPromises = elm['s-p'];
626
+ const postUpdate = () => postUpdateComponent(hostRef);
627
+ if (childrenPromises.length === 0) {
628
+ postUpdate();
629
+ }
630
+ else {
631
+ Promise.all(childrenPromises).then(postUpdate);
632
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
633
+ childrenPromises.length = 0;
634
+ }
635
+ }
636
+ };
637
+ const callRender = (hostRef, instance, elm) => {
638
+ try {
639
+ instance = instance.render() ;
640
+ {
641
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
642
+ }
643
+ {
644
+ hostRef.$flags$ |= 2 /* hasRendered */;
645
+ }
646
+ {
647
+ {
648
+ // looks like we've got child nodes to render into this host element
649
+ // or we need to update the css class/attrs on the host element
650
+ // DOM WRITE!
651
+ {
652
+ renderVdom(hostRef, instance);
653
+ }
654
+ }
655
+ }
656
+ }
657
+ catch (e) {
658
+ consoleError(e, hostRef.$hostElement$);
659
+ }
660
+ return null;
661
+ };
662
+ const postUpdateComponent = (hostRef) => {
663
+ const tagName = hostRef.$cmpMeta$.$tagName$;
664
+ const elm = hostRef.$hostElement$;
665
+ const endPostUpdate = createTime('postUpdate', tagName);
666
+ const ancestorComponent = hostRef.$ancestorComponent$;
667
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
668
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
669
+ {
670
+ // DOM WRITE!
671
+ addHydratedFlag(elm);
672
+ }
673
+ endPostUpdate();
674
+ {
675
+ hostRef.$onReadyResolve$(elm);
676
+ if (!ancestorComponent) {
677
+ appDidLoad();
678
+ }
679
+ }
680
+ }
681
+ else {
682
+ endPostUpdate();
683
+ }
684
+ {
685
+ hostRef.$onInstanceResolve$(elm);
686
+ }
687
+ // load events fire from bottom to top
688
+ // the deepest elements load first then bubbles up
689
+ {
690
+ if (hostRef.$onRenderResolve$) {
691
+ hostRef.$onRenderResolve$();
692
+ hostRef.$onRenderResolve$ = undefined;
693
+ }
694
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
695
+ nextTick(() => scheduleUpdate(hostRef, false));
696
+ }
697
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
698
+ }
699
+ // ( •_•)
700
+ // ( •_•)>⌐■-■
701
+ // (⌐■_■)
702
+ };
703
+ const appDidLoad = (who) => {
704
+ // on appload
705
+ // we have finish the first big initial render
706
+ {
707
+ addHydratedFlag(doc.documentElement);
708
+ }
709
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
710
+ };
711
+ const safeCall = (instance, method, arg) => {
712
+ if (instance && instance[method]) {
713
+ try {
714
+ return instance[method](arg);
715
+ }
716
+ catch (e) {
717
+ consoleError(e);
718
+ }
719
+ }
720
+ return undefined;
721
+ };
722
+ const then = (promise, thenFn) => {
723
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
724
+ };
725
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
726
+ ;
727
+ const parsePropertyValue = (propValue, propType) => {
728
+ // ensure this value is of the correct prop type
729
+ if (propValue != null && !isComplexType(propValue)) {
730
+ if (propType & 4 /* Boolean */) {
731
+ // per the HTML spec, any string value means it is a boolean true value
732
+ // but we'll cheat here and say that the string "false" is the boolean false
733
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
734
+ }
735
+ if (propType & 2 /* Number */) {
736
+ // force it to be a number
737
+ return parseFloat(propValue);
738
+ }
739
+ if (propType & 1 /* String */) {
740
+ // could have been passed as a number or boolean
741
+ // but we still want it as a string
742
+ return String(propValue);
743
+ }
744
+ // redundant return here for better minification
745
+ return propValue;
746
+ }
747
+ // not sure exactly what type we want
748
+ // so no need to change to a different type
749
+ return propValue;
750
+ };
751
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
752
+ const setValue = (ref, propName, newVal, cmpMeta) => {
753
+ // check our new property value against our internal value
754
+ const hostRef = getHostRef(ref);
755
+ const elm = hostRef.$hostElement$ ;
756
+ const oldVal = hostRef.$instanceValues$.get(propName);
757
+ const flags = hostRef.$flags$;
758
+ const instance = hostRef.$lazyInstance$ ;
759
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
760
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
761
+ // gadzooks! the property's value has changed!!
762
+ // set our new value!
763
+ hostRef.$instanceValues$.set(propName, newVal);
764
+ if (instance) {
765
+ // get an array of method names of watch functions to call
766
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
767
+ const watchMethods = cmpMeta.$watchers$[propName];
768
+ if (watchMethods) {
769
+ // this instance is watching for when this property changed
770
+ watchMethods.map((watchMethodName) => {
771
+ try {
772
+ // fire off each of the watch methods that are watching this property
773
+ instance[watchMethodName](newVal, oldVal, propName);
774
+ }
775
+ catch (e) {
776
+ consoleError(e, elm);
777
+ }
778
+ });
779
+ }
780
+ }
781
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
782
+ // looks like this value actually changed, so we've got work to do!
783
+ // but only if we've already rendered, otherwise just chill out
784
+ // queue that we need to do an update, but don't worry about queuing
785
+ // up millions cuz this function ensures it only runs once
786
+ scheduleUpdate(hostRef, false);
787
+ }
788
+ }
789
+ }
790
+ };
791
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
792
+ if (cmpMeta.$members$) {
793
+ if (Cstr.watchers) {
794
+ cmpMeta.$watchers$ = Cstr.watchers;
795
+ }
796
+ // It's better to have a const than two Object.entries()
797
+ const members = Object.entries(cmpMeta.$members$);
798
+ const prototype = Cstr.prototype;
799
+ members.map(([memberName, [memberFlags]]) => {
800
+ if ((memberFlags & 31 /* Prop */ ||
801
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
802
+ // proxyComponent - prop
803
+ Object.defineProperty(prototype, memberName, {
804
+ get() {
805
+ // proxyComponent, get value
806
+ return getValue(this, memberName);
807
+ },
808
+ set(newValue) {
809
+ // proxyComponent, set value
810
+ setValue(this, memberName, newValue, cmpMeta);
811
+ },
812
+ configurable: true,
813
+ enumerable: true,
814
+ });
815
+ }
816
+ else if (flags & 1 /* isElementConstructor */ &&
817
+ memberFlags & 64 /* Method */) {
818
+ // proxyComponent - method
819
+ Object.defineProperty(prototype, memberName, {
820
+ value(...args) {
821
+ const ref = getHostRef(this);
822
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
823
+ },
824
+ });
825
+ }
826
+ });
827
+ if ((flags & 1 /* isElementConstructor */)) {
828
+ const attrNameToPropName = new Map();
829
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
830
+ plt.jmp(() => {
831
+ const propName = attrNameToPropName.get(attrName);
832
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
833
+ // in the case where an attribute was set inline.
834
+ // ```html
835
+ // <my-component some-attribute="some-value"></my-component>
836
+ // ```
837
+ //
838
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
839
+ // programmatically changes it before it has been upgraded as shown below:
840
+ //
841
+ // ```html
842
+ // <!-- this component has _not_ been upgraded yet -->
843
+ // <my-component id="test" some-attribute="some-value"></my-component>
844
+ // <script>
845
+ // // grab non-upgraded component
846
+ // el = document.querySelector("#test");
847
+ // el.someAttribute = "another-value";
848
+ // // upgrade component
849
+ // customElements.define('my-component', MyComponent);
850
+ // </script>
851
+ // ```
852
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
853
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
854
+ // to the value that was set inline i.e. "some-value" from above example. When
855
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
856
+ //
857
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
858
+ // by connectedCallback as this attributeChangedCallback will not fire.
859
+ //
860
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
861
+ //
862
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
863
+ // properties here given that this goes against best practices outlined here
864
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
865
+ if (this.hasOwnProperty(propName)) {
866
+ newValue = this[propName];
867
+ delete this[propName];
868
+ }
869
+ else if (prototype.hasOwnProperty(propName) &&
870
+ typeof this[propName] === 'number' &&
871
+ this[propName] == newValue) {
872
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
873
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
874
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
875
+ return;
876
+ }
877
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
878
+ });
879
+ };
880
+ // create an array of attributes to observe
881
+ // and also create a map of html attribute name to js property name
882
+ Cstr.observedAttributes = members
883
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
884
+ .map(([propName, m]) => {
885
+ const attrName = m[1] || propName;
886
+ attrNameToPropName.set(attrName, propName);
887
+ if (m[0] & 512 /* ReflectAttr */) {
888
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
889
+ }
890
+ return attrName;
891
+ });
892
+ }
893
+ }
894
+ return Cstr;
895
+ };
896
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
897
+ // initializeComponent
898
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
899
+ {
900
+ // we haven't initialized this element yet
901
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
902
+ // lazy loaded components
903
+ // request the component's implementation to be
904
+ // wired up with the host element
905
+ Cstr = loadModule(cmpMeta);
906
+ if (Cstr.then) {
907
+ // Await creates a micro-task avoid if possible
908
+ const endLoad = uniqueTime();
909
+ Cstr = await Cstr;
910
+ endLoad();
911
+ }
912
+ if (!Cstr.isProxied) {
913
+ // we've never proxied this Constructor before
914
+ // let's add the getters/setters to its prototype before
915
+ // the first time we create an instance of the implementation
916
+ {
917
+ cmpMeta.$watchers$ = Cstr.watchers;
918
+ }
919
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
920
+ Cstr.isProxied = true;
921
+ }
922
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
923
+ // ok, time to construct the instance
924
+ // but let's keep track of when we start and stop
925
+ // so that the getters/setters don't incorrectly step on data
926
+ {
927
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
928
+ }
929
+ // construct the lazy-loaded component implementation
930
+ // passing the hostRef is very important during
931
+ // construction in order to directly wire together the
932
+ // host element and the lazy-loaded instance
933
+ try {
934
+ new Cstr(hostRef);
935
+ }
936
+ catch (e) {
937
+ consoleError(e);
938
+ }
939
+ {
940
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
941
+ }
942
+ {
943
+ hostRef.$flags$ |= 128 /* isWatchReady */;
944
+ }
945
+ endNewInstance();
946
+ }
947
+ if (Cstr.style) {
948
+ // this component has styles but we haven't registered them yet
949
+ let style = Cstr.style;
950
+ const scopeId = getScopeId(cmpMeta);
951
+ if (!styles.has(scopeId)) {
952
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
953
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
954
+ endRegisterStyles();
955
+ }
956
+ }
957
+ }
958
+ // we've successfully created a lazy instance
959
+ const ancestorComponent = hostRef.$ancestorComponent$;
960
+ const schedule = () => scheduleUpdate(hostRef, true);
961
+ if (ancestorComponent && ancestorComponent['s-rc']) {
962
+ // this is the initial load and this component it has an ancestor component
963
+ // but the ancestor component has NOT fired its will update lifecycle yet
964
+ // so let's just cool our jets and wait for the ancestor to continue first
965
+ // this will get fired off when the ancestor component
966
+ // finally gets around to rendering its lazy self
967
+ // fire off the initial update
968
+ ancestorComponent['s-rc'].push(schedule);
969
+ }
970
+ else {
971
+ schedule();
972
+ }
973
+ };
974
+ const connectedCallback = (elm) => {
975
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
976
+ const hostRef = getHostRef(elm);
977
+ const cmpMeta = hostRef.$cmpMeta$;
978
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
979
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
980
+ // first time this component has connected
981
+ hostRef.$flags$ |= 1 /* hasConnected */;
982
+ {
983
+ // find the first ancestor component (if there is one) and register
984
+ // this component as one of the actively loading child components for its ancestor
985
+ let ancestorComponent = elm;
986
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
987
+ // climb up the ancestors looking for the first
988
+ // component that hasn't finished its lifecycle update yet
989
+ if (ancestorComponent['s-p']) {
990
+ // we found this components first ancestor component
991
+ // keep a reference to this component's ancestor component
992
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
993
+ break;
994
+ }
995
+ }
996
+ }
997
+ // Lazy properties
998
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
999
+ if (cmpMeta.$members$) {
1000
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1001
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1002
+ const value = elm[memberName];
1003
+ delete elm[memberName];
1004
+ elm[memberName] = value;
1005
+ }
1006
+ });
1007
+ }
1008
+ {
1009
+ initializeComponent(elm, hostRef, cmpMeta);
1010
+ }
1011
+ }
1012
+ endConnected();
1013
+ }
1014
+ };
1015
+ const disconnectedCallback = (elm) => {
1016
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1017
+ getHostRef(elm);
1018
+ }
1019
+ };
1020
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1021
+ const endBootstrap = createTime();
1022
+ const cmpTags = [];
1023
+ const exclude = options.exclude || [];
1024
+ const customElements = win.customElements;
1025
+ const head = doc.head;
1026
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1027
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1028
+ const deferredConnectedCallbacks = [];
1029
+ let appLoadFallback;
1030
+ let isBootstrapping = true;
1031
+ Object.assign(plt, options);
1032
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1033
+ lazyBundles.map((lazyBundle) => {
1034
+ lazyBundle[1].map((compactMeta) => {
1035
+ const cmpMeta = {
1036
+ $flags$: compactMeta[0],
1037
+ $tagName$: compactMeta[1],
1038
+ $members$: compactMeta[2],
1039
+ $listeners$: compactMeta[3],
1040
+ };
1041
+ {
1042
+ cmpMeta.$members$ = compactMeta[2];
1043
+ }
1044
+ {
1045
+ cmpMeta.$attrsToReflect$ = [];
1046
+ }
1047
+ {
1048
+ cmpMeta.$watchers$ = {};
1049
+ }
1050
+ const tagName = cmpMeta.$tagName$;
1051
+ const HostElement = class extends HTMLElement {
1052
+ // StencilLazyHost
1053
+ constructor(self) {
1054
+ // @ts-ignore
1055
+ super(self);
1056
+ self = this;
1057
+ registerHost(self, cmpMeta);
1058
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1059
+ // this component is using shadow dom
1060
+ // and this browser supports shadow dom
1061
+ // add the read-only property "shadowRoot" to the host element
1062
+ // adding the shadow root build conditionals to minimize runtime
1063
+ {
1064
+ {
1065
+ self.attachShadow({ mode: 'open' });
1066
+ }
1067
+ }
1068
+ }
1069
+ }
1070
+ connectedCallback() {
1071
+ if (appLoadFallback) {
1072
+ clearTimeout(appLoadFallback);
1073
+ appLoadFallback = null;
1074
+ }
1075
+ if (isBootstrapping) {
1076
+ // connectedCallback will be processed once all components have been registered
1077
+ deferredConnectedCallbacks.push(this);
1078
+ }
1079
+ else {
1080
+ plt.jmp(() => connectedCallback(this));
1081
+ }
1082
+ }
1083
+ disconnectedCallback() {
1084
+ plt.jmp(() => disconnectedCallback(this));
1085
+ }
1086
+ componentOnReady() {
1087
+ return getHostRef(this).$onReadyPromise$;
1088
+ }
1089
+ };
1090
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1091
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1092
+ cmpTags.push(tagName);
1093
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1094
+ }
1095
+ });
1096
+ });
1097
+ {
1098
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1099
+ visibilityStyle.setAttribute('data-styles', '');
1100
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1101
+ }
1102
+ // Process deferred connectedCallbacks now all components have been registered
1103
+ isBootstrapping = false;
1104
+ if (deferredConnectedCallbacks.length) {
1105
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1106
+ }
1107
+ else {
1108
+ {
1109
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1110
+ }
1111
+ }
1112
+ // Fallback appLoad event
1113
+ endBootstrap();
1114
+ };
1115
+ const hostRefs = new WeakMap();
1116
+ const getHostRef = (ref) => hostRefs.get(ref);
1117
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1118
+ const registerHost = (elm, cmpMeta) => {
1119
+ const hostRef = {
1120
+ $flags$: 0,
1121
+ $hostElement$: elm,
1122
+ $cmpMeta$: cmpMeta,
1123
+ $instanceValues$: new Map(),
1124
+ };
1125
+ {
1126
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1127
+ }
1128
+ {
1129
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1130
+ elm['s-p'] = [];
1131
+ elm['s-rc'] = [];
1132
+ }
1133
+ return hostRefs.set(elm, hostRef);
1134
+ };
1135
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1136
+ const consoleError = (e, el) => (0, console.error)(e, el);
1137
+ const cmpModules = /*@__PURE__*/ new Map();
1138
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1139
+ // loadModuleImport
1140
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1141
+ const bundleId = cmpMeta.$lazyBundleId$;
1142
+ const module = cmpModules.get(bundleId) ;
1143
+ if (module) {
1144
+ return module[exportName];
1145
+ }
1146
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1147
+ /* webpackInclude: /\.entry\.js$/ */
1148
+ /* webpackExclude: /\.system\.entry\.js$/ */
1149
+ /* webpackMode: "lazy" */
1150
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1151
+ {
1152
+ cmpModules.set(bundleId, importedModule);
1153
+ }
1154
+ return importedModule[exportName];
1155
+ }, consoleError);
1156
+ };
1157
+ const styles = new Map();
1158
+ const queueDomReads = [];
1159
+ const queueDomWrites = [];
1160
+ const queueTask = (queue, write) => (cb) => {
1161
+ queue.push(cb);
1162
+ if (!queuePending) {
1163
+ queuePending = true;
1164
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1165
+ nextTick(flush);
1166
+ }
1167
+ else {
1168
+ plt.raf(flush);
1169
+ }
1170
+ }
1171
+ };
1172
+ const consume = (queue) => {
1173
+ for (let i = 0; i < queue.length; i++) {
1174
+ try {
1175
+ queue[i](performance.now());
1176
+ }
1177
+ catch (e) {
1178
+ consoleError(e);
1179
+ }
1180
+ }
1181
+ queue.length = 0;
1182
+ };
1183
+ const flush = () => {
1184
+ // always force a bunch of medium callbacks to run, but still have
1185
+ // a throttle on how many can run in a certain time
1186
+ // DOM READS!!!
1187
+ consume(queueDomReads);
1188
+ // DOM WRITES!!!
1189
+ {
1190
+ consume(queueDomWrites);
1191
+ if ((queuePending = queueDomReads.length > 0)) {
1192
+ // still more to do yet, but we've run out of time
1193
+ // let's let this thing cool off and try again in the next tick
1194
+ plt.raf(flush);
1195
+ }
1196
+ }
1197
+ };
1198
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1199
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1200
+
1201
+ exports.Host = Host;
1202
+ exports.bootstrapLazy = bootstrapLazy;
1203
+ exports.createEvent = createEvent;
1204
+ exports.getElement = getElement;
1205
+ exports.h = h;
1206
+ exports.promiseResolve = promiseResolve;
1207
+ exports.registerInstance = registerInstance;