@haiilo/catalyst 1.2.4 → 1.3.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/catalyst/catalyst.css +1 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/p-270fd91d.entry.js +2 -0
- package/dist/catalyst/{p-394f6b20.entry.js.map → p-270fd91d.entry.js.map} +1 -1
- package/dist/catalyst/p-3ad731e4.entry.js +2 -0
- package/dist/catalyst/p-3ad731e4.entry.js.map +1 -0
- package/dist/catalyst/p-692e49d6.js +3 -0
- package/dist/catalyst/p-692e49d6.js.map +1 -0
- package/dist/catalyst/scss/_variables.scss +2 -10
- package/dist/catalyst/scss/_variables.tokens.scss +2 -2
- package/dist/catalyst/scss/core/_base.scss +5 -1
- package/dist/catalyst/scss/core/_toast.scss +3 -3
- package/dist/catalyst/scss/core/_typography.scss +2 -17
- package/dist/catalyst/scss/index.scss +4 -4
- package/dist/catalyst/scss/utils/_typography.mixins.scss +9 -2
- package/dist/cjs/cat-alert_22.cjs.entry.js +174 -108
- package/dist/cjs/cat-alert_22.cjs.entry.js.map +1 -1
- package/dist/cjs/cat-modal.cjs.entry.js +2 -2
- package/dist/cjs/cat-modal.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +3 -3
- package/dist/cjs/catalyst.cjs.js.map +1 -1
- package/dist/cjs/{index-8ab22379.js → index-b2134f1b.js} +13 -5
- package/dist/cjs/index-b2134f1b.js.map +1 -0
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/cat-button/cat-button.css +9 -5
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +1 -1
- package/dist/collection/components/cat-input/cat-input.css +1 -1
- package/dist/collection/components/cat-menu/cat-menu.css +0 -2
- package/dist/collection/components/cat-menu/cat-menu.js +47 -14
- package/dist/collection/components/cat-menu/cat-menu.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.css +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.css +0 -2
- package/dist/collection/components/cat-select/cat-select.css +1 -1
- package/dist/collection/components/cat-select/cat-select.js +30 -28
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js +3 -3
- package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.css +1 -1
- package/dist/collection/scss/_variables.scss +2 -10
- package/dist/collection/scss/core/_base.scss +5 -1
- package/dist/collection/scss/core/_toast.scss +3 -3
- package/dist/collection/scss/core/_typography.scss +2 -17
- package/dist/collection/scss/utils/_typography.mixins.scss +9 -2
- package/dist/components/cat-avatar2.js.map +1 -1
- package/dist/components/cat-button2.js +1 -1
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox2.js +1 -1
- package/dist/components/cat-input.js +1 -1
- package/dist/components/cat-menu.js +30 -14
- package/dist/components/cat-menu.js.map +1 -1
- package/dist/components/cat-radio.js +1 -1
- package/dist/components/cat-select-demo.js +2 -2
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-select2.js +31 -29
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-textarea.js +1 -1
- package/dist/components/floating-ui.dom.esm.js +106 -57
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/esm/cat-alert_22.entry.js +174 -108
- package/dist/esm/cat-alert_22.entry.js.map +1 -1
- package/dist/esm/cat-modal.entry.js +2 -2
- package/dist/esm/cat-modal.entry.js.map +1 -1
- package/dist/esm/catalyst.js +3 -3
- package/dist/esm/catalyst.js.map +1 -1
- package/dist/esm/{index-df195301.js → index-033048ed.js} +13 -6
- package/dist/esm/index-033048ed.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/loader.js.map +1 -1
- package/dist/types/components/cat-menu/cat-menu.d.ts +5 -0
- package/dist/types/components/cat-select/cat-select.d.ts +4 -3
- package/dist/types/components.d.ts +8 -0
- package/package.json +16 -13
- package/dist/catalyst/p-394f6b20.entry.js +0 -2
- package/dist/catalyst/p-e7265b52.entry.js +0 -2
- package/dist/catalyst/p-e7265b52.entry.js.map +0 -1
- package/dist/catalyst/p-f80e3399.js +0 -3
- package/dist/catalyst/p-f80e3399.js.map +0 -1
- package/dist/cjs/index-8ab22379.js.map +0 -1
- package/dist/esm/index-df195301.js.map +0 -1
|
@@ -105,9 +105,9 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
105
105
|
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
106
106
|
let statefulPlacement = placement;
|
|
107
107
|
let middlewareData = {};
|
|
108
|
+
let resetCount = 0;
|
|
108
109
|
|
|
109
110
|
for (let i = 0; i < middleware.length; i++) {
|
|
110
|
-
|
|
111
111
|
const {
|
|
112
112
|
name,
|
|
113
113
|
fn
|
|
@@ -139,7 +139,9 @@ const computePosition$1 = async (reference, floating, config) => {
|
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
if (reset) {
|
|
142
|
+
if (reset && resetCount <= 50) {
|
|
143
|
+
resetCount++;
|
|
144
|
+
|
|
143
145
|
if (typeof reset === 'object') {
|
|
144
146
|
if (reset.placement) {
|
|
145
147
|
statefulPlacement = reset.placement;
|
|
@@ -247,9 +249,7 @@ async function detectOverflow(middlewareArguments, options) {
|
|
|
247
249
|
} : rects.reference,
|
|
248
250
|
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
|
|
249
251
|
strategy
|
|
250
|
-
}) : rects[elementContext]);
|
|
251
|
-
// 0 or negative = within the clipping rect
|
|
252
|
-
|
|
252
|
+
}) : rects[elementContext]);
|
|
253
253
|
return {
|
|
254
254
|
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
255
255
|
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
@@ -414,19 +414,19 @@ const flip = function (options) {
|
|
|
414
414
|
};
|
|
415
415
|
};
|
|
416
416
|
|
|
417
|
-
function convertValueToCoords(
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
417
|
+
async function convertValueToCoords(middlewareArguments, value) {
|
|
418
|
+
const {
|
|
419
|
+
placement,
|
|
420
|
+
platform,
|
|
421
|
+
elements
|
|
422
|
+
} = middlewareArguments;
|
|
423
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
422
424
|
const side = getSide(placement);
|
|
423
425
|
const alignment = getAlignment(placement);
|
|
424
426
|
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
425
427
|
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
426
428
|
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
427
|
-
const rawValue = typeof value === 'function' ? value(
|
|
428
|
-
placement
|
|
429
|
-
}) : value; // eslint-disable-next-line prefer-const
|
|
429
|
+
const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
|
|
430
430
|
|
|
431
431
|
let {
|
|
432
432
|
mainAxis,
|
|
@@ -472,13 +472,9 @@ const offset = function (value) {
|
|
|
472
472
|
async fn(middlewareArguments) {
|
|
473
473
|
const {
|
|
474
474
|
x,
|
|
475
|
-
y
|
|
476
|
-
placement,
|
|
477
|
-
rects,
|
|
478
|
-
platform,
|
|
479
|
-
elements
|
|
475
|
+
y
|
|
480
476
|
} = middlewareArguments;
|
|
481
|
-
const diffCoords = convertValueToCoords(
|
|
477
|
+
const diffCoords = await convertValueToCoords(middlewareArguments, value);
|
|
482
478
|
return {
|
|
483
479
|
x: x + diffCoords.x,
|
|
484
480
|
y: y + diffCoords.y,
|
|
@@ -490,7 +486,7 @@ const offset = function (value) {
|
|
|
490
486
|
};
|
|
491
487
|
|
|
492
488
|
function isWindow(value) {
|
|
493
|
-
return
|
|
489
|
+
return value && value.document && value.location && value.alert && value.setInterval;
|
|
494
490
|
}
|
|
495
491
|
function getWindow(node) {
|
|
496
492
|
if (node == null) {
|
|
@@ -505,7 +501,7 @@ function getWindow(node) {
|
|
|
505
501
|
return node;
|
|
506
502
|
}
|
|
507
503
|
|
|
508
|
-
function getComputedStyle
|
|
504
|
+
function getComputedStyle(element) {
|
|
509
505
|
return getWindow(element).getComputedStyle(element);
|
|
510
506
|
}
|
|
511
507
|
|
|
@@ -513,6 +509,16 @@ function getNodeName(node) {
|
|
|
513
509
|
return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
|
|
514
510
|
}
|
|
515
511
|
|
|
512
|
+
function getUAString() {
|
|
513
|
+
const uaData = navigator.userAgentData;
|
|
514
|
+
|
|
515
|
+
if (uaData != null && uaData.brands) {
|
|
516
|
+
return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return navigator.userAgent;
|
|
520
|
+
}
|
|
521
|
+
|
|
516
522
|
function isHTMLElement(value) {
|
|
517
523
|
return value instanceof getWindow(value).HTMLElement;
|
|
518
524
|
}
|
|
@@ -523,6 +529,11 @@ function isNode(value) {
|
|
|
523
529
|
return value instanceof getWindow(value).Node;
|
|
524
530
|
}
|
|
525
531
|
function isShadowRoot(node) {
|
|
532
|
+
// Browsers without `ShadowRoot` support
|
|
533
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
|
|
526
537
|
const OwnElement = getWindow(node).ShadowRoot;
|
|
527
538
|
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
528
539
|
}
|
|
@@ -531,36 +542,46 @@ function isOverflowElement(element) {
|
|
|
531
542
|
const {
|
|
532
543
|
overflow,
|
|
533
544
|
overflowX,
|
|
534
|
-
overflowY
|
|
535
|
-
|
|
536
|
-
|
|
545
|
+
overflowY,
|
|
546
|
+
display
|
|
547
|
+
} = getComputedStyle(element);
|
|
548
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
|
|
537
549
|
}
|
|
538
550
|
function isTableElement(element) {
|
|
539
551
|
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
540
552
|
}
|
|
541
553
|
function isContainingBlock(element) {
|
|
542
554
|
// TODO: Try and use feature detection here instead
|
|
543
|
-
const isFirefox =
|
|
544
|
-
const css = getComputedStyle
|
|
555
|
+
const isFirefox = /firefox/i.test(getUAString());
|
|
556
|
+
const css = getComputedStyle(element); // This is non-exhaustive but covers the most common CSS properties that
|
|
545
557
|
// create a containing block.
|
|
546
558
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
547
559
|
|
|
548
|
-
return css.transform !== 'none' || css.perspective !== 'none' ||
|
|
560
|
+
return css.transform !== 'none' || css.perspective !== 'none' || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some( // TS 4.1 compat
|
|
561
|
+
value => {
|
|
562
|
+
const contain = css.contain;
|
|
563
|
+
return contain != null ? contain.includes(value) : false;
|
|
564
|
+
});
|
|
549
565
|
}
|
|
550
566
|
function isLayoutViewport() {
|
|
551
567
|
// Not Safari
|
|
552
|
-
return !/^((?!chrome|android).)*safari/i.test(
|
|
568
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
|
|
553
569
|
// • Always-visible scrollbar or not
|
|
554
570
|
// • Width of <html>, etc.
|
|
555
571
|
// const vV = win.visualViewport;
|
|
556
572
|
// return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
|
|
557
573
|
}
|
|
574
|
+
function isLastTraversableNode(node) {
|
|
575
|
+
return ['html', 'body', '#document'].includes(getNodeName(node));
|
|
576
|
+
}
|
|
558
577
|
|
|
559
578
|
const min = Math.min;
|
|
560
579
|
const max = Math.max;
|
|
561
580
|
const round = Math.round;
|
|
562
581
|
|
|
563
582
|
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
583
|
+
var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
|
|
584
|
+
|
|
564
585
|
if (includeScale === void 0) {
|
|
565
586
|
includeScale = false;
|
|
566
587
|
}
|
|
@@ -580,8 +601,8 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
|
580
601
|
|
|
581
602
|
const win = isElement(element) ? getWindow(element) : window;
|
|
582
603
|
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
583
|
-
const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
|
|
584
|
-
const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
|
|
604
|
+
const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
|
|
605
|
+
const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
|
|
585
606
|
const width = clientRect.width / scaleX;
|
|
586
607
|
const height = clientRect.height / scaleY;
|
|
587
608
|
return {
|
|
@@ -601,16 +622,16 @@ function getDocumentElement(node) {
|
|
|
601
622
|
}
|
|
602
623
|
|
|
603
624
|
function getNodeScroll(element) {
|
|
604
|
-
if (
|
|
625
|
+
if (isElement(element)) {
|
|
605
626
|
return {
|
|
606
|
-
scrollLeft: element.
|
|
607
|
-
scrollTop: element.
|
|
627
|
+
scrollLeft: element.scrollLeft,
|
|
628
|
+
scrollTop: element.scrollTop
|
|
608
629
|
};
|
|
609
630
|
}
|
|
610
631
|
|
|
611
632
|
return {
|
|
612
|
-
scrollLeft: element.
|
|
613
|
-
scrollTop: element.
|
|
633
|
+
scrollLeft: element.pageXOffset,
|
|
634
|
+
scrollTop: element.pageYOffset
|
|
614
635
|
};
|
|
615
636
|
}
|
|
616
637
|
|
|
@@ -628,7 +649,8 @@ function isScaled(element) {
|
|
|
628
649
|
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
629
650
|
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
630
651
|
const documentElement = getDocumentElement(offsetParent);
|
|
631
|
-
const rect = getBoundingClientRect(element,
|
|
652
|
+
const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
|
|
653
|
+
isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
|
|
632
654
|
let scroll = {
|
|
633
655
|
scrollLeft: 0,
|
|
634
656
|
scrollTop: 0
|
|
@@ -690,11 +712,12 @@ function getContainingBlock(element) {
|
|
|
690
712
|
currentNode = currentNode.host;
|
|
691
713
|
}
|
|
692
714
|
|
|
693
|
-
while (isHTMLElement(currentNode) && !
|
|
715
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
694
716
|
if (isContainingBlock(currentNode)) {
|
|
695
717
|
return currentNode;
|
|
696
718
|
} else {
|
|
697
|
-
|
|
719
|
+
const parent = currentNode.parentNode;
|
|
720
|
+
currentNode = isShadowRoot(parent) ? parent.host : parent;
|
|
698
721
|
}
|
|
699
722
|
}
|
|
700
723
|
|
|
@@ -818,7 +841,7 @@ function getDocumentRect(element) {
|
|
|
818
841
|
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
819
842
|
const y = -scroll.scrollTop;
|
|
820
843
|
|
|
821
|
-
if (getComputedStyle
|
|
844
|
+
if (getComputedStyle(body || html).direction === 'rtl') {
|
|
822
845
|
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
823
846
|
}
|
|
824
847
|
|
|
@@ -833,7 +856,7 @@ function getDocumentRect(element) {
|
|
|
833
856
|
function getNearestOverflowAncestor(node) {
|
|
834
857
|
const parentNode = getParentNode(node);
|
|
835
858
|
|
|
836
|
-
if (
|
|
859
|
+
if (isLastTraversableNode(parentNode)) {
|
|
837
860
|
// @ts-ignore assume body is always available
|
|
838
861
|
return node.ownerDocument.body;
|
|
839
862
|
}
|
|
@@ -858,7 +881,7 @@ function getOverflowAncestors(node, list) {
|
|
|
858
881
|
const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
|
|
859
882
|
const updatedList = list.concat(target);
|
|
860
883
|
return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
|
|
861
|
-
updatedList.concat(getOverflowAncestors(
|
|
884
|
+
updatedList.concat(getOverflowAncestors(target));
|
|
862
885
|
}
|
|
863
886
|
|
|
864
887
|
function contains(parent, child) {
|
|
@@ -884,6 +907,22 @@ function contains(parent, child) {
|
|
|
884
907
|
return false;
|
|
885
908
|
}
|
|
886
909
|
|
|
910
|
+
function getNearestParentCapableOfEscapingClipping(element, clippingAncestors) {
|
|
911
|
+
let currentNode = element;
|
|
912
|
+
|
|
913
|
+
while (currentNode && !isLastTraversableNode(currentNode) && // @ts-expect-error
|
|
914
|
+
!clippingAncestors.includes(currentNode)) {
|
|
915
|
+
if (isElement(currentNode) && ['absolute', 'fixed'].includes(getComputedStyle(currentNode).position)) {
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
const parentNode = getParentNode(currentNode);
|
|
920
|
+
currentNode = isShadowRoot(parentNode) ? parentNode.host : parentNode;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
return currentNode;
|
|
924
|
+
}
|
|
925
|
+
|
|
887
926
|
function getInnerBoundingClientRect(element, strategy) {
|
|
888
927
|
const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
889
928
|
const top = clientRect.top + element.clientTop;
|
|
@@ -917,15 +956,25 @@ function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
|
|
|
917
956
|
|
|
918
957
|
function getClippingAncestors(element) {
|
|
919
958
|
const clippingAncestors = getOverflowAncestors(element);
|
|
920
|
-
const
|
|
921
|
-
|
|
959
|
+
const nearestEscapableParent = getNearestParentCapableOfEscapingClipping(element, clippingAncestors);
|
|
960
|
+
let clipperElement = null;
|
|
961
|
+
|
|
962
|
+
if (nearestEscapableParent && isHTMLElement(nearestEscapableParent)) {
|
|
963
|
+
const offsetParent = getOffsetParent(nearestEscapableParent);
|
|
964
|
+
|
|
965
|
+
if (isOverflowElement(nearestEscapableParent)) {
|
|
966
|
+
clipperElement = nearestEscapableParent;
|
|
967
|
+
} else if (isHTMLElement(offsetParent)) {
|
|
968
|
+
clipperElement = offsetParent;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
922
971
|
|
|
923
972
|
if (!isElement(clipperElement)) {
|
|
924
973
|
return [];
|
|
925
974
|
} // @ts-ignore isElement check ensures we return Array<Element>
|
|
926
975
|
|
|
927
976
|
|
|
928
|
-
return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
|
|
977
|
+
return clippingAncestors.filter(clippingAncestors => clipperElement && isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
|
|
929
978
|
} // Gets the maximum area that the element is visible in due to any number of
|
|
930
979
|
// clipping ancestors
|
|
931
980
|
|
|
@@ -978,7 +1027,7 @@ const platform = {
|
|
|
978
1027
|
};
|
|
979
1028
|
},
|
|
980
1029
|
getClientRects: element => Array.from(element.getClientRects()),
|
|
981
|
-
isRTL: element => getComputedStyle
|
|
1030
|
+
isRTL: element => getComputedStyle(element).direction === 'rtl'
|
|
982
1031
|
};
|
|
983
1032
|
|
|
984
1033
|
/**
|
|
@@ -992,14 +1041,11 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
992
1041
|
|
|
993
1042
|
const {
|
|
994
1043
|
ancestorScroll: _ancestorScroll = true,
|
|
995
|
-
ancestorResize
|
|
996
|
-
elementResize
|
|
1044
|
+
ancestorResize = true,
|
|
1045
|
+
elementResize = true,
|
|
997
1046
|
animationFrame = false
|
|
998
1047
|
} = options;
|
|
999
|
-
let cleanedUp = false;
|
|
1000
1048
|
const ancestorScroll = _ancestorScroll && !animationFrame;
|
|
1001
|
-
const ancestorResize = _ancestorResize && !animationFrame;
|
|
1002
|
-
const elementResize = _elementResize && !animationFrame;
|
|
1003
1049
|
const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
|
|
1004
1050
|
ancestors.forEach(ancestor => {
|
|
1005
1051
|
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
@@ -1010,8 +1056,15 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1010
1056
|
let observer = null;
|
|
1011
1057
|
|
|
1012
1058
|
if (elementResize) {
|
|
1013
|
-
|
|
1014
|
-
|
|
1059
|
+
let initialUpdate = true;
|
|
1060
|
+
observer = new ResizeObserver(() => {
|
|
1061
|
+
if (!initialUpdate) {
|
|
1062
|
+
update();
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
initialUpdate = false;
|
|
1066
|
+
});
|
|
1067
|
+
isElement(reference) && !animationFrame && observer.observe(reference);
|
|
1015
1068
|
observer.observe(floating);
|
|
1016
1069
|
}
|
|
1017
1070
|
|
|
@@ -1023,10 +1076,6 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1023
1076
|
}
|
|
1024
1077
|
|
|
1025
1078
|
function frameLoop() {
|
|
1026
|
-
if (cleanedUp) {
|
|
1027
|
-
return;
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
1079
|
const nextRefRect = getBoundingClientRect(reference);
|
|
1031
1080
|
|
|
1032
1081
|
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
@@ -1037,10 +1086,10 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1037
1086
|
frameId = requestAnimationFrame(frameLoop);
|
|
1038
1087
|
}
|
|
1039
1088
|
|
|
1089
|
+
update();
|
|
1040
1090
|
return () => {
|
|
1041
1091
|
var _observer;
|
|
1042
1092
|
|
|
1043
|
-
cleanedUp = true;
|
|
1044
1093
|
ancestors.forEach(ancestor => {
|
|
1045
1094
|
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1046
1095
|
ancestorResize && ancestor.removeEventListener('resize', update);
|