@sankhyalabs/sankhyablocks 1.3.31-beta.2 → 1.3.31-beta.20

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