@sankhyalabs/sankhyablocks 1.3.31-beta.2 → 1.3.31-beta.3

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 (68) hide show
  1. package/dist/cjs/{index-1133bc2a.js → index-e42cb45d.js} +448 -9
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/sankhyablocks.cjs.js +2 -2
  4. package/dist/cjs/snk-application.cjs.entry.js +105 -79
  5. package/dist/cjs/snk-data-unit.cjs.entry.js +144 -0
  6. package/dist/cjs/snk-form.cjs.entry.js +95 -0
  7. package/dist/cjs/snk-grid.cjs.entry.js +64 -0
  8. package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-taskbar.cjs.entry.js +159 -0
  10. package/dist/cjs/taskbar-elements-bfa647c7.js +68 -0
  11. package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
  12. package/dist/collection/collection-manifest.json +4 -0
  13. package/dist/collection/components/snk-application/snk-application.js +52 -5
  14. package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
  15. package/dist/collection/components/snk-data-unit/snk-data-unit.js +325 -0
  16. package/dist/collection/components/snk-form/snk-form.css +3 -0
  17. package/dist/collection/components/snk-form/snk-form.js +194 -0
  18. package/dist/collection/components/snk-grid/snk-grid.css +5 -0
  19. package/dist/collection/components/snk-grid/snk-grid.js +128 -0
  20. package/dist/collection/components/snk-taskbar/component/snk-popup-button.js +7 -0
  21. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +63 -0
  22. package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
  23. package/dist/collection/components/snk-taskbar/snk-taskbar.js +268 -0
  24. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +32 -21
  25. package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
  26. package/dist/components/snk-application2.js +105 -78
  27. package/dist/components/snk-data-unit.d.ts +11 -0
  28. package/dist/components/snk-data-unit.js +165 -0
  29. package/dist/components/snk-form.d.ts +11 -0
  30. package/dist/components/snk-form.js +121 -0
  31. package/dist/components/snk-grid.d.ts +11 -0
  32. package/dist/components/snk-grid.js +88 -0
  33. package/dist/components/snk-taskbar.d.ts +11 -0
  34. package/dist/components/snk-taskbar.js +6 -0
  35. package/dist/components/snk-taskbar2.js +239 -0
  36. package/dist/esm/{index-ffda6382.js → index-02c04e0f.js} +448 -10
  37. package/dist/esm/loader.js +2 -2
  38. package/dist/esm/sankhyablocks.js +2 -2
  39. package/dist/esm/snk-application.entry.js +105 -79
  40. package/dist/esm/snk-data-unit.entry.js +140 -0
  41. package/dist/esm/snk-form.entry.js +91 -0
  42. package/dist/esm/snk-grid.entry.js +60 -0
  43. package/dist/esm/snk-pesquisa.entry.js +1 -1
  44. package/dist/esm/snk-taskbar.entry.js +155 -0
  45. package/dist/esm/taskbar-elements-fe7cbf0e.js +66 -0
  46. package/dist/esm/teste-pesquisa.entry.js +1 -1
  47. package/dist/sankhyablocks/p-09e48ff8.entry.js +1 -0
  48. package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-376004ef.entry.js} +1 -1
  49. package/dist/sankhyablocks/p-37b06977.entry.js +1 -0
  50. package/dist/sankhyablocks/p-64e2471c.js +1 -0
  51. package/dist/sankhyablocks/p-b80352ac.entry.js +69 -0
  52. package/dist/sankhyablocks/p-c156b1da.entry.js +1 -0
  53. package/dist/sankhyablocks/p-cc9c348a.entry.js +1 -0
  54. package/dist/sankhyablocks/p-db215c74.js +2 -0
  55. package/dist/sankhyablocks/{p-d62412bb.entry.js → p-e38386b1.entry.js} +1 -1
  56. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  57. package/dist/types/components/snk-application/snk-application.d.ts +3 -1
  58. package/dist/types/components/snk-taskbar/component/snk-popup-button.d.ts +12 -0
  59. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +24 -0
  60. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +28 -0
  61. package/dist/types/components.d.ts +112 -1
  62. package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
  63. package/package.json +5 -5
  64. package/react/components.d.ts +4 -0
  65. package/react/components.js +4 -0
  66. package/react/components.js.map +1 -1
  67. package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
  68. package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
