@sankhyalabs/sankhyablocks 1.3.31-beta.1 → 1.3.31-beta.4
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.
- package/dist/cjs/{index-1133bc2a.js → index-ebe8245e.js} +453 -9
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +109 -79
- package/dist/cjs/snk-data-unit.cjs.entry.js +174 -0
- package/dist/cjs/snk-form.cjs.entry.js +95 -0
- package/dist/cjs/snk-grid.cjs.entry.js +64 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +159 -0
- package/dist/cjs/taskbar-elements-589a3744.js +68 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +4 -0
- package/dist/collection/components/snk-application/snk-application.js +52 -5
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +429 -0
- package/dist/collection/components/snk-form/snk-form.css +3 -0
- package/dist/collection/components/snk-form/snk-form.js +194 -0
- package/dist/collection/components/snk-grid/snk-grid.css +5 -0
- package/dist/collection/components/snk-grid/snk-grid.js +128 -0
- package/dist/collection/components/snk-taskbar/component/snk-popup-button.js +7 -0
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +63 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +268 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +36 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/components/snk-application2.js +109 -78
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +198 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +121 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +88 -0
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +239 -0
- package/dist/esm/{index-ffda6382.js → index-7565ae23.js} +453 -10
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +109 -79
- package/dist/esm/snk-data-unit.entry.js +170 -0
- package/dist/esm/snk-form.entry.js +91 -0
- package/dist/esm/snk-grid.entry.js +60 -0
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +155 -0
- package/dist/esm/taskbar-elements-b6822601.js +66 -0
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/p-306224bf.entry.js +1 -0
- package/dist/sankhyablocks/p-4ee1e12b.js +1 -0
- package/dist/sankhyablocks/{p-d62412bb.entry.js → p-6d82d7fd.entry.js} +1 -1
- package/dist/sankhyablocks/p-88278b85.entry.js +1 -0
- package/dist/sankhyablocks/p-90b832f7.js +2 -0
- package/dist/sankhyablocks/p-a4b2fa10.entry.js +69 -0
- package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-bb31ea2a.entry.js} +1 -1
- package/dist/sankhyablocks/p-bb8d8fe7.entry.js +1 -0
- package/dist/sankhyablocks/p-e7ade160.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +3 -1
- package/dist/types/components/snk-taskbar/component/snk-popup-button.d.ts +12 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +24 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +28 -0
- package/dist/types/components.d.ts +119 -1
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
- package/package.json +5 -5
- package/react/components.d.ts +4 -0
- package/react/components.js +4 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -23,7 +23,11 @@ function _interopNamespace(e) {
|
|
|
23
23
|
const NAMESPACE = 'sankhyablocks';
|
|
24
24
|
|
|
25
25
|
let scopeId;
|
|
26
|
+
let contentRef;
|
|
26
27
|
let hostTagName;
|
|
28
|
+
let useNativeShadowDom = false;
|
|
29
|
+
let checkSlotFallbackVisibility = false;
|
|
30
|
+
let checkSlotRelocate = false;
|
|
27
31
|
let isSvgMode = false;
|
|
28
32
|
let queuePending = false;
|
|
29
33
|
const win = typeof window !== 'undefined' ? window : {};
|
|
@@ -157,6 +161,8 @@ const isComplexType = (o) => {
|
|
|
157
161
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
158
162
|
const h = (nodeName, vnodeData, ...children) => {
|
|
159
163
|
let child = null;
|
|
164
|
+
let key = null;
|
|
165
|
+
let slotName = null;
|
|
160
166
|
let simple = false;
|
|
161
167
|
let lastSimple = false;
|
|
162
168
|
const vNodeChildren = [];
|
|
@@ -184,6 +190,13 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
184
190
|
};
|
|
185
191
|
walk(children);
|
|
186
192
|
if (vnodeData) {
|
|
193
|
+
// normalize class / classname attributes
|
|
194
|
+
if (vnodeData.key) {
|
|
195
|
+
key = vnodeData.key;
|
|
196
|
+
}
|
|
197
|
+
if (vnodeData.name) {
|
|
198
|
+
slotName = vnodeData.name;
|
|
199
|
+
}
|
|
187
200
|
{
|
|
188
201
|
const classData = vnodeData.className || vnodeData.class;
|
|
189
202
|
if (classData) {
|
|
@@ -196,11 +209,21 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
196
209
|
}
|
|
197
210
|
}
|
|
198
211
|
}
|
|
212
|
+
if (typeof nodeName === 'function') {
|
|
213
|
+
// nodeName is a functional component
|
|
214
|
+
return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
215
|
+
}
|
|
199
216
|
const vnode = newVNode(nodeName, null);
|
|
200
217
|
vnode.$attrs$ = vnodeData;
|
|
201
218
|
if (vNodeChildren.length > 0) {
|
|
202
219
|
vnode.$children$ = vNodeChildren;
|
|
203
220
|
}
|
|
221
|
+
{
|
|
222
|
+
vnode.$key$ = key;
|
|
223
|
+
}
|
|
224
|
+
{
|
|
225
|
+
vnode.$name$ = slotName;
|
|
226
|
+
}
|
|
204
227
|
return vnode;
|
|
205
228
|
};
|
|
206
229
|
const newVNode = (tag, text) => {
|
|
@@ -214,10 +237,46 @@ const newVNode = (tag, text) => {
|
|
|
214
237
|
{
|
|
215
238
|
vnode.$attrs$ = null;
|
|
216
239
|
}
|
|
240
|
+
{
|
|
241
|
+
vnode.$key$ = null;
|
|
242
|
+
}
|
|
243
|
+
{
|
|
244
|
+
vnode.$name$ = null;
|
|
245
|
+
}
|
|
217
246
|
return vnode;
|
|
218
247
|
};
|
|
219
248
|
const Host = {};
|
|
220
249
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
250
|
+
const vdomFnUtils = {
|
|
251
|
+
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
252
|
+
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
253
|
+
};
|
|
254
|
+
const convertToPublic = (node) => ({
|
|
255
|
+
vattrs: node.$attrs$,
|
|
256
|
+
vchildren: node.$children$,
|
|
257
|
+
vkey: node.$key$,
|
|
258
|
+
vname: node.$name$,
|
|
259
|
+
vtag: node.$tag$,
|
|
260
|
+
vtext: node.$text$,
|
|
261
|
+
});
|
|
262
|
+
const convertToPrivate = (node) => {
|
|
263
|
+
if (typeof node.vtag === 'function') {
|
|
264
|
+
const vnodeData = Object.assign({}, node.vattrs);
|
|
265
|
+
if (node.vkey) {
|
|
266
|
+
vnodeData.key = node.vkey;
|
|
267
|
+
}
|
|
268
|
+
if (node.vname) {
|
|
269
|
+
vnodeData.name = node.vname;
|
|
270
|
+
}
|
|
271
|
+
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
272
|
+
}
|
|
273
|
+
const vnode = newVNode(node.vtag, node.vtext);
|
|
274
|
+
vnode.$attrs$ = node.vattrs;
|
|
275
|
+
vnode.$children$ = node.vchildren;
|
|
276
|
+
vnode.$key$ = node.vkey;
|
|
277
|
+
vnode.$name$ = node.vname;
|
|
278
|
+
return vnode;
|
|
279
|
+
};
|
|
221
280
|
/**
|
|
222
281
|
* Production setAccessor() function based on Preact by
|
|
223
282
|
* Jason Miller (@developit)
|
|
@@ -237,6 +296,8 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
237
296
|
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
238
297
|
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
239
298
|
}
|
|
299
|
+
else if (memberName === 'key')
|
|
300
|
+
;
|
|
240
301
|
else if (memberName === 'ref') {
|
|
241
302
|
// minifier will clean this up
|
|
242
303
|
if (newValue) {
|
|
@@ -349,13 +410,36 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
349
410
|
let i = 0;
|
|
350
411
|
let elm;
|
|
351
412
|
let childNode;
|
|
413
|
+
let oldVNode;
|
|
414
|
+
if (!useNativeShadowDom) {
|
|
415
|
+
// remember for later we need to check to relocate nodes
|
|
416
|
+
checkSlotRelocate = true;
|
|
417
|
+
if (newVNode.$tag$ === 'slot') {
|
|
418
|
+
if (scopeId) {
|
|
419
|
+
// scoped css needs to add its scoped id to the parent element
|
|
420
|
+
parentElm.classList.add(scopeId + '-s');
|
|
421
|
+
}
|
|
422
|
+
newVNode.$flags$ |= newVNode.$children$
|
|
423
|
+
? // slot element has fallback content
|
|
424
|
+
2 /* isSlotFallback */
|
|
425
|
+
: // slot element does not have fallback content
|
|
426
|
+
1 /* isSlotReference */;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
352
429
|
if (newVNode.$text$ !== null) {
|
|
353
430
|
// create text node
|
|
354
431
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
355
432
|
}
|
|
433
|
+
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
434
|
+
// create a slot reference node
|
|
435
|
+
elm = newVNode.$elm$ =
|
|
436
|
+
doc.createTextNode('');
|
|
437
|
+
}
|
|
356
438
|
else {
|
|
357
439
|
// create element
|
|
358
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$
|
|
440
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */
|
|
441
|
+
? 'slot-fb'
|
|
442
|
+
: newVNode.$tag$));
|
|
359
443
|
// add css classes, attrs, props, listeners, etc.
|
|
360
444
|
{
|
|
361
445
|
updateElement(null, newVNode, isSvgMode);
|
|
@@ -368,7 +452,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
368
452
|
if (newVNode.$children$) {
|
|
369
453
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
370
454
|
// create the node
|
|
371
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
|
455
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
372
456
|
// return node could have been null
|
|
373
457
|
if (childNode) {
|
|
374
458
|
// append our new node
|
|
@@ -377,20 +461,62 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
377
461
|
}
|
|
378
462
|
}
|
|
379
463
|
}
|
|
464
|
+
{
|
|
465
|
+
elm['s-hn'] = hostTagName;
|
|
466
|
+
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
467
|
+
// remember the content reference comment
|
|
468
|
+
elm['s-sr'] = true;
|
|
469
|
+
// remember the content reference comment
|
|
470
|
+
elm['s-cr'] = contentRef;
|
|
471
|
+
// remember the slot name, or empty string for default slot
|
|
472
|
+
elm['s-sn'] = newVNode.$name$ || '';
|
|
473
|
+
// check if we've got an old vnode for this slot
|
|
474
|
+
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
475
|
+
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
476
|
+
// we've got an old slot vnode and the wrapper is being replaced
|
|
477
|
+
// so let's move the old slot content back to it's original location
|
|
478
|
+
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
380
482
|
return elm;
|
|
381
483
|
};
|
|
484
|
+
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
485
|
+
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
486
|
+
const oldSlotChildNodes = parentElm.childNodes;
|
|
487
|
+
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
488
|
+
const childNode = oldSlotChildNodes[i];
|
|
489
|
+
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
490
|
+
// // this child node in the old element is from another component
|
|
491
|
+
// // remove this node from the old slot's parent
|
|
492
|
+
// childNode.remove();
|
|
493
|
+
// and relocate it back to it's original location
|
|
494
|
+
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
495
|
+
// remove the old original location comment entirely
|
|
496
|
+
// later on the patch function will know what to do
|
|
497
|
+
// and move this to the correct spot in need be
|
|
498
|
+
childNode['s-ol'].remove();
|
|
499
|
+
childNode['s-ol'] = undefined;
|
|
500
|
+
checkSlotRelocate = true;
|
|
501
|
+
}
|
|
502
|
+
if (recursive) {
|
|
503
|
+
putBackInOriginalLocation(childNode, recursive);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
507
|
+
};
|
|
382
508
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
383
|
-
let containerElm = (parentElm);
|
|
509
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
384
510
|
let childNode;
|
|
385
511
|
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
386
512
|
containerElm = containerElm.shadowRoot;
|
|
387
513
|
}
|
|
388
514
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
389
515
|
if (vnodes[startIdx]) {
|
|
390
|
-
childNode = createElm(null, parentVNode, startIdx);
|
|
516
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
391
517
|
if (childNode) {
|
|
392
518
|
vnodes[startIdx].$elm$ = childNode;
|
|
393
|
-
containerElm.insertBefore(childNode, before);
|
|
519
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
394
520
|
}
|
|
395
521
|
}
|
|
396
522
|
}
|
|
@@ -400,6 +526,20 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
400
526
|
if ((vnode = vnodes[startIdx])) {
|
|
401
527
|
elm = vnode.$elm$;
|
|
402
528
|
callNodeRefs(vnode);
|
|
529
|
+
{
|
|
530
|
+
// we're removing this element
|
|
531
|
+
// so it's possible we need to show slot fallback content now
|
|
532
|
+
checkSlotFallbackVisibility = true;
|
|
533
|
+
if (elm['s-ol']) {
|
|
534
|
+
// remove the original location comment
|
|
535
|
+
elm['s-ol'].remove();
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
// it's possible that child nodes of the node
|
|
539
|
+
// that's being removed are slot nodes
|
|
540
|
+
putBackInOriginalLocation(elm, true);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
403
543
|
// remove the vnode's element from the dom
|
|
404
544
|
elm.remove();
|
|
405
545
|
}
|
|
@@ -408,6 +548,8 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
408
548
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
409
549
|
let oldStartIdx = 0;
|
|
410
550
|
let newStartIdx = 0;
|
|
551
|
+
let idxInOld = 0;
|
|
552
|
+
let i = 0;
|
|
411
553
|
let oldEndIdx = oldCh.length - 1;
|
|
412
554
|
let oldStartVnode = oldCh[0];
|
|
413
555
|
let oldEndVnode = oldCh[oldEndIdx];
|
|
@@ -415,6 +557,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
415
557
|
let newStartVnode = newCh[0];
|
|
416
558
|
let newEndVnode = newCh[newEndIdx];
|
|
417
559
|
let node;
|
|
560
|
+
let elmToMove;
|
|
418
561
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
419
562
|
if (oldStartVnode == null) {
|
|
420
563
|
// Vnode might have been moved left
|
|
@@ -440,26 +583,56 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
440
583
|
newEndVnode = newCh[--newEndIdx];
|
|
441
584
|
}
|
|
442
585
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
586
|
+
// Vnode moved right
|
|
587
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
588
|
+
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
589
|
+
}
|
|
443
590
|
patch(oldStartVnode, newEndVnode);
|
|
444
591
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
445
592
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
446
593
|
newEndVnode = newCh[--newEndIdx];
|
|
447
594
|
}
|
|
448
595
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
596
|
+
// Vnode moved left
|
|
597
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
598
|
+
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
599
|
+
}
|
|
449
600
|
patch(oldEndVnode, newStartVnode);
|
|
450
601
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
451
602
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
452
603
|
newStartVnode = newCh[++newStartIdx];
|
|
453
604
|
}
|
|
454
605
|
else {
|
|
606
|
+
// createKeyToOldIdx
|
|
607
|
+
idxInOld = -1;
|
|
455
608
|
{
|
|
609
|
+
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
610
|
+
if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
|
|
611
|
+
idxInOld = i;
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (idxInOld >= 0) {
|
|
617
|
+
elmToMove = oldCh[idxInOld];
|
|
618
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
619
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
|
620
|
+
}
|
|
621
|
+
else {
|
|
622
|
+
patch(elmToMove, newStartVnode);
|
|
623
|
+
oldCh[idxInOld] = undefined;
|
|
624
|
+
node = elmToMove.$elm$;
|
|
625
|
+
}
|
|
626
|
+
newStartVnode = newCh[++newStartIdx];
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
456
629
|
// new element
|
|
457
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
630
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
458
631
|
newStartVnode = newCh[++newStartIdx];
|
|
459
632
|
}
|
|
460
633
|
if (node) {
|
|
461
634
|
{
|
|
462
|
-
oldStartVnode.$elm
|
|
635
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
463
636
|
}
|
|
464
637
|
}
|
|
465
638
|
}
|
|
@@ -475,19 +648,36 @@ const isSameVnode = (vnode1, vnode2) => {
|
|
|
475
648
|
// compare if two vnode to see if they're "technically" the same
|
|
476
649
|
// need to have the same element tag, and same key to be the same
|
|
477
650
|
if (vnode1.$tag$ === vnode2.$tag$) {
|
|
478
|
-
|
|
651
|
+
if (vnode1.$tag$ === 'slot') {
|
|
652
|
+
return vnode1.$name$ === vnode2.$name$;
|
|
653
|
+
}
|
|
654
|
+
{
|
|
655
|
+
return vnode1.$key$ === vnode2.$key$;
|
|
656
|
+
}
|
|
479
657
|
}
|
|
480
658
|
return false;
|
|
481
659
|
};
|
|
660
|
+
const referenceNode = (node) => {
|
|
661
|
+
// this node was relocated to a new location in the dom
|
|
662
|
+
// because of some other component's slot
|
|
663
|
+
// but we still have an html comment in place of where
|
|
664
|
+
// it's original location was according to it's original vdom
|
|
665
|
+
return (node && node['s-ol']) || node;
|
|
666
|
+
};
|
|
667
|
+
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
482
668
|
const patch = (oldVNode, newVNode) => {
|
|
483
669
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
484
670
|
const oldChildren = oldVNode.$children$;
|
|
485
671
|
const newChildren = newVNode.$children$;
|
|
672
|
+
const tag = newVNode.$tag$;
|
|
486
673
|
const text = newVNode.$text$;
|
|
674
|
+
let defaultHolder;
|
|
487
675
|
if (text === null) {
|
|
488
676
|
// element node
|
|
489
677
|
{
|
|
490
|
-
|
|
678
|
+
if (tag === 'slot')
|
|
679
|
+
;
|
|
680
|
+
else {
|
|
491
681
|
// either this is the first render of an element OR it's an update
|
|
492
682
|
// AND we already know it's possible it could have changed
|
|
493
683
|
// this updates the element's css classes, attrs, props, listeners, etc.
|
|
@@ -512,12 +702,147 @@ const patch = (oldVNode, newVNode) => {
|
|
|
512
702
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
513
703
|
}
|
|
514
704
|
}
|
|
705
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
706
|
+
// this element has slotted content
|
|
707
|
+
defaultHolder.parentNode.textContent = text;
|
|
708
|
+
}
|
|
515
709
|
else if (oldVNode.$text$ !== text) {
|
|
516
710
|
// update the text content for the text only vnode
|
|
517
711
|
// and also only if the text is different than before
|
|
518
712
|
elm.data = text;
|
|
519
713
|
}
|
|
520
714
|
};
|
|
715
|
+
const updateFallbackSlotVisibility = (elm) => {
|
|
716
|
+
// tslint:disable-next-line: prefer-const
|
|
717
|
+
const childNodes = elm.childNodes;
|
|
718
|
+
let childNode;
|
|
719
|
+
let i;
|
|
720
|
+
let ilen;
|
|
721
|
+
let j;
|
|
722
|
+
let slotNameAttr;
|
|
723
|
+
let nodeType;
|
|
724
|
+
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
725
|
+
childNode = childNodes[i];
|
|
726
|
+
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
727
|
+
if (childNode['s-sr']) {
|
|
728
|
+
// this is a slot fallback node
|
|
729
|
+
// get the slot name for this slot reference node
|
|
730
|
+
slotNameAttr = childNode['s-sn'];
|
|
731
|
+
// by default always show a fallback slot node
|
|
732
|
+
// then hide it if there are other slots in the light dom
|
|
733
|
+
childNode.hidden = false;
|
|
734
|
+
for (j = 0; j < ilen; j++) {
|
|
735
|
+
nodeType = childNodes[j].nodeType;
|
|
736
|
+
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
737
|
+
// this sibling node is from a different component OR is a named fallback slot node
|
|
738
|
+
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
739
|
+
childNode.hidden = true;
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
// this is a default fallback slot node
|
|
745
|
+
// any element or text node (with content)
|
|
746
|
+
// should hide the default fallback slot node
|
|
747
|
+
if (nodeType === 1 /* ElementNode */ ||
|
|
748
|
+
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
749
|
+
childNode.hidden = true;
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
// keep drilling down
|
|
756
|
+
updateFallbackSlotVisibility(childNode);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
const relocateNodes = [];
|
|
761
|
+
const relocateSlotContent = (elm) => {
|
|
762
|
+
// tslint:disable-next-line: prefer-const
|
|
763
|
+
let childNode;
|
|
764
|
+
let node;
|
|
765
|
+
let hostContentNodes;
|
|
766
|
+
let slotNameAttr;
|
|
767
|
+
let relocateNodeData;
|
|
768
|
+
let j;
|
|
769
|
+
let i = 0;
|
|
770
|
+
const childNodes = elm.childNodes;
|
|
771
|
+
const ilen = childNodes.length;
|
|
772
|
+
for (; i < ilen; i++) {
|
|
773
|
+
childNode = childNodes[i];
|
|
774
|
+
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
775
|
+
// first got the content reference comment node
|
|
776
|
+
// then we got it's parent, which is where all the host content is in now
|
|
777
|
+
hostContentNodes = node.parentNode.childNodes;
|
|
778
|
+
slotNameAttr = childNode['s-sn'];
|
|
779
|
+
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
780
|
+
node = hostContentNodes[j];
|
|
781
|
+
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
782
|
+
// let's do some relocating to its new home
|
|
783
|
+
// but never relocate a content reference node
|
|
784
|
+
// that is suppose to always represent the original content location
|
|
785
|
+
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
786
|
+
// it's possible we've already decided to relocate this node
|
|
787
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
788
|
+
// made some changes to slots
|
|
789
|
+
// let's make sure we also double check
|
|
790
|
+
// fallbacks are correctly hidden or shown
|
|
791
|
+
checkSlotFallbackVisibility = true;
|
|
792
|
+
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
793
|
+
if (relocateNodeData) {
|
|
794
|
+
// previously we never found a slot home for this node
|
|
795
|
+
// but turns out we did, so let's remember it now
|
|
796
|
+
relocateNodeData.$slotRefNode$ = childNode;
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
// add to our list of nodes to relocate
|
|
800
|
+
relocateNodes.push({
|
|
801
|
+
$slotRefNode$: childNode,
|
|
802
|
+
$nodeToRelocate$: node,
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
if (node['s-sr']) {
|
|
806
|
+
relocateNodes.map((relocateNode) => {
|
|
807
|
+
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
808
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
809
|
+
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
810
|
+
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
817
|
+
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
818
|
+
// if we never find a home for this element then we'll need to hide it
|
|
819
|
+
relocateNodes.push({
|
|
820
|
+
$nodeToRelocate$: node,
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
827
|
+
relocateSlotContent(childNode);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
832
|
+
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
833
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
834
|
+
return true;
|
|
835
|
+
}
|
|
836
|
+
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
837
|
+
return true;
|
|
838
|
+
}
|
|
839
|
+
return false;
|
|
840
|
+
}
|
|
841
|
+
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
842
|
+
return true;
|
|
843
|
+
}
|
|
844
|
+
return slotNameAttr === '';
|
|
845
|
+
};
|
|
521
846
|
const callNodeRefs = (vNode) => {
|
|
522
847
|
{
|
|
523
848
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
@@ -526,6 +851,7 @@ const callNodeRefs = (vNode) => {
|
|
|
526
851
|
};
|
|
527
852
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
528
853
|
const hostElm = hostRef.$hostElement$;
|
|
854
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
529
855
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
530
856
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
531
857
|
hostTagName = hostElm.tagName;
|
|
@@ -536,8 +862,90 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
536
862
|
{
|
|
537
863
|
scopeId = hostElm['s-sc'];
|
|
538
864
|
}
|
|
865
|
+
{
|
|
866
|
+
contentRef = hostElm['s-cr'];
|
|
867
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
868
|
+
// always reset
|
|
869
|
+
checkSlotFallbackVisibility = false;
|
|
870
|
+
}
|
|
539
871
|
// synchronous patch
|
|
540
872
|
patch(oldVNode, rootVnode);
|
|
873
|
+
{
|
|
874
|
+
// while we're moving nodes around existing nodes, temporarily disable
|
|
875
|
+
// the disconnectCallback from working
|
|
876
|
+
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
877
|
+
if (checkSlotRelocate) {
|
|
878
|
+
relocateSlotContent(rootVnode.$elm$);
|
|
879
|
+
let relocateData;
|
|
880
|
+
let nodeToRelocate;
|
|
881
|
+
let orgLocationNode;
|
|
882
|
+
let parentNodeRef;
|
|
883
|
+
let insertBeforeNode;
|
|
884
|
+
let refNode;
|
|
885
|
+
let i = 0;
|
|
886
|
+
for (; i < relocateNodes.length; i++) {
|
|
887
|
+
relocateData = relocateNodes[i];
|
|
888
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
889
|
+
if (!nodeToRelocate['s-ol']) {
|
|
890
|
+
// add a reference node marking this node's original location
|
|
891
|
+
// keep a reference to this node for later lookups
|
|
892
|
+
orgLocationNode =
|
|
893
|
+
doc.createTextNode('');
|
|
894
|
+
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
895
|
+
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
for (i = 0; i < relocateNodes.length; i++) {
|
|
899
|
+
relocateData = relocateNodes[i];
|
|
900
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
901
|
+
if (relocateData.$slotRefNode$) {
|
|
902
|
+
// by default we're just going to insert it directly
|
|
903
|
+
// after the slot reference node
|
|
904
|
+
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
905
|
+
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
906
|
+
orgLocationNode = nodeToRelocate['s-ol'];
|
|
907
|
+
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
908
|
+
refNode = orgLocationNode['s-nr'];
|
|
909
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
910
|
+
refNode = refNode.nextSibling;
|
|
911
|
+
if (!refNode || !refNode['s-nr']) {
|
|
912
|
+
insertBeforeNode = refNode;
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
918
|
+
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
919
|
+
// we've checked that it's worth while to relocate
|
|
920
|
+
// since that the node to relocate
|
|
921
|
+
// has a different next sibling or parent relocated
|
|
922
|
+
if (nodeToRelocate !== insertBeforeNode) {
|
|
923
|
+
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
924
|
+
// probably a component in the index.html that doesn't have it's hostname set
|
|
925
|
+
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
926
|
+
}
|
|
927
|
+
// add it back to the dom but in its new home
|
|
928
|
+
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
else {
|
|
933
|
+
// this node doesn't have a slot home to go to, so let's hide it
|
|
934
|
+
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
935
|
+
nodeToRelocate.hidden = true;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
if (checkSlotFallbackVisibility) {
|
|
941
|
+
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
942
|
+
}
|
|
943
|
+
// done moving nodes around
|
|
944
|
+
// allow the disconnect callback to work again
|
|
945
|
+
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
946
|
+
// always reset
|
|
947
|
+
relocateNodes.length = 0;
|
|
948
|
+
}
|
|
541
949
|
};
|
|
542
950
|
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
543
951
|
const createEvent = (ref, name, flags) => {
|
|
@@ -594,6 +1002,9 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
594
1002
|
promise = safeCall(instance, 'componentWillLoad');
|
|
595
1003
|
}
|
|
596
1004
|
}
|
|
1005
|
+
{
|
|
1006
|
+
promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
|
1007
|
+
}
|
|
597
1008
|
endSchedule();
|
|
598
1009
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
599
1010
|
};
|
|
@@ -663,6 +1074,9 @@ const postUpdateComponent = (hostRef) => {
|
|
|
663
1074
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
664
1075
|
const instance = hostRef.$lazyInstance$ ;
|
|
665
1076
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1077
|
+
{
|
|
1078
|
+
safeCall(instance, 'componentDidRender');
|
|
1079
|
+
}
|
|
666
1080
|
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
667
1081
|
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
668
1082
|
{
|
|
@@ -752,6 +1166,15 @@ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
|
752
1166
|
const parsePropertyValue = (propValue, propType) => {
|
|
753
1167
|
// ensure this value is of the correct prop type
|
|
754
1168
|
if (propValue != null && !isComplexType(propValue)) {
|
|
1169
|
+
if (propType & 4 /* Boolean */) {
|
|
1170
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
1171
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1172
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1173
|
+
}
|
|
1174
|
+
if (propType & 2 /* Number */) {
|
|
1175
|
+
// force it to be a number
|
|
1176
|
+
return parseFloat(propValue);
|
|
1177
|
+
}
|
|
755
1178
|
if (propType & 1 /* String */) {
|
|
756
1179
|
// could have been passed as a number or boolean
|
|
757
1180
|
// but we still want it as a string
|
|
@@ -1001,6 +1424,15 @@ const connectedCallback = (elm) => {
|
|
|
1001
1424
|
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1002
1425
|
// first time this component has connected
|
|
1003
1426
|
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1427
|
+
{
|
|
1428
|
+
// initUpdate
|
|
1429
|
+
// if the slot polyfill is required we'll need to put some nodes
|
|
1430
|
+
// in here to act as original content anchors as we move nodes around
|
|
1431
|
+
// host element has been connected to the DOM
|
|
1432
|
+
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1433
|
+
setContentReference(elm);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1004
1436
|
{
|
|
1005
1437
|
// find the first ancestor component (if there is one) and register
|
|
1006
1438
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1038,6 +1470,17 @@ const connectedCallback = (elm) => {
|
|
|
1038
1470
|
endConnected();
|
|
1039
1471
|
}
|
|
1040
1472
|
};
|
|
1473
|
+
const setContentReference = (elm) => {
|
|
1474
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
1475
|
+
// or this browser doesn't support native shadow dom
|
|
1476
|
+
// and this host element was NOT created with SSR
|
|
1477
|
+
// let's pick out the inner content for slot projection
|
|
1478
|
+
// create a node to represent where the original
|
|
1479
|
+
// content was first placed, which is useful later on
|
|
1480
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1481
|
+
contentRefElm['s-cn'] = true;
|
|
1482
|
+
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1483
|
+
};
|
|
1041
1484
|
const disconnectedCallback = (elm) => {
|
|
1042
1485
|
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1043
1486
|
const hostRef = getHostRef(elm);
|
|
@@ -1230,6 +1673,7 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
|
1230
1673
|
exports.Host = Host;
|
|
1231
1674
|
exports.bootstrapLazy = bootstrapLazy;
|
|
1232
1675
|
exports.createEvent = createEvent;
|
|
1676
|
+
exports.getElement = getElement;
|
|
1233
1677
|
exports.h = h;
|
|
1234
1678
|
exports.promiseResolve = promiseResolve;
|
|
1235
1679
|
exports.registerInstance = registerInstance;
|