@rededor/cura 0.3.3 → 0.3.4-alpha.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 (55) hide show
  1. package/dist/cjs/cura-display_4.cjs.entry.js +9 -9
  2. package/dist/cjs/cura-icon.cjs.entry.js +3 -3
  3. package/dist/cjs/cura-icons-view.cjs.entry.js +1 -1
  4. package/dist/cjs/cura.cjs.js +2 -2
  5. package/dist/cjs/{index-8686299e.js → index-76f95c4b.js} +377 -40
  6. package/dist/cjs/loader.cjs.js +2 -2
  7. package/dist/collection/components/cura-icon/cura-icon.css +2 -2
  8. package/dist/collection/components/cura-icon/cura-icon.js +1 -2
  9. package/dist/collection/components/cura-icons-view/cura-icons-view.js +0 -1
  10. package/dist/collection/components/cura-page-template/cura-page-template.css +24 -24
  11. package/dist/collection/components/cura-page-template/cura-page-template.js +1 -2
  12. package/dist/collection/components/text/cura-display/cura-display.css +14 -13
  13. package/dist/collection/components/text/cura-display/cura-display.js +1 -2
  14. package/dist/collection/components/text/cura-heading/cura-heading.css +15 -15
  15. package/dist/collection/components/text/cura-heading/cura-heading.js +1 -2
  16. package/dist/collection/components/text/cura-paragraph/cura-paragraph.css +17 -16
  17. package/dist/collection/components/text/cura-paragraph/cura-paragraph.js +1 -2
  18. package/dist/components/cura-display.js +3 -4
  19. package/dist/components/cura-heading.js +3 -4
  20. package/dist/components/cura-icon2.js +3 -4
  21. package/dist/components/cura-icons-view.js +1 -2
  22. package/dist/components/cura-page-template.js +3 -4
  23. package/dist/components/cura-paragraph.js +3 -4
  24. package/dist/cura/cura.esm.js +1 -1
  25. package/dist/cura/cura.js +1 -1
  26. package/dist/cura/p-0b79032f.system.js +2 -0
  27. package/dist/cura/p-11002b56.system.js +1 -0
  28. package/dist/cura/{p-5b5cf2e4.system.entry.js → p-54c09404.system.entry.js} +1 -1
  29. package/dist/cura/p-57c5329e.js +2 -0
  30. package/dist/cura/p-5a6643e1.entry.js +1 -0
  31. package/dist/cura/p-a2ad5637.system.entry.js +1 -0
  32. package/dist/cura/p-bd91ecb9.system.entry.js +1 -0
  33. package/dist/cura/{p-22290742.entry.js → p-d69916ee.entry.js} +1 -1
  34. package/dist/cura/{p-fbcea891.entry.js → p-f8a5b97d.entry.js} +1 -1
  35. package/dist/esm/cura-display_4.entry.js +9 -9
  36. package/dist/esm/cura-icon.entry.js +3 -3
  37. package/dist/esm/cura-icons-view.entry.js +1 -1
  38. package/dist/esm/cura.js +2 -2
  39. package/dist/esm/{index-c3d31886.js → index-7e8c969d.js} +377 -40
  40. package/dist/esm/loader.js +2 -2
  41. package/dist/esm-es5/cura-display_4.entry.js +1 -1
  42. package/dist/esm-es5/cura-icon.entry.js +1 -1
  43. package/dist/esm-es5/cura-icons-view.entry.js +1 -1
  44. package/dist/esm-es5/cura.js +1 -1
  45. package/dist/esm-es5/index-7e8c969d.js +2 -0
  46. package/dist/esm-es5/loader.js +1 -1
  47. package/package.json +2 -2
  48. package/dist/cura/p-092f3490.system.entry.js +0 -1
  49. package/dist/cura/p-12023453.entry.js +0 -1
  50. package/dist/cura/p-8b416bc6.system.js +0 -1
  51. package/dist/cura/p-a50716bc.js +0 -2
  52. package/dist/cura/p-e447016d.system.js +0 -2
  53. package/dist/cura/p-e8fadcfa.system.entry.js +0 -1
  54. package/dist/esm-es5/index-c3d31886.js +0 -2
  55. package/dist/loader/index.d.ts +0 -12