@@ -1,7 +1,11 @@
1
1
  const NAMESPACE = 'sankhyablocks';
2
2
 
3
3
  let scopeId;
4
+ let contentRef;
4
5
  let hostTagName;
6
+ let useNativeShadowDom = false;
7
+ let checkSlotFallbackVisibility = false;
8
+ let checkSlotRelocate = false;
5
9
  let isSvgMode = false;
6
10
  let queuePending = false;
7
11
  const win = typeof window !== 'undefined' ? window : {};
@@ -135,6 +139,8 @@ const isComplexType = (o) => {
135
139
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
136
140
  const h = (nodeName, vnodeData, ...children) => {
137
141
  let child = null;
142
+ let key = null;
143
+ let slotName = null;
138
144
  let simple = false;
139
145
  let lastSimple = false;
140
146
  const vNodeChildren = [];
@@ -162,6 +168,13 @@ const h = (nodeName, vnodeData, ...children) => {
162
168
  };
163
169
  walk(children);
164
170
  if (vnodeData) {
171
+ // normalize class / classname attributes
172
+ if (vnodeData.key) {
173
+ key = vnodeData.key;
174
+ }
175
+ if (vnodeData.name) {
176
+ slotName = vnodeData.name;
177
+ }
165
178
  {
166
179
  const classData = vnodeData.className || vnodeData.class;
167
180
  if (classData) {
@@ -174,11 +187,21 @@ const h = (nodeName, vnodeData, ...children) => {
174
187
  }
175
188
  }
176
189
  }
190
+ if (typeof nodeName === 'function') {
191
+ // nodeName is a functional component
192
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
193
+ }
177
194
  const vnode = newVNode(nodeName, null);
178
195
  vnode.$attrs$ = vnodeData;
179
196
  if (vNodeChildren.length > 0) {
180
197
  vnode.$children$ = vNodeChildren;
181
198
  }
199
+ {
200
+ vnode.$key$ = key;
201
+ }
202
+ {
203
+ vnode.$name$ = slotName;
204
+ }
182
205
  return vnode;
183
206
  };
184
207
  const newVNode = (tag, text) => {
@@ -192,10 +215,46 @@ const newVNode = (tag, text) => {
192
215
  {
193
216
  vnode.$attrs$ = null;
194
217
  }
218
+ {
219
+ vnode.$key$ = null;
220
+ }
221
+ {
222
+ vnode.$name$ = null;
223
+ }
195
224
  return vnode;
196
225
  };
197
226
  const Host = {};
198
227
  const isHost = (node) => node && node.$tag$ === Host;
228
+ const vdomFnUtils = {
229
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
230
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
231
+ };
232
+ const convertToPublic = (node) => ({
233
+ vattrs: node.$attrs$,
234
+ vchildren: node.$children$,
235
+ vkey: node.$key$,
236
+ vname: node.$name$,
237
+ vtag: node.$tag$,
238
+ vtext: node.$text$,
239
+ });
240
+ const convertToPrivate = (node) => {
241
+ if (typeof node.vtag === 'function') {
242
+ const vnodeData = Object.assign({}, node.vattrs);
243
+ if (node.vkey) {
244
+ vnodeData.key = node.vkey;
245
+ }
246
+ if (node.vname) {
247
+ vnodeData.name = node.vname;
248
+ }
249
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
250
+ }
251
+ const vnode = newVNode(node.vtag, node.vtext);
252
+ vnode.$attrs$ = node.vattrs;
253
+ vnode.$children$ = node.vchildren;
254
+ vnode.$key$ = node.vkey;
255
+ vnode.$name$ = node.vname;
256
+ return vnode;
257
+ };
199
258
  /**
200
259
  * Production setAccessor() function based on Preact by
201
260
  * Jason Miller (@developit)
@@ -215,6 +274,8 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
215
274
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
216
275
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
217
276
  }
277
+ else if (memberName === 'key')
278
+ ;
218
279
  else if (memberName === 'ref') {
219
280
  // minifier will clean this up
220
281
  if (newValue) {
@@ -327,13 +388,36 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
327
388
  let i = 0;
328
389
  let elm;
329
390
  let childNode;
391
+ let oldVNode;
392
+ if (!useNativeShadowDom) {
393
+ // remember for later we need to check to relocate nodes
394
+ checkSlotRelocate = true;
395
+ if (newVNode.$tag$ === 'slot') {
396
+ if (scopeId) {
397
+ // scoped css needs to add its scoped id to the parent element
398
+ parentElm.classList.add(scopeId + '-s');
399
+ }
400
+ newVNode.$flags$ |= newVNode.$children$
401
+ ? // slot element has fallback content
402
+ 2 /* isSlotFallback */
403
+ : // slot element does not have fallback content
404
+ 1 /* isSlotReference */;
405
+ }
406
+ }
330
407
  if (newVNode.$text$ !== null) {
331
408
  // create text node
332
409
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
333
410
  }
411
+ else if (newVNode.$flags$ & 1 /* isSlotReference */) {
412
+ // create a slot reference node
413
+ elm = newVNode.$elm$ =
414
+ doc.createTextNode('');
415
+ }
334
416
  else {
335
417
  // create element
336
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
418
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
419
+ ? 'slot-fb'
420
+ : newVNode.$tag$));
337
421
  // add css classes, attrs, props, listeners, etc.
