@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
@@ -30,8 +30,11 @@ const NAMESPACE = 'cura';
30
30
  *
31
31
  * Modified for Stencil's renderer and slot projection
32
32
  */
33
- let scopeId;
33
+ let contentRef;
34
34
  let hostTagName;
35
+ let useNativeShadowDom = false;
36
+ let checkSlotFallbackVisibility = false;
37
+ let checkSlotRelocate = false;
35
38
  let isSvgMode = false;
36
39
  let queuePending = false;
37
40
  const createTime = (fnName, tagName = '') => {
@@ -63,7 +66,6 @@ const EMPTY_OBJ = {};
63
66
  */
64
67
  const SVG_NS = 'http://www.w3.org/2000/svg';
65
68
  const HTML_NS = 'http://www.w3.org/1999/xhtml';
66
- const isDef = (v) => v != null;
67
69
  const isComplexType = (o) => {
68
70
  // https://jsperf.com/typeof-fn-object/5
69
71
  o = typeof o;
@@ -82,6 +84,7 @@ const isComplexType = (o) => {
82
84
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
83
85
  const h = (nodeName, vnodeData, ...children) => {
84
86
  let child = null;
87
+ let slotName = null;
85
88
  let simple = false;
86
89
  let lastSimple = false;
87
90
  const vNodeChildren = [];
@@ -109,6 +112,9 @@ const h = (nodeName, vnodeData, ...children) => {
109
112
  };
110
113
  walk(children);
111
114
  if (vnodeData) {
115
+ if (vnodeData.name) {
116
+ slotName = vnodeData.name;
117
+ }
112
118
  {
113
119
  const classData = vnodeData.className || vnodeData.class;
114
120
  if (classData) {
@@ -126,6 +132,9 @@ const h = (nodeName, vnodeData, ...children) => {
126
132
  if (vNodeChildren.length > 0) {
127
133
  vnode.$children$ = vNodeChildren;
128
134
  }
135
+ {
136
+ vnode.$name$ = slotName;
137
+ }
129
138
  return vnode;
130
139
  };
131
140
  const newVNode = (tag, text) => {
@@ -139,6 +148,9 @@ const newVNode = (tag, text) => {
139
148
  {
140
149
  vnode.$attrs$ = null;
141
150
  }
151
+ {
152
+ vnode.$name$ = null;
153
+ }
142
154
  return vnode;
143
155
  };
144
156
  const Host = {};
@@ -256,20 +268,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
256
268
  const attachStyles = (hostRef) => {
257
269
  const cmpMeta = hostRef.$cmpMeta$;
258
270
  const elm = hostRef.$hostElement$;
259
- const flags = cmpMeta.$flags$;
260
271
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
261
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
262
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
263
- // only required when we're NOT using native shadow dom (slot)
264
- // or this browser doesn't support native shadow dom
265
- // and this host element was NOT created with SSR
266
- // let's pick out the inner content for slot projection
267
- // create a node to represent where the original
268
- // content was first placed, which is useful later on
269
- // DOM WRITE!!
270
- elm['s-sc'] = scopeId;
271
- elm.classList.add(scopeId + '-h');
272
- }
272
+ addStyle(elm.getRootNode(), cmpMeta);
273
273
  endAttachStyles();
274
274
  };
275
275
  const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
@@ -453,16 +453,35 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
453
453
  let i = 0;
454
454
  let elm;
455
455
  let childNode;
456
+ let oldVNode;
457
+ if (!useNativeShadowDom) {
458
+ // remember for later we need to check to relocate nodes
459
+ checkSlotRelocate = true;
460
+ if (newVNode.$tag$ === 'slot') {
461
+ newVNode.$flags$ |= newVNode.$children$
462
+ ? // slot element has fallback content
463
+ 2 /* VNODE_FLAGS.isSlotFallback */
464
+ : // slot element does not have fallback content
465
+ 1 /* VNODE_FLAGS.isSlotReference */;
466
+ }
467
+ }
456
468
  if (newVNode.$text$ !== null) {
457
469
  // create text node
458
470
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
459
471
  }
472
+ else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
473
+ // create a slot reference node
474
+ elm = newVNode.$elm$ =
475
+ doc.createTextNode('');
476
+ }
460
477
  else {
461
478
  if (!isSvgMode) {
462
479
  isSvgMode = newVNode.$tag$ === 'svg';
463
480
  }
464
481
  // create element
465
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
482
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
483
+ ? 'slot-fb'
484
+ : newVNode.$tag$)
466
485
  );
467
486
  if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
468
487
  isSvgMode = false;
@@ -471,11 +490,6 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
471
490
  {
472
491
  updateElement(null, newVNode, isSvgMode);
473
492
  }
474
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
475
- // if there is a scopeId and this is the initial render
476
- // then let's add the scopeId as a css class
477
- elm.classList.add((elm['s-si'] = scopeId));
478
- }
479
493
  if (newVNode.$children$) {
480
494
  for (i = 0; i < newVNode.$children$.length; ++i) {
481
495
  // create the node
@@ -498,20 +512,59 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
498
512
  }
499
513
  }
500
514
  }
515
+ {
516
+ elm['s-hn'] = hostTagName;
517
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
518
+ // remember the content reference comment
519
+ elm['s-sr'] = true;
520
+ // remember the content reference comment
521
+ elm['s-cr'] = contentRef;
522
+ // remember the slot name, or empty string for default slot
523
+ elm['s-sn'] = newVNode.$name$ || '';
524
+ // check if we've got an old vnode for this slot
525
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
526
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
527
+ // we've got an old slot vnode and the wrapper is being replaced
528
+ // so let's move the old slot content back to it's original location
529
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
530
+ }
531
+ }
532
+ }
501
533
  return elm;
502
534
  };
