@tamagui/focus-scope 1.127.3 → 1.128.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.
Files changed (86) hide show
  1. package/dist/cjs/FocusScope.cjs +29 -8
  2. package/dist/cjs/FocusScope.js +48 -20
  3. package/dist/cjs/FocusScope.js.map +1 -1
  4. package/dist/cjs/FocusScopeController.cjs +76 -0
  5. package/dist/cjs/FocusScopeController.js +69 -0
  6. package/dist/cjs/FocusScopeController.js.map +6 -0
  7. package/dist/cjs/FocusScopeController.native.js +67 -0
  8. package/dist/cjs/FocusScopeController.native.js.map +6 -0
  9. package/dist/cjs/index.cjs +2 -1
  10. package/dist/cjs/index.js +1 -0
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/index.native.js +3 -1
  13. package/dist/cjs/index.native.js.map +1 -1
  14. package/dist/cjs/{FocusScopeProps.cjs → types.cjs} +2 -2
  15. package/dist/cjs/{FocusScopeProps.js → types.js} +3 -3
  16. package/dist/cjs/{FocusScopeProps.js.map → types.js.map} +1 -1
  17. package/dist/cjs/{FocusScopeProps.native.js → types.native.js} +3 -3
  18. package/dist/cjs/types.native.js.map +6 -0
  19. package/dist/esm/FocusScope.js +50 -20
  20. package/dist/esm/FocusScope.js.map +1 -1
  21. package/dist/esm/FocusScope.mjs +29 -8
  22. package/dist/esm/FocusScope.mjs.map +1 -1
  23. package/dist/esm/FocusScopeController.js +48 -0
  24. package/dist/esm/FocusScopeController.js.map +6 -0
  25. package/dist/esm/FocusScopeController.mjs +39 -0
  26. package/dist/esm/FocusScopeController.mjs.map +1 -0
  27. package/dist/esm/FocusScopeController.native.js +41 -0
  28. package/dist/esm/FocusScopeController.native.js.map +1 -0
  29. package/dist/esm/index.js +1 -0
  30. package/dist/esm/index.js.map +1 -1
  31. package/dist/esm/index.mjs +1 -0
  32. package/dist/esm/index.mjs.map +1 -1
  33. package/dist/esm/index.native.js +1 -0
  34. package/dist/esm/index.native.js.map +1 -1
  35. package/dist/esm/types.js +1 -0
  36. package/dist/esm/types.mjs +2 -0
  37. package/dist/esm/types.native.js +2 -0
  38. package/dist/jsx/FocusScope.js +50 -20
  39. package/dist/jsx/FocusScope.js.map +1 -1
  40. package/dist/jsx/FocusScope.mjs +29 -8
  41. package/dist/jsx/FocusScope.mjs.map +1 -1
  42. package/dist/jsx/FocusScopeController.js +48 -0
  43. package/dist/jsx/FocusScopeController.js.map +6 -0
  44. package/dist/jsx/FocusScopeController.mjs +39 -0
  45. package/dist/jsx/FocusScopeController.mjs.map +1 -0
  46. package/dist/jsx/FocusScopeController.native.js +39 -0
  47. package/dist/jsx/FocusScopeController.native.js.map +6 -0
  48. package/dist/jsx/index.js +1 -0
  49. package/dist/jsx/index.js.map +1 -1
  50. package/dist/jsx/index.mjs +1 -0
  51. package/dist/jsx/index.mjs.map +1 -1
  52. package/dist/jsx/index.native.js +1 -0
  53. package/dist/jsx/index.native.js.map +1 -1
  54. package/dist/jsx/types.js +1 -0
  55. package/dist/jsx/types.mjs +2 -0
  56. package/dist/jsx/types.native.js +1 -0
  57. package/package.json +7 -5
  58. package/src/FocusScope.native.tsx +1 -1
  59. package/src/FocusScope.tsx +83 -38
  60. package/src/FocusScopeController.tsx +78 -0
  61. package/src/index.ts +1 -0
  62. package/src/{FocusScopeProps.tsx → types.tsx} +10 -0
  63. package/types/FocusScope.d.ts +1 -1
  64. package/types/FocusScope.d.ts.map +1 -1
  65. package/types/FocusScope.native.d.ts +1 -1
  66. package/types/FocusScope.native.d.ts.map +1 -1
  67. package/types/FocusScopeController.d.ts +19 -0
  68. package/types/FocusScopeController.d.ts.map +1 -0
  69. package/types/index.d.ts +1 -0
  70. package/types/index.d.ts.map +1 -1
  71. package/types/{FocusScopeProps.d.ts → types.d.ts} +11 -1
  72. package/types/types.d.ts.map +1 -0
  73. package/dist/cjs/FocusScopeProps.native.js.map +0 -6
  74. package/dist/esm/FocusScopeProps.js +0 -1
  75. package/dist/esm/FocusScopeProps.mjs +0 -2
  76. package/dist/esm/FocusScopeProps.native.js +0 -2
  77. package/dist/jsx/FocusScopeProps.js +0 -1
  78. package/dist/jsx/FocusScopeProps.mjs +0 -2
  79. package/dist/jsx/FocusScopeProps.native.js +0 -1
  80. package/types/FocusScopeProps.d.ts.map +0 -1
  81. /package/dist/esm/{FocusScopeProps.js.map → types.js.map} +0 -0
  82. /package/dist/esm/{FocusScopeProps.mjs.map → types.mjs.map} +0 -0
  83. /package/dist/esm/{FocusScopeProps.native.js.map → types.native.js.map} +0 -0
  84. /package/dist/jsx/{FocusScopeProps.js.map → types.js.map} +0 -0
  85. /package/dist/jsx/{FocusScopeProps.mjs.map → types.mjs.map} +0 -0
  86. /package/dist/jsx/{FocusScopeProps.native.js.map → types.native.js.map} +0 -0
