@jumpgroup/jump-design-system 0.1.8 → 0.2.0

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 (118) hide show
  1. package/dist/cjs/{index-91a3ed32.js → index-4b95f596.js} +458 -43
  2. package/dist/cjs/index-4b95f596.js.map +1 -0
  3. package/dist/cjs/jump-badge.cjs.entry.js +24 -0
  4. package/dist/cjs/jump-badge.cjs.entry.js.map +1 -0
  5. package/dist/cjs/jump-button.cjs.entry.js +2 -2
  6. package/dist/cjs/jump-button.cjs.entry.js.map +1 -1
  7. package/dist/cjs/jump-card.cjs.entry.js +34 -0
  8. package/dist/cjs/jump-card.cjs.entry.js.map +1 -0
  9. package/dist/cjs/jump-design-system.cjs.js +3 -3
  10. package/dist/cjs/jump-design-system.cjs.js.map +1 -1
  11. package/dist/cjs/jump-icon.cjs.entry.js +1 -1
  12. package/dist/cjs/jump-pagination.cjs.entry.js +4 -4
  13. package/dist/cjs/loader.cjs.js +2 -2
  14. package/dist/collection/collection-manifest.json +3 -1
  15. package/dist/collection/components/jump-badge/jump-badge.css +25 -0
  16. package/dist/collection/components/jump-badge/jump-badge.js +62 -0
  17. package/dist/collection/components/jump-badge/jump-badge.js.map +1 -0
  18. package/dist/collection/components/jump-badge/jump-badge.stories.js +26 -0
  19. package/dist/collection/components/jump-badge/jump-badge.stories.js.map +1 -0
  20. package/dist/collection/components/jump-badge/test/jump-badge.e2e.js +10 -0
  21. package/dist/collection/components/jump-badge/test/jump-badge.e2e.js.map +1 -0
  22. package/dist/collection/components/jump-badge/test/jump-badge.spec.js +18 -0
  23. package/dist/collection/components/jump-badge/test/jump-badge.spec.js.map +1 -0
  24. package/dist/collection/components/jump-button/{jump-button.stories.js → jump-button-filled.stories.js} +12 -10
  25. package/dist/collection/components/jump-button/jump-button-filled.stories.js.map +1 -0
  26. package/dist/collection/components/jump-button/jump-button-outline.stories.js +376 -0
  27. package/dist/collection/components/jump-button/jump-button-outline.stories.js.map +1 -0
  28. package/dist/collection/components/jump-button/jump-button.js +1 -2
  29. package/dist/collection/components/jump-button/jump-button.js.map +1 -1
  30. package/dist/collection/components/jump-card/jump-card-border-radius.stories.js +114 -0
  31. package/dist/collection/components/jump-card/jump-card-border-radius.stories.js.map +1 -0
  32. package/dist/collection/components/jump-card/jump-card-border.stories.js +113 -0
  33. package/dist/collection/components/jump-card/jump-card-border.stories.js.map +1 -0
  34. package/dist/collection/components/jump-card/jump-card-boxed.stories.js +114 -0
  35. package/dist/collection/components/jump-card/jump-card-boxed.stories.js.map +1 -0
  36. package/dist/collection/components/jump-card/jump-card-horizontal.stories.js +114 -0
  37. package/dist/collection/components/jump-card/jump-card-horizontal.stories.js.map +1 -0
  38. package/dist/collection/components/jump-card/jump-card-media-rounded.stories.js +125 -0
  39. package/dist/collection/components/jump-card/jump-card-media-rounded.stories.js.map +1 -0
  40. package/dist/collection/components/jump-card/jump-card-no-image.stories.js +112 -0
  41. package/dist/collection/components/jump-card/jump-card-no-image.stories.js.map +1 -0
  42. package/dist/collection/components/jump-card/jump-card-shadow.stories.js +113 -0
  43. package/dist/collection/components/jump-card/jump-card-shadow.stories.js.map +1 -0
  44. package/dist/collection/components/jump-card/jump-card-top-border-content-radius.stories.js +114 -0
  45. package/dist/collection/components/jump-card/jump-card-top-border-content-radius.stories.js.map +1 -0
  46. package/dist/collection/components/jump-card/jump-card-video.stories.js +111 -0
  47. package/dist/collection/components/jump-card/jump-card-video.stories.js.map +1 -0
  48. package/dist/collection/components/jump-card/jump-card.css +99 -0
  49. package/dist/collection/components/jump-card/jump-card.js +232 -0
  50. package/dist/collection/components/jump-card/jump-card.js.map +1 -0
  51. package/dist/collection/components/jump-card/jump-card.stories.js +113 -0
  52. package/dist/collection/components/jump-card/jump-card.stories.js.map +1 -0
  53. package/dist/collection/components/jump-card/test/jump-card.e2e.js +10 -0
  54. package/dist/collection/components/jump-card/test/jump-card.e2e.js.map +1 -0
  55. package/dist/collection/components/jump-card/test/jump-card.spec.js +18 -0
  56. package/dist/collection/components/jump-card/test/jump-card.spec.js.map +1 -0
  57. package/dist/collection/components/jump-pagination/jump-pagination.js +3 -3
  58. package/dist/components/jump-badge.d.ts +11 -0
  59. package/dist/components/jump-badge.js +40 -0
  60. package/dist/components/jump-badge.js.map +1 -0
  61. package/dist/components/jump-button.js +2 -3
  62. package/dist/components/jump-button.js.map +1 -1
  63. package/dist/components/jump-card.d.ts +11 -0
  64. package/dist/components/jump-card.js +59 -0
  65. package/dist/components/jump-card.js.map +1 -0
  66. package/dist/components/jump-pagination.js +3 -3
  67. package/dist/esm/{index-3cf3394c.js → index-6fbf8ed3.js} +458 -43
  68. package/dist/esm/index-6fbf8ed3.js.map +1 -0
  69. package/dist/esm/jump-badge.entry.js +20 -0
  70. package/dist/esm/jump-badge.entry.js.map +1 -0
  71. package/dist/esm/jump-button.entry.js +2 -2
  72. package/dist/esm/jump-button.entry.js.map +1 -1
  73. package/dist/esm/jump-card.entry.js +30 -0
  74. package/dist/esm/jump-card.entry.js.map +1 -0
  75. package/dist/esm/jump-design-system.js +4 -4
  76. package/dist/esm/jump-design-system.js.map +1 -1
  77. package/dist/esm/jump-icon.entry.js +1 -1
  78. package/dist/esm/jump-pagination.entry.js +4 -4
  79. package/dist/esm/loader.js +3 -3
  80. package/dist/jump-design-system/jump-design-system.esm.js +1 -1
  81. package/dist/jump-design-system/jump-design-system.esm.js.map +1 -1
  82. package/dist/jump-design-system/p-22f19a67.entry.js +2 -0
  83. package/dist/jump-design-system/p-22f19a67.entry.js.map +1 -0
  84. package/dist/jump-design-system/{p-85fbbf60.entry.js → p-70d78318.entry.js} +2 -2
  85. package/dist/jump-design-system/p-c2ab38b9.js +3 -0
  86. package/dist/jump-design-system/p-c2ab38b9.js.map +1 -0
  87. package/dist/jump-design-system/{p-e2af0fd9.entry.js → p-db7d19d5.entry.js} +2 -2
  88. package/dist/jump-design-system/p-db7d19d5.entry.js.map +1 -0
  89. package/dist/jump-design-system/{p-f4cfa17d.entry.js → p-f1c84912.entry.js} +2 -2
  90. package/dist/jump-design-system/p-f77f001e.entry.js +2 -0
  91. package/dist/jump-design-system/p-f77f001e.entry.js.map +1 -0
  92. package/dist/jump-design-system-elements.json +78 -0
  93. package/dist/types/components/jump-badge/jump-badge.d.ts +11 -0
  94. package/dist/types/components/jump-badge/jump-badge.stories.d.ts +19 -0
  95. package/dist/types/components/jump-button/jump-button-outline.stories.d.ts +164 -0
  96. package/dist/types/components/jump-card/jump-card-border-radius.stories.d.ts +77 -0
  97. package/dist/types/components/jump-card/jump-card-border.stories.d.ts +77 -0
  98. package/dist/types/components/jump-card/jump-card-boxed.stories.d.ts +77 -0
  99. package/dist/types/components/jump-card/jump-card-horizontal.stories.d.ts +77 -0
  100. package/dist/types/components/jump-card/jump-card-media-rounded.stories.d.ts +79 -0
  101. package/dist/types/components/jump-card/jump-card-no-image.stories.d.ts +77 -0
  102. package/dist/types/components/jump-card/jump-card-shadow.stories.d.ts +77 -0
  103. package/dist/types/components/jump-card/jump-card-top-border-content-radius.stories.d.ts +77 -0
  104. package/dist/types/components/jump-card/jump-card-video.stories.d.ts +77 -0
  105. package/dist/types/components/jump-card/jump-card.d.ts +47 -0
  106. package/dist/types/components/jump-card/jump-card.stories.d.ts +77 -0
  107. package/dist/types/components.d.ts +130 -0
  108. package/package.json +1 -1
  109. package/readme.md +4 -3
  110. package/dist/cjs/index-91a3ed32.js.map +0 -1
  111. package/dist/collection/components/jump-button/jump-button.stories.js.map +0 -1
  112. package/dist/esm/index-3cf3394c.js.map +0 -1
  113. package/dist/jump-design-system/p-7216d46f.js +0 -3
  114. package/dist/jump-design-system/p-7216d46f.js.map +0 -1
  115. package/dist/jump-design-system/p-e2af0fd9.entry.js.map +0 -1
  116. /package/dist/jump-design-system/{p-85fbbf60.entry.js.map → p-70d78318.entry.js.map} +0 -0
  117. /package/dist/jump-design-system/{p-f4cfa17d.entry.js.map → p-f1c84912.entry.js.map} +0 -0
  118. /package/dist/types/components/jump-button/{jump-button.stories.d.ts → jump-button-filled.stories.d.ts} +0 -0
