@tamagui/floating 3.0.0-beta.924.1 → 3.0.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/interactions/useInteractions.cjs +35 -45
- package/dist/cjs/interactions/useInteractions.native.cjs +101 -100
- package/dist/cjs/interactions/useInteractions.native.js +101 -100
- package/dist/cjs/interactions/useInteractions.native.js.map +1 -1
- package/dist/cjs/interactions/useListNavigation.cjs +4 -3
- package/dist/cjs/interactions/useListNavigation.native.cjs +5 -4
- package/dist/cjs/interactions/useListNavigation.native.js +5 -4
- package/dist/cjs/interactions/useListNavigation.native.js.map +1 -1
- package/dist/cjs/interactions/utils.native.cjs +3 -10
- package/dist/cjs/interactions/utils.native.js +3 -10
- package/dist/cjs/interactions/utils.native.js.map +1 -1
- package/dist/esm/interactions/useInteractions.mjs +36 -45
- package/dist/esm/interactions/useInteractions.mjs.map +1 -1
- package/dist/esm/interactions/useInteractions.native.js +102 -100
- package/dist/esm/interactions/useInteractions.native.js.map +1 -1
- package/dist/esm/interactions/useListNavigation.mjs +4 -3
- package/dist/esm/interactions/useListNavigation.mjs.map +1 -1
- package/dist/esm/interactions/useListNavigation.native.js +5 -4
- package/dist/esm/interactions/useListNavigation.native.js.map +1 -1
- package/dist/esm/interactions/utils.native.js +3 -10
- package/dist/esm/interactions/utils.native.js.map +1 -1
- package/package.json +7 -5
- package/src/interactions/useInteractions.ts +61 -59
- package/src/interactions/useListNavigation.ts +7 -2
- package/types/interactions/useInteractions.d.ts +3 -3
- package/types/interactions/useInteractions.d.ts.map +1 -1
- package/types/interactions/useListNavigation.d.ts.map +1 -1
|
@@ -1,68 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
4
|
-
}
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
|
2
|
+
|
|
5
3
|
function useInteractions(propsList) {
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (_didIteratorError) {
|
|
36
|
-
throw _iteratorError;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
getReferenceProps(userProps) {
|
|
42
|
-
return buildProps(referenceFns, referenceStatic, userProps);
|
|
43
|
-
},
|
|
44
|
-
getFloatingProps(userProps) {
|
|
45
|
-
return buildProps(floatingFns, floatingStatic, userProps);
|
|
46
|
-
},
|
|
47
|
-
getItemProps(userProps) {
|
|
48
|
-
return buildProps(itemFns, {}, userProps);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
4
|
+
var referenceDeps = propsList.map(function(props) {
|
|
5
|
+
return props === null || props === void 0 ? void 0 : props.reference;
|
|
6
|
+
});
|
|
7
|
+
var floatingDeps = propsList.map(function(props) {
|
|
8
|
+
return props === null || props === void 0 ? void 0 : props.floating;
|
|
9
|
+
});
|
|
10
|
+
var itemDeps = propsList.map(function(props) {
|
|
11
|
+
return props === null || props === void 0 ? void 0 : props.item;
|
|
12
|
+
});
|
|
13
|
+
var getReferenceProps = useCallback(function(userProps) {
|
|
14
|
+
return mergeProps(referenceDeps, userProps);
|
|
15
|
+
}, referenceDeps);
|
|
16
|
+
var getFloatingProps = useCallback(function(userProps) {
|
|
17
|
+
return mergeProps(floatingDeps, userProps);
|
|
18
|
+
}, floatingDeps);
|
|
19
|
+
var getItemProps = useCallback(function(userProps) {
|
|
20
|
+
return mergeProps(itemDeps, userProps, true);
|
|
21
|
+
}, itemDeps);
|
|
22
|
+
return useMemo(function() {
|
|
23
|
+
return {
|
|
24
|
+
getReferenceProps,
|
|
25
|
+
getFloatingProps,
|
|
26
|
+
getItemProps
|
|
27
|
+
};
|
|
28
|
+
}, [
|
|
29
|
+
getReferenceProps,
|
|
30
|
+
getFloatingProps,
|
|
31
|
+
getItemProps
|
|
32
|
+
]);
|
|
51
33
|
}
|
|
52
|
-
function
|
|
34
|
+
function mergeProps(list, userProps) {
|
|
35
|
+
var objectsOnly = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
36
|
+
var fnMap = /* @__PURE__ */ new Map();
|
|
37
|
+
var result = {};
|
|
53
38
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
54
39
|
try {
|
|
55
|
-
for (var _iterator =
|
|
56
|
-
var
|
|
57
|
-
if (typeof props
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
for (var _iterator = list[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
41
|
+
var props = _step.value;
|
|
42
|
+
if (!props || objectsOnly && typeof props !== "object") continue;
|
|
43
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
44
|
+
try {
|
|
45
|
+
for (var _iterator1 = Object.keys(props)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
46
|
+
var key = _step1.value;
|
|
47
|
+
var value = props[key];
|
|
48
|
+
if (typeof value === "function") {
|
|
49
|
+
var arr = fnMap.get(key);
|
|
50
|
+
if (!arr) {
|
|
51
|
+
arr = [];
|
|
52
|
+
fnMap.set(key, arr);
|
|
53
|
+
}
|
|
54
|
+
arr.push(value);
|
|
55
|
+
} else {
|
|
56
|
+
result[key] = value;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {
|
|
60
|
+
_didIteratorError1 = true;
|
|
61
|
+
_iteratorError1 = err;
|
|
62
|
+
} finally {
|
|
63
|
+
try {
|
|
64
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
65
|
+
_iterator1.return();
|
|
66
|
+
}
|
|
67
|
+
} finally {
|
|
68
|
+
if (_didIteratorError1) {
|
|
69
|
+
throw _iteratorError1;
|
|
70
|
+
}
|
|
62
71
|
}
|
|
63
|
-
arr.push(props[key]);
|
|
64
|
-
} else {
|
|
65
|
-
staticMap[key] = props[key];
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
} catch (err) {
|
|
@@ -79,70 +85,66 @@ function collectProps(props, fnMap, staticMap) {
|
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
|
-
|
|
83
|
-
function buildProps(fnMap, staticProps, userProps) {
|
|
84
|
-
var result = { ...staticProps };
|
|
85
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
88
|
+
var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;
|
|
86
89
|
try {
|
|
87
90
|
var _loop = function() {
|
|
88
|
-
var [
|
|
89
|
-
|
|
91
|
+
var [key2, fns] = _step2.value;
|
|
92
|
+
result[key2] = function() {
|
|
90
93
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
91
94
|
args[_key] = arguments[_key];
|
|
92
95
|
}
|
|
93
|
-
var
|
|
96
|
+
var _iteratorNormalCompletion4 = true, _didIteratorError4 = false, _iteratorError4 = void 0;
|
|
94
97
|
try {
|
|
95
|
-
for (var
|
|
96
|
-
var fn =
|
|
97
|
-
var
|
|
98
|
-
if (
|
|
98
|
+
for (var _iterator4 = fns[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
99
|
+
var fn = _step4.value;
|
|
100
|
+
var out = fn(...args);
|
|
101
|
+
if (out !== void 0) return out;
|
|
99
102
|
}
|
|
100
103
|
} catch (err) {
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
_didIteratorError4 = true;
|
|
105
|
+
_iteratorError4 = err;
|
|
103
106
|
} finally {
|
|
104
107
|
try {
|
|
105
|
-
if (!
|
|
106
|
-
|
|
108
|
+
if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
|
|
109
|
+
_iterator4.return();
|
|
107
110
|
}
|
|
108
111
|
} finally {
|
|
109
|
-
if (
|
|
110
|
-
throw
|
|
112
|
+
if (_didIteratorError4) {
|
|
113
|
+
throw _iteratorError4;
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
};
|
|
115
|
-
result[key] = hookHandler;
|
|
116
118
|
};
|
|
117
|
-
for (var
|
|
119
|
+
for (var _iterator2 = fnMap[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) _loop();
|
|
118
120
|
} catch (err) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
_didIteratorError2 = true;
|
|
122
|
+
_iteratorError2 = err;
|
|
121
123
|
} finally {
|
|
122
124
|
try {
|
|
123
|
-
if (!
|
|
124
|
-
|
|
125
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
126
|
+
_iterator2.return();
|
|
125
127
|
}
|
|
126
128
|
} finally {
|
|
127
|
-
if (
|
|
128
|
-
throw
|
|
129
|
+
if (_didIteratorError2) {
|
|
130
|
+
throw _iteratorError2;
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
if (userProps) {
|
|
133
|
-
var
|
|
135
|
+
var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
134
136
|
try {
|
|
135
137
|
var _loop1 = function() {
|
|
136
|
-
var
|
|
137
|
-
if (
|
|
138
|
+
var key2 = _step3.value;
|
|
139
|
+
if (key2 === "style") {
|
|
138
140
|
result.style = {
|
|
139
141
|
...result.style,
|
|
140
142
|
...userProps.style
|
|
141
143
|
};
|
|
142
|
-
} else if (typeof userProps[
|
|
143
|
-
var hookFn = result[
|
|
144
|
-
var userFn = userProps[
|
|
145
|
-
result[
|
|
144
|
+
} else if (typeof userProps[key2] === "function" && result[key2]) {
|
|
145
|
+
var hookFn = result[key2];
|
|
146
|
+
var userFn = userProps[key2];
|
|
147
|
+
result[key2] = function() {
|
|
146
148
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
147
149
|
args[_key] = arguments[_key];
|
|
148
150
|
}
|
|
@@ -150,21 +152,21 @@ function buildProps(fnMap, staticProps, userProps) {
|
|
|
150
152
|
hookFn(...args);
|
|
151
153
|
};
|
|
152
154
|
} else {
|
|
153
|
-
result[
|
|
155
|
+
result[key2] = userProps[key2];
|
|
154
156
|
}
|
|
155
157
|
};
|
|
156
|
-
for (var
|
|
158
|
+
for (var _iterator3 = Object.keys(userProps)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) _loop1();
|
|
157
159
|
} catch (err) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
_didIteratorError3 = true;
|
|
161
|
+
_iteratorError3 = err;
|
|
160
162
|
} finally {
|
|
161
163
|
try {
|
|
162
|
-
if (!
|
|
163
|
-
|
|
164
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
|
|
165
|
+
_iterator3.return();
|
|
164
166
|
}
|
|
165
167
|
} finally {
|
|
166
|
-
if (
|
|
167
|
-
throw
|
|
168
|
+
if (_didIteratorError3) {
|
|
169
|
+
throw _iteratorError3;
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInteractions.native.js","names":[],"sources":["esm/interactions/useInteractions.native.js"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"useInteractions.native.js","names":[],"sources":["esm/interactions/useInteractions.native.js"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nfunction useInteractions(propsList) {\n var referenceDeps = propsList.map(function(props) {\n return props === null || props === void 0 ? void 0 : props.reference;\n });\n var floatingDeps = propsList.map(function(props) {\n return props === null || props === void 0 ? void 0 : props.floating;\n });\n var itemDeps = propsList.map(function(props) {\n return props === null || props === void 0 ? void 0 : props.item;\n });\n var getReferenceProps = useCallback(function(userProps) {\n return mergeProps(referenceDeps, userProps);\n }, referenceDeps);\n var getFloatingProps = useCallback(function(userProps) {\n return mergeProps(floatingDeps, userProps);\n }, floatingDeps);\n var getItemProps = useCallback(function(userProps) {\n return mergeProps(itemDeps, userProps, true);\n }, itemDeps);\n return useMemo(function() {\n return {\n getReferenceProps,\n getFloatingProps,\n getItemProps\n };\n }, [\n getReferenceProps,\n getFloatingProps,\n getItemProps\n ]);\n}\nfunction mergeProps(list, userProps) {\n var objectsOnly = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;\n var fnMap = /* @__PURE__ */ new Map();\n var result = {};\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = list[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var props = _step.value;\n if (!props || objectsOnly && typeof props !== \"object\") continue;\n var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;\n try {\n for (var _iterator1 = Object.keys(props)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {\n var key = _step1.value;\n var value = props[key];\n if (typeof value === \"function\") {\n var arr = fnMap.get(key);\n if (!arr) {\n arr = [];\n fnMap.set(key, arr);\n }\n arr.push(value);\n } else {\n result[key] = value;\n }\n }\n } catch (err) {\n _didIteratorError1 = true;\n _iteratorError1 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion1 && _iterator1.return != null) {\n _iterator1.return();\n }\n } finally {\n if (_didIteratorError1) {\n throw _iteratorError1;\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = void 0;\n try {\n var _loop = function() {\n var [key2, fns] = _step2.value;\n result[key2] = function() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var _iteratorNormalCompletion4 = true, _didIteratorError4 = false, _iteratorError4 = void 0;\n try {\n for (var _iterator4 = fns[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {\n var fn = _step4.value;\n var out = fn(...args);\n if (out !== void 0) return out;\n }\n } catch (err) {\n _didIteratorError4 = true;\n _iteratorError4 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion4 && _iterator4.return != null) {\n _iterator4.return();\n }\n } finally {\n if (_didIteratorError4) {\n throw _iteratorError4;\n }\n }\n }\n };\n };\n for (var _iterator2 = fnMap[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) _loop();\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return != null) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n if (userProps) {\n var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;\n try {\n var _loop1 = function() {\n var key2 = _step3.value;\n if (key2 === \"style\") {\n result.style = {\n ...result.style,\n ...userProps.style\n };\n } else if (typeof userProps[key2] === \"function\" && result[key2]) {\n var hookFn = result[key2];\n var userFn = userProps[key2];\n result[key2] = function() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n userFn(...args);\n hookFn(...args);\n };\n } else {\n result[key2] = userProps[key2];\n }\n };\n for (var _iterator3 = Object.keys(userProps)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) _loop1();\n } catch (err) {\n _didIteratorError3 = true;\n _iteratorError3 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion3 && _iterator3.return != null) {\n _iterator3.return();\n }\n } finally {\n if (_didIteratorError3) {\n throw _iteratorError3;\n }\n }\n }\n }\n return result;\n}\nexport {\n useInteractions\n};\n//# sourceMappingURL=useInteractions.js.map\n"],"mappings":";;;AACA,SAAS,gBAAgB,WAAW;CAClC,IAAI,gBAAgB,UAAU,IAAI,SAAS,OAAO;EAChD,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;CAC7D,CAAC;CACD,IAAI,eAAe,UAAU,IAAI,SAAS,OAAO;EAC/C,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;CAC7D,CAAC;CACD,IAAI,WAAW,UAAU,IAAI,SAAS,OAAO;EAC3C,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM;CAC7D,CAAC;CACD,IAAI,oBAAoB,YAAY,SAAS,WAAW;EACtD,OAAO,WAAW,eAAe,SAAS;CAC5C,GAAG,aAAa;CAChB,IAAI,mBAAmB,YAAY,SAAS,WAAW;EACrD,OAAO,WAAW,cAAc,SAAS;CAC3C,GAAG,YAAY;CACf,IAAI,eAAe,YAAY,SAAS,WAAW;EACjD,OAAO,WAAW,UAAU,WAAW,IAAI;CAC7C,GAAG,QAAQ;CACX,OAAO,QAAQ,WAAW;EACxB,OAAO;GACL;GACA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AW;EACb,IAAI,6BAA6B,MAAM,qBAAqB,OAAO,kBAAkB,KAAK;EAC1F,IAAI;GACF,IAAI,SAAS,WAAW;IACtB,IAAI,OAAO,OAAO;IAClB,IAAI,SAAS,SAAS;KACpB,OAAO,QAAQ;MACb,GAAG,OAAO;MACV,GAAG,UAAU;KACf;IACF,OAAO,IAAI,OAAO,UAAU,UAAU,cAAc,OAAO,OAAO;KAChE,IAAI,SAAS,OAAO;KACpB,IAAI,SAAS,UAAU;KACvB,OAAO,QAAQ,WAAW;MACxB,KAAK,IAAI,OAAO,UAAU,QAAQ,OAAO,IAAI,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,MAAM,QAAQ;OACvF,KAAK,QAAQ,UAAU;MACzB;MACA,OAAO,GAAG,IAAI;MACd,OAAO,GAAG,IAAI;KAChB;IACF,OAAO;KACL,OAAO,QAAQ,UAAU;IAC3B;GACF;GACA,KAAK,IAAI,aAAa,OAAO,KAAK,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC,GAAG,QAAQ,EAAE,8BAA8B,SAAS,WAAW,KAAK,EAAC,CAAE,OAAO,6BAA6B,MAAM,OAAO;EACxL,SAAS,KAAK;GACZ,qBAAqB;GACrB,kBAAkB;EACpB,UAAU;GACR,IAAI;IACF,IAAI,CAAC,8BAA8B,WAAW,UAAU,MAAM;KAC5D,WAAW,OAAO;IACpB;GACF,UAAU;IACR,IAAI,oBAAoB;KACtB,MAAM;IACR;GACF;EACF;CACF;CACA,OAAO;AACT"}
|
|
@@ -350,6 +350,8 @@ function useListNavigation(context, props) {
|
|
|
350
350
|
selectedIndex,
|
|
351
351
|
virtual
|
|
352
352
|
]);
|
|
353
|
+
const floatingRef = useRef(elements.floating);
|
|
354
|
+
floatingRef.current = elements.floating;
|
|
353
355
|
const item = useMemo(() => {
|
|
354
356
|
function syncCurrentTarget(currentTarget) {
|
|
355
357
|
if (!latestOpenRef.current) return;
|
|
@@ -383,7 +385,7 @@ function useListNavigation(context, props) {
|
|
|
383
385
|
indexRef.current = -1;
|
|
384
386
|
onNavigate();
|
|
385
387
|
if (!virtual) {
|
|
386
|
-
|
|
388
|
+
floatingRef.current?.focus({ preventScroll: true });
|
|
387
389
|
}
|
|
388
390
|
}
|
|
389
391
|
};
|
|
@@ -393,8 +395,7 @@ function useListNavigation(context, props) {
|
|
|
393
395
|
focusItemOnHover,
|
|
394
396
|
listRef,
|
|
395
397
|
onNavigate,
|
|
396
|
-
virtual
|
|
397
|
-
elements.floating
|
|
398
|
+
virtual
|
|
398
399
|
]);
|
|
399
400
|
return useMemo(() => enabled ? {
|
|
400
401
|
reference,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useListNavigation.js","names":[],"sources":["esm/interactions/useListNavigation.js"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { useEvent } from \"@tamagui/use-event\";\nimport {\n activeElement,\n enqueueFocus,\n findNonDisabledListIndex,\n getMinListIndex,\n getMaxListIndex,\n isHTMLElement,\n isIndexOutOfListBounds,\n isTypeableCombobox,\n isVirtualClick,\n isVirtualPointerEvent,\n stopEvent\n} from \"./utils\";\nconst ARROW_UP = \"ArrowUp\";\nconst ARROW_DOWN = \"ArrowDown\";\nconst ARROW_LEFT = \"ArrowLeft\";\nconst ARROW_RIGHT = \"ArrowRight\";\nfunction doSwitch(orientation, vertical, horizontal) {\n switch (orientation) {\n case \"vertical\":\n return vertical;\n case \"horizontal\":\n return horizontal;\n default:\n return vertical || horizontal;\n }\n}\nfunction isMainOrientationKey(key, orientation) {\n const vertical = key === ARROW_UP || key === ARROW_DOWN;\n const horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isMainOrientationToEndKey(key, orientation, rtl) {\n const vertical = key === ARROW_DOWN;\n const horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal) || key === \"Enter\" || key === \" \" || key === \"\";\n}\nfunction isCrossOrientationOpenKey(key, orientation, rtl) {\n const vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n const horizontal = key === ARROW_DOWN;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isCrossOrientationCloseKey(key, orientation, rtl) {\n const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;\n const horizontal = key === ARROW_UP;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction useListNavigation(context, props) {\n const { open, onOpenChange, elements } = context;\n const {\n listRef,\n activeIndex,\n onNavigate: unstable_onNavigate = () => {\n },\n enabled = true,\n selectedIndex = null,\n allowEscape = false,\n loop = false,\n nested = false,\n rtl = false,\n virtual = false,\n focusItemOnOpen = \"auto\",\n focusItemOnHover = true,\n openOnArrowKeyDown = true,\n disabledIndices = void 0,\n orientation = \"vertical\",\n scrollItemIntoView = true\n } = props;\n const typeableComboboxReference = isTypeableCombobox(elements.domReference);\n const focusItemOnOpenRef = useRef(focusItemOnOpen);\n const indexRef = useRef(selectedIndex ?? -1);\n const keyRef = useRef(null);\n const isPointerModalityRef = useRef(true);\n const previousMountedRef = useRef(!!elements.floating);\n const previousOpenRef = useRef(open);\n const forceSyncFocusRef = useRef(false);\n const forceScrollIntoViewRef = useRef(false);\n const disabledIndicesRef = useRef(disabledIndices);\n disabledIndicesRef.current = disabledIndices;\n const latestOpenRef = useRef(open);\n latestOpenRef.current = open;\n const scrollItemIntoViewRef = useRef(scrollItemIntoView);\n scrollItemIntoViewRef.current = scrollItemIntoView;\n const selectedIndexRef = useRef(selectedIndex);\n selectedIndexRef.current = selectedIndex;\n const stableOnNavigate = useEvent(unstable_onNavigate);\n const [activeId, setActiveId] = useState();\n const onNavigate = useEvent(() => {\n stableOnNavigate(indexRef.current === -1 ? null : indexRef.current);\n });\n const previousOnNavigateRef = useRef(onNavigate);\n const focusItem = useEvent(() => {\n function runFocus(item2) {\n if (virtual) {\n setActiveId(item2.id);\n } else {\n enqueueFocus(item2, {\n sync: forceSyncFocusRef.current,\n preventScroll: true\n });\n }\n }\n const initialItem = listRef.current[indexRef.current];\n const forceScrollIntoView = forceScrollIntoViewRef.current;\n if (initialItem) {\n runFocus(initialItem);\n }\n const scheduler = forceSyncFocusRef.current ? (v) => v() : requestAnimationFrame;\n scheduler(() => {\n const waitedItem = listRef.current[indexRef.current] || initialItem;\n if (!waitedItem) return;\n if (!initialItem) {\n runFocus(waitedItem);\n }\n const scrollIntoViewOptions = scrollItemIntoViewRef.current;\n const shouldScrollIntoView = scrollIntoViewOptions && waitedItem && (forceScrollIntoView || !isPointerModalityRef.current);\n if (shouldScrollIntoView) {\n waitedItem.scrollIntoView?.(\n typeof scrollIntoViewOptions === \"boolean\" ? { block: \"nearest\", inline: \"nearest\" } : scrollIntoViewOptions\n );\n }\n });\n });\n useLayoutEffect(() => {\n if (!enabled) return;\n if (open && elements.floating) {\n if (focusItemOnOpenRef.current && selectedIndex != null) {\n forceScrollIntoViewRef.current = true;\n indexRef.current = selectedIndex;\n onNavigate();\n }\n } else if (previousMountedRef.current) {\n indexRef.current = -1;\n previousOnNavigateRef.current();\n }\n }, [enabled, open, elements.floating, selectedIndex, onNavigate]);\n useLayoutEffect(() => {\n if (!enabled) return;\n if (!open) return;\n if (!elements.floating) return;\n if (activeIndex == null) {\n forceSyncFocusRef.current = false;\n if (selectedIndexRef.current != null) {\n return;\n }\n if (previousMountedRef.current) {\n indexRef.current = -1;\n focusItem();\n }\n if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {\n let runs = 0;\n const waitForListPopulated = () => {\n if (listRef.current[0] == null) {\n if (runs < 2) {\n const scheduler = runs ? requestAnimationFrame : queueMicrotask;\n scheduler(waitForListPopulated);\n }\n runs++;\n } else {\n indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinListIndex(listRef, disabledIndicesRef.current) : getMaxListIndex(listRef, disabledIndicesRef.current);\n keyRef.current = null;\n onNavigate();\n }\n };\n waitForListPopulated();\n }\n } else if (!isIndexOutOfListBounds(listRef, activeIndex)) {\n indexRef.current = activeIndex;\n focusItem();\n forceScrollIntoViewRef.current = false;\n }\n }, [\n enabled,\n open,\n elements.floating,\n activeIndex,\n selectedIndexRef,\n nested,\n listRef,\n orientation,\n rtl,\n onNavigate,\n focusItem,\n disabledIndicesRef\n ]);\n useLayoutEffect(() => {\n previousOnNavigateRef.current = onNavigate;\n previousOpenRef.current = open;\n previousMountedRef.current = !!elements.floating;\n });\n useLayoutEffect(() => {\n if (!open) {\n keyRef.current = null;\n focusItemOnOpenRef.current = focusItemOnOpen;\n }\n }, [open, focusItemOnOpen]);\n const hasActiveIndex = activeIndex != null;\n const commonOnKeyDown = useEvent((event) => {\n isPointerModalityRef.current = false;\n forceSyncFocusRef.current = true;\n if (event.which === 229) {\n return;\n }\n if (!latestOpenRef.current && event.currentTarget === elements.floating) {\n return;\n }\n if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl)) {\n stopEvent(event);\n onOpenChange(false, event.nativeEvent, \"list-navigation\");\n if (isHTMLElement(elements.domReference)) {\n elements.domReference.focus();\n }\n return;\n }\n const currentIndex = indexRef.current;\n const minIndex = getMinListIndex(listRef, disabledIndices);\n const maxIndex = getMaxListIndex(listRef, disabledIndices);\n if (!typeableComboboxReference) {\n if (event.key === \"Home\") {\n stopEvent(event);\n indexRef.current = minIndex;\n onNavigate();\n }\n if (event.key === \"End\") {\n stopEvent(event);\n indexRef.current = maxIndex;\n onNavigate();\n }\n }\n if (isMainOrientationKey(event.key, orientation)) {\n stopEvent(event);\n if (open && !virtual && activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {\n indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;\n onNavigate();\n return;\n }\n if (isMainOrientationToEndKey(event.key, orientation, rtl)) {\n if (loop) {\n indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n });\n } else {\n indexRef.current = Math.min(\n maxIndex,\n findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n })\n );\n }\n } else {\n if (loop) {\n indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n });\n } else {\n indexRef.current = Math.max(\n minIndex,\n findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n })\n );\n }\n }\n if (isIndexOutOfListBounds(listRef, indexRef.current)) {\n indexRef.current = -1;\n }\n onNavigate();\n }\n });\n const ariaActiveDescendantProp = useMemo(() => {\n return virtual && open && hasActiveIndex && {\n \"aria-activedescendant\": activeId\n };\n }, [virtual, open, hasActiveIndex, activeId]);\n const floating = useMemo(() => {\n return {\n \"aria-orientation\": orientation === \"both\" ? void 0 : orientation,\n ...!typeableComboboxReference ? ariaActiveDescendantProp : {},\n onKeyDown: commonOnKeyDown,\n onPointerMove() {\n isPointerModalityRef.current = true;\n }\n };\n }, [ariaActiveDescendantProp, commonOnKeyDown, orientation, typeableComboboxReference]);\n const reference = useMemo(() => {\n function checkVirtualMouse(event) {\n if (focusItemOnOpen === \"auto\" && isVirtualClick(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n function checkVirtualPointer(event) {\n focusItemOnOpenRef.current = focusItemOnOpen;\n if (focusItemOnOpen === \"auto\" && isVirtualPointerEvent(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n return {\n ...ariaActiveDescendantProp,\n onKeyDown(event) {\n isPointerModalityRef.current = false;\n const isArrowKey = event.key.startsWith(\"Arrow\");\n const isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);\n const isMainKey = isMainOrientationKey(event.key, orientation);\n const isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === \"Enter\" || event.key.trim() === \"\";\n if (virtual && open) {\n return commonOnKeyDown(event);\n }\n if (!open && !openOnArrowKeyDown && isArrowKey) {\n return;\n }\n if (isNavigationKey) {\n keyRef.current = event.key;\n }\n if (nested) {\n if (isCrossOpenKey) {\n stopEvent(event);\n if (open) {\n indexRef.current = getMinListIndex(listRef, disabledIndicesRef.current);\n onNavigate();\n } else {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n }\n }\n return;\n }\n if (isMainKey) {\n if (selectedIndex != null) {\n indexRef.current = selectedIndex;\n }\n stopEvent(event);\n if (!open && openOnArrowKeyDown) {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n } else {\n commonOnKeyDown(event);\n }\n if (open) {\n onNavigate();\n }\n }\n },\n onFocus() {\n if (open && !virtual) {\n indexRef.current = -1;\n onNavigate();\n }\n },\n onPointerDown: checkVirtualPointer,\n onPointerEnter: checkVirtualPointer,\n onMouseDown: checkVirtualMouse,\n onClick: checkVirtualMouse\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n disabledIndicesRef,\n focusItemOnOpen,\n listRef,\n nested,\n onNavigate,\n onOpenChange,\n open,\n openOnArrowKeyDown,\n orientation,\n rtl,\n selectedIndex,\n virtual\n ]);\n const item = useMemo(() => {\n function syncCurrentTarget(currentTarget) {\n if (!latestOpenRef.current) return;\n const index = listRef.current.indexOf(currentTarget);\n if (index !== -1 && indexRef.current !== index) {\n indexRef.current = index;\n onNavigate();\n }\n }\n const itemProps = {\n onFocus({ currentTarget }) {\n forceSyncFocusRef.current = true;\n syncCurrentTarget(currentTarget);\n },\n onClick: ({ currentTarget }) => currentTarget.focus({ preventScroll: true }),\n // safari\n onMouseMove({ currentTarget }) {\n forceSyncFocusRef.current = true;\n forceScrollIntoViewRef.current = false;\n if (focusItemOnHover) {\n syncCurrentTarget(currentTarget);\n }\n },\n onPointerLeave({ pointerType }) {\n if (!isPointerModalityRef.current || pointerType === \"touch\") {\n return;\n }\n forceSyncFocusRef.current = true;\n if (!focusItemOnHover) {\n return;\n }\n indexRef.current = -1;\n onNavigate();\n if (!virtual) {\n elements.floating?.focus({ preventScroll: true });\n }\n }\n };\n return itemProps;\n }, [latestOpenRef, focusItemOnHover, listRef, onNavigate, virtual, elements.floating]);\n return useMemo(\n () => enabled ? { reference, floating, item } : {},\n [enabled, reference, floating, item]\n );\n}\nexport {\n useListNavigation\n};\n//# sourceMappingURL=useListNavigation.js.map\n"],"mappings":";;;;;AAeA,MAAM,WAAW;AACjB,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,SAAS,SAAS,aAAa,UAAU,YAAY;CACnD,QAAQ,aAAR;EACE,KAAK,YACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,SACE,OAAO,YAAY;CACvB;AACF;AACA,SAAS,qBAAqB,KAAK,aAAa;CAC9C,MAAM,WAAW,QAAQ,YAAY,QAAQ;CAC7C,MAAM,aAAa,QAAQ,cAAc,QAAQ;CACjD,OAAO,SAAS,aAAa,UAAU,UAAU;AACnD;AACA,SAAS,0BAA0B,KAAK,aAAa,KAAK;CACxD,MAAM,WAAW,QAAQ;CACzB,MAAM,aAAa,MAAM,QAAQ,aAAa,QAAQ;CACtD,OAAO,SAAS,aAAa,UAAU,UAAU,KAAK,QAAQ,WAAW,QAAQ,OAAO,QAAQ;AAClG;AACA,SAAS,0BAA0B,KAAK,aAAa,KAAK;CACxD,MAAM,WAAW,MAAM,QAAQ,aAAa,QAAQ;CACpD,MAAM,aAAa,QAAQ;CAC3B,OAAO,SAAS,aAAa,UAAU,UAAU;AACnD;AACA,SAAS,2BAA2B,KAAK,aAAa,KAAK;CACzD,MAAM,WAAW,MAAM,QAAQ,cAAc,QAAQ;CACrD,MAAM,aAAa,QAAQ;CAC3B,OAAO,SAAS,aAAa,UAAU,UAAU;AACnD;AACA,SAAS,kBAAkB,SAAS,OAAO;CACzC,MAAM,EAAE,MAAM,cAAc,aAAa;CACzC,MAAM,EAC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file":"useListNavigation.js","names":[],"sources":["esm/interactions/useListNavigation.js"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { useEvent } from \"@tamagui/use-event\";\nimport {\n activeElement,\n enqueueFocus,\n findNonDisabledListIndex,\n getMinListIndex,\n getMaxListIndex,\n isHTMLElement,\n isIndexOutOfListBounds,\n isTypeableCombobox,\n isVirtualClick,\n isVirtualPointerEvent,\n stopEvent\n} from \"./utils\";\nconst ARROW_UP = \"ArrowUp\";\nconst ARROW_DOWN = \"ArrowDown\";\nconst ARROW_LEFT = \"ArrowLeft\";\nconst ARROW_RIGHT = \"ArrowRight\";\nfunction doSwitch(orientation, vertical, horizontal) {\n switch (orientation) {\n case \"vertical\":\n return vertical;\n case \"horizontal\":\n return horizontal;\n default:\n return vertical || horizontal;\n }\n}\nfunction isMainOrientationKey(key, orientation) {\n const vertical = key === ARROW_UP || key === ARROW_DOWN;\n const horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isMainOrientationToEndKey(key, orientation, rtl) {\n const vertical = key === ARROW_DOWN;\n const horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal) || key === \"Enter\" || key === \" \" || key === \"\";\n}\nfunction isCrossOrientationOpenKey(key, orientation, rtl) {\n const vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n const horizontal = key === ARROW_DOWN;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isCrossOrientationCloseKey(key, orientation, rtl) {\n const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;\n const horizontal = key === ARROW_UP;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction useListNavigation(context, props) {\n const { open, onOpenChange, elements } = context;\n const {\n listRef,\n activeIndex,\n onNavigate: unstable_onNavigate = () => {\n },\n enabled = true,\n selectedIndex = null,\n allowEscape = false,\n loop = false,\n nested = false,\n rtl = false,\n virtual = false,\n focusItemOnOpen = \"auto\",\n focusItemOnHover = true,\n openOnArrowKeyDown = true,\n disabledIndices = void 0,\n orientation = \"vertical\",\n scrollItemIntoView = true\n } = props;\n const typeableComboboxReference = isTypeableCombobox(elements.domReference);\n const focusItemOnOpenRef = useRef(focusItemOnOpen);\n const indexRef = useRef(selectedIndex ?? -1);\n const keyRef = useRef(null);\n const isPointerModalityRef = useRef(true);\n const previousMountedRef = useRef(!!elements.floating);\n const previousOpenRef = useRef(open);\n const forceSyncFocusRef = useRef(false);\n const forceScrollIntoViewRef = useRef(false);\n const disabledIndicesRef = useRef(disabledIndices);\n disabledIndicesRef.current = disabledIndices;\n const latestOpenRef = useRef(open);\n latestOpenRef.current = open;\n const scrollItemIntoViewRef = useRef(scrollItemIntoView);\n scrollItemIntoViewRef.current = scrollItemIntoView;\n const selectedIndexRef = useRef(selectedIndex);\n selectedIndexRef.current = selectedIndex;\n const stableOnNavigate = useEvent(unstable_onNavigate);\n const [activeId, setActiveId] = useState();\n const onNavigate = useEvent(() => {\n stableOnNavigate(indexRef.current === -1 ? null : indexRef.current);\n });\n const previousOnNavigateRef = useRef(onNavigate);\n const focusItem = useEvent(() => {\n function runFocus(item2) {\n if (virtual) {\n setActiveId(item2.id);\n } else {\n enqueueFocus(item2, {\n sync: forceSyncFocusRef.current,\n preventScroll: true\n });\n }\n }\n const initialItem = listRef.current[indexRef.current];\n const forceScrollIntoView = forceScrollIntoViewRef.current;\n if (initialItem) {\n runFocus(initialItem);\n }\n const scheduler = forceSyncFocusRef.current ? (v) => v() : requestAnimationFrame;\n scheduler(() => {\n const waitedItem = listRef.current[indexRef.current] || initialItem;\n if (!waitedItem) return;\n if (!initialItem) {\n runFocus(waitedItem);\n }\n const scrollIntoViewOptions = scrollItemIntoViewRef.current;\n const shouldScrollIntoView = scrollIntoViewOptions && waitedItem && (forceScrollIntoView || !isPointerModalityRef.current);\n if (shouldScrollIntoView) {\n waitedItem.scrollIntoView?.(\n typeof scrollIntoViewOptions === \"boolean\" ? { block: \"nearest\", inline: \"nearest\" } : scrollIntoViewOptions\n );\n }\n });\n });\n useLayoutEffect(() => {\n if (!enabled) return;\n if (open && elements.floating) {\n if (focusItemOnOpenRef.current && selectedIndex != null) {\n forceScrollIntoViewRef.current = true;\n indexRef.current = selectedIndex;\n onNavigate();\n }\n } else if (previousMountedRef.current) {\n indexRef.current = -1;\n previousOnNavigateRef.current();\n }\n }, [enabled, open, elements.floating, selectedIndex, onNavigate]);\n useLayoutEffect(() => {\n if (!enabled) return;\n if (!open) return;\n if (!elements.floating) return;\n if (activeIndex == null) {\n forceSyncFocusRef.current = false;\n if (selectedIndexRef.current != null) {\n return;\n }\n if (previousMountedRef.current) {\n indexRef.current = -1;\n focusItem();\n }\n if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {\n let runs = 0;\n const waitForListPopulated = () => {\n if (listRef.current[0] == null) {\n if (runs < 2) {\n const scheduler = runs ? requestAnimationFrame : queueMicrotask;\n scheduler(waitForListPopulated);\n }\n runs++;\n } else {\n indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinListIndex(listRef, disabledIndicesRef.current) : getMaxListIndex(listRef, disabledIndicesRef.current);\n keyRef.current = null;\n onNavigate();\n }\n };\n waitForListPopulated();\n }\n } else if (!isIndexOutOfListBounds(listRef, activeIndex)) {\n indexRef.current = activeIndex;\n focusItem();\n forceScrollIntoViewRef.current = false;\n }\n }, [\n enabled,\n open,\n elements.floating,\n activeIndex,\n selectedIndexRef,\n nested,\n listRef,\n orientation,\n rtl,\n onNavigate,\n focusItem,\n disabledIndicesRef\n ]);\n useLayoutEffect(() => {\n previousOnNavigateRef.current = onNavigate;\n previousOpenRef.current = open;\n previousMountedRef.current = !!elements.floating;\n });\n useLayoutEffect(() => {\n if (!open) {\n keyRef.current = null;\n focusItemOnOpenRef.current = focusItemOnOpen;\n }\n }, [open, focusItemOnOpen]);\n const hasActiveIndex = activeIndex != null;\n const commonOnKeyDown = useEvent((event) => {\n isPointerModalityRef.current = false;\n forceSyncFocusRef.current = true;\n if (event.which === 229) {\n return;\n }\n if (!latestOpenRef.current && event.currentTarget === elements.floating) {\n return;\n }\n if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl)) {\n stopEvent(event);\n onOpenChange(false, event.nativeEvent, \"list-navigation\");\n if (isHTMLElement(elements.domReference)) {\n elements.domReference.focus();\n }\n return;\n }\n const currentIndex = indexRef.current;\n const minIndex = getMinListIndex(listRef, disabledIndices);\n const maxIndex = getMaxListIndex(listRef, disabledIndices);\n if (!typeableComboboxReference) {\n if (event.key === \"Home\") {\n stopEvent(event);\n indexRef.current = minIndex;\n onNavigate();\n }\n if (event.key === \"End\") {\n stopEvent(event);\n indexRef.current = maxIndex;\n onNavigate();\n }\n }\n if (isMainOrientationKey(event.key, orientation)) {\n stopEvent(event);\n if (open && !virtual && activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {\n indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;\n onNavigate();\n return;\n }\n if (isMainOrientationToEndKey(event.key, orientation, rtl)) {\n if (loop) {\n indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n });\n } else {\n indexRef.current = Math.min(\n maxIndex,\n findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n })\n );\n }\n } else {\n if (loop) {\n indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n });\n } else {\n indexRef.current = Math.max(\n minIndex,\n findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n })\n );\n }\n }\n if (isIndexOutOfListBounds(listRef, indexRef.current)) {\n indexRef.current = -1;\n }\n onNavigate();\n }\n });\n const ariaActiveDescendantProp = useMemo(() => {\n return virtual && open && hasActiveIndex && {\n \"aria-activedescendant\": activeId\n };\n }, [virtual, open, hasActiveIndex, activeId]);\n const floating = useMemo(() => {\n return {\n \"aria-orientation\": orientation === \"both\" ? void 0 : orientation,\n ...!typeableComboboxReference ? ariaActiveDescendantProp : {},\n onKeyDown: commonOnKeyDown,\n onPointerMove() {\n isPointerModalityRef.current = true;\n }\n };\n }, [ariaActiveDescendantProp, commonOnKeyDown, orientation, typeableComboboxReference]);\n const reference = useMemo(() => {\n function checkVirtualMouse(event) {\n if (focusItemOnOpen === \"auto\" && isVirtualClick(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n function checkVirtualPointer(event) {\n focusItemOnOpenRef.current = focusItemOnOpen;\n if (focusItemOnOpen === \"auto\" && isVirtualPointerEvent(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n return {\n ...ariaActiveDescendantProp,\n onKeyDown(event) {\n isPointerModalityRef.current = false;\n const isArrowKey = event.key.startsWith(\"Arrow\");\n const isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);\n const isMainKey = isMainOrientationKey(event.key, orientation);\n const isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === \"Enter\" || event.key.trim() === \"\";\n if (virtual && open) {\n return commonOnKeyDown(event);\n }\n if (!open && !openOnArrowKeyDown && isArrowKey) {\n return;\n }\n if (isNavigationKey) {\n keyRef.current = event.key;\n }\n if (nested) {\n if (isCrossOpenKey) {\n stopEvent(event);\n if (open) {\n indexRef.current = getMinListIndex(listRef, disabledIndicesRef.current);\n onNavigate();\n } else {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n }\n }\n return;\n }\n if (isMainKey) {\n if (selectedIndex != null) {\n indexRef.current = selectedIndex;\n }\n stopEvent(event);\n if (!open && openOnArrowKeyDown) {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n } else {\n commonOnKeyDown(event);\n }\n if (open) {\n onNavigate();\n }\n }\n },\n onFocus() {\n if (open && !virtual) {\n indexRef.current = -1;\n onNavigate();\n }\n },\n onPointerDown: checkVirtualPointer,\n onPointerEnter: checkVirtualPointer,\n onMouseDown: checkVirtualMouse,\n onClick: checkVirtualMouse\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n disabledIndicesRef,\n focusItemOnOpen,\n listRef,\n nested,\n onNavigate,\n onOpenChange,\n open,\n openOnArrowKeyDown,\n orientation,\n rtl,\n selectedIndex,\n virtual\n ]);\n const floatingRef = useRef(elements.floating);\n floatingRef.current = elements.floating;\n const item = useMemo(() => {\n function syncCurrentTarget(currentTarget) {\n if (!latestOpenRef.current) return;\n const index = listRef.current.indexOf(currentTarget);\n if (index !== -1 && indexRef.current !== index) {\n indexRef.current = index;\n onNavigate();\n }\n }\n const itemProps = {\n onFocus({ currentTarget }) {\n forceSyncFocusRef.current = true;\n syncCurrentTarget(currentTarget);\n },\n onClick: ({ currentTarget }) => currentTarget.focus({ preventScroll: true }),\n // safari\n onMouseMove({ currentTarget }) {\n forceSyncFocusRef.current = true;\n forceScrollIntoViewRef.current = false;\n if (focusItemOnHover) {\n syncCurrentTarget(currentTarget);\n }\n },\n onPointerLeave({ pointerType }) {\n if (!isPointerModalityRef.current || pointerType === \"touch\") {\n return;\n }\n forceSyncFocusRef.current = true;\n if (!focusItemOnHover) {\n return;\n }\n indexRef.current = -1;\n onNavigate();\n if (!virtual) {\n floatingRef.current?.focus({ preventScroll: true });\n }\n }\n };\n return itemProps;\n }, [latestOpenRef, focusItemOnHover, listRef, onNavigate, virtual]);\n return useMemo(\n () => enabled ? { reference, floating, item } : {},\n [enabled, reference, floating, item]\n );\n}\nexport {\n useListNavigation\n};\n//# sourceMappingURL=useListNavigation.js.map\n"],"mappings":";;;;;AAeA,MAAM,WAAW;AACjB,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB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;GACxC,IAAI,CAAC,cAAc,SAAS;GAC5B,MAAM,QAAQ,QAAQ,QAAQ,QAAQ,aAAa;GACnD,IAAI,UAAU,CAAC,KAAK,SAAS,YAAY,OAAO;IAC9C,SAAS,UAAU;IACnB,WAAW;GACb;EACF;EACA,MAAM,YAAY;GAChB,QAAQ,EAAE,iBAAiB;IACzB,kBAAkB,UAAU;IAC5B,kBAAkB,aAAa;GACjC;GACA,UAAU,EAAE,oBAAoB,cAAc,MAAM,EAAE,eAAe,KAAK,CAAC;GAE3E,YAAY,EAAE,iBAAiB;IAC7B,kBAAkB,UAAU;IAC5B,uBAAuB,UAAU;IACjC,IAAI,kBAAkB;KACpB,kBAAkB,aAAa;IACjC;GACF;GACA,eAAe,EAAE,eAAe;IAC9B,IAAI,CAAC,qBAAqB,WAAW,gBAAgB,SAAS;KAC5D;IACF;IACA,kBAAkB,UAAU;IAC5B,IAAI,CAAC,kBAAkB;KACrB;IACF;IACA,SAAS,UAAU,CAAC;IACpB,WAAW;IACX,IAAI,CAAC,SAAS;KACZ,YAAY,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;IACpD;GACF;EACF;EACA,OAAO;CACT,GAAG;EAAC;EAAe;EAAkB;EAAS;EAAY;CAAO,CAAC;CAClE,OAAO,cACC,UAAU;EAAE;EAAW;EAAU;CAAK,IAAI,CAAC,GACjD;EAAC;EAAS;EAAW;EAAU;CAAI,CACrC;AACF"}
|
|
@@ -353,6 +353,8 @@ function useListNavigation(context, props) {
|
|
|
353
353
|
selectedIndex,
|
|
354
354
|
virtual
|
|
355
355
|
]);
|
|
356
|
+
var floatingRef = useRef(elements.floating);
|
|
357
|
+
floatingRef.current = elements.floating;
|
|
356
358
|
var item = useMemo(function() {
|
|
357
359
|
function syncCurrentTarget(currentTarget) {
|
|
358
360
|
if (!latestOpenRef.current) return;
|
|
@@ -392,8 +394,8 @@ function useListNavigation(context, props) {
|
|
|
392
394
|
indexRef.current = -1;
|
|
393
395
|
onNavigate();
|
|
394
396
|
if (!virtual) {
|
|
395
|
-
var
|
|
396
|
-
(
|
|
397
|
+
var _floatingRef_current;
|
|
398
|
+
(_floatingRef_current = floatingRef.current) === null || _floatingRef_current === void 0 ? void 0 : _floatingRef_current.focus({ preventScroll: true });
|
|
397
399
|
}
|
|
398
400
|
}
|
|
399
401
|
};
|
|
@@ -403,8 +405,7 @@ function useListNavigation(context, props) {
|
|
|
403
405
|
focusItemOnHover,
|
|
404
406
|
listRef,
|
|
405
407
|
onNavigate,
|
|
406
|
-
virtual
|
|
407
|
-
elements.floating
|
|
408
|
+
virtual
|
|
408
409
|
]);
|
|
409
410
|
return useMemo(function() {
|
|
410
411
|
return enabled ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useListNavigation.native.js","names":[],"sources":["esm/interactions/useListNavigation.native.js"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { useEvent } from \"@tamagui/use-event\";\nimport { activeElement, enqueueFocus, findNonDisabledListIndex, getMinListIndex, getMaxListIndex, isHTMLElement, isIndexOutOfListBounds, isTypeableCombobox, isVirtualClick, isVirtualPointerEvent, stopEvent } from \"./utils\";\nvar ARROW_UP = \"ArrowUp\";\nvar ARROW_DOWN = \"ArrowDown\";\nvar ARROW_LEFT = \"ArrowLeft\";\nvar ARROW_RIGHT = \"ArrowRight\";\nfunction doSwitch(orientation, vertical, horizontal) {\n switch (orientation) {\n case \"vertical\":\n return vertical;\n case \"horizontal\":\n return horizontal;\n default:\n return vertical || horizontal;\n }\n}\nfunction isMainOrientationKey(key, orientation) {\n var vertical = key === ARROW_UP || key === ARROW_DOWN;\n var horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isMainOrientationToEndKey(key, orientation, rtl) {\n var vertical = key === ARROW_DOWN;\n var horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal) || key === \"Enter\" || key === \" \" || key === \"\";\n}\nfunction isCrossOrientationOpenKey(key, orientation, rtl) {\n var vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n var horizontal = key === ARROW_DOWN;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isCrossOrientationCloseKey(key, orientation, rtl) {\n var vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;\n var horizontal = key === ARROW_UP;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction useListNavigation(context, props) {\n var { open, onOpenChange, elements } = context;\n var { listRef, activeIndex, onNavigate: unstable_onNavigate = function() {\n }, enabled = true, selectedIndex = null, allowEscape = false, loop = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = \"auto\", focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices = void 0, orientation = \"vertical\", scrollItemIntoView = true } = props;\n var typeableComboboxReference = isTypeableCombobox(elements.domReference);\n var focusItemOnOpenRef = useRef(focusItemOnOpen);\n var indexRef = useRef(selectedIndex !== null && selectedIndex !== void 0 ? selectedIndex : -1);\n var keyRef = useRef(null);\n var isPointerModalityRef = useRef(true);\n var previousMountedRef = useRef(!!elements.floating);\n var previousOpenRef = useRef(open);\n var forceSyncFocusRef = useRef(false);\n var forceScrollIntoViewRef = useRef(false);\n var disabledIndicesRef = useRef(disabledIndices);\n disabledIndicesRef.current = disabledIndices;\n var latestOpenRef = useRef(open);\n latestOpenRef.current = open;\n var scrollItemIntoViewRef = useRef(scrollItemIntoView);\n scrollItemIntoViewRef.current = scrollItemIntoView;\n var selectedIndexRef = useRef(selectedIndex);\n selectedIndexRef.current = selectedIndex;\n var stableOnNavigate = useEvent(unstable_onNavigate);\n var [activeId, setActiveId] = useState();\n var onNavigate = useEvent(function() {\n stableOnNavigate(indexRef.current === -1 ? null : indexRef.current);\n });\n var previousOnNavigateRef = useRef(onNavigate);\n var focusItem = useEvent(function() {\n function runFocus(item2) {\n if (virtual) {\n setActiveId(item2.id);\n } else {\n enqueueFocus(item2, {\n sync: forceSyncFocusRef.current,\n preventScroll: true\n });\n }\n }\n var initialItem = listRef.current[indexRef.current];\n var forceScrollIntoView = forceScrollIntoViewRef.current;\n if (initialItem) {\n runFocus(initialItem);\n }\n var scheduler = forceSyncFocusRef.current ? function(v) {\n return v();\n } : requestAnimationFrame;\n scheduler(function() {\n var waitedItem = listRef.current[indexRef.current] || initialItem;\n if (!waitedItem) return;\n if (!initialItem) {\n runFocus(waitedItem);\n }\n var scrollIntoViewOptions = scrollItemIntoViewRef.current;\n var shouldScrollIntoView = scrollIntoViewOptions && waitedItem && (forceScrollIntoView || !isPointerModalityRef.current);\n if (shouldScrollIntoView) {\n var _waitedItem_scrollIntoView;\n (_waitedItem_scrollIntoView = waitedItem.scrollIntoView) === null || _waitedItem_scrollIntoView === void 0 ? void 0 : _waitedItem_scrollIntoView.call(waitedItem, typeof scrollIntoViewOptions === \"boolean\" ? {\n block: \"nearest\",\n inline: \"nearest\"\n } : scrollIntoViewOptions);\n }\n });\n });\n useLayoutEffect(function() {\n if (!enabled) return;\n if (open && elements.floating) {\n if (focusItemOnOpenRef.current && selectedIndex != null) {\n forceScrollIntoViewRef.current = true;\n indexRef.current = selectedIndex;\n onNavigate();\n }\n } else if (previousMountedRef.current) {\n indexRef.current = -1;\n previousOnNavigateRef.current();\n }\n }, [\n enabled,\n open,\n elements.floating,\n selectedIndex,\n onNavigate\n ]);\n useLayoutEffect(function() {\n if (!enabled) return;\n if (!open) return;\n if (!elements.floating) return;\n if (activeIndex == null) {\n forceSyncFocusRef.current = false;\n if (selectedIndexRef.current != null) {\n return;\n }\n if (previousMountedRef.current) {\n indexRef.current = -1;\n focusItem();\n }\n if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {\n var runs = 0;\n var waitForListPopulated = function() {\n if (listRef.current[0] == null) {\n if (runs < 2) {\n var scheduler = runs ? requestAnimationFrame : queueMicrotask;\n scheduler(waitForListPopulated);\n }\n runs++;\n } else {\n indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinListIndex(listRef, disabledIndicesRef.current) : getMaxListIndex(listRef, disabledIndicesRef.current);\n keyRef.current = null;\n onNavigate();\n }\n };\n waitForListPopulated();\n }\n } else if (!isIndexOutOfListBounds(listRef, activeIndex)) {\n indexRef.current = activeIndex;\n focusItem();\n forceScrollIntoViewRef.current = false;\n }\n }, [\n enabled,\n open,\n elements.floating,\n activeIndex,\n selectedIndexRef,\n nested,\n listRef,\n orientation,\n rtl,\n onNavigate,\n focusItem,\n disabledIndicesRef\n ]);\n useLayoutEffect(function() {\n previousOnNavigateRef.current = onNavigate;\n previousOpenRef.current = open;\n previousMountedRef.current = !!elements.floating;\n });\n useLayoutEffect(function() {\n if (!open) {\n keyRef.current = null;\n focusItemOnOpenRef.current = focusItemOnOpen;\n }\n }, [\n open,\n focusItemOnOpen\n ]);\n var hasActiveIndex = activeIndex != null;\n var commonOnKeyDown = useEvent(function(event) {\n isPointerModalityRef.current = false;\n forceSyncFocusRef.current = true;\n if (event.which === 229) {\n return;\n }\n if (!latestOpenRef.current && event.currentTarget === elements.floating) {\n return;\n }\n if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl)) {\n stopEvent(event);\n onOpenChange(false, event.nativeEvent, \"list-navigation\");\n if (isHTMLElement(elements.domReference)) {\n elements.domReference.focus();\n }\n return;\n }\n var currentIndex = indexRef.current;\n var minIndex = getMinListIndex(listRef, disabledIndices);\n var maxIndex = getMaxListIndex(listRef, disabledIndices);\n if (!typeableComboboxReference) {\n if (event.key === \"Home\") {\n stopEvent(event);\n indexRef.current = minIndex;\n onNavigate();\n }\n if (event.key === \"End\") {\n stopEvent(event);\n indexRef.current = maxIndex;\n onNavigate();\n }\n }\n if (isMainOrientationKey(event.key, orientation)) {\n stopEvent(event);\n if (open && !virtual && activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {\n indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;\n onNavigate();\n return;\n }\n if (isMainOrientationToEndKey(event.key, orientation, rtl)) {\n if (loop) {\n indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n });\n } else {\n indexRef.current = Math.min(maxIndex, findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n }));\n }\n } else {\n if (loop) {\n indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n });\n } else {\n indexRef.current = Math.max(minIndex, findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n }));\n }\n }\n if (isIndexOutOfListBounds(listRef, indexRef.current)) {\n indexRef.current = -1;\n }\n onNavigate();\n }\n });\n var ariaActiveDescendantProp = useMemo(function() {\n return virtual && open && hasActiveIndex && {\n \"aria-activedescendant\": activeId\n };\n }, [\n virtual,\n open,\n hasActiveIndex,\n activeId\n ]);\n var floating = useMemo(function() {\n return {\n \"aria-orientation\": orientation === \"both\" ? void 0 : orientation,\n ...!typeableComboboxReference ? ariaActiveDescendantProp : {},\n onKeyDown: commonOnKeyDown,\n onPointerMove() {\n isPointerModalityRef.current = true;\n }\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n orientation,\n typeableComboboxReference\n ]);\n var reference = useMemo(function() {\n function checkVirtualMouse(event) {\n if (focusItemOnOpen === \"auto\" && isVirtualClick(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n function checkVirtualPointer(event) {\n focusItemOnOpenRef.current = focusItemOnOpen;\n if (focusItemOnOpen === \"auto\" && isVirtualPointerEvent(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n return {\n ...ariaActiveDescendantProp,\n onKeyDown(event) {\n isPointerModalityRef.current = false;\n var isArrowKey = event.key.startsWith(\"Arrow\");\n var isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);\n var isMainKey = isMainOrientationKey(event.key, orientation);\n var isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === \"Enter\" || event.key.trim() === \"\";\n if (virtual && open) {\n return commonOnKeyDown(event);\n }\n if (!open && !openOnArrowKeyDown && isArrowKey) {\n return;\n }\n if (isNavigationKey) {\n keyRef.current = event.key;\n }\n if (nested) {\n if (isCrossOpenKey) {\n stopEvent(event);\n if (open) {\n indexRef.current = getMinListIndex(listRef, disabledIndicesRef.current);\n onNavigate();\n } else {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n }\n }\n return;\n }\n if (isMainKey) {\n if (selectedIndex != null) {\n indexRef.current = selectedIndex;\n }\n stopEvent(event);\n if (!open && openOnArrowKeyDown) {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n } else {\n commonOnKeyDown(event);\n }\n if (open) {\n onNavigate();\n }\n }\n },\n onFocus() {\n if (open && !virtual) {\n indexRef.current = -1;\n onNavigate();\n }\n },\n onPointerDown: checkVirtualPointer,\n onPointerEnter: checkVirtualPointer,\n onMouseDown: checkVirtualMouse,\n onClick: checkVirtualMouse\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n disabledIndicesRef,\n focusItemOnOpen,\n listRef,\n nested,\n onNavigate,\n onOpenChange,\n open,\n openOnArrowKeyDown,\n orientation,\n rtl,\n selectedIndex,\n virtual\n ]);\n var item = useMemo(function() {\n function syncCurrentTarget(currentTarget) {\n if (!latestOpenRef.current) return;\n var index = listRef.current.indexOf(currentTarget);\n if (index !== -1 && indexRef.current !== index) {\n indexRef.current = index;\n onNavigate();\n }\n }\n var itemProps = {\n onFocus(param) {\n var { currentTarget } = param;\n forceSyncFocusRef.current = true;\n syncCurrentTarget(currentTarget);\n },\n onClick: function(param) {\n var { currentTarget } = param;\n return currentTarget.focus({\n preventScroll: true\n });\n },\n // safari\n onMouseMove(param) {\n var { currentTarget } = param;\n forceSyncFocusRef.current = true;\n forceScrollIntoViewRef.current = false;\n if (focusItemOnHover) {\n syncCurrentTarget(currentTarget);\n }\n },\n onPointerLeave(param) {\n var { pointerType } = param;\n if (!isPointerModalityRef.current || pointerType === \"touch\") {\n return;\n }\n forceSyncFocusRef.current = true;\n if (!focusItemOnHover) {\n return;\n }\n indexRef.current = -1;\n onNavigate();\n if (!virtual) {\n var _elements_floating;\n (_elements_floating = elements.floating) === null || _elements_floating === void 0 ? void 0 : _elements_floating.focus({\n preventScroll: true\n });\n }\n }\n };\n return itemProps;\n }, [\n latestOpenRef,\n focusItemOnHover,\n listRef,\n onNavigate,\n virtual,\n elements.floating\n ]);\n return useMemo(function() {\n return enabled ? {\n reference,\n floating,\n item\n } : {};\n }, [\n enabled,\n reference,\n floating,\n item\n ]);\n}\nexport {\n useListNavigation\n};\n//# sourceMappingURL=useListNavigation.js.map\n"],"mappings":";;;;;AAGA,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,cAAc;AAClB,SAAS,SAAS,aAAa,UAAU,YAAY;CACnD,QAAQ,aAAR;EACE,KAAK,YACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,SACE,OAAO,YAAY;CACvB;AACF;AACA,SAAS,qBAAqB,KAAK,aAAa;CAC9C,IAAI,WAAW,QAAQ,YAAY,QAAQ;CAC3C,IAAI,aAAa,QAAQ,cAAc,QAAQ;CAC/C,OAAO,SAAS,aAAa,UAAU,UAAU;AACnD;AACA,SAAS,0BAA0B,KAAK,aAAa,KAAK;CACxD,IAAI,WAAW,QAAQ;CACvB,IAAI,aAAa,MAAM,QAAQ,aAAa,QAAQ;CACpD,OAAO,SAAS,aAAa,UAAU,UAAU,KAAK,QAAQ,WAAW,QAAQ,OAAO,QAAQ;AAClG;AACA,SAAS,0BAA0B,KAAK,aAAa,KAAK;CACxD,IAAI,WAAW,MAAM,QAAQ,aAAa,QAAQ;C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IACjB,IAAI,EAAE,kBAAkB;IACxB,kBAAkB,UAAU;IAC5B,uBAAuB,UAAU;IACjC,IAAI,kBAAkB;KACpB,kBAAkB,aAAa;IACjC;GACF;GACA,eAAe,OAAO;IACpB,IAAI,EAAE,gBAAgB;IACtB,IAAI,CAAC,qBAAqB,WAAW,gBAAgB,SAAS;KAC5D;IACF;IACA,kBAAkB,UAAU;IAC5B,IAAI,CAAC,kBAAkB;KACrB;IACF;IACA,SAAS,UAAU,CAAC;IACpB,WAAW;IACX,IAAI,CAAC,SAAS;KACZ,IAAI;KACJ,CAAC,qBAAqB,SAAS,cAAc,QAAQ,uBAAuB,KAAK,IAAI,KAAK,IAAI,mBAAmB,MAAM,EACrH,eAAe,KACjB,CAAC;IACH;GACF;EACF;EACA,OAAO;CACT,GAAG;EACD;EACA;EACA;EACA;EACA;EACA,SAAS;CACX,CAAC;CACD,OAAO,QAAQ,WAAW;EACxB,OAAO,UAAU;GACf;GACA;GACA;EACF,IAAI,CAAC;CACP,GAAG;EACD;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"useListNavigation.native.js","names":[],"sources":["esm/interactions/useListNavigation.native.js"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { useEvent } from \"@tamagui/use-event\";\nimport { activeElement, enqueueFocus, findNonDisabledListIndex, getMinListIndex, getMaxListIndex, isHTMLElement, isIndexOutOfListBounds, isTypeableCombobox, isVirtualClick, isVirtualPointerEvent, stopEvent } from \"./utils\";\nvar ARROW_UP = \"ArrowUp\";\nvar ARROW_DOWN = \"ArrowDown\";\nvar ARROW_LEFT = \"ArrowLeft\";\nvar ARROW_RIGHT = \"ArrowRight\";\nfunction doSwitch(orientation, vertical, horizontal) {\n switch (orientation) {\n case \"vertical\":\n return vertical;\n case \"horizontal\":\n return horizontal;\n default:\n return vertical || horizontal;\n }\n}\nfunction isMainOrientationKey(key, orientation) {\n var vertical = key === ARROW_UP || key === ARROW_DOWN;\n var horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isMainOrientationToEndKey(key, orientation, rtl) {\n var vertical = key === ARROW_DOWN;\n var horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n return doSwitch(orientation, vertical, horizontal) || key === \"Enter\" || key === \" \" || key === \"\";\n}\nfunction isCrossOrientationOpenKey(key, orientation, rtl) {\n var vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;\n var horizontal = key === ARROW_DOWN;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction isCrossOrientationCloseKey(key, orientation, rtl) {\n var vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;\n var horizontal = key === ARROW_UP;\n return doSwitch(orientation, vertical, horizontal);\n}\nfunction useListNavigation(context, props) {\n var { open, onOpenChange, elements } = context;\n var { listRef, activeIndex, onNavigate: unstable_onNavigate = function() {\n }, enabled = true, selectedIndex = null, allowEscape = false, loop = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = \"auto\", focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices = void 0, orientation = \"vertical\", scrollItemIntoView = true } = props;\n var typeableComboboxReference = isTypeableCombobox(elements.domReference);\n var focusItemOnOpenRef = useRef(focusItemOnOpen);\n var indexRef = useRef(selectedIndex !== null && selectedIndex !== void 0 ? selectedIndex : -1);\n var keyRef = useRef(null);\n var isPointerModalityRef = useRef(true);\n var previousMountedRef = useRef(!!elements.floating);\n var previousOpenRef = useRef(open);\n var forceSyncFocusRef = useRef(false);\n var forceScrollIntoViewRef = useRef(false);\n var disabledIndicesRef = useRef(disabledIndices);\n disabledIndicesRef.current = disabledIndices;\n var latestOpenRef = useRef(open);\n latestOpenRef.current = open;\n var scrollItemIntoViewRef = useRef(scrollItemIntoView);\n scrollItemIntoViewRef.current = scrollItemIntoView;\n var selectedIndexRef = useRef(selectedIndex);\n selectedIndexRef.current = selectedIndex;\n var stableOnNavigate = useEvent(unstable_onNavigate);\n var [activeId, setActiveId] = useState();\n var onNavigate = useEvent(function() {\n stableOnNavigate(indexRef.current === -1 ? null : indexRef.current);\n });\n var previousOnNavigateRef = useRef(onNavigate);\n var focusItem = useEvent(function() {\n function runFocus(item2) {\n if (virtual) {\n setActiveId(item2.id);\n } else {\n enqueueFocus(item2, {\n sync: forceSyncFocusRef.current,\n preventScroll: true\n });\n }\n }\n var initialItem = listRef.current[indexRef.current];\n var forceScrollIntoView = forceScrollIntoViewRef.current;\n if (initialItem) {\n runFocus(initialItem);\n }\n var scheduler = forceSyncFocusRef.current ? function(v) {\n return v();\n } : requestAnimationFrame;\n scheduler(function() {\n var waitedItem = listRef.current[indexRef.current] || initialItem;\n if (!waitedItem) return;\n if (!initialItem) {\n runFocus(waitedItem);\n }\n var scrollIntoViewOptions = scrollItemIntoViewRef.current;\n var shouldScrollIntoView = scrollIntoViewOptions && waitedItem && (forceScrollIntoView || !isPointerModalityRef.current);\n if (shouldScrollIntoView) {\n var _waitedItem_scrollIntoView;\n (_waitedItem_scrollIntoView = waitedItem.scrollIntoView) === null || _waitedItem_scrollIntoView === void 0 ? void 0 : _waitedItem_scrollIntoView.call(waitedItem, typeof scrollIntoViewOptions === \"boolean\" ? {\n block: \"nearest\",\n inline: \"nearest\"\n } : scrollIntoViewOptions);\n }\n });\n });\n useLayoutEffect(function() {\n if (!enabled) return;\n if (open && elements.floating) {\n if (focusItemOnOpenRef.current && selectedIndex != null) {\n forceScrollIntoViewRef.current = true;\n indexRef.current = selectedIndex;\n onNavigate();\n }\n } else if (previousMountedRef.current) {\n indexRef.current = -1;\n previousOnNavigateRef.current();\n }\n }, [\n enabled,\n open,\n elements.floating,\n selectedIndex,\n onNavigate\n ]);\n useLayoutEffect(function() {\n if (!enabled) return;\n if (!open) return;\n if (!elements.floating) return;\n if (activeIndex == null) {\n forceSyncFocusRef.current = false;\n if (selectedIndexRef.current != null) {\n return;\n }\n if (previousMountedRef.current) {\n indexRef.current = -1;\n focusItem();\n }\n if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {\n var runs = 0;\n var waitForListPopulated = function() {\n if (listRef.current[0] == null) {\n if (runs < 2) {\n var scheduler = runs ? requestAnimationFrame : queueMicrotask;\n scheduler(waitForListPopulated);\n }\n runs++;\n } else {\n indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? getMinListIndex(listRef, disabledIndicesRef.current) : getMaxListIndex(listRef, disabledIndicesRef.current);\n keyRef.current = null;\n onNavigate();\n }\n };\n waitForListPopulated();\n }\n } else if (!isIndexOutOfListBounds(listRef, activeIndex)) {\n indexRef.current = activeIndex;\n focusItem();\n forceScrollIntoViewRef.current = false;\n }\n }, [\n enabled,\n open,\n elements.floating,\n activeIndex,\n selectedIndexRef,\n nested,\n listRef,\n orientation,\n rtl,\n onNavigate,\n focusItem,\n disabledIndicesRef\n ]);\n useLayoutEffect(function() {\n previousOnNavigateRef.current = onNavigate;\n previousOpenRef.current = open;\n previousMountedRef.current = !!elements.floating;\n });\n useLayoutEffect(function() {\n if (!open) {\n keyRef.current = null;\n focusItemOnOpenRef.current = focusItemOnOpen;\n }\n }, [\n open,\n focusItemOnOpen\n ]);\n var hasActiveIndex = activeIndex != null;\n var commonOnKeyDown = useEvent(function(event) {\n isPointerModalityRef.current = false;\n forceSyncFocusRef.current = true;\n if (event.which === 229) {\n return;\n }\n if (!latestOpenRef.current && event.currentTarget === elements.floating) {\n return;\n }\n if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl)) {\n stopEvent(event);\n onOpenChange(false, event.nativeEvent, \"list-navigation\");\n if (isHTMLElement(elements.domReference)) {\n elements.domReference.focus();\n }\n return;\n }\n var currentIndex = indexRef.current;\n var minIndex = getMinListIndex(listRef, disabledIndices);\n var maxIndex = getMaxListIndex(listRef, disabledIndices);\n if (!typeableComboboxReference) {\n if (event.key === \"Home\") {\n stopEvent(event);\n indexRef.current = minIndex;\n onNavigate();\n }\n if (event.key === \"End\") {\n stopEvent(event);\n indexRef.current = maxIndex;\n onNavigate();\n }\n }\n if (isMainOrientationKey(event.key, orientation)) {\n stopEvent(event);\n if (open && !virtual && activeElement(event.currentTarget.ownerDocument) === event.currentTarget) {\n indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;\n onNavigate();\n return;\n }\n if (isMainOrientationToEndKey(event.key, orientation, rtl)) {\n if (loop) {\n indexRef.current = currentIndex >= maxIndex ? allowEscape && currentIndex !== listRef.current.length ? -1 : minIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n });\n } else {\n indexRef.current = Math.min(maxIndex, findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n disabledIndices\n }));\n }\n } else {\n if (loop) {\n indexRef.current = currentIndex <= minIndex ? allowEscape && currentIndex !== -1 ? listRef.current.length : maxIndex : findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n });\n } else {\n indexRef.current = Math.max(minIndex, findNonDisabledListIndex(listRef, {\n startingIndex: currentIndex,\n decrement: true,\n disabledIndices\n }));\n }\n }\n if (isIndexOutOfListBounds(listRef, indexRef.current)) {\n indexRef.current = -1;\n }\n onNavigate();\n }\n });\n var ariaActiveDescendantProp = useMemo(function() {\n return virtual && open && hasActiveIndex && {\n \"aria-activedescendant\": activeId\n };\n }, [\n virtual,\n open,\n hasActiveIndex,\n activeId\n ]);\n var floating = useMemo(function() {\n return {\n \"aria-orientation\": orientation === \"both\" ? void 0 : orientation,\n ...!typeableComboboxReference ? ariaActiveDescendantProp : {},\n onKeyDown: commonOnKeyDown,\n onPointerMove() {\n isPointerModalityRef.current = true;\n }\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n orientation,\n typeableComboboxReference\n ]);\n var reference = useMemo(function() {\n function checkVirtualMouse(event) {\n if (focusItemOnOpen === \"auto\" && isVirtualClick(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n function checkVirtualPointer(event) {\n focusItemOnOpenRef.current = focusItemOnOpen;\n if (focusItemOnOpen === \"auto\" && isVirtualPointerEvent(event.nativeEvent)) {\n focusItemOnOpenRef.current = true;\n }\n }\n return {\n ...ariaActiveDescendantProp,\n onKeyDown(event) {\n isPointerModalityRef.current = false;\n var isArrowKey = event.key.startsWith(\"Arrow\");\n var isCrossOpenKey = isCrossOrientationOpenKey(event.key, orientation, rtl);\n var isMainKey = isMainOrientationKey(event.key, orientation);\n var isNavigationKey = (nested ? isCrossOpenKey : isMainKey) || event.key === \"Enter\" || event.key.trim() === \"\";\n if (virtual && open) {\n return commonOnKeyDown(event);\n }\n if (!open && !openOnArrowKeyDown && isArrowKey) {\n return;\n }\n if (isNavigationKey) {\n keyRef.current = event.key;\n }\n if (nested) {\n if (isCrossOpenKey) {\n stopEvent(event);\n if (open) {\n indexRef.current = getMinListIndex(listRef, disabledIndicesRef.current);\n onNavigate();\n } else {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n }\n }\n return;\n }\n if (isMainKey) {\n if (selectedIndex != null) {\n indexRef.current = selectedIndex;\n }\n stopEvent(event);\n if (!open && openOnArrowKeyDown) {\n onOpenChange(true, event.nativeEvent, \"list-navigation\");\n } else {\n commonOnKeyDown(event);\n }\n if (open) {\n onNavigate();\n }\n }\n },\n onFocus() {\n if (open && !virtual) {\n indexRef.current = -1;\n onNavigate();\n }\n },\n onPointerDown: checkVirtualPointer,\n onPointerEnter: checkVirtualPointer,\n onMouseDown: checkVirtualMouse,\n onClick: checkVirtualMouse\n };\n }, [\n ariaActiveDescendantProp,\n commonOnKeyDown,\n disabledIndicesRef,\n focusItemOnOpen,\n listRef,\n nested,\n onNavigate,\n onOpenChange,\n open,\n openOnArrowKeyDown,\n orientation,\n rtl,\n selectedIndex,\n virtual\n ]);\n var floatingRef = useRef(elements.floating);\n floatingRef.current = elements.floating;\n var item = useMemo(function() {\n function syncCurrentTarget(currentTarget) {\n if (!latestOpenRef.current) return;\n var index = listRef.current.indexOf(currentTarget);\n if (index !== -1 && indexRef.current !== index) {\n indexRef.current = index;\n onNavigate();\n }\n }\n var itemProps = {\n onFocus(param) {\n var { currentTarget } = param;\n forceSyncFocusRef.current = true;\n syncCurrentTarget(currentTarget);\n },\n onClick: function(param) {\n var { currentTarget } = param;\n return currentTarget.focus({\n preventScroll: true\n });\n },\n // safari\n onMouseMove(param) {\n var { currentTarget } = param;\n forceSyncFocusRef.current = true;\n forceScrollIntoViewRef.current = false;\n if (focusItemOnHover) {\n syncCurrentTarget(currentTarget);\n }\n },\n onPointerLeave(param) {\n var { pointerType } = param;\n if (!isPointerModalityRef.current || pointerType === \"touch\") {\n return;\n }\n forceSyncFocusRef.current = true;\n if (!focusItemOnHover) {\n return;\n }\n indexRef.current = -1;\n onNavigate();\n if (!virtual) {\n var _floatingRef_current;\n (_floatingRef_current = floatingRef.current) === null || _floatingRef_current === void 0 ? void 0 : _floatingRef_current.focus({\n preventScroll: true\n });\n }\n }\n };\n return itemProps;\n }, [\n latestOpenRef,\n focusItemOnHover,\n listRef,\n onNavigate,\n virtual\n ]);\n return useMemo(function() {\n return enabled ? {\n reference,\n floating,\n item\n } : {};\n }, [\n enabled,\n reference,\n floating,\n item\n ]);\n}\nexport {\n useListNavigation\n};\n//# sourceMappingURL=useListNavigation.js.map\n"],"mappings":";;;;;AAGA,IAAI,WAAW;AACf,IAAI,aAAa;AACjB,IAAI,aAAa;AACjB,IAAI,cAAc;AAClB,SAAS,SAAS,aAAa,UAAU,YAAY;CACnD,QAAQ,aAAR;EACE,KAAK,YACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,SACE,OAAO,YAAY;CACvB;AACF;AACA,SAAS,qBAAqB,KAAK,aAAa;CAC9C,IAAI,WAAW,QAAQ,YAAY,QAAQ;CAC3C,IAAI,aAAa,QAAQ,cAAc,QAAQ;CAC/C,OAAO,SAAS,aAAa,UAAU,UAAU;AACnD;AACA,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