@qualtrics/ui-react 2.75.0 → 2.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/__node_modules/@radix-ui/primitive/dist/index.js +54 -0
- package/dist/__node_modules/@radix-ui/react-arrow/dist/index.js +28 -0
- package/dist/__node_modules/@radix-ui/react-collection/dist/index.js +605 -0
- package/dist/__node_modules/@radix-ui/react-compose-refs/dist/index.js +45 -0
- package/dist/__node_modules/@radix-ui/react-context/dist/index.js +108 -0
- package/dist/__node_modules/@radix-ui/react-direction/dist/index.js +21 -0
- package/dist/__node_modules/@radix-ui/react-dismissable-layer/dist/index.js +223 -0
- package/dist/__node_modules/@radix-ui/react-dropdown-menu/dist/index.js +350 -0
- package/dist/__node_modules/@radix-ui/react-focus-guards/dist/index.js +35 -0
- package/dist/__node_modules/@radix-ui/react-focus-scope/dist/index.js +248 -0
- package/dist/__node_modules/@radix-ui/react-id/dist/index.js +15 -0
- package/dist/__node_modules/@radix-ui/react-menu/dist/index.js +911 -0
- package/dist/__node_modules/@radix-ui/react-popper/dist/index.js +325 -0
- package/dist/__node_modules/@radix-ui/react-portal/dist/index.js +25 -0
- package/dist/__node_modules/@radix-ui/react-presence/dist/index.js +141 -0
- package/dist/__node_modules/@radix-ui/react-primitive/dist/index.js +34 -0
- package/dist/__node_modules/@radix-ui/react-roving-focus/dist/index.js +216 -0
- package/dist/__node_modules/@radix-ui/react-slot/dist/index.js +127 -0
- package/dist/__node_modules/@radix-ui/react-use-callback-ref/dist/index.js +18 -0
- package/dist/__node_modules/@radix-ui/react-use-controllable-state/dist/index.js +141 -0
- package/dist/__node_modules/@radix-ui/react-use-effect-event/dist/index.js +32 -0
- package/dist/__node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +23 -0
- package/dist/__node_modules/@radix-ui/react-use-layout-effect/dist/index.js +6 -0
- package/dist/__node_modules/@radix-ui/react-use-size/dist/index.js +48 -0
- package/dist/__node_modules/aria-hidden/dist/es2015/index.js +169 -0
- package/dist/__node_modules/detect-node-es/esm/node.js +4 -0
- package/dist/__node_modules/get-nonce/dist/es2015/index.js +15 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/SideEffect.js +169 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/UI.js +39 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/handleScroll.js +110 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/index.js +1 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/medium.js +6 -0
- package/dist/__node_modules/react-remove-scroll/dist/es2015/sidecar.js +8 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/component.js +57 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/index.js +3 -0
- package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/component.js +19 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/index.js +3 -0
- package/dist/__node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
- package/dist/__node_modules/tslib/tslib.es6.js +403 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/createRef.js +25 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/index.js +8 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/mergeRef.js +21 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/refToCallback.js +50 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/transformRef.js +17 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
- package/dist/__node_modules/use-callback-ref/dist/es2015/useTransformRef.js +21 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/config.js +8 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/env.js +8 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/exports.js +21 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/hoc.js +18 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/hook.js +44 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/index.js +6 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/medium.js +81 -0
- package/dist/__node_modules/use-sidecar/dist/es2015/renderProp.js +38 -0
- package/dist/__shared/cjs/{index-98bc748b.js → index-58d973dc.js} +3 -3
- package/dist/__shared/cjs/{index-9f6415a6.js → index-fd8ffec5.js} +409 -372
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/BreakpointSwitch/BreakpointSwitch.js +3 -2
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/ButtonGroup/ButtonGroup.js +3 -2
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/ColorPicker/ColorPicker.js +7 -8
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/Combobox/Combobox.js +9 -8
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/Combobox/ComboboxList.js +5 -6
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/Dropdown.js +1 -1
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/Dropdown/DropdownButton.js +10 -9
- package/dist/components/Dropdown/DropdownList.js +6 -7
- 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/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/ConditionSet.js +2 -2
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/Modal/Modal.js +4 -2
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/BaseMenu.js +31 -25
- package/dist/components/NewMenu/Menu/Menu.js +1 -0
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NewMenu/SelectMenu/SelectMenu.js +3 -1
- package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +10 -4
- package/dist/components/NewMenu/parts/MenuItem.js +1 -1
- 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/Popover/Popover.js +8 -14
- package/dist/components/Popover/Popover2.js +3 -3
- 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/TabList.js +3 -2
- package/dist/components/Tabs/TabPanels.js +2 -1
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip.js +6 -12
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/deprecated_ColorPicker/ColorPicker.js +5 -6
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs.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/usePrevious/usePrevious.js +1 -1
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +2 -2
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +18 -17
- package/dist/index.es.js +1 -1
- package/dist/index.js +4 -5
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Combobox/ComboboxFlyout.js +6 -6
- package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +1 -1
- package/dist/next/Combobox/hooks/useComboboxLoadingState/useComboboxLoadingState.js +1 -1
- 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/Hooks/usePaneSearch.js +1 -1
- package/dist/next/Menu/Menu.js +5 -3
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuButton.js +1 -1
- package/dist/next/Menu/MenuItem.js +2 -2
- package/dist/next/Menu/MenuPane.js +14 -7
- package/dist/next/Menu/SubMenu.js +8 -6
- package/dist/next/PhoneNumberInput/PhoneNumberInput.js +90 -41
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/Select/Select.js +4 -2
- package/dist/next/Select/Select2.js +3 -3
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimeDropdown.js +5 -6
- package/dist/next/TimePicker/TimeInput.js +104 -37
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +19 -13
- package/dist/next/index.js +5617 -330
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/dist/utils/GridChildrenWrapper/GridChildrenWrapper.js +2 -1
- package/dist/utils/Popper/Popper.js +149 -115
- package/dist/utils/Portal/Portal.js +3 -2
- package/dist/utils/Text/Text.js +3 -2
- package/dist/utils/filterChildren/filterChildren.js +3 -2
- package/dist/utils/index.js +1 -0
- package/icons/package.json +3 -4
- package/next/package.json +4 -5
- package/package.json +15 -16
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { composeEventHandlers } from '../../primitive/dist/index.js';
|
|
3
|
+
import { composeRefs } from '../../react-compose-refs/dist/index.js';
|
|
4
|
+
import { createContextScope } from '../../react-context/dist/index.js';
|
|
5
|
+
import { useControllableState } from '../../react-use-controllable-state/dist/index.js';
|
|
6
|
+
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
7
|
+
import { createMenuScope, Root as Root3, Anchor as Anchor2, Portal, Content as Content2$1, Group, Label, Item as Item2$1, CheckboxItem, RadioGroup, RadioItem, ItemIndicator, Separator, Arrow as Arrow2$1, Sub, SubTrigger, SubContent } from '../../react-menu/dist/index.js';
|
|
8
|
+
import { useId } from '../../react-id/dist/index.js';
|
|
9
|
+
|
|
10
|
+
"use client";
|
|
11
|
+
var DROPDOWN_MENU_NAME = "DropdownMenu";
|
|
12
|
+
var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope(DROPDOWN_MENU_NAME, [createMenuScope]);
|
|
13
|
+
var useMenuScope = createMenuScope();
|
|
14
|
+
var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
|
|
15
|
+
var DropdownMenu = props => {
|
|
16
|
+
const {
|
|
17
|
+
__scopeDropdownMenu,
|
|
18
|
+
children,
|
|
19
|
+
dir,
|
|
20
|
+
open: openProp,
|
|
21
|
+
defaultOpen,
|
|
22
|
+
onOpenChange,
|
|
23
|
+
modal = true
|
|
24
|
+
} = props;
|
|
25
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
26
|
+
const triggerRef = React.useRef(null);
|
|
27
|
+
const [open, setOpen] = useControllableState({
|
|
28
|
+
prop: openProp,
|
|
29
|
+
defaultProp: defaultOpen !== null && defaultOpen !== void 0 ? defaultOpen : false,
|
|
30
|
+
onChange: onOpenChange,
|
|
31
|
+
caller: DROPDOWN_MENU_NAME
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */React.createElement(DropdownMenuProvider, {
|
|
34
|
+
scope: __scopeDropdownMenu,
|
|
35
|
+
triggerId: useId(),
|
|
36
|
+
triggerRef,
|
|
37
|
+
contentId: useId(),
|
|
38
|
+
open,
|
|
39
|
+
onOpenChange: setOpen,
|
|
40
|
+
onOpenToggle: React.useCallback(() => setOpen(prevOpen => !prevOpen), [setOpen]),
|
|
41
|
+
modal,
|
|
42
|
+
children: /* @__PURE__ */React.createElement(Root3, {
|
|
43
|
+
...menuScope,
|
|
44
|
+
open,
|
|
45
|
+
onOpenChange: setOpen,
|
|
46
|
+
dir,
|
|
47
|
+
modal,
|
|
48
|
+
children
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
DropdownMenu.displayName = DROPDOWN_MENU_NAME;
|
|
53
|
+
var TRIGGER_NAME = "DropdownMenuTrigger";
|
|
54
|
+
var DropdownMenuTrigger = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
55
|
+
const {
|
|
56
|
+
__scopeDropdownMenu,
|
|
57
|
+
disabled = false,
|
|
58
|
+
...triggerProps
|
|
59
|
+
} = props;
|
|
60
|
+
const context = useDropdownMenuContext(TRIGGER_NAME, __scopeDropdownMenu);
|
|
61
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
62
|
+
return /* @__PURE__ */React.createElement(Anchor2, {
|
|
63
|
+
asChild: true,
|
|
64
|
+
...menuScope,
|
|
65
|
+
children: /* @__PURE__ */React.createElement(Primitive.button, {
|
|
66
|
+
type: "button",
|
|
67
|
+
id: context.triggerId,
|
|
68
|
+
"aria-haspopup": "menu",
|
|
69
|
+
"aria-expanded": context.open,
|
|
70
|
+
"aria-controls": context.open ? context.contentId : void 0,
|
|
71
|
+
"data-state": context.open ? "open" : "closed",
|
|
72
|
+
"data-disabled": disabled ? "" : void 0,
|
|
73
|
+
disabled,
|
|
74
|
+
...triggerProps,
|
|
75
|
+
ref: composeRefs(forwardedRef, context.triggerRef),
|
|
76
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, event => {
|
|
77
|
+
if (!disabled && event.button === 0 && event.ctrlKey === false) {
|
|
78
|
+
context.onOpenToggle();
|
|
79
|
+
if (!context.open) event.preventDefault();
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, event => {
|
|
83
|
+
if (disabled) return;
|
|
84
|
+
if (["Enter", " "].includes(event.key)) context.onOpenToggle();
|
|
85
|
+
if (event.key === "ArrowDown") context.onOpenChange(true);
|
|
86
|
+
if (["Enter", " ", "ArrowDown"].includes(event.key)) event.preventDefault();
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
DropdownMenuTrigger.displayName = TRIGGER_NAME;
|
|
92
|
+
var PORTAL_NAME = "DropdownMenuPortal";
|
|
93
|
+
var DropdownMenuPortal = props => {
|
|
94
|
+
const {
|
|
95
|
+
__scopeDropdownMenu,
|
|
96
|
+
...portalProps
|
|
97
|
+
} = props;
|
|
98
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
99
|
+
return /* @__PURE__ */React.createElement(Portal, {
|
|
100
|
+
...menuScope,
|
|
101
|
+
...portalProps
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
DropdownMenuPortal.displayName = PORTAL_NAME;
|
|
105
|
+
var CONTENT_NAME = "DropdownMenuContent";
|
|
106
|
+
var DropdownMenuContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
107
|
+
const {
|
|
108
|
+
__scopeDropdownMenu,
|
|
109
|
+
...contentProps
|
|
110
|
+
} = props;
|
|
111
|
+
const context = useDropdownMenuContext(CONTENT_NAME, __scopeDropdownMenu);
|
|
112
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
113
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
114
|
+
return /* @__PURE__ */React.createElement(Content2$1, {
|
|
115
|
+
id: context.contentId,
|
|
116
|
+
"aria-labelledby": context.triggerId,
|
|
117
|
+
...menuScope,
|
|
118
|
+
...contentProps,
|
|
119
|
+
ref: forwardedRef,
|
|
120
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, event => {
|
|
121
|
+
var _context$triggerRef$c;
|
|
122
|
+
if (!hasInteractedOutsideRef.current) (_context$triggerRef$c = context.triggerRef.current) === null || _context$triggerRef$c === void 0 || _context$triggerRef$c.focus();
|
|
123
|
+
hasInteractedOutsideRef.current = false;
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
}),
|
|
126
|
+
onInteractOutside: composeEventHandlers(props.onInteractOutside, event => {
|
|
127
|
+
const originalEvent = event.detail.originalEvent;
|
|
128
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
129
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
130
|
+
if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
|
|
131
|
+
}),
|
|
132
|
+
style: {
|
|
133
|
+
...props.style,
|
|
134
|
+
// re-namespace exposed content custom properties
|
|
135
|
+
...{
|
|
136
|
+
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
137
|
+
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
138
|
+
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
139
|
+
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
140
|
+
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
DropdownMenuContent.displayName = CONTENT_NAME;
|
|
146
|
+
var GROUP_NAME = "DropdownMenuGroup";
|
|
147
|
+
var DropdownMenuGroup = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
148
|
+
const {
|
|
149
|
+
__scopeDropdownMenu,
|
|
150
|
+
...groupProps
|
|
151
|
+
} = props;
|
|
152
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
153
|
+
return /* @__PURE__ */React.createElement(Group, {
|
|
154
|
+
...menuScope,
|
|
155
|
+
...groupProps,
|
|
156
|
+
ref: forwardedRef
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
DropdownMenuGroup.displayName = GROUP_NAME;
|
|
160
|
+
var LABEL_NAME = "DropdownMenuLabel";
|
|
161
|
+
var DropdownMenuLabel = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
162
|
+
const {
|
|
163
|
+
__scopeDropdownMenu,
|
|
164
|
+
...labelProps
|
|
165
|
+
} = props;
|
|
166
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
167
|
+
return /* @__PURE__ */React.createElement(Label, {
|
|
168
|
+
...menuScope,
|
|
169
|
+
...labelProps,
|
|
170
|
+
ref: forwardedRef
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
DropdownMenuLabel.displayName = LABEL_NAME;
|
|
174
|
+
var ITEM_NAME = "DropdownMenuItem";
|
|
175
|
+
var DropdownMenuItem = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
176
|
+
const {
|
|
177
|
+
__scopeDropdownMenu,
|
|
178
|
+
...itemProps
|
|
179
|
+
} = props;
|
|
180
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
181
|
+
return /* @__PURE__ */React.createElement(Item2$1, {
|
|
182
|
+
...menuScope,
|
|
183
|
+
...itemProps,
|
|
184
|
+
ref: forwardedRef
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
DropdownMenuItem.displayName = ITEM_NAME;
|
|
188
|
+
var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
|
|
189
|
+
var DropdownMenuCheckboxItem = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
190
|
+
const {
|
|
191
|
+
__scopeDropdownMenu,
|
|
192
|
+
...checkboxItemProps
|
|
193
|
+
} = props;
|
|
194
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
195
|
+
return /* @__PURE__ */React.createElement(CheckboxItem, {
|
|
196
|
+
...menuScope,
|
|
197
|
+
...checkboxItemProps,
|
|
198
|
+
ref: forwardedRef
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
DropdownMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
|
|
202
|
+
var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
|
|
203
|
+
var DropdownMenuRadioGroup = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
204
|
+
const {
|
|
205
|
+
__scopeDropdownMenu,
|
|
206
|
+
...radioGroupProps
|
|
207
|
+
} = props;
|
|
208
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
209
|
+
return /* @__PURE__ */React.createElement(RadioGroup, {
|
|
210
|
+
...menuScope,
|
|
211
|
+
...radioGroupProps,
|
|
212
|
+
ref: forwardedRef
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
DropdownMenuRadioGroup.displayName = RADIO_GROUP_NAME;
|
|
216
|
+
var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
|
|
217
|
+
var DropdownMenuRadioItem = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
218
|
+
const {
|
|
219
|
+
__scopeDropdownMenu,
|
|
220
|
+
...radioItemProps
|
|
221
|
+
} = props;
|
|
222
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
223
|
+
return /* @__PURE__ */React.createElement(RadioItem, {
|
|
224
|
+
...menuScope,
|
|
225
|
+
...radioItemProps,
|
|
226
|
+
ref: forwardedRef
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
DropdownMenuRadioItem.displayName = RADIO_ITEM_NAME;
|
|
230
|
+
var INDICATOR_NAME = "DropdownMenuItemIndicator";
|
|
231
|
+
var DropdownMenuItemIndicator = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
232
|
+
const {
|
|
233
|
+
__scopeDropdownMenu,
|
|
234
|
+
...itemIndicatorProps
|
|
235
|
+
} = props;
|
|
236
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
237
|
+
return /* @__PURE__ */React.createElement(ItemIndicator, {
|
|
238
|
+
...menuScope,
|
|
239
|
+
...itemIndicatorProps,
|
|
240
|
+
ref: forwardedRef
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
|
|
244
|
+
var SEPARATOR_NAME = "DropdownMenuSeparator";
|
|
245
|
+
var DropdownMenuSeparator = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
246
|
+
const {
|
|
247
|
+
__scopeDropdownMenu,
|
|
248
|
+
...separatorProps
|
|
249
|
+
} = props;
|
|
250
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
251
|
+
return /* @__PURE__ */React.createElement(Separator, {
|
|
252
|
+
...menuScope,
|
|
253
|
+
...separatorProps,
|
|
254
|
+
ref: forwardedRef
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
DropdownMenuSeparator.displayName = SEPARATOR_NAME;
|
|
258
|
+
var ARROW_NAME = "DropdownMenuArrow";
|
|
259
|
+
var DropdownMenuArrow = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
260
|
+
const {
|
|
261
|
+
__scopeDropdownMenu,
|
|
262
|
+
...arrowProps
|
|
263
|
+
} = props;
|
|
264
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
265
|
+
return /* @__PURE__ */React.createElement(Arrow2$1, {
|
|
266
|
+
...menuScope,
|
|
267
|
+
...arrowProps,
|
|
268
|
+
ref: forwardedRef
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
DropdownMenuArrow.displayName = ARROW_NAME;
|
|
272
|
+
var DropdownMenuSub = props => {
|
|
273
|
+
const {
|
|
274
|
+
__scopeDropdownMenu,
|
|
275
|
+
children,
|
|
276
|
+
open: openProp,
|
|
277
|
+
onOpenChange,
|
|
278
|
+
defaultOpen
|
|
279
|
+
} = props;
|
|
280
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
281
|
+
const [open, setOpen] = useControllableState({
|
|
282
|
+
prop: openProp,
|
|
283
|
+
defaultProp: defaultOpen !== null && defaultOpen !== void 0 ? defaultOpen : false,
|
|
284
|
+
onChange: onOpenChange,
|
|
285
|
+
caller: "DropdownMenuSub"
|
|
286
|
+
});
|
|
287
|
+
return /* @__PURE__ */React.createElement(Sub, {
|
|
288
|
+
...menuScope,
|
|
289
|
+
open,
|
|
290
|
+
onOpenChange: setOpen,
|
|
291
|
+
children
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
|
|
295
|
+
var DropdownMenuSubTrigger = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
296
|
+
const {
|
|
297
|
+
__scopeDropdownMenu,
|
|
298
|
+
...subTriggerProps
|
|
299
|
+
} = props;
|
|
300
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
301
|
+
return /* @__PURE__ */React.createElement(SubTrigger, {
|
|
302
|
+
...menuScope,
|
|
303
|
+
...subTriggerProps,
|
|
304
|
+
ref: forwardedRef
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
DropdownMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
|
|
308
|
+
var SUB_CONTENT_NAME = "DropdownMenuSubContent";
|
|
309
|
+
var DropdownMenuSubContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
310
|
+
const {
|
|
311
|
+
__scopeDropdownMenu,
|
|
312
|
+
...subContentProps
|
|
313
|
+
} = props;
|
|
314
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
315
|
+
return /* @__PURE__ */React.createElement(SubContent, {
|
|
316
|
+
...menuScope,
|
|
317
|
+
...subContentProps,
|
|
318
|
+
ref: forwardedRef,
|
|
319
|
+
style: {
|
|
320
|
+
...props.style,
|
|
321
|
+
// re-namespace exposed content custom properties
|
|
322
|
+
...{
|
|
323
|
+
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
324
|
+
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
325
|
+
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
326
|
+
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
327
|
+
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
DropdownMenuSubContent.displayName = SUB_CONTENT_NAME;
|
|
333
|
+
var Root2 = DropdownMenu;
|
|
334
|
+
var Trigger = DropdownMenuTrigger;
|
|
335
|
+
var Portal2 = DropdownMenuPortal;
|
|
336
|
+
var Content2 = DropdownMenuContent;
|
|
337
|
+
var Group2 = DropdownMenuGroup;
|
|
338
|
+
var Label2 = DropdownMenuLabel;
|
|
339
|
+
var Item2 = DropdownMenuItem;
|
|
340
|
+
var CheckboxItem2 = DropdownMenuCheckboxItem;
|
|
341
|
+
var RadioGroup2 = DropdownMenuRadioGroup;
|
|
342
|
+
var RadioItem2 = DropdownMenuRadioItem;
|
|
343
|
+
var ItemIndicator2 = DropdownMenuItemIndicator;
|
|
344
|
+
var Separator2 = DropdownMenuSeparator;
|
|
345
|
+
var Arrow2 = DropdownMenuArrow;
|
|
346
|
+
var Sub2 = DropdownMenuSub;
|
|
347
|
+
var SubTrigger2 = DropdownMenuSubTrigger;
|
|
348
|
+
var SubContent2 = DropdownMenuSubContent;
|
|
349
|
+
|
|
350
|
+
export { Arrow2 as Arrow, CheckboxItem2 as CheckboxItem, Content2 as Content, DropdownMenu, DropdownMenuArrow, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuItemIndicator, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Group2 as Group, Item2 as Item, ItemIndicator2 as ItemIndicator, Label2 as Label, Portal2 as Portal, RadioGroup2 as RadioGroup, RadioItem2 as RadioItem, Root2 as Root, Separator2 as Separator, Sub2 as Sub, SubContent2 as SubContent, SubTrigger2 as SubTrigger, Trigger, createDropdownMenuScope };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
var count = 0;
|
|
5
|
+
function FocusGuards(props) {
|
|
6
|
+
useFocusGuards();
|
|
7
|
+
return props.children;
|
|
8
|
+
}
|
|
9
|
+
function useFocusGuards() {
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
var _edgeGuards$, _edgeGuards$2;
|
|
12
|
+
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
13
|
+
document.body.insertAdjacentElement("afterbegin", (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : createFocusGuard());
|
|
14
|
+
document.body.insertAdjacentElement("beforeend", (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : createFocusGuard());
|
|
15
|
+
count++;
|
|
16
|
+
return () => {
|
|
17
|
+
if (count === 1) {
|
|
18
|
+
document.querySelectorAll("[data-radix-focus-guard]").forEach(node => node.remove());
|
|
19
|
+
}
|
|
20
|
+
count--;
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
}
|
|
24
|
+
function createFocusGuard() {
|
|
25
|
+
const element = document.createElement("span");
|
|
26
|
+
element.setAttribute("data-radix-focus-guard", "");
|
|
27
|
+
element.tabIndex = 0;
|
|
28
|
+
element.style.outline = "none";
|
|
29
|
+
element.style.opacity = "0";
|
|
30
|
+
element.style.position = "fixed";
|
|
31
|
+
element.style.pointerEvents = "none";
|
|
32
|
+
return element;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { FocusGuards, FocusGuards as Root, useFocusGuards };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
|
|
3
|
+
import { Primitive } from '../../react-primitive/dist/index.js';
|
|
4
|
+
import { useCallbackRef } from '../../react-use-callback-ref/dist/index.js';
|
|
5
|
+
|
|
6
|
+
"use client";
|
|
7
|
+
var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
8
|
+
var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
9
|
+
var EVENT_OPTIONS = {
|
|
10
|
+
bubbles: false,
|
|
11
|
+
cancelable: true
|
|
12
|
+
};
|
|
13
|
+
var FOCUS_SCOPE_NAME = "FocusScope";
|
|
14
|
+
var FocusScope = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
|
|
15
|
+
const {
|
|
16
|
+
loop = false,
|
|
17
|
+
trapped = false,
|
|
18
|
+
onMountAutoFocus: onMountAutoFocusProp,
|
|
19
|
+
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
20
|
+
...scopeProps
|
|
21
|
+
} = props;
|
|
22
|
+
const [container, setContainer] = React.useState(null);
|
|
23
|
+
const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp);
|
|
24
|
+
const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);
|
|
25
|
+
const lastFocusedElementRef = React.useRef(null);
|
|
26
|
+
const composedRefs = useComposedRefs(forwardedRef, node => setContainer(node));
|
|
27
|
+
const focusScope = React.useRef({
|
|
28
|
+
paused: false,
|
|
29
|
+
pause() {
|
|
30
|
+
this.paused = true;
|
|
31
|
+
},
|
|
32
|
+
resume() {
|
|
33
|
+
this.paused = false;
|
|
34
|
+
}
|
|
35
|
+
}).current;
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (trapped) {
|
|
38
|
+
let handleFocusIn2 = function (event) {
|
|
39
|
+
if (focusScope.paused || !container) return;
|
|
40
|
+
const target = event.target;
|
|
41
|
+
if (container.contains(target)) {
|
|
42
|
+
lastFocusedElementRef.current = target;
|
|
43
|
+
} else {
|
|
44
|
+
focus(lastFocusedElementRef.current, {
|
|
45
|
+
select: true
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
handleFocusOut2 = function (event) {
|
|
50
|
+
if (focusScope.paused || !container) return;
|
|
51
|
+
const relatedTarget = event.relatedTarget;
|
|
52
|
+
if (relatedTarget === null) return;
|
|
53
|
+
if (!container.contains(relatedTarget)) {
|
|
54
|
+
focus(lastFocusedElementRef.current, {
|
|
55
|
+
select: true
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
handleMutations2 = function (mutations) {
|
|
60
|
+
const focusedElement = document.activeElement;
|
|
61
|
+
if (focusedElement !== document.body) return;
|
|
62
|
+
for (const mutation of mutations) {
|
|
63
|
+
if (mutation.removedNodes.length > 0) focus(container);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var handleFocusIn = handleFocusIn2,
|
|
67
|
+
handleFocusOut = handleFocusOut2,
|
|
68
|
+
handleMutations = handleMutations2;
|
|
69
|
+
document.addEventListener("focusin", handleFocusIn2);
|
|
70
|
+
document.addEventListener("focusout", handleFocusOut2);
|
|
71
|
+
const mutationObserver = new MutationObserver(handleMutations2);
|
|
72
|
+
if (container) mutationObserver.observe(container, {
|
|
73
|
+
childList: true,
|
|
74
|
+
subtree: true
|
|
75
|
+
});
|
|
76
|
+
return () => {
|
|
77
|
+
document.removeEventListener("focusin", handleFocusIn2);
|
|
78
|
+
document.removeEventListener("focusout", handleFocusOut2);
|
|
79
|
+
mutationObserver.disconnect();
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}, [trapped, container, focusScope.paused]);
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
if (container) {
|
|
85
|
+
focusScopesStack.add(focusScope);
|
|
86
|
+
const previouslyFocusedElement = document.activeElement;
|
|
87
|
+
const hasFocusedCandidate = container.contains(previouslyFocusedElement);
|
|
88
|
+
if (!hasFocusedCandidate) {
|
|
89
|
+
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
90
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
91
|
+
container.dispatchEvent(mountEvent);
|
|
92
|
+
if (!mountEvent.defaultPrevented) {
|
|
93
|
+
focusFirst(removeLinks(getTabbableCandidates(container)), {
|
|
94
|
+
select: true
|
|
95
|
+
});
|
|
96
|
+
if (document.activeElement === previouslyFocusedElement) {
|
|
97
|
+
focus(container);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return () => {
|
|
102
|
+
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
103
|
+
setTimeout(() => {
|
|
104
|
+
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
105
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
106
|
+
container.dispatchEvent(unmountEvent);
|
|
107
|
+
if (!unmountEvent.defaultPrevented) {
|
|
108
|
+
focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : document.body, {
|
|
109
|
+
select: true
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
113
|
+
focusScopesStack.remove(focusScope);
|
|
114
|
+
}, 0);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
118
|
+
const handleKeyDown = React.useCallback(event => {
|
|
119
|
+
if (!loop && !trapped) return;
|
|
120
|
+
if (focusScope.paused) return;
|
|
121
|
+
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
122
|
+
const focusedElement = document.activeElement;
|
|
123
|
+
if (isTabKey && focusedElement) {
|
|
124
|
+
const container2 = event.currentTarget;
|
|
125
|
+
const [first, last] = getTabbableEdges(container2);
|
|
126
|
+
const hasTabbableElementsInside = first && last;
|
|
127
|
+
if (!hasTabbableElementsInside) {
|
|
128
|
+
if (focusedElement === container2) event.preventDefault();
|
|
129
|
+
} else {
|
|
130
|
+
if (!event.shiftKey && focusedElement === last) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
if (loop) focus(first, {
|
|
133
|
+
select: true
|
|
134
|
+
});
|
|
135
|
+
} else if (event.shiftKey && focusedElement === first) {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
if (loop) focus(last, {
|
|
138
|
+
select: true
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, [loop, trapped, focusScope.paused]);
|
|
144
|
+
return /* @__PURE__ */React.createElement(Primitive.div, {
|
|
145
|
+
tabIndex: -1,
|
|
146
|
+
...scopeProps,
|
|
147
|
+
ref: composedRefs,
|
|
148
|
+
onKeyDown: handleKeyDown
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
FocusScope.displayName = FOCUS_SCOPE_NAME;
|
|
152
|
+
function focusFirst(candidates) {
|
|
153
|
+
let {
|
|
154
|
+
select = false
|
|
155
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
156
|
+
const previouslyFocusedElement = document.activeElement;
|
|
157
|
+
for (const candidate of candidates) {
|
|
158
|
+
focus(candidate, {
|
|
159
|
+
select
|
|
160
|
+
});
|
|
161
|
+
if (document.activeElement !== previouslyFocusedElement) return;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function getTabbableEdges(container) {
|
|
165
|
+
const candidates = getTabbableCandidates(container);
|
|
166
|
+
const first = findVisible(candidates, container);
|
|
167
|
+
const last = findVisible(candidates.reverse(), container);
|
|
168
|
+
return [first, last];
|
|
169
|
+
}
|
|
170
|
+
function getTabbableCandidates(container) {
|
|
171
|
+
const nodes = [];
|
|
172
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
173
|
+
acceptNode: node => {
|
|
174
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
175
|
+
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
|
176
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
|
180
|
+
return nodes;
|
|
181
|
+
}
|
|
182
|
+
function findVisible(elements, container) {
|
|
183
|
+
for (const element of elements) {
|
|
184
|
+
if (!isHidden(element, {
|
|
185
|
+
upTo: container
|
|
186
|
+
})) return element;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function isHidden(node, _ref) {
|
|
190
|
+
let {
|
|
191
|
+
upTo
|
|
192
|
+
} = _ref;
|
|
193
|
+
if (getComputedStyle(node).visibility === "hidden") return true;
|
|
194
|
+
while (node) {
|
|
195
|
+
if (upTo !== void 0 && node === upTo) return false;
|
|
196
|
+
if (getComputedStyle(node).display === "none") return true;
|
|
197
|
+
node = node.parentElement;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
function isSelectableInput(element) {
|
|
202
|
+
return element instanceof HTMLInputElement && "select" in element;
|
|
203
|
+
}
|
|
204
|
+
function focus(element) {
|
|
205
|
+
let {
|
|
206
|
+
select = false
|
|
207
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
208
|
+
if (element && element.focus) {
|
|
209
|
+
const previouslyFocusedElement = document.activeElement;
|
|
210
|
+
element.focus({
|
|
211
|
+
preventScroll: true
|
|
212
|
+
});
|
|
213
|
+
if (element !== previouslyFocusedElement && isSelectableInput(element) && select) element.select();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
var focusScopesStack = createFocusScopesStack();
|
|
217
|
+
function createFocusScopesStack() {
|
|
218
|
+
let stack = [];
|
|
219
|
+
return {
|
|
220
|
+
add(focusScope) {
|
|
221
|
+
const activeFocusScope = stack[0];
|
|
222
|
+
if (focusScope !== activeFocusScope) {
|
|
223
|
+
activeFocusScope === null || activeFocusScope === void 0 || activeFocusScope.pause();
|
|
224
|
+
}
|
|
225
|
+
stack = arrayRemove(stack, focusScope);
|
|
226
|
+
stack.unshift(focusScope);
|
|
227
|
+
},
|
|
228
|
+
remove(focusScope) {
|
|
229
|
+
var _stack$;
|
|
230
|
+
stack = arrayRemove(stack, focusScope);
|
|
231
|
+
(_stack$ = stack[0]) === null || _stack$ === void 0 || _stack$.resume();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function arrayRemove(array, item) {
|
|
236
|
+
const updatedArray = [...array];
|
|
237
|
+
const index = updatedArray.indexOf(item);
|
|
238
|
+
if (index !== -1) {
|
|
239
|
+
updatedArray.splice(index, 1);
|
|
240
|
+
}
|
|
241
|
+
return updatedArray;
|
|
242
|
+
}
|
|
243
|
+
function removeLinks(items) {
|
|
244
|
+
return items.filter(item => item.tagName !== "A");
|
|
245
|
+
}
|
|
246
|
+
var Root = FocusScope;
|
|
247
|
+
|
|
248
|
+
export { FocusScope, Root };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
|
|
3
|
+
|
|
4
|
+
// packages/react/id/src/id.tsx
|
|
5
|
+
var useReactId = React[" useId ".trim().toString()] || (() => void 0);
|
|
6
|
+
var count = 0;
|
|
7
|
+
function useId(deterministicId) {
|
|
8
|
+
const [id, setId] = React.useState(useReactId());
|
|
9
|
+
useLayoutEffect2(() => {
|
|
10
|
+
if (!deterministicId) setId(reactId => reactId !== null && reactId !== void 0 ? reactId : String(count++));
|
|
11
|
+
}, [deterministicId]);
|
|
12
|
+
return deterministicId || (id ? "radix-".concat(id) : "");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useId };
|