@@ -1,4 +1,5 @@
1
1
  const NAMESPACE = 'jump-design-system';
2
+ const BUILD = /* jump-design-system */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: false, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: false, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: false, propNumber: true, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: false, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: false, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: false };
2
3
 
3
4
  /**
4
5
  * Virtual DOM patching algorithm based on Snabbdom by
@@ -8,9 +9,11 @@ const NAMESPACE = 'jump-design-system';
8
9
  *
9
10
  * Modified for Stencil's renderer and slot projection
10
11
  */
11
- let scopeId;
12
+ let contentRef;
12
13
  let hostTagName;
13
14
  let useNativeShadowDom = false;
15
+ let checkSlotFallbackVisibility = false;
16
+ let checkSlotRelocate = false;
14
17
  let isSvgMode = false;
15
18
  let queuePending = false;
16
19
  const createTime = (fnName, tagName = '') => {
@@ -43,7 +46,6 @@ const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
43
46
  * Don't add values to these!!
44
47
  */
45
48
  const EMPTY_OBJ = {};
46
- const isDef = (v) => v != null;
47
49
  /**
48
50
  * Check whether a value is a 'complex type', defined here as an object or a
49
51
  * function.
@@ -81,6 +83,7 @@ function queryNonceMetaTagContent(doc) {
81
83
  const h = (nodeName, vnodeData, ...children) => {
82
84
  let child = null;
83
85
  let key = null;
86
+ let slotName = null;
84
87
  let simple = false;
85
88
  let lastSimple = false;
86
89
  const vNodeChildren = [];
@@ -111,6 +114,9 @@ const h = (nodeName, vnodeData, ...children) => {
111
114
  if (vnodeData.key) {
112
115
  key = vnodeData.key;
113
116
  }
117
+ if (vnodeData.name) {
118
+ slotName = vnodeData.name;
119
+ }
114
120
  // normalize class / className attributes
115
121
  {
116
122
  const classData = vnodeData.className || vnodeData.class;
@@ -132,6 +138,9 @@ const h = (nodeName, vnodeData, ...children) => {
132
138
  {
133
139
  vnode.$key$ = key;
134
140
  }
141
+ {
142
+ vnode.$name$ = slotName;
143
+ }
135
144
  return vnode;
136
145
  };
137
146
  /**
@@ -156,6 +165,9 @@ const newVNode = (tag, text) => {
156
165
  {
157
166
  vnode.$key$ = null;
158
167
  }
168
+ {
169
+ vnode.$name$ = null;
170
+ }
159
171
  return vnode;
160
172
  };
161
173
  const Host = {};
@@ -286,20 +298,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
286
298
  const attachStyles = (hostRef) => {
287
299
  const cmpMeta = hostRef.$cmpMeta$;
288
300
  const elm = hostRef.$hostElement$;
289
- const flags = cmpMeta.$flags$;
290
301
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
291
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
292
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
293
- // only required when we're NOT using native shadow dom (slot)
294
- // or this browser doesn't support native shadow dom
295
- // and this host element was NOT created with SSR
296
- // let's pick out the inner content for slot projection
297
- // create a node to represent where the original
298
- // content was first placed, which is useful later on
299
- // DOM WRITE!!
300
- elm['s-sc'] = scopeId;
301
- elm.classList.add(scopeId + '-h');
302
- }
302
+ addStyle(elm.getRootNode(), cmpMeta);
303
303
  endAttachStyles();
304
304
  };
305
305
  const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
@@ -425,22 +425,36 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
425
425
  let i = 0;
426
426
  let elm;
427
427
  let childNode;
428
+ let oldVNode;
429
+ if (!useNativeShadowDom) {
430
+ // remember for later we need to check to relocate nodes
431
+ checkSlotRelocate = true;
432
+ if (newVNode.$tag$ === 'slot') {
433
+ newVNode.$flags$ |= newVNode.$children$
434
+ ? // slot element has fallback content
435
+ 2 /* VNODE_FLAGS.isSlotFallback */
436
+ : // slot element does not have fallback content
437
+ 1 /* VNODE_FLAGS.isSlotReference */;
438
+ }
439
+ }
428
440
  if (newVNode.$text$ !== null) {
429
441
  // create text node
430
442
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
431
443
  }
