@hanzogui/floating 3.0.5 → 4.3.1
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/Floating.cjs +7 -5
- package/dist/cjs/Floating.native.js +18 -16
- package/dist/cjs/Floating.native.js.map +1 -1
- package/dist/cjs/index.cjs +28 -26
- package/dist/cjs/index.native.js +28 -26
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/interactions/PopupTriggerMap.cjs +21 -12
- package/dist/cjs/interactions/PopupTriggerMap.native.js +51 -27
- package/dist/cjs/interactions/PopupTriggerMap.native.js.map +1 -1
- package/dist/cjs/interactions/createFloatingEvents.cjs +21 -12
- package/dist/cjs/interactions/createFloatingEvents.native.js +22 -13
- package/dist/cjs/interactions/createFloatingEvents.native.js.map +1 -1
- package/dist/cjs/interactions/safePolygon.cjs +213 -131
- package/dist/cjs/interactions/safePolygon.native.js +182 -103
- package/dist/cjs/interactions/safePolygon.native.js.map +1 -1
- package/dist/cjs/interactions/types.cjs +7 -5
- package/dist/cjs/interactions/types.native.js +7 -5
- package/dist/cjs/interactions/types.native.js.map +1 -1
- package/dist/cjs/interactions/useClick.cjs +91 -49
- package/dist/cjs/interactions/useClick.native.js +96 -54
- package/dist/cjs/interactions/useClick.native.js.map +1 -1
- package/dist/cjs/interactions/useDelayGroup.cjs +63 -44
- package/dist/cjs/interactions/useDelayGroup.native.js +74 -58
- package/dist/cjs/interactions/useDelayGroup.native.js.map +1 -1
- package/dist/cjs/interactions/useFocus.cjs +73 -44
- package/dist/cjs/interactions/useFocus.native.js +75 -49
- package/dist/cjs/interactions/useFocus.native.js.map +1 -1
- package/dist/cjs/interactions/useHover.cjs +242 -109
- package/dist/cjs/interactions/useHover.native.js +268 -143
- package/dist/cjs/interactions/useHover.native.js.map +1 -1
- package/dist/cjs/interactions/useInnerOffset.cjs +88 -64
- package/dist/cjs/interactions/useInnerOffset.native.js +88 -65
- package/dist/cjs/interactions/useInnerOffset.native.js.map +1 -1
- package/dist/cjs/interactions/useInteractions.cjs +60 -31
- package/dist/cjs/interactions/useInteractions.native.js +133 -81
- package/dist/cjs/interactions/useInteractions.native.js.map +1 -1
- package/dist/cjs/interactions/useListNavigation.cjs +346 -181
- package/dist/cjs/interactions/useListNavigation.native.js +350 -214
- package/dist/cjs/interactions/useListNavigation.native.js.map +1 -1
- package/dist/cjs/interactions/useRole.cjs +83 -73
- package/dist/cjs/interactions/useRole.native.js +107 -99
- package/dist/cjs/interactions/useRole.native.js.map +1 -1
- package/dist/cjs/interactions/useTypeahead.cjs +115 -65
- package/dist/cjs/interactions/useTypeahead.native.js +122 -77
- package/dist/cjs/interactions/useTypeahead.native.js.map +1 -1
- package/dist/cjs/interactions/utils.cjs +68 -38
- package/dist/cjs/interactions/utils.native.js +93 -54
- package/dist/cjs/interactions/utils.native.js.map +1 -1
- package/dist/cjs/middleware/inner.cjs +80 -67
- package/dist/cjs/middleware/inner.native.js +87 -76
- package/dist/cjs/middleware/inner.native.js.map +1 -1
- package/dist/cjs/useFloating.cjs +48 -45
- package/dist/cjs/useFloating.native.js +50 -48
- package/dist/cjs/useFloating.native.js.map +1 -1
- package/dist/esm/Floating.native.js +5 -5
- package/dist/esm/Floating.native.js.map +1 -1
- package/dist/esm/interactions/PopupTriggerMap.mjs +9 -2
- package/dist/esm/interactions/PopupTriggerMap.mjs.map +1 -1
- package/dist/esm/interactions/PopupTriggerMap.native.js +39 -17
- package/dist/esm/interactions/PopupTriggerMap.native.js.map +1 -1
- package/dist/esm/interactions/createFloatingEvents.mjs +9 -2
- package/dist/esm/interactions/createFloatingEvents.mjs.map +1 -1
- package/dist/esm/interactions/createFloatingEvents.native.js +10 -3
- package/dist/esm/interactions/createFloatingEvents.native.js.map +1 -1
- package/dist/esm/interactions/safePolygon.mjs +201 -121
- package/dist/esm/interactions/safePolygon.mjs.map +1 -1
- package/dist/esm/interactions/safePolygon.native.js +170 -93
- package/dist/esm/interactions/safePolygon.native.js.map +1 -1
- package/dist/esm/interactions/useClick.mjs +79 -39
- package/dist/esm/interactions/useClick.mjs.map +1 -1
- package/dist/esm/interactions/useClick.native.js +82 -42
- package/dist/esm/interactions/useClick.native.js.map +1 -1
- package/dist/esm/interactions/useDelayGroup.mjs +39 -22
- package/dist/esm/interactions/useDelayGroup.mjs.map +1 -1
- package/dist/esm/interactions/useDelayGroup.native.js +42 -28
- package/dist/esm/interactions/useDelayGroup.native.js.map +1 -1
- package/dist/esm/interactions/useFocus.mjs +59 -32
- package/dist/esm/interactions/useFocus.mjs.map +1 -1
- package/dist/esm/interactions/useFocus.native.js +61 -37
- package/dist/esm/interactions/useFocus.native.js.map +1 -1
- package/dist/esm/interactions/useHover.mjs +215 -84
- package/dist/esm/interactions/useHover.mjs.map +1 -1
- package/dist/esm/interactions/useHover.native.js +240 -117
- package/dist/esm/interactions/useHover.native.js.map +1 -1
- package/dist/esm/interactions/useInnerOffset.mjs +61 -39
- package/dist/esm/interactions/useInnerOffset.mjs.map +1 -1
- package/dist/esm/interactions/useInnerOffset.native.js +61 -40
- package/dist/esm/interactions/useInnerOffset.native.js.map +1 -1
- package/dist/esm/interactions/useInteractions.mjs +48 -21
- package/dist/esm/interactions/useInteractions.mjs.map +1 -1
- package/dist/esm/interactions/useInteractions.native.js +121 -71
- package/dist/esm/interactions/useInteractions.native.js.map +1 -1
- package/dist/esm/interactions/useListNavigation.mjs +331 -168
- package/dist/esm/interactions/useListNavigation.mjs.map +1 -1
- package/dist/esm/interactions/useListNavigation.native.js +335 -201
- package/dist/esm/interactions/useListNavigation.native.js.map +1 -1
- package/dist/esm/interactions/useRole.mjs +59 -51
- package/dist/esm/interactions/useRole.mjs.map +1 -1
- package/dist/esm/interactions/useRole.native.js +82 -76
- package/dist/esm/interactions/useRole.native.js.map +1 -1
- package/dist/esm/interactions/useTypeahead.mjs +100 -52
- package/dist/esm/interactions/useTypeahead.mjs.map +1 -1
- package/dist/esm/interactions/useTypeahead.native.js +107 -64
- package/dist/esm/interactions/useTypeahead.native.js.map +1 -1
- package/dist/esm/interactions/utils.mjs +56 -28
- package/dist/esm/interactions/utils.mjs.map +1 -1
- package/dist/esm/interactions/utils.native.js +81 -44
- package/dist/esm/interactions/utils.native.js.map +1 -1
- package/dist/esm/middleware/inner.mjs +54 -43
- package/dist/esm/middleware/inner.mjs.map +1 -1
- package/dist/esm/middleware/inner.native.js +61 -52
- package/dist/esm/middleware/inner.native.js.map +1 -1
- package/dist/esm/useFloating.mjs +22 -21
- package/dist/esm/useFloating.mjs.map +1 -1
- package/dist/esm/useFloating.native.js +24 -24
- package/dist/esm/useFloating.native.js.map +1 -1
- package/package.json +3 -3
|
@@ -2,40 +2,42 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var inner_exports = {};
|
|
33
35
|
__export(inner_exports, {
|
|
34
36
|
inner: () => inner
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(inner_exports);
|
|
37
|
-
var ReactDOM = __toESM(require("react-dom"), 1)
|
|
38
|
-
|
|
39
|
+
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
40
|
+
var import_react_dom = require("@floating-ui/react-dom");
|
|
39
41
|
function getArgsWithCustomFloatingHeight(state, height) {
|
|
40
42
|
return {
|
|
41
43
|
...state,
|
|
@@ -53,53 +55,64 @@ const inner = props => ({
|
|
|
53
55
|
options: props,
|
|
54
56
|
async fn(state) {
|
|
55
57
|
const {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (!item || index == null)
|
|
58
|
+
listRef,
|
|
59
|
+
overflowRef,
|
|
60
|
+
onFallbackChange,
|
|
61
|
+
offset: innerOffset = 0,
|
|
62
|
+
index = 0,
|
|
63
|
+
minItemsVisible = 4,
|
|
64
|
+
referenceOverflowThreshold = 0,
|
|
65
|
+
scrollRef,
|
|
66
|
+
padding = 0
|
|
67
|
+
} = props;
|
|
68
|
+
const {
|
|
69
|
+
rects,
|
|
70
|
+
platform,
|
|
71
|
+
elements: {
|
|
72
|
+
floating
|
|
73
|
+
}
|
|
74
|
+
} = state;
|
|
75
|
+
const item = listRef.current?.[index ?? 0];
|
|
76
|
+
const scrollEl = scrollRef?.current || floating;
|
|
77
|
+
const clientTop = floating.clientTop || scrollEl.clientTop;
|
|
78
|
+
const floatingIsBordered = floating.clientTop !== 0;
|
|
79
|
+
const scrollElIsBordered = scrollEl.clientTop !== 0;
|
|
80
|
+
const floatingIsScrollEl = floating === scrollEl;
|
|
81
|
+
if (!item || index == null) {
|
|
82
|
+
onFallbackChange?.(true);
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
80
85
|
const nextArgs = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
...state,
|
|
87
|
+
...(await (0, import_react_dom.offset)(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state))
|
|
88
|
+
};
|
|
89
|
+
const detectOverflowOptions = {
|
|
90
|
+
padding
|
|
91
|
+
};
|
|
92
|
+
const overflow = await platform.detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);
|
|
93
|
+
const refOverflow = await platform.detectOverflow(nextArgs, {
|
|
94
|
+
...detectOverflowOptions,
|
|
95
|
+
elementContext: "reference"
|
|
96
|
+
});
|
|
97
|
+
const diffY = Math.max(0, overflow.top);
|
|
98
|
+
const nextY = nextArgs.y + diffY;
|
|
99
|
+
const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
|
|
100
|
+
const rounder = isScrollable ? v => v : Math.round;
|
|
101
|
+
const maxHeight = rounder(Math.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)));
|
|
102
|
+
scrollEl.style.maxHeight = `${maxHeight}px`;
|
|
103
|
+
scrollEl.scrollTop = diffY;
|
|
104
|
+
if (onFallbackChange) {
|
|
96
105
|
const shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, listRef.current?.length ?? 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
|
|
97
106
|
ReactDOM.flushSync(() => onFallbackChange(shouldFallback));
|
|
98
107
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
if (overflowRef) {
|
|
109
|
+
;
|
|
110
|
+
overflowRef.current = await platform.detectOverflow(getArgsWithCustomFloatingHeight({
|
|
111
|
+
...nextArgs,
|
|
112
|
+
y: nextY
|
|
113
|
+
}, scrollEl.offsetHeight + clientTop + floating.clientTop), detectOverflowOptions);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
103
116
|
y: nextY
|
|
104
117
|
};
|
|
105
118
|
}
|
|
@@ -4,40 +4,42 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var inner_exports = {};
|
|
35
37
|
__export(inner_exports, {
|
|
36
38
|
inner: () => inner
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(inner_exports);
|
|
39
|
-
var ReactDOM = __toESM(require("react-dom"), 1)
|
|
40
|
-
|
|
41
|
+
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
42
|
+
var import_react_dom = require("@floating-ui/react-dom");
|
|
41
43
|
function getArgsWithCustomFloatingHeight(state, height) {
|
|
42
44
|
return {
|
|
43
45
|
...state,
|
|
@@ -55,63 +57,72 @@ var inner = function (props) {
|
|
|
55
57
|
name: "inner",
|
|
56
58
|
options: props,
|
|
57
59
|
async fn(state) {
|
|
58
|
-
var _listRef_current
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!item || index == null)
|
|
60
|
+
var _listRef_current;
|
|
61
|
+
var {
|
|
62
|
+
listRef,
|
|
63
|
+
overflowRef,
|
|
64
|
+
onFallbackChange,
|
|
65
|
+
offset: innerOffset = 0,
|
|
66
|
+
index = 0,
|
|
67
|
+
minItemsVisible = 4,
|
|
68
|
+
referenceOverflowThreshold = 0,
|
|
69
|
+
scrollRef,
|
|
70
|
+
padding = 0
|
|
71
|
+
} = props;
|
|
72
|
+
var {
|
|
73
|
+
rects,
|
|
74
|
+
platform,
|
|
75
|
+
elements: {
|
|
76
|
+
floating
|
|
77
|
+
}
|
|
78
|
+
} = state;
|
|
79
|
+
var item = (_listRef_current = listRef.current) === null || _listRef_current === void 0 ? void 0 : _listRef_current[index !== null && index !== void 0 ? index : 0];
|
|
80
|
+
var scrollEl = (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) || floating;
|
|
81
|
+
var clientTop = floating.clientTop || scrollEl.clientTop;
|
|
82
|
+
var floatingIsBordered = floating.clientTop !== 0;
|
|
83
|
+
var scrollElIsBordered = scrollEl.clientTop !== 0;
|
|
84
|
+
var floatingIsScrollEl = floating === scrollEl;
|
|
85
|
+
if (!item || index == null) {
|
|
86
|
+
onFallbackChange === null || onFallbackChange === void 0 ? void 0 : onFallbackChange(true);
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
84
89
|
var nextArgs = {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
...state,
|
|
91
|
+
...(await (0, import_react_dom.offset)(-item.offsetTop - floating.clientTop - rects.reference.height / 2 - item.offsetHeight / 2 - innerOffset).fn(state))
|
|
92
|
+
};
|
|
93
|
+
var detectOverflowOptions = {
|
|
94
|
+
padding
|
|
95
|
+
};
|
|
96
|
+
var overflow = await platform.detectOverflow(getArgsWithCustomFloatingHeight(nextArgs, scrollEl.scrollHeight + clientTop + floating.clientTop), detectOverflowOptions);
|
|
97
|
+
var refOverflow = await platform.detectOverflow(nextArgs, {
|
|
98
|
+
...detectOverflowOptions,
|
|
99
|
+
elementContext: "reference"
|
|
100
|
+
});
|
|
101
|
+
var diffY = Math.max(0, overflow.top);
|
|
102
|
+
var nextY = nextArgs.y + diffY;
|
|
103
|
+
var isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
|
|
104
|
+
var rounder = isScrollable ? function (v) {
|
|
105
|
+
return v;
|
|
106
|
+
} : Math.round;
|
|
107
|
+
var maxHeight = rounder(Math.max(0, scrollEl.scrollHeight + (floatingIsBordered && floatingIsScrollEl || scrollElIsBordered ? clientTop * 2 : 0) - diffY - Math.max(0, overflow.bottom)));
|
|
108
|
+
scrollEl.style.maxHeight = `${maxHeight}px`;
|
|
109
|
+
scrollEl.scrollTop = diffY;
|
|
110
|
+
if (onFallbackChange) {
|
|
111
|
+
var _listRef_current1;
|
|
112
|
+
var _listRef_current_length;
|
|
113
|
+
var shouldFallback = scrollEl.offsetHeight < item.offsetHeight * Math.min(minItemsVisible, (_listRef_current_length = (_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 ? void 0 : _listRef_current1.length) !== null && _listRef_current_length !== void 0 ? _listRef_current_length : 0) - 1 || refOverflow.top >= -referenceOverflowThreshold || refOverflow.bottom >= -referenceOverflowThreshold;
|
|
107
114
|
ReactDOM.flushSync(function () {
|
|
108
115
|
return onFallbackChange(shouldFallback);
|
|
109
116
|
});
|
|
110
117
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
if (overflowRef) {
|
|
119
|
+
;
|
|
120
|
+
overflowRef.current = await platform.detectOverflow(getArgsWithCustomFloatingHeight({
|
|
121
|
+
...nextArgs,
|
|
122
|
+
y: nextY
|
|
123
|
+
}, scrollEl.offsetHeight + clientTop + floating.clientTop), detectOverflowOptions);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
115
126
|
y: nextY
|
|
116
127
|
};
|
|
117
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","inner_exports","__export","inner","module","exports","ReactDOM","__toESM","require","import_react_dom","getArgsWithCustomFloatingHeight","state","height","rects","floating","props","name","options","fn","_listRef_current","listRef","overflowRef","onFallbackChange","offset","innerOffset","index","minItemsVisible","referenceOverflowThreshold","scrollRef","padding","platform","elements","item","current","scrollEl","clientTop","floatingIsBordered","scrollElIsBordered","floatingIsScrollEl","nextArgs","offsetTop","reference","offsetHeight","detectOverflowOptions","overflow","detectOverflow","scrollHeight","refOverflow","elementContext","diffY","Math","max","top","nextY","y","isScrollable","clientHeight","rounder","v","round","maxHeight","bottom","style","scrollTop","_listRef_current1","_listRef_current_length","shouldFallback","min","length","flushSync"],"sources":["../../../src/middleware/inner.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","inner_exports","__export","inner","module","exports","ReactDOM","__toESM","require","import_react_dom","getArgsWithCustomFloatingHeight","state","height","rects","floating","props","name","options","fn","_listRef_current","listRef","overflowRef","onFallbackChange","offset","innerOffset","index","minItemsVisible","referenceOverflowThreshold","scrollRef","padding","platform","elements","item","current","scrollEl","clientTop","floatingIsBordered","scrollElIsBordered","floatingIsScrollEl","nextArgs","offsetTop","reference","offsetHeight","detectOverflowOptions","overflow","detectOverflow","scrollHeight","refOverflow","elementContext","diffY","Math","max","top","nextY","y","isScrollable","clientHeight","rounder","v","round","maxHeight","bottom","style","scrollTop","_listRef_current1","_listRef_current_length","shouldFallback","min","length","flushSync"],"sources":["../../../src/middleware/inner.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,KAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAA0BT,YAAA,CAAAK,aAAA;AAC1B,IAAAK,QAAA,GAAAC,OAAA,CAAuBC,OAAA;AAkBvB,IAAAC,gBAAS,GAAAD,OAAA,yBAAwD,CAAgB;AAC/E,SAAOE,gCAAAC,KAAA,EAAAC,MAAA;EAAA,OACF;IACH,GAAAD,KAAO;IAAAE,KACF;MACH,GAAAF,KAAA,CAAAE,KAAU;MAAAC,QACL;QACH,GAAAH,KAAA,CAAAE,KAAA,CAAAC,QAAA;QACFF;MACF;IACF;EACF;AAEO;AA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AEArB,QAAM,CAAA+D,SAAc,aAAM;UACrB,OAAA/C,gBAAA,CAAA4C,cAAA;QACH;MACD;MAED,IAAM7C,WAAQ,EAAK;QACnB;QACAA,WAAM,CAAAY,OAAe,SAASH,QAAA,CAAAe,cAAwB,CAAAnC,+BAAA;UAChD,GAAA6B,QAAU;UAEVe,CAAA,EAAAD;QACJ,GAAKnB,QAAA,CAAAQ,YAAA,GAAAP,SAAA,GAAArB,QAAA,CAAAqB,SAAA,GAAAQ,qBAAA;MAAA;MACH,OACA;QAMFW,CAAA,EAAAD;MACF;IAEA;EACA;AAGA","ignoreList":[]}
|
package/dist/cjs/useFloating.cjs
CHANGED
|
@@ -2,60 +2,63 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var useFloating_exports = {};
|
|
33
35
|
__export(useFloating_exports, {
|
|
34
36
|
FloatingOverrideContext: () => FloatingOverrideContext,
|
|
35
37
|
useFloating: () => useFloating
|
|
36
38
|
});
|
|
37
39
|
module.exports = __toCommonJS(useFloating_exports);
|
|
38
|
-
var import_react = __toESM(require("react"), 1)
|
|
39
|
-
|
|
40
|
-
const FloatingOverrideContext = import_react.default.createContext(null)
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
var import_react = __toESM(require("react"), 1);
|
|
41
|
+
var Floating = __toESM(require("./Floating.cjs"), 1);
|
|
42
|
+
const FloatingOverrideContext = import_react.default.createContext(null);
|
|
43
|
+
const useFloating = props => {
|
|
44
|
+
"use no memo";
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
46
|
+
const context = import_react.default.useContext(FloatingOverrideContext);
|
|
47
|
+
return (context || Floating.useFloating)?.({
|
|
48
|
+
...props,
|
|
49
|
+
middleware: [
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
...props.middleware, {
|
|
52
|
+
name: `rounded`,
|
|
53
|
+
fn({
|
|
54
|
+
x,
|
|
55
|
+
y
|
|
56
|
+
}) {
|
|
57
|
+
return {
|
|
58
|
+
x: Math.round(x),
|
|
59
|
+
y: Math.round(y)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}]
|
|
63
|
+
});
|
|
64
|
+
};
|
|
@@ -4,64 +4,66 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var useFloating_exports = {};
|
|
35
37
|
__export(useFloating_exports, {
|
|
36
38
|
FloatingOverrideContext: () => FloatingOverrideContext,
|
|
37
39
|
useFloating: () => useFloating
|
|
38
40
|
});
|
|
39
41
|
module.exports = __toCommonJS(useFloating_exports);
|
|
40
|
-
var import_react = __toESM(require("react"), 1)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
var import_react = __toESM(require("react"), 1);
|
|
43
|
+
var Floating = __toESM(require("./Floating.native.js"), 1);
|
|
44
|
+
var FloatingOverrideContext = /* @__PURE__ */import_react.default.createContext(null);
|
|
45
|
+
var useFloating = function (props) {
|
|
46
|
+
"use no memo";
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
var _this;
|
|
49
|
+
var context = import_react.default.useContext(FloatingOverrideContext);
|
|
50
|
+
return (_this = context || Floating.useFloating) === null || _this === void 0 ? void 0 : _this({
|
|
51
|
+
...props,
|
|
52
|
+
middleware: [
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
...props.middleware, {
|
|
55
|
+
name: `rounded`,
|
|
56
|
+
fn(param) {
|
|
57
|
+
var {
|
|
58
|
+
x,
|
|
59
|
+
y
|
|
60
|
+
} = param;
|
|
61
|
+
return {
|
|
62
|
+
x: Math.round(x),
|
|
63
|
+
y: Math.round(y)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
67
69
|
//# sourceMappingURL=useFloating.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useFloating_exports","__export","FloatingOverrideContext","useFloating","module","exports","import_react","__toESM","require","Floating","default","createContext","props","_this","context","useContext","middleware","name","fn","param","x","y","Math","round"],"sources":["../../src/useFloating.tsx"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useFloating_exports","__export","FloatingOverrideContext","useFloating","module","exports","import_react","__toESM","require","Floating","default","createContext","props","_this","context","useContext","middleware","name","fn","param","x","y","Math","round"],"sources":["../../src/useFloating.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,mBAAA;AAAAC,QAAA,CAAAD,mBAAA;EAAAE,uBAAA,EAAAA,CAAA,KAAAA,uBAAA;EAAAC,WAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAV,YAAkB,CAAAK,mBAAA;AAElB,IAAAM,YAA0B,GAAAC,OAAA,CAAAC,OAAA;AA0BnB,IAAAC,QAAM,GAAAF,OAAA,CAAAC,OAAA,uBAA0B;AAAM,IAC3CN,uBAAA,kBAAAI,YAAA,CAAAI,OAAA,CAAAC,aAAA;AACF,IAAAR,WAAA,YAAAA,CAAAS,KAAA;EAEO,aAAM;;EACX,IAAAC,KAAA;EAEA,IAAAC,OAAM,GAAAR,YAAU,CAAAI,OAAA,CAAAK,UAAM,CAAAb,uBAAW;EACjC,QAAQW,KAAA,GAAAC,OAAW,IAAAL,QAAS,CAAAN,WAAe,cAAAU,KAAA,uBAAAA,KAAA;IACzC,GAAGD,KAAA;IACHI,UAAA,EAAY;IAAA;IAEV,GAAGJ,KAAA,CAAMI,UAAA,EACT;MACEC,IAAA,EAAM;MACNC,GAAGC,KAAK,EAAE;QACR;UAAAC,CAAO;UAAAC;QAAA,IAAAF,KAAA;QAAA,OACF;UACHC,CAAA,EAAGE,IAAA,CAAKC,KAAA,CAAMH,CAAC;UACjBC,CAAA,EAAAC,IAAA,CAAAC,KAAA,CAAAF,CAAA;QACF;MACF;IACF;EAEJ","ignoreList":[]}
|