@@ -8,8 +8,11 @@ const NAMESPACE = 'cura';
8
8
  *
9
9
  * Modified for Stencil's renderer and slot projection
10
10
  */
11
- let scopeId;
11
+ let contentRef;
12
12
  let hostTagName;
13
+ let useNativeShadowDom = false;
14
+ let checkSlotFallbackVisibility = false;
15
+ let checkSlotRelocate = false;
13
16
  let isSvgMode = false;
14
17
  let queuePending = false;
15
18
  const createTime = (fnName, tagName = '') => {
@@ -41,7 +44,6 @@ const EMPTY_OBJ = {};
41
44
  */
42
45
  const SVG_NS = 'http://www.w3.org/2000/svg';
43
46
  const HTML_NS = 'http://www.w3.org/1999/xhtml';
44
- const isDef = (v) => v != null;
45
47
  const isComplexType = (o) => {
46
48
  // https://jsperf.com/typeof-fn-object/5
47
49
  o = typeof o;
@@ -60,6 +62,7 @@ const isComplexType = (o) => {
60
62
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
61
63
  const h = (nodeName, vnodeData, ...children) => {
62
64
  let child = null;
65
+ let slotName = null;
63
66
  let simple = false;
64
67
  let lastSimple = false;
65
68
  const vNodeChildren = [];
@@ -87,6 +90,9 @@ const h = (nodeName, vnodeData, ...children) => {
87
90
  };
88
91
  walk(children);
89
92
  if (vnodeData) {
93
+ if (vnodeData.name) {
94
+ slotName = vnodeData.name;
95
+ }
90
96
  {
91
97
  const classData = vnodeData.className || vnodeData.class;
92
98
  if (classData) {
@@ -104,6 +110,9 @@ const h = (nodeName, vnodeData, ...children) => {
104
110
  if (vNodeChildren.length > 0) {
105
111
  vnode.$children$ = vNodeChildren;
106
112
  }
113
+ {
114
+ vnode.$name$ = slotName;
115
+ }
107
116
  return vnode;
108
117
  };
109
118
  const newVNode = (tag, text) => {
@@ -117,6 +126,9 @@ const newVNode = (tag, text) => {
117
126
  {
118
127
  vnode.$attrs$ = null;
119
128
  }
129
+ {
130
+ vnode.$name$ = null;
131
+ }
120
132
  return vnode;
121
133
  };
122
134
  const Host = {};
@@ -234,20 +246,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
234
246
  const attachStyles = (hostRef) => {
235
247
  const cmpMeta = hostRef.$cmpMeta$;
236
248
  const elm = hostRef.$hostElement$;
237
- const flags = cmpMeta.$flags$;
238
249
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
239
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
240
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
241
- // only required when we're NOT using native shadow dom (slot)
242
- // or this browser doesn't support native shadow dom
243
- // and this host element was NOT created with SSR
244
- // let's pick out the inner content for slot projection
245
- // create a node to represent where the original
246
- // content was first placed, which is useful later on
247
- // DOM WRITE!!
248
- elm['s-sc'] = scopeId;
249
- elm.classList.add(scopeId + '-h');
250
- }
250
+ addStyle(elm.getRootNode(), cmpMeta);
251
251
  endAttachStyles();
252
252
  };
253
253
  const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
@@ -431,16 +431,35 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
431
431
  let i = 0;
432
432
  let elm;
433
433
  let childNode;
434
+ let oldVNode;
435
+ if (!useNativeShadowDom) {
436
+ // remember for later we need to check to relocate nodes
437
+ checkSlotRelocate = true;
438
+ if (newVNode.$tag$ === 'slot') {
439
+ newVNode.$flags$ |= newVNode.$children$
440
+ ? // slot element has fallback content
441
+ 2 /* VNODE_FLAGS.isSlotFallback */
442
+ : // slot element does not have fallback content
443
+ 1 /* VNODE_FLAGS.isSlotReference */;
444
+ }
445
+ }
434
446
  if (newVNode.$text$ !== null) {
435
447
  // create text node
436
448
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
437
449
  }
450
+ else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
451
+ // create a slot reference node
452
+ elm = newVNode.$elm$ =
453
+ doc.createTextNode('');
454
+ }
438
455
  else {
439
456
  if (!isSvgMode) {
440
457
  isSvgMode = newVNode.$tag$ === 'svg';
441
458
  }
442
459
  // create element
443
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
460
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
461
+ ? 'slot-fb'
462
+ : newVNode.$tag$)
444
463
  );
445
464
  if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
446
465
  isSvgMode = false;
@@ -449,11 +468,6 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
449
468
  {
450
469
  updateElement(null, newVNode, isSvgMode);
451
470
  }
452
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
453
- // if there is a scopeId and this is the initial render
454
- // then let's add the scopeId as a css class
455
- elm.classList.add((elm['s-si'] = scopeId));
456
- }
457
471
  if (newVNode.$children$) {
458
472
  for (i = 0; i < newVNode.$children$.length; ++i) {
459
473
  // create the node
@@ -476,20 +490,59 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
476
490
  }
477
491
  }
478
492
  }
493
+ {
494
+ elm['s-hn'] = hostTagName;
495
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
496
+ // remember the content reference comment
497
+ elm['s-sr'] = true;
498
+ // remember the content reference comment
499
+ elm['s-cr'] = contentRef;
500
+ // remember the slot name, or empty string for default slot
501
+ elm['s-sn'] = newVNode.$name$ || '';
502
+ // check if we've got an old vnode for this slot
503
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
504
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
505
+ // we've got an old slot vnode and the wrapper is being replaced
506
+ // so let's move the old slot content back to it's original location
507
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
508
+ }
509
+ }
510
+ }
479
511
  return elm;
480
512
  };