444
+ else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
445
+ // create a slot reference node
446
+ elm = newVNode.$elm$ =
447
+ doc.createTextNode('');
448
+ }
432
449
  else {
433
450
  // create element
434
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
451
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
452
+ ? 'slot-fb'
453
+ : newVNode.$tag$));
435
454
  // add css classes, attrs, props, listeners, etc.
436
455
  {
437
456
  updateElement(null, newVNode, isSvgMode);
438
457
  }
439
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
440
- // if there is a scopeId and this is the initial render
441
- // then let's add the scopeId as a css class
442
- elm.classList.add((elm['s-si'] = scopeId));
443
- }
444
458
  if (newVNode.$children$) {
445
459
  for (i = 0; i < newVNode.$children$.length; ++i) {
446
460
  // create the node
@@ -456,8 +470,50 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
456
470
  // This needs to always happen so we can hide nodes that are projected
457
471
  // to another component but don't end up in a slot
458
472
  elm['s-hn'] = hostTagName;
473
+ {
474
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
475
+ // remember the content reference comment
476
+ elm['s-sr'] = true;
477
+ // remember the content reference comment
478
+ elm['s-cr'] = contentRef;
479
+ // remember the slot name, or empty string for default slot
480
+ elm['s-sn'] = newVNode.$name$ || '';
481
+ // check if we've got an old vnode for this slot
482
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
483
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
484
+ {
485
+ // we've got an old slot vnode and the wrapper is being replaced
486
+ // so let's move the old slot content back to its original location
487
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
488
+ }
489
+ }
490
+ }
491
+ }
459
492
  return elm;
