@3t-transform/threeteeui 0.0.6 → 0.0.8

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 (121) hide show
  1. package/dist/cjs/{index-8a7479e4.js → index-8a4cb9bc.js} +256 -407
  2. package/dist/cjs/loader.cjs.js +4 -3
  3. package/dist/cjs/tttx-button.cjs.entry.js +28 -0
  4. package/dist/cjs/tttx-checkbox.cjs.entry.js +28 -0
  5. package/dist/cjs/tttx-form.cjs.entry.js +58 -0
  6. package/dist/cjs/tttx-icon.cjs.entry.js +1845 -5
  7. package/dist/cjs/tttx-input.cjs.entry.js +44 -0
  8. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +26 -0
  9. package/dist/cjs/tttx-popover-content.cjs.entry.js +23 -0
  10. package/dist/cjs/tttx.cjs.js +7 -3
  11. package/dist/collection/collection-manifest.json +9 -5
  12. package/dist/collection/components/atoms/tttx-button/tttx-button.css +61 -0
  13. package/dist/collection/components/atoms/tttx-button/tttx-button.js +93 -0
  14. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +27 -0
  15. package/dist/collection/components/atoms/tttx-icon/tttx-icon.css +101 -0
  16. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +114 -0
  17. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +47 -0
  18. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.css +48 -0
  19. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +66 -0
  20. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +15 -0
  21. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.css +30 -0
  22. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.js +96 -0
  23. package/dist/collection/components/atoms/tttx-popover-content/tttx-popover-content.stories.js +23 -0
  24. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.css +135 -0
  25. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.js +101 -0
  26. package/dist/collection/components/atoms/ttx-checkbox/tttx-checkbox.stories.js +13 -0
  27. package/dist/collection/components/molecules/tttx-form/tttx-form.js +109 -0
  28. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +33 -0
  29. package/dist/collection/components/molecules/tttx-input/tttx-input.css +149 -0
  30. package/dist/collection/components/molecules/tttx-input/tttx-input.js +259 -0
  31. package/dist/collection/components/molecules/tttx-input/tttx-input.stories.js +106 -0
  32. package/dist/collection/components/palette.stories.js +88 -0
  33. package/dist/collection/icons.js +2838 -0
  34. package/dist/components/index.d.ts +16 -3
  35. package/dist/components/index.js +7 -3
  36. package/dist/components/{tttx-worksheet.d.ts → tttx-button.d.ts} +4 -4
  37. package/dist/components/tttx-button.js +45 -0
  38. package/dist/components/tttx-checkbox.d.ts +11 -0
  39. package/dist/components/tttx-checkbox.js +46 -0
  40. package/dist/components/{tttx-page.d.ts → tttx-form.d.ts} +4 -4
  41. package/dist/components/tttx-form.js +75 -0
  42. package/dist/components/tttx-icon.js +1 -32
  43. package/dist/components/tttx-icon2.js +1875 -0
  44. package/dist/components/tttx-input.d.ts +11 -0
  45. package/dist/components/tttx-input.js +77 -0
  46. package/dist/components/tttx-loading-spinner.d.ts +11 -0
  47. package/dist/components/tttx-loading-spinner.js +43 -0
  48. package/dist/components/tttx-popover-content.d.ts +11 -0
  49. package/dist/components/tttx-popover-content.js +42 -0
  50. package/dist/esm/{index-854ff56f.js → index-9654537d.js} +254 -408
  51. package/dist/esm/loader.js +4 -3
  52. package/dist/esm/polyfills/css-shim.js +1 -1
  53. package/dist/esm/tttx-button.entry.js +24 -0
  54. package/dist/esm/tttx-checkbox.entry.js +24 -0
  55. package/dist/esm/tttx-form.entry.js +54 -0
  56. package/dist/esm/tttx-icon.entry.js +1845 -5
  57. package/dist/esm/tttx-input.entry.js +40 -0
  58. package/dist/esm/tttx-loading-spinner.entry.js +22 -0
  59. package/dist/esm/tttx-popover-content.entry.js +19 -0
  60. package/dist/esm/tttx.js +4 -3
  61. package/dist/tttx/p-1884203f.entry.js +1 -0
  62. package/dist/tttx/p-317b13d3.entry.js +1 -0
  63. package/dist/tttx/p-3cb692d6.entry.js +1 -0
  64. package/dist/tttx/p-3cd7ad04.entry.js +1 -0
  65. package/dist/tttx/p-674e2f18.entry.js +1 -0
  66. package/dist/tttx/p-a23389f1.entry.js +1 -0
  67. package/dist/tttx/p-b6cc2780.js +2 -0
  68. package/dist/tttx/p-f30a0e84.entry.js +1 -0
  69. package/dist/tttx/tttx.esm.js +1 -1
  70. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +9 -0
  71. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +20 -0
  72. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +14 -0
  73. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +21 -0
  74. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -0
  75. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +5 -0
  76. package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.d.ts +7 -0
  77. package/dist/types/components/atoms/tttx-popover-content/tttx-popover-content.stories.d.ts +18 -0
  78. package/dist/types/components/atoms/ttx-checkbox/tttx-checkbox.d.ts +9 -0
  79. package/dist/types/{docs/template.stories.d.ts → components/atoms/ttx-checkbox/tttx-checkbox.stories.d.ts} +1 -0
  80. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +11 -0
  81. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +13 -0
  82. package/dist/types/components/molecules/tttx-input/tttx-input.d.ts +20 -0
  83. package/dist/types/components/molecules/tttx-input/tttx-input.stories.d.ts +60 -0
  84. package/dist/types/components/palette.stories.d.ts +6 -0
  85. package/dist/types/components.d.ts +142 -38
  86. package/dist/types/icons.d.ts +2 -0
  87. package/dist/types/stencil-public-runtime.d.ts +59 -3
  88. package/loader/index.d.ts +9 -0
  89. package/package.json +33 -25
  90. package/readme.md +14 -32
  91. package/dist/cjs/toolbar-656be6e6.js +0 -34259
  92. package/dist/cjs/tttx-page.cjs.entry.js +0 -927
  93. package/dist/cjs/tttx-worksheet.cjs.entry.js +0 -47
  94. package/dist/collection/components/components/tttx-icon/tttx-icon.css +0 -89
  95. package/dist/collection/components/components/tttx-icon/tttx-icon.js +0 -59
  96. package/dist/collection/components/components/tttx-icon/tttx-icon.stories.js +0 -40
  97. package/dist/collection/components/patterns/tttx-page/tttx-page.css +0 -162
  98. package/dist/collection/components/patterns/tttx-page/tttx-page.js +0 -213
  99. package/dist/collection/components/patterns/tttx-page/tttx-page.stories.js +0 -80
  100. package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.css +0 -134
  101. package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.js +0 -70
  102. package/dist/collection/components/patterns/tttx-worksheet/tttx-worksheet.stories.js +0 -44
  103. package/dist/collection/docs/template.stories.js +0 -10
  104. package/dist/components/tttx-page.js +0 -953
  105. package/dist/components/tttx-worksheet.js +0 -6
  106. package/dist/components/tttx-worksheet2.js +0 -34288
  107. package/dist/esm/toolbar-cede4385.js +0 -34231
  108. package/dist/esm/tttx-page.entry.js +0 -923
  109. package/dist/esm/tttx-worksheet.entry.js +0 -43
  110. package/dist/tttx/p-4b57de2e.entry.js +0 -1
  111. package/dist/tttx/p-61f78304.entry.js +0 -1
  112. package/dist/tttx/p-7244abd4.entry.js +0 -1
  113. package/dist/tttx/p-d038fe18.js +0 -1
  114. package/dist/tttx/p-ddfeb0ba.js +0 -2
  115. package/dist/tttx/tttx.css +0 -1
  116. package/dist/types/components/components/tttx-icon/tttx-icon.d.ts +0 -5
  117. package/dist/types/components/components/tttx-icon/tttx-icon.stories.d.ts +0 -24
  118. package/dist/types/components/patterns/tttx-page/tttx-page.d.ts +0 -21
  119. package/dist/types/components/patterns/tttx-page/tttx-page.stories.d.ts +0 -48
  120. package/dist/types/components/patterns/tttx-worksheet/tttx-worksheet.d.ts +0 -9
  121. package/dist/types/components/patterns/tttx-worksheet/tttx-worksheet.stories.d.ts +0 -23