535
+ const putBackInOriginalLocation = (parentElm, recursive) => {
536
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
537
+ const oldSlotChildNodes = parentElm.childNodes;
538
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
539
+ const childNode = oldSlotChildNodes[i];
540
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
541
+ // // this child node in the old element is from another component
542
+ // // remove this node from the old slot's parent
543
+ // childNode.remove();
544
+ // and relocate it back to it's original location
545
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
546
+ // remove the old original location comment entirely
547
+ // later on the patch function will know what to do
548
+ // and move this to the correct spot in need be
549
+ childNode['s-ol'].remove();
550
+ childNode['s-ol'] = undefined;
551
+ checkSlotRelocate = true;
552
+ }
553
+ if (recursive) {
554
+ putBackInOriginalLocation(childNode, recursive);
555
+ }
556
+ }
557
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
558
+ };
503
559
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
504
- let containerElm = (parentElm);
560
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
505
561
  let childNode;
506
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
507
- containerElm = containerElm.shadowRoot;
508
- }
509
562
  for (; startIdx <= endIdx; ++startIdx) {
510
563
  if (vnodes[startIdx]) {
511
564
  childNode = createElm(null, parentVNode, startIdx);
512
565
  if (childNode) {
513
566
  vnodes[startIdx].$elm$ = childNode;
514
- containerElm.insertBefore(childNode, before);
567
+ containerElm.insertBefore(childNode, referenceNode(before) );
515
568
  }
516
569
  }
517
570
  }
@@ -520,6 +573,20 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
520
573
  for (; startIdx <= endIdx; ++startIdx) {
521
574
  if ((vnode = vnodes[startIdx])) {
522
575
  elm = vnode.$elm$;
576
+ {
577
+ // we're removing this element
578
+ // so it's possible we need to show slot fallback content now
579
+ checkSlotFallbackVisibility = true;
580
+ if (elm['s-ol']) {
581
+ // remove the original location comment
582
+ elm['s-ol'].remove();
583
+ }
584
+ else {
585
+ // it's possible that child nodes of the node
586
+ // that's being removed are slot nodes
587
+ putBackInOriginalLocation(elm, true);
588
+ }
589
+ }
523
590
  // remove the vnode's element from the dom
524
591
  elm.remove();
525
592
  }
@@ -635,6 +702,23 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
635
702
  newEndVnode = newCh[--newEndIdx];
636
703
  }
