@sankhyalabs/sankhyablocks 1.1.23 → 1.1.27

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 (186) hide show
  1. package/dist/cjs/ApplicationUtils-05b74ee9.js +39 -0
  2. package/dist/cjs/AssetsUtils-bd004f63.js +24 -0
  3. package/dist/cjs/CSSVarsUtils-75ca9c64.js +19 -0
  4. package/dist/cjs/_commonjsHelpers-537d719a.js +20 -0
  5. package/dist/cjs/ez-action-chip.cjs.entry.js +27 -0
  6. package/dist/cjs/ez-application.cjs.entry.js +26 -0
  7. package/dist/cjs/ez-button_4.cjs.entry.js +660 -0
  8. package/dist/cjs/ez-calendar.cjs.entry.js +223 -0
  9. package/dist/cjs/ez-collapsible-box.cjs.entry.js +47 -0
  10. package/dist/cjs/ez-combo-box.cjs.entry.js +278 -0
  11. package/dist/cjs/ez-date-input.cjs.entry.js +102 -0
  12. package/dist/cjs/ez-date-time-input.cjs.entry.js +145 -0
  13. package/dist/cjs/ez-dialog.cjs.entry.js +89 -0
  14. package/dist/cjs/ez-form.cjs.entry.js +785 -0
  15. package/dist/cjs/ez-grid.cjs.entry.js +110485 -0
  16. package/dist/cjs/ez-icon.cjs.entry.js +41 -0
  17. package/dist/cjs/ez-label-chip.cjs.entry.js +104 -0
  18. package/dist/cjs/ez-modal_2.cjs.entry.js +316 -0
  19. package/dist/cjs/ez-number-input.cjs.entry.js +86 -0
  20. package/dist/cjs/ez-popover.cjs.entry.js +120 -0
  21. package/dist/cjs/ez-popup.cjs.entry.js +48 -0
  22. package/dist/cjs/ez-search.cjs.entry.js +64 -0
  23. package/dist/cjs/ez-tabselector.cjs.entry.js +198 -0
  24. package/dist/cjs/ez-text-area.cjs.entry.js +114 -0
  25. package/dist/cjs/ez-text-input.cjs.entry.js +201 -0
  26. package/dist/cjs/ez-time-input.cjs.entry.js +118 -0
  27. package/dist/cjs/ez-toast.cjs.entry.js +44 -0
  28. package/dist/cjs/ez-upload.cjs.entry.js +356 -0
  29. package/dist/cjs/index-6ac5268e.js +1769 -0
  30. package/dist/cjs/loader.cjs.js +2 -2
  31. package/dist/cjs/sankhyablocks.cjs.js +2 -2
  32. package/dist/cjs/snk-application.cjs.entry.js +52 -1313
  33. package/dist/cjs/test-du.cjs.entry.js +76 -0
  34. package/dist/collection/collection-manifest.json +36 -1
  35. package/dist/collection/components/snk-application/snk-application.js +8 -4
  36. package/dist/{collection/temp → components}/ApplicationUtils.js +37 -31
  37. package/dist/components/AssetsUtils.js +22 -0
  38. package/dist/components/CSSVarsUtils.js +17 -0
  39. package/dist/components/_commonjsHelpers.js +17 -0
  40. package/dist/components/ez-action-chip.js +44 -0
  41. package/dist/components/ez-application.js +39 -0
  42. package/dist/components/ez-button.js +6 -0
  43. package/dist/components/ez-button2.js +105 -0
  44. package/dist/components/ez-calendar.js +6 -0
  45. package/dist/components/ez-calendar2.js +242 -0
  46. package/dist/components/ez-check.js +6 -0
  47. package/dist/components/ez-check2.js +94 -0
  48. package/dist/components/ez-collapsible-box.js +67 -0
  49. package/dist/components/ez-combo-box.js +6 -0
  50. package/dist/components/ez-combo-box2.js +311 -0
  51. package/dist/components/ez-date-input.js +135 -0
  52. package/dist/components/ez-date-time-input.js +179 -0
  53. package/dist/components/ez-dialog.js +124 -0
  54. package/dist/components/ez-form.js +6 -0
  55. package/dist/components/ez-form2.js +807 -0
  56. package/dist/components/ez-grid.js +110576 -0
  57. package/dist/components/ez-icon.js +6 -0
  58. package/dist/components/ez-icon2.js +56 -0
  59. package/dist/components/ez-label-chip.js +125 -0
  60. package/dist/components/ez-list.js +6 -0
  61. package/dist/components/ez-list2.js +523 -0
  62. package/dist/components/ez-modal.js +6 -0
  63. package/dist/components/ez-modal2.js +82 -0
  64. package/dist/components/ez-number-input.js +115 -0
  65. package/dist/components/ez-popover.js +145 -0
  66. package/dist/components/ez-popup.js +67 -0
  67. package/dist/components/ez-search.js +100 -0
  68. package/dist/components/ez-tabselector.js +6 -0
  69. package/dist/components/ez-tabselector2.js +213 -0
  70. package/dist/components/ez-text-area.js +137 -0
  71. package/dist/components/ez-text-input.js +6 -0
  72. package/dist/components/ez-text-input2.js +223 -0
  73. package/dist/components/ez-time-input.js +153 -0
  74. package/dist/components/ez-toast.js +64 -0
  75. package/dist/components/ez-upload.js +382 -0
  76. package/dist/components/grid-config.js +6 -0
  77. package/dist/components/grid-config2.js +318 -0
  78. package/dist/components/select-box.js +6 -0
  79. package/dist/components/select-box2.js +47 -0
  80. package/dist/components/snk-application.js +5 -1266
  81. package/dist/components/test-du.js +101 -0
  82. package/dist/esm/ApplicationUtils-e0b6d857.js +37 -0
  83. package/dist/esm/AssetsUtils-98074c9c.js +22 -0
  84. package/dist/esm/CSSVarsUtils-0787c3f3.js +17 -0
  85. package/dist/esm/_commonjsHelpers-9943807e.js +17 -0
  86. package/dist/esm/ez-action-chip.entry.js +23 -0
  87. package/dist/esm/ez-application.entry.js +22 -0
  88. package/dist/esm/ez-button_4.entry.js +653 -0
  89. package/dist/esm/ez-calendar.entry.js +219 -0
  90. package/dist/esm/ez-collapsible-box.entry.js +43 -0
  91. package/dist/esm/ez-combo-box.entry.js +274 -0
  92. package/dist/esm/ez-date-input.entry.js +98 -0
  93. package/dist/esm/ez-date-time-input.entry.js +141 -0
  94. package/dist/esm/ez-dialog.entry.js +85 -0
  95. package/dist/esm/ez-form.entry.js +781 -0
  96. package/dist/esm/ez-grid.entry.js +110481 -0
  97. package/dist/esm/ez-icon.entry.js +37 -0
  98. package/dist/esm/ez-label-chip.entry.js +100 -0
  99. package/dist/esm/ez-modal_2.entry.js +311 -0
  100. package/dist/esm/ez-number-input.entry.js +82 -0
  101. package/dist/esm/ez-popover.entry.js +116 -0
  102. package/dist/esm/ez-popup.entry.js +44 -0
  103. package/dist/esm/ez-search.entry.js +60 -0
  104. package/dist/esm/ez-tabselector.entry.js +194 -0
  105. package/dist/esm/ez-text-area.entry.js +110 -0
  106. package/dist/esm/ez-text-input.entry.js +197 -0
  107. package/dist/esm/ez-time-input.entry.js +114 -0
  108. package/dist/esm/ez-toast.entry.js +40 -0
  109. package/dist/esm/ez-upload.entry.js +352 -0
  110. package/dist/esm/index-df166135.js +1738 -0
  111. package/dist/esm/loader.js +2 -2
  112. package/dist/esm/sankhyablocks.js +2 -2
  113. package/dist/esm/snk-application.entry.js +6 -1267
  114. package/dist/esm/test-du.entry.js +72 -0
  115. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-action-chip/ez-action-chip.css +67 -0
  116. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-application/ez-application.css +3 -0
  117. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-button/ez-button.css +180 -0
  118. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-calendar/ez-calendar.css +319 -0
  119. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-check/ez-check.css +327 -0
  120. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +162 -0
  121. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-combo-box/ez-combo-box.css +217 -0
  122. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-input/ez-date-input.css +49 -0
  123. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-time-input/ez-date-time-input.css +44 -0
  124. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-dialog/ez-dialog.css +527 -0
  125. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-form/ez-form.css +5 -0
  126. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/ez-grid.css +31 -0
  127. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +129 -0
  128. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +10 -0
  129. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-icon/ez-icon.css +176 -0
  130. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-label-chip/ez-label-chip.css +139 -0
  131. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-list/ez-list.css +335 -0
  132. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-modal/ez-modal.css +358 -0
  133. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-number-input/ez-number-input.css +4 -0
  134. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popover/ez-popover.css +44 -0
  135. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popup/ez-popup.css +405 -0
  136. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-search/ez-search.css +3 -0
  137. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-tabselector/ez-tabselector.css +138 -0
  138. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-area/ez-text-area.css +165 -0
  139. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-input/ez-text-input.css +196 -0
  140. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-time-input/ez-time-input.css +10 -0
  141. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-toast/ez-toast.css +127 -0
  142. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-upload/ez-upload.css +568 -0
  143. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/test-du/test-du.css +3 -0
  144. package/dist/sankhyablocks/p-08e1cded.entry.js +1 -0
  145. package/dist/sankhyablocks/p-0a77ac95.entry.js +57 -0
  146. package/dist/sankhyablocks/p-112455b1.js +1 -0
  147. package/dist/sankhyablocks/p-126c4aaa.entry.js +1 -0
  148. package/dist/sankhyablocks/p-1421b89a.entry.js +1 -0
  149. package/dist/sankhyablocks/p-1beadcaf.entry.js +1 -0
  150. package/dist/sankhyablocks/p-1c423f5d.entry.js +1 -0
  151. package/dist/sankhyablocks/p-28a0dbf0.entry.js +1 -0
  152. package/dist/sankhyablocks/p-4763d5c2.js +1 -0
  153. package/dist/sankhyablocks/p-4c66200a.entry.js +1 -0
  154. package/dist/sankhyablocks/p-5dc772be.entry.js +1 -0
  155. package/dist/sankhyablocks/p-5ff3e300.entry.js +1 -0
  156. package/dist/sankhyablocks/p-7122cec4.entry.js +1 -0
  157. package/dist/sankhyablocks/p-811b4b9d.js +1 -0
  158. package/dist/sankhyablocks/p-813fe4f7.js +1 -0
  159. package/dist/sankhyablocks/p-9b33a005.entry.js +1 -0
  160. package/dist/sankhyablocks/p-9e22ec87.entry.js +1 -0
  161. package/dist/sankhyablocks/p-9f7239df.entry.js +1 -0
  162. package/dist/sankhyablocks/p-9f7e6e48.js +1 -0
  163. package/dist/sankhyablocks/p-a47e0537.entry.js +1 -0
  164. package/dist/sankhyablocks/p-a9aba60a.entry.js +1 -0
  165. package/dist/sankhyablocks/p-afda7940.entry.js +1 -0
  166. package/dist/sankhyablocks/p-b3a83eaf.entry.js +1 -0
  167. package/dist/sankhyablocks/p-b96a8d40.entry.js +1 -0
  168. package/dist/sankhyablocks/p-c61c0e40.entry.js +1 -0
  169. package/dist/sankhyablocks/p-ca29d028.entry.js +1 -0
  170. package/dist/sankhyablocks/p-cd17abb1.entry.js +1 -0
  171. package/dist/sankhyablocks/p-d3a5366d.entry.js +369 -0
  172. package/dist/sankhyablocks/p-d5703a41.entry.js +1 -0
  173. package/dist/sankhyablocks/p-e5f77a59.entry.js +1 -0
  174. package/dist/sankhyablocks/p-e9e94d51.entry.js +1 -0
  175. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  176. package/dist/types/components/snk-application/snk-application.d.ts +1 -1
  177. package/dist/types/components.d.ts +1 -1
  178. package/package.json +11 -3
  179. package/react/components.d.ts +29 -0
  180. package/react/components.js +29 -0
  181. package/react/components.js.map +1 -1
  182. package/dist/cjs/index-20a7d705.js +0 -733
  183. package/dist/esm/index-8d3572c4.js +0 -707
  184. package/dist/sankhyablocks/p-5fa264b9.js +0 -1
  185. package/dist/sankhyablocks/p-f3bdd8c3.entry.js +0 -57
  186. package/dist/types/temp/ApplicationUtils.d.ts +0 -7