@@ -30,11 +30,8 @@ const NAMESPACE = 'tttx';
30
30
  *
31
31
  * Modified for Stencil's renderer and slot projection
32
32
  */
33
- let contentRef;
33
+ let scopeId;
34
34
  let hostTagName;
35
- let useNativeShadowDom = false;
36
- let checkSlotFallbackVisibility = false;
37
- let checkSlotRelocate = false;
38
35
  let isSvgMode = false;
39
36
  let queuePending = false;
40
37
  const createTime = (fnName, tagName = '') => {
@@ -60,11 +57,24 @@ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
60
57
  * Don't add values to these!!
61
58
  */
62
59
  const EMPTY_OBJ = {};
60
+ const isDef = (v) => v != null;
63
61
  const isComplexType = (o) => {
64
62
  // https://jsperf.com/typeof-fn-object/5
65
63
  o = typeof o;
66
64
  return o === 'object' || o === 'function';
67
65
  };
66
+ /**
67
+ * Helper method for querying a `meta` tag that contains a nonce value
68
+ * out of a DOM's head.
69
+ *
70
+ * @param doc The DOM containing the `head` to query against
71
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
72
+ * exists or the tag has no content.
73
+ */
74
+ function queryNonceMetaTagContent(doc) {
75
+ var _a, _b, _c;
76
+ return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
77
+ }
68
78
  /**
69
79
  * Production h() function based on Preact by
70
80
  * Jason Miller (@developit)
@@ -73,12 +83,10 @@ const isComplexType = (o) => {
73
83
  *
74
84
  * Modified for Stencil's compiler and vdom
75
85
  */
76
- // const stack: any[] = [];
77
86
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
78
87
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
79
88
  const h = (nodeName, vnodeData, ...children) => {
80
89
  let child = null;
81
- let slotName = null;
82
90
  let simple = false;
83
91
  let lastSimple = false;
84
92
  const vNodeChildren = [];
@@ -106,9 +114,6 @@ const h = (nodeName, vnodeData, ...children) => {
106
114
  };
107
115
  walk(children);
108
116
  if (vnodeData) {
109
- if (vnodeData.name) {
110
- slotName = vnodeData.name;
111
- }
112
117
  {
113
118
  const classData = vnodeData.className || vnodeData.class;
114
119
  if (classData) {
@@ -126,11 +131,16 @@ const h = (nodeName, vnodeData, ...children) => {
126
131
  if (vNodeChildren.length > 0) {
127
132
  vnode.$children$ = vNodeChildren;
128
133
  }
129
- {
130
- vnode.$name$ = slotName;
131
- }
132
134
  return vnode;
133
135
  };
136
+ /**
137
+ * A utility function for creating a virtual DOM node from a tag and some
138
+ * possible text content.
139
+ *
140
+ * @param tag the tag for this element
141
+ * @param text possible text content for the node
142
+ * @returns a newly-minted virtual DOM node
143
+ */
134
144
  const newVNode = (tag, text) => {
135
145
  const vnode = {
136
146
  $flags$: 0,
@@ -142,12 +152,15 @@ const newVNode = (tag, text) => {
142
152
  {
143
153
  vnode.$attrs$ = null;
144
154
  }
145
- {
146
- vnode.$name$ = null;
147
- }
148
155
  return vnode;
149
156
  };
150
157
  const Host = {};
158
+ /**
159
+ * Check whether a given node is a Host node or not
160
+ *
161
+ * @param node the virtual DOM node to check
162
+ * @returns whether it's a Host node or not
163
+ */
151
164
  const isHost = (node) => node && node.$tag$ === Host;
152
165
  /**
153
166
  * Parse a new property value for a given property type.
@@ -175,6 +188,11 @@ const isHost = (node) => node && node.$tag$ === Host;
175
188
  const parsePropertyValue = (propValue, propType) => {
176
189
  // ensure this value is of the correct prop type
177
190
  if (propValue != null && !isComplexType(propValue)) {
191
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
192
+ // per the HTML spec, any string value means it is a boolean true value
193
+ // but we'll cheat here and say that the string "false" is the boolean false
194
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
195
+ }
178
196
  if (propType & 1 /* MEMBER_FLAGS.String */) {
179
197
  // could have been passed as a number or boolean
180
198
  // but we still want it as a string
@@ -187,6 +205,20 @@ const parsePropertyValue = (propValue, propType) => {
187
205
  // so no need to change to a different type
188
206
  return propValue;
189
207
  };
208
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
209
+ const createEvent = (ref, name, flags) => {
210
+ const elm = getElement(ref);
211
+ return {
212
+ emit: (detail) => {
213
+ return emitEvent(elm, name, {
214
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
215
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
216
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
217
+ detail,
218
+ });
219
+ },
220
+ };
221
+ };
190
222
  /**
191
223
  * Helper function to create & dispatch a custom Event on a provided target
192
224
  * @param elm the target of the Event
@@ -217,6 +249,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
217
249
  styles.set(scopeId, style);
218
250
  };
219
251
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
252
+ var _a;
220
253
  let scopeId = getScopeId(cmpMeta);
221
254
  const style = styles.get(scopeId);
222
255
  // if an element is NOT connected then getRootNode() will return the wrong root node
@@ -236,6 +269,11 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
236
269
  styleElm = doc.createElement('style');
237
270
  styleElm.innerHTML = style;
238
271
  }
272
+ // Apply CSP nonce to the style tag if it exists
273
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
274
+ if (nonce != null) {
275
+ styleElm.setAttribute('nonce', nonce);
276
+ }
239
277
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
240
278
  }
241
279
  if (appliedStyles) {
@@ -252,8 +290,20 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
252
290
  const attachStyles = (hostRef) => {
253
291
  const cmpMeta = hostRef.$cmpMeta$;
254
292
  const elm = hostRef.$hostElement$;
293
+ const flags = cmpMeta.$flags$;
255
294
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
256
- addStyle(elm.getRootNode(), cmpMeta);
295
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
296
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
297
+ // only required when we're NOT using native shadow dom (slot)
298
+ // or this browser doesn't support native shadow dom
299
+ // and this host element was NOT created with SSR
300
+ // let's pick out the inner content for slot projection
301
+ // create a node to represent where the original
302
+ // content was first placed, which is useful later on
303
+ // DOM WRITE!!
304
+ elm['s-sc'] = scopeId;
305
+ elm.classList.add(scopeId + '-h');
306
+ }
257
307
  endAttachStyles();
258
308
  };
259
309
  const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
@@ -268,7 +318,7 @@ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
268
318
  const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
269
319
  if (oldValue !== newValue) {
270
320
  let isProp = isMemberInElement(elm, memberName);
271
- memberName.toLowerCase();
321
+ let ln = memberName.toLowerCase();
272
322
  if (memberName === 'class') {
273
323
  const classList = elm.classList;
274
324
  const oldClasses = parseClassList(oldValue);
@@ -276,37 +326,51 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
276
326
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
277
327
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
278
328
  }
279
- else if (memberName === 'style') {
280
- // update style attribute, css properties and values
281
- {
282
- for (const prop in oldValue) {
283
- if (!newValue || newValue[prop] == null) {
284
- if (prop.includes('-')) {
285
- elm.style.removeProperty(prop);
286
- }
287
- else {
288
- elm.style[prop] = '';
289
- }
290
- }
291
- }
292
- }
293
- for (const prop in newValue) {
294
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
295
- if (prop.includes('-')) {
296
- elm.style.setProperty(prop, newValue[prop]);
297
- }
298
- else {
299
- elm.style[prop] = newValue[prop];
300
- }
301
- }
302
- }
303
- }
304
329
  else if (memberName === 'ref') {
305
330
  // minifier will clean this up
306
331
  if (newValue) {
307
332
  newValue(elm);
308
333
  }
309
334
  }
335
+ else if ((!isProp ) &&
336
+ memberName[0] === 'o' &&
337
+ memberName[1] === 'n') {
338
+ // Event Handlers
339
+ // so if the member name starts with "on" and the 3rd characters is
340
+ // a capital letter, and it's not already a member on the element,
341
+ // then we're assuming it's an event listener
342
+ if (memberName[2] === '-') {
343
+ // on- prefixed events
344
+ // allows to be explicit about the dom event to listen without any magic
345
+ // under the hood:
346
+ // <my-cmp on-click> // listens for "click"
347
+ // <my-cmp on-Click> // listens for "Click"
348
+ // <my-cmp on-ionChange> // listens for "ionChange"
349
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
350
+ memberName = memberName.slice(3);
351
+ }
352
+ else if (isMemberInElement(win, ln)) {
353
+ // standard event
354
+ // the JSX attribute could have been "onMouseOver" and the
355
+ // member name "onmouseover" is on the window's prototype
356
+ // so let's add the listener "mouseover", which is all lowercased
357
+ memberName = ln.slice(2);
358
+ }
359
+ else {
360
+ // custom event
361
+ // the JSX attribute could have been "onMyCustomEvent"
362
+ // so let's trim off the "on" prefix and lowercase the first character
363
+ // and add the listener "myCustomEvent"
364
+ // except for the first character, we keep the event name case
365
+ memberName = ln[2] + memberName.slice(3);
366
+ }
367
+ if (oldValue) {
368
+ plt.rel(elm, memberName, oldValue, false);
369
+ }
370
+ if (newValue) {
371
+ plt.ael(elm, memberName, newValue, false);
372
+ }
373
+ }
310
374
  else {
311
375
  // Set property if it exists and it's not a SVG
312
376
  const isComplex = isComplexType(newValue);
@@ -384,36 +448,22 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
384
448
  let i = 0;
385
449
  let elm;
386
450
  let childNode;
387
- let oldVNode;
388
- if (!useNativeShadowDom) {
389
- // remember for later we need to check to relocate nodes
390
- checkSlotRelocate = true;
391
- if (newVNode.$tag$ === 'slot') {
392
- newVNode.$flags$ |= newVNode.$children$
393
- ? // slot element has fallback content
394
- 2 /* VNODE_FLAGS.isSlotFallback */
395
- : // slot element does not have fallback content
396
- 1 /* VNODE_FLAGS.isSlotReference */;
397
- }
398
- }
399
451
  if (newVNode.$text$ !== null) {
400
452
  // create text node
401
453
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
402
454
  }
403
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
404
- // create a slot reference node
405
- elm = newVNode.$elm$ =
406
- doc.createTextNode('');
407
- }
408
455
  else {
409
456
  // create element
410
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
411
- ? 'slot-fb'
412
- : newVNode.$tag$));
457
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
413
458
  // add css classes, attrs, props, listeners, etc.
414
459
  {
415
460
  updateElement(null, newVNode, isSvgMode);
416
461
  }
462
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
463
+ // if there is a scopeId and this is the initial render
464
+ // then let's add the scopeId as a css class
465
+ elm.classList.add((elm['s-si'] = scopeId));
466
+ }
417
467
  if (newVNode.$children$) {
418
468
  for (i = 0; i < newVNode.$children$.length; ++i) {
419
469
  // create the node
@@ -426,82 +476,57 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
426
476
  }
427
477
  }
428
478
  }
429
- {
430
- elm['s-hn'] = hostTagName;
431
- if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
432
- // remember the content reference comment
433
- elm['s-sr'] = true;
434
- // remember the content reference comment
435
- elm['s-cr'] = contentRef;
436
- // remember the slot name, or empty string for default slot
437
- elm['s-sn'] = newVNode.$name$ || '';
438
- // check if we've got an old vnode for this slot
439
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
440
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
441
- // we've got an old slot vnode and the wrapper is being replaced
442
- // so let's move the old slot content back to it's original location
443
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
444
- }
445
- }
446
- }
447
479
  return elm;
