@sankhyalabs/sankhyablocks 1.3.31-beta.14 → 1.3.31-beta.17

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