637
704
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
705
+ // case: "Vnode moved right"
706
+ //
707
+ // We've found that the last node in our window on the new children is
708
+ // the same VNode as the _first_ node in our window on the old children
709
+ // we're dealing with now. Visually, this is the layout of these two
710
+ // nodes:
711
+ //
712
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
713
+ // ^^^^^^^^^^^
714
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
715
+ // ^^^^^^^^^^^^^
716
+ //
717
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
718
+ // and move the DOM element for `oldStartVnode`.
719
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
720
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
721
+ }
638
722
  patch(oldStartVnode, newEndVnode);
639
723
  // We need to move the element for `oldStartVnode` into a position which
640
724
  // will be appropriate for `newEndVnode`. For this we can use
@@ -658,6 +742,24 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
658
742
  newEndVnode = newCh[--newEndIdx];
659
743
  }
660
744
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
745
+ // case: "Vnode moved left"
746
+ //
747
+ // We've found that the first node in our window on the new children is
748
+ // the same VNode as the _last_ node in our window on the old children.
749
+ // Visually, this is the layout of these two nodes:
750
+ //
751
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
752
+ // ^^^^^^^^^^^^^
753
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
754
+ // ^^^^^^^^^^^
755
+ //
756
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
757
+ // (which will handle updating any changed attributes, reconciling their
758
+ // children etc) but we also need to move the DOM node to which
759
+ // `oldEndVnode` corresponds.
760
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
761
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
762
+ }
661
763
  patch(oldEndVnode, newStartVnode);
662
764
  // We've already checked above if `oldStartVnode` and `newStartVnode` are
663
765
  // the same node, so since we're here we know that they are not. Thus we
@@ -680,7 +782,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
680
782
  if (node) {
681
783
  // if we created a new node then handle inserting it to the DOM
682
784
  {
683
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
785
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
684
786
  }
685
787
  }
686
788
  }
@@ -717,10 +819,21 @@ const isSameVnode = (leftVNode, rightVNode) => {
717
819
  // compare if two vnode to see if they're "technically" the same
718
820
  // need to have the same element tag, and same key to be the same
719
821
  if (leftVNode.$tag$ === rightVNode.$tag$) {
822
+ if (leftVNode.$tag$ === 'slot') {
823
+ return leftVNode.$name$ === rightVNode.$name$;
824
+ }
720
825
  return true;
721
826
  }
722
827
  return false;
723
828
  };