448
480
  };
449
- const putBackInOriginalLocation = (parentElm, recursive) => {
450
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
451
- const oldSlotChildNodes = parentElm.childNodes;
452
- for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
453
- const childNode = oldSlotChildNodes[i];
454
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
455
- // // this child node in the old element is from another component
456
- // // remove this node from the old slot's parent
457
- // childNode.remove();
458
- // and relocate it back to it's original location
459
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
460
- // remove the old original location comment entirely
461
- // later on the patch function will know what to do
462
- // and move this to the correct spot in need be
463
- childNode['s-ol'].remove();
464
- childNode['s-ol'] = undefined;
465
- checkSlotRelocate = true;
466
- }
467
- if (recursive) {
468
- putBackInOriginalLocation(childNode, recursive);
469
- }
470
- }
471
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
472
- };
481
+ /**
482
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
483
+ * add them to the DOM in the appropriate place.
484
+ *
485
+ * @param parentElm the DOM node which should be used as a parent for the new
486
+ * DOM nodes
487
+ * @param before a child of the `parentElm` which the new children should be
488
+ * inserted before (optional)
489
+ * @param parentVNode the parent virtual DOM node
490
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
491
+ * @param startIdx the index in the child virtual DOM nodes at which to start
492
+ * creating DOM nodes (inclusive)
493
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
494
+ * creating DOM nodes (inclusive)
495
+ */
473
496
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
474
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
497
+ let containerElm = (parentElm);
475
498
  let childNode;