@@ -36,9 +36,11 @@ __export(FocusScope_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(FocusScope_exports);
38
38
  var import_compose_refs = require("@tamagui/compose-refs"),
39
- import_use_event = require("@tamagui/use-event"),
40
39
  import_start_transition = require("@tamagui/start-transition"),
40
+ import_use_async = require("@tamagui/use-async"),
41
+ import_use_event = require("@tamagui/use-event"),
41
42
  React = __toESM(require("react")),
43
+ import_FocusScopeController = require("./FocusScopeController.cjs"),
42
44
  import_jsx_runtime = require("react/jsx-runtime");
43
45
  const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount",
44
46
  AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount",
@@ -46,11 +48,28 @@ const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount",
46
48
  bubbles: !1,
47
49
  cancelable: !0
48
50
  },
49
- FocusScope = React.forwardRef(function (props, forwardedRef) {
50
- const childProps = useFocusScope(props, forwardedRef);
51
- return typeof props.children == "function" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
52
- children: props.children(childProps)
53
- }) : React.cloneElement(React.Children.only(props.children), childProps);
51
+ FocusScope = React.forwardRef(function ({
52
+ __scopeFocusScope,
53
+ ...props
54
+ }, forwardedRef) {
55
+ const context = (0, import_FocusScopeController.useFocusScopeControllerContext)("FocusScope", __scopeFocusScope, {
56
+ warn: !1,
57
+ fallback: {}
58
+ }),
59
+ mergedProps = {
60
+ ...props,
61
+ enabled: context.enabled ?? props.enabled,
62
+ loop: context.loop ?? props.loop,
63
+ trapped: context.trapped ?? props.trapped,
64
+ onMountAutoFocus: context.onMountAutoFocus ?? props.onMountAutoFocus,
65
+ onUnmountAutoFocus: context.onUnmountAutoFocus ?? props.onUnmountAutoFocus,
66
+ forceUnmount: context.forceUnmount ?? props.forceUnmount,
67
+ focusOnIdle: context.focusOnIdle ?? props.focusOnIdle
68
+ },
69
+ childProps = useFocusScope(mergedProps, forwardedRef);
70
+ return typeof mergedProps.children == "function" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
71
+ children: mergedProps.children(childProps)
72
+ }) : React.cloneElement(React.Children.only(mergedProps.children), childProps);
54
73
  });
