@tamagui/focus-scope 1.61.3 → 1.62.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/FocusScope.js +52 -145
- package/dist/cjs/FocusScope.js.map +2 -2
- package/dist/cjs/FocusScope.native.js +6 -11
- package/dist/cjs/FocusScope.native.js.map +1 -1
- package/dist/cjs/FocusScopeProps.js +3 -6
- package/dist/cjs/FocusScopeProps.js.map +1 -1
- package/dist/cjs/FocusScopeProps.native.js +15 -0
- package/dist/cjs/FocusScopeProps.native.js.map +6 -0
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +20 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/esm/FocusScope.js +45 -129
- package/dist/esm/FocusScope.js.map +2 -2
- package/dist/jsx/FocusScope.js +43 -126
- package/dist/jsx/FocusScope.js.map +2 -2
- package/dist/jsx/FocusScope.native.js +1 -3
- package/dist/jsx/FocusScope.native.js.map +1 -1
- package/dist/jsx/FocusScopeProps.native.js +1 -0
- package/dist/jsx/FocusScopeProps.native.js.map +6 -0
- package/dist/jsx/index.native.js +2 -0
- package/dist/jsx/index.native.js.map +6 -0
- package/package.json +4 -4
- package/dist/esm/FocusScope.native.js +0 -8
- package/dist/esm/FocusScope.native.js.map +0 -6
package/dist/cjs/FocusScope.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
13
|
return to;
|
|
19
14
|
};
|
|
20
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -22,147 +17,79 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
17
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
18
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
19
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
26
21
|
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
29
23
|
var FocusScope_exports = {};
|
|
30
24
|
__export(FocusScope_exports, {
|
|
31
25
|
FocusScope: () => FocusScope,
|
|
32
26
|
useFocusScope: () => useFocusScope
|
|
33
27
|
});
|
|
34
28
|
module.exports = __toCommonJS(FocusScope_exports);
|
|
35
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var React = __toESM(require("react"));
|
|
39
|
-
const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
40
|
-
const AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
41
|
-
const EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
42
|
-
const FocusScope = React.forwardRef(
|
|
43
|
-
function FocusScope2(props, forwardedRef) {
|
|
29
|
+
var import_compose_refs = require("@tamagui/compose-refs"), import_use_event = require("@tamagui/use-event"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount", AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount", EVENT_OPTIONS = { bubbles: !1, cancelable: !0 }, FocusScope = React.forwardRef(
|
|
31
|
+
function(props, forwardedRef) {
|
|
44
32
|
const childProps = useFocusScope(props, forwardedRef);
|
|
45
|
-
|
|
46
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: props.children(childProps) });
|
|
47
|
-
}
|
|
48
|
-
return React.cloneElement(React.Children.only(props.children), childProps);
|
|
33
|
+
return typeof props.children == "function" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: props.children(childProps) }) : React.cloneElement(React.Children.only(props.children), childProps);
|
|
49
34
|
}
|
|
50
35
|
);
|
|
51
36
|
function useFocusScope(props, forwardedRef) {
|
|
52
37
|
const {
|
|
53
|
-
loop =
|
|
54
|
-
enabled =
|
|
55
|
-
trapped =
|
|
38
|
+
loop = !1,
|
|
39
|
+
enabled = !0,
|
|
40
|
+
trapped = !1,
|
|
56
41
|
onMountAutoFocus: onMountAutoFocusProp,
|
|
57
42
|
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
58
43
|
forceUnmount,
|
|
59
44
|
children,
|
|
60
45
|
...scopeProps
|
|
61
|
-
} = props
|
|
62
|
-
|
|
63
|
-
const onMountAutoFocus = (0, import_use_event.useEvent)(onMountAutoFocusProp);
|
|
64
|
-
const onUnmountAutoFocus = (0, import_use_event.useEvent)(onUnmountAutoFocusProp);
|
|
65
|
-
const lastFocusedElementRef = React.useRef(null);
|
|
66
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => setContainer(node));
|
|
67
|
-
const focusScope = React.useRef({
|
|
68
|
-
paused: false,
|
|
46
|
+
} = props, [container, setContainer] = React.useState(null), onMountAutoFocus = (0, import_use_event.useEvent)(onMountAutoFocusProp), onUnmountAutoFocus = (0, import_use_event.useEvent)(onUnmountAutoFocusProp), lastFocusedElementRef = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node) => setContainer(node)), focusScope = React.useRef({
|
|
47
|
+
paused: !1,
|
|
69
48
|
pause() {
|
|
70
|
-
this.paused =
|
|
49
|
+
this.paused = !0;
|
|
71
50
|
},
|
|
72
51
|
resume() {
|
|
73
|
-
this.paused =
|
|
52
|
+
this.paused = !1;
|
|
74
53
|
}
|
|
75
54
|
}).current;
|
|
76
55
|
React.useEffect(() => {
|
|
77
|
-
if (!enabled)
|
|
78
|
-
return;
|
|
79
|
-
if (!trapped)
|
|
56
|
+
if (!enabled || !trapped)
|
|
80
57
|
return;
|
|
81
58
|
function handleFocusIn(event) {
|
|
82
59
|
if (focusScope.paused || !container)
|
|
83
60
|
return;
|
|
84
61
|
const target = event.target;
|
|
85
|
-
|
|
86
|
-
lastFocusedElementRef.current = target;
|
|
87
|
-
} else {
|
|
88
|
-
focus(lastFocusedElementRef.current, { select: true });
|
|
89
|
-
}
|
|
62
|
+
container.contains(target) ? lastFocusedElementRef.current = target : focus(lastFocusedElementRef.current, { select: !0 });
|
|
90
63
|
}
|
|
91
64
|
function handleFocusOut(event) {
|
|
92
|
-
|
|
93
|
-
return;
|
|
94
|
-
if (!container.contains(event.relatedTarget)) {
|
|
95
|
-
focus(lastFocusedElementRef.current, { select: true });
|
|
96
|
-
}
|
|
65
|
+
focusScope.paused || !container || container.contains(event.relatedTarget) || focus(lastFocusedElementRef.current, { select: !0 });
|
|
97
66
|
}
|
|
98
|
-
document.addEventListener("focusin", handleFocusIn)
|
|
99
|
-
|
|
100
|
-
return () => {
|
|
101
|
-
document.removeEventListener("focusin", handleFocusIn);
|
|
102
|
-
document.removeEventListener("focusout", handleFocusOut);
|
|
67
|
+
return document.addEventListener("focusin", handleFocusIn), document.addEventListener("focusout", handleFocusOut), () => {
|
|
68
|
+
document.removeEventListener("focusin", handleFocusIn), document.removeEventListener("focusout", handleFocusOut);
|
|
103
69
|
};
|
|
104
|
-
}, [trapped, forceUnmount, container, focusScope.paused])
|
|
105
|
-
|
|
106
|
-
if (!enabled)
|
|
107
|
-
return;
|
|
108
|
-
if (!container)
|
|
109
|
-
return;
|
|
110
|
-
if (forceUnmount)
|
|
70
|
+
}, [trapped, forceUnmount, container, focusScope.paused]), React.useEffect(() => {
|
|
71
|
+
if (!enabled || !container || forceUnmount)
|
|
111
72
|
return;
|
|
112
73
|
focusScopesStack.add(focusScope);
|
|
113
74
|
const previouslyFocusedElement = document.activeElement;
|
|
114
|
-
|
|
115
|
-
if (!hasFocusedCandidate) {
|
|
75
|
+
if (!container.contains(previouslyFocusedElement)) {
|
|
116
76
|
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
117
|
-
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
118
|
-
container.dispatchEvent(mountEvent);
|
|
119
|
-
if (!mountEvent.defaultPrevented) {
|
|
120
|
-
focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
|
|
121
|
-
if (document.activeElement === previouslyFocusedElement) {
|
|
122
|
-
focus(container);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
77
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus), container.dispatchEvent(mountEvent), mountEvent.defaultPrevented || (focusFirst(removeLinks(getTabbableCandidates(container)), { select: !0 }), document.activeElement === previouslyFocusedElement && focus(container));
|
|
125
78
|
}
|
|
126
79
|
return () => {
|
|
127
80
|
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
128
81
|
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
129
|
-
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
130
|
-
container.dispatchEvent(unmountEvent);
|
|
131
|
-
if (!unmountEvent.defaultPrevented) {
|
|
132
|
-
focus(previouslyFocusedElement ?? document.body, { select: true });
|
|
133
|
-
}
|
|
134
|
-
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
135
|
-
focusScopesStack.remove(focusScope);
|
|
82
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus), container.dispatchEvent(unmountEvent), unmountEvent.defaultPrevented || focus(previouslyFocusedElement ?? document.body, { select: !0 }), container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus), focusScopesStack.remove(focusScope);
|
|
136
83
|
};
|
|
137
84
|
}, [enabled, container, forceUnmount, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
138
85
|
const handleKeyDown = React.useCallback(
|
|
139
86
|
(event) => {
|
|
140
|
-
if (!trapped)
|
|
141
|
-
return;
|
|
142
|
-
if (!loop)
|
|
87
|
+
if (!trapped || !loop || focusScope.paused)
|
|
143
88
|
return;
|
|
144
|
-
|
|
145
|
-
return;
|
|
146
|
-
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
147
|
-
const focusedElement = document.activeElement;
|
|
89
|
+
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey, focusedElement = document.activeElement;
|
|
148
90
|
if (isTabKey && focusedElement) {
|
|
149
|
-
const container2 = event.currentTarget;
|
|
150
|
-
|
|
151
|
-
const hasTabbableElementsInside = first && last;
|
|
152
|
-
if (!hasTabbableElementsInside) {
|
|
153
|
-
if (focusedElement === container2)
|
|
154
|
-
event.preventDefault();
|
|
155
|
-
} else {
|
|
156
|
-
if (!event.shiftKey && focusedElement === last) {
|
|
157
|
-
event.preventDefault();
|
|
158
|
-
if (loop)
|
|
159
|
-
focus(first, { select: true });
|
|
160
|
-
} else if (event.shiftKey && focusedElement === first) {
|
|
161
|
-
event.preventDefault();
|
|
162
|
-
if (loop)
|
|
163
|
-
focus(last, { select: true });
|
|
164
|
-
}
|
|
165
|
-
}
|
|
91
|
+
const container2 = event.currentTarget, [first, last] = getTabbableEdges(container2);
|
|
92
|
+
first && last ? !event.shiftKey && focusedElement === last ? (event.preventDefault(), loop && focus(first, { select: !0 })) : event.shiftKey && focusedElement === first && (event.preventDefault(), loop && focus(last, { select: !0 })) : focusedElement === container2 && event.preventDefault();
|
|
166
93
|
}
|
|
167
94
|
},
|
|
168
95
|
[loop, trapped, focusScope.paused]
|
|
@@ -174,62 +101,52 @@ function useFocusScope(props, forwardedRef) {
|
|
|
174
101
|
onKeyDown: handleKeyDown
|
|
175
102
|
};
|
|
176
103
|
}
|
|
177
|
-
function focusFirst(candidates, { select =
|
|
104
|
+
function focusFirst(candidates, { select = !1 } = {}) {
|
|
178
105
|
const previouslyFocusedElement = document.activeElement;
|
|
179
|
-
for (const candidate of candidates)
|
|
180
|
-
focus(candidate, { select })
|
|
181
|
-
if (document.activeElement !== previouslyFocusedElement)
|
|
106
|
+
for (const candidate of candidates)
|
|
107
|
+
if (focus(candidate, { select }), document.activeElement !== previouslyFocusedElement)
|
|
182
108
|
return;
|
|
183
|
-
}
|
|
184
109
|
}
|
|
185
110
|
function getTabbableEdges(container) {
|
|
186
|
-
const candidates = getTabbableCandidates(container);
|
|
187
|
-
const first = findVisible(candidates, container);
|
|
188
|
-
const last = findVisible(candidates.reverse(), container);
|
|
111
|
+
const candidates = getTabbableCandidates(container), first = findVisible(candidates, container), last = findVisible(candidates.reverse(), container);
|
|
189
112
|
return [first, last];
|
|
190
113
|
}
|
|
191
114
|
function getTabbableCandidates(container) {
|
|
192
|
-
const nodes = []
|
|
193
|
-
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
115
|
+
const nodes = [], walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
194
116
|
acceptNode: (node) => {
|
|
195
117
|
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
196
|
-
|
|
197
|
-
return NodeFilter.FILTER_SKIP;
|
|
198
|
-
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
118
|
+
return node.disabled || node.hidden || isHiddenInput ? NodeFilter.FILTER_SKIP : node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
199
119
|
}
|
|
200
120
|
});
|
|
201
|
-
|
|
121
|
+
for (; walker.nextNode(); )
|
|
202
122
|
nodes.push(walker.currentNode);
|
|
203
123
|
return nodes;
|
|
204
124
|
}
|
|
205
125
|
function findVisible(elements, container) {
|
|
206
|
-
for (const element of elements)
|
|
126
|
+
for (const element of elements)
|
|
207
127
|
if (!isHidden(element, { upTo: container }))
|
|
208
128
|
return element;
|
|
209
|
-
}
|
|
210
129
|
}
|
|
211
130
|
function isHidden(node, { upTo }) {
|
|
212
131
|
if (getComputedStyle(node).visibility === "hidden")
|
|
213
|
-
return
|
|
214
|
-
|
|
132
|
+
return !0;
|
|
133
|
+
for (; node; ) {
|
|
215
134
|
if (upTo !== void 0 && node === upTo)
|
|
216
|
-
return
|
|
135
|
+
return !1;
|
|
217
136
|
if (getComputedStyle(node).display === "none")
|
|
218
|
-
return
|
|
137
|
+
return !0;
|
|
219
138
|
node = node.parentElement;
|
|
220
139
|
}
|
|
221
|
-
return
|
|
140
|
+
return !1;
|
|
222
141
|
}
|
|
223
142
|
function isSelectableInput(element) {
|
|
224
143
|
return element instanceof HTMLInputElement && "select" in element;
|
|
225
144
|
}
|
|
226
|
-
function focus(element, { select =
|
|
145
|
+
function focus(element, { select = !1 } = {}) {
|
|
227
146
|
setTimeout(() => {
|
|
228
|
-
if (element
|
|
147
|
+
if (element?.focus) {
|
|
229
148
|
const previouslyFocusedElement = document.activeElement;
|
|
230
|
-
element.focus({ preventScroll:
|
|
231
|
-
if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
|
|
232
|
-
element.select();
|
|
149
|
+
element.focus({ preventScroll: !0 }), element !== previouslyFocusedElement && isSelectableInput(element) && select && element.select();
|
|
233
150
|
}
|
|
234
151
|
});
|
|
235
152
|
}
|
|
@@ -239,26 +156,16 @@ function createFocusScopesStack() {
|
|
|
239
156
|
return {
|
|
240
157
|
add(focusScope) {
|
|
241
158
|
const activeFocusScope = stack[0];
|
|
242
|
-
|
|
243
|
-
activeFocusScope == null ? void 0 : activeFocusScope.pause();
|
|
244
|
-
}
|
|
245
|
-
stack = arrayRemove(stack, focusScope);
|
|
246
|
-
stack.unshift(focusScope);
|
|
159
|
+
focusScope !== activeFocusScope && activeFocusScope?.pause(), stack = arrayRemove(stack, focusScope), stack.unshift(focusScope);
|
|
247
160
|
},
|
|
248
161
|
remove(focusScope) {
|
|
249
|
-
|
|
250
|
-
stack = arrayRemove(stack, focusScope);
|
|
251
|
-
(_a = stack[0]) == null ? void 0 : _a.resume();
|
|
162
|
+
stack = arrayRemove(stack, focusScope), stack[0]?.resume();
|
|
252
163
|
}
|
|
253
164
|
};
|
|
254
165
|
}
|
|
255
166
|
function arrayRemove(array, item) {
|
|
256
|
-
const updatedArray = [...array];
|
|
257
|
-
|
|
258
|
-
if (index !== -1) {
|
|
259
|
-
updatedArray.splice(index, 1);
|
|
260
|
-
}
|
|
261
|
-
return updatedArray;
|
|
167
|
+
const updatedArray = [...array], index = updatedArray.indexOf(item);
|
|
168
|
+
return index !== -1 && updatedArray.splice(index, 1), updatedArray;
|
|
262
169
|
}
|
|
263
170
|
function removeLinks(items) {
|
|
264
171
|
return items.filter((item) => item.tagName !== "A");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/FocusScope.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": ["
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC,kCAChC,mBAAyB,+BACzB,QAAuB,2BAqBV;AAjBb,MAAM,qBAAqB,+BACrB,uBAAuB,iCACvB,gBAAgB,EAAE,SAAS,IAAO,YAAY,GAAK,GAUnD,aAAa,MAAM;AAAA,EACvB,SAAoB,OAAO,cAAc;AACvC,UAAM,aAAa,cAAc,OAAO,YAAY;AAEpD,WAAI,OAAO,MAAM,YAAa,aACrB,2EAAG,gBAAM,SAAS,UAAU,GAAE,IAGhC,MAAM,aAAa,MAAM,SAAS,KAAK,MAAM,QAAQ,GAAU,UAAU;AAAA,EAClF;AACF;AAMO,SAAS,cACd,OACA,cACA;AACA,QAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,OACE,CAAC,WAAW,YAAY,IAAI,MAAM,SAA6B,IAAI,GACnE,uBAAmB,2BAAS,oBAAoB,GAChD,yBAAqB,2BAAS,sBAAsB,GACpD,wBAAwB,MAAM,OAA2B,IAAI,GAC7D,mBAAe,qCAAgB,cAAc,CAAC,SAAS,aAAa,IAAI,CAAC,GAEzE,aAAa,MAAM,OAAO;AAAA,IAC9B,QAAQ;AAAA,IACR,QAAQ;AACN,WAAK,SAAS;AAAA,IAChB;AAAA,IACA,SAAS;A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,yBAAyB;AAEhC,MAAI,QAAyB,CAAC;AAE9B,SAAO;AAAA,IACL,IAAI,YAA2B;AAE7B,YAAM,mBAAmB,MAAM,CAAC;AAChC,MAAI,eAAe,oBACjB,kBAAkB,MAAM,GAG1B,QAAQ,YAAY,OAAO,UAAU,GACrC,MAAM,QAAQ,UAAU;AAAA,IAC1B;AAAA,IAEA,OAAO,YAA2B;AAChC,cAAQ,YAAY,OAAO,UAAU,GACrC,MAAM,CAAC,GAAG,OAAO;AAAA,IACnB;AAAA,EACF;AACF;AAEA,SAAS,YAAe,OAAY,MAAS;AAC3C,QAAM,eAAe,CAAC,GAAG,KAAK,GACxB,QAAQ,aAAa,QAAQ,IAAI;AACvC,SAAI,UAAU,MACZ,aAAa,OAAO,OAAO,CAAC,GAEvB;AACT;AAEA,SAAS,YAAY,OAAsB;AACzC,SAAO,MAAM,OAAO,CAAC,SAAS,KAAK,YAAY,GAAG;AACpD;",
|
|
5
|
+
"names": ["container"]
|
|
6
6
|
}
|
|
@@ -5,26 +5,21 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __export = (target, all) => {
|
|
7
7
|
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
11
|
for (let key of __getOwnPropNames(from))
|
|
13
|
-
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
13
|
return to;
|
|
17
14
|
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
19
16
|
var FocusScope_native_exports = {};
|
|
20
17
|
__export(FocusScope_native_exports, {
|
|
21
18
|
FocusScope: () => FocusScope
|
|
22
19
|
});
|
|
23
20
|
module.exports = __toCommonJS(FocusScope_native_exports);
|
|
24
21
|
var import_react = require("react");
|
|
25
|
-
const FocusScope = (0, import_react.forwardRef)((props, _ref) =>
|
|
26
|
-
return props.children;
|
|
27
|
-
});
|
|
22
|
+
const FocusScope = (0, import_react.forwardRef)((props, _ref) => props.children);
|
|
28
23
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
24
|
0 && (module.exports = {
|
|
30
25
|
FocusScope
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/FocusScope.native.tsx"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAIpB,MAAM,iBAAa,yBAAW,CAAC,OAAwB,SACrD,MAAM,QACd;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
5
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
7
|
for (let key of __getOwnPropNames(from))
|
|
9
|
-
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
9
|
return to;
|
|
13
10
|
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value:
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
12
|
var FocusScopeProps_exports = {};
|
|
16
13
|
module.exports = __toCommonJS(FocusScopeProps_exports);
|
|
17
14
|
//# sourceMappingURL=FocusScopeProps.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
return to;
|
|
11
|
+
};
|
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
13
|
+
var FocusScopeProps_exports = {};
|
|
14
|
+
module.exports = __toCommonJS(FocusScopeProps_exports);
|
|
15
|
+
//# sourceMappingURL=FocusScopeProps.js.map
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
5
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
7
|
for (let key of __getOwnPropNames(from))
|
|
9
|
-
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
8
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
9
|
return to;
|
|
13
|
-
};
|
|
14
|
-
var
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
10
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
12
|
var src_exports = {};
|
|
17
13
|
module.exports = __toCommonJS(src_exports);
|
|
18
14
|
__reExport(src_exports, require("./FocusScope"), module.exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
return to;
|
|
11
|
+
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
12
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
13
|
+
var src_exports = {};
|
|
14
|
+
module.exports = __toCommonJS(src_exports);
|
|
15
|
+
__reExport(src_exports, require("./FocusScope"), module.exports);
|
|
16
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
17
|
+
0 && (module.exports = {
|
|
18
|
+
...require("./FocusScope")
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
package/dist/esm/FocusScope.js
CHANGED
|
@@ -1,134 +1,70 @@
|
|
|
1
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
1
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
3
2
|
import { useEvent } from "@tamagui/use-event";
|
|
4
3
|
import * as React from "react";
|
|
5
|
-
|
|
6
|
-
const AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount"
|
|
7
|
-
|
|
8
|
-
const FocusScope = React.forwardRef(
|
|
9
|
-
function FocusScope2(props, forwardedRef) {
|
|
4
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
5
|
+
const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount", AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount", EVENT_OPTIONS = { bubbles: !1, cancelable: !0 }, FocusScope = React.forwardRef(
|
|
6
|
+
function(props, forwardedRef) {
|
|
10
7
|
const childProps = useFocusScope(props, forwardedRef);
|
|
11
|
-
|
|
12
|
-
return /* @__PURE__ */ jsx(Fragment, { children: props.children(childProps) });
|
|
13
|
-
}
|
|
14
|
-
return React.cloneElement(React.Children.only(props.children), childProps);
|
|
8
|
+
return typeof props.children == "function" ? /* @__PURE__ */ jsx(Fragment, { children: props.children(childProps) }) : React.cloneElement(React.Children.only(props.children), childProps);
|
|
15
9
|
}
|
|
16
10
|
);
|
|
17
11
|
function useFocusScope(props, forwardedRef) {
|
|
18
12
|
const {
|
|
19
|
-
loop =
|
|
20
|
-
enabled =
|
|
21
|
-
trapped =
|
|
13
|
+
loop = !1,
|
|
14
|
+
enabled = !0,
|
|
15
|
+
trapped = !1,
|
|
22
16
|
onMountAutoFocus: onMountAutoFocusProp,
|
|
23
17
|
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
24
18
|
forceUnmount,
|
|
25
19
|
children,
|
|
26
20
|
...scopeProps
|
|
27
|
-
} = props
|
|
28
|
-
|
|
29
|
-
const onMountAutoFocus = useEvent(onMountAutoFocusProp);
|
|
30
|
-
const onUnmountAutoFocus = useEvent(onUnmountAutoFocusProp);
|
|
31
|
-
const lastFocusedElementRef = React.useRef(null);
|
|
32
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
|
|
33
|
-
const focusScope = React.useRef({
|
|
34
|
-
paused: false,
|
|
21
|
+
} = props, [container, setContainer] = React.useState(null), onMountAutoFocus = useEvent(onMountAutoFocusProp), onUnmountAutoFocus = useEvent(onUnmountAutoFocusProp), lastFocusedElementRef = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node)), focusScope = React.useRef({
|
|
22
|
+
paused: !1,
|
|
35
23
|
pause() {
|
|
36
|
-
this.paused =
|
|
24
|
+
this.paused = !0;
|
|
37
25
|
},
|
|
38
26
|
resume() {
|
|
39
|
-
this.paused =
|
|
27
|
+
this.paused = !1;
|
|
40
28
|
}
|
|
41
29
|
}).current;
|
|
42
30
|
React.useEffect(() => {
|
|
43
|
-
if (!enabled)
|
|
44
|
-
return;
|
|
45
|
-
if (!trapped)
|
|
31
|
+
if (!enabled || !trapped)
|
|
46
32
|
return;
|
|
47
33
|
function handleFocusIn(event) {
|
|
48
34
|
if (focusScope.paused || !container)
|
|
49
35
|
return;
|
|
50
36
|
const target = event.target;
|
|
51
|
-
|
|
52
|
-
lastFocusedElementRef.current = target;
|
|
53
|
-
} else {
|
|
54
|
-
focus(lastFocusedElementRef.current, { select: true });
|
|
55
|
-
}
|
|
37
|
+
container.contains(target) ? lastFocusedElementRef.current = target : focus(lastFocusedElementRef.current, { select: !0 });
|
|
56
38
|
}
|
|
57
39
|
function handleFocusOut(event) {
|
|
58
|
-
|
|
59
|
-
return;
|
|
60
|
-
if (!container.contains(event.relatedTarget)) {
|
|
61
|
-
focus(lastFocusedElementRef.current, { select: true });
|
|
62
|
-
}
|
|
40
|
+
focusScope.paused || !container || container.contains(event.relatedTarget) || focus(lastFocusedElementRef.current, { select: !0 });
|
|
63
41
|
}
|
|
64
|
-
document.addEventListener("focusin", handleFocusIn)
|
|
65
|
-
|
|
66
|
-
return () => {
|
|
67
|
-
document.removeEventListener("focusin", handleFocusIn);
|
|
68
|
-
document.removeEventListener("focusout", handleFocusOut);
|
|
42
|
+
return document.addEventListener("focusin", handleFocusIn), document.addEventListener("focusout", handleFocusOut), () => {
|
|
43
|
+
document.removeEventListener("focusin", handleFocusIn), document.removeEventListener("focusout", handleFocusOut);
|
|
69
44
|
};
|
|
70
|
-
}, [trapped, forceUnmount, container, focusScope.paused])
|
|
71
|
-
|
|
72
|
-
if (!enabled)
|
|
73
|
-
return;
|
|
74
|
-
if (!container)
|
|
75
|
-
return;
|
|
76
|
-
if (forceUnmount)
|
|
45
|
+
}, [trapped, forceUnmount, container, focusScope.paused]), React.useEffect(() => {
|
|
46
|
+
if (!enabled || !container || forceUnmount)
|
|
77
47
|
return;
|
|
78
48
|
focusScopesStack.add(focusScope);
|
|
79
49
|
const previouslyFocusedElement = document.activeElement;
|
|
80
|
-
|
|
81
|
-
if (!hasFocusedCandidate) {
|
|
50
|
+
if (!container.contains(previouslyFocusedElement)) {
|
|
82
51
|
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
83
|
-
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
84
|
-
container.dispatchEvent(mountEvent);
|
|
85
|
-
if (!mountEvent.defaultPrevented) {
|
|
86
|
-
focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
|
|
87
|
-
if (document.activeElement === previouslyFocusedElement) {
|
|
88
|
-
focus(container);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
52
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus), container.dispatchEvent(mountEvent), mountEvent.defaultPrevented || (focusFirst(removeLinks(getTabbableCandidates(container)), { select: !0 }), document.activeElement === previouslyFocusedElement && focus(container));
|
|
91
53
|
}
|
|
92
54
|
return () => {
|
|
93
55
|
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
94
56
|
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
95
|
-
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
96
|
-
container.dispatchEvent(unmountEvent);
|
|
97
|
-
if (!unmountEvent.defaultPrevented) {
|
|
98
|
-
focus(previouslyFocusedElement ?? document.body, { select: true });
|
|
99
|
-
}
|
|
100
|
-
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
101
|
-
focusScopesStack.remove(focusScope);
|
|
57
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus), container.dispatchEvent(unmountEvent), unmountEvent.defaultPrevented || focus(previouslyFocusedElement ?? document.body, { select: !0 }), container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus), focusScopesStack.remove(focusScope);
|
|
102
58
|
};
|
|
103
59
|
}, [enabled, container, forceUnmount, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
104
60
|
const handleKeyDown = React.useCallback(
|
|
105
61
|
(event) => {
|
|
106
|
-
if (!trapped)
|
|
107
|
-
return;
|
|
108
|
-
if (!loop)
|
|
62
|
+
if (!trapped || !loop || focusScope.paused)
|
|
109
63
|
return;
|
|
110
|
-
|
|
111
|
-
return;
|
|
112
|
-
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
113
|
-
const focusedElement = document.activeElement;
|
|
64
|
+
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey, focusedElement = document.activeElement;
|
|
114
65
|
if (isTabKey && focusedElement) {
|
|
115
|
-
const container2 = event.currentTarget;
|
|
116
|
-
|
|
117
|
-
const hasTabbableElementsInside = first && last;
|
|
118
|
-
if (!hasTabbableElementsInside) {
|
|
119
|
-
if (focusedElement === container2)
|
|
120
|
-
event.preventDefault();
|
|
121
|
-
} else {
|
|
122
|
-
if (!event.shiftKey && focusedElement === last) {
|
|
123
|
-
event.preventDefault();
|
|
124
|
-
if (loop)
|
|
125
|
-
focus(first, { select: true });
|
|
126
|
-
} else if (event.shiftKey && focusedElement === first) {
|
|
127
|
-
event.preventDefault();
|
|
128
|
-
if (loop)
|
|
129
|
-
focus(last, { select: true });
|
|
130
|
-
}
|
|
131
|
-
}
|
|
66
|
+
const container2 = event.currentTarget, [first, last] = getTabbableEdges(container2);
|
|
67
|
+
first && last ? !event.shiftKey && focusedElement === last ? (event.preventDefault(), loop && focus(first, { select: !0 })) : event.shiftKey && focusedElement === first && (event.preventDefault(), loop && focus(last, { select: !0 })) : focusedElement === container2 && event.preventDefault();
|
|
132
68
|
}
|
|
133
69
|
},
|
|
134
70
|
[loop, trapped, focusScope.paused]
|
|
@@ -140,62 +76,52 @@ function useFocusScope(props, forwardedRef) {
|
|
|
140
76
|
onKeyDown: handleKeyDown
|
|
141
77
|
};
|
|
142
78
|
}
|
|
143
|
-
function focusFirst(candidates, { select =
|
|
79
|
+
function focusFirst(candidates, { select = !1 } = {}) {
|
|
144
80
|
const previouslyFocusedElement = document.activeElement;
|
|
145
|
-
for (const candidate of candidates)
|
|
146
|
-
focus(candidate, { select })
|
|
147
|
-
if (document.activeElement !== previouslyFocusedElement)
|
|
81
|
+
for (const candidate of candidates)
|
|
82
|
+
if (focus(candidate, { select }), document.activeElement !== previouslyFocusedElement)
|
|
148
83
|
return;
|
|
149
|
-
}
|
|
150
84
|
}
|
|
151
85
|
function getTabbableEdges(container) {
|
|
152
|
-
const candidates = getTabbableCandidates(container);
|
|
153
|
-
const first = findVisible(candidates, container);
|
|
154
|
-
const last = findVisible(candidates.reverse(), container);
|
|
86
|
+
const candidates = getTabbableCandidates(container), first = findVisible(candidates, container), last = findVisible(candidates.reverse(), container);
|
|
155
87
|
return [first, last];
|
|
156
88
|
}
|
|
157
89
|
function getTabbableCandidates(container) {
|
|
158
|
-
const nodes = []
|
|
159
|
-
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
90
|
+
const nodes = [], walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
160
91
|
acceptNode: (node) => {
|
|
161
92
|
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
162
|
-
|
|
163
|
-
return NodeFilter.FILTER_SKIP;
|
|
164
|
-
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
93
|
+
return node.disabled || node.hidden || isHiddenInput ? NodeFilter.FILTER_SKIP : node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
165
94
|
}
|
|
166
95
|
});
|
|
167
|
-
|
|
96
|
+
for (; walker.nextNode(); )
|
|
168
97
|
nodes.push(walker.currentNode);
|
|
169
98
|
return nodes;
|
|
170
99
|
}
|
|
171
100
|
function findVisible(elements, container) {
|
|
172
|
-
for (const element of elements)
|
|
101
|
+
for (const element of elements)
|
|
173
102
|
if (!isHidden(element, { upTo: container }))
|
|
174
103
|
return element;
|
|
175
|
-
}
|
|
176
104
|
}
|
|
177
105
|
function isHidden(node, { upTo }) {
|
|
178
106
|
if (getComputedStyle(node).visibility === "hidden")
|
|
179
|
-
return
|
|
180
|
-
|
|
107
|
+
return !0;
|
|
108
|
+
for (; node; ) {
|
|
181
109
|
if (upTo !== void 0 && node === upTo)
|
|
182
|
-
return
|
|
110
|
+
return !1;
|
|
183
111
|
if (getComputedStyle(node).display === "none")
|
|
184
|
-
return
|
|
112
|
+
return !0;
|
|
185
113
|
node = node.parentElement;
|
|
186
114
|
}
|
|
187
|
-
return
|
|
115
|
+
return !1;
|
|
188
116
|
}
|
|
189
117
|
function isSelectableInput(element) {
|
|
190
118
|
return element instanceof HTMLInputElement && "select" in element;
|
|
191
119
|
}
|
|
192
|
-
function focus(element, { select =
|
|
120
|
+
function focus(element, { select = !1 } = {}) {
|
|
193
121
|
setTimeout(() => {
|
|
194
|
-
if (element
|
|
122
|
+
if (element?.focus) {
|
|
195
123
|
const previouslyFocusedElement = document.activeElement;
|
|
196
|
-
element.focus({ preventScroll:
|
|
197
|
-
if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
|
|
198
|
-
element.select();
|
|
124
|
+
element.focus({ preventScroll: !0 }), element !== previouslyFocusedElement && isSelectableInput(element) && select && element.select();
|
|
199
125
|
}
|
|
200
126
|
});
|
|
201
127
|
}
|
|
@@ -205,26 +131,16 @@ function createFocusScopesStack() {
|
|
|
205
131
|
return {
|
|
206
132
|
add(focusScope) {
|
|
207
133
|
const activeFocusScope = stack[0];
|
|
208
|
-
|
|
209
|
-
activeFocusScope == null ? void 0 : activeFocusScope.pause();
|
|
210
|
-
}
|
|
211
|
-
stack = arrayRemove(stack, focusScope);
|
|
212
|
-
stack.unshift(focusScope);
|
|
134
|
+
focusScope !== activeFocusScope && activeFocusScope?.pause(), stack = arrayRemove(stack, focusScope), stack.unshift(focusScope);
|
|
213
135
|
},
|
|
214
136
|
remove(focusScope) {
|
|
215
|
-
|
|
216
|
-
stack = arrayRemove(stack, focusScope);
|
|
217
|
-
(_a = stack[0]) == null ? void 0 : _a.resume();
|
|
137
|
+
stack = arrayRemove(stack, focusScope), stack[0]?.resume();
|
|
218
138
|
}
|
|
219
139
|
};
|
|
220
140
|
}
|
|
221
141
|
function arrayRemove(array, item) {
|
|
222
|
-
const updatedArray = [...array];
|
|
223
|
-
|
|
224
|
-
if (index !== -1) {
|
|
225
|
-
updatedArray.splice(index, 1);
|
|
226
|
-
}
|
|
227
|
-
return updatedArray;
|
|
142
|
+
const updatedArray = [...array], index = updatedArray.indexOf(item);
|
|
143
|
+
return index !== -1 && updatedArray.splice(index, 1), updatedArray;
|
|
228
144
|
}
|
|
229
145
|
function removeLinks(items) {
|
|
230
146
|
return items.filter((item) => item.tagName !== "A");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/FocusScope.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": ["
|
|
4
|
+
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,YAAY,WAAW;AAqBV;AAjBb,MAAM,qBAAqB,+BACrB,uBAAuB,iCACvB,gBAAgB,EAAE,SAAS,IAAO,YAAY,GAAK,GAUnD,aAAa,MAAM;AAAA,EACvB,SAAoB,OAAO,cAAc;AACvC,UAAM,aAAa,cAAc,OAAO,YAAY;AAEpD,WAAI,OAAO,MAAM,YAAa,aACrB,gCAAG,gBAAM,SAAS,UAAU,GAAE,IAGhC,MAAM,aAAa,MAAM,SAAS,KAAK,MAAM,QAAQ,GAAU,UAAU;AAAA,EAClF;AACF;AAMO,SAAS,cACd,OACA,cACA;AACA,QAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAAU;AAAA,IACV,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,OACE,CAAC,WAAW,YAAY,IAAI,MAAM,SAA6B,IAAI,GACnE,mBAAmB,SAAS,oBAAoB,GAChD,qBAAqB,SAAS,sBAAsB,GACpD,wBAAwB,MAAM,OAA2B,IAAI,GAC7D,eAAe,gBAAgB,cAAc,CAAC,SAAS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,YAAY,4BAA4B,kBAAkB,OAAO,KAAK,UACxE,QAAQ,OAAO;AAAA,IACnB;AAAA,EACF,CAAC;AACH;AAOA,MAAM,mBAAmB,uBAAuB;AAEhD,SAAS,yBAAyB;AAEhC,MAAI,QAAyB,CAAC;AAE9B,SAAO;AAAA,IACL,IAAI,YAA2B;AAE7B,YAAM,mBAAmB,MAAM,CAAC;AAChC,MAAI,eAAe,oBACjB,kBAAkB,MAAM,GAG1B,QAAQ,YAAY,OAAO,UAAU,GACrC,MAAM,QAAQ,UAAU;AAAA,IAC1B;AAAA,IAEA,OAAO,YAA2B;AAChC,cAAQ,YAAY,OAAO,UAAU,GACrC,MAAM,CAAC,GAAG,OAAO;AAAA,IACnB;AAAA,EACF;AACF;AAEA,SAAS,YAAe,OAAY,MAAS;AAC3C,QAAM,eAAe,CAAC,GAAG,KAAK,GACxB,QAAQ,aAAa,QAAQ,IAAI;AACvC,SAAI,UAAU,MACZ,aAAa,OAAO,OAAO,CAAC,GAEvB;AACT;AAEA,SAAS,YAAY,OAAsB;AACzC,SAAO,MAAM,OAAO,CAAC,SAAS,KAAK,YAAY,GAAG;AACpD;",
|
|
5
|
+
"names": ["container"]
|
|
6
6
|
}
|
package/dist/jsx/FocusScope.js
CHANGED
|
@@ -1,133 +1,69 @@
|
|
|
1
1
|
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
2
2
|
import { useEvent } from "@tamagui/use-event";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount"
|
|
5
|
-
|
|
6
|
-
const EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
7
|
-
const FocusScope = React.forwardRef(
|
|
8
|
-
function FocusScope2(props, forwardedRef) {
|
|
4
|
+
const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount", AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount", EVENT_OPTIONS = { bubbles: !1, cancelable: !0 }, FocusScope = React.forwardRef(
|
|
5
|
+
function(props, forwardedRef) {
|
|
9
6
|
const childProps = useFocusScope(props, forwardedRef);
|
|
10
|
-
|
|
11
|
-
return <>{props.children(childProps)}</>;
|
|
12
|
-
}
|
|
13
|
-
return React.cloneElement(React.Children.only(props.children), childProps);
|
|
7
|
+
return typeof props.children == "function" ? <>{props.children(childProps)}</> : React.cloneElement(React.Children.only(props.children), childProps);
|
|
14
8
|
}
|
|
15
9
|
);
|
|
16
10
|
function useFocusScope(props, forwardedRef) {
|
|
17
11
|
const {
|
|
18
|
-
loop =
|
|
19
|
-
enabled =
|
|
20
|
-
trapped =
|
|
12
|
+
loop = !1,
|
|
13
|
+
enabled = !0,
|
|
14
|
+
trapped = !1,
|
|
21
15
|
onMountAutoFocus: onMountAutoFocusProp,
|
|
22
16
|
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
23
17
|
forceUnmount,
|
|
24
18
|
children,
|
|
25
19
|
...scopeProps
|
|
26
|
-
} = props
|
|
27
|
-
|
|
28
|
-
const onMountAutoFocus = useEvent(onMountAutoFocusProp);
|
|
29
|
-
const onUnmountAutoFocus = useEvent(onUnmountAutoFocusProp);
|
|
30
|
-
const lastFocusedElementRef = React.useRef(null);
|
|
31
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
|
|
32
|
-
const focusScope = React.useRef({
|
|
33
|
-
paused: false,
|
|
20
|
+
} = props, [container, setContainer] = React.useState(null), onMountAutoFocus = useEvent(onMountAutoFocusProp), onUnmountAutoFocus = useEvent(onUnmountAutoFocusProp), lastFocusedElementRef = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node)), focusScope = React.useRef({
|
|
21
|
+
paused: !1,
|
|
34
22
|
pause() {
|
|
35
|
-
this.paused =
|
|
23
|
+
this.paused = !0;
|
|
36
24
|
},
|
|
37
25
|
resume() {
|
|
38
|
-
this.paused =
|
|
26
|
+
this.paused = !1;
|
|
39
27
|
}
|
|
40
28
|
}).current;
|
|
41
29
|
React.useEffect(() => {
|
|
42
|
-
if (!enabled)
|
|
43
|
-
return;
|
|
44
|
-
if (!trapped)
|
|
30
|
+
if (!enabled || !trapped)
|
|
45
31
|
return;
|
|
46
32
|
function handleFocusIn(event) {
|
|
47
33
|
if (focusScope.paused || !container)
|
|
48
34
|
return;
|
|
49
35
|
const target = event.target;
|
|
50
|
-
|
|
51
|
-
lastFocusedElementRef.current = target;
|
|
52
|
-
} else {
|
|
53
|
-
focus(lastFocusedElementRef.current, { select: true });
|
|
54
|
-
}
|
|
36
|
+
container.contains(target) ? lastFocusedElementRef.current = target : focus(lastFocusedElementRef.current, { select: !0 });
|
|
55
37
|
}
|
|
56
38
|
function handleFocusOut(event) {
|
|
57
|
-
|
|
58
|
-
return;
|
|
59
|
-
if (!container.contains(event.relatedTarget)) {
|
|
60
|
-
focus(lastFocusedElementRef.current, { select: true });
|
|
61
|
-
}
|
|
39
|
+
focusScope.paused || !container || container.contains(event.relatedTarget) || focus(lastFocusedElementRef.current, { select: !0 });
|
|
62
40
|
}
|
|
63
|
-
document.addEventListener("focusin", handleFocusIn)
|
|
64
|
-
|
|
65
|
-
return () => {
|
|
66
|
-
document.removeEventListener("focusin", handleFocusIn);
|
|
67
|
-
document.removeEventListener("focusout", handleFocusOut);
|
|
41
|
+
return document.addEventListener("focusin", handleFocusIn), document.addEventListener("focusout", handleFocusOut), () => {
|
|
42
|
+
document.removeEventListener("focusin", handleFocusIn), document.removeEventListener("focusout", handleFocusOut);
|
|
68
43
|
};
|
|
69
|
-
}, [trapped, forceUnmount, container, focusScope.paused])
|
|
70
|
-
|
|
71
|
-
if (!enabled)
|
|
72
|
-
return;
|
|
73
|
-
if (!container)
|
|
74
|
-
return;
|
|
75
|
-
if (forceUnmount)
|
|
44
|
+
}, [trapped, forceUnmount, container, focusScope.paused]), React.useEffect(() => {
|
|
45
|
+
if (!enabled || !container || forceUnmount)
|
|
76
46
|
return;
|
|
77
47
|
focusScopesStack.add(focusScope);
|
|
78
48
|
const previouslyFocusedElement = document.activeElement;
|
|
79
|
-
|
|
80
|
-
if (!hasFocusedCandidate) {
|
|
49
|
+
if (!container.contains(previouslyFocusedElement)) {
|
|
81
50
|
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
82
|
-
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
83
|
-
container.dispatchEvent(mountEvent);
|
|
84
|
-
if (!mountEvent.defaultPrevented) {
|
|
85
|
-
focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
|
|
86
|
-
if (document.activeElement === previouslyFocusedElement) {
|
|
87
|
-
focus(container);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
51
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus), container.dispatchEvent(mountEvent), mountEvent.defaultPrevented || (focusFirst(removeLinks(getTabbableCandidates(container)), { select: !0 }), document.activeElement === previouslyFocusedElement && focus(container));
|
|
90
52
|
}
|
|
91
53
|
return () => {
|
|
92
54
|
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
93
55
|
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
94
|
-
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
95
|
-
container.dispatchEvent(unmountEvent);
|
|
96
|
-
if (!unmountEvent.defaultPrevented) {
|
|
97
|
-
focus(previouslyFocusedElement ?? document.body, { select: true });
|
|
98
|
-
}
|
|
99
|
-
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
100
|
-
focusScopesStack.remove(focusScope);
|
|
56
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus), container.dispatchEvent(unmountEvent), unmountEvent.defaultPrevented || focus(previouslyFocusedElement ?? document.body, { select: !0 }), container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus), focusScopesStack.remove(focusScope);
|
|
101
57
|
};
|
|
102
58
|
}, [enabled, container, forceUnmount, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
103
59
|
const handleKeyDown = React.useCallback(
|
|
104
60
|
(event) => {
|
|
105
|
-
if (!trapped)
|
|
106
|
-
return;
|
|
107
|
-
if (!loop)
|
|
108
|
-
return;
|
|
109
|
-
if (focusScope.paused)
|
|
61
|
+
if (!trapped || !loop || focusScope.paused)
|
|
110
62
|
return;
|
|
111
|
-
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
112
|
-
const focusedElement = document.activeElement;
|
|
63
|
+
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey, focusedElement = document.activeElement;
|
|
113
64
|
if (isTabKey && focusedElement) {
|
|
114
|
-
const container2 = event.currentTarget;
|
|
115
|
-
|
|
116
|
-
const hasTabbableElementsInside = first && last;
|
|
117
|
-
if (!hasTabbableElementsInside) {
|
|
118
|
-
if (focusedElement === container2)
|
|
119
|
-
event.preventDefault();
|
|
120
|
-
} else {
|
|
121
|
-
if (!event.shiftKey && focusedElement === last) {
|
|
122
|
-
event.preventDefault();
|
|
123
|
-
if (loop)
|
|
124
|
-
focus(first, { select: true });
|
|
125
|
-
} else if (event.shiftKey && focusedElement === first) {
|
|
126
|
-
event.preventDefault();
|
|
127
|
-
if (loop)
|
|
128
|
-
focus(last, { select: true });
|
|
129
|
-
}
|
|
130
|
-
}
|
|
65
|
+
const container2 = event.currentTarget, [first, last] = getTabbableEdges(container2);
|
|
66
|
+
first && last ? !event.shiftKey && focusedElement === last ? (event.preventDefault(), loop && focus(first, { select: !0 })) : event.shiftKey && focusedElement === first && (event.preventDefault(), loop && focus(last, { select: !0 })) : focusedElement === container2 && event.preventDefault();
|
|
131
67
|
}
|
|
132
68
|
},
|
|
133
69
|
[loop, trapped, focusScope.paused]
|
|
@@ -139,62 +75,52 @@ function useFocusScope(props, forwardedRef) {
|
|
|
139
75
|
onKeyDown: handleKeyDown
|
|
140
76
|
};
|
|
141
77
|
}
|
|
142
|
-
function focusFirst(candidates, { select =
|
|
78
|
+
function focusFirst(candidates, { select = !1 } = {}) {
|
|
143
79
|
const previouslyFocusedElement = document.activeElement;
|
|
144
|
-
for (const candidate of candidates)
|
|
145
|
-
focus(candidate, { select })
|
|
146
|
-
if (document.activeElement !== previouslyFocusedElement)
|
|
80
|
+
for (const candidate of candidates)
|
|
81
|
+
if (focus(candidate, { select }), document.activeElement !== previouslyFocusedElement)
|
|
147
82
|
return;
|
|
148
|
-
}
|
|
149
83
|
}
|
|
150
84
|
function getTabbableEdges(container) {
|
|
151
|
-
const candidates = getTabbableCandidates(container);
|
|
152
|
-
const first = findVisible(candidates, container);
|
|
153
|
-
const last = findVisible(candidates.reverse(), container);
|
|
85
|
+
const candidates = getTabbableCandidates(container), first = findVisible(candidates, container), last = findVisible(candidates.reverse(), container);
|
|
154
86
|
return [first, last];
|
|
155
87
|
}
|
|
156
88
|
function getTabbableCandidates(container) {
|
|
157
|
-
const nodes = []
|
|
158
|
-
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
89
|
+
const nodes = [], walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
159
90
|
acceptNode: (node) => {
|
|
160
91
|
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
161
|
-
|
|
162
|
-
return NodeFilter.FILTER_SKIP;
|
|
163
|
-
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
92
|
+
return node.disabled || node.hidden || isHiddenInput ? NodeFilter.FILTER_SKIP : node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
164
93
|
}
|
|
165
94
|
});
|
|
166
|
-
|
|
95
|
+
for (; walker.nextNode(); )
|
|
167
96
|
nodes.push(walker.currentNode);
|
|
168
97
|
return nodes;
|
|
169
98
|
}
|
|
170
99
|
function findVisible(elements, container) {
|
|
171
|
-
for (const element of elements)
|
|
100
|
+
for (const element of elements)
|
|
172
101
|
if (!isHidden(element, { upTo: container }))
|
|
173
102
|
return element;
|
|
174
|
-
}
|
|
175
103
|
}
|
|
176
104
|
function isHidden(node, { upTo }) {
|
|
177
105
|
if (getComputedStyle(node).visibility === "hidden")
|
|
178
|
-
return
|
|
179
|
-
|
|
106
|
+
return !0;
|
|
107
|
+
for (; node; ) {
|
|
180
108
|
if (upTo !== void 0 && node === upTo)
|
|
181
|
-
return
|
|
109
|
+
return !1;
|
|
182
110
|
if (getComputedStyle(node).display === "none")
|
|
183
|
-
return
|
|
111
|
+
return !0;
|
|
184
112
|
node = node.parentElement;
|
|
185
113
|
}
|
|
186
|
-
return
|
|
114
|
+
return !1;
|
|
187
115
|
}
|
|
188
116
|
function isSelectableInput(element) {
|
|
189
117
|
return element instanceof HTMLInputElement && "select" in element;
|
|
190
118
|
}
|
|
191
|
-
function focus(element, { select =
|
|
119
|
+
function focus(element, { select = !1 } = {}) {
|
|
192
120
|
setTimeout(() => {
|
|
193
121
|
if (element?.focus) {
|
|
194
122
|
const previouslyFocusedElement = document.activeElement;
|
|
195
|
-
element.focus({ preventScroll:
|
|
196
|
-
if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
|
|
197
|
-
element.select();
|
|
123
|
+
element.focus({ preventScroll: !0 }), element !== previouslyFocusedElement && isSelectableInput(element) && select && element.select();
|
|
198
124
|
}
|
|
199
125
|
});
|
|
200
126
|
}
|
|
@@ -204,25 +130,16 @@ function createFocusScopesStack() {
|
|
|
204
130
|
return {
|
|
205
131
|
add(focusScope) {
|
|
206
132
|
const activeFocusScope = stack[0];
|
|
207
|
-
|
|
208
|
-
activeFocusScope?.pause();
|
|
209
|
-
}
|
|
210
|
-
stack = arrayRemove(stack, focusScope);
|
|
211
|
-
stack.unshift(focusScope);
|
|
133
|
+
focusScope !== activeFocusScope && activeFocusScope?.pause(), stack = arrayRemove(stack, focusScope), stack.unshift(focusScope);
|
|
212
134
|
},
|
|
213
135
|
remove(focusScope) {
|
|
214
|
-
stack = arrayRemove(stack, focusScope);
|
|
215
|
-
stack[0]?.resume();
|
|
136
|
+
stack = arrayRemove(stack, focusScope), stack[0]?.resume();
|
|
216
137
|
}
|
|
217
138
|
};
|
|
218
139
|
}
|
|
219
140
|
function arrayRemove(array, item) {
|
|
220
|
-
const updatedArray = [...array];
|
|
221
|
-
|
|
222
|
-
if (index !== -1) {
|
|
223
|
-
updatedArray.splice(index, 1);
|
|
224
|
-
}
|
|
225
|
-
return updatedArray;
|
|
141
|
+
const updatedArray = [...array], index = updatedArray.indexOf(item);
|
|
142
|
+
return index !== -1 && updatedArray.splice(index, 1), updatedArray;
|
|
226
143
|
}
|
|
227
144
|
function removeLinks(items) {
|
|
228
145
|
return items.filter((item) => item.tagName !== "A");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/FocusScope.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,YAAY,WAAW;AAIvB,MAAM,qBAAqB
|
|
5
|
-
"names": ["
|
|
4
|
+
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,YAAY,WAAW;AAIvB,MAAM,qBAAqB,+BACrB,uBAAuB,iCACvB,gBAAgB,EAAE,SAAS,IAAO,YAAY,GAAK,GAUnD,aAAa,MAAM;AAAA,EACvB,SAAoB,OAAO,cAAc;AACvC,UAAM,aAAa,cAAc,OAAO,YAAY;AAEpD,WAAI,OAAO,MAAM,YAAa,aACrB,GAAG,MAAM,SAAS,UAAU,EAAE,MAGhC,MAAM,aAAa,MAAM,SAAS,KAAK,MAAM,QAAQ,GAAU,UAAU;AAAA,EAClF;AACF;AAMO,SAAS,cACd,OACA,cACA;AACA,QAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV,UAA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K;AAAA,EACd;AACA,SAAO;AACT;AAEA,SAAS,kBACP,SACqD;AACrD,SAAO,mBAAmB,oBAAoB,YAAY;AAC5D;AAEA,SAAS,MAAM,SAAkC,EAAE,SAAS,GAAM,IAAI,CAAC,GAAG;AAGxE,aAAW,MAAM;AAEf,QAAI,SAAS,OAAO;AAClB,YAAM,2BAA2B,SAAS;AAE1C,cAAQ,MAAM,EAAE,eAAe,GAAK,CAAC,GAEjC,YAAY,4BAA4B,kBAAkB,OAAO,KAAK,UACxE,QAAQ,OAAO;AAAA,IACnB;AAAA,EACF,CAAC;AACH;AAOA,MAAM,mBAAmB,uBAAuB;AAEhD,SAAS,yBAAyB;AAEhC,MAAI,QAAyB,CAAC;AAE9B,SAAO;AAAA,IACL,IAAI,YAA2B;AAE7B,YAAM,mBAAmB,MAAM,CAAC;AAChC,MAAI,eAAe,oBACjB,kBAAkB,MAAM,GAG1B,QAAQ,YAAY,OAAO,UAAU,GACrC,MAAM,QAAQ,UAAU;AAAA,IAC1B;AAAA,IAEA,OAAO,YAA2B;AAChC,cAAQ,YAAY,OAAO,UAAU,GACrC,MAAM,CAAC,GAAG,OAAO;AAAA,IACnB;AAAA,EACF;AACF;AAEA,SAAS,YAAe,OAAY,MAAS;AAC3C,QAAM,eAAe,CAAC,GAAG,KAAK,GACxB,QAAQ,aAAa,QAAQ,IAAI;AACvC,SAAI,UAAU,MACZ,aAAa,OAAO,OAAO,CAAC,GAEvB;AACT;AAEA,SAAS,YAAY,OAAsB;AACzC,SAAO,MAAM,OAAO,CAAC,SAAS,KAAK,YAAY,GAAG;AACpD;",
|
|
5
|
+
"names": ["container"]
|
|
6
6
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=FocusScopeProps.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/focus-scope",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.62.1",
|
|
4
4
|
"sideEffects": true,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"clean:build": "tamagui-build clean:build"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tamagui/compose-refs": "1.
|
|
25
|
-
"@tamagui/use-event": "1.
|
|
24
|
+
"@tamagui/compose-refs": "1.62.1",
|
|
25
|
+
"@tamagui/use-event": "1.62.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "*"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@tamagui/build": "1.
|
|
31
|
+
"@tamagui/build": "1.62.1",
|
|
32
32
|
"react": "^18.2.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|