513
+ const putBackInOriginalLocation = (parentElm, recursive) => {
514
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
515
+ const oldSlotChildNodes = parentElm.childNodes;
516
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
517
+ const childNode = oldSlotChildNodes[i];
518
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
519
+ // // this child node in the old element is from another component
520
+ // // remove this node from the old slot's parent
521
+ // childNode.remove();
522
+ // and relocate it back to it's original location
523
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
524
+ // remove the old original location comment entirely
525
+ // later on the patch function will know what to do
526
+ // and move this to the correct spot in need be
527
+ childNode['s-ol'].remove();
528
+ childNode['s-ol'] = undefined;
529
+ checkSlotRelocate = true;
530
+ }
531
+ if (recursive) {
532
+ putBackInOriginalLocation(childNode, recursive);
533
+ }
534
+ }
535
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
536
+ };
481
537
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
482
- let containerElm = (parentElm);
538
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
483
539
  let childNode;
484
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
485
- containerElm = containerElm.shadowRoot;
486
- }
487
540
  for (; startIdx <= endIdx; ++startIdx) {
488
541
  if (vnodes[startIdx]) {
489
542
  childNode = createElm(null, parentVNode, startIdx);
490
543
  if (childNode) {
491
544
  vnodes[startIdx].$elm$ = childNode;
492
- containerElm.insertBefore(childNode, before);
545
+ containerElm.insertBefore(childNode, referenceNode(before) );
493
546
  }
494
547
  }
495
548
  }