55
74
  function useFocusScope(props, forwardedRef) {
56
75
  const {
@@ -60,6 +79,7 @@ function useFocusScope(props, forwardedRef) {
60
79
  onMountAutoFocus: onMountAutoFocusProp,
61
80
  onUnmountAutoFocus: onUnmountAutoFocusProp,
62
81
  forceUnmount,
82
+ focusOnIdle = !0,
63
83
  children,
64
84
  ...scopeProps
65
85
  } = props,
@@ -105,13 +125,14 @@ function useFocusScope(props, forwardedRef) {
105
125
  return document.addEventListener("focusin", handleFocusIn), document.addEventListener("focusout", handleFocusOut), () => {
106
126
  controller.abort(), document.removeEventListener("focusin", handleFocusIn), document.removeEventListener("focusout", handleFocusOut);
107
127
  };
108
- }, [trapped, forceUnmount, container, focusScope.paused]), React.useEffect(() => {
128
+ }, [trapped, forceUnmount, container, focusScope.paused]), (0, import_use_async.useAsyncEffect)(async signal => {
109
129
  if (!enabled || !container || forceUnmount) return;
110
130
  focusScopesStack.add(focusScope);
111
131
  const previouslyFocusedElement = document.activeElement;
112
132
  if (!container.contains(previouslyFocusedElement)) {
113
133
  const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
114
134
  if (container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus), container.dispatchEvent(mountEvent), !mountEvent.defaultPrevented) {
135
+ focusOnIdle && (await (0, import_use_async.sleep)(typeof focusOnIdle == "number" ? focusOnIdle : 16, signal), await (0, import_use_async.fullyIdle)(signal));
115
136
  const candidates = removeLinks(getTabbableCandidates(container));
116
137
  focusFirst(candidates, {
117
138
  select: !0
@@ -125,7 +146,7 @@ function useFocusScope(props, forwardedRef) {
125
146
  select: !0
126
147
  }), container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus), focusScopesStack.remove(focusScope);
127
148
  };
128
- }, [enabled, container, forceUnmount, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
149
+ }, [enabled, container, forceUnmount, onMountAutoFocus, onUnmountAutoFocus, focusScope, focusOnIdle]);
129
150
  const handleKeyDown = React.useCallback(event => {
130
151
  if (!trapped || !loop || focusScope.paused) return;
131
152
  const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey,
@@ -26,11 +26,26 @@ __export(FocusScope_exports, {
26
26
  useFocusScope: () => useFocusScope
27
27
  });
28
28
  module.exports = __toCommonJS(FocusScope_exports);
29
- var import_compose_refs = require("@tamagui/compose-refs"), import_use_event = require("@tamagui/use-event"), import_start_transition = require("@tamagui/start-transition"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
29
+ var import_compose_refs = require("@tamagui/compose-refs"), import_start_transition = require("@tamagui/start-transition"), import_use_async = require("@tamagui/use-async"), import_use_event = require("@tamagui/use-event"), React = __toESM(require("react")), import_FocusScopeController = require("./FocusScopeController"), import_jsx_runtime = require("react/jsx-runtime");
30
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) {
32
- const childProps = useFocusScope(props, forwardedRef);
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);
31
+ function({ __scopeFocusScope, ...props }, forwardedRef) {
32
+ const context = (0, import_FocusScopeController.useFocusScopeControllerContext)("FocusScope", __scopeFocusScope, {
33
+ warn: !1,
34
+ fallback: {}
35
+ }), mergedProps = {
36
+ ...props,
37
+ enabled: context.enabled ?? props.enabled,
38
+ loop: context.loop ?? props.loop,
39
+ trapped: context.trapped ?? props.trapped,
40
+ onMountAutoFocus: context.onMountAutoFocus ?? props.onMountAutoFocus,
41
+ onUnmountAutoFocus: context.onUnmountAutoFocus ?? props.onUnmountAutoFocus,
42
+ forceUnmount: context.forceUnmount ?? props.forceUnmount,
43
+ focusOnIdle: context.focusOnIdle ?? props.focusOnIdle
44
+ }, childProps = useFocusScope(mergedProps, forwardedRef);
45
+ return typeof mergedProps.children == "function" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: mergedProps.children(childProps) }) : React.cloneElement(
46
+ React.Children.only(mergedProps.children),
47
+ childProps
48
+ );
34
49
  }
35
50
  );
