@sankhyalabs/sankhyablocks 1.3.34 → 1.4.0-beta.1

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