@@ -498,6 +551,20 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
498
551
  for (; startIdx <= endIdx; ++startIdx) {
499
552
  if ((vnode = vnodes[startIdx])) {
500
553
  elm = vnode.$elm$;
554
+ {
555
+ // we're removing this element
556
+ // so it's possible we need to show slot fallback content now
557
+ checkSlotFallbackVisibility = true;
558
+ if (elm['s-ol']) {
559
+ // remove the original location comment
560
+ elm['s-ol'].remove();
561
+ }
562
+ else {
563
+ // it's possible that child nodes of the node
564
+ // that's being removed are slot nodes
565
+ putBackInOriginalLocation(elm, true);
566
+ }
567
+ }
501
568
  // remove the vnode's element from the dom
502
569
  elm.remove();
503
570
  }
@@ -613,6 +680,23 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
613
680
  newEndVnode = newCh[--newEndIdx];
614
681
  }
615
682
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
683
+ // case: "Vnode moved right"
684
+ //
685
+ // We've found that the last node in our window on the new children is
686
+ // the same VNode as the _first_ node in our window on the old children
687
+ // we're dealing with now. Visually, this is the layout of these two
688
+ // nodes:
689
+ //
690
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
691
+ // ^^^^^^^^^^^
692
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
693
+ // ^^^^^^^^^^^^^
694
+ //
695
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
696
+ // and move the DOM element for `oldStartVnode`.
697
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
698
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
699
+ }
616
700
  patch(oldStartVnode, newEndVnode);
617
701
  // We need to move the element for `oldStartVnode` into a position which
618
702
  // will be appropriate for `newEndVnode`. For this we can use
@@ -636,6 +720,24 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
636
720
  newEndVnode = newCh[--newEndIdx];
637
721
  }
638
722
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
723
+ // case: "Vnode moved left"
724
+ //
725
+ // We've found that the first node in our window on the new children is
726
+ // the same VNode as the _last_ node in our window on the old children.
727
+ // Visually, this is the layout of these two nodes:
728
+ //
729
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
730
+ // ^^^^^^^^^^^^^
731
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
732
+ // ^^^^^^^^^^^
733
+ //
734
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
735
+ // (which will handle updating any changed attributes, reconciling their
736
+ // children etc) but we also need to move the DOM node to which
737
+ // `oldEndVnode` corresponds.
738
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
739
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
740
+ }
639
741
  patch(oldEndVnode, newStartVnode);
640
742
  // We've already checked above if `oldStartVnode` and `newStartVnode` are
641
743
  // the same node, so since we're here we know that they are not. Thus we
@@ -658,7 +760,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
658
760
  if (node) {
659
761
  // if we created a new node then handle inserting it to the DOM
660
762
  {
661
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
763
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
662
764
  }
663
765
  }
664
766
  }
@@ -695,10 +797,21 @@ const isSameVnode = (leftVNode, rightVNode) => {
695
797
  // compare if two vnode to see if they're "technically" the same
696
798
  // need to have the same element tag, and same key to be the same
697
799
  if (leftVNode.$tag$ === rightVNode.$tag$) {
800
+ if (leftVNode.$tag$ === 'slot') {
801
+ return leftVNode.$name$ === rightVNode.$name$;
802
+ }
698
803
  return true;
699
804
  }
700
805
  return false;
701
806
  };