36
51
  function useFocusScope(props, forwardedRef) {
@@ -41,6 +56,7 @@ function useFocusScope(props, forwardedRef) {
41
56
  onMountAutoFocus: onMountAutoFocusProp,
42
57
  onUnmountAutoFocus: onUnmountAutoFocusProp,
43
58
  forceUnmount,
59
+ focusOnIdle = !0,
44
60
  children,
45
61
  ...scopeProps
46
62
  } = props, [container, setContainer] = React.useState(null), onMountAutoFocus = (0, import_use_event.useEvent)(onMountAutoFocusProp), onUnmountAutoFocus = (0, import_use_event.useEvent)(onUnmountAutoFocusProp), lastFocusedElementRef = React.useRef(null), setContainerTransition = React.useCallback(
@@ -76,23 +92,35 @@ function useFocusScope(props, forwardedRef) {
76
92
  return document.addEventListener("focusin", handleFocusIn), document.addEventListener("focusout", handleFocusOut), () => {
77
93
  controller.abort(), document.removeEventListener("focusin", handleFocusIn), document.removeEventListener("focusout", handleFocusOut);
78
94
  };
79
- }, [trapped, forceUnmount, container, focusScope.paused]), React.useEffect(() => {
80
- if (!enabled || !container || forceUnmount) return;
81
- focusScopesStack.add(focusScope);
82
- const previouslyFocusedElement = document.activeElement;
83
- if (!container.contains(previouslyFocusedElement)) {
84
- const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
85
- if (container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus), container.dispatchEvent(mountEvent), !mountEvent.defaultPrevented) {
86
- const candidates = removeLinks(getTabbableCandidates(container));
87
- focusFirst(candidates, { select: !0 }), document.activeElement === previouslyFocusedElement && focus(container);
95
+ }, [trapped, forceUnmount, container, focusScope.paused]), (0, import_use_async.useAsyncEffect)(
96
+ async (signal) => {
97
+ if (!enabled || !container || forceUnmount) return;
98
+ focusScopesStack.add(focusScope);
99
+ const previouslyFocusedElement = document.activeElement;
100
+ if (!container.contains(previouslyFocusedElement)) {
101
+ const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
102
+ if (container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus), container.dispatchEvent(mountEvent), !mountEvent.defaultPrevented) {
103
+ focusOnIdle && (await (0, import_use_async.sleep)(typeof focusOnIdle == "number" ? focusOnIdle : 16, signal), await (0, import_use_async.fullyIdle)(signal));
104
+ const candidates = removeLinks(getTabbableCandidates(container));
105
+ focusFirst(candidates, { select: !0 }), document.activeElement === previouslyFocusedElement && focus(container);
106
+ }
88
107
  }
89
- }
90
- return () => {
91
- container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
92
- const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
93
- 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);
94
- };
95
- }, [enabled, container, forceUnmount, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
108
+ return () => {
109
+ container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
110
+ const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
111
+ 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);
112
+ };
113
+ },
114
+ [
115
+ enabled,
116
+ container,
117
+ forceUnmount,
118
+ onMountAutoFocus,
119
+ onUnmountAutoFocus,
120
+ focusScope,
121
+ focusOnIdle
122
+ ]
123
+ );
96
124
  const handleKeyDown = React.useCallback(
97
125
  (event) => {
98
126
  if (!trapped || !loop || focusScope.paused) return;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/FocusScope.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAgC,kCAChC,mBAAyB,+BACzB,0BAAgC,sCAChC,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,GA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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
5
  "names": ["container"]
6
6
  }
@@ -0,0 +1,76 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var FocusScopeController_exports = {};
33
+ __export(FocusScopeController_exports, {
34
+ FocusScopeController: () => FocusScopeControllerComponent,
35
+ FocusScopeControllerProvider: () => FocusScopeControllerProvider,
36
+ createFocusScopeControllerScope: () => createFocusScopeControllerScope,
37
+ useFocusScopeControllerContext: () => useFocusScopeControllerContext
38
+ });
39
+ module.exports = __toCommonJS(FocusScopeController_exports);
40
+ var import_create_context = require("@tamagui/create-context"),
41
+ import_use_event = require("@tamagui/use-event"),
42
+ React = __toESM(require("react")),
43
+ import_jsx_runtime = require("react/jsx-runtime");
44
+ const FOCUS_SCOPE_CONTROLLER_NAME = "FocusScopeController",
45
+ [createFocusScopeControllerContext, createFocusScopeControllerScope] = (0, import_create_context.createContextScope)(FOCUS_SCOPE_CONTROLLER_NAME),
46
+ [FocusScopeControllerProvider, useFocusScopeControllerContext] = createFocusScopeControllerContext(FOCUS_SCOPE_CONTROLLER_NAME);
47
+ function FocusScopeController(props) {
48
+ const {
49
+ __scopeFocusScope,
50
+ children,
51
+ enabled,
52
+ loop,
53
+ trapped,
54
+ onMountAutoFocus,
55
+ onUnmountAutoFocus,
56
+ forceUnmount,
57
+ focusOnIdle
58
+ } = props,
59
+ stableOnMountAutoFocus = (0, import_use_event.useEvent)(onMountAutoFocus),
60
+ stableOnUnmountAutoFocus = (0, import_use_event.useEvent)(onUnmountAutoFocus),
61
+ contextValue = React.useMemo(() => ({
62
+ enabled,
63
+ loop,
64
+ trapped,
65
+ onMountAutoFocus: stableOnMountAutoFocus,
66
+ onUnmountAutoFocus: stableOnUnmountAutoFocus,
67
+ forceUnmount,
68
+ focusOnIdle
69
+ }), [enabled, loop, trapped, stableOnMountAutoFocus, stableOnUnmountAutoFocus, forceUnmount, focusOnIdle]);
70
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(FocusScopeControllerProvider, {
71
+ scope: __scopeFocusScope,
72
+ ...contextValue,
73
+ children
74
+ });
75
+ }
76
+ const FocusScopeControllerComponent = FocusScopeController;
@@ -0,0 +1,69 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+ var FocusScopeController_exports = {};
24
+ __export(FocusScopeController_exports, {
25
+ FocusScopeController: () => FocusScopeControllerComponent,
26
+ FocusScopeControllerProvider: () => FocusScopeControllerProvider,
27
+ createFocusScopeControllerScope: () => createFocusScopeControllerScope,
28
+ useFocusScopeControllerContext: () => useFocusScopeControllerContext
29
+ });
30
+ module.exports = __toCommonJS(FocusScopeController_exports);
31
+ var import_create_context = require("@tamagui/create-context"), import_use_event = require("@tamagui/use-event"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
32
+ const FOCUS_SCOPE_CONTROLLER_NAME = "FocusScopeController", [createFocusScopeControllerContext, createFocusScopeControllerScope] = (0, import_create_context.createContextScope)(FOCUS_SCOPE_CONTROLLER_NAME), [FocusScopeControllerProvider, useFocusScopeControllerContext] = createFocusScopeControllerContext(
33
+ FOCUS_SCOPE_CONTROLLER_NAME
34
+ );
35
+ function FocusScopeController(props) {
36
+ const {
37
+ __scopeFocusScope,
38
+ children,
39
+ enabled,
40
+ loop,
41
+ trapped,
42
+ onMountAutoFocus,
43
+ onUnmountAutoFocus,
44
+ forceUnmount,
45
+ focusOnIdle
46
+ } = props, stableOnMountAutoFocus = (0, import_use_event.useEvent)(onMountAutoFocus), stableOnUnmountAutoFocus = (0, import_use_event.useEvent)(onUnmountAutoFocus), contextValue = React.useMemo(
47
+ () => ({
48
+ enabled,
49
+ loop,
50
+ trapped,
51
+ onMountAutoFocus: stableOnMountAutoFocus,
52
+ onUnmountAutoFocus: stableOnUnmountAutoFocus,
53
+ forceUnmount,
54
+ focusOnIdle
55
+ }),
56
+ [
57
+ enabled,
58
+ loop,
59
+ trapped,
60
+ stableOnMountAutoFocus,
61
+ stableOnUnmountAutoFocus,
62
+ forceUnmount,
63
+ focusOnIdle
64
+ ]
65
+ );
66
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FocusScopeControllerProvider, { scope: __scopeFocusScope, ...contextValue, children });
67
+ }
68
+ const FocusScopeControllerComponent = FocusScopeController;
69
+ //# sourceMappingURL=FocusScopeController.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/FocusScopeController.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAmC,oCACnC,mBAAyB,+BACzB,QAAuB,2BA8DnB;AA1DJ,MAAM,8BAA8B,wBAE9B,CAAC,mCAAmC,+BAA+B,QACvE,0CAAmB,2BAA2B,GAI1C,CAAC,8BAA8B,8BAA8B,IACjE;AAAA,EACE;AACF;AAUF,SAAS,qBAAqB,OAA+C;AAC3E,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,OAEE,6BAAyB,2BAAS,gBAAgB,GAClD,+BAA2B,2BAAS,kBAAkB,GAEtD,eAAe,MAAM;AAAA,IACzB,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,kBAAkB;AAAA,MAClB,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SACE,4CAAC,gCAA6B,OAAO,mBAAoB,GAAG,cACzD,UACH;AAEJ;AAEA,MAAM,gCAAgC;",
5
+ "names": []
6
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
+ var FocusScopeController_exports = {};
25
+ __export(FocusScopeController_exports, {
26
+ FocusScopeController: () => FocusScopeControllerComponent,
27
+ FocusScopeControllerProvider: () => FocusScopeControllerProvider,
28
+ createFocusScopeControllerScope: () => createFocusScopeControllerScope,
29
+ useFocusScopeControllerContext: () => useFocusScopeControllerContext
30
+ });
31
+ module.exports = __toCommonJS(FocusScopeController_exports);
32
+ var import_jsx_runtime = require("react/jsx-runtime"), import_create_context = require("@tamagui/create-context"), import_use_event = require("@tamagui/use-event"), React = __toESM(require("react")), FOCUS_SCOPE_CONTROLLER_NAME = "FocusScopeController", [createFocusScopeControllerContext, createFocusScopeControllerScope] = (0, import_create_context.createContextScope)(FOCUS_SCOPE_CONTROLLER_NAME), [FocusScopeControllerProvider, useFocusScopeControllerContext] = createFocusScopeControllerContext(FOCUS_SCOPE_CONTROLLER_NAME);
33
+ function FocusScopeController(props) {
34
+ var { __scopeFocusScope, children, enabled, loop, trapped, onMountAutoFocus, onUnmountAutoFocus, forceUnmount, focusOnIdle } = props, stableOnMountAutoFocus = (0, import_use_event.useEvent)(onMountAutoFocus), stableOnUnmountAutoFocus = (0, import_use_event.useEvent)(onUnmountAutoFocus), contextValue = React.useMemo(function() {
35
+ return {
36
+ enabled,
37
+ loop,
38
+ trapped,
39
+ onMountAutoFocus: stableOnMountAutoFocus,
40
+ onUnmountAutoFocus: stableOnUnmountAutoFocus,
41
+ forceUnmount,
42
+ focusOnIdle
43
+ };
44
+ }, [
45
+ enabled,
46
+ loop,
47
+ trapped,
48
+ stableOnMountAutoFocus,
49
+ stableOnUnmountAutoFocus,
50
+ forceUnmount,
51
+ focusOnIdle
52
+ ]);
53
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FocusScopeControllerProvider, {
54
+ scope: __scopeFocusScope,
55
+ ...contextValue,
56
+ children
57
+ });
58
+ }
59
+ var FocusScopeControllerComponent = FocusScopeController;
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ FocusScopeController,
63
+ FocusScopeControllerProvider,
64
+ createFocusScopeControllerScope,
65
+ useFocusScopeControllerContext
66
+ });
67
+ //# sourceMappingURL=FocusScopeController.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/FocusScopeController.tsx"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAAA,wBAAmC,oCACnC,mBAAyB,+BACzB,QAAuB,2BAIjBA,8BAA8B,wBAE9B,CAACC,mCAAmCC,+BAAAA,QACxCC,0CAAmBH,2BAAAA,GAIf,CAACI,8BAA8BC,8BAAAA,IACnCJ,kCACED,2BAAAA;AAWJ,SAASM,qBAAqBC,OAA6C;AACzE,MAAM,EACJC,mBACAC,UACAC,SACAC,MACAC,SACAC,kBACAC,oBACAC,cACAC,YAAW,IACTT,OAEEU,6BAAyBC,2BAASL,gBAAAA,GAClCM,+BAA2BD,2BAASJ,kBAAAA,GAEpCM,eAAeC,MAAMC,QACzB,WAAA;WAAO;MACLZ;MACAC;MACAC;MACAC,kBAAkBI;MAClBH,oBAAoBK;MACpBJ;MACAC;IACF;KACA;IACEN;IACAC;IACAC;IACAK;IACAE;IACAJ;IACAC;GACD;AAGH,SACE,uCAAAO,KAACnB,8BAAAA;IAA6BoB,OAAOhB;IAAoB,GAAGY;;;AAIhE;AAEA,IAAMK,gCAAgCnB;",
5
+ "names": ["FOCUS_SCOPE_CONTROLLER_NAME", "createFocusScopeControllerContext", "createFocusScopeControllerScope", "createContextScope", "FocusScopeControllerProvider", "useFocusScopeControllerContext", "FocusScopeController", "props", "__scopeFocusScope", "children", "enabled", "loop", "trapped", "onMountAutoFocus", "onUnmountAutoFocus", "forceUnmount", "focusOnIdle", "stableOnMountAutoFocus", "useEvent", "stableOnUnmountAutoFocus", "contextValue", "React", "useMemo", "_jsx", "scope", "FocusScopeControllerComponent"]
6
+ }
@@ -15,4 +15,5 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
15
15
  }), mod);