499
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
500
+ containerElm = containerElm.shadowRoot;
501
+ }
476
502
  for (; startIdx <= endIdx; ++startIdx) {
477
503
  if (vnodes[startIdx]) {
478
504
  childNode = createElm(null, parentVNode, startIdx);
479
505
  if (childNode) {
480
506
  vnodes[startIdx].$elm$ = childNode;
481
- containerElm.insertBefore(childNode, referenceNode(before) );
507
+ containerElm.insertBefore(childNode, before);
482
508
  }
483
509
  }
484
510
  }
485
511
  };
512
+ /**
513
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
514
+ * This can be used to, for instance, clean up after a list of children which
515
+ * should no longer be shown.
516
+ *
517
+ * This function also handles some of Stencil's slot relocation logic.
518
+ *
519
+ * @param vnodes a list of virtual DOM nodes to remove
520
+ * @param startIdx the index at which to start removing nodes (inclusive)
521
+ * @param endIdx the index at which to stop removing nodes (inclusive)
522
+ * @param vnode a VNode
523
+ * @param elm an element
524
+ */
486
525
  const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
487
526
  for (; startIdx <= endIdx; ++startIdx) {
488
527
  if ((vnode = vnodes[startIdx])) {
489
528
  elm = vnode.$elm$;
490
529
  callNodeRefs(vnode);
491
- {
492
- // we're removing this element
493
- // so it's possible we need to show slot fallback content now
494
- checkSlotFallbackVisibility = true;
495
- if (elm['s-ol']) {
496
- // remove the original location comment
497
- elm['s-ol'].remove();
498
- }
499
- else {
500
- // it's possible that child nodes of the node
501
- // that's being removed are slot nodes
502
- putBackInOriginalLocation(elm, true);
503
- }
504
- }
505
530
  // remove the vnode's element from the dom
506
531
  elm.remove();
507
532
  }
@@ -617,23 +642,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
617
642
  newEndVnode = newCh[--newEndIdx];
618
643
  }