338
422
  {
339
423
  updateElement(null, newVNode, isSvgMode);
@@ -346,7 +430,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
346
430
  if (newVNode.$children$) {
347
431
  for (i = 0; i < newVNode.$children$.length; ++i) {
348
432
  // create the node
349
- childNode = createElm(oldParentVNode, newVNode, i);
433
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
350
434
  // return node could have been null
351
435
  if (childNode) {
352
436
  // append our new node
@@ -355,20 +439,62 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
355
439
  }
356
440
  }
357
441
  }
442
+ {
443
+ elm['s-hn'] = hostTagName;
444
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
445
+ // remember the content reference comment
446
+ elm['s-sr'] = true;
447
+ // remember the content reference comment
448
+ elm['s-cr'] = contentRef;
449
+ // remember the slot name, or empty string for default slot
450
+ elm['s-sn'] = newVNode.$name$ || '';
451
+ // check if we've got an old vnode for this slot
452
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
453
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
454
+ // we've got an old slot vnode and the wrapper is being replaced
455
+ // so let's move the old slot content back to it's original location
456
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
457
+ }
458
+ }
459
+ }
358
460
  return elm;
359
461
  };
462
+ const putBackInOriginalLocation = (parentElm, recursive) => {
463
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
464
+ const oldSlotChildNodes = parentElm.childNodes;
465
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
466
+ const childNode = oldSlotChildNodes[i];
467
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
468
+ // // this child node in the old element is from another component
469
+ // // remove this node from the old slot's parent
470
+ // childNode.remove();
471
+ // and relocate it back to it's original location
472
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
473
+ // remove the old original location comment entirely
474
+ // later on the patch function will know what to do
475
+ // and move this to the correct spot in need be
476
+ childNode['s-ol'].remove();
477
+ childNode['s-ol'] = undefined;
478
+ checkSlotRelocate = true;
479
+ }
480
+ if (recursive) {
481
+ putBackInOriginalLocation(childNode, recursive);
482
+ }
483
+ }
484
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
485
+ };
360
486
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
361
- let containerElm = (parentElm);
487
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
362
488
  let childNode;
363
489
  if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
364
490
  containerElm = containerElm.shadowRoot;
365
491
  }
366
492
  for (; startIdx <= endIdx; ++startIdx) {
367
493
  if (vnodes[startIdx]) {
368
- childNode = createElm(null, parentVNode, startIdx);
494
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
369
495
  if (childNode) {
370
496
  vnodes[startIdx].$elm$ = childNode;
371
- containerElm.insertBefore(childNode, before);
497
+ containerElm.insertBefore(childNode, referenceNode(before) );
372
498
  }
373
499
  }
374
500
  }