829
+ const referenceNode = (node) => {
830
+ // this node was relocated to a new location in the dom
831
+ // because of some other component's slot
832
+ // but we still have an html comment in place of where
833
+ // it's original location was according to it's original vdom
834
+ return (node && node['s-ol']) || node;
835
+ };
836
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
724
837
  /**
725
838
  * Handle reconciling an outdated VNode with a new one which corresponds to
726
839
  * it. This function handles flushing updates to the DOM and reconciling the
@@ -735,6 +848,7 @@ const patch = (oldVNode, newVNode) => {
735
848
  const newChildren = newVNode.$children$;
736
849
  const tag = newVNode.$tag$;
737
850
  const text = newVNode.$text$;
851
+ let defaultHolder;
738
852
  if (text === null) {
739
853
  {
740
854
  // test if we're rendering an svg element, or still rendering nodes inside of one
@@ -773,12 +887,147 @@ const patch = (oldVNode, newVNode) => {
773
887
  isSvgMode = false;
774
888
  }
775
889
  }
890
+ else if ((defaultHolder = elm['s-cr'])) {
891
+ // this element has slotted content
892
+ defaultHolder.parentNode.textContent = text;
893
+ }
776
894
  else if (oldVNode.$text$ !== text) {
777
895
  // update the text content for the text only vnode
778
896
  // and also only if the text is different than before
779
897
  elm.data = text;
780
898
  }
781
899
  };
900
+ const updateFallbackSlotVisibility = (elm) => {
901
+ // tslint:disable-next-line: prefer-const
902
+ const childNodes = elm.childNodes;
903
+ let childNode;
904
+ let i;
905
+ let ilen;
906
+ let j;
907
+ let slotNameAttr;
908
+ let nodeType;
909
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
910
+ childNode = childNodes[i];
911
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
912
+ if (childNode['s-sr']) {
913
+ // this is a slot fallback node
914
+ // get the slot name for this slot reference node
915
+ slotNameAttr = childNode['s-sn'];
916
+ // by default always show a fallback slot node
917
+ // then hide it if there are other slots in the light dom
918
+ childNode.hidden = false;
919
+ for (j = 0; j < ilen; j++) {
920
+ nodeType = childNodes[j].nodeType;
921
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
922
+ // this sibling node is from a different component OR is a named fallback slot node
923
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
924
+ childNode.hidden = true;
925
+ break;
926
+ }
927
+ }
928
+ else {
929
+ // this is a default fallback slot node
930
+ // any element or text node (with content)
931
+ // should hide the default fallback slot node
932
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
933
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
934
+ childNode.hidden = true;
935
+ break;
936
+ }
937
+ }
938
+ }
939
+ }
940
+ // keep drilling down
941
+ updateFallbackSlotVisibility(childNode);
942
+ }
943
+ }
944
+ };
945
+ const relocateNodes = [];
946
+ const relocateSlotContent = (elm) => {
947
+ // tslint:disable-next-line: prefer-const
948
+ let childNode;
949
+ let node;
950
+ let hostContentNodes;
951
+ let slotNameAttr;
952
+ let relocateNodeData;
953
+ let j;
954
+ let i = 0;
955
+ const childNodes = elm.childNodes;
956
+ const ilen = childNodes.length;
957
+ for (; i < ilen; i++) {
958
+ childNode = childNodes[i];
959
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
960
+ // first got the content reference comment node
961
+ // then we got it's parent, which is where all the host content is in now
962
+ hostContentNodes = node.parentNode.childNodes;
963
+ slotNameAttr = childNode['s-sn'];
964
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
965
+ node = hostContentNodes[j];
966
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
967
+ // let's do some relocating to its new home
968
+ // but never relocate a content reference node
969
+ // that is suppose to always represent the original content location
970
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
971
+ // it's possible we've already decided to relocate this node
972
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
973
+ // made some changes to slots
974
+ // let's make sure we also double check
975
+ // fallbacks are correctly hidden or shown
976
+ checkSlotFallbackVisibility = true;
977
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
978
+ if (relocateNodeData) {
979
+ // previously we never found a slot home for this node
980
+ // but turns out we did, so let's remember it now
981
+ relocateNodeData.$slotRefNode$ = childNode;
982
+ }
983
+ else {
984
+ // add to our list of nodes to relocate
985
+ relocateNodes.push({
986
+ $slotRefNode$: childNode,
987
+ $nodeToRelocate$: node,
988
+ });
989
+ }
990
+ if (node['s-sr']) {
991
+ relocateNodes.map((relocateNode) => {
992
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
993
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
994
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
995
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
996
+ }
997
+ }
998
+ });
999
+ }
1000
+ }
1001
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1002
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
1003
+ // if we never find a home for this element then we'll need to hide it
1004
+ relocateNodes.push({
1005
+ $nodeToRelocate$: node,
1006
+ });
1007
+ }
1008
+ }
1009
+ }
1010
+ }
1011
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1012
+ relocateSlotContent(childNode);
1013
+ }
1014
+ }
1015
+ };
1016
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1017
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1018
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1019
+ return true;
1020
+ }
1021
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1022
+ return true;
1023
+ }
1024
+ return false;
1025
+ }
1026
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
1027
+ return true;
1028
+ }
1029
+ return slotNameAttr === '';
1030
+ };
782
1031
  const renderVdom = (hostRef, renderFnResults) => {
783
1032
  const hostElm = hostRef.$hostElement$;
784
1033
  const cmpMeta = hostRef.$cmpMeta$;
@@ -792,12 +1041,91 @@ const renderVdom = (hostRef, renderFnResults) => {
792
1041
  rootVnode.$tag$ = null;
793
1042
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
794
1043
  hostRef.$vnode$ = rootVnode;
795
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1044
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
796
1045
  {
797
- scopeId = hostElm['s-sc'];
1046
+ contentRef = hostElm['s-cr'];
1047
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1048
+ // always reset
1049
+ checkSlotFallbackVisibility = false;
798
1050
  }
799
1051
  // synchronous patch
800
1052
  patch(oldVNode, rootVnode);
1053
+ {
1054
+ // while we're moving nodes around existing nodes, temporarily disable
1055
+ // the disconnectCallback from working
1056
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1057
+ if (checkSlotRelocate) {
1058
+ relocateSlotContent(rootVnode.$elm$);
1059
+ let relocateData;
1060
+ let nodeToRelocate;
1061
+ let orgLocationNode;
1062
+ let parentNodeRef;
1063
+ let insertBeforeNode;
1064
+ let refNode;
1065
+ let i = 0;
1066
+ for (; i < relocateNodes.length; i++) {
1067
+ relocateData = relocateNodes[i];
1068
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1069
+ if (!nodeToRelocate['s-ol']) {
1070
+ // add a reference node marking this node's original location
1071
+ // keep a reference to this node for later lookups
1072
+ orgLocationNode =
1073
+ doc.createTextNode('');
1074
+ orgLocationNode['s-nr'] = nodeToRelocate;
1075
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1076
+ }
1077
+ }
1078
+ for (i = 0; i < relocateNodes.length; i++) {
1079
+ relocateData = relocateNodes[i];
1080
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1081
+ if (relocateData.$slotRefNode$) {
1082
+ // by default we're just going to insert it directly
1083
+ // after the slot reference node
1084
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1085
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1086
+ orgLocationNode = nodeToRelocate['s-ol'];
1087
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
1088
+ refNode = orgLocationNode['s-nr'];
1089
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1090
+ refNode = refNode.nextSibling;
1091
+ if (!refNode || !refNode['s-nr']) {
1092
+ insertBeforeNode = refNode;
1093
+ break;
1094
+ }
1095
+ }
1096
+ }
1097
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1098
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1099
+ // we've checked that it's worth while to relocate
1100
+ // since that the node to relocate
1101
+ // has a different next sibling or parent relocated
1102
+ if (nodeToRelocate !== insertBeforeNode) {
1103
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1104
+ // probably a component in the index.html that doesn't have it's hostname set
1105
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1106
+ }
1107
+ // add it back to the dom but in its new home
1108
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1109
+ }
1110
+ }
1111
+ }
1112
+ else {
1113
+ // this node doesn't have a slot home to go to, so let's hide it
1114
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1115
+ nodeToRelocate.hidden = true;
1116
+ }
1117
+ }
1118
+ }
1119
+ }
1120
+ if (checkSlotFallbackVisibility) {
1121
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1122
+ }
1123
+ // done moving nodes around
1124
+ // allow the disconnect callback to work again
1125
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1126
+ // always reset
1127
+ relocateNodes.length = 0;
1128
+ }
801
1129
  };
802
1130
  const attachToAncestor = (hostRef, ancestorComponent) => {
803
1131
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
@@ -1188,6 +1516,15 @@ const connectedCallback = (elm) => {
1188
1516
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1189
1517
  // first time this component has connected
1190
1518
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1519
+ {
1520
+ // initUpdate
1521
+ // if the slot polyfill is required we'll need to put some nodes
1522
+ // in here to act as original content anchors as we move nodes around
1523
+ // host element has been connected to the DOM
1524
+ if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1525
+ setContentReference(elm);
1526
+ }
1527
+ }
1191
1528
  {
1192
1529
  // find the first ancestor component (if there is one) and register
1193
1530
  // this component as one of the actively loading child components for its ancestor
@@ -1225,6 +1562,17 @@ const connectedCallback = (elm) => {
1225
1562
  endConnected();
1226
1563
  }
1227
1564
  };
1565
+ const setContentReference = (elm) => {
1566
+ // only required when we're NOT using native shadow dom (slot)
1567
+ // or this browser doesn't support native shadow dom
1568
+ // and this host element was NOT created with SSR
1569
+ // let's pick out the inner content for slot projection
1570
+ // create a node to represent where the original
1571
+ // content was first placed, which is useful later on
1572
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1573
+ contentRefElm['s-cn'] = true;
1574
+ elm.insertBefore(contentRefElm, elm.firstChild);
1575
+ };
1228
1576
  const disconnectedCallback = (elm) => {
1229
1577
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1230
1578
  getHostRef(elm);
@@ -1268,17 +1616,6 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1268
1616
  super(self);
1269
1617
  self = this;
1270
1618
  registerHost(self, cmpMeta);
1271
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1272
- // this component is using shadow dom
1273
- // and this browser supports shadow dom
1274
- // add the read-only property "shadowRoot" to the host element
1275
- // adding the shadow root build conditionals to minimize runtime
1276
- {
1277
- {
1278
- self.attachShadow({ mode: 'open' });
1279
- }
1280
- }
1281
- }
1282
1619
  }
1283
1620
  connectedCallback() {
1284
1621
  if (appLoadFallback) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-8686299e.js');
5
+ const index = require('./index-76f95c4b.js');
6
6
  const appGlobals = require('./app-globals-0f70160b.js');
7
7
 
8
8
  /*
@@ -16,7 +16,7 @@ const defineCustomElements = (win, options) => {
16
16
  if (typeof window === 'undefined') return Promise.resolve();
17
17
  return patchEsm().then(() => {
18
18
  appGlobals.globalScripts();
19
- return index.bootstrapLazy([["cura-icon.cjs",[[1,"cura-icon",{"name":[513],"color":[1],"size":[8],"iconset":[513],"disabled":[4]}]]],["cura-icons-view.cjs",[[1,"cura-icons-view",{"selected":[32]}]]],["cura-display_4.cjs",[[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);
19
+ return index.bootstrapLazy([["cura-icon.cjs",[[0,"cura-icon",{"name":[513],"color":[1],"size":[8],"iconset":[513],"disabled":[4]}]]],["cura-icons-view.cjs",[[0,"cura-icons-view",{"selected":[32]}]]],["cura-display_4.cjs",[[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);
20
20
  });
21
21
  };
22
22
 
@@ -1,8 +1,8 @@
1
- :host {
1
+ .cura-icon {
2
2
  width: var(--size);
3
3
  height: var(--size);
4
4
  }
5
- :host svg {
5
+ .cura-icon svg {
6
6
  display: inline-block;
7
7
  stroke: var(--color);
8
8
  width: var(--size);
@@ -37,10 +37,9 @@ export class CuraIcon {
37
37
  this.host.style.setProperty(prop, value);
38
38
  }
39
39
  render() {
40
- return (h(Host, null, h("svg", { version: "1.1", viewBox: "0 0 24 24", preserveAspectRatio: "xMidYMid meet", xmlns: "http://www.w3.org/2000/svg" }, h("use", { xlinkHref: `${this.assetsPath}/icons/iconset-${this.iconset}.svg#${this.name}` }))));
40
+ return (h(Host, { class: 'cura-icon' }, h("svg", { version: "1.1", viewBox: "0 0 24 24", preserveAspectRatio: "xMidYMid meet", xmlns: "http://www.w3.org/2000/svg" }, h("use", { xlinkHref: `${this.assetsPath}/icons/iconset-${this.iconset}.svg#${this.name}` }))));
41
41
  }
42
42
  static get is() { return "cura-icon"; }
43
- static get encapsulation() { return "shadow"; }
44
43
  static get originalStyleUrls() {
45
44
  return {
46
45
  "$": ["cura-icon.scss"]
@@ -13,7 +13,6 @@ export class CuraIconsView {
13
13
  return (h(Host, null, h("div", { class: "iconDetail" }, h("h4", null, this.selected), h("div", { class: "iconSizes" }, this.sizes.map(size => h("div", { class: "size" }, h("cura-icon", { name: this.selected, size: size }), h("span", null, size)))), h("div", { class: "iconSizes invert" }, this.sizes.map(size => h("div", { class: "size" }, h("cura-icon", { name: this.selected, size: size, color: "neutral-white" }), h("span", null, size)))), h("div", { class: "iconSizes" }, this.colors.map(color => h("div", { class: "size" }, h("cura-icon", { name: this.selected, color: color }), h("span", null, color))), h("div", { class: "size" }, h("cura-icon", { name: this.selected, disabled: true }), h("span", null, "Disabled")))), h("div", { class: "icons" }, iconsetdefaulticons.map(icon => h("div", { class: "icon", onClick: () => this.setSelected(icon) }, h("cura-icon", { name: icon }), h("span", null, icon))))));
14
14
  }
15
15
  static get is() { return "cura-icons-view"; }
16
- static get encapsulation() { return "shadow"; }
17
16
  static get originalStyleUrls() {
18
17
  return {
19
18
  "$": ["cura-icons-view.scss"]