619
644
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
620
- // case: "Vnode moved right"
621
- //
622
- // We've found that the last node in our window on the new children is
623
- // the same VNode as the _first_ node in our window on the old children
624
- // we're dealing with now. Visually, this is the layout of these two
625
- // nodes:
626
- //
627
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
628
- // ^^^^^^^^^^^
629
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
630
- // ^^^^^^^^^^^^^
631
- //
632
- // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
633
- // and move the DOM element for `oldStartVnode`.
634
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
635
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
636
- }
637
645
  patch(oldStartVnode, newEndVnode);
638
646
  // We need to move the element for `oldStartVnode` into a position which
639
647
  // will be appropriate for `newEndVnode`. For this we can use
@@ -657,24 +665,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
657
665
  newEndVnode = newCh[--newEndIdx];
658
666
  }
659
667
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
660
- // case: "Vnode moved left"
661
- //
662
- // We've found that the first node in our window on the new children is
663
- // the same VNode as the _last_ node in our window on the old children.
664
- // Visually, this is the layout of these two nodes:
665
- //
666
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
667
- // ^^^^^^^^^^^^^
668
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
669
- // ^^^^^^^^^^^
670
- //
671
- // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
672
- // (which will handle updating any changed attributes, reconciling their
673
- // children etc) but we also need to move the DOM node to which
674
- // `oldEndVnode` corresponds.
675
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
676
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
677
- }
678
668
  patch(oldEndVnode, newStartVnode);
679
669
  // We've already checked above if `oldStartVnode` and `newStartVnode` are
680
670
  // the same node, so since we're here we know that they are not. Thus we
@@ -697,7 +687,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
697
687
  if (node) {
698
688
  // if we created a new node then handle inserting it to the DOM
699
689
  {
700
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
690
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
701
691
  }
702
692
  }
703
693
  }
@@ -724,7 +714,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
724
714
  *
725
715
  * So, in other words, if `key` attrs are not set on VNodes which may be
726
716
  * changing order within a `children` array or something along those lines then
727
- * we could obtain a false positive and then have to do needless re-rendering.
717
+ * we could obtain a false negative and then have to do needless re-rendering
718
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
728
719
  *
729
720
  * @param leftVNode the first VNode to check
730
721
  * @param rightVNode the second VNode to check
@@ -734,21 +725,10 @@ const isSameVnode = (leftVNode, rightVNode) => {
734
725
  // compare if two vnode to see if they're "technically" the same
735
726
  // need to have the same element tag, and same key to be the same
736
727
  if (leftVNode.$tag$ === rightVNode.$tag$) {
737
- if (leftVNode.$tag$ === 'slot') {
738
- return leftVNode.$name$ === rightVNode.$name$;
739
- }
740
728
  return true;
741
729
  }
742
730
  return false;
743
731
  };