460
493
  };
494
+ const putBackInOriginalLocation = (parentElm, recursive) => {
495
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
496
+ const oldSlotChildNodes = parentElm.childNodes;
497
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
498
+ const childNode = oldSlotChildNodes[i];
499
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
500
+ // and relocate it back to it's original location
501
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
502
+ // remove the old original location comment entirely
503
+ // later on the patch function will know what to do
504
+ // and move this to the correct spot if need be
505
+ childNode['s-ol'].remove();
506
+ childNode['s-ol'] = undefined;
507
+ // Reset so we can correctly move the node around again.
508
+ childNode['s-sh'] = undefined;
509
+ checkSlotRelocate = true;
510
+ }
511
+ if (recursive) {
512
+ putBackInOriginalLocation(childNode, recursive);
513
+ }
514
+ }
515
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
516
+ };
461
517
  /**
462
518
  * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
463
519
  * add them to the DOM in the appropriate place.
@@ -474,17 +530,14 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
474
530
  * creating DOM nodes (inclusive)
475
531
  */
476
532
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
477
- let containerElm = (parentElm);
533
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
478
534
  let childNode;
479
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
480
- containerElm = containerElm.shadowRoot;
481
- }
482
535
  for (; startIdx <= endIdx; ++startIdx) {
483
536
  if (vnodes[startIdx]) {
484
537
  childNode = createElm(null, parentVNode, startIdx);
485
538
  if (childNode) {
486
539
  vnodes[startIdx].$elm$ = childNode;
487
- containerElm.insertBefore(childNode, before);
540
+ containerElm.insertBefore(childNode, referenceNode(before) );
488
541
  }
489
542
  }
490
543
  }
@@ -506,6 +559,20 @@ const removeVnodes = (vnodes, startIdx, endIdx) => {
506
559
  if (vnode) {
507
560
  const elm = vnode.$elm$;
508
561
  if (elm) {
562
+ {
563
+ // we're removing this element
564
+ // so it's possible we need to show slot fallback content now
565
+ checkSlotFallbackVisibility = true;
566
+ if (elm['s-ol']) {
567
+ // remove the original location comment
568
+ elm['s-ol'].remove();
569
+ }
570
+ else {
571
+ // it's possible that child nodes of the node
572
+ // that's being removed are slot nodes
573
+ putBackInOriginalLocation(elm, true);
574
+ }
575
+ }
509
576
  // remove the vnode's element from the dom
510
577
  elm.remove();
511
578
  }
@@ -626,6 +693,23 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
626
693
  newEndVnode = newCh[--newEndIdx];
627
694
  }
628
695
  else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
696
+ // case: "Vnode moved right"
697
+ //
698
+ // We've found that the last node in our window on the new children is
699
+ // the same VNode as the _first_ node in our window on the old children
700
+ // we're dealing with now. Visually, this is the layout of these two
701
+ // nodes:
702
+ //
703
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
704
+ // ^^^^^^^^^^^
705
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
706
+ // ^^^^^^^^^^^^^
707
+ //
708
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
709
+ // and move the DOM element for `oldStartVnode`.
710
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
711
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
712
+ }
629
713
  patch(oldStartVnode, newEndVnode, isInitialRender);
630
714
  // We need to move the element for `oldStartVnode` into a position which
631
715
  // will be appropriate for `newEndVnode`. For this we can use