@@ -0,0 +1,1769 @@
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 = 'sankhyablocks';
24
+
25
+ let scopeId;
26
+ let contentRef;
27
+ let hostTagName;
28
+ let useNativeShadowDom = false;
29
+ let checkSlotFallbackVisibility = false;
30
+ let checkSlotRelocate = false;
31
+ let isSvgMode = false;
32
+ let queuePending = false;
33
+ const win = typeof window !== 'undefined' ? window : {};
34
+ const doc = win.document || { head: {} };
35
+ const plt = {
36
+ $flags$: 0,
37
+ $resourcesUrl$: '',
38
+ jmp: (h) => h(),
39
+ raf: (h) => requestAnimationFrame(h),
40
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
41
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
42
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
43
+ };
44
+ const promiseResolve = (v) => Promise.resolve(v);
45
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
46
+ try {
47
+ new CSSStyleSheet();
48
+ return typeof new CSSStyleSheet().replace === 'function';
49
+ }
50
+ catch (e) { }
51
+ return false;
52
+ })()
53
+ ;
54
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
55
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
56
+ const createTime = (fnName, tagName = '') => {
57
+ {
58
+ return () => {
59
+ return;
60
+ };
61
+ }
62
+ };
63
+ const uniqueTime = (key, measureText) => {
64
+ {
65
+ return () => {
66
+ return;
67
+ };
68
+ }
69
+ };
70
+ const rootAppliedStyles = new WeakMap();
71
+ const registerStyle = (scopeId, cssText, allowCS) => {
72
+ let style = styles.get(scopeId);
73
+ if (supportsConstructibleStylesheets && allowCS) {
74
+ style = (style || new CSSStyleSheet());
75
+ style.replace(cssText);
76
+ }
77
+ else {
78
+ style = cssText;
79
+ }
80
+ styles.set(scopeId, style);
81
+ };
82
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
83
+ let scopeId = getScopeId(cmpMeta);
84
+ let style = styles.get(scopeId);
85
+ // if an element is NOT connected then getRootNode() will return the wrong root node
86
+ // so the fallback is to always use the document for the root node in those cases
87
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
88
+ if (style) {
89
+ if (typeof style === 'string') {
90
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
91
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
92
+ let styleElm;
93
+ if (!appliedStyles) {
94
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
95
+ }
96
+ if (!appliedStyles.has(scopeId)) {
97
+ {
98
+ {
99
+ styleElm = doc.createElement('style');
100
+ styleElm.innerHTML = style;
101
+ }
102
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
103
+ }
104
+ if (appliedStyles) {
105
+ appliedStyles.add(scopeId);
106
+ }
107
+ }
108
+ }
109
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
110
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
111
+ }
112
+ }
113
+ return scopeId;
114
+ };
115
+ const attachStyles = (hostRef) => {
116
+ const cmpMeta = hostRef.$cmpMeta$;
117
+ const elm = hostRef.$hostElement$;
118
+ const flags = cmpMeta.$flags$;
119
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
120
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
121
+ if (flags & 10 /* needsScopedEncapsulation */) {
122
+ // only required when we're NOT using native shadow dom (slot)
123
+ // or this browser doesn't support native shadow dom
124
+ // and this host element was NOT created with SSR
125
+ // let's pick out the inner content for slot projection
126
+ // create a node to represent where the original
127
+ // content was first placed, which is useful later on
128
+ // DOM WRITE!!
129
+ elm['s-sc'] = scopeId;
130
+ elm.classList.add(scopeId + '-h');
131
+ if (flags & 2 /* scopedCssEncapsulation */) {
132
+ elm.classList.add(scopeId + '-s');
133
+ }
134
+ }
135
+ endAttachStyles();
136
+ };
137
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
138
+ /**
139
+ * Default style mode id
140
+ */
141
+ /**
142
+ * Reusable empty obj/array
143
+ * Don't add values to these!!
144
+ */
145
+ const EMPTY_OBJ = {};
146
+ /**
147
+ * Namespaces
148
+ */
149
+ const SVG_NS = 'http://www.w3.org/2000/svg';
150
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
151
+ const isDef = (v) => v != null;
152
+ const isComplexType = (o) => {
153
+ // https://jsperf.com/typeof-fn-object/5
154
+ o = typeof o;
155
+ return o === 'object' || o === 'function';
156
+ };
157
+ /**
158
+ * Production h() function based on Preact by
159
+ * Jason Miller (@developit)
160
+ * Licensed under the MIT License
161
+ * https://github.com/developit/preact/blob/master/LICENSE
162
+ *
163
+ * Modified for Stencil's compiler and vdom
164
+ */
165
+ // const stack: any[] = [];
166
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
167
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
168
+ const h = (nodeName, vnodeData, ...children) => {
169
+ let child = null;
170
+ let key = null;
171
+ let slotName = null;
172
+ let simple = false;
173
+ let lastSimple = false;
174
+ let vNodeChildren = [];
175
+ const walk = (c) => {
176
+ for (let i = 0; i < c.length; i++) {
177
+ child = c[i];
178
+ if (Array.isArray(child)) {
179
+ walk(child);
180
+ }
181
+ else if (child != null && typeof child !== 'boolean') {
182
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
183
+ child = String(child);
184
+ }
185
+ if (simple && lastSimple) {
186
+ // If the previous child was simple (string), we merge both
187
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
188
+ }
189
+ else {
190
+ // Append a new vNode, if it's text, we create a text vNode
191
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
192
+ }
193
+ lastSimple = simple;
194
+ }
195
+ }
196
+ };
197
+ walk(children);
198
+ if (vnodeData) {
199
+ // normalize class / classname attributes
200
+ if (vnodeData.key) {
201
+ key = vnodeData.key;
202
+ }
203
+ if (vnodeData.name) {
204
+ slotName = vnodeData.name;
205
+ }
206
+ {
207
+ const classData = vnodeData.className || vnodeData.class;
208
+ if (classData) {
209
+ vnodeData.class =
210
+ typeof classData !== 'object'
211
+ ? classData
212
+ : Object.keys(classData)
213
+ .filter((k) => classData[k])
214
+ .join(' ');
215
+ }
216
+ }
217
+ }
218
+ if (typeof nodeName === 'function') {
219
+ // nodeName is a functional component
220
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
221
+ }
222
+ const vnode = newVNode(nodeName, null);
223
+ vnode.$attrs$ = vnodeData;
224
+ if (vNodeChildren.length > 0) {
225
+ vnode.$children$ = vNodeChildren;
226
+ }
227
+ {
228
+ vnode.$key$ = key;
229
+ }
230
+ {
231
+ vnode.$name$ = slotName;
232
+ }
233
+ return vnode;
234
+ };
235
+ const newVNode = (tag, text) => {
236
+ const vnode = {
237
+ $flags$: 0,
238
+ $tag$: tag,
239
+ $text$: text,
240
+ $elm$: null,
241
+ $children$: null,
242
+ };
243
+ {
244
+ vnode.$attrs$ = null;
245
+ }
246
+ {
247
+ vnode.$key$ = null;
248
+ }
249
+ {
250
+ vnode.$name$ = null;
251
+ }
252
+ return vnode;
253
+ };
254
+ const Host = {};
255
+ const isHost = (node) => node && node.$tag$ === Host;
256
+ const vdomFnUtils = {
257
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
258
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
259
+ };
260
+ const convertToPublic = (node) => ({
261
+ vattrs: node.$attrs$,
262
+ vchildren: node.$children$,
263
+ vkey: node.$key$,
264
+ vname: node.$name$,
265
+ vtag: node.$tag$,
266
+ vtext: node.$text$,
267
+ });
268
+ const convertToPrivate = (node) => {
269
+ if (typeof node.vtag === 'function') {
270
+ const vnodeData = Object.assign({}, node.vattrs);
271
+ if (node.vkey) {
272
+ vnodeData.key = node.vkey;
273
+ }
274
+ if (node.vname) {
275
+ vnodeData.name = node.vname;
276
+ }
277
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
278
+ }
279
+ const vnode = newVNode(node.vtag, node.vtext);
280
+ vnode.$attrs$ = node.vattrs;
281
+ vnode.$children$ = node.vchildren;
282
+ vnode.$key$ = node.vkey;
283
+ vnode.$name$ = node.vname;
284
+ return vnode;
285
+ };
286
+ /**
287
+ * Production setAccessor() function based on Preact by
288
+ * Jason Miller (@developit)
289
+ * Licensed under the MIT License
290
+ * https://github.com/developit/preact/blob/master/LICENSE
291
+ *
292
+ * Modified for Stencil's compiler and vdom
293
+ */
294
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
295
+ if (oldValue !== newValue) {
296
+ let isProp = isMemberInElement(elm, memberName);
297
+ let ln = memberName.toLowerCase();
298
+ if (memberName === 'class') {
299
+ const classList = elm.classList;
300
+ const oldClasses = parseClassList(oldValue);
301
+ const newClasses = parseClassList(newValue);
302
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
303
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
304
+ }
305
+ else if (memberName === 'style') {
306
+ // update style attribute, css properties and values
307
+ {
308
+ for (const prop in oldValue) {
309
+ if (!newValue || newValue[prop] == null) {
310
+ if (prop.includes('-')) {
311
+ elm.style.removeProperty(prop);
312
+ }
313
+ else {
314
+ elm.style[prop] = '';
315
+ }
316
+ }
317
+ }
318
+ }
319
+ for (const prop in newValue) {
320
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
321
+ if (prop.includes('-')) {
322
+ elm.style.setProperty(prop, newValue[prop]);
323
+ }
324
+ else {
325
+ elm.style[prop] = newValue[prop];
326
+ }
327
+ }
328
+ }
329
+ }
330
+ else if (memberName === 'key')
331
+ ;
332
+ else if (memberName === 'ref') {
333
+ // minifier will clean this up
334
+ if (newValue) {
335
+ newValue(elm);
336
+ }
337
+ }
338
+ else if ((!isProp ) &&
339
+ memberName[0] === 'o' &&
340
+ memberName[1] === 'n') {
341
+ // Event Handlers
342
+ // so if the member name starts with "on" and the 3rd characters is
343
+ // a capital letter, and it's not already a member on the element,
344
+ // then we're assuming it's an event listener
345
+ if (memberName[2] === '-') {
346
+ // on- prefixed events
347
+ // allows to be explicit about the dom event to listen without any magic
348
+ // under the hood:
349
+ // <my-cmp on-click> // listens for "click"
350
+ // <my-cmp on-Click> // listens for "Click"
351
+ // <my-cmp on-ionChange> // listens for "ionChange"
352
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
353
+ memberName = memberName.slice(3);
354
+ }
355
+ else if (isMemberInElement(win, ln)) {
356
+ // standard event
357
+ // the JSX attribute could have been "onMouseOver" and the
358
+ // member name "onmouseover" is on the window's prototype
359
+ // so let's add the listener "mouseover", which is all lowercased
360
+ memberName = ln.slice(2);
361
+ }
362
+ else {
363
+ // custom event
364
+ // the JSX attribute could have been "onMyCustomEvent"
365
+ // so let's trim off the "on" prefix and lowercase the first character
366
+ // and add the listener "myCustomEvent"
367
+ // except for the first character, we keep the event name case
368
+ memberName = ln[2] + memberName.slice(3);
369
+ }
370
+ if (oldValue) {
371
+ plt.rel(elm, memberName, oldValue, false);
372
+ }
373
+ if (newValue) {
374
+ plt.ael(elm, memberName, newValue, false);
375
+ }
376
+ }
377
+ else {
378
+ // Set property if it exists and it's not a SVG
379
+ const isComplex = isComplexType(newValue);
380
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
381
+ try {
382
+ if (!elm.tagName.includes('-')) {
383
+ let n = newValue == null ? '' : newValue;
384
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
385
+ if (memberName === 'list') {
386
+ isProp = false;
387
+ }
388
+ else if (oldValue == null || elm[memberName] != n) {
389
+ elm[memberName] = n;
390
+ }
391
+ }
392
+ else {
393
+ elm[memberName] = newValue;
394
+ }
395
+ }
396
+ catch (e) { }
397
+ }
398
+ /**
399
+ * Need to manually update attribute if:
400
+ * - memberName is not an attribute
401
+ * - if we are rendering the host element in order to reflect attribute
402
+ * - if it's a SVG, since properties might not work in <svg>
403
+ * - if the newValue is null/undefined or 'false'.
404
+ */
405
+ let xlink = false;
406
+ {
407
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
408
+ memberName = ln;
409
+ xlink = true;
410
+ }
411
+ }
412
+ if (newValue == null || newValue === false) {
413
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
414
+ if (xlink) {
415
+ elm.removeAttributeNS(XLINK_NS, memberName);
416
+ }
417
+ else {
418
+ elm.removeAttribute(memberName);
419
+ }
420
+ }
421
+ }
422
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
423
+ newValue = newValue === true ? '' : newValue;
424
+ if (xlink) {
425
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
426
+ }
427
+ else {
428
+ elm.setAttribute(memberName, newValue);
429
+ }
430
+ }
431
+ }
432
+ }
433
+ };
434
+ const parseClassListRegex = /\s/;
435
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
436
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
437
+ // if the element passed in is a shadow root, which is a document fragment
438
+ // then we want to be adding attrs/props to the shadow root's "host" element
439
+ // if it's not a shadow root, then we add attrs/props to the same element
440
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
441
+ ? newVnode.$elm$.host
442
+ : newVnode.$elm$;
443
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
444
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
445
+ {
446
+ // remove attributes no longer present on the vnode by setting them to undefined
447
+ for (memberName in oldVnodeAttrs) {
448
+ if (!(memberName in newVnodeAttrs)) {
449
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
450
+ }
451
+ }
452
+ }
453
+ // add new & update changed attributes
454
+ for (memberName in newVnodeAttrs) {
455
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
456
+ }
457
+ };
458
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
459
+ // tslint:disable-next-line: prefer-const
460
+ let newVNode = newParentVNode.$children$[childIndex];
461
+ let i = 0;
462
+ let elm;
463
+ let childNode;
464
+ let oldVNode;
465
+ if (!useNativeShadowDom) {
466
+ // remember for later we need to check to relocate nodes
467
+ checkSlotRelocate = true;
468
+ if (newVNode.$tag$ === 'slot') {
469
+ if (scopeId) {
470
+ // scoped css needs to add its scoped id to the parent element
471
+ parentElm.classList.add(scopeId + '-s');
472
+ }
473
+ newVNode.$flags$ |= newVNode.$children$
474
+ ? // slot element has fallback content
475
+ 2 /* isSlotFallback */
476
+ : // slot element does not have fallback content
477
+ 1 /* isSlotReference */;
478
+ }
479
+ }
480
+ if (newVNode.$text$ !== null) {
481
+ // create text node
482
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
483
+ }
484
+ else if (newVNode.$flags$ & 1 /* isSlotReference */) {
485
+ // create a slot reference node
486
+ elm = newVNode.$elm$ =
487
+ doc.createTextNode('');
488
+ }
489
+ else {
490
+ if (!isSvgMode) {
491
+ isSvgMode = newVNode.$tag$ === 'svg';
492
+ }
493
+ // create element
494
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
495
+ ? 'slot-fb'
496
+ : newVNode.$tag$)
497
+ );
498
+ if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
499
+ isSvgMode = false;
500
+ }
501
+ // add css classes, attrs, props, listeners, etc.
502
+ {
503
+ updateElement(null, newVNode, isSvgMode);
504
+ }
505
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
506
+ // if there is a scopeId and this is the initial render
507
+ // then let's add the scopeId as a css class
508
+ elm.classList.add((elm['s-si'] = scopeId));
509
+ }
510
+ if (newVNode.$children$) {
511
+ for (i = 0; i < newVNode.$children$.length; ++i) {
512
+ // create the node
513
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
514
+ // return node could have been null
515
+ if (childNode) {
516
+ // append our new node
517
+ elm.appendChild(childNode);
518
+ }
519
+ }
520
+ }
521
+ {
522
+ if (newVNode.$tag$ === 'svg') {
523
+ // Only reset the SVG context when we're exiting <svg> element
524
+ isSvgMode = false;
525
+ }
526
+ else if (elm.tagName === 'foreignObject') {
527
+ // Reenter SVG context when we're exiting <foreignObject> element
528
+ isSvgMode = true;
529
+ }
530
+ }
531
+ }
532
+ {
533
+ elm['s-hn'] = hostTagName;
534
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
535
+ // remember the content reference comment
536
+ elm['s-sr'] = true;
537
+ // remember the content reference comment
538
+ elm['s-cr'] = contentRef;
539
+ // remember the slot name, or empty string for default slot
540
+ elm['s-sn'] = newVNode.$name$ || '';
541
+ // check if we've got an old vnode for this slot
542
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
543
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
544
+ // we've got an old slot vnode and the wrapper is being replaced
545
+ // so let's move the old slot content back to it's original location
546
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
547
+ }
548
+ }
549
+ }
550
+ return elm;
551
+ };
552
+ const putBackInOriginalLocation = (parentElm, recursive) => {
553
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
554
+ const oldSlotChildNodes = parentElm.childNodes;
555
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
556
+ const childNode = oldSlotChildNodes[i];
557
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
558
+ // // this child node in the old element is from another component
559
+ // // remove this node from the old slot's parent
560
+ // childNode.remove();
561
+ // and relocate it back to it's original location
562
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
563
+ // remove the old original location comment entirely
564
+ // later on the patch function will know what to do
565
+ // and move this to the correct spot in need be
566
+ childNode['s-ol'].remove();
567
+ childNode['s-ol'] = undefined;
568
+ checkSlotRelocate = true;
569
+ }
570
+ if (recursive) {
571
+ putBackInOriginalLocation(childNode, recursive);
572
+ }
573
+ }
574
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
575
+ };
576
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
577
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
578
+ let childNode;
579
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
580
+ containerElm = containerElm.shadowRoot;
581
+ }
582
+ for (; startIdx <= endIdx; ++startIdx) {
583
+ if (vnodes[startIdx]) {
584
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
585
+ if (childNode) {
586
+ vnodes[startIdx].$elm$ = childNode;
587
+ containerElm.insertBefore(childNode, referenceNode(before) );
588
+ }
589
+ }
590
+ }
591
+ };
592
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
593
+ for (; startIdx <= endIdx; ++startIdx) {
594
+ if ((vnode = vnodes[startIdx])) {
595
+ elm = vnode.$elm$;
596
+ callNodeRefs(vnode);
597
+ {
598
+ // we're removing this element
599
+ // so it's possible we need to show slot fallback content now
600
+ checkSlotFallbackVisibility = true;
601
+ if (elm['s-ol']) {
602
+ // remove the original location comment
603
+ elm['s-ol'].remove();
604
+ }
605
+ else {
606
+ // it's possible that child nodes of the node
607
+ // that's being removed are slot nodes
608
+ putBackInOriginalLocation(elm, true);
609
+ }
610
+ }
611
+ // remove the vnode's element from the dom
612
+ elm.remove();
613
+ }
614
+ }
615
+ };
616
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
617
+ let oldStartIdx = 0;
618
+ let newStartIdx = 0;
619
+ let idxInOld = 0;
620
+ let i = 0;
621
+ let oldEndIdx = oldCh.length - 1;
622
+ let oldStartVnode = oldCh[0];
623
+ let oldEndVnode = oldCh[oldEndIdx];
624
+ let newEndIdx = newCh.length - 1;
625
+ let newStartVnode = newCh[0];
626
+ let newEndVnode = newCh[newEndIdx];
627
+ let node;
628
+ let elmToMove;
629
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
630
+ if (oldStartVnode == null) {
631
+ // Vnode might have been moved left
632
+ oldStartVnode = oldCh[++oldStartIdx];
633
+ }
634
+ else if (oldEndVnode == null) {
635
+ oldEndVnode = oldCh[--oldEndIdx];
636
+ }
637
+ else if (newStartVnode == null) {
638
+ newStartVnode = newCh[++newStartIdx];
639
+ }
640
+ else if (newEndVnode == null) {
641
+ newEndVnode = newCh[--newEndIdx];
642
+ }
643
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
644
+ patch(oldStartVnode, newStartVnode);
645
+ oldStartVnode = oldCh[++oldStartIdx];
646
+ newStartVnode = newCh[++newStartIdx];
647
+ }
648
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
649
+ patch(oldEndVnode, newEndVnode);
650
+ oldEndVnode = oldCh[--oldEndIdx];
651
+ newEndVnode = newCh[--newEndIdx];
652
+ }
653
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
654
+ // Vnode moved right
655
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
656
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
657
+ }
658
+ patch(oldStartVnode, newEndVnode);
659
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
660
+ oldStartVnode = oldCh[++oldStartIdx];
661
+ newEndVnode = newCh[--newEndIdx];
662
+ }
663
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
664
+ // Vnode moved left
665
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
666
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
667
+ }
668
+ patch(oldEndVnode, newStartVnode);
669
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
670
+ oldEndVnode = oldCh[--oldEndIdx];
671
+ newStartVnode = newCh[++newStartIdx];
672
+ }
673
+ else {
674
+ // createKeyToOldIdx
675
+ idxInOld = -1;
676
+ {
677
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
678
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
679
+ idxInOld = i;
680
+ break;
681
+ }
682
+ }
683
+ }
684
+ if (idxInOld >= 0) {
685
+ elmToMove = oldCh[idxInOld];
686
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
687
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
688
+ }
689
+ else {
690
+ patch(elmToMove, newStartVnode);
691
+ oldCh[idxInOld] = undefined;
692
+ node = elmToMove.$elm$;
693
+ }
694
+ newStartVnode = newCh[++newStartIdx];
695
+ }
696
+ else {
697
+ // new element
698
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
699
+ newStartVnode = newCh[++newStartIdx];
700
+ }
701
+ if (node) {
702
+ {
703
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
704
+ }
705
+ }
706
+ }
707
+ }
708
+ if (oldStartIdx > oldEndIdx) {
709
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
710
+ }
711
+ else if (newStartIdx > newEndIdx) {
712
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
713
+ }
714
+ };
715
+ const isSameVnode = (vnode1, vnode2) => {
716
+ // compare if two vnode to see if they're "technically" the same
717
+ // need to have the same element tag, and same key to be the same
718
+ if (vnode1.$tag$ === vnode2.$tag$) {
719
+ if (vnode1.$tag$ === 'slot') {
720
+ return vnode1.$name$ === vnode2.$name$;
721
+ }
722
+ {
723
+ return vnode1.$key$ === vnode2.$key$;
724
+ }
725
+ }
726
+ return false;
727
+ };
728
+ const referenceNode = (node) => {
729
+ // this node was relocated to a new location in the dom
730
+ // because of some other component's slot
731
+ // but we still have an html comment in place of where
732
+ // it's original location was according to it's original vdom
733
+ return (node && node['s-ol']) || node;
734
+ };
735
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
736
+ const patch = (oldVNode, newVNode) => {
737
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
738
+ const oldChildren = oldVNode.$children$;
739
+ const newChildren = newVNode.$children$;
740
+ const tag = newVNode.$tag$;
741
+ const text = newVNode.$text$;
742
+ let defaultHolder;
743
+ if (text === null) {
744
+ {
745
+ // test if we're rendering an svg element, or still rendering nodes inside of one
746
+ // only add this to the when the compiler sees we're using an svg somewhere
747
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
748
+ }
749
+ // element node
750
+ {
751
+ if (tag === 'slot')
752
+ ;
753
+ else {
754
+ // either this is the first render of an element OR it's an update
755
+ // AND we already know it's possible it could have changed
756
+ // this updates the element's css classes, attrs, props, listeners, etc.
757
+ updateElement(oldVNode, newVNode, isSvgMode);
758
+ }
759
+ }
760
+ if (oldChildren !== null && newChildren !== null) {
761
+ // looks like there's child vnodes for both the old and new vnodes
762
+ updateChildren(elm, oldChildren, newVNode, newChildren);
763
+ }
764
+ else if (newChildren !== null) {
765
+ // no old child vnodes, but there are new child vnodes to add
766
+ if (oldVNode.$text$ !== null) {
767
+ // the old vnode was text, so be sure to clear it out
768
+ elm.textContent = '';
769
+ }
770
+ // add the new vnode children
771
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
772
+ }
773
+ else if (oldChildren !== null) {
774
+ // no new child vnodes, but there are old child vnodes to remove
775
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
776
+ }
777
+ if (isSvgMode && tag === 'svg') {
778
+ isSvgMode = false;
779
+ }
780
+ }
781
+ else if ((defaultHolder = elm['s-cr'])) {
782
+ // this element has slotted content
783
+ defaultHolder.parentNode.textContent = text;
784
+ }
785
+ else if (oldVNode.$text$ !== text) {
786
+ // update the text content for the text only vnode
787
+ // and also only if the text is different than before
788
+ elm.data = text;
789
+ }
790
+ };
791
+ const updateFallbackSlotVisibility = (elm) => {
792
+ // tslint:disable-next-line: prefer-const
793
+ let childNodes = elm.childNodes;
794
+ let childNode;
795
+ let i;
796
+ let ilen;
797
+ let j;
798
+ let slotNameAttr;
799
+ let nodeType;
800
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
801
+ childNode = childNodes[i];
802
+ if (childNode.nodeType === 1 /* ElementNode */) {
803
+ if (childNode['s-sr']) {
804
+ // this is a slot fallback node
805
+ // get the slot name for this slot reference node
806
+ slotNameAttr = childNode['s-sn'];
807
+ // by default always show a fallback slot node
808
+ // then hide it if there are other slots in the light dom
809
+ childNode.hidden = false;
810
+ for (j = 0; j < ilen; j++) {
811
+ nodeType = childNodes[j].nodeType;
812
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
813
+ // this sibling node is from a different component OR is a named fallback slot node
814
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
815
+ childNode.hidden = true;
816
+ break;
817
+ }
818
+ }
819
+ else {
820
+ // this is a default fallback slot node
821
+ // any element or text node (with content)
822
+ // should hide the default fallback slot node
823
+ if (nodeType === 1 /* ElementNode */ ||
824
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
825
+ childNode.hidden = true;
826
+ break;
827
+ }
828
+ }
829
+ }
830
+ }
831
+ // keep drilling down
832
+ updateFallbackSlotVisibility(childNode);
833
+ }
834
+ }
835
+ };
836
+ const relocateNodes = [];
837
+ const relocateSlotContent = (elm) => {
838
+ // tslint:disable-next-line: prefer-const
839
+ let childNode;
840
+ let node;
841
+ let hostContentNodes;
842
+ let slotNameAttr;
843
+ let relocateNodeData;
844
+ let j;
845
+ let i = 0;
846
+ let childNodes = elm.childNodes;
847
+ let ilen = childNodes.length;
848
+ for (; i < ilen; i++) {
849
+ childNode = childNodes[i];
850
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
851
+ // first got the content reference comment node
852
+ // then we got it's parent, which is where all the host content is in now
853
+ hostContentNodes = node.parentNode.childNodes;
854
+ slotNameAttr = childNode['s-sn'];
855
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
856
+ node = hostContentNodes[j];
857
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
858
+ // let's do some relocating to its new home
859
+ // but never relocate a content reference node
860
+ // that is suppose to always represent the original content location
861
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
862
+ // it's possible we've already decided to relocate this node
863
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
864
+ // made some changes to slots
865
+ // let's make sure we also double check
866
+ // fallbacks are correctly hidden or shown
867
+ checkSlotFallbackVisibility = true;
868
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
869
+ if (relocateNodeData) {
870
+ // previously we never found a slot home for this node
871
+ // but turns out we did, so let's remember it now
872
+ relocateNodeData.$slotRefNode$ = childNode;
873
+ }
874
+ else {
875
+ // add to our list of nodes to relocate
876
+ relocateNodes.push({
877
+ $slotRefNode$: childNode,
878
+ $nodeToRelocate$: node,
879
+ });
880
+ }
881
+ if (node['s-sr']) {
882
+ relocateNodes.map((relocateNode) => {
883
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
884
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
885
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
886
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
887
+ }
888
+ }
889
+ });
890
+ }
891
+ }
892
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
893
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
894
+ // if we never find a home for this element then we'll need to hide it
895
+ relocateNodes.push({
896
+ $nodeToRelocate$: node,
897
+ });
898
+ }
899
+ }
900
+ }
901
+ }
902
+ if (childNode.nodeType === 1 /* ElementNode */) {
903
+ relocateSlotContent(childNode);
904
+ }
905
+ }
906
+ };
907
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
908
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
909
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
910
+ return true;
911
+ }
912
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
913
+ return true;
914
+ }
915
+ return false;
916
+ }
917
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
918
+ return true;
919
+ }
920
+ return slotNameAttr === '';
921
+ };
922
+ const callNodeRefs = (vNode) => {
923
+ {
924
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
925
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
926
+ }
927
+ };
928
+ const renderVdom = (hostRef, renderFnResults) => {
929
+ const hostElm = hostRef.$hostElement$;
930
+ const cmpMeta = hostRef.$cmpMeta$;
931
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
932
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
933
+ hostTagName = hostElm.tagName;
934
+ if (cmpMeta.$attrsToReflect$) {
935
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
936
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
937
+ }
938
+ rootVnode.$tag$ = null;
939
+ rootVnode.$flags$ |= 4 /* isHost */;
940
+ hostRef.$vnode$ = rootVnode;
941
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
942
+ {
943
+ scopeId = hostElm['s-sc'];
944
+ }
945
+ {
946
+ contentRef = hostElm['s-cr'];
947
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
948
+ // always reset
949
+ checkSlotFallbackVisibility = false;
950
+ }
951
+ // synchronous patch
952
+ patch(oldVNode, rootVnode);
953
+ {
954
+ // while we're moving nodes around existing nodes, temporarily disable
955
+ // the disconnectCallback from working
956
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
957
+ if (checkSlotRelocate) {
958
+ relocateSlotContent(rootVnode.$elm$);
959
+ let relocateData;
960
+ let nodeToRelocate;
961
+ let orgLocationNode;
962
+ let parentNodeRef;
963
+ let insertBeforeNode;
964
+ let refNode;
965
+ let i = 0;
966
+ for (; i < relocateNodes.length; i++) {
967
+ relocateData = relocateNodes[i];
968
+ nodeToRelocate = relocateData.$nodeToRelocate$;
969
+ if (!nodeToRelocate['s-ol']) {
970
+ // add a reference node marking this node's original location
971
+ // keep a reference to this node for later lookups
972
+ orgLocationNode =
973
+ doc.createTextNode('');
974
+ orgLocationNode['s-nr'] = nodeToRelocate;
975
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
976
+ }
977
+ }
978
+ for (i = 0; i < relocateNodes.length; i++) {
979
+ relocateData = relocateNodes[i];
980
+ nodeToRelocate = relocateData.$nodeToRelocate$;
981
+ if (relocateData.$slotRefNode$) {
982
+ // by default we're just going to insert it directly
983
+ // after the slot reference node
984
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
985
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
986
+ orgLocationNode = nodeToRelocate['s-ol'];
987
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
988
+ refNode = orgLocationNode['s-nr'];
989
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
990
+ refNode = refNode.nextSibling;
991
+ if (!refNode || !refNode['s-nr']) {
992
+ insertBeforeNode = refNode;
993
+ break;
994
+ }
995
+ }
996
+ }
997
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
998
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
999
+ // we've checked that it's worth while to relocate
1000
+ // since that the node to relocate
1001
+ // has a different next sibling or parent relocated
1002
+ if (nodeToRelocate !== insertBeforeNode) {
1003
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1004
+ // probably a component in the index.html that doesn't have it's hostname set
1005
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1006
+ }
1007
+ // add it back to the dom but in its new home
1008
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1009
+ }
1010
+ }
1011
+ }
1012
+ else {
1013
+ // this node doesn't have a slot home to go to, so let's hide it
1014
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
1015
+ nodeToRelocate.hidden = true;
1016
+ }
1017
+ }
1018
+ }
1019
+ }
1020
+ if (checkSlotFallbackVisibility) {
1021
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1022
+ }
1023
+ // done moving nodes around
1024
+ // allow the disconnect callback to work again
1025
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1026
+ // always reset
1027
+ relocateNodes.length = 0;
1028
+ }
1029
+ };
1030
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
1031
+ const createEvent = (ref, name, flags) => {
1032
+ const elm = getElement(ref);
1033
+ return {
1034
+ emit: (detail) => {
1035
+ return emitEvent(elm, name, {
1036
+ bubbles: !!(flags & 4 /* Bubbles */),
1037
+ composed: !!(flags & 2 /* Composed */),
1038
+ cancelable: !!(flags & 1 /* Cancellable */),
1039
+ detail,
1040
+ });
1041
+ },
1042
+ };
1043
+ };
1044
+ /**
1045
+ * Helper function to create & dispatch a custom Event on a provided target
1046
+ * @param elm the target of the Event
1047
+ * @param name the name to give the custom Event
1048
+ * @param opts options for configuring a custom Event
1049
+ * @returns the custom Event
1050
+ */
1051
+ const emitEvent = (elm, name, opts) => {
1052
+ const ev = plt.ce(name, opts);
1053
+ elm.dispatchEvent(ev);
1054
+ return ev;
1055
+ };
1056
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1057
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1058
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1059
+ }
1060
+ };
1061
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
1062
+ {
1063
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1064
+ }
1065
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1066
+ hostRef.$flags$ |= 512 /* needsRerender */;
1067
+ return;
1068
+ }
1069
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1070
+ // there is no ancestor component or the ancestor component
1071
+ // has already fired off its lifecycle update then
1072
+ // fire off the initial update
1073
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1074
+ return writeTask(dispatch) ;
1075
+ };
1076
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1077
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1078
+ const instance = hostRef.$lazyInstance$ ;
1079
+ let promise;
1080
+ if (isInitialLoad) {
1081
+ {
1082
+ promise = safeCall(instance, 'componentWillLoad');
1083
+ }
1084
+ }
1085
+ {
1086
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1087
+ }
1088
+ endSchedule();
1089
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1090
+ };
1091
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1092
+ // updateComponent
1093
+ const elm = hostRef.$hostElement$;
1094
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1095
+ const rc = elm['s-rc'];
1096
+ if (isInitialLoad) {
1097
+ // DOM WRITE!
1098
+ attachStyles(hostRef);
1099
+ }
1100
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1101
+ {
1102
+ callRender(hostRef, instance);
1103
+ }
1104
+ if (rc) {
1105
+ // ok, so turns out there are some child host elements
1106
+ // waiting on this parent element to load
1107
+ // let's fire off all update callbacks waiting
1108
+ rc.map((cb) => cb());
1109
+ elm['s-rc'] = undefined;
1110
+ }
1111
+ endRender();
1112
+ endUpdate();
1113
+ {
1114
+ const childrenPromises = elm['s-p'];
1115
+ const postUpdate = () => postUpdateComponent(hostRef);
1116
+ if (childrenPromises.length === 0) {
1117
+ postUpdate();
1118
+ }
1119
+ else {
1120
+ Promise.all(childrenPromises).then(postUpdate);
1121
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1122
+ childrenPromises.length = 0;
1123
+ }
1124
+ }
1125
+ };
1126
+ const callRender = (hostRef, instance, elm) => {
1127
+ try {
1128
+ instance = instance.render() ;
1129
+ {
1130
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1131
+ }
1132
+ {
1133
+ hostRef.$flags$ |= 2 /* hasRendered */;
1134
+ }
1135
+ {
1136
+ {
1137
+ // looks like we've got child nodes to render into this host element
1138
+ // or we need to update the css class/attrs on the host element
1139
+ // DOM WRITE!
1140
+ {
1141
+ renderVdom(hostRef, instance);
1142
+ }
1143
+ }
1144
+ }
1145
+ }
1146
+ catch (e) {
1147
+ consoleError(e, hostRef.$hostElement$);
1148
+ }
1149
+ return null;
1150
+ };
1151
+ const postUpdateComponent = (hostRef) => {
1152
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1153
+ const elm = hostRef.$hostElement$;
1154
+ const endPostUpdate = createTime('postUpdate', tagName);
1155
+ const instance = hostRef.$lazyInstance$ ;
1156
+ const ancestorComponent = hostRef.$ancestorComponent$;
1157
+ {
1158
+ safeCall(instance, 'componentDidRender');
1159
+ }
1160
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1161
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1162
+ {
1163
+ // DOM WRITE!
1164
+ addHydratedFlag(elm);
1165
+ }
1166
+ {
1167
+ safeCall(instance, 'componentDidLoad');
1168
+ }
1169
+ endPostUpdate();
1170
+ {
1171
+ hostRef.$onReadyResolve$(elm);
1172
+ if (!ancestorComponent) {
1173
+ appDidLoad();
1174
+ }
1175
+ }
1176
+ }
1177
+ else {
1178
+ endPostUpdate();
1179
+ }
1180
+ {
1181
+ hostRef.$onInstanceResolve$(elm);
1182
+ }
1183
+ // load events fire from bottom to top
1184
+ // the deepest elements load first then bubbles up
1185
+ {
1186
+ if (hostRef.$onRenderResolve$) {
1187
+ hostRef.$onRenderResolve$();
1188
+ hostRef.$onRenderResolve$ = undefined;
1189
+ }
1190
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
1191
+ nextTick(() => scheduleUpdate(hostRef, false));
1192
+ }
1193
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1194
+ }
1195
+ // ( •_•)
1196
+ // ( •_•)>⌐■-■
1197
+ // (⌐■_■)
1198
+ };
1199
+ const forceUpdate = (ref) => {
1200
+ {
1201
+ const hostRef = getHostRef(ref);
1202
+ const isConnected = hostRef.$hostElement$.isConnected;
1203
+ if (isConnected &&
1204
+ (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1205
+ scheduleUpdate(hostRef, false);
1206
+ }
1207
+ // Returns "true" when the forced update was successfully scheduled
1208
+ return isConnected;
1209
+ }
1210
+ };
1211
+ const appDidLoad = (who) => {
1212
+ // on appload
1213
+ // we have finish the first big initial render
1214
+ {
1215
+ addHydratedFlag(doc.documentElement);
1216
+ }
1217
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1218
+ };
1219
+ const safeCall = (instance, method, arg) => {
1220
+ if (instance && instance[method]) {
1221
+ try {
1222
+ return instance[method](arg);
1223
+ }
1224
+ catch (e) {
1225
+ consoleError(e);
1226
+ }
1227
+ }
1228
+ return undefined;
1229
+ };
1230
+ const then = (promise, thenFn) => {
1231
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1232
+ };
1233
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1234
+ ;
1235
+ /**
1236
+ * Parse a new property value for a given property type.
1237
+ *
1238
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1239
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1240
+ * 1. `any`, the type given to `propValue` in the function signature
1241
+ * 2. the type stored from `propType`.
1242
+ *
1243
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1244
+ *
1245
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1246
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1247
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1248
+ * ```tsx
1249
+ * <my-cmp prop-val={0}></my-cmp>
1250
+ * ```
1251
+ *
1252
+ * HTML prop values on the other hand, will always a string
1253
+ *
1254
+ * @param propValue the new value to coerce to some type
1255
+ * @param propType the type of the prop, expressed as a binary number
1256
+ * @returns the parsed/coerced value
1257
+ */
1258
+ const parsePropertyValue = (propValue, propType) => {
1259
+ // ensure this value is of the correct prop type
1260
+ if (propValue != null && !isComplexType(propValue)) {
1261
+ if (propType & 4 /* Boolean */) {
1262
+ // per the HTML spec, any string value means it is a boolean true value
1263
+ // but we'll cheat here and say that the string "false" is the boolean false
1264
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
1265
+ }
1266
+ if (propType & 2 /* Number */) {
1267
+ // force it to be a number
1268
+ return parseFloat(propValue);
1269
+ }
1270
+ if (propType & 1 /* String */) {
1271
+ // could have been passed as a number or boolean
1272
+ // but we still want it as a string
1273
+ return String(propValue);
1274
+ }
1275
+ // redundant return here for better minification
1276
+ return propValue;
1277
+ }
1278
+ // not sure exactly what type we want
1279
+ // so no need to change to a different type
1280
+ return propValue;
1281
+ };
1282
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1283
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1284
+ // check our new property value against our internal value
1285
+ const hostRef = getHostRef(ref);
1286
+ const elm = hostRef.$hostElement$ ;
1287
+ const oldVal = hostRef.$instanceValues$.get(propName);
1288
+ const flags = hostRef.$flags$;
1289
+ const instance = hostRef.$lazyInstance$ ;
1290
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1291
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1292
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1293
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1294
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1295
+ // gadzooks! the property's value has changed!!
1296
+ // set our new value!
1297
+ hostRef.$instanceValues$.set(propName, newVal);
1298
+ if (instance) {
1299
+ // get an array of method names of watch functions to call
1300
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1301
+ const watchMethods = cmpMeta.$watchers$[propName];
1302
+ if (watchMethods) {
1303
+ // this instance is watching for when this property changed
1304
+ watchMethods.map((watchMethodName) => {
1305
+ try {
1306
+ // fire off each of the watch methods that are watching this property
1307
+ instance[watchMethodName](newVal, oldVal, propName);
1308
+ }
1309
+ catch (e) {
1310
+ consoleError(e, elm);
1311
+ }
1312
+ });
1313
+ }
1314
+ }
1315
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1316
+ // looks like this value actually changed, so we've got work to do!
1317
+ // but only if we've already rendered, otherwise just chill out
1318
+ // queue that we need to do an update, but don't worry about queuing
1319
+ // up millions cuz this function ensures it only runs once
1320
+ scheduleUpdate(hostRef, false);
1321
+ }
1322
+ }
1323
+ }
1324
+ };
1325
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1326
+ if (cmpMeta.$members$) {
1327
+ if (Cstr.watchers) {
1328
+ cmpMeta.$watchers$ = Cstr.watchers;
1329
+ }
1330
+ // It's better to have a const than two Object.entries()
1331
+ const members = Object.entries(cmpMeta.$members$);
1332
+ const prototype = Cstr.prototype;
1333
+ members.map(([memberName, [memberFlags]]) => {
1334
+ if ((memberFlags & 31 /* Prop */ ||
1335
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1336
+ // proxyComponent - prop
1337
+ Object.defineProperty(prototype, memberName, {
1338
+ get() {
1339
+ // proxyComponent, get value
1340
+ return getValue(this, memberName);
1341
+ },
1342
+ set(newValue) {
1343
+ // proxyComponent, set value
1344
+ setValue(this, memberName, newValue, cmpMeta);
1345
+ },
1346
+ configurable: true,
1347
+ enumerable: true,
1348
+ });
1349
+ }
1350
+ else if (flags & 1 /* isElementConstructor */ &&
1351
+ memberFlags & 64 /* Method */) {
1352
+ // proxyComponent - method
1353
+ Object.defineProperty(prototype, memberName, {
1354
+ value(...args) {
1355
+ const ref = getHostRef(this);
1356
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1357
+ },
1358
+ });
1359
+ }
1360
+ });
1361
+ if ((flags & 1 /* isElementConstructor */)) {
1362
+ const attrNameToPropName = new Map();
1363
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1364
+ plt.jmp(() => {
1365
+ const propName = attrNameToPropName.get(attrName);
1366
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1367
+ // in the case where an attribute was set inline.
1368
+ // ```html
1369
+ // <my-component some-attribute="some-value"></my-component>
1370
+ // ```
1371
+ //
1372
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1373
+ // programmatically changes it before it has been upgraded as shown below:
1374
+ //
1375
+ // ```html
1376
+ // <!-- this component has _not_ been upgraded yet -->
1377
+ // <my-component id="test" some-attribute="some-value"></my-component>
1378
+ // <script>
1379
+ // // grab non-upgraded component
1380
+ // el = document.querySelector("#test");
1381
+ // el.someAttribute = "another-value";
1382
+ // // upgrade component
1383
+ // customElements.define('my-component', MyComponent);
1384
+ // </script>
1385
+ // ```
1386
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1387
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1388
+ // to the value that was set inline i.e. "some-value" from above example. When
1389
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1390
+ //
1391
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1392
+ // by connectedCallback as this attributeChangedCallback will not fire.
1393
+ //
1394
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1395
+ //
1396
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1397
+ // properties here given that this goes against best practices outlined here
1398
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1399
+ if (this.hasOwnProperty(propName)) {
1400
+ newValue = this[propName];
1401
+ delete this[propName];
1402
+ }
1403
+ else if (prototype.hasOwnProperty(propName) &&
1404
+ typeof this[propName] === 'number' &&
1405
+ this[propName] == newValue) {
1406
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1407
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1408
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1409
+ return;
1410
+ }
1411
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1412
+ });
1413
+ };
1414
+ // create an array of attributes to observe
1415
+ // and also create a map of html attribute name to js property name
1416
+ Cstr.observedAttributes = members
1417
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1418
+ .map(([propName, m]) => {
1419
+ const attrName = m[1] || propName;
1420
+ attrNameToPropName.set(attrName, propName);
1421
+ if (m[0] & 512 /* ReflectAttr */) {
1422
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
1423
+ }
1424
+ return attrName;
1425
+ });
1426
+ }
1427
+ }
1428
+ return Cstr;
1429
+ };
1430
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1431
+ // initializeComponent
1432
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1433
+ {
1434
+ // we haven't initialized this element yet
1435
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1436
+ // lazy loaded components
1437
+ // request the component's implementation to be
1438
+ // wired up with the host element
1439
+ Cstr = loadModule(cmpMeta);
1440
+ if (Cstr.then) {
1441
+ // Await creates a micro-task avoid if possible
1442
+ const endLoad = uniqueTime();
1443
+ Cstr = await Cstr;
1444
+ endLoad();
1445
+ }
1446
+ if (!Cstr.isProxied) {
1447
+ // we've never proxied this Constructor before
1448
+ // let's add the getters/setters to its prototype before
1449
+ // the first time we create an instance of the implementation
1450
+ {
1451
+ cmpMeta.$watchers$ = Cstr.watchers;
1452
+ }
1453
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1454
+ Cstr.isProxied = true;
1455
+ }
1456
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1457
+ // ok, time to construct the instance
1458
+ // but let's keep track of when we start and stop
1459
+ // so that the getters/setters don't incorrectly step on data
1460
+ {
1461
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1462
+ }
1463
+ // construct the lazy-loaded component implementation
1464
+ // passing the hostRef is very important during
1465
+ // construction in order to directly wire together the
1466
+ // host element and the lazy-loaded instance
1467
+ try {
1468
+ new Cstr(hostRef);
1469
+ }
1470
+ catch (e) {
1471
+ consoleError(e);
1472
+ }
1473
+ {
1474
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1475
+ }
1476
+ {
1477
+ hostRef.$flags$ |= 128 /* isWatchReady */;
1478
+ }
1479
+ endNewInstance();
1480
+ }
1481
+ if (Cstr.style) {
1482
+ // this component has styles but we haven't registered them yet
1483
+ let style = Cstr.style;
1484
+ const scopeId = getScopeId(cmpMeta);
1485
+ if (!styles.has(scopeId)) {
1486
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1487
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1488
+ endRegisterStyles();
1489
+ }
1490
+ }
1491
+ }
1492
+ // we've successfully created a lazy instance
1493
+ const ancestorComponent = hostRef.$ancestorComponent$;
1494
+ const schedule = () => scheduleUpdate(hostRef, true);
1495
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1496
+ // this is the initial load and this component it has an ancestor component
1497
+ // but the ancestor component has NOT fired its will update lifecycle yet
1498
+ // so let's just cool our jets and wait for the ancestor to continue first
1499
+ // this will get fired off when the ancestor component
1500
+ // finally gets around to rendering its lazy self
1501
+ // fire off the initial update
1502
+ ancestorComponent['s-rc'].push(schedule);
1503
+ }
1504
+ else {
1505
+ schedule();
1506
+ }
1507
+ };
1508
+ const connectedCallback = (elm) => {
1509
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1510
+ const hostRef = getHostRef(elm);
1511
+ const cmpMeta = hostRef.$cmpMeta$;
1512
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1513
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1514
+ // first time this component has connected
1515
+ hostRef.$flags$ |= 1 /* hasConnected */;
1516
+ {
1517
+ // initUpdate
1518
+ // if the slot polyfill is required we'll need to put some nodes
1519
+ // in here to act as original content anchors as we move nodes around
1520
+ // host element has been connected to the DOM
1521
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1522
+ setContentReference(elm);
1523
+ }
1524
+ }
1525
+ {
1526
+ // find the first ancestor component (if there is one) and register
1527
+ // this component as one of the actively loading child components for its ancestor
1528
+ let ancestorComponent = elm;
1529
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1530
+ // climb up the ancestors looking for the first
1531
+ // component that hasn't finished its lifecycle update yet
1532
+ if (ancestorComponent['s-p']) {
1533
+ // we found this components first ancestor component
1534
+ // keep a reference to this component's ancestor component
1535
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1536
+ break;
1537
+ }
1538
+ }
1539
+ }
1540
+ // Lazy properties
1541
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1542
+ if (cmpMeta.$members$) {
1543
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1544
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1545
+ const value = elm[memberName];
1546
+ delete elm[memberName];
1547
+ elm[memberName] = value;
1548
+ }
1549
+ });
1550
+ }
1551
+ {
1552
+ initializeComponent(elm, hostRef, cmpMeta);
1553
+ }
1554
+ }
1555
+ endConnected();
1556
+ }
1557
+ };
1558
+ const setContentReference = (elm) => {
1559
+ // only required when we're NOT using native shadow dom (slot)
1560
+ // or this browser doesn't support native shadow dom
1561
+ // and this host element was NOT created with SSR
1562
+ // let's pick out the inner content for slot projection
1563
+ // create a node to represent where the original
1564
+ // content was first placed, which is useful later on
1565
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1566
+ contentRefElm['s-cn'] = true;
1567
+ elm.insertBefore(contentRefElm, elm.firstChild);
1568
+ };
1569
+ const disconnectedCallback = (elm) => {
1570
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1571
+ getHostRef(elm);
1572
+ }
1573
+ };
1574
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1575
+ const endBootstrap = createTime();
1576
+ const cmpTags = [];
1577
+ const exclude = options.exclude || [];
1578
+ const customElements = win.customElements;
1579
+ const head = doc.head;
1580
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1581
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1582
+ const deferredConnectedCallbacks = [];
1583
+ let appLoadFallback;
1584
+ let isBootstrapping = true;
1585
+ Object.assign(plt, options);
1586
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1587
+ lazyBundles.map((lazyBundle) => {
1588
+ lazyBundle[1].map((compactMeta) => {
1589
+ const cmpMeta = {
1590
+ $flags$: compactMeta[0],
1591
+ $tagName$: compactMeta[1],
1592
+ $members$: compactMeta[2],
1593
+ $listeners$: compactMeta[3],
1594
+ };
1595
+ {
1596
+ cmpMeta.$members$ = compactMeta[2];
1597
+ }
1598
+ {
1599
+ cmpMeta.$attrsToReflect$ = [];
1600
+ }
1601
+ {
1602
+ cmpMeta.$watchers$ = {};
1603
+ }
1604
+ const tagName = cmpMeta.$tagName$;
1605
+ const HostElement = class extends HTMLElement {
1606
+ // StencilLazyHost
1607
+ constructor(self) {
1608
+ // @ts-ignore
1609
+ super(self);
1610
+ self = this;
1611
+ registerHost(self, cmpMeta);
1612
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1613
+ // this component is using shadow dom
1614
+ // and this browser supports shadow dom
1615
+ // add the read-only property "shadowRoot" to the host element
1616
+ // adding the shadow root build conditionals to minimize runtime
1617
+ {
1618
+ {
1619
+ self.attachShadow({ mode: 'open' });
1620
+ }
1621
+ }
1622
+ }
1623
+ }
1624
+ connectedCallback() {
1625
+ if (appLoadFallback) {
1626
+ clearTimeout(appLoadFallback);
1627
+ appLoadFallback = null;
1628
+ }
1629
+ if (isBootstrapping) {
1630
+ // connectedCallback will be processed once all components have been registered
1631
+ deferredConnectedCallbacks.push(this);
1632
+ }
1633
+ else {
1634
+ plt.jmp(() => connectedCallback(this));
1635
+ }
1636
+ }
1637
+ disconnectedCallback() {
1638
+ plt.jmp(() => disconnectedCallback(this));
1639
+ }
1640
+ componentOnReady() {
1641
+ return getHostRef(this).$onReadyPromise$;
1642
+ }
1643
+ };
1644
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1645
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1646
+ cmpTags.push(tagName);
1647
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1648
+ }
1649
+ });
1650
+ });
1651
+ {
1652
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1653
+ visibilityStyle.setAttribute('data-styles', '');
1654
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1655
+ }
1656
+ // Process deferred connectedCallbacks now all components have been registered
1657
+ isBootstrapping = false;
1658
+ if (deferredConnectedCallbacks.length) {
1659
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1660
+ }
1661
+ else {
1662
+ {
1663
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1664
+ }
1665
+ }
1666
+ // Fallback appLoad event
1667
+ endBootstrap();
1668
+ };
1669
+ const getAssetPath = (path) => {
1670
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
1671
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
1672
+ };
1673
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
1674
+ const hostRefs = new WeakMap();
1675
+ const getHostRef = (ref) => hostRefs.get(ref);
1676
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1677
+ const registerHost = (elm, cmpMeta) => {
1678
+ const hostRef = {
1679
+ $flags$: 0,
1680
+ $hostElement$: elm,
1681
+ $cmpMeta$: cmpMeta,
1682
+ $instanceValues$: new Map(),
1683
+ };
1684
+ {
1685
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1686
+ }
1687
+ {
1688
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1689
+ elm['s-p'] = [];
1690
+ elm['s-rc'] = [];
1691
+ }
1692
+ return hostRefs.set(elm, hostRef);
1693
+ };
1694
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1695
+ const consoleError = (e, el) => (0, console.error)(e, el);
1696
+ const cmpModules = /*@__PURE__*/ new Map();
1697
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1698
+ // loadModuleImport
1699
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1700
+ const bundleId = cmpMeta.$lazyBundleId$;
1701
+ const module = cmpModules.get(bundleId) ;
1702
+ if (module) {
1703
+ return module[exportName];
1704
+ }
1705
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1706
+ /* webpackInclude: /\.entry\.js$/ */
1707
+ /* webpackExclude: /\.system\.entry\.js$/ */
1708
+ /* webpackMode: "lazy" */
1709
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1710
+ {
1711
+ cmpModules.set(bundleId, importedModule);
1712
+ }
1713
+ return importedModule[exportName];
1714
+ }, consoleError);
1715
+ };
1716
+ const styles = new Map();
1717
+ const queueDomReads = [];
1718
+ const queueDomWrites = [];
1719
+ const queueTask = (queue, write) => (cb) => {
1720
+ queue.push(cb);
1721
+ if (!queuePending) {
1722
+ queuePending = true;
1723
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1724
+ nextTick(flush);
1725
+ }
1726
+ else {
1727
+ plt.raf(flush);
1728
+ }
1729
+ }
1730
+ };
1731
+ const consume = (queue) => {
1732
+ for (let i = 0; i < queue.length; i++) {
1733
+ try {
1734
+ queue[i](performance.now());
1735
+ }
1736
+ catch (e) {
1737
+ consoleError(e);
1738
+ }
1739
+ }
1740
+ queue.length = 0;
1741
+ };
1742
+ const flush = () => {
1743
+ // always force a bunch of medium callbacks to run, but still have
1744
+ // a throttle on how many can run in a certain time
1745
+ // DOM READS!!!
1746
+ consume(queueDomReads);
1747
+ // DOM WRITES!!!
1748
+ {
1749
+ consume(queueDomWrites);
1750
+ if ((queuePending = queueDomReads.length > 0)) {
1751
+ // still more to do yet, but we've run out of time
1752
+ // let's let this thing cool off and try again in the next tick
1753
+ plt.raf(flush);
1754
+ }
1755
+ }
1756
+ };
1757
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1758
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1759
+
1760
+ exports.Host = Host;
1761
+ exports.bootstrapLazy = bootstrapLazy;
1762
+ exports.createEvent = createEvent;
1763
+ exports.forceUpdate = forceUpdate;
1764
+ exports.getAssetPath = getAssetPath;
1765
+ exports.getElement = getElement;
1766
+ exports.h = h;
1767
+ exports.promiseResolve = promiseResolve;
1768
+ exports.registerInstance = registerInstance;
1769
+ exports.setAssetPath = setAssetPath;