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