@@ -649,6 +733,24 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
649
733
  newEndVnode = newCh[--newEndIdx];
650
734
  }
651
735
  else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
736
+ // case: "Vnode moved left"
737
+ //
738
+ // We've found that the first node in our window on the new children is
739
+ // the same VNode as the _last_ node in our window on the old children.
740
+ // Visually, this is the layout of these two nodes:
741
+ //
742
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
743
+ // ^^^^^^^^^^^^^
744
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
745
+ // ^^^^^^^^^^^
746
+ //
747
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
748
+ // (which will handle updating any changed attributes, reconciling their
749
+ // children etc) but we also need to move the DOM node to which
750
+ // `oldEndVnode` corresponds.
751
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
752
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
753
+ }
652
754
  patch(oldEndVnode, newStartVnode, isInitialRender);
653
755
  // We've already checked above if `oldStartVnode` and `newStartVnode` are
654
756
  // the same node, so since we're here we know that they are not. Thus we
@@ -705,7 +807,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
705
807
  if (node) {
706
808
  // if we created a new node then handle inserting it to the DOM
707
809
  {
708
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
810
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
709
811
  }
710
812
  }
711
813
  }
@@ -744,6 +846,9 @@ const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
744
846
  // compare if two vnode to see if they're "technically" the same
745
847
  // need to have the same element tag, and same key to be the same
746
848
  if (leftVNode.$tag$ === rightVNode.$tag$) {
849
+ if (leftVNode.$tag$ === 'slot') {
850
+ return leftVNode.$name$ === rightVNode.$name$;
851
+ }
747
852
  // this will be set if JSX tags in the build have `key` attrs set on them
748
853
  // we only want to check this if we're not on the first render since on
749
854
  // first render `leftVNode.$key$` will always be `null`, so we can be led
@@ -756,6 +861,14 @@ const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
756
861
  }
757
862
  return false;
758
863
  };