807
+ const referenceNode = (node) => {
808
+ // this node was relocated to a new location in the dom
809
+ // because of some other component's slot
810
+ // but we still have an html comment in place of where
811
+ // it's original location was according to it's original vdom
812
+ return (node && node['s-ol']) || node;
813
+ };
814
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
702
815
  /**
703
816
  * Handle reconciling an outdated VNode with a new one which corresponds to
704
817
  * it. This function handles flushing updates to the DOM and reconciling the
@@ -713,6 +826,7 @@ const patch = (oldVNode, newVNode) => {
713
826
  const newChildren = newVNode.$children$;
714
827
  const tag = newVNode.$tag$;
715
828
  const text = newVNode.$text$;
829
+ let defaultHolder;
716
830
  if (text === null) {
717
831
  {
718
832
  // test if we're rendering an svg element, or still rendering nodes inside of one
@@ -751,12 +865,147 @@ const patch = (oldVNode, newVNode) => {
751
865
  isSvgMode = false;
752
866
  }
753
867
  }
868
+ else if ((defaultHolder = elm['s-cr'])) {
869
+ // this element has slotted content
870
+ defaultHolder.parentNode.textContent = text;
871
+ }
754
872
  else if (oldVNode.$text$ !== text) {
755
873
  // update the text content for the text only vnode
756
874
  // and also only if the text is different than before
757
875
  elm.data = text;
758
876
  }
759
877
  };
878
+ const updateFallbackSlotVisibility = (elm) => {
879
+ // tslint:disable-next-line: prefer-const
880
+ const childNodes = elm.childNodes;
881
+ let childNode;
882
+ let i;
883
+ let ilen;
884
+ let j;
885
+ let slotNameAttr;
886
+ let nodeType;
887
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
888
+ childNode = childNodes[i];
889
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
890
+ if (childNode['s-sr']) {
891
+ // this is a slot fallback node
892
+ // get the slot name for this slot reference node
893
+ slotNameAttr = childNode['s-sn'];
894
+ // by default always show a fallback slot node
895
+ // then hide it if there are other slots in the light dom
896
+ childNode.hidden = false;
897
+ for (j = 0; j < ilen; j++) {
898
+ nodeType = childNodes[j].nodeType;
899
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
900
+ // this sibling node is from a different component OR is a named fallback slot node
901
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
902
+ childNode.hidden = true;
903
+ break;
904
+ }
905
+ }
906
+ else {
907
+ // this is a default fallback slot node
908
+ // any element or text node (with content)
909
+ // should hide the default fallback slot node
910
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
911
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
912
+ childNode.hidden = true;
913
+ break;
914
+ }
915
+ }
916
+ }
917
+ }
918
+ // keep drilling down
919
+ updateFallbackSlotVisibility(childNode);
920
+ }
921
+ }
922
+ };
923
+ const relocateNodes = [];
924
+ const relocateSlotContent = (elm) => {
925
+ // tslint:disable-next-line: prefer-const
926
+ let childNode;
927
+ let node;
928
+ let hostContentNodes;
929
+ let slotNameAttr;
930
+ let relocateNodeData;
931
+ let j;
932
+ let i = 0;
933
+ const childNodes = elm.childNodes;
934
+ const ilen = childNodes.length;
935
+ for (; i < ilen; i++) {
936
+ childNode = childNodes[i];
937
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
938
+ // first got the content reference comment node
939
+ // then we got it's parent, which is where all the host content is in now
940
+ hostContentNodes = node.parentNode.childNodes;
941
+ slotNameAttr = childNode['s-sn'];
942
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
943
+ node = hostContentNodes[j];
944
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
945
+ // let's do some relocating to its new home
946
+ // but never relocate a content reference node
947
+ // that is suppose to always represent the original content location
948
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
949
+ // it's possible we've already decided to relocate this node
950
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
951
+ // made some changes to slots
952
+ // let's make sure we also double check
953
+ // fallbacks are correctly hidden or shown
954
+ checkSlotFallbackVisibility = true;
955
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
956
+ if (relocateNodeData) {
957
+ // previously we never found a slot home for this node
958
+ // but turns out we did, so let's remember it now
959
+ relocateNodeData.$slotRefNode$ = childNode;
960
+ }
961
+ else {
962
+ // add to our list of nodes to relocate
963
+ relocateNodes.push({
964
+ $slotRefNode$: childNode,
965
+ $nodeToRelocate$: node,
966
+ });
967
+ }
968
+ if (node['s-sr']) {
969
+ relocateNodes.map((relocateNode) => {
970
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
971
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
972
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
973
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
974
+ }
975
+ }
976
+ });
977
+ }
978
+ }
979
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
980
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
981
+ // if we never find a home for this element then we'll need to hide it
982
+ relocateNodes.push({
983
+ $nodeToRelocate$: node,
984
+ });
985
+ }
986
+ }
987
+ }
988
+ }
989
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
990
+ relocateSlotContent(childNode);
991
+ }
992
+ }
993
+ };
994
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
995
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
996
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
997
+ return true;
998
+ }
999
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1000
+ return true;
1001
+ }
1002
+ return false;
1003
+ }
1004
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
1005
+ return true;
1006
+ }
1007
+ return slotNameAttr === '';
1008
+ };
760
1009
  const renderVdom = (hostRef, renderFnResults) => {
761
1010
  const hostElm = hostRef.$hostElement$;
762
1011
  const cmpMeta = hostRef.$cmpMeta$;
@@ -770,12 +1019,91 @@ const renderVdom = (hostRef, renderFnResults) => {
770
1019
  rootVnode.$tag$ = null;
771
1020
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
772
1021
  hostRef.$vnode$ = rootVnode;
773
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1022
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
774
1023
  {
775
- scopeId = hostElm['s-sc'];
1024
+ contentRef = hostElm['s-cr'];
1025
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1026
+ // always reset
1027
+ checkSlotFallbackVisibility = false;
776
1028
  }
777
1029
  // synchronous patch
778
1030
  patch(oldVNode, rootVnode);
1031
+ {
1032
+ // while we're moving nodes around existing nodes, temporarily disable
1033
+ // the disconnectCallback from working
1034
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1035
+ if (checkSlotRelocate) {
1036
+ relocateSlotContent(rootVnode.$elm$);
1037
+ let relocateData;
1038
+ let nodeToRelocate;
1039
+ let orgLocationNode;
1040
+ let parentNodeRef;
1041
+ let insertBeforeNode;
1042
+ let refNode;
1043
+ let i = 0;
1044
+ for (; i < relocateNodes.length; i++) {
1045
+ relocateData = relocateNodes[i];
1046
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1047
+ if (!nodeToRelocate['s-ol']) {
1048
+ // add a reference node marking this node's original location
1049
+ // keep a reference to this node for later lookups
1050
+ orgLocationNode =
1051
+ doc.createTextNode('');
1052
+ orgLocationNode['s-nr'] = nodeToRelocate;
1053
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1054
+ }
1055
+ }
1056
+ for (i = 0; i < relocateNodes.length; i++) {
1057
+ relocateData = relocateNodes[i];
1058
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1059
+ if (relocateData.$slotRefNode$) {
1060
+ // by default we're just going to insert it directly
1061
+ // after the slot reference node
1062
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1063
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1064
+ orgLocationNode = nodeToRelocate['s-ol'];
1065
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
1066
+ refNode = orgLocationNode['s-nr'];
1067
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1068
+ refNode = refNode.nextSibling;
1069
+ if (!refNode || !refNode['s-nr']) {
1070
+ insertBeforeNode = refNode;
1071
+ break;
1072
+ }
1073
+ }
1074
+ }
1075
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1076
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1077
+ // we've checked that it's worth while to relocate
1078
+ // since that the node to relocate
1079
+ // has a different next sibling or parent relocated
1080
+ if (nodeToRelocate !== insertBeforeNode) {
1081
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1082
+ // probably a component in the index.html that doesn't have it's hostname set
1083
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1084
+ }
1085
+ // add it back to the dom but in its new home
1086
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1087
+ }
1088
+ }
1089
+ }
1090
+ else {
1091
+ // this node doesn't have a slot home to go to, so let's hide it
1092
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1093
+ nodeToRelocate.hidden = true;
1094
+ }
1095
+ }
1096
+ }
1097
+ }
1098
+ if (checkSlotFallbackVisibility) {
1099
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1100
+ }
1101
+ // done moving nodes around
1102
+ // allow the disconnect callback to work again
1103
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1104
+ // always reset
1105
+ relocateNodes.length = 0;
1106
+ }
779
1107
  };
780
1108
  const attachToAncestor = (hostRef, ancestorComponent) => {
781
1109
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
@@ -1166,6 +1494,15 @@ const connectedCallback = (elm) => {
1166
1494
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1167
1495
  // first time this component has connected
1168
1496
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1497
+ {
1498
+ // initUpdate
1499
+ // if the slot polyfill is required we'll need to put some nodes
1500
+ // in here to act as original content anchors as we move nodes around
1501
+ // host element has been connected to the DOM
1502
+ if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1503
+ setContentReference(elm);
1504
+ }
1505
+ }
1169
1506
  {
1170
1507
  // find the first ancestor component (if there is one) and register
1171
1508
  // this component as one of the actively loading child components for its ancestor
@@ -1203,6 +1540,17 @@ const connectedCallback = (elm) => {
1203
1540
  endConnected();
1204
1541
  }
1205
1542
  };
1543
+ const setContentReference = (elm) => {
1544
+ // only required when we're NOT using native shadow dom (slot)
1545
+ // or this browser doesn't support native shadow dom
1546
+ // and this host element was NOT created with SSR
1547
+ // let's pick out the inner content for slot projection
1548
+ // create a node to represent where the original
1549
+ // content was first placed, which is useful later on
1550
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1551
+ contentRefElm['s-cn'] = true;
1552
+ elm.insertBefore(contentRefElm, elm.firstChild);
1553
+ };
1206
1554
  const disconnectedCallback = (elm) => {
1207
1555
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1208
1556
  getHostRef(elm);
@@ -1246,17 +1594,6 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1246
1594
  super(self);
1247
1595
  self = this;
1248
1596
  registerHost(self, cmpMeta);
1249
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1250
- // this component is using shadow dom
1251
- // and this browser supports shadow dom
1252
- // add the read-only property "shadowRoot" to the host element
1253
- // adding the shadow root build conditionals to minimize runtime
1254
- {
1255
- {
1256
- self.attachShadow({ mode: 'open' });
1257
- }
1258
- }
1259
- }
1260
1597
  }
1261
1598
  connectedCallback() {
1262
1599
  if (appLoadFallback) {
@@ -1,4 +1,4 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-c3d31886.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-7e8c969d.js';
2
2
  import { g as globalScripts } from './app-globals-cb45bff3.js';
3
3
 
4
4
  /*
@@ -12,7 +12,7 @@ const defineCustomElements = (win, options) => {
12
12
  if (typeof window === 'undefined') return Promise.resolve();
13
13
  return patchEsm().then(() => {
14
14
  globalScripts();
15
- return bootstrapLazy([["cura-icon",[[1,"cura-icon",{"name":[513],"color":[1],"size":[8],"iconset":[513],"disabled":[4]}]]],["cura-icons-view",[[1,"cura-icons-view",{"selected":[32]}]]],["cura-display_4",[[1,"cura-display",{"level":[514],"size":[513],"inverted":[516],"spotColor":[513,"spot-color"]}],[1,"cura-heading",{"level":[514],"size":[513],"weight":[513],"inverted":[516],"spotColor":[513,"spot-color"]}],[1,"cura-page-template",{"contentwidth":[513]}],[1,"cura-paragraph",{"size":[513],"inverted":[516],"spotColor":[513,"spot-color"]}]]]], options);
15
+ return bootstrapLazy([["cura-icon",[[0,"cura-icon",{"name":[513],"color":[1],"size":[8],"iconset":[513],"disabled":[4]}]]],["cura-icons-view",[[0,"cura-icons-view",{"selected":[32]}]]],["cura-display_4",[[4,"cura-display",{"level":[514],"size":[513],"inverted":[516],"spotColor":[513,"spot-color"]}],[4,"cura-heading",{"level":[514],"size":[513],"weight":[513],"inverted":[516],"spotColor":[513,"spot-color"]}],[4,"cura-page-template",{"contentwidth":[513]}],[4,"cura-paragraph",{"size":[513],"inverted":[516],"spotColor":[513,"spot-color"]}]]]], options);
16
16
  });
17
17
  };
18
18