@vritti/quantum-ui 0.2.7 → 0.2.9
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/README.md +7 -7
- package/dist/Alert.js +110 -0
- package/dist/Alert.js.map +1 -0
- package/dist/Avatar.js +219 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/Badge.js +32 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Button2.js +2 -2
- package/dist/Chart.js +19003 -0
- package/dist/Chart.js.map +1 -0
- package/dist/Checkbox.js +6 -26
- package/dist/Checkbox.js.map +1 -1
- package/dist/Combination.js +3856 -0
- package/dist/Combination.js.map +1 -0
- package/dist/DatePicker.js +15 -3886
- package/dist/DatePicker.js.map +1 -1
- package/dist/DropdownMenu.js +1522 -0
- package/dist/DropdownMenu.js.map +1 -0
- package/dist/Form.js +34 -23
- package/dist/Form.js.map +1 -1
- package/dist/Label.js +1 -1
- package/dist/OTPField.js +16 -5
- package/dist/OTPField.js.map +1 -1
- package/dist/PhoneField.js +14 -6
- package/dist/PhoneField.js.map +1 -1
- package/dist/Progress.js +116 -0
- package/dist/Progress.js.map +1 -0
- package/dist/SelectField.js +1351 -0
- package/dist/SelectField.js.map +1 -0
- package/dist/Separator.js +6 -0
- package/dist/Separator.js.map +1 -0
- package/dist/Sonner.js +3 -38
- package/dist/Sonner.js.map +1 -1
- package/dist/Spinner.js +1 -9
- package/dist/Spinner.js.map +1 -1
- package/dist/Switch.js +210 -0
- package/dist/Switch.js.map +1 -0
- package/dist/ThemeContext.js +57 -0
- package/dist/ThemeContext.js.map +1 -0
- package/dist/ThemeToggle.js +4 -15
- package/dist/ThemeToggle.js.map +1 -1
- package/dist/Toggle.js +69 -0
- package/dist/Toggle.js.map +1 -0
- package/dist/_commonjsHelpers.js +6 -0
- package/dist/_commonjsHelpers.js.map +1 -0
- package/dist/assets/quantum-ui.css +18 -0
- package/dist/axios.js.map +1 -1
- package/dist/check.js +15 -0
- package/dist/check.js.map +1 -0
- package/dist/chevron-down.js +15 -0
- package/dist/chevron-down.js.map +1 -0
- package/dist/chevron-right.js +15 -0
- package/dist/chevron-right.js.map +1 -0
- package/dist/components/Alert.js +2 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/Avatar.js +2 -0
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/Badge.js +2 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Chart.js +2 -0
- package/dist/components/Chart.js.map +1 -0
- package/dist/components/DropdownMenu.js +2 -0
- package/dist/components/DropdownMenu.js.map +1 -0
- package/dist/components/Progress.js +1 -174
- package/dist/components/Progress.js.map +1 -1
- package/dist/components/SelectField.js +2 -0
- package/dist/components/SelectField.js.map +1 -0
- package/dist/components/Separator.js +2 -0
- package/dist/components/Separator.js.map +1 -0
- package/dist/components/Switch.js +2 -0
- package/dist/components/Switch.js.map +1 -0
- package/dist/components/Toggle.js +2 -0
- package/dist/components/Toggle.js.map +1 -0
- package/dist/context/index.js +2 -0
- package/dist/context/index.js.map +1 -0
- package/dist/field.js +2 -49
- package/dist/field.js.map +1 -1
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/index10.js +105 -0
- package/dist/index10.js.map +1 -0
- package/dist/index11.js +79 -0
- package/dist/index11.js.map +1 -0
- package/dist/index12.js +101 -0
- package/dist/index12.js.map +1 -0
- package/dist/index13.js +205 -0
- package/dist/index13.js.map +1 -0
- package/dist/index14.js +199 -0
- package/dist/index14.js.map +1 -0
- package/dist/index2.js +55 -130
- package/dist/index2.js.map +1 -1
- package/dist/index3.js +10 -42
- package/dist/index3.js.map +1 -1
- package/dist/index4.js +125 -35
- package/dist/index4.js.map +1 -1
- package/dist/index5.js +26 -414
- package/dist/index5.js.map +1 -1
- package/dist/index6.js +8 -0
- package/dist/index6.js.map +1 -0
- package/dist/index7.js +16 -0
- package/dist/index7.js.map +1 -0
- package/dist/index8.js +45 -0
- package/dist/index8.js.map +1 -0
- package/dist/index9.js +41 -0
- package/dist/index9.js.map +1 -0
- package/dist/lib/components/Alert/Alert.d.ts +10 -0
- package/dist/lib/components/Alert/Alert.d.ts.map +1 -0
- package/dist/lib/components/Alert/index.d.ts +2 -0
- package/dist/lib/components/Alert/index.d.ts.map +1 -0
- package/dist/lib/components/Avatar/Avatar.d.ts +8 -0
- package/dist/lib/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/lib/components/Avatar/index.d.ts +2 -0
- package/dist/lib/components/Avatar/index.d.ts.map +1 -0
- package/dist/lib/components/Badge/Badge.d.ts +5 -0
- package/dist/lib/components/Badge/Badge.d.ts.map +1 -0
- package/dist/lib/components/Badge/index.d.ts +3 -0
- package/dist/lib/components/Badge/index.d.ts.map +1 -0
- package/dist/lib/components/Button/index.d.ts +1 -1
- package/dist/lib/components/Button/index.d.ts.map +1 -1
- package/dist/lib/components/Chart/Chart.d.ts +13 -0
- package/dist/lib/components/Chart/Chart.d.ts.map +1 -0
- package/dist/lib/components/Chart/index.d.ts +3 -0
- package/dist/lib/components/Chart/index.d.ts.map +1 -0
- package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts +28 -0
- package/dist/lib/components/DropdownMenu/DropdownMenu.d.ts.map +1 -0
- package/dist/lib/components/DropdownMenu/index.d.ts +3 -0
- package/dist/lib/components/DropdownMenu/index.d.ts.map +1 -0
- package/dist/lib/components/DropdownMenu/types.d.ts +72 -0
- package/dist/lib/components/DropdownMenu/types.d.ts.map +1 -0
- package/dist/lib/components/Form/Form.d.ts +1 -1
- package/dist/lib/components/Form/Form.d.ts.map +1 -1
- package/dist/lib/components/OTPField/OTPField.d.ts.map +1 -1
- package/dist/lib/components/PhoneField/PhoneField.d.ts.map +1 -1
- package/dist/lib/components/SelectField/SelectField.d.ts +24 -0
- package/dist/lib/components/SelectField/SelectField.d.ts.map +1 -0
- package/dist/lib/components/SelectField/index.d.ts +3 -0
- package/dist/lib/components/SelectField/index.d.ts.map +1 -0
- package/dist/lib/components/Separator/Separator.d.ts +3 -0
- package/dist/lib/components/Separator/Separator.d.ts.map +1 -0
- package/dist/lib/components/Separator/index.d.ts +2 -0
- package/dist/lib/components/Separator/index.d.ts.map +1 -0
- package/dist/lib/components/Switch/Switch.d.ts +9 -0
- package/dist/lib/components/Switch/Switch.d.ts.map +1 -0
- package/dist/lib/components/Switch/index.d.ts +3 -0
- package/dist/lib/components/Switch/index.d.ts.map +1 -0
- package/dist/lib/components/ThemeToggle/ThemeToggle.d.ts.map +1 -1
- package/dist/lib/components/Toggle/Toggle.d.ts +7 -0
- package/dist/lib/components/Toggle/Toggle.d.ts.map +1 -0
- package/dist/lib/components/Toggle/index.d.ts +2 -0
- package/dist/lib/components/Toggle/index.d.ts.map +1 -0
- package/dist/lib/components/index.d.ts +10 -0
- package/dist/lib/components/index.d.ts.map +1 -1
- package/dist/lib/context/ThemeContext.d.ts +18 -0
- package/dist/lib/context/ThemeContext.d.ts.map +1 -0
- package/dist/lib/context/index.d.ts +2 -0
- package/dist/lib/context/index.d.ts.map +1 -0
- package/dist/lib/hooks/index.d.ts +2 -0
- package/dist/lib/hooks/index.d.ts.map +1 -0
- package/dist/lib/hooks/useTheme.d.ts +8 -0
- package/dist/lib/hooks/useTheme.d.ts.map +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/theme/index.d.ts +13 -0
- package/dist/lib/theme/index.d.ts.map +1 -0
- package/dist/lib/utils/axios.d.ts +1 -0
- package/dist/lib/utils/axios.d.ts.map +1 -1
- package/dist/lib/utils/formHelpers.d.ts +7 -3
- package/dist/lib/utils/formHelpers.d.ts.map +1 -1
- package/dist/separator2.js +53 -0
- package/dist/separator2.js.map +1 -0
- package/dist/shadcn/index.d.ts +1 -1
- package/dist/shadcn/index.d.ts.map +1 -1
- package/dist/shadcn/shadcnAlert/alert.d.ts +11 -0
- package/dist/shadcn/shadcnAlert/alert.d.ts.map +1 -0
- package/dist/shadcn/shadcnAlert/index.d.ts +2 -0
- package/dist/shadcn/shadcnAlert/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnAvatar/Avatar.d.ts +12 -0
- package/dist/shadcn/shadcnAvatar/Avatar.d.ts.map +1 -0
- package/dist/shadcn/shadcnAvatar/index.d.ts +2 -0
- package/dist/shadcn/shadcnAvatar/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnBadge/Badge.d.ts +11 -0
- package/dist/shadcn/shadcnBadge/Badge.d.ts.map +1 -0
- package/dist/shadcn/shadcnBadge/index.d.ts +3 -0
- package/dist/shadcn/shadcnBadge/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnButton/Button.d.ts +2 -2
- package/dist/shadcn/shadcnChart/Chart.d.ts +58 -0
- package/dist/shadcn/shadcnChart/Chart.d.ts.map +1 -0
- package/dist/shadcn/shadcnChart/index.d.ts +3 -0
- package/dist/shadcn/shadcnChart/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnSpinner/Spinner.d.ts.map +1 -1
- package/dist/shadcn/shadcnSwitch/Switch.d.ts +7 -0
- package/dist/shadcn/shadcnSwitch/Switch.d.ts.map +1 -0
- package/dist/shadcn/shadcnSwitch/index.d.ts +2 -0
- package/dist/shadcn/shadcnSwitch/index.d.ts.map +1 -0
- package/dist/shadcn/shadcnToggle/Toggle.d.ts +10 -0
- package/dist/shadcn/shadcnToggle/Toggle.d.ts.map +1 -0
- package/dist/shadcn/shadcnToggle/index.d.ts +2 -0
- package/dist/shadcn/shadcnToggle/index.d.ts.map +1 -0
- package/dist/theme/index.js +11 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/triangle-alert.js +40 -0
- package/dist/triangle-alert.js.map +1 -0
- package/dist/useTheme.js +15 -0
- package/dist/useTheme.js.map +1 -0
- package/package.json +59 -6
|
@@ -0,0 +1,1522 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { B as Button } from './Button.js';
|
|
4
|
+
import { P as Primitive, a as composeEventHandlers, u as useControllableState, d as dispatchDiscreteCustomEvent, c as createSlot } from './index13.js';
|
|
5
|
+
import { u as useComposedRefs, c as composeRefs } from './index5.js';
|
|
6
|
+
import { c as createContextScope } from './index12.js';
|
|
7
|
+
import { c as createCollection, u as useDirection } from './index11.js';
|
|
8
|
+
import { u as useId, c as createPopperScope, R as Root2$1, P as Portal$1, A as Anchor, h as hideOthers, a as useFocusGuards, b as ReactRemoveScroll, F as FocusScope, D as DismissableLayer, C as Content, d as Arrow } from './Combination.js';
|
|
9
|
+
import { P as Presence } from './index4.js';
|
|
10
|
+
import { u as useCallbackRef } from './index3.js';
|
|
11
|
+
import { c as cn } from './utils.js';
|
|
12
|
+
import { C as Check } from './check.js';
|
|
13
|
+
import { c as createLucideIcon } from './createLucideIcon.js';
|
|
14
|
+
import { C as ChevronRight } from './chevron-right.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @license lucide-react v0.562.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const __iconNode = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
|
|
25
|
+
const Circle = createLucideIcon("circle", __iconNode);
|
|
26
|
+
|
|
27
|
+
var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
|
|
28
|
+
var EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
29
|
+
var GROUP_NAME$2 = "RovingFocusGroup";
|
|
30
|
+
var [Collection$1, useCollection$1, createCollectionScope$1] = createCollection(GROUP_NAME$2);
|
|
31
|
+
var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(
|
|
32
|
+
GROUP_NAME$2,
|
|
33
|
+
[createCollectionScope$1]
|
|
34
|
+
);
|
|
35
|
+
var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME$2);
|
|
36
|
+
var RovingFocusGroup = React.forwardRef(
|
|
37
|
+
(props, forwardedRef) => {
|
|
38
|
+
return /* @__PURE__ */ jsx(Collection$1.Provider, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx(Collection$1.Slot, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx(RovingFocusGroupImpl, { ...props, ref: forwardedRef }) }) });
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
RovingFocusGroup.displayName = GROUP_NAME$2;
|
|
42
|
+
var RovingFocusGroupImpl = React.forwardRef((props, forwardedRef) => {
|
|
43
|
+
const {
|
|
44
|
+
__scopeRovingFocusGroup,
|
|
45
|
+
orientation,
|
|
46
|
+
loop = false,
|
|
47
|
+
dir,
|
|
48
|
+
currentTabStopId: currentTabStopIdProp,
|
|
49
|
+
defaultCurrentTabStopId,
|
|
50
|
+
onCurrentTabStopIdChange,
|
|
51
|
+
onEntryFocus,
|
|
52
|
+
preventScrollOnEntryFocus = false,
|
|
53
|
+
...groupProps
|
|
54
|
+
} = props;
|
|
55
|
+
const ref = React.useRef(null);
|
|
56
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
57
|
+
const direction = useDirection(dir);
|
|
58
|
+
const [currentTabStopId, setCurrentTabStopId] = useControllableState({
|
|
59
|
+
prop: currentTabStopIdProp,
|
|
60
|
+
defaultProp: defaultCurrentTabStopId ?? null,
|
|
61
|
+
onChange: onCurrentTabStopIdChange,
|
|
62
|
+
caller: GROUP_NAME$2
|
|
63
|
+
});
|
|
64
|
+
const [isTabbingBackOut, setIsTabbingBackOut] = React.useState(false);
|
|
65
|
+
const handleEntryFocus = useCallbackRef(onEntryFocus);
|
|
66
|
+
const getItems = useCollection$1(__scopeRovingFocusGroup);
|
|
67
|
+
const isClickFocusRef = React.useRef(false);
|
|
68
|
+
const [focusableItemsCount, setFocusableItemsCount] = React.useState(0);
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
const node = ref.current;
|
|
71
|
+
if (node) {
|
|
72
|
+
node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
73
|
+
return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
74
|
+
}
|
|
75
|
+
}, [handleEntryFocus]);
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
RovingFocusProvider,
|
|
78
|
+
{
|
|
79
|
+
scope: __scopeRovingFocusGroup,
|
|
80
|
+
orientation,
|
|
81
|
+
dir: direction,
|
|
82
|
+
loop,
|
|
83
|
+
currentTabStopId,
|
|
84
|
+
onItemFocus: React.useCallback(
|
|
85
|
+
(tabStopId) => setCurrentTabStopId(tabStopId),
|
|
86
|
+
[setCurrentTabStopId]
|
|
87
|
+
),
|
|
88
|
+
onItemShiftTab: React.useCallback(() => setIsTabbingBackOut(true), []),
|
|
89
|
+
onFocusableItemAdd: React.useCallback(
|
|
90
|
+
() => setFocusableItemsCount((prevCount) => prevCount + 1),
|
|
91
|
+
[]
|
|
92
|
+
),
|
|
93
|
+
onFocusableItemRemove: React.useCallback(
|
|
94
|
+
() => setFocusableItemsCount((prevCount) => prevCount - 1),
|
|
95
|
+
[]
|
|
96
|
+
),
|
|
97
|
+
children: /* @__PURE__ */ jsx(
|
|
98
|
+
Primitive.div,
|
|
99
|
+
{
|
|
100
|
+
tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
|
|
101
|
+
"data-orientation": orientation,
|
|
102
|
+
...groupProps,
|
|
103
|
+
ref: composedRefs,
|
|
104
|
+
style: { outline: "none", ...props.style },
|
|
105
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, () => {
|
|
106
|
+
isClickFocusRef.current = true;
|
|
107
|
+
}),
|
|
108
|
+
onFocus: composeEventHandlers(props.onFocus, (event) => {
|
|
109
|
+
const isKeyboardFocus = !isClickFocusRef.current;
|
|
110
|
+
if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
|
|
111
|
+
const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
|
|
112
|
+
event.currentTarget.dispatchEvent(entryFocusEvent);
|
|
113
|
+
if (!entryFocusEvent.defaultPrevented) {
|
|
114
|
+
const items = getItems().filter((item) => item.focusable);
|
|
115
|
+
const activeItem = items.find((item) => item.active);
|
|
116
|
+
const currentItem = items.find((item) => item.id === currentTabStopId);
|
|
117
|
+
const candidateItems = [activeItem, currentItem, ...items].filter(
|
|
118
|
+
Boolean
|
|
119
|
+
);
|
|
120
|
+
const candidateNodes = candidateItems.map((item) => item.ref.current);
|
|
121
|
+
focusFirst$1(candidateNodes, preventScrollOnEntryFocus);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
isClickFocusRef.current = false;
|
|
125
|
+
}),
|
|
126
|
+
onBlur: composeEventHandlers(props.onBlur, () => setIsTabbingBackOut(false))
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
var ITEM_NAME$2 = "RovingFocusGroupItem";
|
|
133
|
+
var RovingFocusGroupItem = React.forwardRef(
|
|
134
|
+
(props, forwardedRef) => {
|
|
135
|
+
const {
|
|
136
|
+
__scopeRovingFocusGroup,
|
|
137
|
+
focusable = true,
|
|
138
|
+
active = false,
|
|
139
|
+
tabStopId,
|
|
140
|
+
children,
|
|
141
|
+
...itemProps
|
|
142
|
+
} = props;
|
|
143
|
+
const autoId = useId();
|
|
144
|
+
const id = tabStopId || autoId;
|
|
145
|
+
const context = useRovingFocusContext(ITEM_NAME$2, __scopeRovingFocusGroup);
|
|
146
|
+
const isCurrentTabStop = context.currentTabStopId === id;
|
|
147
|
+
const getItems = useCollection$1(__scopeRovingFocusGroup);
|
|
148
|
+
const { onFocusableItemAdd, onFocusableItemRemove, currentTabStopId } = context;
|
|
149
|
+
React.useEffect(() => {
|
|
150
|
+
if (focusable) {
|
|
151
|
+
onFocusableItemAdd();
|
|
152
|
+
return () => onFocusableItemRemove();
|
|
153
|
+
}
|
|
154
|
+
}, [focusable, onFocusableItemAdd, onFocusableItemRemove]);
|
|
155
|
+
return /* @__PURE__ */ jsx(
|
|
156
|
+
Collection$1.ItemSlot,
|
|
157
|
+
{
|
|
158
|
+
scope: __scopeRovingFocusGroup,
|
|
159
|
+
id,
|
|
160
|
+
focusable,
|
|
161
|
+
active,
|
|
162
|
+
children: /* @__PURE__ */ jsx(
|
|
163
|
+
Primitive.span,
|
|
164
|
+
{
|
|
165
|
+
tabIndex: isCurrentTabStop ? 0 : -1,
|
|
166
|
+
"data-orientation": context.orientation,
|
|
167
|
+
...itemProps,
|
|
168
|
+
ref: forwardedRef,
|
|
169
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
|
|
170
|
+
if (!focusable) event.preventDefault();
|
|
171
|
+
else context.onItemFocus(id);
|
|
172
|
+
}),
|
|
173
|
+
onFocus: composeEventHandlers(props.onFocus, () => context.onItemFocus(id)),
|
|
174
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
175
|
+
if (event.key === "Tab" && event.shiftKey) {
|
|
176
|
+
context.onItemShiftTab();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (event.target !== event.currentTarget) return;
|
|
180
|
+
const focusIntent = getFocusIntent(event, context.orientation, context.dir);
|
|
181
|
+
if (focusIntent !== void 0) {
|
|
182
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
const items = getItems().filter((item) => item.focusable);
|
|
185
|
+
let candidateNodes = items.map((item) => item.ref.current);
|
|
186
|
+
if (focusIntent === "last") candidateNodes.reverse();
|
|
187
|
+
else if (focusIntent === "prev" || focusIntent === "next") {
|
|
188
|
+
if (focusIntent === "prev") candidateNodes.reverse();
|
|
189
|
+
const currentIndex = candidateNodes.indexOf(event.currentTarget);
|
|
190
|
+
candidateNodes = context.loop ? wrapArray$1(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
|
|
191
|
+
}
|
|
192
|
+
setTimeout(() => focusFirst$1(candidateNodes));
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
children: typeof children === "function" ? children({ isCurrentTabStop, hasTabStop: currentTabStopId != null }) : children
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
RovingFocusGroupItem.displayName = ITEM_NAME$2;
|
|
203
|
+
var MAP_KEY_TO_FOCUS_INTENT = {
|
|
204
|
+
ArrowLeft: "prev",
|
|
205
|
+
ArrowUp: "prev",
|
|
206
|
+
ArrowRight: "next",
|
|
207
|
+
ArrowDown: "next",
|
|
208
|
+
PageUp: "first",
|
|
209
|
+
Home: "first",
|
|
210
|
+
PageDown: "last",
|
|
211
|
+
End: "last"
|
|
212
|
+
};
|
|
213
|
+
function getDirectionAwareKey(key, dir) {
|
|
214
|
+
if (dir !== "rtl") return key;
|
|
215
|
+
return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
|
|
216
|
+
}
|
|
217
|
+
function getFocusIntent(event, orientation, dir) {
|
|
218
|
+
const key = getDirectionAwareKey(event.key, dir);
|
|
219
|
+
if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
|
|
220
|
+
if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
|
|
221
|
+
return MAP_KEY_TO_FOCUS_INTENT[key];
|
|
222
|
+
}
|
|
223
|
+
function focusFirst$1(candidates, preventScroll = false) {
|
|
224
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
225
|
+
for (const candidate of candidates) {
|
|
226
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
227
|
+
candidate.focus({ preventScroll });
|
|
228
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function wrapArray$1(array, startIndex) {
|
|
232
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
233
|
+
}
|
|
234
|
+
var Root = RovingFocusGroup;
|
|
235
|
+
var Item = RovingFocusGroupItem;
|
|
236
|
+
|
|
237
|
+
var SELECTION_KEYS = ["Enter", " "];
|
|
238
|
+
var FIRST_KEYS = ["ArrowDown", "PageUp", "Home"];
|
|
239
|
+
var LAST_KEYS = ["ArrowUp", "PageDown", "End"];
|
|
240
|
+
var FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
|
|
241
|
+
var SUB_OPEN_KEYS = {
|
|
242
|
+
ltr: [...SELECTION_KEYS, "ArrowRight"],
|
|
243
|
+
rtl: [...SELECTION_KEYS, "ArrowLeft"]
|
|
244
|
+
};
|
|
245
|
+
var SUB_CLOSE_KEYS = {
|
|
246
|
+
ltr: ["ArrowLeft"],
|
|
247
|
+
rtl: ["ArrowRight"]
|
|
248
|
+
};
|
|
249
|
+
var MENU_NAME = "Menu";
|
|
250
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(MENU_NAME);
|
|
251
|
+
var [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, [
|
|
252
|
+
createCollectionScope,
|
|
253
|
+
createPopperScope,
|
|
254
|
+
createRovingFocusGroupScope
|
|
255
|
+
]);
|
|
256
|
+
var usePopperScope = createPopperScope();
|
|
257
|
+
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
258
|
+
var [MenuProvider, useMenuContext] = createMenuContext(MENU_NAME);
|
|
259
|
+
var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME);
|
|
260
|
+
var Menu = (props) => {
|
|
261
|
+
const { __scopeMenu, open = false, children, dir, onOpenChange, modal = true } = props;
|
|
262
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
263
|
+
const [content, setContent] = React.useState(null);
|
|
264
|
+
const isUsingKeyboardRef = React.useRef(false);
|
|
265
|
+
const handleOpenChange = useCallbackRef(onOpenChange);
|
|
266
|
+
const direction = useDirection(dir);
|
|
267
|
+
React.useEffect(() => {
|
|
268
|
+
const handleKeyDown = () => {
|
|
269
|
+
isUsingKeyboardRef.current = true;
|
|
270
|
+
document.addEventListener("pointerdown", handlePointer, { capture: true, once: true });
|
|
271
|
+
document.addEventListener("pointermove", handlePointer, { capture: true, once: true });
|
|
272
|
+
};
|
|
273
|
+
const handlePointer = () => isUsingKeyboardRef.current = false;
|
|
274
|
+
document.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
275
|
+
return () => {
|
|
276
|
+
document.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
277
|
+
document.removeEventListener("pointerdown", handlePointer, { capture: true });
|
|
278
|
+
document.removeEventListener("pointermove", handlePointer, { capture: true });
|
|
279
|
+
};
|
|
280
|
+
}, []);
|
|
281
|
+
return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
|
|
282
|
+
MenuProvider,
|
|
283
|
+
{
|
|
284
|
+
scope: __scopeMenu,
|
|
285
|
+
open,
|
|
286
|
+
onOpenChange: handleOpenChange,
|
|
287
|
+
content,
|
|
288
|
+
onContentChange: setContent,
|
|
289
|
+
children: /* @__PURE__ */ jsx(
|
|
290
|
+
MenuRootProvider,
|
|
291
|
+
{
|
|
292
|
+
scope: __scopeMenu,
|
|
293
|
+
onClose: React.useCallback(() => handleOpenChange(false), [handleOpenChange]),
|
|
294
|
+
isUsingKeyboardRef,
|
|
295
|
+
dir: direction,
|
|
296
|
+
modal,
|
|
297
|
+
children
|
|
298
|
+
}
|
|
299
|
+
)
|
|
300
|
+
}
|
|
301
|
+
) });
|
|
302
|
+
};
|
|
303
|
+
Menu.displayName = MENU_NAME;
|
|
304
|
+
var ANCHOR_NAME = "MenuAnchor";
|
|
305
|
+
var MenuAnchor = React.forwardRef(
|
|
306
|
+
(props, forwardedRef) => {
|
|
307
|
+
const { __scopeMenu, ...anchorProps } = props;
|
|
308
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
309
|
+
return /* @__PURE__ */ jsx(Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
MenuAnchor.displayName = ANCHOR_NAME;
|
|
313
|
+
var PORTAL_NAME$1 = "MenuPortal";
|
|
314
|
+
var [PortalProvider, usePortalContext] = createMenuContext(PORTAL_NAME$1, {
|
|
315
|
+
forceMount: void 0
|
|
316
|
+
});
|
|
317
|
+
var MenuPortal = (props) => {
|
|
318
|
+
const { __scopeMenu, forceMount, children, container } = props;
|
|
319
|
+
const context = useMenuContext(PORTAL_NAME$1, __scopeMenu);
|
|
320
|
+
return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopeMenu, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Portal$1, { asChild: true, container, children }) }) });
|
|
321
|
+
};
|
|
322
|
+
MenuPortal.displayName = PORTAL_NAME$1;
|
|
323
|
+
var CONTENT_NAME$1 = "MenuContent";
|
|
324
|
+
var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME$1);
|
|
325
|
+
var MenuContent = React.forwardRef(
|
|
326
|
+
(props, forwardedRef) => {
|
|
327
|
+
const portalContext = usePortalContext(CONTENT_NAME$1, props.__scopeMenu);
|
|
328
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
329
|
+
const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
|
|
330
|
+
const rootContext = useMenuRootContext(CONTENT_NAME$1, props.__scopeMenu);
|
|
331
|
+
return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeMenu, children: rootContext.modal ? /* @__PURE__ */ jsx(MenuRootContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(MenuRootContentNonModal, { ...contentProps, ref: forwardedRef }) }) }) });
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
var MenuRootContentModal = React.forwardRef(
|
|
335
|
+
(props, forwardedRef) => {
|
|
336
|
+
const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
|
|
337
|
+
const ref = React.useRef(null);
|
|
338
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
339
|
+
React.useEffect(() => {
|
|
340
|
+
const content = ref.current;
|
|
341
|
+
if (content) return hideOthers(content);
|
|
342
|
+
}, []);
|
|
343
|
+
return /* @__PURE__ */ jsx(
|
|
344
|
+
MenuContentImpl,
|
|
345
|
+
{
|
|
346
|
+
...props,
|
|
347
|
+
ref: composedRefs,
|
|
348
|
+
trapFocus: context.open,
|
|
349
|
+
disableOutsidePointerEvents: context.open,
|
|
350
|
+
disableOutsideScroll: true,
|
|
351
|
+
onFocusOutside: composeEventHandlers(
|
|
352
|
+
props.onFocusOutside,
|
|
353
|
+
(event) => event.preventDefault(),
|
|
354
|
+
{ checkForDefaultPrevented: false }
|
|
355
|
+
),
|
|
356
|
+
onDismiss: () => context.onOpenChange(false)
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
);
|
|
361
|
+
var MenuRootContentNonModal = React.forwardRef((props, forwardedRef) => {
|
|
362
|
+
const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
|
|
363
|
+
return /* @__PURE__ */ jsx(
|
|
364
|
+
MenuContentImpl,
|
|
365
|
+
{
|
|
366
|
+
...props,
|
|
367
|
+
ref: forwardedRef,
|
|
368
|
+
trapFocus: false,
|
|
369
|
+
disableOutsidePointerEvents: false,
|
|
370
|
+
disableOutsideScroll: false,
|
|
371
|
+
onDismiss: () => context.onOpenChange(false)
|
|
372
|
+
}
|
|
373
|
+
);
|
|
374
|
+
});
|
|
375
|
+
var Slot = createSlot("MenuContent.ScrollLock");
|
|
376
|
+
var MenuContentImpl = React.forwardRef(
|
|
377
|
+
(props, forwardedRef) => {
|
|
378
|
+
const {
|
|
379
|
+
__scopeMenu,
|
|
380
|
+
loop = false,
|
|
381
|
+
trapFocus,
|
|
382
|
+
onOpenAutoFocus,
|
|
383
|
+
onCloseAutoFocus,
|
|
384
|
+
disableOutsidePointerEvents,
|
|
385
|
+
onEntryFocus,
|
|
386
|
+
onEscapeKeyDown,
|
|
387
|
+
onPointerDownOutside,
|
|
388
|
+
onFocusOutside,
|
|
389
|
+
onInteractOutside,
|
|
390
|
+
onDismiss,
|
|
391
|
+
disableOutsideScroll,
|
|
392
|
+
...contentProps
|
|
393
|
+
} = props;
|
|
394
|
+
const context = useMenuContext(CONTENT_NAME$1, __scopeMenu);
|
|
395
|
+
const rootContext = useMenuRootContext(CONTENT_NAME$1, __scopeMenu);
|
|
396
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
397
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
398
|
+
const getItems = useCollection(__scopeMenu);
|
|
399
|
+
const [currentItemId, setCurrentItemId] = React.useState(null);
|
|
400
|
+
const contentRef = React.useRef(null);
|
|
401
|
+
const composedRefs = useComposedRefs(forwardedRef, contentRef, context.onContentChange);
|
|
402
|
+
const timerRef = React.useRef(0);
|
|
403
|
+
const searchRef = React.useRef("");
|
|
404
|
+
const pointerGraceTimerRef = React.useRef(0);
|
|
405
|
+
const pointerGraceIntentRef = React.useRef(null);
|
|
406
|
+
const pointerDirRef = React.useRef("right");
|
|
407
|
+
const lastPointerXRef = React.useRef(0);
|
|
408
|
+
const ScrollLockWrapper = disableOutsideScroll ? ReactRemoveScroll : React.Fragment;
|
|
409
|
+
const scrollLockWrapperProps = disableOutsideScroll ? { as: Slot, allowPinchZoom: true } : void 0;
|
|
410
|
+
const handleTypeaheadSearch = (key) => {
|
|
411
|
+
const search = searchRef.current + key;
|
|
412
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
413
|
+
const currentItem = document.activeElement;
|
|
414
|
+
const currentMatch = items.find((item) => item.ref.current === currentItem)?.textValue;
|
|
415
|
+
const values = items.map((item) => item.textValue);
|
|
416
|
+
const nextMatch = getNextMatch(values, search, currentMatch);
|
|
417
|
+
const newItem = items.find((item) => item.textValue === nextMatch)?.ref.current;
|
|
418
|
+
(function updateSearch(value) {
|
|
419
|
+
searchRef.current = value;
|
|
420
|
+
window.clearTimeout(timerRef.current);
|
|
421
|
+
if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
|
|
422
|
+
})(search);
|
|
423
|
+
if (newItem) {
|
|
424
|
+
setTimeout(() => newItem.focus());
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
React.useEffect(() => {
|
|
428
|
+
return () => window.clearTimeout(timerRef.current);
|
|
429
|
+
}, []);
|
|
430
|
+
useFocusGuards();
|
|
431
|
+
const isPointerMovingToSubmenu = React.useCallback((event) => {
|
|
432
|
+
const isMovingTowards = pointerDirRef.current === pointerGraceIntentRef.current?.side;
|
|
433
|
+
return isMovingTowards && isPointerInGraceArea(event, pointerGraceIntentRef.current?.area);
|
|
434
|
+
}, []);
|
|
435
|
+
return /* @__PURE__ */ jsx(
|
|
436
|
+
MenuContentProvider,
|
|
437
|
+
{
|
|
438
|
+
scope: __scopeMenu,
|
|
439
|
+
searchRef,
|
|
440
|
+
onItemEnter: React.useCallback(
|
|
441
|
+
(event) => {
|
|
442
|
+
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
443
|
+
},
|
|
444
|
+
[isPointerMovingToSubmenu]
|
|
445
|
+
),
|
|
446
|
+
onItemLeave: React.useCallback(
|
|
447
|
+
(event) => {
|
|
448
|
+
if (isPointerMovingToSubmenu(event)) return;
|
|
449
|
+
contentRef.current?.focus();
|
|
450
|
+
setCurrentItemId(null);
|
|
451
|
+
},
|
|
452
|
+
[isPointerMovingToSubmenu]
|
|
453
|
+
),
|
|
454
|
+
onTriggerLeave: React.useCallback(
|
|
455
|
+
(event) => {
|
|
456
|
+
if (isPointerMovingToSubmenu(event)) event.preventDefault();
|
|
457
|
+
},
|
|
458
|
+
[isPointerMovingToSubmenu]
|
|
459
|
+
),
|
|
460
|
+
pointerGraceTimerRef,
|
|
461
|
+
onPointerGraceIntentChange: React.useCallback((intent) => {
|
|
462
|
+
pointerGraceIntentRef.current = intent;
|
|
463
|
+
}, []),
|
|
464
|
+
children: /* @__PURE__ */ jsx(ScrollLockWrapper, { ...scrollLockWrapperProps, children: /* @__PURE__ */ jsx(
|
|
465
|
+
FocusScope,
|
|
466
|
+
{
|
|
467
|
+
asChild: true,
|
|
468
|
+
trapped: trapFocus,
|
|
469
|
+
onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, (event) => {
|
|
470
|
+
event.preventDefault();
|
|
471
|
+
contentRef.current?.focus({ preventScroll: true });
|
|
472
|
+
}),
|
|
473
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
474
|
+
children: /* @__PURE__ */ jsx(
|
|
475
|
+
DismissableLayer,
|
|
476
|
+
{
|
|
477
|
+
asChild: true,
|
|
478
|
+
disableOutsidePointerEvents,
|
|
479
|
+
onEscapeKeyDown,
|
|
480
|
+
onPointerDownOutside,
|
|
481
|
+
onFocusOutside,
|
|
482
|
+
onInteractOutside,
|
|
483
|
+
onDismiss,
|
|
484
|
+
children: /* @__PURE__ */ jsx(
|
|
485
|
+
Root,
|
|
486
|
+
{
|
|
487
|
+
asChild: true,
|
|
488
|
+
...rovingFocusGroupScope,
|
|
489
|
+
dir: rootContext.dir,
|
|
490
|
+
orientation: "vertical",
|
|
491
|
+
loop,
|
|
492
|
+
currentTabStopId: currentItemId,
|
|
493
|
+
onCurrentTabStopIdChange: setCurrentItemId,
|
|
494
|
+
onEntryFocus: composeEventHandlers(onEntryFocus, (event) => {
|
|
495
|
+
if (!rootContext.isUsingKeyboardRef.current) event.preventDefault();
|
|
496
|
+
}),
|
|
497
|
+
preventScrollOnEntryFocus: true,
|
|
498
|
+
children: /* @__PURE__ */ jsx(
|
|
499
|
+
Content,
|
|
500
|
+
{
|
|
501
|
+
role: "menu",
|
|
502
|
+
"aria-orientation": "vertical",
|
|
503
|
+
"data-state": getOpenState(context.open),
|
|
504
|
+
"data-radix-menu-content": "",
|
|
505
|
+
dir: rootContext.dir,
|
|
506
|
+
...popperScope,
|
|
507
|
+
...contentProps,
|
|
508
|
+
ref: composedRefs,
|
|
509
|
+
style: { outline: "none", ...contentProps.style },
|
|
510
|
+
onKeyDown: composeEventHandlers(contentProps.onKeyDown, (event) => {
|
|
511
|
+
const target = event.target;
|
|
512
|
+
const isKeyDownInside = target.closest("[data-radix-menu-content]") === event.currentTarget;
|
|
513
|
+
const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
|
|
514
|
+
const isCharacterKey = event.key.length === 1;
|
|
515
|
+
if (isKeyDownInside) {
|
|
516
|
+
if (event.key === "Tab") event.preventDefault();
|
|
517
|
+
if (!isModifierKey && isCharacterKey) handleTypeaheadSearch(event.key);
|
|
518
|
+
}
|
|
519
|
+
const content = contentRef.current;
|
|
520
|
+
if (event.target !== content) return;
|
|
521
|
+
if (!FIRST_LAST_KEYS.includes(event.key)) return;
|
|
522
|
+
event.preventDefault();
|
|
523
|
+
const items = getItems().filter((item) => !item.disabled);
|
|
524
|
+
const candidateNodes = items.map((item) => item.ref.current);
|
|
525
|
+
if (LAST_KEYS.includes(event.key)) candidateNodes.reverse();
|
|
526
|
+
focusFirst(candidateNodes);
|
|
527
|
+
}),
|
|
528
|
+
onBlur: composeEventHandlers(props.onBlur, (event) => {
|
|
529
|
+
if (!event.currentTarget.contains(event.target)) {
|
|
530
|
+
window.clearTimeout(timerRef.current);
|
|
531
|
+
searchRef.current = "";
|
|
532
|
+
}
|
|
533
|
+
}),
|
|
534
|
+
onPointerMove: composeEventHandlers(
|
|
535
|
+
props.onPointerMove,
|
|
536
|
+
whenMouse((event) => {
|
|
537
|
+
const target = event.target;
|
|
538
|
+
const pointerXHasChanged = lastPointerXRef.current !== event.clientX;
|
|
539
|
+
if (event.currentTarget.contains(target) && pointerXHasChanged) {
|
|
540
|
+
const newDir = event.clientX > lastPointerXRef.current ? "right" : "left";
|
|
541
|
+
pointerDirRef.current = newDir;
|
|
542
|
+
lastPointerXRef.current = event.clientX;
|
|
543
|
+
}
|
|
544
|
+
})
|
|
545
|
+
)
|
|
546
|
+
}
|
|
547
|
+
)
|
|
548
|
+
}
|
|
549
|
+
)
|
|
550
|
+
}
|
|
551
|
+
)
|
|
552
|
+
}
|
|
553
|
+
) })
|
|
554
|
+
}
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
MenuContent.displayName = CONTENT_NAME$1;
|
|
559
|
+
var GROUP_NAME$1 = "MenuGroup";
|
|
560
|
+
var MenuGroup = React.forwardRef(
|
|
561
|
+
(props, forwardedRef) => {
|
|
562
|
+
const { __scopeMenu, ...groupProps } = props;
|
|
563
|
+
return /* @__PURE__ */ jsx(Primitive.div, { role: "group", ...groupProps, ref: forwardedRef });
|
|
564
|
+
}
|
|
565
|
+
);
|
|
566
|
+
MenuGroup.displayName = GROUP_NAME$1;
|
|
567
|
+
var LABEL_NAME$1 = "MenuLabel";
|
|
568
|
+
var MenuLabel = React.forwardRef(
|
|
569
|
+
(props, forwardedRef) => {
|
|
570
|
+
const { __scopeMenu, ...labelProps } = props;
|
|
571
|
+
return /* @__PURE__ */ jsx(Primitive.div, { ...labelProps, ref: forwardedRef });
|
|
572
|
+
}
|
|
573
|
+
);
|
|
574
|
+
MenuLabel.displayName = LABEL_NAME$1;
|
|
575
|
+
var ITEM_NAME$1 = "MenuItem";
|
|
576
|
+
var ITEM_SELECT = "menu.itemSelect";
|
|
577
|
+
var MenuItem = React.forwardRef(
|
|
578
|
+
(props, forwardedRef) => {
|
|
579
|
+
const { disabled = false, onSelect, ...itemProps } = props;
|
|
580
|
+
const ref = React.useRef(null);
|
|
581
|
+
const rootContext = useMenuRootContext(ITEM_NAME$1, props.__scopeMenu);
|
|
582
|
+
const contentContext = useMenuContentContext(ITEM_NAME$1, props.__scopeMenu);
|
|
583
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
584
|
+
const isPointerDownRef = React.useRef(false);
|
|
585
|
+
const handleSelect = () => {
|
|
586
|
+
const menuItem = ref.current;
|
|
587
|
+
if (!disabled && menuItem) {
|
|
588
|
+
const itemSelectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true });
|
|
589
|
+
menuItem.addEventListener(ITEM_SELECT, (event) => onSelect?.(event), { once: true });
|
|
590
|
+
dispatchDiscreteCustomEvent(menuItem, itemSelectEvent);
|
|
591
|
+
if (itemSelectEvent.defaultPrevented) {
|
|
592
|
+
isPointerDownRef.current = false;
|
|
593
|
+
} else {
|
|
594
|
+
rootContext.onClose();
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
return /* @__PURE__ */ jsx(
|
|
599
|
+
MenuItemImpl,
|
|
600
|
+
{
|
|
601
|
+
...itemProps,
|
|
602
|
+
ref: composedRefs,
|
|
603
|
+
disabled,
|
|
604
|
+
onClick: composeEventHandlers(props.onClick, handleSelect),
|
|
605
|
+
onPointerDown: (event) => {
|
|
606
|
+
props.onPointerDown?.(event);
|
|
607
|
+
isPointerDownRef.current = true;
|
|
608
|
+
},
|
|
609
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
|
|
610
|
+
if (!isPointerDownRef.current) event.currentTarget?.click();
|
|
611
|
+
}),
|
|
612
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
613
|
+
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
614
|
+
if (disabled || isTypingAhead && event.key === " ") return;
|
|
615
|
+
if (SELECTION_KEYS.includes(event.key)) {
|
|
616
|
+
event.currentTarget.click();
|
|
617
|
+
event.preventDefault();
|
|
618
|
+
}
|
|
619
|
+
})
|
|
620
|
+
}
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
);
|
|
624
|
+
MenuItem.displayName = ITEM_NAME$1;
|
|
625
|
+
var MenuItemImpl = React.forwardRef(
|
|
626
|
+
(props, forwardedRef) => {
|
|
627
|
+
const { __scopeMenu, disabled = false, textValue, ...itemProps } = props;
|
|
628
|
+
const contentContext = useMenuContentContext(ITEM_NAME$1, __scopeMenu);
|
|
629
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
|
|
630
|
+
const ref = React.useRef(null);
|
|
631
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
632
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
633
|
+
const [textContent, setTextContent] = React.useState("");
|
|
634
|
+
React.useEffect(() => {
|
|
635
|
+
const menuItem = ref.current;
|
|
636
|
+
if (menuItem) {
|
|
637
|
+
setTextContent((menuItem.textContent ?? "").trim());
|
|
638
|
+
}
|
|
639
|
+
}, [itemProps.children]);
|
|
640
|
+
return /* @__PURE__ */ jsx(
|
|
641
|
+
Collection.ItemSlot,
|
|
642
|
+
{
|
|
643
|
+
scope: __scopeMenu,
|
|
644
|
+
disabled,
|
|
645
|
+
textValue: textValue ?? textContent,
|
|
646
|
+
children: /* @__PURE__ */ jsx(Item, { asChild: true, ...rovingFocusGroupScope, focusable: !disabled, children: /* @__PURE__ */ jsx(
|
|
647
|
+
Primitive.div,
|
|
648
|
+
{
|
|
649
|
+
role: "menuitem",
|
|
650
|
+
"data-highlighted": isFocused ? "" : void 0,
|
|
651
|
+
"aria-disabled": disabled || void 0,
|
|
652
|
+
"data-disabled": disabled ? "" : void 0,
|
|
653
|
+
...itemProps,
|
|
654
|
+
ref: composedRefs,
|
|
655
|
+
onPointerMove: composeEventHandlers(
|
|
656
|
+
props.onPointerMove,
|
|
657
|
+
whenMouse((event) => {
|
|
658
|
+
if (disabled) {
|
|
659
|
+
contentContext.onItemLeave(event);
|
|
660
|
+
} else {
|
|
661
|
+
contentContext.onItemEnter(event);
|
|
662
|
+
if (!event.defaultPrevented) {
|
|
663
|
+
const item = event.currentTarget;
|
|
664
|
+
item.focus({ preventScroll: true });
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
})
|
|
668
|
+
),
|
|
669
|
+
onPointerLeave: composeEventHandlers(
|
|
670
|
+
props.onPointerLeave,
|
|
671
|
+
whenMouse((event) => contentContext.onItemLeave(event))
|
|
672
|
+
),
|
|
673
|
+
onFocus: composeEventHandlers(props.onFocus, () => setIsFocused(true)),
|
|
674
|
+
onBlur: composeEventHandlers(props.onBlur, () => setIsFocused(false))
|
|
675
|
+
}
|
|
676
|
+
) })
|
|
677
|
+
}
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
var CHECKBOX_ITEM_NAME$1 = "MenuCheckboxItem";
|
|
682
|
+
var MenuCheckboxItem = React.forwardRef(
|
|
683
|
+
(props, forwardedRef) => {
|
|
684
|
+
const { checked = false, onCheckedChange, ...checkboxItemProps } = props;
|
|
685
|
+
return /* @__PURE__ */ jsx(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ jsx(
|
|
686
|
+
MenuItem,
|
|
687
|
+
{
|
|
688
|
+
role: "menuitemcheckbox",
|
|
689
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
690
|
+
...checkboxItemProps,
|
|
691
|
+
ref: forwardedRef,
|
|
692
|
+
"data-state": getCheckedState(checked),
|
|
693
|
+
onSelect: composeEventHandlers(
|
|
694
|
+
checkboxItemProps.onSelect,
|
|
695
|
+
() => onCheckedChange?.(isIndeterminate(checked) ? true : !checked),
|
|
696
|
+
{ checkForDefaultPrevented: false }
|
|
697
|
+
)
|
|
698
|
+
}
|
|
699
|
+
) });
|
|
700
|
+
}
|
|
701
|
+
);
|
|
702
|
+
MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME$1;
|
|
703
|
+
var RADIO_GROUP_NAME$1 = "MenuRadioGroup";
|
|
704
|
+
var [RadioGroupProvider, useRadioGroupContext] = createMenuContext(
|
|
705
|
+
RADIO_GROUP_NAME$1,
|
|
706
|
+
{ value: void 0, onValueChange: () => {
|
|
707
|
+
} }
|
|
708
|
+
);
|
|
709
|
+
var MenuRadioGroup = React.forwardRef(
|
|
710
|
+
(props, forwardedRef) => {
|
|
711
|
+
const { value, onValueChange, ...groupProps } = props;
|
|
712
|
+
const handleValueChange = useCallbackRef(onValueChange);
|
|
713
|
+
return /* @__PURE__ */ jsx(RadioGroupProvider, { scope: props.__scopeMenu, value, onValueChange: handleValueChange, children: /* @__PURE__ */ jsx(MenuGroup, { ...groupProps, ref: forwardedRef }) });
|
|
714
|
+
}
|
|
715
|
+
);
|
|
716
|
+
MenuRadioGroup.displayName = RADIO_GROUP_NAME$1;
|
|
717
|
+
var RADIO_ITEM_NAME$1 = "MenuRadioItem";
|
|
718
|
+
var MenuRadioItem = React.forwardRef(
|
|
719
|
+
(props, forwardedRef) => {
|
|
720
|
+
const { value, ...radioItemProps } = props;
|
|
721
|
+
const context = useRadioGroupContext(RADIO_ITEM_NAME$1, props.__scopeMenu);
|
|
722
|
+
const checked = value === context.value;
|
|
723
|
+
return /* @__PURE__ */ jsx(ItemIndicatorProvider, { scope: props.__scopeMenu, checked, children: /* @__PURE__ */ jsx(
|
|
724
|
+
MenuItem,
|
|
725
|
+
{
|
|
726
|
+
role: "menuitemradio",
|
|
727
|
+
"aria-checked": checked,
|
|
728
|
+
...radioItemProps,
|
|
729
|
+
ref: forwardedRef,
|
|
730
|
+
"data-state": getCheckedState(checked),
|
|
731
|
+
onSelect: composeEventHandlers(
|
|
732
|
+
radioItemProps.onSelect,
|
|
733
|
+
() => context.onValueChange?.(value),
|
|
734
|
+
{ checkForDefaultPrevented: false }
|
|
735
|
+
)
|
|
736
|
+
}
|
|
737
|
+
) });
|
|
738
|
+
}
|
|
739
|
+
);
|
|
740
|
+
MenuRadioItem.displayName = RADIO_ITEM_NAME$1;
|
|
741
|
+
var ITEM_INDICATOR_NAME = "MenuItemIndicator";
|
|
742
|
+
var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(
|
|
743
|
+
ITEM_INDICATOR_NAME,
|
|
744
|
+
{ checked: false }
|
|
745
|
+
);
|
|
746
|
+
var MenuItemIndicator = React.forwardRef(
|
|
747
|
+
(props, forwardedRef) => {
|
|
748
|
+
const { __scopeMenu, forceMount, ...itemIndicatorProps } = props;
|
|
749
|
+
const indicatorContext = useItemIndicatorContext(ITEM_INDICATOR_NAME, __scopeMenu);
|
|
750
|
+
return /* @__PURE__ */ jsx(
|
|
751
|
+
Presence,
|
|
752
|
+
{
|
|
753
|
+
present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true,
|
|
754
|
+
children: /* @__PURE__ */ jsx(
|
|
755
|
+
Primitive.span,
|
|
756
|
+
{
|
|
757
|
+
...itemIndicatorProps,
|
|
758
|
+
ref: forwardedRef,
|
|
759
|
+
"data-state": getCheckedState(indicatorContext.checked)
|
|
760
|
+
}
|
|
761
|
+
)
|
|
762
|
+
}
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
);
|
|
766
|
+
MenuItemIndicator.displayName = ITEM_INDICATOR_NAME;
|
|
767
|
+
var SEPARATOR_NAME$1 = "MenuSeparator";
|
|
768
|
+
var MenuSeparator = React.forwardRef(
|
|
769
|
+
(props, forwardedRef) => {
|
|
770
|
+
const { __scopeMenu, ...separatorProps } = props;
|
|
771
|
+
return /* @__PURE__ */ jsx(
|
|
772
|
+
Primitive.div,
|
|
773
|
+
{
|
|
774
|
+
role: "separator",
|
|
775
|
+
"aria-orientation": "horizontal",
|
|
776
|
+
...separatorProps,
|
|
777
|
+
ref: forwardedRef
|
|
778
|
+
}
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
);
|
|
782
|
+
MenuSeparator.displayName = SEPARATOR_NAME$1;
|
|
783
|
+
var ARROW_NAME$1 = "MenuArrow";
|
|
784
|
+
var MenuArrow = React.forwardRef(
|
|
785
|
+
(props, forwardedRef) => {
|
|
786
|
+
const { __scopeMenu, ...arrowProps } = props;
|
|
787
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
788
|
+
return /* @__PURE__ */ jsx(Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
789
|
+
}
|
|
790
|
+
);
|
|
791
|
+
MenuArrow.displayName = ARROW_NAME$1;
|
|
792
|
+
var SUB_NAME = "MenuSub";
|
|
793
|
+
var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
|
|
794
|
+
var MenuSub = (props) => {
|
|
795
|
+
const { __scopeMenu, children, open = false, onOpenChange } = props;
|
|
796
|
+
const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
|
|
797
|
+
const popperScope = usePopperScope(__scopeMenu);
|
|
798
|
+
const [trigger, setTrigger] = React.useState(null);
|
|
799
|
+
const [content, setContent] = React.useState(null);
|
|
800
|
+
const handleOpenChange = useCallbackRef(onOpenChange);
|
|
801
|
+
React.useEffect(() => {
|
|
802
|
+
if (parentMenuContext.open === false) handleOpenChange(false);
|
|
803
|
+
return () => handleOpenChange(false);
|
|
804
|
+
}, [parentMenuContext.open, handleOpenChange]);
|
|
805
|
+
return /* @__PURE__ */ jsx(Root2$1, { ...popperScope, children: /* @__PURE__ */ jsx(
|
|
806
|
+
MenuProvider,
|
|
807
|
+
{
|
|
808
|
+
scope: __scopeMenu,
|
|
809
|
+
open,
|
|
810
|
+
onOpenChange: handleOpenChange,
|
|
811
|
+
content,
|
|
812
|
+
onContentChange: setContent,
|
|
813
|
+
children: /* @__PURE__ */ jsx(
|
|
814
|
+
MenuSubProvider,
|
|
815
|
+
{
|
|
816
|
+
scope: __scopeMenu,
|
|
817
|
+
contentId: useId(),
|
|
818
|
+
triggerId: useId(),
|
|
819
|
+
trigger,
|
|
820
|
+
onTriggerChange: setTrigger,
|
|
821
|
+
children
|
|
822
|
+
}
|
|
823
|
+
)
|
|
824
|
+
}
|
|
825
|
+
) });
|
|
826
|
+
};
|
|
827
|
+
MenuSub.displayName = SUB_NAME;
|
|
828
|
+
var SUB_TRIGGER_NAME$1 = "MenuSubTrigger";
|
|
829
|
+
var MenuSubTrigger = React.forwardRef(
|
|
830
|
+
(props, forwardedRef) => {
|
|
831
|
+
const context = useMenuContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
|
|
832
|
+
const rootContext = useMenuRootContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
|
|
833
|
+
const subContext = useMenuSubContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
|
|
834
|
+
const contentContext = useMenuContentContext(SUB_TRIGGER_NAME$1, props.__scopeMenu);
|
|
835
|
+
const openTimerRef = React.useRef(null);
|
|
836
|
+
const { pointerGraceTimerRef, onPointerGraceIntentChange } = contentContext;
|
|
837
|
+
const scope = { __scopeMenu: props.__scopeMenu };
|
|
838
|
+
const clearOpenTimer = React.useCallback(() => {
|
|
839
|
+
if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
|
|
840
|
+
openTimerRef.current = null;
|
|
841
|
+
}, []);
|
|
842
|
+
React.useEffect(() => clearOpenTimer, [clearOpenTimer]);
|
|
843
|
+
React.useEffect(() => {
|
|
844
|
+
const pointerGraceTimer = pointerGraceTimerRef.current;
|
|
845
|
+
return () => {
|
|
846
|
+
window.clearTimeout(pointerGraceTimer);
|
|
847
|
+
onPointerGraceIntentChange(null);
|
|
848
|
+
};
|
|
849
|
+
}, [pointerGraceTimerRef, onPointerGraceIntentChange]);
|
|
850
|
+
return /* @__PURE__ */ jsx(MenuAnchor, { asChild: true, ...scope, children: /* @__PURE__ */ jsx(
|
|
851
|
+
MenuItemImpl,
|
|
852
|
+
{
|
|
853
|
+
id: subContext.triggerId,
|
|
854
|
+
"aria-haspopup": "menu",
|
|
855
|
+
"aria-expanded": context.open,
|
|
856
|
+
"aria-controls": subContext.contentId,
|
|
857
|
+
"data-state": getOpenState(context.open),
|
|
858
|
+
...props,
|
|
859
|
+
ref: composeRefs(forwardedRef, subContext.onTriggerChange),
|
|
860
|
+
onClick: (event) => {
|
|
861
|
+
props.onClick?.(event);
|
|
862
|
+
if (props.disabled || event.defaultPrevented) return;
|
|
863
|
+
event.currentTarget.focus();
|
|
864
|
+
if (!context.open) context.onOpenChange(true);
|
|
865
|
+
},
|
|
866
|
+
onPointerMove: composeEventHandlers(
|
|
867
|
+
props.onPointerMove,
|
|
868
|
+
whenMouse((event) => {
|
|
869
|
+
contentContext.onItemEnter(event);
|
|
870
|
+
if (event.defaultPrevented) return;
|
|
871
|
+
if (!props.disabled && !context.open && !openTimerRef.current) {
|
|
872
|
+
contentContext.onPointerGraceIntentChange(null);
|
|
873
|
+
openTimerRef.current = window.setTimeout(() => {
|
|
874
|
+
context.onOpenChange(true);
|
|
875
|
+
clearOpenTimer();
|
|
876
|
+
}, 100);
|
|
877
|
+
}
|
|
878
|
+
})
|
|
879
|
+
),
|
|
880
|
+
onPointerLeave: composeEventHandlers(
|
|
881
|
+
props.onPointerLeave,
|
|
882
|
+
whenMouse((event) => {
|
|
883
|
+
clearOpenTimer();
|
|
884
|
+
const contentRect = context.content?.getBoundingClientRect();
|
|
885
|
+
if (contentRect) {
|
|
886
|
+
const side = context.content?.dataset.side;
|
|
887
|
+
const rightSide = side === "right";
|
|
888
|
+
const bleed = rightSide ? -5 : 5;
|
|
889
|
+
const contentNearEdge = contentRect[rightSide ? "left" : "right"];
|
|
890
|
+
const contentFarEdge = contentRect[rightSide ? "right" : "left"];
|
|
891
|
+
contentContext.onPointerGraceIntentChange({
|
|
892
|
+
area: [
|
|
893
|
+
// Apply a bleed on clientX to ensure that our exit point is
|
|
894
|
+
// consistently within polygon bounds
|
|
895
|
+
{ x: event.clientX + bleed, y: event.clientY },
|
|
896
|
+
{ x: contentNearEdge, y: contentRect.top },
|
|
897
|
+
{ x: contentFarEdge, y: contentRect.top },
|
|
898
|
+
{ x: contentFarEdge, y: contentRect.bottom },
|
|
899
|
+
{ x: contentNearEdge, y: contentRect.bottom }
|
|
900
|
+
],
|
|
901
|
+
side
|
|
902
|
+
});
|
|
903
|
+
window.clearTimeout(pointerGraceTimerRef.current);
|
|
904
|
+
pointerGraceTimerRef.current = window.setTimeout(
|
|
905
|
+
() => contentContext.onPointerGraceIntentChange(null),
|
|
906
|
+
300
|
|
907
|
+
);
|
|
908
|
+
} else {
|
|
909
|
+
contentContext.onTriggerLeave(event);
|
|
910
|
+
if (event.defaultPrevented) return;
|
|
911
|
+
contentContext.onPointerGraceIntentChange(null);
|
|
912
|
+
}
|
|
913
|
+
})
|
|
914
|
+
),
|
|
915
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
916
|
+
const isTypingAhead = contentContext.searchRef.current !== "";
|
|
917
|
+
if (props.disabled || isTypingAhead && event.key === " ") return;
|
|
918
|
+
if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) {
|
|
919
|
+
context.onOpenChange(true);
|
|
920
|
+
context.content?.focus();
|
|
921
|
+
event.preventDefault();
|
|
922
|
+
}
|
|
923
|
+
})
|
|
924
|
+
}
|
|
925
|
+
) });
|
|
926
|
+
}
|
|
927
|
+
);
|
|
928
|
+
MenuSubTrigger.displayName = SUB_TRIGGER_NAME$1;
|
|
929
|
+
var SUB_CONTENT_NAME$1 = "MenuSubContent";
|
|
930
|
+
var MenuSubContent = React.forwardRef(
|
|
931
|
+
(props, forwardedRef) => {
|
|
932
|
+
const portalContext = usePortalContext(CONTENT_NAME$1, props.__scopeMenu);
|
|
933
|
+
const { forceMount = portalContext.forceMount, ...subContentProps } = props;
|
|
934
|
+
const context = useMenuContext(CONTENT_NAME$1, props.__scopeMenu);
|
|
935
|
+
const rootContext = useMenuRootContext(CONTENT_NAME$1, props.__scopeMenu);
|
|
936
|
+
const subContext = useMenuSubContext(SUB_CONTENT_NAME$1, props.__scopeMenu);
|
|
937
|
+
const ref = React.useRef(null);
|
|
938
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
939
|
+
return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeMenu, children: /* @__PURE__ */ jsx(
|
|
940
|
+
MenuContentImpl,
|
|
941
|
+
{
|
|
942
|
+
id: subContext.contentId,
|
|
943
|
+
"aria-labelledby": subContext.triggerId,
|
|
944
|
+
...subContentProps,
|
|
945
|
+
ref: composedRefs,
|
|
946
|
+
align: "start",
|
|
947
|
+
side: rootContext.dir === "rtl" ? "left" : "right",
|
|
948
|
+
disableOutsidePointerEvents: false,
|
|
949
|
+
disableOutsideScroll: false,
|
|
950
|
+
trapFocus: false,
|
|
951
|
+
onOpenAutoFocus: (event) => {
|
|
952
|
+
if (rootContext.isUsingKeyboardRef.current) ref.current?.focus();
|
|
953
|
+
event.preventDefault();
|
|
954
|
+
},
|
|
955
|
+
onCloseAutoFocus: (event) => event.preventDefault(),
|
|
956
|
+
onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => {
|
|
957
|
+
if (event.target !== subContext.trigger) context.onOpenChange(false);
|
|
958
|
+
}),
|
|
959
|
+
onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, (event) => {
|
|
960
|
+
rootContext.onClose();
|
|
961
|
+
event.preventDefault();
|
|
962
|
+
}),
|
|
963
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
964
|
+
const isKeyDownInside = event.currentTarget.contains(event.target);
|
|
965
|
+
const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key);
|
|
966
|
+
if (isKeyDownInside && isCloseKey) {
|
|
967
|
+
context.onOpenChange(false);
|
|
968
|
+
subContext.trigger?.focus();
|
|
969
|
+
event.preventDefault();
|
|
970
|
+
}
|
|
971
|
+
})
|
|
972
|
+
}
|
|
973
|
+
) }) }) });
|
|
974
|
+
}
|
|
975
|
+
);
|
|
976
|
+
MenuSubContent.displayName = SUB_CONTENT_NAME$1;
|
|
977
|
+
function getOpenState(open) {
|
|
978
|
+
return open ? "open" : "closed";
|
|
979
|
+
}
|
|
980
|
+
function isIndeterminate(checked) {
|
|
981
|
+
return checked === "indeterminate";
|
|
982
|
+
}
|
|
983
|
+
function getCheckedState(checked) {
|
|
984
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
985
|
+
}
|
|
986
|
+
function focusFirst(candidates) {
|
|
987
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
988
|
+
for (const candidate of candidates) {
|
|
989
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
990
|
+
candidate.focus();
|
|
991
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
function wrapArray(array, startIndex) {
|
|
995
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
996
|
+
}
|
|
997
|
+
function getNextMatch(values, search, currentMatch) {
|
|
998
|
+
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
|
|
999
|
+
const normalizedSearch = isRepeated ? search[0] : search;
|
|
1000
|
+
const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
|
|
1001
|
+
let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
|
|
1002
|
+
const excludeCurrentMatch = normalizedSearch.length === 1;
|
|
1003
|
+
if (excludeCurrentMatch) wrappedValues = wrappedValues.filter((v) => v !== currentMatch);
|
|
1004
|
+
const nextMatch = wrappedValues.find(
|
|
1005
|
+
(value) => value.toLowerCase().startsWith(normalizedSearch.toLowerCase())
|
|
1006
|
+
);
|
|
1007
|
+
return nextMatch !== currentMatch ? nextMatch : void 0;
|
|
1008
|
+
}
|
|
1009
|
+
function isPointInPolygon(point, polygon) {
|
|
1010
|
+
const { x, y } = point;
|
|
1011
|
+
let inside = false;
|
|
1012
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
1013
|
+
const ii = polygon[i];
|
|
1014
|
+
const jj = polygon[j];
|
|
1015
|
+
const xi = ii.x;
|
|
1016
|
+
const yi = ii.y;
|
|
1017
|
+
const xj = jj.x;
|
|
1018
|
+
const yj = jj.y;
|
|
1019
|
+
const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
|
|
1020
|
+
if (intersect) inside = !inside;
|
|
1021
|
+
}
|
|
1022
|
+
return inside;
|
|
1023
|
+
}
|
|
1024
|
+
function isPointerInGraceArea(event, area) {
|
|
1025
|
+
if (!area) return false;
|
|
1026
|
+
const cursorPos = { x: event.clientX, y: event.clientY };
|
|
1027
|
+
return isPointInPolygon(cursorPos, area);
|
|
1028
|
+
}
|
|
1029
|
+
function whenMouse(handler) {
|
|
1030
|
+
return (event) => event.pointerType === "mouse" ? handler(event) : void 0;
|
|
1031
|
+
}
|
|
1032
|
+
var Root3 = Menu;
|
|
1033
|
+
var Anchor2 = MenuAnchor;
|
|
1034
|
+
var Portal = MenuPortal;
|
|
1035
|
+
var Content2$1 = MenuContent;
|
|
1036
|
+
var Group = MenuGroup;
|
|
1037
|
+
var Label = MenuLabel;
|
|
1038
|
+
var Item2$1 = MenuItem;
|
|
1039
|
+
var CheckboxItem = MenuCheckboxItem;
|
|
1040
|
+
var RadioGroup = MenuRadioGroup;
|
|
1041
|
+
var RadioItem = MenuRadioItem;
|
|
1042
|
+
var ItemIndicator = MenuItemIndicator;
|
|
1043
|
+
var Separator = MenuSeparator;
|
|
1044
|
+
var Arrow2 = MenuArrow;
|
|
1045
|
+
var Sub = MenuSub;
|
|
1046
|
+
var SubTrigger = MenuSubTrigger;
|
|
1047
|
+
var SubContent = MenuSubContent;
|
|
1048
|
+
|
|
1049
|
+
var DROPDOWN_MENU_NAME = "DropdownMenu";
|
|
1050
|
+
var [createDropdownMenuContext] = createContextScope(
|
|
1051
|
+
DROPDOWN_MENU_NAME,
|
|
1052
|
+
[createMenuScope]
|
|
1053
|
+
);
|
|
1054
|
+
var useMenuScope = createMenuScope();
|
|
1055
|
+
var [DropdownMenuProvider, useDropdownMenuContext] = createDropdownMenuContext(DROPDOWN_MENU_NAME);
|
|
1056
|
+
var DropdownMenu$2 = (props) => {
|
|
1057
|
+
const {
|
|
1058
|
+
__scopeDropdownMenu,
|
|
1059
|
+
children,
|
|
1060
|
+
dir,
|
|
1061
|
+
open: openProp,
|
|
1062
|
+
defaultOpen,
|
|
1063
|
+
onOpenChange,
|
|
1064
|
+
modal = true
|
|
1065
|
+
} = props;
|
|
1066
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1067
|
+
const triggerRef = React.useRef(null);
|
|
1068
|
+
const [open, setOpen] = useControllableState({
|
|
1069
|
+
prop: openProp,
|
|
1070
|
+
defaultProp: defaultOpen ?? false,
|
|
1071
|
+
onChange: onOpenChange,
|
|
1072
|
+
caller: DROPDOWN_MENU_NAME
|
|
1073
|
+
});
|
|
1074
|
+
return /* @__PURE__ */ jsx(
|
|
1075
|
+
DropdownMenuProvider,
|
|
1076
|
+
{
|
|
1077
|
+
scope: __scopeDropdownMenu,
|
|
1078
|
+
triggerId: useId(),
|
|
1079
|
+
triggerRef,
|
|
1080
|
+
contentId: useId(),
|
|
1081
|
+
open,
|
|
1082
|
+
onOpenChange: setOpen,
|
|
1083
|
+
onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
1084
|
+
modal,
|
|
1085
|
+
children: /* @__PURE__ */ jsx(Root3, { ...menuScope, open, onOpenChange: setOpen, dir, modal, children })
|
|
1086
|
+
}
|
|
1087
|
+
);
|
|
1088
|
+
};
|
|
1089
|
+
DropdownMenu$2.displayName = DROPDOWN_MENU_NAME;
|
|
1090
|
+
var TRIGGER_NAME = "DropdownMenuTrigger";
|
|
1091
|
+
var DropdownMenuTrigger$2 = React.forwardRef(
|
|
1092
|
+
(props, forwardedRef) => {
|
|
1093
|
+
const { __scopeDropdownMenu, disabled = false, ...triggerProps } = props;
|
|
1094
|
+
const context = useDropdownMenuContext(TRIGGER_NAME, __scopeDropdownMenu);
|
|
1095
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1096
|
+
return /* @__PURE__ */ jsx(Anchor2, { asChild: true, ...menuScope, children: /* @__PURE__ */ jsx(
|
|
1097
|
+
Primitive.button,
|
|
1098
|
+
{
|
|
1099
|
+
type: "button",
|
|
1100
|
+
id: context.triggerId,
|
|
1101
|
+
"aria-haspopup": "menu",
|
|
1102
|
+
"aria-expanded": context.open,
|
|
1103
|
+
"aria-controls": context.open ? context.contentId : void 0,
|
|
1104
|
+
"data-state": context.open ? "open" : "closed",
|
|
1105
|
+
"data-disabled": disabled ? "" : void 0,
|
|
1106
|
+
disabled,
|
|
1107
|
+
...triggerProps,
|
|
1108
|
+
ref: composeRefs(forwardedRef, context.triggerRef),
|
|
1109
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
|
|
1110
|
+
if (!disabled && event.button === 0 && event.ctrlKey === false) {
|
|
1111
|
+
context.onOpenToggle();
|
|
1112
|
+
if (!context.open) event.preventDefault();
|
|
1113
|
+
}
|
|
1114
|
+
}),
|
|
1115
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
1116
|
+
if (disabled) return;
|
|
1117
|
+
if (["Enter", " "].includes(event.key)) context.onOpenToggle();
|
|
1118
|
+
if (event.key === "ArrowDown") context.onOpenChange(true);
|
|
1119
|
+
if (["Enter", " ", "ArrowDown"].includes(event.key)) event.preventDefault();
|
|
1120
|
+
})
|
|
1121
|
+
}
|
|
1122
|
+
) });
|
|
1123
|
+
}
|
|
1124
|
+
);
|
|
1125
|
+
DropdownMenuTrigger$2.displayName = TRIGGER_NAME;
|
|
1126
|
+
var PORTAL_NAME = "DropdownMenuPortal";
|
|
1127
|
+
var DropdownMenuPortal$2 = (props) => {
|
|
1128
|
+
const { __scopeDropdownMenu, ...portalProps } = props;
|
|
1129
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1130
|
+
return /* @__PURE__ */ jsx(Portal, { ...menuScope, ...portalProps });
|
|
1131
|
+
};
|
|
1132
|
+
DropdownMenuPortal$2.displayName = PORTAL_NAME;
|
|
1133
|
+
var CONTENT_NAME = "DropdownMenuContent";
|
|
1134
|
+
var DropdownMenuContent$2 = React.forwardRef(
|
|
1135
|
+
(props, forwardedRef) => {
|
|
1136
|
+
const { __scopeDropdownMenu, ...contentProps } = props;
|
|
1137
|
+
const context = useDropdownMenuContext(CONTENT_NAME, __scopeDropdownMenu);
|
|
1138
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1139
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
1140
|
+
return /* @__PURE__ */ jsx(
|
|
1141
|
+
Content2$1,
|
|
1142
|
+
{
|
|
1143
|
+
id: context.contentId,
|
|
1144
|
+
"aria-labelledby": context.triggerId,
|
|
1145
|
+
...menuScope,
|
|
1146
|
+
...contentProps,
|
|
1147
|
+
ref: forwardedRef,
|
|
1148
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
1149
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
1150
|
+
hasInteractedOutsideRef.current = false;
|
|
1151
|
+
event.preventDefault();
|
|
1152
|
+
}),
|
|
1153
|
+
onInteractOutside: composeEventHandlers(props.onInteractOutside, (event) => {
|
|
1154
|
+
const originalEvent = event.detail.originalEvent;
|
|
1155
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
1156
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
1157
|
+
if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
|
|
1158
|
+
}),
|
|
1159
|
+
style: {
|
|
1160
|
+
...props.style,
|
|
1161
|
+
// re-namespace exposed content custom properties
|
|
1162
|
+
...{
|
|
1163
|
+
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
1164
|
+
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
1165
|
+
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
1166
|
+
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1167
|
+
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
);
|
|
1172
|
+
}
|
|
1173
|
+
);
|
|
1174
|
+
DropdownMenuContent$2.displayName = CONTENT_NAME;
|
|
1175
|
+
var GROUP_NAME = "DropdownMenuGroup";
|
|
1176
|
+
var DropdownMenuGroup$2 = React.forwardRef(
|
|
1177
|
+
(props, forwardedRef) => {
|
|
1178
|
+
const { __scopeDropdownMenu, ...groupProps } = props;
|
|
1179
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1180
|
+
return /* @__PURE__ */ jsx(Group, { ...menuScope, ...groupProps, ref: forwardedRef });
|
|
1181
|
+
}
|
|
1182
|
+
);
|
|
1183
|
+
DropdownMenuGroup$2.displayName = GROUP_NAME;
|
|
1184
|
+
var LABEL_NAME = "DropdownMenuLabel";
|
|
1185
|
+
var DropdownMenuLabel$2 = React.forwardRef(
|
|
1186
|
+
(props, forwardedRef) => {
|
|
1187
|
+
const { __scopeDropdownMenu, ...labelProps } = props;
|
|
1188
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1189
|
+
return /* @__PURE__ */ jsx(Label, { ...menuScope, ...labelProps, ref: forwardedRef });
|
|
1190
|
+
}
|
|
1191
|
+
);
|
|
1192
|
+
DropdownMenuLabel$2.displayName = LABEL_NAME;
|
|
1193
|
+
var ITEM_NAME = "DropdownMenuItem";
|
|
1194
|
+
var DropdownMenuItem$2 = React.forwardRef(
|
|
1195
|
+
(props, forwardedRef) => {
|
|
1196
|
+
const { __scopeDropdownMenu, ...itemProps } = props;
|
|
1197
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1198
|
+
return /* @__PURE__ */ jsx(Item2$1, { ...menuScope, ...itemProps, ref: forwardedRef });
|
|
1199
|
+
}
|
|
1200
|
+
);
|
|
1201
|
+
DropdownMenuItem$2.displayName = ITEM_NAME;
|
|
1202
|
+
var CHECKBOX_ITEM_NAME = "DropdownMenuCheckboxItem";
|
|
1203
|
+
var DropdownMenuCheckboxItem$2 = React.forwardRef((props, forwardedRef) => {
|
|
1204
|
+
const { __scopeDropdownMenu, ...checkboxItemProps } = props;
|
|
1205
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1206
|
+
return /* @__PURE__ */ jsx(CheckboxItem, { ...menuScope, ...checkboxItemProps, ref: forwardedRef });
|
|
1207
|
+
});
|
|
1208
|
+
DropdownMenuCheckboxItem$2.displayName = CHECKBOX_ITEM_NAME;
|
|
1209
|
+
var RADIO_GROUP_NAME = "DropdownMenuRadioGroup";
|
|
1210
|
+
var DropdownMenuRadioGroup$2 = React.forwardRef((props, forwardedRef) => {
|
|
1211
|
+
const { __scopeDropdownMenu, ...radioGroupProps } = props;
|
|
1212
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1213
|
+
return /* @__PURE__ */ jsx(RadioGroup, { ...menuScope, ...radioGroupProps, ref: forwardedRef });
|
|
1214
|
+
});
|
|
1215
|
+
DropdownMenuRadioGroup$2.displayName = RADIO_GROUP_NAME;
|
|
1216
|
+
var RADIO_ITEM_NAME = "DropdownMenuRadioItem";
|
|
1217
|
+
var DropdownMenuRadioItem$2 = React.forwardRef((props, forwardedRef) => {
|
|
1218
|
+
const { __scopeDropdownMenu, ...radioItemProps } = props;
|
|
1219
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1220
|
+
return /* @__PURE__ */ jsx(RadioItem, { ...menuScope, ...radioItemProps, ref: forwardedRef });
|
|
1221
|
+
});
|
|
1222
|
+
DropdownMenuRadioItem$2.displayName = RADIO_ITEM_NAME;
|
|
1223
|
+
var INDICATOR_NAME = "DropdownMenuItemIndicator";
|
|
1224
|
+
var DropdownMenuItemIndicator = React.forwardRef((props, forwardedRef) => {
|
|
1225
|
+
const { __scopeDropdownMenu, ...itemIndicatorProps } = props;
|
|
1226
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1227
|
+
return /* @__PURE__ */ jsx(ItemIndicator, { ...menuScope, ...itemIndicatorProps, ref: forwardedRef });
|
|
1228
|
+
});
|
|
1229
|
+
DropdownMenuItemIndicator.displayName = INDICATOR_NAME;
|
|
1230
|
+
var SEPARATOR_NAME = "DropdownMenuSeparator";
|
|
1231
|
+
var DropdownMenuSeparator$2 = React.forwardRef((props, forwardedRef) => {
|
|
1232
|
+
const { __scopeDropdownMenu, ...separatorProps } = props;
|
|
1233
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1234
|
+
return /* @__PURE__ */ jsx(Separator, { ...menuScope, ...separatorProps, ref: forwardedRef });
|
|
1235
|
+
});
|
|
1236
|
+
DropdownMenuSeparator$2.displayName = SEPARATOR_NAME;
|
|
1237
|
+
var ARROW_NAME = "DropdownMenuArrow";
|
|
1238
|
+
var DropdownMenuArrow = React.forwardRef(
|
|
1239
|
+
(props, forwardedRef) => {
|
|
1240
|
+
const { __scopeDropdownMenu, ...arrowProps } = props;
|
|
1241
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1242
|
+
return /* @__PURE__ */ jsx(Arrow2, { ...menuScope, ...arrowProps, ref: forwardedRef });
|
|
1243
|
+
}
|
|
1244
|
+
);
|
|
1245
|
+
DropdownMenuArrow.displayName = ARROW_NAME;
|
|
1246
|
+
var DropdownMenuSub$2 = (props) => {
|
|
1247
|
+
const { __scopeDropdownMenu, children, open: openProp, onOpenChange, defaultOpen } = props;
|
|
1248
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1249
|
+
const [open, setOpen] = useControllableState({
|
|
1250
|
+
prop: openProp,
|
|
1251
|
+
defaultProp: defaultOpen ?? false,
|
|
1252
|
+
onChange: onOpenChange,
|
|
1253
|
+
caller: "DropdownMenuSub"
|
|
1254
|
+
});
|
|
1255
|
+
return /* @__PURE__ */ jsx(Sub, { ...menuScope, open, onOpenChange: setOpen, children });
|
|
1256
|
+
};
|
|
1257
|
+
var SUB_TRIGGER_NAME = "DropdownMenuSubTrigger";
|
|
1258
|
+
var DropdownMenuSubTrigger$2 = React.forwardRef((props, forwardedRef) => {
|
|
1259
|
+
const { __scopeDropdownMenu, ...subTriggerProps } = props;
|
|
1260
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1261
|
+
return /* @__PURE__ */ jsx(SubTrigger, { ...menuScope, ...subTriggerProps, ref: forwardedRef });
|
|
1262
|
+
});
|
|
1263
|
+
DropdownMenuSubTrigger$2.displayName = SUB_TRIGGER_NAME;
|
|
1264
|
+
var SUB_CONTENT_NAME = "DropdownMenuSubContent";
|
|
1265
|
+
var DropdownMenuSubContent$2 = React.forwardRef((props, forwardedRef) => {
|
|
1266
|
+
const { __scopeDropdownMenu, ...subContentProps } = props;
|
|
1267
|
+
const menuScope = useMenuScope(__scopeDropdownMenu);
|
|
1268
|
+
return /* @__PURE__ */ jsx(
|
|
1269
|
+
SubContent,
|
|
1270
|
+
{
|
|
1271
|
+
...menuScope,
|
|
1272
|
+
...subContentProps,
|
|
1273
|
+
ref: forwardedRef,
|
|
1274
|
+
style: {
|
|
1275
|
+
...props.style,
|
|
1276
|
+
// re-namespace exposed content custom properties
|
|
1277
|
+
...{
|
|
1278
|
+
"--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
1279
|
+
"--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
|
|
1280
|
+
"--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
|
|
1281
|
+
"--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
|
|
1282
|
+
"--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
);
|
|
1287
|
+
});
|
|
1288
|
+
DropdownMenuSubContent$2.displayName = SUB_CONTENT_NAME;
|
|
1289
|
+
var Root2 = DropdownMenu$2;
|
|
1290
|
+
var Trigger = DropdownMenuTrigger$2;
|
|
1291
|
+
var Portal2 = DropdownMenuPortal$2;
|
|
1292
|
+
var Content2 = DropdownMenuContent$2;
|
|
1293
|
+
var Group2 = DropdownMenuGroup$2;
|
|
1294
|
+
var Label2 = DropdownMenuLabel$2;
|
|
1295
|
+
var Item2 = DropdownMenuItem$2;
|
|
1296
|
+
var CheckboxItem2 = DropdownMenuCheckboxItem$2;
|
|
1297
|
+
var RadioGroup2 = DropdownMenuRadioGroup$2;
|
|
1298
|
+
var RadioItem2 = DropdownMenuRadioItem$2;
|
|
1299
|
+
var ItemIndicator2 = DropdownMenuItemIndicator;
|
|
1300
|
+
var Separator2 = DropdownMenuSeparator$2;
|
|
1301
|
+
var Sub2 = DropdownMenuSub$2;
|
|
1302
|
+
var SubTrigger2 = DropdownMenuSubTrigger$2;
|
|
1303
|
+
var SubContent2 = DropdownMenuSubContent$2;
|
|
1304
|
+
|
|
1305
|
+
const DropdownMenu$1 = Root2;
|
|
1306
|
+
const DropdownMenuTrigger$1 = Trigger;
|
|
1307
|
+
const DropdownMenuGroup$1 = Group2;
|
|
1308
|
+
const DropdownMenuPortal$1 = Portal2;
|
|
1309
|
+
const DropdownMenuSub$1 = Sub2;
|
|
1310
|
+
const DropdownMenuRadioGroup$1 = RadioGroup2;
|
|
1311
|
+
const DropdownMenuSubTrigger$1 = React.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
1312
|
+
SubTrigger2,
|
|
1313
|
+
{
|
|
1314
|
+
ref,
|
|
1315
|
+
className: cn(
|
|
1316
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
|
|
1317
|
+
inset && "pl-8",
|
|
1318
|
+
className
|
|
1319
|
+
),
|
|
1320
|
+
...props,
|
|
1321
|
+
children: [
|
|
1322
|
+
children,
|
|
1323
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto h-4 w-4" })
|
|
1324
|
+
]
|
|
1325
|
+
}
|
|
1326
|
+
));
|
|
1327
|
+
DropdownMenuSubTrigger$1.displayName = SubTrigger2.displayName;
|
|
1328
|
+
const DropdownMenuSubContent$1 = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1329
|
+
SubContent2,
|
|
1330
|
+
{
|
|
1331
|
+
ref,
|
|
1332
|
+
className: cn(
|
|
1333
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
1334
|
+
className
|
|
1335
|
+
),
|
|
1336
|
+
...props
|
|
1337
|
+
}
|
|
1338
|
+
));
|
|
1339
|
+
DropdownMenuSubContent$1.displayName = SubContent2.displayName;
|
|
1340
|
+
const DropdownMenuContent$1 = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(Portal2, { children: /* @__PURE__ */ jsx(
|
|
1341
|
+
Content2,
|
|
1342
|
+
{
|
|
1343
|
+
ref,
|
|
1344
|
+
sideOffset,
|
|
1345
|
+
className: cn(
|
|
1346
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
1347
|
+
className
|
|
1348
|
+
),
|
|
1349
|
+
...props
|
|
1350
|
+
}
|
|
1351
|
+
) }));
|
|
1352
|
+
DropdownMenuContent$1.displayName = Content2.displayName;
|
|
1353
|
+
const DropdownMenuItem$1 = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1354
|
+
Item2,
|
|
1355
|
+
{
|
|
1356
|
+
ref,
|
|
1357
|
+
className: cn(
|
|
1358
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
1359
|
+
inset && "pl-8",
|
|
1360
|
+
className
|
|
1361
|
+
),
|
|
1362
|
+
...props
|
|
1363
|
+
}
|
|
1364
|
+
));
|
|
1365
|
+
DropdownMenuItem$1.displayName = Item2.displayName;
|
|
1366
|
+
const DropdownMenuCheckboxItem$1 = React.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
1367
|
+
CheckboxItem2,
|
|
1368
|
+
{
|
|
1369
|
+
ref,
|
|
1370
|
+
className: cn(
|
|
1371
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
1372
|
+
className
|
|
1373
|
+
),
|
|
1374
|
+
checked,
|
|
1375
|
+
...props,
|
|
1376
|
+
children: [
|
|
1377
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(ItemIndicator2, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
|
|
1378
|
+
children
|
|
1379
|
+
]
|
|
1380
|
+
}
|
|
1381
|
+
));
|
|
1382
|
+
DropdownMenuCheckboxItem$1.displayName = CheckboxItem2.displayName;
|
|
1383
|
+
const DropdownMenuRadioItem$1 = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
1384
|
+
RadioItem2,
|
|
1385
|
+
{
|
|
1386
|
+
ref,
|
|
1387
|
+
className: cn(
|
|
1388
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
1389
|
+
className
|
|
1390
|
+
),
|
|
1391
|
+
...props,
|
|
1392
|
+
children: [
|
|
1393
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(ItemIndicator2, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }),
|
|
1394
|
+
children
|
|
1395
|
+
]
|
|
1396
|
+
}
|
|
1397
|
+
));
|
|
1398
|
+
DropdownMenuRadioItem$1.displayName = RadioItem2.displayName;
|
|
1399
|
+
const DropdownMenuLabel$1 = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1400
|
+
Label2,
|
|
1401
|
+
{
|
|
1402
|
+
ref,
|
|
1403
|
+
className: cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className),
|
|
1404
|
+
...props
|
|
1405
|
+
}
|
|
1406
|
+
));
|
|
1407
|
+
DropdownMenuLabel$1.displayName = Label2.displayName;
|
|
1408
|
+
const DropdownMenuSeparator$1 = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Separator2, { ref, className: cn("-mx-1 my-2 h-px bg-border", className), ...props }));
|
|
1409
|
+
DropdownMenuSeparator$1.displayName = Separator2.displayName;
|
|
1410
|
+
const DropdownMenuShortcut$1 = ({ className, ...props }) => {
|
|
1411
|
+
return /* @__PURE__ */ jsx("span", { className: cn("ml-auto text-xs tracking-widest opacity-60", className), ...props });
|
|
1412
|
+
};
|
|
1413
|
+
DropdownMenuShortcut$1.displayName = "DropdownMenuShortcut";
|
|
1414
|
+
|
|
1415
|
+
const DropdownMenuRoot = DropdownMenu$1;
|
|
1416
|
+
const DropdownMenuCheckboxItem = DropdownMenuCheckboxItem$1;
|
|
1417
|
+
const DropdownMenuContent = DropdownMenuContent$1;
|
|
1418
|
+
const DropdownMenuGroup = DropdownMenuGroup$1;
|
|
1419
|
+
const DropdownMenuItem = DropdownMenuItem$1;
|
|
1420
|
+
const DropdownMenuLabel = DropdownMenuLabel$1;
|
|
1421
|
+
const DropdownMenuPortal = DropdownMenuPortal$1;
|
|
1422
|
+
const DropdownMenuRadioGroup = DropdownMenuRadioGroup$1;
|
|
1423
|
+
const DropdownMenuRadioItem = DropdownMenuRadioItem$1;
|
|
1424
|
+
const DropdownMenuSeparator = DropdownMenuSeparator$1;
|
|
1425
|
+
const DropdownMenuShortcut = DropdownMenuShortcut$1;
|
|
1426
|
+
const DropdownMenuSub = DropdownMenuSub$1;
|
|
1427
|
+
const DropdownMenuSubContent = DropdownMenuSubContent$1;
|
|
1428
|
+
const DropdownMenuSubTrigger = DropdownMenuSubTrigger$1;
|
|
1429
|
+
const DropdownMenuTrigger = DropdownMenuTrigger$1;
|
|
1430
|
+
const renderMenuItem = (item, index) => {
|
|
1431
|
+
switch (item.type) {
|
|
1432
|
+
case "separator":
|
|
1433
|
+
return /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, item.id ?? `separator-${index}`);
|
|
1434
|
+
case "label":
|
|
1435
|
+
return /* @__PURE__ */ jsx(DropdownMenuLabel, { children: item.label }, item.id);
|
|
1436
|
+
case "item": {
|
|
1437
|
+
const Icon = item.icon;
|
|
1438
|
+
return /* @__PURE__ */ jsxs(
|
|
1439
|
+
DropdownMenuItem,
|
|
1440
|
+
{
|
|
1441
|
+
onClick: item.onClick,
|
|
1442
|
+
disabled: item.disabled,
|
|
1443
|
+
className: item.variant === "destructive" ? "text-destructive focus:text-destructive" : void 0,
|
|
1444
|
+
children: [
|
|
1445
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: "mr-2 h-4 w-4" }),
|
|
1446
|
+
/* @__PURE__ */ jsx("span", { children: item.label }),
|
|
1447
|
+
item.shortcut && /* @__PURE__ */ jsx(DropdownMenuShortcut, { children: item.shortcut })
|
|
1448
|
+
]
|
|
1449
|
+
},
|
|
1450
|
+
item.id
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
case "checkbox": {
|
|
1454
|
+
const Icon = item.icon;
|
|
1455
|
+
return /* @__PURE__ */ jsxs(
|
|
1456
|
+
DropdownMenuCheckboxItem,
|
|
1457
|
+
{
|
|
1458
|
+
checked: item.checked,
|
|
1459
|
+
onCheckedChange: item.onCheckedChange,
|
|
1460
|
+
disabled: item.disabled,
|
|
1461
|
+
children: [
|
|
1462
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: "mr-2 h-4 w-4" }),
|
|
1463
|
+
item.label
|
|
1464
|
+
]
|
|
1465
|
+
},
|
|
1466
|
+
item.id
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
case "radio-group":
|
|
1470
|
+
return /* @__PURE__ */ jsx(DropdownMenuRadioGroup, { value: item.value, onValueChange: item.onValueChange, children: item.items.map((radioItem) => {
|
|
1471
|
+
const Icon = radioItem.icon;
|
|
1472
|
+
return /* @__PURE__ */ jsxs(DropdownMenuRadioItem, { value: radioItem.value, disabled: radioItem.disabled, children: [
|
|
1473
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: "mr-2 h-4 w-4" }),
|
|
1474
|
+
radioItem.label
|
|
1475
|
+
] }, radioItem.value);
|
|
1476
|
+
}) }, item.id);
|
|
1477
|
+
case "sub": {
|
|
1478
|
+
const Icon = item.icon;
|
|
1479
|
+
return /* @__PURE__ */ jsxs(DropdownMenuSub, { children: [
|
|
1480
|
+
/* @__PURE__ */ jsxs(DropdownMenuSubTrigger, { disabled: item.disabled, children: [
|
|
1481
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: "mr-2 h-4 w-4" }),
|
|
1482
|
+
/* @__PURE__ */ jsx("span", { children: item.label })
|
|
1483
|
+
] }),
|
|
1484
|
+
/* @__PURE__ */ jsx(DropdownMenuPortal, { children: /* @__PURE__ */ jsx(DropdownMenuSubContent, { children: item.items.map((subItem, subIndex) => renderMenuItem(subItem, subIndex)) }) })
|
|
1485
|
+
] }, item.id);
|
|
1486
|
+
}
|
|
1487
|
+
case "group":
|
|
1488
|
+
return /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
1489
|
+
item.label && /* @__PURE__ */ jsx(DropdownMenuLabel, { children: item.label }),
|
|
1490
|
+
item.items.map((groupItem, groupIndex) => renderMenuItem(groupItem, groupIndex))
|
|
1491
|
+
] }, item.id);
|
|
1492
|
+
case "custom": {
|
|
1493
|
+
const content = typeof item.render === "function" ? item.render() : item.render;
|
|
1494
|
+
if (item.asMenuItem) {
|
|
1495
|
+
return /* @__PURE__ */ jsx(DropdownMenuItem, { onClick: item.onClick, disabled: item.disabled, children: content }, item.id);
|
|
1496
|
+
}
|
|
1497
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: content }, item.id);
|
|
1498
|
+
}
|
|
1499
|
+
default:
|
|
1500
|
+
return null;
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
const DropdownMenu = ({
|
|
1504
|
+
trigger,
|
|
1505
|
+
items,
|
|
1506
|
+
contentClassName,
|
|
1507
|
+
align = "end",
|
|
1508
|
+
side
|
|
1509
|
+
}) => {
|
|
1510
|
+
const TriggerIcon = trigger.icon;
|
|
1511
|
+
return /* @__PURE__ */ jsxs(DropdownMenuRoot, { children: [
|
|
1512
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: trigger.children ?? /* @__PURE__ */ jsxs(Button, { variant: trigger.variant, className: trigger.className, children: [
|
|
1513
|
+
TriggerIcon && /* @__PURE__ */ jsx(TriggerIcon, { className: "mr-2 h-4 w-4" }),
|
|
1514
|
+
trigger.label
|
|
1515
|
+
] }) }),
|
|
1516
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { className: contentClassName, align, side, children: items.map((item, index) => renderMenuItem(item, index)) })
|
|
1517
|
+
] });
|
|
1518
|
+
};
|
|
1519
|
+
DropdownMenu.displayName = "DropdownMenu";
|
|
1520
|
+
|
|
1521
|
+
export { DropdownMenuRoot as D, DropdownMenuCheckboxItem as a, DropdownMenuContent as b, DropdownMenuGroup as c, DropdownMenuItem as d, DropdownMenuLabel as e, DropdownMenuPortal as f, DropdownMenuRadioGroup as g, DropdownMenuRadioItem as h, DropdownMenuSeparator as i, DropdownMenuShortcut as j, DropdownMenuSub as k, DropdownMenuSubContent as l, DropdownMenuSubTrigger as m, DropdownMenuTrigger as n, DropdownMenu as o };
|
|
1522
|
+
//# sourceMappingURL=DropdownMenu.js.map
|