@mgdis/mg-components 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-88560a66.js → index-64cee0c8.js} +248 -81
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{mg-badge_24.cjs.entry.js → mg-badge_23.cjs.entry.js} +206 -2180
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-modal.cjs.entry.js +8 -1
- package/dist/cjs/mg-popover.cjs.entry.js +171 -0
- package/dist/cjs/popper-71bf3058.js +1790 -0
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +116 -99
- package/dist/collection/components/atoms/mg-button/mg-button.js +221 -220
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +72 -69
- package/dist/collection/components/atoms/mg-icon/doc/mg-icon.stories.js +1 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +102 -92
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +83 -67
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +64 -55
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +3 -6
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +120 -106
- package/dist/collection/components/molecules/inputs/MgInput.js +8 -17
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +323 -318
- package/dist/collection/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.js +3 -2
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +356 -361
- package/dist/collection/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.js +1 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +462 -456
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +347 -340
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +348 -343
- package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +4 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +406 -401
- package/dist/collection/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.js +12 -15
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +2 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +476 -473
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +461 -456
- package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +2 -8
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +299 -298
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +1 -3
- package/dist/collection/components/molecules/mg-details/mg-details.js +95 -93
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +13 -27
- package/dist/collection/components/molecules/mg-form/mg-form.js +175 -166
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +2 -6
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +37 -37
- package/dist/collection/components/molecules/mg-message/doc/mg-message.stories.js +1 -3
- package/dist/collection/components/molecules/mg-message/mg-message.js +154 -153
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +11 -15
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +147 -134
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +5 -6
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +112 -117
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +1 -8
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +2 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +192 -189
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +1 -4
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +129 -127
- package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +1 -5
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +150 -135
- package/dist/collection/fonts/OpenSans-Bold.ttf +0 -0
- package/dist/collection/locales/en/messages.json +50 -0
- package/dist/collection/locales/fr/messages.json +50 -0
- package/dist/collection/stories/grids.stories.js +1 -44
- package/dist/collection/stories/helpers.stories.js +1 -19
- package/dist/collection/stories/icons.stories.js +1 -4
- package/dist/collection/stories/typography.stories.js +1 -12
- package/dist/collection/variables.css +3 -2
- package/dist/collection/variables.scss +3 -2
- package/dist/components/MgInput.js +6 -3
- package/dist/components/mg-badge2.js +7 -0
- package/dist/components/mg-button2.js +2 -7
- package/dist/components/mg-input-checkbox.js +1 -6
- package/dist/components/mg-input-date.js +10 -27
- package/dist/components/mg-input-numeric.js +1 -6
- package/dist/components/mg-input-password.js +1 -6
- package/dist/components/mg-input-radio.js +1 -6
- package/dist/components/mg-input-select2.js +1 -6
- package/dist/components/mg-input-text2.js +3 -8
- package/dist/components/mg-input-textarea.js +2 -7
- package/dist/components/mg-input-title2.js +9 -0
- package/dist/components/mg-input-toggle.js +2 -7
- package/dist/components/mg-modal.js +7 -0
- package/dist/components/mg-pagination.js +3 -3
- package/dist/components/mg-panel.js +8 -4
- package/dist/components/mg-tabs.js +8 -1
- package/dist/components/mg-tooltip2.js +7 -0
- package/dist/esm/{index-bca81100.js → index-120f47fd.js} +248 -81
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{mg-badge_24.entry.js → mg-badge_23.entry.js} +207 -2180
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-modal.entry.js +8 -1
- package/dist/esm/mg-popover.entry.js +167 -0
- package/dist/esm/popper-93ecb064.js +1788 -0
- package/dist/mg-components/fonts/OpenSans-Bold.ttf +0 -0
- package/dist/mg-components/locales/en/messages.json +50 -0
- package/dist/mg-components/locales/fr/messages.json +50 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-21991be8.entry.js +1 -0
- package/dist/mg-components/p-36a64f8c.entry.js +1 -0
- package/dist/mg-components/p-4c66f794.js +1 -0
- package/dist/mg-components/{p-b14a3443.js → p-7bc32a2f.js} +0 -0
- package/dist/mg-components/p-b380a0df.entry.js +1 -0
- package/dist/mg-components/variables.css +3 -2
- package/dist/mg-components/variables.scss +3 -2
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +1 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +0 -1
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +1 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +0 -1
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +1 -10
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +0 -1
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +0 -1
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +0 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +0 -1
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +0 -1
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +0 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +0 -1
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +1 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +1 -1
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +1 -0
- package/dist/types/components.d.ts +29 -29
- package/loader/package.json +1 -0
- package/package.json +8 -8
- package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
- package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
- package/dist/mg-components/p-a2883dc7.entry.js +0 -1
- package/dist/mg-components/p-cffe0519.entry.js +0 -1
|
@@ -43,7 +43,7 @@ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =
|
|
|
43
43
|
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
44
44
|
try {
|
|
45
45
|
{
|
|
46
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
46
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
47
47
|
// instance is ready, let's call it's member method for this event
|
|
48
48
|
hostRef.$lazyInstance$[methodName](ev);
|
|
49
49
|
}
|
|
@@ -57,12 +57,12 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
const getHostListenerTarget = (elm, flags) => {
|
|
60
|
-
if (flags & 8 /* TargetWindow */)
|
|
60
|
+
if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
|
|
61
61
|
return win;
|
|
62
62
|
return elm;
|
|
63
63
|
};
|
|
64
64
|
// prettier-ignore
|
|
65
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
65
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
66
66
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
67
67
|
const createTime = (fnName, tagName = '') => {
|
|
68
68
|
{
|
|
@@ -78,7 +78,7 @@ const uniqueTime = (key, measureText) => {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
-
const rootAppliedStyles = new WeakMap();
|
|
81
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
82
82
|
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
83
83
|
let style = styles.get(scopeId);
|
|
84
84
|
if (supportsConstructableStylesheets && allowCS) {
|
|
@@ -100,7 +100,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
100
100
|
const style = styles.get(scopeId);
|
|
101
101
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
102
102
|
// so the fallback is to always use the document for the root node in those cases
|
|
103
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
103
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
104
104
|
if (style) {
|
|
105
105
|
if (typeof style === 'string') {
|
|
106
106
|
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
@@ -134,7 +134,7 @@ const attachStyles = (hostRef) => {
|
|
|
134
134
|
const flags = cmpMeta.$flags$;
|
|
135
135
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
136
136
|
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
137
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
137
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
138
138
|
// only required when we're NOT using native shadow dom (slot)
|
|
139
139
|
// or this browser doesn't support native shadow dom
|
|
140
140
|
// and this host element was NOT created with SSR
|
|
@@ -144,7 +144,7 @@ const attachStyles = (hostRef) => {
|
|
|
144
144
|
// DOM WRITE!!
|
|
145
145
|
elm['s-sc'] = scopeId;
|
|
146
146
|
elm.classList.add(scopeId + '-h');
|
|
147
|
-
if (flags & 2 /* scopedCssEncapsulation */) {
|
|
147
|
+
if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
148
148
|
elm.classList.add(scopeId + '-s');
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -405,7 +405,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
408
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
409
409
|
newValue = newValue === true ? '' : newValue;
|
|
410
410
|
{
|
|
411
411
|
elm.setAttribute(memberName, newValue);
|
|
@@ -420,7 +420,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
420
420
|
// if the element passed in is a shadow root, which is a document fragment
|
|
421
421
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
422
422
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
423
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
423
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
424
424
|
? newVnode.$elm$.host
|
|
425
425
|
: newVnode.$elm$;
|
|
426
426
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -438,6 +438,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
438
438
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
439
439
|
}
|
|
440
440
|
};
|
|
441
|
+
/**
|
|
442
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
443
|
+
*
|
|
444
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
445
|
+
* @param newParentVNode the parent VNode from the current render
|
|
446
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
447
|
+
* children, for which we will create a new DOM node
|
|
448
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
449
|
+
* @returns the newly created node
|
|
450
|
+
*/
|
|
441
451
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
442
452
|
// tslint:disable-next-line: prefer-const
|
|
443
453
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -455,16 +465,16 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
455
465
|
}
|
|
456
466
|
newVNode.$flags$ |= newVNode.$children$
|
|
457
467
|
? // slot element has fallback content
|
|
458
|
-
2 /* isSlotFallback */
|
|
468
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
459
469
|
: // slot element does not have fallback content
|
|
460
|
-
1 /* isSlotReference */;
|
|
470
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
461
471
|
}
|
|
462
472
|
}
|
|
463
473
|
if (newVNode.$text$ !== null) {
|
|
464
474
|
// create text node
|
|
465
475
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
466
476
|
}
|
|
467
|
-
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
477
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
468
478
|
// create a slot reference node
|
|
469
479
|
elm = newVNode.$elm$ =
|
|
470
480
|
doc.createTextNode('');
|
|
@@ -474,7 +484,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
474
484
|
isSvgMode = newVNode.$tag$ === 'svg';
|
|
475
485
|
}
|
|
476
486
|
// create element
|
|
477
|
-
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
|
|
487
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
478
488
|
? 'slot-fb'
|
|
479
489
|
: newVNode.$tag$)
|
|
480
490
|
);
|
|
@@ -514,7 +524,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
514
524
|
}
|
|
515
525
|
{
|
|
516
526
|
elm['s-hn'] = hostTagName;
|
|
517
|
-
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
527
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
518
528
|
// remember the content reference comment
|
|
519
529
|
elm['s-sr'] = true;
|
|
520
530
|
// remember the content reference comment
|
|
@@ -533,7 +543,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
533
543
|
return elm;
|
|
534
544
|
};
|
|
535
545
|
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
536
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
546
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
537
547
|
const oldSlotChildNodes = parentElm.childNodes;
|
|
538
548
|
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
539
549
|
const childNode = oldSlotChildNodes[i];
|
|
@@ -554,7 +564,7 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
|
554
564
|
putBackInOriginalLocation(childNode, recursive);
|
|
555
565
|
}
|
|
556
566
|
}
|
|
557
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
567
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
558
568
|
};
|
|
559
569
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
560
570
|
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
@@ -596,6 +606,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
596
606
|
}
|
|
597
607
|
}
|
|
598
608
|
};
|
|
609
|
+
/**
|
|
610
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
611
|
+
* traversing the two collections of children, identifying nodes that are
|
|
612
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
613
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
614
|
+
*
|
|
615
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
616
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
617
|
+
* 'windows' by storing start and end indices and references to the
|
|
618
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
619
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
620
|
+
* no children left to update by doing the following:
|
|
621
|
+
*
|
|
622
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
623
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
624
|
+
* only with a window bounded by the highlighted elements:
|
|
625
|
+
*
|
|
626
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
627
|
+
* ^^^^^^ ^^^^^^
|
|
628
|
+
*
|
|
629
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
630
|
+
* across the windows. This will basically detect elements which haven't
|
|
631
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
632
|
+
* VNode elements (represented as HTML):
|
|
633
|
+
*
|
|
634
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
635
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
636
|
+
*
|
|
637
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
638
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
639
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
640
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
641
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
642
|
+
*
|
|
643
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
644
|
+
* window corresponds to the element at the end of the other window. This is
|
|
645
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
646
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
647
|
+
* children nodes themselves have not changed but merely moved in the
|
|
648
|
+
* following example:
|
|
649
|
+
*
|
|
650
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
651
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
652
|
+
*
|
|
653
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
654
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
655
|
+
* DOM.
|
|
656
|
+
*
|
|
657
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
658
|
+
* nodes in the old children which have the same key as the first element in
|
|
659
|
+
* our window on the new children. If we find such a node we handle calling
|
|
660
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
661
|
+
* what we find.
|
|
662
|
+
*
|
|
663
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
664
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
665
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
666
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
667
|
+
* children has collapsed we still have more nodes on the new children that
|
|
668
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
669
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
670
|
+
* sure the corresponding DOM nodes are removed.
|
|
671
|
+
*
|
|
672
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
673
|
+
* @param oldCh the old children of the parent node
|
|
674
|
+
* @param newVNode the new VNode which will replace the parent
|
|
675
|
+
* @param newCh the new children of the parent node
|
|
676
|
+
*/
|
|
599
677
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
600
678
|
let oldStartIdx = 0;
|
|
601
679
|
let newStartIdx = 0;
|
|
@@ -608,7 +686,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
608
686
|
let node;
|
|
609
687
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
610
688
|
if (oldStartVnode == null) {
|
|
611
|
-
//
|
|
689
|
+
// VNode might have been moved left
|
|
612
690
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
613
691
|
}
|
|
614
692
|
else if (oldEndVnode == null) {
|
|
@@ -621,42 +699,102 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
621
699
|
newEndVnode = newCh[--newEndIdx];
|
|
622
700
|
}
|
|
623
701
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
702
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
703
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
704
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
705
|
+
// since things are matched up in order.
|
|
624
706
|
patch(oldStartVnode, newStartVnode);
|
|
625
707
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
626
708
|
newStartVnode = newCh[++newStartIdx];
|
|
627
709
|
}
|
|
628
710
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
711
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
712
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
713
|
+
// need to move any DOM Nodes.
|
|
629
714
|
patch(oldEndVnode, newEndVnode);
|
|
630
715
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
631
716
|
newEndVnode = newCh[--newEndIdx];
|
|
632
717
|
}
|
|
633
718
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
634
|
-
// Vnode moved right
|
|
719
|
+
// case: "Vnode moved right"
|
|
720
|
+
//
|
|
721
|
+
// We've found that the last node in our window on the new children is
|
|
722
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
723
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
724
|
+
// nodes:
|
|
725
|
+
//
|
|
726
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
727
|
+
// ^^^^^^^^^^^
|
|
728
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
729
|
+
// ^^^^^^^^^^^^^
|
|
730
|
+
//
|
|
731
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
732
|
+
// and move the DOM element for `oldStartVnode`.
|
|
635
733
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
636
734
|
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
637
735
|
}
|
|
638
736
|
patch(oldStartVnode, newEndVnode);
|
|
737
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
738
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
739
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
740
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
741
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
742
|
+
//
|
|
743
|
+
// <old-start-node />
|
|
744
|
+
// <some-intervening-node />
|
|
745
|
+
// <old-end-node />
|
|
746
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
747
|
+
// <next-sibling />
|
|
748
|
+
//
|
|
749
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
750
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
751
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
752
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
753
|
+
// append it to the children of the parent element.
|
|
639
754
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
640
755
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
641
756
|
newEndVnode = newCh[--newEndIdx];
|
|
642
757
|
}
|
|
643
758
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
644
|
-
// Vnode moved left
|
|
759
|
+
// case: "Vnode moved left"
|
|
760
|
+
//
|
|
761
|
+
// We've found that the first node in our window on the new children is
|
|
762
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
763
|
+
// Visually, this is the layout of these two nodes:
|
|
764
|
+
//
|
|
765
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
766
|
+
// ^^^^^^^^^^^^^
|
|
767
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
768
|
+
// ^^^^^^^^^^^
|
|
769
|
+
//
|
|
770
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
771
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
772
|
+
// children etc) but we also need to move the DOM node to which
|
|
773
|
+
// `oldEndVnode` corresponds.
|
|
645
774
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
646
775
|
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
647
776
|
}
|
|
648
777
|
patch(oldEndVnode, newStartVnode);
|
|
778
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
779
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
780
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
781
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
782
|
+
// future.
|
|
649
783
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
650
784
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
651
785
|
newStartVnode = newCh[++newStartIdx];
|
|
652
786
|
}
|
|
653
787
|
else {
|
|
654
788
|
{
|
|
655
|
-
//
|
|
789
|
+
// We either didn't find an element in the old children that matches
|
|
790
|
+
// the key of the first new child OR the build is not using `key`
|
|
791
|
+
// attributes at all. In either case we need to create a new element
|
|
792
|
+
// for the new node.
|
|
656
793
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
657
794
|
newStartVnode = newCh[++newStartIdx];
|
|
658
795
|
}
|
|
659
796
|
if (node) {
|
|
797
|
+
// if we created a new node then handle inserting it to the DOM
|
|
660
798
|
{
|
|
661
799
|
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
662
800
|
}
|
|
@@ -664,18 +802,39 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
664
802
|
}
|
|
665
803
|
}
|
|
666
804
|
if (oldStartIdx > oldEndIdx) {
|
|
805
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
667
806
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
668
807
|
}
|
|
669
808
|
else if (newStartIdx > newEndIdx) {
|
|
809
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
810
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
811
|
+
// relevant DOM nodes)
|
|
670
812
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
671
813
|
}
|
|
672
814
|
};
|
|
673
|
-
|
|
815
|
+
/**
|
|
816
|
+
* Compare two VNodes to determine if they are the same
|
|
817
|
+
*
|
|
818
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
819
|
+
* information set on the two VNodes and can be misleading under certain
|
|
820
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
821
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
822
|
+
* checking that they have the same tag.
|
|
823
|
+
*
|
|
824
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
825
|
+
* changing order within a `children` array or something along those lines then
|
|
826
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
827
|
+
*
|
|
828
|
+
* @param leftVNode the first VNode to check
|
|
829
|
+
* @param rightVNode the second VNode to check
|
|
830
|
+
* @returns whether they're equal or not
|
|
831
|
+
*/
|
|
832
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
674
833
|
// compare if two vnode to see if they're "technically" the same
|
|
675
834
|
// need to have the same element tag, and same key to be the same
|
|
676
|
-
if (
|
|
677
|
-
if (
|
|
678
|
-
return
|
|
835
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
836
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
837
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
679
838
|
}
|
|
680
839
|
return true;
|
|
681
840
|
}
|
|
@@ -689,6 +848,14 @@ const referenceNode = (node) => {
|
|
|
689
848
|
return (node && node['s-ol']) || node;
|
|
690
849
|
};
|
|
691
850
|
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
851
|
+
/**
|
|
852
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
853
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
854
|
+
* children of the two nodes (if any).
|
|
855
|
+
*
|
|
856
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
857
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
858
|
+
*/
|
|
692
859
|
const patch = (oldVNode, newVNode) => {
|
|
693
860
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
694
861
|
const oldChildren = oldVNode.$children$;
|
|
@@ -702,7 +869,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
702
869
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
703
870
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
704
871
|
}
|
|
705
|
-
// element node
|
|
706
872
|
{
|
|
707
873
|
if (tag === 'slot')
|
|
708
874
|
;
|
|
@@ -715,6 +881,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
715
881
|
}
|
|
716
882
|
if (oldChildren !== null && newChildren !== null) {
|
|
717
883
|
// looks like there's child vnodes for both the old and new vnodes
|
|
884
|
+
// so we need to call `updateChildren` to reconcile them
|
|
718
885
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
719
886
|
}
|
|
720
887
|
else if (newChildren !== null) {
|
|
@@ -755,7 +922,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
755
922
|
let nodeType;
|
|
756
923
|
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
757
924
|
childNode = childNodes[i];
|
|
758
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
925
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
759
926
|
if (childNode['s-sr']) {
|
|
760
927
|
// this is a slot fallback node
|
|
761
928
|
// get the slot name for this slot reference node
|
|
@@ -767,7 +934,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
767
934
|
nodeType = childNodes[j].nodeType;
|
|
768
935
|
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
769
936
|
// this sibling node is from a different component OR is a named fallback slot node
|
|
770
|
-
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
937
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
771
938
|
childNode.hidden = true;
|
|
772
939
|
break;
|
|
773
940
|
}
|
|
@@ -776,8 +943,8 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
776
943
|
// this is a default fallback slot node
|
|
777
944
|
// any element or text node (with content)
|
|
778
945
|
// should hide the default fallback slot node
|
|
779
|
-
if (nodeType === 1 /* ElementNode */ ||
|
|
780
|
-
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
946
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
947
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
781
948
|
childNode.hidden = true;
|
|
782
949
|
break;
|
|
783
950
|
}
|
|
@@ -855,13 +1022,13 @@ const relocateSlotContent = (elm) => {
|
|
|
855
1022
|
}
|
|
856
1023
|
}
|
|
857
1024
|
}
|
|
858
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1025
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
859
1026
|
relocateSlotContent(childNode);
|
|
860
1027
|
}
|
|
861
1028
|
}
|
|
862
1029
|
};
|
|
863
1030
|
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
864
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1031
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
865
1032
|
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
866
1033
|
return true;
|
|
867
1034
|
}
|
|
@@ -892,7 +1059,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
892
1059
|
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
893
1060
|
}
|
|
894
1061
|
rootVnode.$tag$ = null;
|
|
895
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1062
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
896
1063
|
hostRef.$vnode$ = rootVnode;
|
|
897
1064
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
898
1065
|
{
|
|
@@ -900,7 +1067,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
900
1067
|
}
|
|
901
1068
|
{
|
|
902
1069
|
contentRef = hostElm['s-cr'];
|
|
903
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
1070
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
904
1071
|
// always reset
|
|
905
1072
|
checkSlotFallbackVisibility = false;
|
|
906
1073
|
}
|
|
@@ -909,7 +1076,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
909
1076
|
{
|
|
910
1077
|
// while we're moving nodes around existing nodes, temporarily disable
|
|
911
1078
|
// the disconnectCallback from working
|
|
912
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
1079
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
913
1080
|
if (checkSlotRelocate) {
|
|
914
1081
|
relocateSlotContent(rootVnode.$elm$);
|
|
915
1082
|
let relocateData;
|
|
@@ -967,7 +1134,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
967
1134
|
}
|
|
968
1135
|
else {
|
|
969
1136
|
// this node doesn't have a slot home to go to, so let's hide it
|
|
970
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1137
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
971
1138
|
nodeToRelocate.hidden = true;
|
|
972
1139
|
}
|
|
973
1140
|
}
|
|
@@ -978,7 +1145,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
978
1145
|
}
|
|
979
1146
|
// done moving nodes around
|
|
980
1147
|
// allow the disconnect callback to work again
|
|
981
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
1148
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
982
1149
|
// always reset
|
|
983
1150
|
relocateNodes.length = 0;
|
|
984
1151
|
}
|
|
@@ -989,9 +1156,9 @@ const createEvent = (ref, name, flags) => {
|
|
|
989
1156
|
return {
|
|
990
1157
|
emit: (detail) => {
|
|
991
1158
|
return emitEvent(elm, name, {
|
|
992
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
993
|
-
composed: !!(flags & 2 /* Composed */),
|
|
994
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
1159
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
1160
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
1161
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
995
1162
|
detail,
|
|
996
1163
|
});
|
|
997
1164
|
},
|
|
@@ -1016,10 +1183,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
1016
1183
|
};
|
|
1017
1184
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
1018
1185
|
{
|
|
1019
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1186
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1020
1187
|
}
|
|
1021
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
1022
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1188
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1189
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
1023
1190
|
return;
|
|
1024
1191
|
}
|
|
1025
1192
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -1035,7 +1202,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1035
1202
|
let promise;
|
|
1036
1203
|
if (isInitialLoad) {
|
|
1037
1204
|
{
|
|
1038
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
1205
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1039
1206
|
if (hostRef.$queuedListeners$) {
|
|
1040
1207
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1041
1208
|
hostRef.$queuedListeners$ = null;
|
|
@@ -1078,7 +1245,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1078
1245
|
}
|
|
1079
1246
|
else {
|
|
1080
1247
|
Promise.all(childrenPromises).then(postUpdate);
|
|
1081
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1248
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
1082
1249
|
childrenPromises.length = 0;
|
|
1083
1250
|
}
|
|
1084
1251
|
}
|
|
@@ -1087,10 +1254,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
1087
1254
|
try {
|
|
1088
1255
|
instance = instance.render() ;
|
|
1089
1256
|
{
|
|
1090
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1257
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1091
1258
|
}
|
|
1092
1259
|
{
|
|
1093
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1260
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
1094
1261
|
}
|
|
1095
1262
|
{
|
|
1096
1263
|
{
|
|
@@ -1117,8 +1284,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1117
1284
|
{
|
|
1118
1285
|
safeCall(instance, 'componentDidRender');
|
|
1119
1286
|
}
|
|
1120
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
1121
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1287
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1288
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
1122
1289
|
{
|
|
1123
1290
|
// DOM WRITE!
|
|
1124
1291
|
addHydratedFlag(elm);
|
|
@@ -1147,10 +1314,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1147
1314
|
hostRef.$onRenderResolve$();
|
|
1148
1315
|
hostRef.$onRenderResolve$ = undefined;
|
|
1149
1316
|
}
|
|
1150
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1317
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
1151
1318
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
1152
1319
|
}
|
|
1153
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1320
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
1154
1321
|
}
|
|
1155
1322
|
// ( •_•)
|
|
1156
1323
|
// ( •_•)>⌐■-■
|
|
@@ -1206,16 +1373,16 @@ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
|
1206
1373
|
const parsePropertyValue = (propValue, propType) => {
|
|
1207
1374
|
// ensure this value is of the correct prop type
|
|
1208
1375
|
if (propValue != null && !isComplexType(propValue)) {
|
|
1209
|
-
if (propType & 4 /* Boolean */) {
|
|
1376
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
1210
1377
|
// per the HTML spec, any string value means it is a boolean true value
|
|
1211
1378
|
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1212
1379
|
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1213
1380
|
}
|
|
1214
|
-
if (propType & 2 /* Number */) {
|
|
1381
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
1215
1382
|
// force it to be a number
|
|
1216
1383
|
return parseFloat(propValue);
|
|
1217
1384
|
}
|
|
1218
|
-
if (propType & 1 /* String */) {
|
|
1385
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
1219
1386
|
// could have been passed as a number or boolean
|
|
1220
1387
|
// but we still want it as a string
|
|
1221
1388
|
return String(propValue);
|
|
@@ -1239,13 +1406,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1239
1406
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1240
1407
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1241
1408
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1242
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1409
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1243
1410
|
// gadzooks! the property's value has changed!!
|
|
1244
1411
|
// set our new value!
|
|
1245
1412
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1246
1413
|
if (instance) {
|
|
1247
1414
|
// get an array of method names of watch functions to call
|
|
1248
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1415
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
1249
1416
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1250
1417
|
if (watchMethods) {
|
|
1251
1418
|
// this instance is watching for when this property changed
|
|
@@ -1260,7 +1427,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1260
1427
|
});
|
|
1261
1428
|
}
|
|
1262
1429
|
}
|
|
1263
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1430
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1264
1431
|
// looks like this value actually changed, so we've got work to do!
|
|
1265
1432
|
// but only if we've already rendered, otherwise just chill out
|
|
1266
1433
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1279,8 +1446,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1279
1446
|
const members = Object.entries(cmpMeta.$members$);
|
|
1280
1447
|
const prototype = Cstr.prototype;
|
|
1281
1448
|
members.map(([memberName, [memberFlags]]) => {
|
|
1282
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
1283
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1449
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1450
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1284
1451
|
// proxyComponent - prop
|
|
1285
1452
|
Object.defineProperty(prototype, memberName, {
|
|
1286
1453
|
get() {
|
|
@@ -1295,8 +1462,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1295
1462
|
enumerable: true,
|
|
1296
1463
|
});
|
|
1297
1464
|
}
|
|
1298
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
1299
|
-
memberFlags & 64 /* Method */) {
|
|
1465
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1466
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1300
1467
|
// proxyComponent - method
|
|
1301
1468
|
Object.defineProperty(prototype, memberName, {
|
|
1302
1469
|
value(...args) {
|
|
@@ -1306,7 +1473,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1306
1473
|
});
|
|
1307
1474
|
}
|
|
1308
1475
|
});
|
|
1309
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1476
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1310
1477
|
const attrNameToPropName = new Map();
|
|
1311
1478
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1312
1479
|
plt.jmp(() => {
|
|
@@ -1362,11 +1529,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1362
1529
|
// create an array of attributes to observe
|
|
1363
1530
|
// and also create a map of html attribute name to js property name
|
|
1364
1531
|
Cstr.observedAttributes = members
|
|
1365
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1532
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1366
1533
|
.map(([propName, m]) => {
|
|
1367
1534
|
const attrName = m[1] || propName;
|
|
1368
1535
|
attrNameToPropName.set(attrName, propName);
|
|
1369
|
-
if (m[0] & 512 /* ReflectAttr */) {
|
|
1536
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1370
1537
|
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1371
1538
|
}
|
|
1372
1539
|
return attrName;
|
|
@@ -1377,10 +1544,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1377
1544
|
};
|
|
1378
1545
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1379
1546
|
// initializeComponent
|
|
1380
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1547
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1381
1548
|
{
|
|
1382
1549
|
// we haven't initialized this element yet
|
|
1383
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1550
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1384
1551
|
// lazy loaded components
|
|
1385
1552
|
// request the component's implementation to be
|
|
1386
1553
|
// wired up with the host element
|
|
@@ -1398,7 +1565,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1398
1565
|
{
|
|
1399
1566
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1400
1567
|
}
|
|
1401
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1568
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1402
1569
|
Cstr.isProxied = true;
|
|
1403
1570
|
}
|
|
1404
1571
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1406,7 +1573,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1406
1573
|
// but let's keep track of when we start and stop
|
|
1407
1574
|
// so that the getters/setters don't incorrectly step on data
|
|
1408
1575
|
{
|
|
1409
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1576
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1410
1577
|
}
|
|
1411
1578
|
// construct the lazy-loaded component implementation
|
|
1412
1579
|
// passing the hostRef is very important during
|
|
@@ -1419,10 +1586,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1419
1586
|
consoleError(e);
|
|
1420
1587
|
}
|
|
1421
1588
|
{
|
|
1422
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1589
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1423
1590
|
}
|
|
1424
1591
|
{
|
|
1425
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1592
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1426
1593
|
}
|
|
1427
1594
|
endNewInstance();
|
|
1428
1595
|
}
|
|
@@ -1432,7 +1599,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1432
1599
|
const scopeId = getScopeId(cmpMeta);
|
|
1433
1600
|
if (!styles.has(scopeId)) {
|
|
1434
1601
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1435
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1602
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1436
1603
|
endRegisterStyles();
|
|
1437
1604
|
}
|
|
1438
1605
|
}
|
|
@@ -1454,19 +1621,19 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1454
1621
|
}
|
|
1455
1622
|
};
|
|
1456
1623
|
const connectedCallback = (elm) => {
|
|
1457
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1624
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1458
1625
|
const hostRef = getHostRef(elm);
|
|
1459
1626
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1460
1627
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1461
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1628
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1462
1629
|
// first time this component has connected
|
|
1463
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1630
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1464
1631
|
{
|
|
1465
1632
|
// initUpdate
|
|
1466
1633
|
// if the slot polyfill is required we'll need to put some nodes
|
|
1467
1634
|
// in here to act as original content anchors as we move nodes around
|
|
1468
1635
|
// host element has been connected to the DOM
|
|
1469
|
-
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1636
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1470
1637
|
setContentReference(elm);
|
|
1471
1638
|
}
|
|
1472
1639
|
}
|
|
@@ -1489,7 +1656,7 @@ const connectedCallback = (elm) => {
|
|
|
1489
1656
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1490
1657
|
if (cmpMeta.$members$) {
|
|
1491
1658
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1492
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1659
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1493
1660
|
const value = elm[memberName];
|
|
1494
1661
|
delete elm[memberName];
|
|
1495
1662
|
elm[memberName] = value;
|
|
@@ -1521,7 +1688,7 @@ const setContentReference = (elm) => {
|
|
|
1521
1688
|
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1522
1689
|
};
|
|
1523
1690
|
const disconnectedCallback = (elm) => {
|
|
1524
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1691
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1525
1692
|
const hostRef = getHostRef(elm);
|
|
1526
1693
|
{
|
|
1527
1694
|
if (hostRef.$rmListeners$) {
|
|
@@ -1572,7 +1739,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1572
1739
|
super(self);
|
|
1573
1740
|
self = this;
|
|
1574
1741
|
registerHost(self, cmpMeta);
|
|
1575
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1742
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1576
1743
|
// this component is using shadow dom
|
|
1577
1744
|
// and this browser supports shadow dom
|
|
1578
1745
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1607,7 +1774,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1607
1774
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1608
1775
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1609
1776
|
cmpTags.push(tagName);
|
|
1610
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1777
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1611
1778
|
}
|
|
1612
1779
|
});
|
|
1613
1780
|
});
|
|
@@ -1629,7 +1796,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1629
1796
|
// Fallback appLoad event
|
|
1630
1797
|
endBootstrap();
|
|
1631
1798
|
};
|
|
1632
|
-
const hostRefs = new WeakMap();
|
|
1799
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1633
1800
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1634
1801
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1635
1802
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1674,14 +1841,14 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1674
1841
|
return importedModule[exportName];
|
|
1675
1842
|
}, consoleError);
|
|
1676
1843
|
};
|
|
1677
|
-
const styles = new Map();
|
|
1844
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1678
1845
|
const queueDomReads = [];
|
|
1679
1846
|
const queueDomWrites = [];
|
|
1680
1847
|
const queueTask = (queue, write) => (cb) => {
|
|
1681
1848
|
queue.push(cb);
|
|
1682
1849
|
if (!queuePending) {
|
|
1683
1850
|
queuePending = true;
|
|
1684
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1851
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1685
1852
|
nextTick(flush);
|
|
1686
1853
|
}
|
|
1687
1854
|
else {
|