@@ -378,6 +504,20 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
378
504
  if ((vnode = vnodes[startIdx])) {
379
505
  elm = vnode.$elm$;
380
506
  callNodeRefs(vnode);
507
+ {
508
+ // we're removing this element
509
+ // so it's possible we need to show slot fallback content now
510
+ checkSlotFallbackVisibility = true;
511
+ if (elm['s-ol']) {
512
+ // remove the original location comment
513
+ elm['s-ol'].remove();
514
+ }
515
+ else {
516
+ // it's possible that child nodes of the node
517
+ // that's being removed are slot nodes
518
+ putBackInOriginalLocation(elm, true);
519
+ }
520
+ }
381
521
  // remove the vnode's element from the dom
382
522
  elm.remove();
383
523
  }
@@ -386,6 +526,8 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
386
526
  const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
387
527
  let oldStartIdx = 0;
388
528
  let newStartIdx = 0;
529
+ let idxInOld = 0;
530
+ let i = 0;
389
531
  let oldEndIdx = oldCh.length - 1;
390
532
  let oldStartVnode = oldCh[0];
391
533
  let oldEndVnode = oldCh[oldEndIdx];
@@ -393,6 +535,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
393
535
  let newStartVnode = newCh[0];
394
536
  let newEndVnode = newCh[newEndIdx];
395
537
  let node;
538
+ let elmToMove;
396
539
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
397
540
  if (oldStartVnode == null) {
398
541
  // Vnode might have been moved left
@@ -418,26 +561,56 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
418
561
  newEndVnode = newCh[--newEndIdx];
419
562
  }
420
563
  else if (isSameVnode(oldStartVnode, newEndVnode)) {
564
+ // Vnode moved right
565
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
566
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
567
+ }
421
568
  patch(oldStartVnode, newEndVnode);
422
569
  parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
423
570
  oldStartVnode = oldCh[++oldStartIdx];
424
571
  newEndVnode = newCh[--newEndIdx];
425
572
  }
426
573
  else if (isSameVnode(oldEndVnode, newStartVnode)) {
574
+ // Vnode moved left
575
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
576
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
577
+ }
427
578
  patch(oldEndVnode, newStartVnode);
428
579
  parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
429
580
  oldEndVnode = oldCh[--oldEndIdx];
430
581
  newStartVnode = newCh[++newStartIdx];
431
582
  }
432
583
  else {
584
+ // createKeyToOldIdx
585
+ idxInOld = -1;
433
586
  {
587
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
588
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
589
+ idxInOld = i;
590
+ break;
591
+ }
592
+ }
593
+ }
594
+ if (idxInOld >= 0) {
595
+ elmToMove = oldCh[idxInOld];
596
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
597
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
598
+ }
599
+ else {
600
+ patch(elmToMove, newStartVnode);
601
+ oldCh[idxInOld] = undefined;
602
+ node = elmToMove.$elm$;
603
+ }
604
+ newStartVnode = newCh[++newStartIdx];
605
+ }
606
+ else {
434
607
  // new element
435
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
608
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
436
609
  newStartVnode = newCh[++newStartIdx];
437
610
  }
438
611
  if (node) {
439
612
  {
440
- oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
613
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
441
614
  }
442
615
  }
443
616
  }
@@ -453,19 +626,36 @@ const isSameVnode = (vnode1, vnode2) => {
453
626
  // compare if two vnode to see if they're "technically" the same
454
627
  // need to have the same element tag, and same key to be the same
455
628
  if (vnode1.$tag$ === vnode2.$tag$) {
456
- return true;
629
+ if (vnode1.$tag$ === 'slot') {
630
+ return vnode1.$name$ === vnode2.$name$;
631
+ }
632
+ {
633
+ return vnode1.$key$ === vnode2.$key$;
634
+ }
457
635
  }
458
636
  return false;
459
637
  };