864
+ const referenceNode = (node) => {
865
+ // this node was relocated to a new location in the dom
866
+ // because of some other component's slot
867
+ // but we still have an html comment in place of where
868
+ // it's original location was according to it's original vdom
869
+ return (node && node['s-ol']) || node;
870
+ };
871
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
759
872
  /**
760
873
  * Handle reconciling an outdated VNode with a new one which corresponds to
761
874
  * it. This function handles flushing updates to the DOM and reconciling the
@@ -771,6 +884,7 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
771
884
  const newChildren = newVNode.$children$;
772
885
  const tag = newVNode.$tag$;
773
886
  const text = newVNode.$text$;
887
+ let defaultHolder;
774
888
  if (text === null) {
775
889
  {
776
890
  if (tag === 'slot' && !useNativeShadowDom) ;
@@ -800,12 +914,193 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
800
914
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
801
915
  }
802
916
  }
917
+ else if ((defaultHolder = elm['s-cr'])) {
918
+ // this element has slotted content
919
+ defaultHolder.parentNode.textContent = text;
920
+ }
803
921
  else if (oldVNode.$text$ !== text) {
804
922
  // update the text content for the text only vnode
805
923
  // and also only if the text is different than before
806
924
  elm.data = text;
807
925
  }
808
926
  };
927
+ /**
928
+ * Adjust the `.hidden` property as-needed on any nodes in a DOM subtree which
929
+ * are slot fallbacks nodes.
930
+ *
931
+ * A slot fallback node should be visible by default. Then, it should be
932
+ * conditionally hidden if:
933
+ *
934
+ * - it has a sibling with a `slot` property set to its slot name or if
935
+ * - it is a default fallback slot node, in which case we hide if it has any
936
+ * content
937
+ *
938
+ * @param elm the element of interest
939
+ */
940
+ const updateFallbackSlotVisibility = (elm) => {
941
+ const childNodes = elm.childNodes;
942
+ for (const childNode of childNodes) {
943
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
944
+ if (childNode['s-sr']) {
945
+ // this is a slot fallback node
946
+ // get the slot name for this slot reference node
947
+ const slotName = childNode['s-sn'];
948
+ // by default always show a fallback slot node
949
+ // then hide it if there are other slots in the light dom
950
+ childNode.hidden = false;
951
+ // we need to check all of its sibling nodes in order to see if
952
+ // `childNode` should be hidden
953
+ for (const siblingNode of childNodes) {
954
+ // Don't check the node against itself
955
+ if (siblingNode !== childNode) {
956
+ if (siblingNode['s-hn'] !== childNode['s-hn'] || slotName !== '') {
957
+ // this sibling node is from a different component OR is a named
958
+ // fallback slot node
959
+ if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
960
+ (slotName === siblingNode.getAttribute('slot') || slotName === siblingNode['s-sn'])) {
961
+ childNode.hidden = true;
962
+ break;
963
+ }
964
+ }
965
+ else {
966
+ // this is a default fallback slot node
967
+ // any element or text node (with content)
968
+ // should hide the default fallback slot node
969
+ if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ ||
970
+ (siblingNode.nodeType === 3 /* NODE_TYPE.TextNode */ && siblingNode.textContent.trim() !== '')) {
971
+ childNode.hidden = true;
972
+ break;
973
+ }
974
+ }
975
+ }
976
+ }
977
+ }
978
+ // keep drilling down
979
+ updateFallbackSlotVisibility(childNode);
980
+ }
981
+ }
982
+ };
983
+ /**
984
+ * Component-global information about nodes which are either currently being
985
+ * relocated or will be shortly.
986
+ */
987
+ const relocateNodes = [];
988
+ /**
989
+ * Mark the contents of a slot for relocation via adding references to them to
990
+ * the {@link relocateNodes} data structure. The actual work of relocating them
991
+ * will then be handled in {@link renderVdom}.
992
+ *
993
+ * @param elm a render node whose child nodes need to be relocated
994
+ */
995
+ const markSlotContentForRelocation = (elm) => {
996
+ // tslint:disable-next-line: prefer-const
997
+ let node;
998
+ let hostContentNodes;
999
+ let j;
1000
+ for (const childNode of elm.childNodes) {
1001
+ // we need to find child nodes which are slot references so we can then try
1002
+ // to match them up with nodes that need to be relocated
1003
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1004
+ // first get the content reference comment node ('s-cr'), then we get
1005
+ // its parent, which is where all the host content is now
1006
+ hostContentNodes = node.parentNode.childNodes;
1007
+ const slotName = childNode['s-sn'];
1008
+ // iterate through all the nodes under the location where the host was
1009
+ // originally rendered
1010
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1011
+ node = hostContentNodes[j];
1012
+ // check that the node is not a content reference node or a node
1013
+ // reference and then check that the host name does not match that of
1014
+ // childNode.
1015
+ // In addition, check that the slot either has not already been relocated, or
1016
+ // that its current location's host is not childNode's host. This is essentially
1017
+ // a check so that we don't try to relocate (and then hide) a node that is already
1018
+ // where it should be.
1019
+ if (!node['s-cn'] &&
1020
+ !node['s-nr'] &&
1021
+ node['s-hn'] !== childNode['s-hn'] &&
1022
+ (!BUILD.experimentalSlotFixes )) {
1023
+ // if `node` is located in the slot that `childNode` refers to (via the
1024
+ // `'s-sn'` property) then we need to relocate it from it's current spot
1025
+ // (under the host element parent) to the right slot location
1026
+ if (isNodeLocatedInSlot(node, slotName)) {
1027
+ // it's possible we've already decided to relocate this node
1028
+ let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1029
+ // made some changes to slots
1030
+ // let's make sure we also double check
1031
+ // fallbacks are correctly hidden or shown
1032
+ checkSlotFallbackVisibility = true;
1033
+ // ensure that the slot-name attr is correct
1034
+ node['s-sn'] = node['s-sn'] || slotName;
1035
+ if (relocateNodeData) {
1036
+ relocateNodeData.$nodeToRelocate$['s-sh'] = childNode['s-hn'];
1037
+ // we marked this node for relocation previously but didn't find
1038
+ // out the slot reference node to which it needs to be relocated
1039
+ // so write it down now!
1040
+ relocateNodeData.$slotRefNode$ = childNode;
1041
+ }
1042
+ else {
1043
+ node['s-sh'] = childNode['s-hn'];
1044
+ // add to our list of nodes to relocate
1045
+ relocateNodes.push({
1046
+ $slotRefNode$: childNode,
1047
+ $nodeToRelocate$: node,
1048
+ });
1049
+ }
1050
+ if (node['s-sr']) {
1051
+ relocateNodes.map((relocateNode) => {
1052
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1053
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1054
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1055
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1056
+ }
1057
+ }
1058
+ });
1059
+ }
1060
+ }
1061
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1062
+ // the node is not found within the slot (`childNode`) that we're
1063
+ // currently looking at, so we stick it into `relocateNodes` to
1064
+ // handle later. If we never find a home for this element then
1065
+ // we'll need to hide it
1066
+ relocateNodes.push({
1067
+ $nodeToRelocate$: node,
1068
+ });
1069
+ }
1070
+ }
1071
+ }
1072
+ }
1073
+ // if we're dealing with any type of element (capable of itself being a
1074
+ // slot reference or containing one) then we recur
1075
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1076
+ markSlotContentForRelocation(childNode);
1077
+ }
1078
+ }
1079
+ };
1080
+ /**
1081
+ * Check whether a node is located in a given named slot.
1082
+ *
1083
+ * @param nodeToRelocate the node of interest
1084
+ * @param slotName the slot name to check
1085
+ * @returns whether the node is located in the slot or not
1086
+ */
1087
+ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
1088
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1089
+ if (nodeToRelocate.getAttribute('slot') === null && slotName === '') {
1090
+ // if the node doesn't have a slot attribute, and the slot we're checking
1091
+ // is not a named slot, then we assume the node should be within the slot
1092
+ return true;
1093
+ }
1094
+ if (nodeToRelocate.getAttribute('slot') === slotName) {
1095
+ return true;
1096
+ }
1097
+ return false;
1098
+ }
1099
+ if (nodeToRelocate['s-sn'] === slotName) {
1100
+ return true;
1101
+ }
1102
+ return slotName === '';
1103
+ };
809
1104
  /**
810
1105
  * The main entry point for Stencil's virtual DOM-based rendering engine
811
1106
  *
@@ -820,6 +1115,7 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
820
1115
  * @param isInitialLoad whether or not this is the first call after page load
821
1116
  */