744
- const referenceNode = (node) => {
745
- // this node was relocated to a new location in the dom
746
- // because of some other component's slot
747
- // but we still have an html comment in place of where
748
- // it's original location was according to it's original vdom
749
- return (node && node['s-ol']) || node;
750
- };
751
- const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
752
732
  /**
753
733
  * Handle reconciling an outdated VNode with a new one which corresponds to
754
734
  * it. This function handles flushing updates to the DOM and reconciling the
@@ -763,7 +743,6 @@ const patch = (oldVNode, newVNode) => {
763
743
  const newChildren = newVNode.$children$;
764
744
  const tag = newVNode.$tag$;
765
745
  const text = newVNode.$text$;
766
- let defaultHolder;
767
746
  if (text === null) {
768
747
  {
769
748
  if (tag === 'slot')
@@ -794,247 +773,44 @@ const patch = (oldVNode, newVNode) => {
794
773
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
795
774
  }
796
775
  }
797
- else if ((defaultHolder = elm['s-cr'])) {
798
- // this element has slotted content
799
- defaultHolder.parentNode.textContent = text;
800
- }
801
776
  else if (oldVNode.$text$ !== text) {
802
777
  // update the text content for the text only vnode
803
778
  // and also only if the text is different than before
804
779
  elm.data = text;
805
780
  }
806
781
  };
807
- const updateFallbackSlotVisibility = (elm) => {
808
- // tslint:disable-next-line: prefer-const
809
- const childNodes = elm.childNodes;
810
- let childNode;
811
- let i;
812
- let ilen;
813
- let j;
814
- let slotNameAttr;
815
- let nodeType;
816
- for (i = 0, ilen = childNodes.length; i < ilen; i++) {
817
- childNode = childNodes[i];
818
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
819
- if (childNode['s-sr']) {
820
- // this is a slot fallback node
821
- // get the slot name for this slot reference node
822
- slotNameAttr = childNode['s-sn'];
823
- // by default always show a fallback slot node
824
- // then hide it if there are other slots in the light dom
825
- childNode.hidden = false;
826
- for (j = 0; j < ilen; j++) {
827
- nodeType = childNodes[j].nodeType;
828
- if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
829
- // this sibling node is from a different component OR is a named fallback slot node
830
- if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
831
- childNode.hidden = true;
832
- break;
833
- }
834
- }
835
- else {
836
- // this is a default fallback slot node
837
- // any element or text node (with content)
838
- // should hide the default fallback slot node
839
- if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
840
- (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
841
- childNode.hidden = true;
842
- break;
843
- }
844
- }
845
- }
846
- }
847
- // keep drilling down
848
- updateFallbackSlotVisibility(childNode);
849
- }
850
- }
851
- };
852
- const relocateNodes = [];
853
- const relocateSlotContent = (elm) => {
854
- // tslint:disable-next-line: prefer-const
855
- let childNode;
856
- let node;
857
- let hostContentNodes;
858
- let slotNameAttr;
859
- let relocateNodeData;
860
- let j;
861
- let i = 0;
862
- const childNodes = elm.childNodes;
863
- const ilen = childNodes.length;
864
- for (; i < ilen; i++) {
865
- childNode = childNodes[i];
866
- if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
867
- // first got the content reference comment node
868
- // then we got it's parent, which is where all the host content is in now
869
- hostContentNodes = node.parentNode.childNodes;
870
- slotNameAttr = childNode['s-sn'];
871
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
872
- node = hostContentNodes[j];
873
- if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
874
- // let's do some relocating to its new home
875
- // but never relocate a content reference node
876
- // that is suppose to always represent the original content location
877
- if (isNodeLocatedInSlot(node, slotNameAttr)) {
878
- // it's possible we've already decided to relocate this node
879
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
880
- // made some changes to slots
881
- // let's make sure we also double check
882
- // fallbacks are correctly hidden or shown
883
- checkSlotFallbackVisibility = true;
884
- node['s-sn'] = node['s-sn'] || slotNameAttr;
885
- if (relocateNodeData) {
886
- // previously we never found a slot home for this node
887
- // but turns out we did, so let's remember it now
888
- relocateNodeData.$slotRefNode$ = childNode;
889
- }
890
- else {
891
- // add to our list of nodes to relocate
892
- relocateNodes.push({
893
- $slotRefNode$: childNode,
894
- $nodeToRelocate$: node,
895
- });
896
- }
897
- if (node['s-sr']) {
898
- relocateNodes.map((relocateNode) => {
899
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
900
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
901
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
902
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
903
- }
904
- }
905
- });
906
- }
907
- }
908
- else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
909
- // so far this element does not have a slot home, not setting slotRefNode on purpose
910
- // if we never find a home for this element then we'll need to hide it
911
- relocateNodes.push({
912
- $nodeToRelocate$: node,
913
- });
914
- }
915
- }
916
- }
917
- }
918
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
919
- relocateSlotContent(childNode);
920
- }
921
- }
922
- };
923
- const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
924
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
925
- if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
926
- return true;
927
- }
928
- if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
929
- return true;
930
- }
931
- return false;
932
- }
933
- if (nodeToRelocate['s-sn'] === slotNameAttr) {
934
- return true;
935
- }
936
- return slotNameAttr === '';
937
- };
938
782
  const callNodeRefs = (vNode) => {
939
783
  {
940
784
  vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
941
785
  vNode.$children$ && vNode.$children$.map(callNodeRefs);
942
786
  }
943
787
  };
788
+ /**
789
+ * The main entry point for Stencil's virtual DOM-based rendering engine
790
+ *
791
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
792
+ * function will handle creating a virtual DOM tree with a single root, patching
793
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
794
+ * relocation, and reflecting attributes.
795
+ *
796
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
797
+ * the DOM node into which it should be rendered.
798
+ * @param renderFnResults the virtual DOM nodes to be rendered
799
+ */
944
800
  const renderVdom = (hostRef, renderFnResults) => {
945
801
  const hostElm = hostRef.$hostElement$;
946
- const cmpMeta = hostRef.$cmpMeta$;
947
802
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
948
803
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
949
804
  hostTagName = hostElm.tagName;
950
805
  rootVnode.$tag$ = null;
951
806
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
952
807
  hostRef.$vnode$ = rootVnode;
953
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
808
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
954
809
  {
955
- contentRef = hostElm['s-cr'];
956
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
957
- // always reset
958
- checkSlotFallbackVisibility = false;
810
+ scopeId = hostElm['s-sc'];
959
811
  }
960
812
  // synchronous patch
961
813
  patch(oldVNode, rootVnode);
962
- {
963
- // while we're moving nodes around existing nodes, temporarily disable
964
- // the disconnectCallback from working
965
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
966
- if (checkSlotRelocate) {
967
- relocateSlotContent(rootVnode.$elm$);
968
- let relocateData;
969
- let nodeToRelocate;
970
- let orgLocationNode;
971
- let parentNodeRef;
972
- let insertBeforeNode;
973
- let refNode;
974
- let i = 0;
975
- for (; i < relocateNodes.length; i++) {
976
- relocateData = relocateNodes[i];
977
- nodeToRelocate = relocateData.$nodeToRelocate$;
978
- if (!nodeToRelocate['s-ol']) {
979
- // add a reference node marking this node's original location
980
- // keep a reference to this node for later lookups
981
- orgLocationNode =
982
- doc.createTextNode('');
983
- orgLocationNode['s-nr'] = nodeToRelocate;
984
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
985
- }
986
- }
987
- for (i = 0; i < relocateNodes.length; i++) {
988
- relocateData = relocateNodes[i];
989
- nodeToRelocate = relocateData.$nodeToRelocate$;
990
- if (relocateData.$slotRefNode$) {
991
- // by default we're just going to insert it directly
992
- // after the slot reference node
993
- parentNodeRef = relocateData.$slotRefNode$.parentNode;
994
- insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
995
- orgLocationNode = nodeToRelocate['s-ol'];
996
- while ((orgLocationNode = orgLocationNode.previousSibling)) {
997
- refNode = orgLocationNode['s-nr'];
998
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
999
- refNode = refNode.nextSibling;
1000
- if (!refNode || !refNode['s-nr']) {
1001
- insertBeforeNode = refNode;
1002
- break;
1003
- }
1004
- }
1005
- }
1006
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1007
- nodeToRelocate.nextSibling !== insertBeforeNode) {
1008
- // we've checked that it's worth while to relocate
1009
- // since that the node to relocate
1010
- // has a different next sibling or parent relocated
1011
- if (nodeToRelocate !== insertBeforeNode) {
1012
- if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1013
- // probably a component in the index.html that doesn't have it's hostname set
1014
- nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1015
- }
1016
- // add it back to the dom but in its new home
1017
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1018
- }
1019
- }
1020
- }
1021
- else {
1022
- // this node doesn't have a slot home to go to, so let's hide it
1023
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1024
- nodeToRelocate.hidden = true;
1025
- }
1026
- }
1027
- }
1028
- }
1029
- if (checkSlotFallbackVisibility) {
1030
- updateFallbackSlotVisibility(rootVnode.$elm$);
1031
- }
1032
- // done moving nodes around
1033
- // allow the disconnect callback to work again
1034
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1035
- // always reset
1036
- relocateNodes.length = 0;
1037
- }
1038
814
  };