638
+ const referenceNode = (node) => {
639
+ // this node was relocated to a new location in the dom
640
+ // because of some other component's slot
641
+ // but we still have an html comment in place of where
642
+ // it's original location was according to it's original vdom
643
+ return (node && node['s-ol']) || node;
644
+ };
645
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
460
646
  const patch = (oldVNode, newVNode) => {
461
647
  const elm = (newVNode.$elm$ = oldVNode.$elm$);
462
648
  const oldChildren = oldVNode.$children$;
463
649
  const newChildren = newVNode.$children$;
650
+ const tag = newVNode.$tag$;
464
651
  const text = newVNode.$text$;
652
+ let defaultHolder;
465
653
  if (text === null) {
466
654
  // element node
467
655
  {
468
- {
656
+ if (tag === 'slot')
657
+ ;
658
+ else {
469
659
  // either this is the first render of an element OR it's an update
470
660
  // AND we already know it's possible it could have changed
471
661
  // this updates the element's css classes, attrs, props, listeners, etc.
@@ -490,12 +680,147 @@ const patch = (oldVNode, newVNode) => {
490
680
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
491
681
  }
492
682
  }
683
+ else if ((defaultHolder = elm['s-cr'])) {
684
+ // this element has slotted content
685
+ defaultHolder.parentNode.textContent = text;
686
+ }
493
687
  else if (oldVNode.$text$ !== text) {
494
688
  // update the text content for the text only vnode
495
689
  // and also only if the text is different than before
496
690
  elm.data = text;
497
691
  }
498
692
  };
693
+ const updateFallbackSlotVisibility = (elm) => {
694
+ // tslint:disable-next-line: prefer-const
695
+ const childNodes = elm.childNodes;
696
+ let childNode;
697
+ let i;
698
+ let ilen;
699
+ let j;
700
+ let slotNameAttr;
701
+ let nodeType;
702
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
703
+ childNode = childNodes[i];
704
+ if (childNode.nodeType === 1 /* ElementNode */) {
705
+ if (childNode['s-sr']) {
706
+ // this is a slot fallback node
707
+ // get the slot name for this slot reference node
708
+ slotNameAttr = childNode['s-sn'];
709
+ // by default always show a fallback slot node
710
+ // then hide it if there are other slots in the light dom
711
+ childNode.hidden = false;
712
+ for (j = 0; j < ilen; j++) {
713
+ nodeType = childNodes[j].nodeType;
714
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
715
+ // this sibling node is from a different component OR is a named fallback slot node
716
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
717
+ childNode.hidden = true;
718
+ break;
719
+ }
720
+ }
721
+ else {
722
+ // this is a default fallback slot node
723
+ // any element or text node (with content)
724
+ // should hide the default fallback slot node
725
+ if (nodeType === 1 /* ElementNode */ ||
726
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
727
+ childNode.hidden = true;
728
+ break;
729
+ }
730
+ }
731
+ }
732
+ }
733
+ // keep drilling down
734
+ updateFallbackSlotVisibility(childNode);
735
+ }
736
+ }
737
+ };
738
+ const relocateNodes = [];
739
+ const relocateSlotContent = (elm) => {
740
+ // tslint:disable-next-line: prefer-const
741
+ let childNode;
742
+ let node;
743
+ let hostContentNodes;
744
+ let slotNameAttr;
745
+ let relocateNodeData;
746
+ let j;
747
+ let i = 0;
748
+ const childNodes = elm.childNodes;
749
+ const ilen = childNodes.length;
750
+ for (; i < ilen; i++) {
751
+ childNode = childNodes[i];
752
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
753
+ // first got the content reference comment node
754
+ // then we got it's parent, which is where all the host content is in now
755
+ hostContentNodes = node.parentNode.childNodes;
756
+ slotNameAttr = childNode['s-sn'];
757
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
758
+ node = hostContentNodes[j];
759
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
760
+ // let's do some relocating to its new home
761
+ // but never relocate a content reference node
762
+ // that is suppose to always represent the original content location
763
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
764
+ // it's possible we've already decided to relocate this node
765
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
766
+ // made some changes to slots
767
+ // let's make sure we also double check
768
+ // fallbacks are correctly hidden or shown
769
+ checkSlotFallbackVisibility = true;
770
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
771
+ if (relocateNodeData) {
772
+ // previously we never found a slot home for this node
773
+ // but turns out we did, so let's remember it now
774
+ relocateNodeData.$slotRefNode$ = childNode;
775
+ }
776
+ else {
777
+ // add to our list of nodes to relocate
778
+ relocateNodes.push({
779
+ $slotRefNode$: childNode,
780
+ $nodeToRelocate$: node,
781
+ });
782
+ }
783
+ if (node['s-sr']) {
784
+ relocateNodes.map((relocateNode) => {
785
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
786
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
787
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
788
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
789
+ }
790
+ }
791
+ });
792
+ }
793
+ }
794
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
795
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
796
+ // if we never find a home for this element then we'll need to hide it
797
+ relocateNodes.push({
798
+ $nodeToRelocate$: node,
799
+ });
800
+ }
801
+ }
802
+ }
803
+ }
804
+ if (childNode.nodeType === 1 /* ElementNode */) {
805
+ relocateSlotContent(childNode);
806
+ }
807
+ }
808
+ };
809
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
810
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
811
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
812
+ return true;
813
+ }
814
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
815
+ return true;
816
+ }
817
+ return false;
818
+ }
819
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
820
+ return true;
821
+ }
822
+ return slotNameAttr === '';
823
+ };
499
824
  const callNodeRefs = (vNode) => {
500
825
  {
501
826
  vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
@@ -504,6 +829,7 @@ const callNodeRefs = (vNode) => {
504
829
  };
505
830
  const renderVdom = (hostRef, renderFnResults) => {
506
831
  const hostElm = hostRef.$hostElement$;
832
+ const cmpMeta = hostRef.$cmpMeta$;
507
833
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
508
834
  const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
509
835
  hostTagName = hostElm.tagName;
@@ -514,8 +840,90 @@ const renderVdom = (hostRef, renderFnResults) => {
514
840
  {
515
841
  scopeId = hostElm['s-sc'];
516
842
  }
843
+ {
844
+ contentRef = hostElm['s-cr'];
845
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
846
+ // always reset
847
+ checkSlotFallbackVisibility = false;
848
+ }
517
849
  // synchronous patch
518
850
  patch(oldVNode, rootVnode);
851
+ {
852
+ // while we're moving nodes around existing nodes, temporarily disable
853
+ // the disconnectCallback from working
854
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
855
+ if (checkSlotRelocate) {
856
+ relocateSlotContent(rootVnode.$elm$);
857
+ let relocateData;
858
+ let nodeToRelocate;
859
+ let orgLocationNode;
860
+ let parentNodeRef;
861
+ let insertBeforeNode;
862
+ let refNode;
863
+ let i = 0;
864
+ for (; i < relocateNodes.length; i++) {
865
+ relocateData = relocateNodes[i];
866
+ nodeToRelocate = relocateData.$nodeToRelocate$;
867
+ if (!nodeToRelocate['s-ol']) {
868
+ // add a reference node marking this node's original location
869
+ // keep a reference to this node for later lookups
870
+ orgLocationNode =
871
+ doc.createTextNode('');
872
+ orgLocationNode['s-nr'] = nodeToRelocate;
873
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
874
+ }
875
+ }
876
+ for (i = 0; i < relocateNodes.length; i++) {
877
+ relocateData = relocateNodes[i];
878
+ nodeToRelocate = relocateData.$nodeToRelocate$;
879
+ if (relocateData.$slotRefNode$) {
880
+ // by default we're just going to insert it directly
881
+ // after the slot reference node
882
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
883
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
884
+ orgLocationNode = nodeToRelocate['s-ol'];
885
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
886
+ refNode = orgLocationNode['s-nr'];
887
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
888
+ refNode = refNode.nextSibling;
889
+ if (!refNode || !refNode['s-nr']) {
890
+ insertBeforeNode = refNode;
891
+ break;
892
+ }
893
+ }
894
+ }
895
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
896
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
897
+ // we've checked that it's worth while to relocate
898
+ // since that the node to relocate
899
+ // has a different next sibling or parent relocated
900
+ if (nodeToRelocate !== insertBeforeNode) {
901
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
902
+ // probably a component in the index.html that doesn't have it's hostname set
903
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
904
+ }
905
+ // add it back to the dom but in its new home
906
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
907
+ }
908
+ }
909
+ }
910
+ else {
911
+ // this node doesn't have a slot home to go to, so let's hide it
912
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
913
+ nodeToRelocate.hidden = true;
914
+ }
915
+ }
916
+ }
917
+ }
918
+ if (checkSlotFallbackVisibility) {
919
+ updateFallbackSlotVisibility(rootVnode.$elm$);
920
+ }
921
+ // done moving nodes around
922
+ // allow the disconnect callback to work again
923
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
924
+ // always reset
925
+ relocateNodes.length = 0;
926
+ }
519
927
  };
