@everymatrix/general-input 1.44.0 → 1.45.2

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