@qualtrics/ui-react 2.85.4 → 2.85.5
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/CHANGELOG.md +8 -0
- package/dist/__node_modules/@radix-ui/react-arrow/dist/index.js +2 -2
- package/dist/__node_modules/@radix-ui/react-collection/dist/index.js +209 -118
- package/dist/__node_modules/@radix-ui/react-direction/dist/index.js +6 -3
- package/dist/__node_modules/@radix-ui/react-dismissable-layer/dist/index.js +1 -3
- package/dist/__node_modules/@radix-ui/react-dropdown-menu/dist/index.js +18 -34
- package/dist/__node_modules/@radix-ui/react-focus-scope/dist/index.js +78 -21
- package/dist/__node_modules/@radix-ui/react-menu/dist/index.js +127 -120
- package/dist/__node_modules/@radix-ui/react-popper/dist/index.js +35 -21
- package/dist/__node_modules/@radix-ui/react-portal/dist/index.js +1 -2
- package/dist/__node_modules/@radix-ui/react-presence/dist/index.js +1 -2
- package/dist/__node_modules/@radix-ui/react-primitive/dist/index.js +2 -2
- package/dist/__node_modules/@radix-ui/react-roving-focus/dist/index.js +16 -6
- package/dist/__node_modules/@radix-ui/react-slot/dist/index.js +28 -7
- package/dist/__node_modules/@radix-ui/react-use-callback-ref/dist/index.js +11 -3
- package/dist/__node_modules/@radix-ui/react-use-size/dist/index.js +22 -15
- package/dist/__shared/cjs/{index-08198ff4.js → index-bd03241f.js} +206 -205
- package/dist/__shared/cjs/{index-e51bbd75.js → index-ccb5282a.js} +12 -3
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Button/Button.js +52 -6
- package/dist/components/Button/Button2.js +6 -52
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/ColorPicker/ColorPickerFlyout.js +1 -1
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/FilePicker/FilePicker.js +1 -1
- package/dist/components/FilePicker/FilePicker2.js +3 -3
- package/dist/components/FormField/Caption.js +3 -3
- package/dist/components/FormField/FormField2.js +3 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/Icon/IconTypes.js +1 -0
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/Label/Label2.js +3 -3
- package/dist/components/Link/Link2.js +3 -3
- package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Pagination/PaginationNextButton.js +1 -1
- package/dist/components/Pagination/PaginationPreviousButton.js +1 -1
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch.js +1 -1
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Switch/Switch2.js +3 -3
- package/dist/components/Table/Table2.js +3 -3
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +1 -1
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
- package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
- package/dist/design-tokens/less/typography.js +3 -3
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/components/PulseIcon.js +11 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.es.js +1 -0
- package/dist/icons/index.js +2 -1
- package/dist/index.d.ts +72 -71
- package/dist/index.es.js +2 -2
- package/dist/index.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/Chat/Loader.js +1 -1
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Form/FormFields/InputField.js +3 -3
- package/dist/next/Indicator/Indicator2.js +3 -3
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/next/Menu/Menu.js +2 -2
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuButton.js +2 -2
- package/dist/next/Menu/MenuItem.js +2 -2
- package/dist/next/Menu/MenuPane.js +3 -3
- package/dist/next/Menu/SubMenu.js +5 -5
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/Select/Select2.js +3 -3
- package/dist/next/SplitButton/SplitButton.js +1 -1
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/ToggleButton/ToggleButton.js +1 -1
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.js +598 -403
- package/dist/translations-en.js +71 -71
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/icons/package.json +2 -2
- package/next/package.json +3 -3
- package/package.json +6 -6
|
@@ -7,7 +7,7 @@ import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
|
7
7
|
import { createContextScope } from '../../react-context/dist/index.js';
|
|
8
8
|
import { useControllableState } from '../../react-use-controllable-state/dist/index.js';
|
|
9
9
|
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
10
|
-
import { createMenuScope,
|
|
10
|
+
import { createMenuScope, Menu, Anchor as MenuAnchor, MenuPortal, Content as MenuContent, Group as MenuGroup, Label as MenuLabel, Item as MenuItem, CheckboxItem as MenuCheckboxItem, MenuRadioGroup, MenuRadioItem, ItemIndicator as MenuItemIndicator, MenuSeparator, Arrow as MenuArrow, MenuSub, MenuSubTrigger, MenuSubContent } from '../../react-menu/dist/index.js';
|
|
11
11
|
import { useId } from '../../react-id/dist/index.js';
|
|
12
12
|
|
|
13
13
|
"use client";
|
|
@@ -69,7 +69,7 @@ var DropdownMenu = /* @__PURE__ */__name(props => {
|
|
|
69
69
|
onOpenChange: setOpen,
|
|
70
70
|
onOpenToggle: React.useCallback(() => setOpen(prevOpen => !prevOpen), [setOpen]),
|
|
71
71
|
modal,
|
|
72
|
-
children: /* @__PURE__ */React.createElement(
|
|
72
|
+
children: /* @__PURE__ */React.createElement(Menu, {
|
|
73
73
|
...menuScope,
|
|
74
74
|
open,
|
|
75
75
|
onOpenChange: setOpen,
|
|
@@ -91,7 +91,7 @@ __name(function DropdownMenuTrigger2(props, forwardedRef) {
|
|
|
91
91
|
const context = useDropdownMenuContext(TRIGGER_NAME, __scopeDropdownMenu);
|
|
92
92
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
93
93
|
const composedRefs = useComposedRefs(forwardedRef, context.triggerRef);
|
|
94
|
-
return /* @__PURE__ */React.createElement(
|
|
94
|
+
return /* @__PURE__ */React.createElement(MenuAnchor, {
|
|
95
95
|
asChild: true,
|
|
96
96
|
...menuScope,
|
|
97
97
|
children: /* @__PURE__ */React.createElement(Primitive.button, {
|
|
@@ -125,7 +125,7 @@ var DropdownMenuPortal = /* @__PURE__ */__name(props => {
|
|
|
125
125
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
126
126
|
portalProps = _objectWithoutProperties(props, _excluded2);
|
|
127
127
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
128
|
-
return /* @__PURE__ */React.createElement(
|
|
128
|
+
return /* @__PURE__ */React.createElement(MenuPortal, {
|
|
129
129
|
...menuScope,
|
|
130
130
|
...portalProps
|
|
131
131
|
});
|
|
@@ -140,7 +140,7 @@ __name(function DropdownMenuContent2(props, forwardedRef) {
|
|
|
140
140
|
const context = useDropdownMenuContext(CONTENT_NAME, __scopeDropdownMenu);
|
|
141
141
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
142
142
|
const hasInteractedOutsideRef = React.useRef(false);
|
|
143
|
-
return /* @__PURE__ */React.createElement(
|
|
143
|
+
return /* @__PURE__ */React.createElement(MenuContent, {
|
|
144
144
|
id: context.contentId,
|
|
145
145
|
"aria-labelledby": context.triggerId,
|
|
146
146
|
...menuScope,
|
|
@@ -178,7 +178,7 @@ __name(function DropdownMenuGroup2(props, forwardedRef) {
|
|
|
178
178
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
179
179
|
groupProps = _objectWithoutProperties(props, _excluded4);
|
|
180
180
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
181
|
-
return /* @__PURE__ */React.createElement(
|
|
181
|
+
return /* @__PURE__ */React.createElement(MenuGroup, {
|
|
182
182
|
...menuScope,
|
|
183
183
|
...groupProps,
|
|
184
184
|
ref: forwardedRef
|
|
@@ -191,7 +191,7 @@ __name(function DropdownMenuLabel2(props, forwardedRef) {
|
|
|
191
191
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
192
192
|
labelProps = _objectWithoutProperties(props, _excluded5);
|
|
193
193
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
194
|
-
return /* @__PURE__ */React.createElement(
|
|
194
|
+
return /* @__PURE__ */React.createElement(MenuLabel, {
|
|
195
195
|
...menuScope,
|
|
196
196
|
...labelProps,
|
|
197
197
|
ref: forwardedRef
|
|
@@ -204,7 +204,7 @@ __name(function DropdownMenuItem2(props, forwardedRef) {
|
|
|
204
204
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
205
205
|
itemProps = _objectWithoutProperties(props, _excluded6);
|
|
206
206
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
207
|
-
return /* @__PURE__ */React.createElement(
|
|
207
|
+
return /* @__PURE__ */React.createElement(MenuItem, {
|
|
208
208
|
...menuScope,
|
|
209
209
|
...itemProps,
|
|
210
210
|
ref: forwardedRef
|
|
@@ -214,7 +214,7 @@ var DropdownMenuCheckboxItem = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__
|
|
|
214
214
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
215
215
|
checkboxItemProps = _objectWithoutProperties(props, _excluded7);
|
|
216
216
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
217
|
-
return /* @__PURE__ */React.createElement(
|
|
217
|
+
return /* @__PURE__ */React.createElement(MenuCheckboxItem, {
|
|
218
218
|
...menuScope,
|
|
219
219
|
...checkboxItemProps,
|
|
220
220
|
ref: forwardedRef
|
|
@@ -224,7 +224,7 @@ var DropdownMenuRadioGroup = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__na
|
|
|
224
224
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
225
225
|
radioGroupProps = _objectWithoutProperties(props, _excluded8);
|
|
226
226
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
227
|
-
return /* @__PURE__ */React.createElement(
|
|
227
|
+
return /* @__PURE__ */React.createElement(MenuRadioGroup, {
|
|
228
228
|
...menuScope,
|
|
229
229
|
...radioGroupProps,
|
|
230
230
|
ref: forwardedRef
|
|
@@ -234,7 +234,7 @@ var DropdownMenuRadioItem = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__nam
|
|
|
234
234
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
235
235
|
radioItemProps = _objectWithoutProperties(props, _excluded9);
|
|
236
236
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
237
|
-
return /* @__PURE__ */React.createElement(
|
|
237
|
+
return /* @__PURE__ */React.createElement(MenuRadioItem, {
|
|
238
238
|
...menuScope,
|
|
239
239
|
...radioItemProps,
|
|
240
240
|
ref: forwardedRef
|
|
@@ -244,7 +244,7 @@ var DropdownMenuItemIndicator = /* @__PURE__ */React.forwardRef(/* @__PURE__ */_
|
|
|
244
244
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
245
245
|
itemIndicatorProps = _objectWithoutProperties(props, _excluded0);
|
|
246
246
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
247
|
-
return /* @__PURE__ */React.createElement(
|
|
247
|
+
return /* @__PURE__ */React.createElement(MenuItemIndicator, {
|
|
248
248
|
...menuScope,
|
|
249
249
|
...itemIndicatorProps,
|
|
250
250
|
ref: forwardedRef
|
|
@@ -254,7 +254,7 @@ var DropdownMenuSeparator = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__nam
|
|
|
254
254
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
255
255
|
separatorProps = _objectWithoutProperties(props, _excluded1);
|
|
256
256
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
257
|
-
return /* @__PURE__ */React.createElement(
|
|
257
|
+
return /* @__PURE__ */React.createElement(MenuSeparator, {
|
|
258
258
|
...menuScope,
|
|
259
259
|
...separatorProps,
|
|
260
260
|
ref: forwardedRef
|
|
@@ -267,7 +267,7 @@ __name(function DropdownMenuArrow2(props, forwardedRef) {
|
|
|
267
267
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
268
268
|
arrowProps = _objectWithoutProperties(props, _excluded10);
|
|
269
269
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
270
|
-
return /* @__PURE__ */React.createElement(
|
|
270
|
+
return /* @__PURE__ */React.createElement(MenuArrow, {
|
|
271
271
|
...menuScope,
|
|
272
272
|
...arrowProps,
|
|
273
273
|
ref: forwardedRef
|
|
@@ -289,7 +289,7 @@ var DropdownMenuSub = /* @__PURE__ */__name(props => {
|
|
|
289
289
|
_useControllableState4 = _slicedToArray(_useControllableState3, 2),
|
|
290
290
|
open = _useControllableState4[0],
|
|
291
291
|
setOpen = _useControllableState4[1];
|
|
292
|
-
return /* @__PURE__ */React.createElement(
|
|
292
|
+
return /* @__PURE__ */React.createElement(MenuSub, {
|
|
293
293
|
...menuScope,
|
|
294
294
|
open,
|
|
295
295
|
onOpenChange: setOpen,
|
|
@@ -300,7 +300,7 @@ var DropdownMenuSubTrigger = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__na
|
|
|
300
300
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
301
301
|
subTriggerProps = _objectWithoutProperties(props, _excluded11);
|
|
302
302
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
303
|
-
return /* @__PURE__ */React.createElement(
|
|
303
|
+
return /* @__PURE__ */React.createElement(MenuSubTrigger, {
|
|
304
304
|
...menuScope,
|
|
305
305
|
...subTriggerProps,
|
|
306
306
|
ref: forwardedRef
|
|
@@ -310,7 +310,7 @@ var DropdownMenuSubContent = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__na
|
|
|
310
310
|
const __scopeDropdownMenu = props.__scopeDropdownMenu,
|
|
311
311
|
subContentProps = _objectWithoutProperties(props, _excluded12);
|
|
312
312
|
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
313
|
-
return /* @__PURE__ */React.createElement(
|
|
313
|
+
return /* @__PURE__ */React.createElement(MenuSubContent, {
|
|
314
314
|
...menuScope,
|
|
315
315
|
...subContentProps,
|
|
316
316
|
ref: forwardedRef,
|
|
@@ -327,21 +327,5 @@ var DropdownMenuSubContent = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__na
|
|
|
327
327
|
}
|
|
328
328
|
});
|
|
329
329
|
}, "DropdownMenuSubContent"));
|
|
330
|
-
var Root2 = DropdownMenu;
|
|
331
|
-
var Trigger = DropdownMenuTrigger;
|
|
332
|
-
var Portal2 = DropdownMenuPortal;
|
|
333
|
-
var Content2 = DropdownMenuContent;
|
|
334
|
-
var Group2 = DropdownMenuGroup;
|
|
335
|
-
var Label2 = DropdownMenuLabel;
|
|
336
|
-
var Item2 = DropdownMenuItem;
|
|
337
|
-
var CheckboxItem2 = DropdownMenuCheckboxItem;
|
|
338
|
-
var RadioGroup2 = DropdownMenuRadioGroup;
|
|
339
|
-
var RadioItem2 = DropdownMenuRadioItem;
|
|
340
|
-
var ItemIndicator2 = DropdownMenuItemIndicator;
|
|
341
|
-
var Separator2 = DropdownMenuSeparator;
|
|
342
|
-
var Arrow2 = DropdownMenuArrow;
|
|
343
|
-
var Sub2 = DropdownMenuSub;
|
|
344
|
-
var SubTrigger2 = DropdownMenuSubTrigger;
|
|
345
|
-
var SubContent2 = DropdownMenuSubContent;
|
|
346
330
|
|
|
347
|
-
export {
|
|
331
|
+
export { DropdownMenuArrow as Arrow, DropdownMenuCheckboxItem as CheckboxItem, DropdownMenuContent as Content, DropdownMenu, DropdownMenuArrow, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuItemIndicator, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DropdownMenuGroup as Group, DropdownMenuItem as Item, DropdownMenuItemIndicator as ItemIndicator, DropdownMenuLabel as Label, DropdownMenuPortal as Portal, DropdownMenuRadioGroup as RadioGroup, DropdownMenuRadioItem as RadioItem, DropdownMenu as Root, DropdownMenuSeparator as Separator, DropdownMenuSub as Sub, DropdownMenuSubContent as SubContent, DropdownMenuSubTrigger as SubTrigger, DropdownMenuTrigger as Trigger, createDropdownMenuScope };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
2
2
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
3
|
+
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
5
6
|
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
6
7
|
import { useCallbackRef } from '../../react-use-callback-ref/dist/index.js';
|
|
7
8
|
|
|
8
9
|
"use client";
|
|
9
|
-
const _excluded = ["loop", "trapped", "onMountAutoFocus", "onUnmountAutoFocus"];
|
|
10
|
+
const _excluded = ["loop", "trapped", "branches", "onMountAutoFocus", "onUnmountAutoFocus"];
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __name = (target, value) => __defProp(target, "name", {
|
|
12
13
|
value,
|
|
@@ -23,6 +24,7 @@ var FocusScope = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function
|
|
|
23
24
|
loop = _props$loop === void 0 ? false : _props$loop,
|
|
24
25
|
_props$trapped = props.trapped,
|
|
25
26
|
trapped = _props$trapped === void 0 ? false : _props$trapped,
|
|
27
|
+
branches = props.branches,
|
|
26
28
|
onMountAutoFocusProp = props.onMountAutoFocus,
|
|
27
29
|
onUnmountAutoFocusProp = props.onUnmountAutoFocus,
|
|
28
30
|
scopeProps = _objectWithoutProperties(props, _excluded);
|
|
@@ -34,6 +36,16 @@ var FocusScope = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function
|
|
|
34
36
|
const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);
|
|
35
37
|
const lastFocusedElementRef = React.useRef(null);
|
|
36
38
|
const composedRefs = useComposedRefs(forwardedRef, setContainer);
|
|
39
|
+
const branchesRef = React.useRef(branches);
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
branchesRef.current = branches;
|
|
42
|
+
});
|
|
43
|
+
const isTargetInScope = React.useCallback(target => {
|
|
44
|
+
var _branchesRef$current;
|
|
45
|
+
if (!target) return false;
|
|
46
|
+
if (container !== null && container !== void 0 && container.contains(target)) return true;
|
|
47
|
+
return Boolean((_branchesRef$current = branchesRef.current) === null || _branchesRef$current === void 0 ? void 0 : _branchesRef$current.some(branch => branch.contains(target)));
|
|
48
|
+
}, [container]);
|
|
37
49
|
const focusScope = React.useRef({
|
|
38
50
|
paused: false,
|
|
39
51
|
pause() {
|
|
@@ -48,7 +60,7 @@ var FocusScope = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function
|
|
|
48
60
|
let handleFocusIn2 = function (event) {
|
|
49
61
|
if (focusScope.paused || !container) return;
|
|
50
62
|
const target = event.target;
|
|
51
|
-
if (
|
|
63
|
+
if (isTargetInScope(target)) {
|
|
52
64
|
lastFocusedElementRef.current = target;
|
|
53
65
|
} else {
|
|
54
66
|
focus(lastFocusedElementRef.current, {
|
|
@@ -60,7 +72,7 @@ var FocusScope = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function
|
|
|
60
72
|
if (focusScope.paused || !container) return;
|
|
61
73
|
const relatedTarget = event.relatedTarget;
|
|
62
74
|
if (relatedTarget === null) return;
|
|
63
|
-
if (!
|
|
75
|
+
if (!isTargetInScope(relatedTarget)) {
|
|
64
76
|
focus(lastFocusedElementRef.current, {
|
|
65
77
|
select: true
|
|
66
78
|
});
|
|
@@ -92,7 +104,7 @@ var FocusScope = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function
|
|
|
92
104
|
mutationObserver.disconnect();
|
|
93
105
|
};
|
|
94
106
|
}
|
|
95
|
-
}, [trapped, container, focusScope.paused]);
|
|
107
|
+
}, [trapped, container, focusScope.paused, isTargetInScope]);
|
|
96
108
|
React.useEffect(() => {
|
|
97
109
|
if (container) {
|
|
98
110
|
focusScopesStack.add(focusScope);
|
|
@@ -113,12 +125,14 @@ var FocusScope = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function
|
|
|
113
125
|
}
|
|
114
126
|
return () => {
|
|
115
127
|
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
128
|
+
const ownerDocument = container.ownerDocument;
|
|
129
|
+
const UnmountEvent = CustomEvent;
|
|
116
130
|
setTimeout(() => {
|
|
117
|
-
const unmountEvent = new
|
|
131
|
+
const unmountEvent = new UnmountEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
118
132
|
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
119
133
|
container.dispatchEvent(unmountEvent);
|
|
120
134
|
if (!unmountEvent.defaultPrevented) {
|
|
121
|
-
focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement :
|
|
135
|
+
focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : ownerDocument.body, {
|
|
122
136
|
select: true
|
|
123
137
|
});
|
|
124
138
|
}
|
|
@@ -164,10 +178,47 @@ var FocusScope = /* @__PURE__ */React.forwardRef(/* @__PURE__ */__name(function
|
|
|
164
178
|
onKeyDown: handleKeyDown
|
|
165
179
|
});
|
|
166
180
|
}, "FocusScope"));
|
|
181
|
+
var FocusScopeBranchContext = /*#__PURE__*/React.createContext(null);
|
|
182
|
+
function FocusScopeBranchProvider(_ref) {
|
|
183
|
+
let registry = _ref.registry,
|
|
184
|
+
children = _ref.children;
|
|
185
|
+
if (!registry) {
|
|
186
|
+
return children;
|
|
187
|
+
}
|
|
188
|
+
return /* @__PURE__ */React.createElement(FocusScopeBranchContext.Provider, {
|
|
189
|
+
value: registry,
|
|
190
|
+
children
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
__name(FocusScopeBranchProvider, "FocusScopeBranchProvider");
|
|
194
|
+
function useFocusScopeBranchRegistry() {
|
|
195
|
+
const _React$useState3 = React.useState([]),
|
|
196
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
197
|
+
nodes = _React$useState4[0],
|
|
198
|
+
setNodes = _React$useState4[1];
|
|
199
|
+
const registry = React.useMemo(() => ({
|
|
200
|
+
add: /* @__PURE__ */__name(node => setNodes(prev => _includesInstanceProperty(prev).call(prev, node) ? prev : [...prev, node]), "add"),
|
|
201
|
+
remove: /* @__PURE__ */__name(node => setNodes(prev => prev.filter(current => current !== node)), "remove")
|
|
202
|
+
}), []);
|
|
203
|
+
return {
|
|
204
|
+
nodes,
|
|
205
|
+
registry
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
__name(useFocusScopeBranchRegistry, "useFocusScopeBranchRegistry");
|
|
209
|
+
function useFocusScopeBranch(node) {
|
|
210
|
+
const registry = React.useContext(FocusScopeBranchContext);
|
|
211
|
+
React.useEffect(() => {
|
|
212
|
+
if (!node || !registry) return;
|
|
213
|
+
registry.add(node);
|
|
214
|
+
return () => registry.remove(node);
|
|
215
|
+
}, [node, registry]);
|
|
216
|
+
}
|
|
217
|
+
__name(useFocusScopeBranch, "useFocusScopeBranch");
|
|
167
218
|
function focusFirst(candidates) {
|
|
168
|
-
let
|
|
169
|
-
|
|
170
|
-
select =
|
|
219
|
+
let _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
220
|
+
_ref2$select = _ref2.select,
|
|
221
|
+
select = _ref2$select === void 0 ? false : _ref2$select;
|
|
171
222
|
const previouslyFocusedElement = document.activeElement;
|
|
172
223
|
for (const candidate of candidates) {
|
|
173
224
|
focus(candidate, {
|
|
@@ -186,14 +237,19 @@ function getTabbableEdges(container) {
|
|
|
186
237
|
__name(getTabbableEdges, "getTabbableEdges");
|
|
187
238
|
function getTabbableCandidates(container) {
|
|
188
239
|
const nodes = [];
|
|
189
|
-
const
|
|
240
|
+
const document2 = container.ownerDocument;
|
|
241
|
+
const walker = document2.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
190
242
|
acceptNode: /* @__PURE__ */__name(node => {
|
|
191
243
|
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
192
|
-
if (node.disabled || node.hidden || isHiddenInput)
|
|
244
|
+
if (node.disabled || node.hidden || isHiddenInput) {
|
|
245
|
+
return NodeFilter.FILTER_SKIP;
|
|
246
|
+
}
|
|
193
247
|
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
194
248
|
}, "acceptNode")
|
|
195
249
|
});
|
|
196
|
-
while (walker.nextNode())
|
|
250
|
+
while (walker.nextNode()) {
|
|
251
|
+
nodes.push(walker.currentNode);
|
|
252
|
+
}
|
|
197
253
|
return nodes;
|
|
198
254
|
}
|
|
199
255
|
__name(getTabbableCandidates, "getTabbableCandidates");
|
|
@@ -213,8 +269,8 @@ function findVisible(elements, container) {
|
|
|
213
269
|
}
|
|
214
270
|
}
|
|
215
271
|
__name(findVisible, "findVisible");
|
|
216
|
-
function isHidden(node,
|
|
217
|
-
let upTo =
|
|
272
|
+
function isHidden(node, _ref3) {
|
|
273
|
+
let upTo = _ref3.upTo;
|
|
218
274
|
if (getComputedStyle(node).visibility === "hidden") return true;
|
|
219
275
|
while (node) {
|
|
220
276
|
if (upTo !== void 0 && node === upTo) return false;
|
|
@@ -225,15 +281,17 @@ function isHidden(node, _ref2) {
|
|
|
225
281
|
}
|
|
226
282
|
__name(isHidden, "isHidden");
|
|
227
283
|
function isSelectableInput(element) {
|
|
228
|
-
return element
|
|
284
|
+
return element.tagName === "INPUT" && typeof element.select === "function";
|
|
229
285
|
}
|
|
230
286
|
__name(isSelectableInput, "isSelectableInput");
|
|
231
287
|
function focus(element) {
|
|
232
|
-
let
|
|
233
|
-
|
|
234
|
-
select =
|
|
288
|
+
let _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
289
|
+
_ref4$select = _ref4.select,
|
|
290
|
+
select = _ref4$select === void 0 ? false : _ref4$select;
|
|
235
291
|
if (element && element.focus) {
|
|
236
|
-
|
|
292
|
+
var _element$ownerDocumen;
|
|
293
|
+
const ownerDocument = (_element$ownerDocumen = element.ownerDocument) !== null && _element$ownerDocumen !== void 0 ? _element$ownerDocumen : document;
|
|
294
|
+
const previouslyFocusedElement = ownerDocument.activeElement;
|
|
237
295
|
element.focus({
|
|
238
296
|
preventScroll: true
|
|
239
297
|
});
|
|
@@ -274,6 +332,5 @@ function removeLinks(items) {
|
|
|
274
332
|
return items.filter(item => item.tagName !== "A");
|
|
275
333
|
}
|
|
276
334
|
__name(removeLinks, "removeLinks");
|
|
277
|
-
var Root = FocusScope;
|
|
278
335
|
|
|
279
|
-
export { FocusScope, Root };
|
|
336
|
+
export { FocusScope, FocusScopeBranchProvider, FocusScope as Root, useFocusScopeBranch, useFocusScopeBranchRegistry };
|