16
16
  var index_exports = {};
17
17
  module.exports = __toCommonJS(index_exports);
18
- __reExport(index_exports, require("./FocusScope.cjs"), module.exports);
18
+ __reExport(index_exports, require("./FocusScope.cjs"), module.exports);
19
+ __reExport(index_exports, require("./FocusScopeController.cjs"), module.exports);
package/dist/cjs/index.js CHANGED
@@ -12,4 +12,5 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0
12
12
  var index_exports = {};
13
13
  module.exports = __toCommonJS(index_exports);
14
14
  __reExport(index_exports, require("./FocusScope"), module.exports);
15
+ __reExport(index_exports, require("./FocusScopeController"), module.exports);
15
16
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,yBAAd;",
4
+ "mappings": ";;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,yBAAd;AACA,0BAAc,mCADd;",
5
5
  "names": []
6
6
  }
@@ -13,8 +13,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0
13
13
  var index_exports = {};
14
14
  module.exports = __toCommonJS(index_exports);
15
15
  __reExport(index_exports, require("./FocusScope"), module.exports);
16
+ __reExport(index_exports, require("./FocusScopeController"), module.exports);
16
17
  // Annotate the CommonJS export names for ESM import in node:
17
18
  0 && (module.exports = {
18
- ...require("./FocusScope")
19
+ ...require("./FocusScope"),
20
+ ...require("./FocusScopeController")
19
21
  });