822
1117
  const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1118
+ var _a, _b, _c, _d;
823
1119
  const hostElm = hostRef.$hostElement$;
824
1120
  const cmpMeta = hostRef.$cmpMeta$;
825
1121
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
@@ -858,13 +1154,113 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
858
1154
  rootVnode.$tag$ = null;
859
1155
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
860
1156
  hostRef.$vnode$ = rootVnode;
861
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1157
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
1158
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
862
1159
  {
863
- scopeId = hostElm['s-sc'];
1160
+ contentRef = hostElm['s-cr'];
1161
+ // always reset
1162
+ checkSlotFallbackVisibility = false;
864
1163
  }
865
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
866
1164
  // synchronous patch
867
1165
  patch(oldVNode, rootVnode, isInitialLoad);
1166
+ {
1167
+ // while we're moving nodes around existing nodes, temporarily disable
1168
+ // the disconnectCallback from working
1169
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1170
+ if (checkSlotRelocate) {
1171
+ markSlotContentForRelocation(rootVnode.$elm$);
1172
+ for (const relocateData of relocateNodes) {
1173
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
1174
+ if (!nodeToRelocate['s-ol']) {
1175
+ // add a reference node marking this node's original location
1176
+ // keep a reference to this node for later lookups
1177
+ const orgLocationNode = doc.createTextNode('');
1178
+ orgLocationNode['s-nr'] = nodeToRelocate;
1179
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1180
+ }
1181
+ }
1182
+ for (const relocateData of relocateNodes) {
1183
+ const nodeToRelocate = relocateData.$nodeToRelocate$;
1184
+ const slotRefNode = relocateData.$slotRefNode$;
1185
+ if (slotRefNode) {
1186
+ const parentNodeRef = slotRefNode.parentNode;
1187
+ // When determining where to insert content, the most simple case would be
1188
+ // to relocate the node immediately following the slot reference node. We do this
1189
+ // by getting a reference to the node immediately following the slot reference node
1190
+ // since we will use `insertBefore` to manipulate the DOM.
1191
+ //
1192
+ // If there is no node immediately following the slot reference node, then we will just
1193
+ // end up appending the node as the last child of the parent.
1194
+ let insertBeforeNode = slotRefNode.nextSibling;
1195
+ // If the node we're currently planning on inserting the new node before is an element,
1196
+ // we need to do some additional checks to make sure we're inserting the node in the correct order.
1197
+ // The use case here would be that we have multiple nodes being relocated to the same slot. So, we want
1198
+ // to make sure they get inserted into their new how in the same order they were declared in their original location.
1199
+ //
1200
+ // TODO(STENCIL-914): Remove `experimentalSlotFixes` check
1201
+ {
1202
+ let orgLocationNode = (_a = nodeToRelocate['s-ol']) === null || _a === void 0 ? void 0 : _a.previousSibling;
1203
+ while (orgLocationNode) {
1204
+ let refNode = (_b = orgLocationNode['s-nr']) !== null && _b !== void 0 ? _b : null;
1205
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1206
+ refNode = refNode.nextSibling;
1207
+ if (!refNode || !refNode['s-nr']) {
1208
+ insertBeforeNode = refNode;
1209
+ break;
1210
+ }
1211
+ }
1212
+ orgLocationNode = orgLocationNode.previousSibling;
1213
+ }
1214
+ }
1215
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1216
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1217
+ // we've checked that it's worth while to relocate
1218
+ // since that the node to relocate
1219
+ // has a different next sibling or parent relocated
1220
+ if (nodeToRelocate !== insertBeforeNode) {
1221
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1222
+ // probably a component in the index.html that doesn't have its hostname set
1223
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1224
+ }
1225
+ // Add it back to the dom but in its new home
1226
+ // If we get to this point and `insertBeforeNode` is `null`, that means
1227
+ // we're just going to append the node as the last child of the parent. Passing
1228
+ // `null` as the second arg here will trigger that behavior.
1229
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1230
+ // Reset the `hidden` value back to what it was defined as originally
1231
+ // This solves a problem where a `slot` is dynamically rendered and `hidden` may have
1232
+ // been set on content originally, but now it has a slot to go to so it should have
1233
+ // the value it was defined as having in the DOM, not what we overrode it to.
1234
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1235
+ nodeToRelocate.hidden = (_c = nodeToRelocate['s-ih']) !== null && _c !== void 0 ? _c : false;
1236
+ }
1237
+ }
1238
+ }
1239
+ }
1240
+ else {
1241
+ // this node doesn't have a slot home to go to, so let's hide it
1242
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1243
+ // Store the initial value of `hidden` so we can reset it later when
1244
+ // moving nodes around.
1245
+ if (isInitialLoad) {
1246
+ nodeToRelocate['s-ih'] = (_d = nodeToRelocate.hidden) !== null && _d !== void 0 ? _d : false;
1247
+ }
1248
+ nodeToRelocate.hidden = true;
1249
+ }
1250
+ }
1251
+ }
1252
+ }
1253
+ if (checkSlotFallbackVisibility) {
1254
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1255
+ }
1256
+ // done moving nodes around
1257
+ // allow the disconnect callback to work again
1258
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1259
+ // always reset
1260
+ relocateNodes.length = 0;
1261
+ }
1262
+ // Clear the content ref so we don't create a memory leak
1263
+ contentRef = undefined;
868
1264
  };