520
928
  const getElement = (ref) => (getHostRef(ref).$hostElement$ );
521
929
  const createEvent = (ref, name, flags) => {
@@ -572,6 +980,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
572
980
  promise = safeCall(instance, 'componentWillLoad');
573
981
  }
574
982
  }
983
+ {
984
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
985
+ }
575
986
  endSchedule();
576
987
  return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
577
988
  };
@@ -641,6 +1052,9 @@ const postUpdateComponent = (hostRef) => {
641
1052
  const endPostUpdate = createTime('postUpdate', tagName);
642
1053
  const instance = hostRef.$lazyInstance$ ;
643
1054
  const ancestorComponent = hostRef.$ancestorComponent$;
1055
+ {
1056
+ safeCall(instance, 'componentDidRender');
1057
+ }
644
1058
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
645
1059
  hostRef.$flags$ |= 64 /* hasLoadedComponent */;
646
1060
  {
@@ -730,6 +1144,10 @@ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
730
1144
  const parsePropertyValue = (propValue, propType) => {
731
1145
  // ensure this value is of the correct prop type
732
1146
  if (propValue != null && !isComplexType(propValue)) {
1147
+ if (propType & 2 /* Number */) {
1148
+ // force it to be a number
1149
+ return parseFloat(propValue);
1150
+ }
733
1151
  if (propType & 1 /* String */) {
734
1152
  // could have been passed as a number or boolean
735
1153
  // but we still want it as a string
@@ -979,6 +1397,15 @@ const connectedCallback = (elm) => {
979
1397
  if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
980
1398
  // first time this component has connected
981
1399
  hostRef.$flags$ |= 1 /* hasConnected */;
1400
+ {
1401
+ // initUpdate
1402
+ // if the slot polyfill is required we'll need to put some nodes
1403
+ // in here to act as original content anchors as we move nodes around
1404
+ // host element has been connected to the DOM
1405
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1406
+ setContentReference(elm);
1407
+ }
1408
+ }
982
1409
  {
983
1410
  // find the first ancestor component (if there is one) and register
984
1411
  // this component as one of the actively loading child components for its ancestor
@@ -1016,6 +1443,17 @@ const connectedCallback = (elm) => {
1016
1443
  endConnected();
1017
1444
  }
1018
1445
  };
1446
+ const setContentReference = (elm) => {
1447
+ // only required when we're NOT using native shadow dom (slot)
1448
+ // or this browser doesn't support native shadow dom
1449
+ // and this host element was NOT created with SSR
1450
+ // let's pick out the inner content for slot projection
1451
+ // create a node to represent where the original
1452
+ // content was first placed, which is useful later on
1453
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1454
+ contentRefElm['s-cn'] = true;
1455
+ elm.insertBefore(contentRefElm, elm.firstChild);
1456
+ };
1019
1457
  const disconnectedCallback = (elm) => {
1020
1458
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1021
1459
  const hostRef = getHostRef(elm);
@@ -1205,4 +1643,4 @@ const flush = () => {
1205
1643
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1206
1644
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1207
1645
 
1208
- export { Host as H, bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r };
1646
+ export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r };