20
22
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;AAAA;;0BAAc,yBAAd;",
4
+ "mappings": ";;;;;;;;;;;;AAAA;;0BAAc,yBAAd;AACA,0BAAc,mCADd;",
5
5
  "names": []
6
6
  }
@@ -12,5 +12,5 @@ var __copyProps = (to, from, except, desc) => {
12
12
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
13
13
  value: !0
14
14
  }), mod);
15
- var FocusScopeProps_exports = {};
16
- module.exports = __toCommonJS(FocusScopeProps_exports);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -9,6 +9,6 @@ var __copyProps = (to, from, except, desc) => {
9
9
  return to;
10
10
  };
11
11
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var FocusScopeProps_exports = {};
13
- module.exports = __toCommonJS(FocusScopeProps_exports);
14
- //# sourceMappingURL=FocusScopeProps.js.map
12
+ var types_exports = {};
13
+ module.exports = __toCommonJS(types_exports);
14
+ //# sourceMappingURL=types.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/FocusScopeProps.tsx"],
3
+ "sources": ["../../src/types.tsx"],
4
4
  "mappings": ";;;;;;;;;;;AAAA;AAAA;",
5
5
  "names": []
6
6
  }
@@ -10,6 +10,6 @@ var __copyProps = (to, from, except, desc) => {
10
10
  return to;
11
11
  };