1039
815
  const attachToAncestor = (hostRef, ancestorComponent) => {
1040
816
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
@@ -1060,6 +836,18 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
1060
836
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1061
837
  const instance = hostRef.$lazyInstance$ ;
1062
838
  let promise;
839
+ if (isInitialLoad) {
840
+ {
841
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
842
+ if (hostRef.$queuedListeners$) {
843
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
844
+ hostRef.$queuedListeners$ = null;
845
+ }
846
+ }
847
+ {
848
+ promise = safeCall(instance, 'componentWillLoad');
849
+ }
850
+ }
1063
851
  endSchedule();
1064
852
  return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1065
853
  };
@@ -1391,15 +1179,6 @@ const connectedCallback = (elm) => {
1391
1179
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1392
1180
  // first time this component has connected
1393
1181
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1394
- {
1395
- // initUpdate
1396
- // if the slot polyfill is required we'll need to put some nodes
1397
- // in here to act as original content anchors as we move nodes around
1398
- // host element has been connected to the DOM
1399
- if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1400
- setContentReference(elm);
1401
- }
1402
- }
1403
1182
  {
1404
1183
  // find the first ancestor component (if there is one) and register
1405
1184
  // this component as one of the actively loading child components for its ancestor
@@ -1430,26 +1209,32 @@ const connectedCallback = (elm) => {
1430
1209
  initializeComponent(elm, hostRef, cmpMeta);
1431
1210
  }
1432
1211
  }
1212
+ else {
1213
+ // not the first time this has connected
1214
+ // reattach any event listeners to the host
1215
+ // since they would have been removed when disconnected
1216
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1217
+ }
1433
1218
  endConnected();
