@haiilo/catalyst 6.3.1 → 6.3.2
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.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/p-2257ac13.entry.js +10 -0
- package/dist/catalyst/p-2257ac13.entry.js.map +1 -0
- package/dist/catalyst/scss/fonts/_fonts.mixins.lato.scss +36 -18
- package/dist/catalyst/scss/utils/_color.scss +3 -1
- package/dist/catalyst/scss/utils/_typography.mixins.scss +10 -2
- package/dist/catalyst/scss/vendor/_flatpickr.scss +5 -2
- package/dist/cjs/cat-alert_26.cjs.entry.js +513 -240
- package/dist/cjs/cat-alert_26.cjs.entry.js.map +1 -1
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/cat-button/cat-button.css +0 -1
- package/dist/collection/components/cat-datepicker/cat-datepicker.config.js +6 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.config.js.map +1 -1
- package/dist/collection/components/cat-datepicker/cat-datepicker.js +30 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.js.map +1 -1
- package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js +17 -0
- package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js.map +1 -1
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +10 -5
- package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.js +22 -11
- package/dist/collection/components/cat-select/cat-select.js.map +1 -1
- package/dist/collection/components/cat-tabs/cat-tabs.css +7 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +1 -1
- package/dist/collection/scss/fonts/_fonts.mixins.lato.scss +36 -18
- package/dist/collection/scss/utils/_color.scss +3 -1
- package/dist/collection/scss/utils/_typography.mixins.scss +10 -2
- package/dist/collection/scss/vendor/_flatpickr.scss +5 -2
- package/dist/components/cat-button2.js +1 -1
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/cat-datepicker-inline.js +4 -1
- package/dist/components/cat-datepicker-inline.js.map +1 -1
- package/dist/components/cat-datepicker.js +16 -0
- package/dist/components/cat-datepicker.js.map +1 -1
- package/dist/components/cat-datepicker.locale.js +6 -0
- package/dist/components/cat-datepicker.locale.js.map +1 -1
- package/dist/components/cat-dropdown2.js +252 -99
- package/dist/components/cat-dropdown2.js.map +1 -1
- package/dist/components/cat-input2.js.map +1 -1
- package/dist/components/cat-select2.js +21 -10
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-tabs.js +1 -1
- package/dist/components/cat-tabs.js.map +1 -1
- package/dist/components/cat-textarea.js.map +1 -1
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +215 -129
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/esm/cat-alert_26.entry.js +513 -240
- package/dist/esm/cat-alert_26.entry.js.map +1 -1
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/cat-datepicker/cat-datepicker.config.d.ts +3 -0
- package/dist/types/components/cat-datepicker/cat-datepicker.d.ts +7 -0
- package/dist/types/components/cat-datepicker-inline/cat-datepicker-inline.d.ts +6 -0
- package/dist/types/components.d.ts +16 -0
- package/package.json +11 -11
- package/dist/catalyst/p-dfc7c716.entry.js +0 -10
- package/dist/catalyst/p-dfc7c716.entry.js.map +0 -1
|
@@ -676,7 +676,7 @@ const size = function (options) {
|
|
|
676
676
|
|
|
677
677
|
function getWindow(node) {
|
|
678
678
|
var _node$ownerDocument;
|
|
679
|
-
return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
679
|
+
return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
680
680
|
}
|
|
681
681
|
|
|
682
682
|
function getComputedStyle$1(element) {
|
|
@@ -687,22 +687,24 @@ function isNode(value) {
|
|
|
687
687
|
return value instanceof getWindow(value).Node;
|
|
688
688
|
}
|
|
689
689
|
function getNodeName(node) {
|
|
690
|
-
|
|
690
|
+
if (isNode(node)) {
|
|
691
|
+
return (node.nodeName || '').toLowerCase();
|
|
692
|
+
}
|
|
693
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
694
|
+
// returning `#document` an infinite loop won't occur.
|
|
695
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
696
|
+
return '#document';
|
|
691
697
|
}
|
|
692
698
|
|
|
693
699
|
function isHTMLElement(value) {
|
|
694
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
695
|
-
}
|
|
696
|
-
function isElement(value) {
|
|
697
|
-
return value instanceof getWindow(value).Element;
|
|
700
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
698
701
|
}
|
|
699
702
|
function isShadowRoot(node) {
|
|
700
703
|
// Browsers without `ShadowRoot` support.
|
|
701
704
|
if (typeof ShadowRoot === 'undefined') {
|
|
702
705
|
return false;
|
|
703
706
|
}
|
|
704
|
-
|
|
705
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
707
|
+
return node instanceof getWindow(node).ShadowRoot || node instanceof ShadowRoot;
|
|
706
708
|
}
|
|
707
709
|
function isOverflowElement(element) {
|
|
708
710
|
const {
|
|
@@ -721,7 +723,7 @@ function isContainingBlock(element) {
|
|
|
721
723
|
const css = getComputedStyle$1(element);
|
|
722
724
|
|
|
723
725
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
724
|
-
return css.transform !== 'none' || css.perspective !== 'none' || !safari && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !safari && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
|
|
726
|
+
return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !safari && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !safari && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
|
|
725
727
|
}
|
|
726
728
|
function isSafari() {
|
|
727
729
|
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
@@ -734,6 +736,11 @@ function isLastTraversableNode(node) {
|
|
|
734
736
|
const min = Math.min;
|
|
735
737
|
const max = Math.max;
|
|
736
738
|
const round = Math.round;
|
|
739
|
+
const floor = Math.floor;
|
|
740
|
+
const createCoords = v => ({
|
|
741
|
+
x: v,
|
|
742
|
+
y: v
|
|
743
|
+
});
|
|
737
744
|
|
|
738
745
|
function getCssDimensions(element) {
|
|
739
746
|
const css = getComputedStyle$1(element);
|
|
@@ -752,31 +759,31 @@ function getCssDimensions(element) {
|
|
|
752
759
|
return {
|
|
753
760
|
width,
|
|
754
761
|
height,
|
|
755
|
-
|
|
762
|
+
$: shouldFallback
|
|
756
763
|
};
|
|
757
764
|
}
|
|
758
765
|
|
|
766
|
+
function isElement(value) {
|
|
767
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
768
|
+
}
|
|
769
|
+
|
|
759
770
|
function unwrapElement(element) {
|
|
760
771
|
return !isElement(element) ? element.contextElement : element;
|
|
761
772
|
}
|
|
762
773
|
|
|
763
|
-
const FALLBACK_SCALE = {
|
|
764
|
-
x: 1,
|
|
765
|
-
y: 1
|
|
766
|
-
};
|
|
767
774
|
function getScale(element) {
|
|
768
775
|
const domElement = unwrapElement(element);
|
|
769
776
|
if (!isHTMLElement(domElement)) {
|
|
770
|
-
return
|
|
777
|
+
return createCoords(1);
|
|
771
778
|
}
|
|
772
779
|
const rect = domElement.getBoundingClientRect();
|
|
773
780
|
const {
|
|
774
781
|
width,
|
|
775
782
|
height,
|
|
776
|
-
|
|
783
|
+
$
|
|
777
784
|
} = getCssDimensions(domElement);
|
|
778
|
-
let x = (
|
|
779
|
-
let y = (
|
|
785
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
786
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
780
787
|
|
|
781
788
|
// 0, NaN, or Infinity should always fallback to 1.
|
|
782
789
|
|
|
@@ -792,27 +799,26 @@ function getScale(element) {
|
|
|
792
799
|
};
|
|
793
800
|
}
|
|
794
801
|
|
|
795
|
-
const noOffsets =
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
function getVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
800
|
-
var _win$visualViewport, _win$visualViewport2;
|
|
801
|
-
if (isFixed === void 0) {
|
|
802
|
-
isFixed = true;
|
|
803
|
-
}
|
|
804
|
-
if (!isSafari()) {
|
|
805
|
-
return noOffsets;
|
|
806
|
-
}
|
|
807
|
-
const win = element ? getWindow(element) : window;
|
|
808
|
-
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== win) {
|
|
802
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
803
|
+
function getVisualOffsets(element) {
|
|
804
|
+
const win = getWindow(element);
|
|
805
|
+
if (!isSafari() || !win.visualViewport) {
|
|
809
806
|
return noOffsets;
|
|
810
807
|
}
|
|
811
808
|
return {
|
|
812
|
-
x:
|
|
813
|
-
y:
|
|
809
|
+
x: win.visualViewport.offsetLeft,
|
|
810
|
+
y: win.visualViewport.offsetTop
|
|
814
811
|
};
|
|
815
812
|
}
|
|
813
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
814
|
+
if (isFixed === void 0) {
|
|
815
|
+
isFixed = false;
|
|
816
|
+
}
|
|
817
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
820
|
+
return isFixed;
|
|
821
|
+
}
|
|
816
822
|
|
|
817
823
|
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
818
824
|
if (includeScale === void 0) {
|
|
@@ -823,7 +829,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
823
829
|
}
|
|
824
830
|
const clientRect = element.getBoundingClientRect();
|
|
825
831
|
const domElement = unwrapElement(element);
|
|
826
|
-
let scale =
|
|
832
|
+
let scale = createCoords(1);
|
|
827
833
|
if (includeScale) {
|
|
828
834
|
if (offsetParent) {
|
|
829
835
|
if (isElement(offsetParent)) {
|
|
@@ -833,7 +839,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
833
839
|
scale = getScale(element);
|
|
834
840
|
}
|
|
835
841
|
}
|
|
836
|
-
const visualOffsets =
|
|
842
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
837
843
|
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
838
844
|
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
839
845
|
let width = clientRect.width / scale.x;
|
|
@@ -846,14 +852,14 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
846
852
|
const iframeScale = getScale(currentIFrame);
|
|
847
853
|
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
848
854
|
const css = getComputedStyle(currentIFrame);
|
|
849
|
-
iframeRect.
|
|
850
|
-
iframeRect.
|
|
855
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
856
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
851
857
|
x *= iframeScale.x;
|
|
852
858
|
y *= iframeScale.y;
|
|
853
859
|
width *= iframeScale.x;
|
|
854
860
|
height *= iframeScale.y;
|
|
855
|
-
x +=
|
|
856
|
-
y +=
|
|
861
|
+
x += left;
|
|
862
|
+
y += top;
|
|
857
863
|
currentIFrame = getWindow(currentIFrame).frameElement;
|
|
858
864
|
}
|
|
859
865
|
}
|
|
@@ -865,10 +871,6 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
865
871
|
});
|
|
866
872
|
}
|
|
867
873
|
|
|
868
|
-
function getDocumentElement(node) {
|
|
869
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
874
|
function getNodeScroll(element) {
|
|
873
875
|
if (isElement(element)) {
|
|
874
876
|
return {
|
|
@@ -882,6 +884,11 @@ function getNodeScroll(element) {
|
|
|
882
884
|
};
|
|
883
885
|
}
|
|
884
886
|
|
|
887
|
+
function getDocumentElement(node) {
|
|
888
|
+
var _ref;
|
|
889
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
890
|
+
}
|
|
891
|
+
|
|
885
892
|
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
886
893
|
let {
|
|
887
894
|
rect,
|
|
@@ -897,14 +904,8 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
897
904
|
scrollLeft: 0,
|
|
898
905
|
scrollTop: 0
|
|
899
906
|
};
|
|
900
|
-
let scale =
|
|
901
|
-
|
|
902
|
-
y: 1
|
|
903
|
-
};
|
|
904
|
-
const offsets = {
|
|
905
|
-
x: 0,
|
|
906
|
-
y: 0
|
|
907
|
-
};
|
|
907
|
+
let scale = createCoords(1);
|
|
908
|
+
const offsets = createCoords(0);
|
|
908
909
|
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
909
910
|
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
910
911
|
scroll = getNodeScroll(offsetParent);
|
|
@@ -924,6 +925,10 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
924
925
|
};
|
|
925
926
|
}
|
|
926
927
|
|
|
928
|
+
function getClientRects(element) {
|
|
929
|
+
return Array.from(element.getClientRects());
|
|
930
|
+
}
|
|
931
|
+
|
|
927
932
|
function getWindowScrollBarX(element) {
|
|
928
933
|
// If <html> has a CSS width greater than the viewport, then this will be
|
|
929
934
|
// incorrect for RTL.
|
|
@@ -970,9 +975,7 @@ function getParentNode(node) {
|
|
|
970
975
|
function getNearestOverflowAncestor(node) {
|
|
971
976
|
const parentNode = getParentNode(node);
|
|
972
977
|
if (isLastTraversableNode(parentNode)) {
|
|
973
|
-
|
|
974
|
-
// check, so it's either the <html> or <body> element.
|
|
975
|
-
return parentNode.ownerDocument.body;
|
|
978
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
976
979
|
}
|
|
977
980
|
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
978
981
|
return parentNode;
|
|
@@ -1024,10 +1027,7 @@ function getInnerBoundingClientRect(element, strategy) {
|
|
|
1024
1027
|
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1025
1028
|
const top = clientRect.top + element.clientTop;
|
|
1026
1029
|
const left = clientRect.left + element.clientLeft;
|
|
1027
|
-
const scale = isHTMLElement(element) ? getScale(element) :
|
|
1028
|
-
x: 1,
|
|
1029
|
-
y: 1
|
|
1030
|
-
};
|
|
1030
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1031
1031
|
const width = element.clientWidth * scale.x;
|
|
1032
1032
|
const height = element.clientHeight * scale.y;
|
|
1033
1033
|
const x = left * scale.x;
|
|
@@ -1131,6 +1131,36 @@ function getDimensions(element) {
|
|
|
1131
1131
|
return getCssDimensions(element);
|
|
1132
1132
|
}
|
|
1133
1133
|
|
|
1134
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1135
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1136
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1137
|
+
const isFixed = strategy === 'fixed';
|
|
1138
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1139
|
+
let scroll = {
|
|
1140
|
+
scrollLeft: 0,
|
|
1141
|
+
scrollTop: 0
|
|
1142
|
+
};
|
|
1143
|
+
const offsets = createCoords(0);
|
|
1144
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1145
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1146
|
+
scroll = getNodeScroll(offsetParent);
|
|
1147
|
+
}
|
|
1148
|
+
if (isHTMLElement(offsetParent)) {
|
|
1149
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1150
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1151
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1152
|
+
} else if (documentElement) {
|
|
1153
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
return {
|
|
1157
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1158
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1159
|
+
width: rect.width,
|
|
1160
|
+
height: rect.height
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1134
1164
|
function getTrueOffsetParent(element, polyfill) {
|
|
1135
1165
|
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
1136
1166
|
return null;
|
|
@@ -1169,68 +1199,115 @@ function getOffsetParent(element, polyfill) {
|
|
|
1169
1199
|
return offsetParent || getContainingBlock(element) || window;
|
|
1170
1200
|
}
|
|
1171
1201
|
|
|
1172
|
-
function
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
};
|
|
1181
|
-
const offsets = {
|
|
1182
|
-
x: 0,
|
|
1183
|
-
y: 0
|
|
1184
|
-
};
|
|
1185
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1186
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1187
|
-
scroll = getNodeScroll(offsetParent);
|
|
1188
|
-
}
|
|
1189
|
-
if (isHTMLElement(offsetParent)) {
|
|
1190
|
-
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1191
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1192
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1193
|
-
} else if (documentElement) {
|
|
1194
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1202
|
+
const getElementRects = async function (_ref) {
|
|
1203
|
+
let {
|
|
1204
|
+
reference,
|
|
1205
|
+
floating,
|
|
1206
|
+
strategy
|
|
1207
|
+
} = _ref;
|
|
1208
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1209
|
+
const getDimensionsFn = this.getDimensions;
|
|
1197
1210
|
return {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1211
|
+
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1212
|
+
floating: {
|
|
1213
|
+
x: 0,
|
|
1214
|
+
y: 0,
|
|
1215
|
+
...(await getDimensionsFn(floating))
|
|
1216
|
+
}
|
|
1202
1217
|
};
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
function isRTL(element) {
|
|
1221
|
+
return getComputedStyle(element).direction === 'rtl';
|
|
1203
1222
|
}
|
|
1204
1223
|
|
|
1205
1224
|
const platform = {
|
|
1206
|
-
getClippingRect,
|
|
1207
1225
|
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1208
|
-
isElement,
|
|
1209
|
-
getDimensions,
|
|
1210
|
-
getOffsetParent,
|
|
1211
1226
|
getDocumentElement,
|
|
1227
|
+
getClippingRect,
|
|
1228
|
+
getOffsetParent,
|
|
1229
|
+
getElementRects,
|
|
1230
|
+
getClientRects,
|
|
1231
|
+
getDimensions,
|
|
1212
1232
|
getScale,
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
reference,
|
|
1216
|
-
floating,
|
|
1217
|
-
strategy
|
|
1218
|
-
} = _ref;
|
|
1219
|
-
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1220
|
-
const getDimensionsFn = this.getDimensions;
|
|
1221
|
-
return {
|
|
1222
|
-
reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
|
|
1223
|
-
floating: {
|
|
1224
|
-
x: 0,
|
|
1225
|
-
y: 0,
|
|
1226
|
-
...(await getDimensionsFn(floating))
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
},
|
|
1230
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
1231
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
1233
|
+
isElement,
|
|
1234
|
+
isRTL
|
|
1232
1235
|
};
|
|
1233
1236
|
|
|
1237
|
+
// https://samthor.au/2021/observing-dom/
|
|
1238
|
+
function observeMove(element, onMove) {
|
|
1239
|
+
let io = null;
|
|
1240
|
+
let timeoutId;
|
|
1241
|
+
const root = getDocumentElement(element);
|
|
1242
|
+
function cleanup() {
|
|
1243
|
+
clearTimeout(timeoutId);
|
|
1244
|
+
io && io.disconnect();
|
|
1245
|
+
io = null;
|
|
1246
|
+
}
|
|
1247
|
+
function refresh(skip, threshold) {
|
|
1248
|
+
if (skip === void 0) {
|
|
1249
|
+
skip = false;
|
|
1250
|
+
}
|
|
1251
|
+
if (threshold === void 0) {
|
|
1252
|
+
threshold = 1;
|
|
1253
|
+
}
|
|
1254
|
+
cleanup();
|
|
1255
|
+
const {
|
|
1256
|
+
left,
|
|
1257
|
+
top,
|
|
1258
|
+
width,
|
|
1259
|
+
height
|
|
1260
|
+
} = element.getBoundingClientRect();
|
|
1261
|
+
if (!skip) {
|
|
1262
|
+
onMove();
|
|
1263
|
+
}
|
|
1264
|
+
if (!width || !height) {
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
const insetTop = floor(top);
|
|
1268
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
1269
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
1270
|
+
const insetLeft = floor(left);
|
|
1271
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
1272
|
+
const options = {
|
|
1273
|
+
rootMargin,
|
|
1274
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
1275
|
+
};
|
|
1276
|
+
let isFirstUpdate = true;
|
|
1277
|
+
function handleObserve(entries) {
|
|
1278
|
+
const ratio = entries[0].intersectionRatio;
|
|
1279
|
+
if (ratio !== threshold) {
|
|
1280
|
+
if (!isFirstUpdate) {
|
|
1281
|
+
return refresh();
|
|
1282
|
+
}
|
|
1283
|
+
if (!ratio) {
|
|
1284
|
+
timeoutId = setTimeout(() => {
|
|
1285
|
+
refresh(false, 1e-7);
|
|
1286
|
+
}, 100);
|
|
1287
|
+
} else {
|
|
1288
|
+
refresh(false, ratio);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
isFirstUpdate = false;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
1295
|
+
// error.
|
|
1296
|
+
try {
|
|
1297
|
+
io = new IntersectionObserver(handleObserve, {
|
|
1298
|
+
...options,
|
|
1299
|
+
// Handle <iframe>s
|
|
1300
|
+
root: root.ownerDocument
|
|
1301
|
+
});
|
|
1302
|
+
} catch (e) {
|
|
1303
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
1304
|
+
}
|
|
1305
|
+
io.observe(element);
|
|
1306
|
+
}
|
|
1307
|
+
refresh(true);
|
|
1308
|
+
return cleanup;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1234
1311
|
/**
|
|
1235
1312
|
* Automatically updates the position of the floating element when necessary.
|
|
1236
1313
|
* Should only be called when the floating element is mounted on the DOM or
|
|
@@ -1246,30 +1323,39 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1246
1323
|
const {
|
|
1247
1324
|
ancestorScroll = true,
|
|
1248
1325
|
ancestorResize = true,
|
|
1249
|
-
elementResize =
|
|
1326
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
1327
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
1250
1328
|
animationFrame = false
|
|
1251
1329
|
} = options;
|
|
1252
|
-
const
|
|
1330
|
+
const referenceEl = unwrapElement(reference);
|
|
1331
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
1253
1332
|
ancestors.forEach(ancestor => {
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
ancestor.addEventListener('scroll', update, {
|
|
1258
|
-
passive: true
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1333
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1334
|
+
passive: true
|
|
1335
|
+
});
|
|
1261
1336
|
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1262
1337
|
});
|
|
1263
|
-
|
|
1338
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
1339
|
+
let reobserveFrame = -1;
|
|
1340
|
+
let resizeObserver = null;
|
|
1264
1341
|
if (elementResize) {
|
|
1265
|
-
|
|
1342
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
1343
|
+
let [firstEntry] = _ref;
|
|
1344
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
1345
|
+
// Prevent update loops when using the `size` middleware.
|
|
1346
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
1347
|
+
resizeObserver.unobserve(floating);
|
|
1348
|
+
cancelAnimationFrame(reobserveFrame);
|
|
1349
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
1350
|
+
resizeObserver && resizeObserver.observe(floating);
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1266
1353
|
update();
|
|
1267
1354
|
});
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
observer.observe(reference.contextElement);
|
|
1355
|
+
if (referenceEl && !animationFrame) {
|
|
1356
|
+
resizeObserver.observe(referenceEl);
|
|
1271
1357
|
}
|
|
1272
|
-
|
|
1358
|
+
resizeObserver.observe(floating);
|
|
1273
1359
|
}
|
|
1274
1360
|
let frameId;
|
|
1275
1361
|
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
@@ -1286,13 +1372,13 @@ function autoUpdate(reference, floating, update, options) {
|
|
|
1286
1372
|
}
|
|
1287
1373
|
update();
|
|
1288
1374
|
return () => {
|
|
1289
|
-
var _observer;
|
|
1290
1375
|
ancestors.forEach(ancestor => {
|
|
1291
1376
|
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1292
1377
|
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1293
1378
|
});
|
|
1294
|
-
|
|
1295
|
-
|
|
1379
|
+
cleanupIo && cleanupIo();
|
|
1380
|
+
resizeObserver && resizeObserver.disconnect();
|
|
1381
|
+
resizeObserver = null;
|
|
1296
1382
|
if (animationFrame) {
|
|
1297
1383
|
cancelAnimationFrame(frameId);
|
|
1298
1384
|
}
|