@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
|
@@ -65,7 +65,7 @@ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) =
|
|
|
65
65
|
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
66
66
|
try {
|
|
67
67
|
{
|
|
68
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
68
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
69
69
|
// instance is ready, let's call it's member method for this event
|
|
70
70
|
hostRef.$lazyInstance$[methodName](ev);
|
|
71
71
|
}
|
|
@@ -79,12 +79,12 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
const getHostListenerTarget = (elm, flags) => {
|
|
82
|
-
if (flags & 8 /* TargetWindow */)
|
|
82
|
+
if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
|
|
83
83
|
return win;
|
|
84
84
|
return elm;
|
|
85
85
|
};
|
|
86
86
|
// prettier-ignore
|
|
87
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
87
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
88
88
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
89
89
|
const createTime = (fnName, tagName = '') => {
|
|
90
90
|
{
|
|
@@ -100,7 +100,7 @@ const uniqueTime = (key, measureText) => {
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
const rootAppliedStyles = new WeakMap();
|
|
103
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
104
104
|
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
105
105
|
let style = styles.get(scopeId);
|
|
106
106
|
if (supportsConstructableStylesheets && allowCS) {
|
|
@@ -122,7 +122,7 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
122
122
|
const style = styles.get(scopeId);
|
|
123
123
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
124
124
|
// so the fallback is to always use the document for the root node in those cases
|
|
125
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
125
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
126
126
|
if (style) {
|
|
127
127
|
if (typeof style === 'string') {
|
|
128
128
|
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
@@ -156,7 +156,7 @@ const attachStyles = (hostRef) => {
|
|
|
156
156
|
const flags = cmpMeta.$flags$;
|
|
157
157
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
158
158
|
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
159
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
159
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
160
160
|
// only required when we're NOT using native shadow dom (slot)
|
|
161
161
|
// or this browser doesn't support native shadow dom
|
|
162
162
|
// and this host element was NOT created with SSR
|
|
@@ -166,7 +166,7 @@ const attachStyles = (hostRef) => {
|
|
|
166
166
|
// DOM WRITE!!
|
|
167
167
|
elm['s-sc'] = scopeId;
|
|
168
168
|
elm.classList.add(scopeId + '-h');
|
|
169
|
-
if (flags & 2 /* scopedCssEncapsulation */) {
|
|
169
|
+
if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
170
170
|
elm.classList.add(scopeId + '-s');
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -427,7 +427,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
430
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
431
431
|
newValue = newValue === true ? '' : newValue;
|
|
432
432
|
{
|
|
433
433
|
elm.setAttribute(memberName, newValue);
|
|
@@ -442,7 +442,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
442
442
|
// if the element passed in is a shadow root, which is a document fragment
|
|
443
443
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
444
444
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
445
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
445
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
446
446
|
? newVnode.$elm$.host
|
|
447
447
|
: newVnode.$elm$;
|
|
448
448
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -460,6 +460,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
460
460
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
|
+
/**
|
|
464
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
465
|
+
*
|
|
466
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
467
|
+
* @param newParentVNode the parent VNode from the current render
|
|
468
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
469
|
+
* children, for which we will create a new DOM node
|
|
470
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
471
|
+
* @returns the newly created node
|
|
472
|
+
*/
|
|
463
473
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
464
474
|
// tslint:disable-next-line: prefer-const
|
|
465
475
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -477,16 +487,16 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
477
487
|
}
|
|
478
488
|
newVNode.$flags$ |= newVNode.$children$
|
|
479
489
|
? // slot element has fallback content
|
|
480
|
-
2 /* isSlotFallback */
|
|
490
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
481
491
|
: // slot element does not have fallback content
|
|
482
|
-
1 /* isSlotReference */;
|
|
492
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
483
493
|
}
|
|
484
494
|
}
|
|
485
495
|
if (newVNode.$text$ !== null) {
|
|
486
496
|
// create text node
|
|
487
497
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
488
498
|
}
|
|
489
|
-
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
499
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
490
500
|
// create a slot reference node
|
|
491
501
|
elm = newVNode.$elm$ =
|
|
492
502
|
doc.createTextNode('');
|
|
@@ -496,7 +506,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
496
506
|
isSvgMode = newVNode.$tag$ === 'svg';
|
|
497
507
|
}
|
|
498
508
|
// create element
|
|
499
|
-
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
|
|
509
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
500
510
|
? 'slot-fb'
|
|
501
511
|
: newVNode.$tag$)
|
|
502
512
|
);
|
|
@@ -536,7 +546,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
536
546
|
}
|
|
537
547
|
{
|
|
538
548
|
elm['s-hn'] = hostTagName;
|
|
539
|
-
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
549
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
540
550
|
// remember the content reference comment
|
|
541
551
|
elm['s-sr'] = true;
|
|
542
552
|
// remember the content reference comment
|
|
@@ -555,7 +565,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
555
565
|
return elm;
|
|
556
566
|
};
|
|
557
567
|
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
558
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
568
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
559
569
|
const oldSlotChildNodes = parentElm.childNodes;
|
|
560
570
|
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
561
571
|
const childNode = oldSlotChildNodes[i];
|
|
@@ -576,7 +586,7 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
|
576
586
|
putBackInOriginalLocation(childNode, recursive);
|
|
577
587
|
}
|
|
578
588
|
}
|
|
579
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
589
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
580
590
|
};
|
|
581
591
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
582
592
|
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
@@ -618,6 +628,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
618
628
|
}
|
|
619
629
|
}
|
|
620
630
|
};
|
|
631
|
+
/**
|
|
632
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
633
|
+
* traversing the two collections of children, identifying nodes that are
|
|
634
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
635
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
636
|
+
*
|
|
637
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
638
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
639
|
+
* 'windows' by storing start and end indices and references to the
|
|
640
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
641
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
642
|
+
* no children left to update by doing the following:
|
|
643
|
+
*
|
|
644
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
645
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
646
|
+
* only with a window bounded by the highlighted elements:
|
|
647
|
+
*
|
|
648
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
649
|
+
* ^^^^^^ ^^^^^^
|
|
650
|
+
*
|
|
651
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
652
|
+
* across the windows. This will basically detect elements which haven't
|
|
653
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
654
|
+
* VNode elements (represented as HTML):
|
|
655
|
+
*
|
|
656
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
657
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
658
|
+
*
|
|
659
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
660
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
661
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
662
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
663
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
664
|
+
*
|
|
665
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
666
|
+
* window corresponds to the element at the end of the other window. This is
|
|
667
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
668
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
669
|
+
* children nodes themselves have not changed but merely moved in the
|
|
670
|
+
* following example:
|
|
671
|
+
*
|
|
672
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
673
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
674
|
+
*
|
|
675
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
676
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
677
|
+
* DOM.
|
|
678
|
+
*
|
|
679
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
680
|
+
* nodes in the old children which have the same key as the first element in
|
|
681
|
+
* our window on the new children. If we find such a node we handle calling
|
|
682
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
683
|
+
* what we find.
|
|
684
|
+
*
|
|
685
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
686
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
687
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
688
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
689
|
+
* children has collapsed we still have more nodes on the new children that
|
|
690
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
691
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
692
|
+
* sure the corresponding DOM nodes are removed.
|
|
693
|
+
*
|
|
694
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
695
|
+
* @param oldCh the old children of the parent node
|
|
696
|
+
* @param newVNode the new VNode which will replace the parent
|
|
697
|
+
* @param newCh the new children of the parent node
|
|
698
|
+
*/
|
|
621
699
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
622
700
|
let oldStartIdx = 0;
|
|
623
701
|
let newStartIdx = 0;
|
|
@@ -630,7 +708,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
630
708
|
let node;
|
|
631
709
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
632
710
|
if (oldStartVnode == null) {
|
|
633
|
-
//
|
|
711
|
+
// VNode might have been moved left
|
|
634
712
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
635
713
|
}
|
|
636
714
|
else if (oldEndVnode == null) {
|
|
@@ -643,42 +721,102 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
643
721
|
newEndVnode = newCh[--newEndIdx];
|
|
644
722
|
}
|
|
645
723
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
724
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
725
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
726
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
727
|
+
// since things are matched up in order.
|
|
646
728
|
patch(oldStartVnode, newStartVnode);
|
|
647
729
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
648
730
|
newStartVnode = newCh[++newStartIdx];
|
|
649
731
|
}
|
|
650
732
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
733
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
734
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
735
|
+
// need to move any DOM Nodes.
|
|
651
736
|
patch(oldEndVnode, newEndVnode);
|
|
652
737
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
653
738
|
newEndVnode = newCh[--newEndIdx];
|
|
654
739
|
}
|
|
655
740
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
656
|
-
// Vnode moved right
|
|
741
|
+
// case: "Vnode moved right"
|
|
742
|
+
//
|
|
743
|
+
// We've found that the last node in our window on the new children is
|
|
744
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
745
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
746
|
+
// nodes:
|
|
747
|
+
//
|
|
748
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
749
|
+
// ^^^^^^^^^^^
|
|
750
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
751
|
+
// ^^^^^^^^^^^^^
|
|
752
|
+
//
|
|
753
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
754
|
+
// and move the DOM element for `oldStartVnode`.
|
|
657
755
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
658
756
|
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
659
757
|
}
|
|
660
758
|
patch(oldStartVnode, newEndVnode);
|
|
759
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
760
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
761
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
762
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
763
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
764
|
+
//
|
|
765
|
+
// <old-start-node />
|
|
766
|
+
// <some-intervening-node />
|
|
767
|
+
// <old-end-node />
|
|
768
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
769
|
+
// <next-sibling />
|
|
770
|
+
//
|
|
771
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
772
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
773
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
774
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
775
|
+
// append it to the children of the parent element.
|
|
661
776
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
662
777
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
663
778
|
newEndVnode = newCh[--newEndIdx];
|
|
664
779
|
}
|
|
665
780
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
666
|
-
// Vnode moved left
|
|
781
|
+
// case: "Vnode moved left"
|
|
782
|
+
//
|
|
783
|
+
// We've found that the first node in our window on the new children is
|
|
784
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
785
|
+
// Visually, this is the layout of these two nodes:
|
|
786
|
+
//
|
|
787
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
788
|
+
// ^^^^^^^^^^^^^
|
|
789
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
790
|
+
// ^^^^^^^^^^^
|
|
791
|
+
//
|
|
792
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
793
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
794
|
+
// children etc) but we also need to move the DOM node to which
|
|
795
|
+
// `oldEndVnode` corresponds.
|
|
667
796
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
668
797
|
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
669
798
|
}
|
|
670
799
|
patch(oldEndVnode, newStartVnode);
|
|
800
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
801
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
802
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
803
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
804
|
+
// future.
|
|
671
805
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
672
806
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
673
807
|
newStartVnode = newCh[++newStartIdx];
|
|
674
808
|
}
|
|
675
809
|
else {
|
|
676
810
|
{
|
|
677
|
-
//
|
|
811
|
+
// We either didn't find an element in the old children that matches
|
|
812
|
+
// the key of the first new child OR the build is not using `key`
|
|
813
|
+
// attributes at all. In either case we need to create a new element
|
|
814
|
+
// for the new node.
|
|
678
815
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
679
816
|
newStartVnode = newCh[++newStartIdx];
|
|
680
817
|
}
|
|
681
818
|
if (node) {
|
|
819
|
+
// if we created a new node then handle inserting it to the DOM
|
|
682
820
|
{
|
|
683
821
|
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
684
822
|
}
|
|
@@ -686,18 +824,39 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
686
824
|
}
|
|
687
825
|
}
|
|
688
826
|
if (oldStartIdx > oldEndIdx) {
|
|
827
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
689
828
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
690
829
|
}
|
|
691
830
|
else if (newStartIdx > newEndIdx) {
|
|
831
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
832
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
833
|
+
// relevant DOM nodes)
|
|
692
834
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
693
835
|
}
|
|
694
836
|
};
|
|
695
|
-
|
|
837
|
+
/**
|
|
838
|
+
* Compare two VNodes to determine if they are the same
|
|
839
|
+
*
|
|
840
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
841
|
+
* information set on the two VNodes and can be misleading under certain
|
|
842
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
843
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
844
|
+
* checking that they have the same tag.
|
|
845
|
+
*
|
|
846
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
847
|
+
* changing order within a `children` array or something along those lines then
|
|
848
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
849
|
+
*
|
|
850
|
+
* @param leftVNode the first VNode to check
|
|
851
|
+
* @param rightVNode the second VNode to check
|
|
852
|
+
* @returns whether they're equal or not
|
|
853
|
+
*/
|
|
854
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
696
855
|
// compare if two vnode to see if they're "technically" the same
|
|
697
856
|
// need to have the same element tag, and same key to be the same
|
|
698
|
-
if (
|
|
699
|
-
if (
|
|
700
|
-
return
|
|
857
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
858
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
859
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
701
860
|
}
|
|
702
861
|
return true;
|
|
703
862
|
}
|
|
@@ -711,6 +870,14 @@ const referenceNode = (node) => {
|
|
|
711
870
|
return (node && node['s-ol']) || node;
|
|
712
871
|
};
|
|
713
872
|
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
873
|
+
/**
|
|
874
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
875
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
876
|
+
* children of the two nodes (if any).
|
|
877
|
+
*
|
|
878
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
879
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
880
|
+
*/
|
|
714
881
|
const patch = (oldVNode, newVNode) => {
|
|
715
882
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
716
883
|
const oldChildren = oldVNode.$children$;
|
|
@@ -724,7 +891,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
724
891
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
725
892
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
726
893
|
}
|
|
727
|
-
// element node
|
|
728
894
|
{
|
|
729
895
|
if (tag === 'slot')
|
|
730
896
|
;
|
|
@@ -737,6 +903,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
737
903
|
}
|
|
738
904
|
if (oldChildren !== null && newChildren !== null) {
|
|
739
905
|
// looks like there's child vnodes for both the old and new vnodes
|
|
906
|
+
// so we need to call `updateChildren` to reconcile them
|
|
740
907
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
741
908
|
}
|
|
742
909
|
else if (newChildren !== null) {
|
|
@@ -777,7 +944,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
777
944
|
let nodeType;
|
|
778
945
|
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
779
946
|
childNode = childNodes[i];
|
|
780
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
947
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
781
948
|
if (childNode['s-sr']) {
|
|
782
949
|
// this is a slot fallback node
|
|
783
950
|
// get the slot name for this slot reference node
|
|
@@ -789,7 +956,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
789
956
|
nodeType = childNodes[j].nodeType;
|
|
790
957
|
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
791
958
|
// this sibling node is from a different component OR is a named fallback slot node
|
|
792
|
-
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
959
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
793
960
|
childNode.hidden = true;
|
|
794
961
|
break;
|
|
795
962
|
}
|
|
@@ -798,8 +965,8 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
798
965
|
// this is a default fallback slot node
|
|
799
966
|
// any element or text node (with content)
|
|
800
967
|
// should hide the default fallback slot node
|
|
801
|
-
if (nodeType === 1 /* ElementNode */ ||
|
|
802
|
-
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
968
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
969
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
803
970
|
childNode.hidden = true;
|
|
804
971
|
break;
|
|
805
972
|
}
|
|
@@ -877,13 +1044,13 @@ const relocateSlotContent = (elm) => {
|
|
|
877
1044
|
}
|
|
878
1045
|
}
|
|
879
1046
|
}
|
|
880
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1047
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
881
1048
|
relocateSlotContent(childNode);
|
|
882
1049
|
}
|
|
883
1050
|
}
|
|
884
1051
|
};
|
|
885
1052
|
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
886
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1053
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
887
1054
|
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
888
1055
|
return true;
|
|
889
1056
|
}
|
|
@@ -914,7 +1081,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
914
1081
|
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
915
1082
|
}
|
|
916
1083
|
rootVnode.$tag$ = null;
|
|
917
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1084
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
918
1085
|
hostRef.$vnode$ = rootVnode;
|
|
919
1086
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
920
1087
|
{
|
|
@@ -922,7 +1089,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
922
1089
|
}
|
|
923
1090
|
{
|
|
924
1091
|
contentRef = hostElm['s-cr'];
|
|
925
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
1092
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
926
1093
|
// always reset
|
|
927
1094
|
checkSlotFallbackVisibility = false;
|
|
928
1095
|
}
|
|
@@ -931,7 +1098,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
931
1098
|
{
|
|
932
1099
|
// while we're moving nodes around existing nodes, temporarily disable
|
|
933
1100
|
// the disconnectCallback from working
|
|
934
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
1101
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
935
1102
|
if (checkSlotRelocate) {
|
|
936
1103
|
relocateSlotContent(rootVnode.$elm$);
|
|
937
1104
|
let relocateData;
|
|
@@ -989,7 +1156,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
989
1156
|
}
|
|
990
1157
|
else {
|
|
991
1158
|
// this node doesn't have a slot home to go to, so let's hide it
|
|
992
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1159
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
993
1160
|
nodeToRelocate.hidden = true;
|
|
994
1161
|
}
|
|
995
1162
|
}
|
|
@@ -1000,7 +1167,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1000
1167
|
}
|
|
1001
1168
|
// done moving nodes around
|
|
1002
1169
|
// allow the disconnect callback to work again
|
|
1003
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
1170
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1004
1171
|
// always reset
|
|
1005
1172
|
relocateNodes.length = 0;
|
|
1006
1173
|
}
|
|
@@ -1011,9 +1178,9 @@ const createEvent = (ref, name, flags) => {
|
|
|
1011
1178
|
return {
|
|
1012
1179
|
emit: (detail) => {
|
|
1013
1180
|
return emitEvent(elm, name, {
|
|
1014
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
1015
|
-
composed: !!(flags & 2 /* Composed */),
|
|
1016
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
1181
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
1182
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
1183
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
1017
1184
|
detail,
|
|
1018
1185
|
});
|
|
1019
1186
|
},
|
|
@@ -1038,10 +1205,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
1038
1205
|
};
|
|
1039
1206
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
1040
1207
|
{
|
|
1041
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1208
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1042
1209
|
}
|
|
1043
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
1044
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1210
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1211
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
1045
1212
|
return;
|
|
1046
1213
|
}
|
|
1047
1214
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -1057,7 +1224,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1057
1224
|
let promise;
|
|
1058
1225
|
if (isInitialLoad) {
|
|
1059
1226
|
{
|
|
1060
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
1227
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1061
1228
|
if (hostRef.$queuedListeners$) {
|
|
1062
1229
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1063
1230
|
hostRef.$queuedListeners$ = null;
|
|
@@ -1100,7 +1267,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1100
1267
|
}
|
|
1101
1268
|
else {
|
|
1102
1269
|
Promise.all(childrenPromises).then(postUpdate);
|
|
1103
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1270
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
1104
1271
|
childrenPromises.length = 0;
|
|
1105
1272
|
}
|
|
1106
1273
|
}
|
|
@@ -1109,10 +1276,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
1109
1276
|
try {
|
|
1110
1277
|
instance = instance.render() ;
|
|
1111
1278
|
{
|
|
1112
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1279
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1113
1280
|
}
|
|
1114
1281
|
{
|
|
1115
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1282
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
1116
1283
|
}
|
|
1117
1284
|
{
|
|
1118
1285
|
{
|
|
@@ -1139,8 +1306,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1139
1306
|
{
|
|
1140
1307
|
safeCall(instance, 'componentDidRender');
|
|
1141
1308
|
}
|
|
1142
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
1143
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1309
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1310
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
1144
1311
|
{
|
|
1145
1312
|
// DOM WRITE!
|
|
1146
1313
|
addHydratedFlag(elm);
|
|
@@ -1169,10 +1336,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1169
1336
|
hostRef.$onRenderResolve$();
|
|
1170
1337
|
hostRef.$onRenderResolve$ = undefined;
|
|
1171
1338
|
}
|
|
1172
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1339
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
1173
1340
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
1174
1341
|
}
|
|
1175
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1342
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
1176
1343
|
}
|
|
1177
1344
|
// ( •_•)
|
|
1178
1345
|
// ( •_•)>⌐■-■
|
|
@@ -1228,16 +1395,16 @@ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
|
1228
1395
|
const parsePropertyValue = (propValue, propType) => {
|
|
1229
1396
|
// ensure this value is of the correct prop type
|
|
1230
1397
|
if (propValue != null && !isComplexType(propValue)) {
|
|
1231
|
-
if (propType & 4 /* Boolean */) {
|
|
1398
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
1232
1399
|
// per the HTML spec, any string value means it is a boolean true value
|
|
1233
1400
|
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1234
1401
|
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1235
1402
|
}
|
|
1236
|
-
if (propType & 2 /* Number */) {
|
|
1403
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
1237
1404
|
// force it to be a number
|
|
1238
1405
|
return parseFloat(propValue);
|
|
1239
1406
|
}
|
|
1240
|
-
if (propType & 1 /* String */) {
|
|
1407
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
1241
1408
|
// could have been passed as a number or boolean
|
|
1242
1409
|
// but we still want it as a string
|
|
1243
1410
|
return String(propValue);
|
|
@@ -1261,13 +1428,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1261
1428
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1262
1429
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1263
1430
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1264
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1431
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1265
1432
|
// gadzooks! the property's value has changed!!
|
|
1266
1433
|
// set our new value!
|
|
1267
1434
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1268
1435
|
if (instance) {
|
|
1269
1436
|
// get an array of method names of watch functions to call
|
|
1270
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1437
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
1271
1438
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1272
1439
|
if (watchMethods) {
|
|
1273
1440
|
// this instance is watching for when this property changed
|
|
@@ -1282,7 +1449,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1282
1449
|
});
|
|
1283
1450
|
}
|
|
1284
1451
|
}
|
|
1285
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1452
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1286
1453
|
// looks like this value actually changed, so we've got work to do!
|
|
1287
1454
|
// but only if we've already rendered, otherwise just chill out
|
|
1288
1455
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1301,8 +1468,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1301
1468
|
const members = Object.entries(cmpMeta.$members$);
|
|
1302
1469
|
const prototype = Cstr.prototype;
|
|
1303
1470
|
members.map(([memberName, [memberFlags]]) => {
|
|
1304
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
1305
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1471
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1472
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1306
1473
|
// proxyComponent - prop
|
|
1307
1474
|
Object.defineProperty(prototype, memberName, {
|
|
1308
1475
|
get() {
|
|
@@ -1317,8 +1484,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1317
1484
|
enumerable: true,
|
|
1318
1485
|
});
|
|
1319
1486
|
}
|
|
1320
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
1321
|
-
memberFlags & 64 /* Method */) {
|
|
1487
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1488
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1322
1489
|
// proxyComponent - method
|
|
1323
1490
|
Object.defineProperty(prototype, memberName, {
|
|
1324
1491
|
value(...args) {
|
|
@@ -1328,7 +1495,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1328
1495
|
});
|
|
1329
1496
|
}
|
|
1330
1497
|
});
|
|
1331
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1498
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1332
1499
|
const attrNameToPropName = new Map();
|
|
1333
1500
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1334
1501
|
plt.jmp(() => {
|
|
@@ -1384,11 +1551,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1384
1551
|
// create an array of attributes to observe
|
|
1385
1552
|
// and also create a map of html attribute name to js property name
|
|
1386
1553
|
Cstr.observedAttributes = members
|
|
1387
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1554
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1388
1555
|
.map(([propName, m]) => {
|
|
1389
1556
|
const attrName = m[1] || propName;
|
|
1390
1557
|
attrNameToPropName.set(attrName, propName);
|
|
1391
|
-
if (m[0] & 512 /* ReflectAttr */) {
|
|
1558
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1392
1559
|
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1393
1560
|
}
|
|
1394
1561
|
return attrName;
|
|
@@ -1399,10 +1566,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1399
1566
|
};
|
|
1400
1567
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1401
1568
|
// initializeComponent
|
|
1402
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1569
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1403
1570
|
{
|
|
1404
1571
|
// we haven't initialized this element yet
|
|
1405
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1572
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1406
1573
|
// lazy loaded components
|
|
1407
1574
|
// request the component's implementation to be
|
|
1408
1575
|
// wired up with the host element
|
|
@@ -1420,7 +1587,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1420
1587
|
{
|
|
1421
1588
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1422
1589
|
}
|
|
1423
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1590
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1424
1591
|
Cstr.isProxied = true;
|
|
1425
1592
|
}
|
|
1426
1593
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1428,7 +1595,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1428
1595
|
// but let's keep track of when we start and stop
|
|
1429
1596
|
// so that the getters/setters don't incorrectly step on data
|
|
1430
1597
|
{
|
|
1431
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1598
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1432
1599
|
}
|
|
1433
1600
|
// construct the lazy-loaded component implementation
|
|
1434
1601
|
// passing the hostRef is very important during
|
|
@@ -1441,10 +1608,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1441
1608
|
consoleError(e);
|
|
1442
1609
|
}
|
|
1443
1610
|
{
|
|
1444
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1611
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1445
1612
|
}
|
|
1446
1613
|
{
|
|
1447
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1614
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1448
1615
|
}
|
|
1449
1616
|
endNewInstance();
|
|
1450
1617
|
}
|
|
@@ -1454,7 +1621,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1454
1621
|
const scopeId = getScopeId(cmpMeta);
|
|
1455
1622
|
if (!styles.has(scopeId)) {
|
|
1456
1623
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1457
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1624
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1458
1625
|
endRegisterStyles();
|
|
1459
1626
|
}
|
|
1460
1627
|
}
|
|
@@ -1476,19 +1643,19 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1476
1643
|
}
|
|
1477
1644
|
};
|
|
1478
1645
|
const connectedCallback = (elm) => {
|
|
1479
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1646
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1480
1647
|
const hostRef = getHostRef(elm);
|
|
1481
1648
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1482
1649
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1483
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1650
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1484
1651
|
// first time this component has connected
|
|
1485
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1652
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1486
1653
|
{
|
|
1487
1654
|
// initUpdate
|
|
1488
1655
|
// if the slot polyfill is required we'll need to put some nodes
|
|
1489
1656
|
// in here to act as original content anchors as we move nodes around
|
|
1490
1657
|
// host element has been connected to the DOM
|
|
1491
|
-
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1658
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1492
1659
|
setContentReference(elm);
|
|
1493
1660
|
}
|
|
1494
1661
|
}
|
|
@@ -1511,7 +1678,7 @@ const connectedCallback = (elm) => {
|
|
|
1511
1678
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1512
1679
|
if (cmpMeta.$members$) {
|
|
1513
1680
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1514
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1681
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1515
1682
|
const value = elm[memberName];
|
|
1516
1683
|
delete elm[memberName];
|
|
1517
1684
|
elm[memberName] = value;
|
|
@@ -1543,7 +1710,7 @@ const setContentReference = (elm) => {
|
|
|
1543
1710
|
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1544
1711
|
};
|
|
1545
1712
|
const disconnectedCallback = (elm) => {
|
|
1546
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1713
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1547
1714
|
const hostRef = getHostRef(elm);
|
|
1548
1715
|
{
|
|
1549
1716
|
if (hostRef.$rmListeners$) {
|
|
@@ -1594,7 +1761,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1594
1761
|
super(self);
|
|
1595
1762
|
self = this;
|
|
1596
1763
|
registerHost(self, cmpMeta);
|
|
1597
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1764
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1598
1765
|
// this component is using shadow dom
|
|
1599
1766
|
// and this browser supports shadow dom
|
|
1600
1767
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1629,7 +1796,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1629
1796
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1630
1797
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1631
1798
|
cmpTags.push(tagName);
|
|
1632
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1799
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1633
1800
|
}
|
|
1634
1801
|
});
|
|
1635
1802
|
});
|
|
@@ -1651,7 +1818,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1651
1818
|
// Fallback appLoad event
|
|
1652
1819
|
endBootstrap();
|
|
1653
1820
|
};
|
|
1654
|
-
const hostRefs = new WeakMap();
|
|
1821
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1655
1822
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1656
1823
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1657
1824
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1696,14 +1863,14 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1696
1863
|
return importedModule[exportName];
|
|
1697
1864
|
}, consoleError);
|
|
1698
1865
|
};
|
|
1699
|
-
const styles = new Map();
|
|
1866
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1700
1867
|
const queueDomReads = [];
|
|
1701
1868
|
const queueDomWrites = [];
|
|
1702
1869
|
const queueTask = (queue, write) => (cb) => {
|
|
1703
1870
|
queue.push(cb);
|
|
1704
1871
|
if (!queuePending) {
|
|
1705
1872
|
queuePending = true;
|
|
1706
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1873
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1707
1874
|
nextTick(flush);
|
|
1708
1875
|
}
|
|
1709
1876
|
else {
|