1434
1219
  }
1435
1220
  };
1436
- const setContentReference = (elm) => {
1437
- // only required when we're NOT using native shadow dom (slot)
1438
- // or this browser doesn't support native shadow dom
1439
- // and this host element was NOT created with SSR
1440
- // let's pick out the inner content for slot projection
1441
- // create a node to represent where the original
1442
- // content was first placed, which is useful later on
1443
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1444
- contentRefElm['s-cn'] = true;
1445
- elm.insertBefore(contentRefElm, elm.firstChild);
1446
- };
1447
1221
  const disconnectedCallback = (elm) => {
1448
1222
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1449
- getHostRef(elm);
1223
+ const hostRef = getHostRef(elm);
1224
+ const instance = hostRef.$lazyInstance$ ;
1225
+ {
1226
+ if (hostRef.$rmListeners$) {
1227
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1228
+ hostRef.$rmListeners$ = undefined;
1229
+ }
1230
+ }
1231
+ {
1232
+ safeCall(instance, 'disconnectedCallback');
1233
+ }
1450
1234
  }
1451
1235
  };
1452
1236
  const bootstrapLazy = (lazyBundles, options = {}) => {
1237
+ var _a;
1453
1238
  const endBootstrap = createTime();
1454
1239
  const cmpTags = [];
1455
1240
  const exclude = options.exclude || [];
@@ -1473,6 +1258,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1473
1258
  {
1474
1259
  cmpMeta.$members$ = compactMeta[2];
1475
1260
  }
1261
+ {
1262
+ cmpMeta.$listeners$ = compactMeta[3];
1263
+ }
1476
1264
  const tagName = cmpMeta.$tagName$;
1477
1265
  const HostElement = class extends HTMLElement {
1478
1266
  // StencilLazyHost
@@ -1481,6 +1269,17 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1481
1269
  super(self);
1482
1270
  self = this;
1483
1271
  registerHost(self, cmpMeta);
1272
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1273
+ // this component is using shadow dom
1274
+ // and this browser supports shadow dom
1275
+ // add the read-only property "shadowRoot" to the host element
1276
+ // adding the shadow root build conditionals to minimize runtime
1277
+ {
1278
+ {
1279
+ self.attachShadow({ mode: 'open' });
1280
+ }
1281
+ }
1282
+ }
1484
1283
  }
1485
1284
  connectedCallback() {
1486
1285
  if (appLoadFallback) {
@@ -1512,6 +1311,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1512
1311
  {
1513
1312
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1514
1313
  visibilityStyle.setAttribute('data-styles', '');
1314
+ // Apply CSP nonce to the style tag if it exists
1315
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1316
+ if (nonce != null) {
1317
+ visibilityStyle.setAttribute('nonce', nonce);
1318
+ }
1515
1319
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1516
1320
  }
1517
1321
  // Process deferred connectedCallbacks now all components have been registered
@@ -1527,6 +1331,47 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1527
1331
  // Fallback appLoad event
1528
1332
  endBootstrap();
1529
1333
  };
1334
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1335
+ if (listeners) {
1336
+ listeners.map(([flags, name, method]) => {
1337
+ const target = getHostListenerTarget(elm, flags) ;
1338
+ const handler = hostListenerProxy(hostRef, method);
1339
+ const opts = hostListenerOpts(flags);
1340
+ plt.ael(target, name, handler, opts);
1341
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1342
+ });
1343
+ }
1344
+ };
1345
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1346
+ try {
1347
+ {
1348
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1349
+ // instance is ready, let's call it's member method for this event
1350
+ hostRef.$lazyInstance$[methodName](ev);
1351
+ }
1352
+ else {
1353
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1354
+ }
1355
+ }
1356
+ }
1357
+ catch (e) {
1358
+ consoleError(e);
1359
+ }
1360
+ };
1361
+ const getHostListenerTarget = (elm, flags) => {
1362
+ if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
1363
+ return doc;
1364
+ return elm;
1365
+ };
1366
+ // prettier-ignore
1367
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1368
+ /**
1369
+ * Assigns the given value to the nonce property on the runtime platform object.
1370
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1371
+ * @param nonce The value to be assigned to the platform nonce property.
1372
+ * @returns void
1373
+ */
1374
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1530
1375
  const hostRefs = /*@__PURE__*/ new WeakMap();
1531
1376
  const getHostRef = (ref) => hostRefs.get(ref);
1532
1377
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
@@ -1542,6 +1387,7 @@ const registerHost = (elm, cmpMeta) => {
1542
1387
  elm['s-p'] = [];
1543
1388
  elm['s-rc'] = [];
1544
1389
  }
1390
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1545
1391
  return hostRefs.set(elm, hostRef);
1546
1392
  };
1547
1393
  const isMemberInElement = (elm, memberName) => memberName in elm;
@@ -1635,6 +1481,9 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1635
1481
 
1636
1482
  exports.Host = Host;
1637
1483
  exports.bootstrapLazy = bootstrapLazy;
1484
+ exports.createEvent = createEvent;
1485
+ exports.getElement = getElement;
1638
1486
  exports.h = h;
1639
1487
  exports.promiseResolve = promiseResolve;
1640
1488
  exports.registerInstance = registerInstance;
1489
+ exports.setNonce = setNonce;