12
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
13
+ var types_exports = {};
14
+ module.exports = __toCommonJS(types_exports);
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/types.tsx"],
4
+ "mappings": ";;;;;;;;;;;;AAKA;;",
5
+ "names": []
6
+ }
@@ -1,12 +1,29 @@
1
1
  import { useComposedRefs } from "@tamagui/compose-refs";
2
- import { useEvent } from "@tamagui/use-event";
3
2
  import { startTransition } from "@tamagui/start-transition";
3
+ import { fullyIdle, sleep, useAsyncEffect } from "@tamagui/use-async";
4
+ import { useEvent } from "@tamagui/use-event";
4
5
  import * as React from "react";
6
+ import { useFocusScopeControllerContext } from "./FocusScopeController";
5
7
  import { Fragment, jsx } from "react/jsx-runtime";
6
8
  const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount", AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount", EVENT_OPTIONS = { bubbles: !1, cancelable: !0 }, FocusScope = React.forwardRef(
7
- function(props, forwardedRef) {
8
- const childProps = useFocusScope(props, forwardedRef);
9
- return typeof props.children == "function" ? /* @__PURE__ */ jsx(Fragment, { children: props.children(childProps) }) : React.cloneElement(React.Children.only(props.children), childProps);
9
+ function({ __scopeFocusScope, ...props }, forwardedRef) {
10
+ const context = useFocusScopeControllerContext("FocusScope", __scopeFocusScope, {
11
+ warn: !1,
12
+ fallback: {}
13
+ }), mergedProps = {
14
+ ...props,
15
+ enabled: context.enabled ?? props.enabled,
16
+ loop: context.loop ?? props.loop,
17
+ trapped: context.trapped ?? props.trapped,
18
+ onMountAutoFocus: context.onMountAutoFocus ?? props.onMountAutoFocus,
19
+ onUnmountAutoFocus: context.onUnmountAutoFocus ?? props.onUnmountAutoFocus,
20
+ forceUnmount: context.forceUnmount ?? props.forceUnmount,
21
+ focusOnIdle: context.focusOnIdle ?? props.focusOnIdle
22
+ }, childProps = useFocusScope(mergedProps, forwardedRef);
23
+ return typeof mergedProps.children == "function" ? /* @__PURE__ */ jsx(Fragment, { children: mergedProps.children(childProps) }) : React.cloneElement(
24
+ React.Children.only(mergedProps.children),
25
+ childProps
26
+ );
10
27
  }
11
28
  );
12
29
  function useFocusScope(props, forwardedRef) {
@@ -17,6 +34,7 @@ function useFocusScope(props, forwardedRef) {
17
34
  onMountAutoFocus: onMountAutoFocusProp,
18
35
  onUnmountAutoFocus: onUnmountAutoFocusProp,
19
36
  forceUnmount,
37
+ focusOnIdle = !0,
20
38
  children,
21
39
  ...scopeProps
22
40
  } = props, [container, setContainer] = React.useState(null), onMountAutoFocus = useEvent(onMountAutoFocusProp), onUnmountAutoFocus = useEvent(onUnmountAutoFocusProp), lastFocusedElementRef = React.useRef(null), setContainerTransition = React.useCallback(
@@ -52,23 +70,35 @@ function useFocusScope(props, forwardedRef) {
52
70
  return document.addEventListener("focusin", handleFocusIn), document.addEventListener("focusout", handleFocusOut), () => {
53
71
  controller.abort(), document.removeEventListener("focusin", handleFocusIn), document.removeEventListener("focusout", handleFocusOut);
54
72
  };
55
- }, [trapped, forceUnmount, container, focusScope.paused]), React.useEffect(() => {
56
- if (!enabled || !container || forceUnmount) return;
57
- focusScopesStack.add(focusScope);
58
- const previouslyFocusedElement = document.activeElement;
59
- if (!container.contains(previouslyFocusedElement)) {
60
- const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
61
- if (container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus), container.dispatchEvent(mountEvent), !mountEvent.defaultPrevented) {
62
- const candidates = removeLinks(getTabbableCandidates(container));
63
- focusFirst(candidates, { select: !0 }), document.activeElement === previouslyFocusedElement && focus(container);
73
+ }, [trapped, forceUnmount, container, focusScope.paused]), useAsyncEffect(
74
+ async (signal) => {
75
+ if (!enabled || !container || forceUnmount) return;
76
+ focusScopesStack.add(focusScope);
77
+ const previouslyFocusedElement = document.activeElement;
78
+ if (!container.contains(previouslyFocusedElement)) {
79
+ const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
80
+ if (container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus), container.dispatchEvent(mountEvent), !mountEvent.defaultPrevented) {
81
+ focusOnIdle && (await sleep(typeof focusOnIdle == "number" ? focusOnIdle : 16, signal), await fullyIdle(signal));
82
+ const candidates = removeLinks(getTabbableCandidates(container));
83
+ focusFirst(candidates, { select: !0 }), document.activeElement === previouslyFocusedElement && focus(container);
84
+ }
64
85
  }
65
- }
66
- return () => {
67
- container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
68
- const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
69
- 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);
70
- };
71
- }, [enabled, container, forceUnmount, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
86
+ return () => {
87
+ container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
88
+ const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
89
+ 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);
90
+ };
91
+ },
92
+ [
93
+ enabled,
94
+ container,
95
+ forceUnmount,
96
+ onMountAutoFocus,
97
+ onUnmountAutoFocus,
98
+ focusScope,
99
+ focusOnIdle
100
+ ]
101
+ );
72
102
  const handleKeyDown = React.useCallback(
73
103
  (event) => {
74
104
  if (!trapped || !loop || focusScope.paused) return;