869
1265
  const attachToAncestor = (hostRef, ancestorComponent) => {
870
1266
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
@@ -1279,7 +1675,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1279
1675
  if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1280
1676
  // Let the runtime know that the component has been initialized
1281
1677
  hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1282
- {
1678
+ const bundleId = cmpMeta.$lazyBundleId$;
1679
+ if (bundleId) {
1283
1680
  // lazy loaded components
1284
1681
  // request the component's implementation to be
1285
1682
  // wired up with the host element
@@ -1316,6 +1713,14 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1316
1713
  }
1317
1714
  endNewInstance();
1318
1715
  }
1716
+ else {
1717
+ // sync constructor component
1718
+ Cstr = elm.constructor;
1719
+ // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
1720
+ // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
1721
+ // Stencil has completed instantiating the component.
1722
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
1723
+ }
1319
1724
  if (Cstr.style) {
1320
1725
  // this component has styles but we haven't registered them yet
1321
1726
  let style = Cstr.style;
@@ -1353,6 +1758,16 @@ const connectedCallback = (elm) => {
1353
1758
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1354
1759
  // first time this component has connected
1355
1760
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1761
+ {
1762
+ // initUpdate
1763
+ // if the slot polyfill is required we'll need to put some nodes
1764
+ // in here to act as original content anchors as we move nodes around
1765
+ // host element has been connected to the DOM
1766
+ if ((// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
1767
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1768
+ setContentReference(elm);
1769
+ }
1770
+ }
1356
1771
  {
1357
1772
  // find the first ancestor component (if there is one) and register
1358
1773
  // this component as one of the actively loading child components for its ancestor
@@ -1393,6 +1808,17 @@ const connectedCallback = (elm) => {
1393
1808
  endConnected();
1394
1809
  }
1395
1810
  };
1811
+ const setContentReference = (elm) => {
1812
+ // only required when we're NOT using native shadow dom (slot)
1813
+ // or this browser doesn't support native shadow dom
1814
+ // and this host element was NOT created with SSR
1815
+ // let's pick out the inner content for slot projection
1816
+ // create a node to represent where the original
1817
+ // content was first placed, which is useful later on
1818
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1819
+ contentRefElm['s-cn'] = true;
1820
+ elm.insertBefore(contentRefElm, elm.firstChild);
1821
+ };
1396
1822
  const disconnectInstance = (instance) => {
1397
1823
  };
1398
1824
  const disconnectedCallback = async (elm) => {
@@ -1446,17 +1872,6 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1446
1872
  super(self);
1447
1873
  self = this;
1448
1874
  registerHost(self, cmpMeta);
1449
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1450
- // this component is using shadow dom
1451
- // and this browser supports shadow dom
1452
- // add the read-only property "shadowRoot" to the host element
1453
- // adding the shadow root build conditionals to minimize runtime
1454
- {
1455
- {
1456
- self.attachShadow({ mode: 'open' });
1457
- }
1458
- }
1459
- }
1460
1875
  }
1461
1876
  connectedCallback() {
1462
1877
  if (appLoadFallback) {
@@ -1675,4 +2090,4 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1675
2090
 
1676
2091
  export { Host as H, bootstrapLazy as b, h, promiseResolve as p, registerInstance as r, setNonce as s };
1677
2092
 
1678
- //# sourceMappingURL=index-3cf3394c.js.map
2093
+ //# sourceMappingURL=index-6fbf8ed3.js.map