@yahoo/uds 3.5.0-beta.2 → 3.5.0-beta.4
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/cli/FullWidthClassToProp.mock.tsx +17 -0
- package/cli/bin/uds-darwin-arm64-baseline +0 -0
- package/cli/bin/uds-linux-arm64 +0 -0
- package/cli/bin/uds-linux-x64-baseline +0 -0
- package/dist/Input-D6N7TCc9.d.ts +42 -0
- package/dist/Input-Tv8gAhPN.d.cts +42 -0
- package/dist/Pressable-DSWYYU6N.d.ts +44 -0
- package/dist/Pressable-cW57Ibe2.d.cts +44 -0
- package/dist/{VStack-CmraVolm.d.ts → VStack-Ca-CbKTr.d.ts} +2 -40
- package/dist/{VStack-dT3EJCu4.d.cts → VStack-Ck33D8i-.d.cts} +2 -40
- package/dist/chunk-2W4ER46N.js +1 -0
- package/dist/chunk-3WLIHKQU.js +3 -0
- package/dist/chunk-4AS6QR6M.cjs +3 -0
- package/dist/chunk-FGRUT3UC.cjs +2 -0
- package/dist/chunk-L72D6DDM.cjs +1 -0
- package/dist/chunk-MO2VPSXU.js +1 -0
- package/dist/chunk-PNR3372L.js +3 -0
- package/dist/chunk-UFBH4CCM.cjs +1 -0
- package/dist/client/Menu.cjs +2 -0
- package/dist/client/Menu.d.cts +626 -0
- package/dist/client/Menu.d.ts +626 -0
- package/dist/client/Menu.js +3 -0
- package/dist/client/index.cjs +1 -2
- package/dist/client/index.d.cts +10 -664
- package/dist/client/index.d.ts +10 -664
- package/dist/client/index.js +1 -3
- package/dist/{index-D1poGuo1.d.cts → index-CDx_NWe2.d.cts} +1 -1
- package/dist/{index-BOfq14yW.d.ts → index-xaTWnEHm.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/tailwind/plugin.cjs +1 -1
- package/dist/tailwind/plugin.d.cts +1 -1
- package/dist/tailwind/plugin.d.ts +1 -1
- package/dist/tailwind/plugin.js +2 -2
- package/dist/tailwind/utils.cjs +1 -1
- package/dist/tailwind/utils.d.cts +1 -1
- package/dist/tailwind/utils.d.ts +1 -1
- package/dist/tailwind/utils.js +1 -1
- package/dist/tokens/automation/configs.cjs +1 -1
- package/dist/tokens/automation/configs.d.cts +2 -2
- package/dist/tokens/automation/configs.d.ts +2 -2
- package/dist/tokens/automation/configs.js +1 -1
- package/dist/tokens/automation/properties.cjs +1 -1
- package/dist/tokens/automation/properties.d.cts +2 -2
- package/dist/tokens/automation/properties.d.ts +2 -2
- package/dist/tokens/automation/properties.js +1 -1
- package/dist/tokens/index.cjs +1 -1
- package/dist/tokens/index.d.cts +4 -4
- package/dist/tokens/index.d.ts +4 -4
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/parseTokens.d.cts +1 -1
- package/dist/tokens/parseTokens.d.ts +1 -1
- package/dist/{types-B_jakWRK.d.cts → types-BdV70-Tw.d.cts} +1 -1
- package/dist/{types-B_jakWRK.d.ts → types-BdV70-Tw.d.ts} +1 -1
- package/package.json +11 -1
- package/dist/chunk-IQ4HRDIM.cjs +0 -3
- package/dist/chunk-KSHOOD3K.js +0 -3
@@ -0,0 +1,626 @@
|
|
1
|
+
import * as react from 'react';
|
2
|
+
import { AriaRole, HTMLAttributes, PropsWithChildren } from 'react';
|
3
|
+
import { MenuProps, MenuItemProps as MenuItemProps$1, MenuItemCheckboxProps as MenuItemCheckboxProps$1, MenuProviderProps as MenuProviderProps$1, MenuButtonProps, useMenuContext, useMenuStore } from '@ariakit/react/menu';
|
4
|
+
import { j as SpacingAlias, k as UniversalMenuItemProps } from '../types-BdV70-Tw.js';
|
5
|
+
import { V as VStackProps, D as DividerProps, B as BoxProps } from '../VStack-Ca-CbKTr.js';
|
6
|
+
import { P as PressableProps } from '../Pressable-DSWYYU6N.js';
|
7
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
8
|
+
import { useStoreState } from '@ariakit/react';
|
9
|
+
import '@yahoo/uds-icons/types';
|
10
|
+
import 'motion/react';
|
11
|
+
import 'type-fest';
|
12
|
+
|
13
|
+
interface MenuContentProps extends Omit<VStackProps, 'asChild'> {
|
14
|
+
gutter?: SpacingAlias;
|
15
|
+
/** UDS handles nested border radius for the first and last item for you to prevent clipping and visual jank.
|
16
|
+
* If you need to disable this, set this prop to true.
|
17
|
+
*
|
18
|
+
* @link https://github.com/yahoo-uds/uds/blob/main/packages/uds/src/hooks/useNestedBorderRadius.ts
|
19
|
+
**/
|
20
|
+
disableAutoBorderRadius?: boolean;
|
21
|
+
/**
|
22
|
+
* `portalRef` is similar to `ref` but is scoped to the portal node. It's
|
23
|
+
* useful when you need to be informed when the portal element is appended to
|
24
|
+
* the DOM or removed from the DOM.
|
25
|
+
*
|
26
|
+
* Live examples:
|
27
|
+
* - [Form with Select](https://ariakit.org/examples/form-select)
|
28
|
+
* @example
|
29
|
+
* ```jsx
|
30
|
+
* const [portalElement, setPortalElement] = useState(null);
|
31
|
+
*
|
32
|
+
* <Portal portalRef={setPortalElement} />
|
33
|
+
* ```
|
34
|
+
*/
|
35
|
+
portalRef?: MenuProps['portalRef'];
|
36
|
+
/**
|
37
|
+
* Determines whether the element should be rendered as a React Portal.
|
38
|
+
*
|
39
|
+
* Live examples:
|
40
|
+
* - [Combobox with integrated
|
41
|
+
* filter](https://ariakit.org/examples/combobox-filtering-integrated)
|
42
|
+
* - [Dialog with Menu](https://ariakit.org/examples/dialog-menu)
|
43
|
+
* - [Hovercard with keyboard
|
44
|
+
* support](https://ariakit.org/examples/hovercard-disclosure)
|
45
|
+
* - [Menubar](https://ariakit.org/components/menubar)
|
46
|
+
* - [Standalone Popover](https://ariakit.org/examples/popover-standalone)
|
47
|
+
* - [Animated Select](https://ariakit.org/examples/select-animated)
|
48
|
+
* @default true
|
49
|
+
*/
|
50
|
+
portal?: boolean;
|
51
|
+
/**
|
52
|
+
* An HTML element or a memoized callback function that returns an HTML
|
53
|
+
* element to be used as the portal element. By default, the portal element
|
54
|
+
* will be a `div` element appended to the `document.body`.
|
55
|
+
*
|
56
|
+
* Live examples:
|
57
|
+
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
58
|
+
* @example
|
59
|
+
* ```jsx
|
60
|
+
* const [portal, setPortal] = useState(null);
|
61
|
+
*
|
62
|
+
* <Portal portalElement={portal} />
|
63
|
+
* <div ref={setPortal} />
|
64
|
+
* ```
|
65
|
+
* @example
|
66
|
+
* ```jsx
|
67
|
+
* const getPortalElement = useCallback(() => {
|
68
|
+
* const div = document.createElement("div");
|
69
|
+
* const portalRoot = document.getElementById("portal-root");
|
70
|
+
* portalRoot.appendChild(div);
|
71
|
+
* return div;
|
72
|
+
* }, []);
|
73
|
+
*
|
74
|
+
* <Portal portalElement={getPortalElement} />
|
75
|
+
* ```
|
76
|
+
*/
|
77
|
+
portalElement?: MenuProps['portalElement'];
|
78
|
+
/**
|
79
|
+
* Determines whether the popover should hide when the mouse leaves the
|
80
|
+
* popover or the anchor element and there's no _hover intent_, meaning, the
|
81
|
+
* mouse isn't moving toward the popover.
|
82
|
+
*
|
83
|
+
* This can be either a boolean or a callback receiving the mouse move event
|
84
|
+
* that initiated the behavior. The callback should return a boolean.
|
85
|
+
*
|
86
|
+
* **Note**: This behavior won't be triggered when the popover or any of its
|
87
|
+
* descendants are in focus.
|
88
|
+
* @default true
|
89
|
+
*/
|
90
|
+
hideOnHoverOutside?: MenuProps['hideOnHoverOutside'];
|
91
|
+
/**
|
92
|
+
* Determines if the dialog will hide when the user presses the Escape key.
|
93
|
+
*
|
94
|
+
* This prop can be either a boolean or a function that accepts an event as an
|
95
|
+
* argument and returns a boolean. The event object represents the keydown
|
96
|
+
* event that initiated the hide action, which could be either a native
|
97
|
+
* keyboard event or a React synthetic event.
|
98
|
+
*
|
99
|
+
* **Note**: When placing Ariakit dialogs inside third-party dialogs, using
|
100
|
+
* `event.stopPropagation()` within this function will stop the event from
|
101
|
+
* reaching the third-party dialog, closing only the Ariakit dialog.
|
102
|
+
* @default true
|
103
|
+
*/
|
104
|
+
hideOnEscape?: MenuProps['hideOnEscape'];
|
105
|
+
/**
|
106
|
+
* Determines if the dialog should hide when the user clicks or focuses on an
|
107
|
+
* element outside the dialog.
|
108
|
+
*
|
109
|
+
* This prop can be either a boolean or a function that takes an event as an
|
110
|
+
* argument and returns a boolean. The event object represents the event that
|
111
|
+
* triggered the action, which could be a native event or a React synthetic
|
112
|
+
* event of various types.
|
113
|
+
*
|
114
|
+
* Live examples:
|
115
|
+
* - [Selection Popover](https://ariakit.org/examples/popover-selection)
|
116
|
+
* @default true
|
117
|
+
*/
|
118
|
+
hideOnInteractOutside?: MenuProps['hideOnInteractOutside'];
|
119
|
+
/**
|
120
|
+
* Determines if the pointer events outside of the popover and its anchor
|
121
|
+
* element should be disabled during _hover intent_, that is, when the mouse
|
122
|
+
* is moving toward the popover.
|
123
|
+
*
|
124
|
+
* This is required as these external events may trigger focus on other
|
125
|
+
* elements and close the popover while the user is attempting to hover over
|
126
|
+
* it.
|
127
|
+
*
|
128
|
+
* This can be either a boolean or a callback receiving the mouse event
|
129
|
+
* happening during hover intent. The callback should return a boolean.
|
130
|
+
* @default true
|
131
|
+
*/
|
132
|
+
disablePointerEventsOnApproach?: MenuProps['disablePointerEventsOnApproach'];
|
133
|
+
/**
|
134
|
+
* Object returned by the [`useMenuStore`](https://ariakit.org/reference/use-menu-store) hook.
|
135
|
+
* If not provided, the closest [`Menu.Content`](https://uds.build/docs/components/menu#menu-content) or
|
136
|
+
* [`Menu.Provider`](https://uds.build/docs/components/menu#menu-provider) context will be used.
|
137
|
+
*/
|
138
|
+
store?: MenuProps['store'];
|
139
|
+
/**
|
140
|
+
* Whether the popover should have the same width as the anchor element. This
|
141
|
+
* will be exposed to CSS as
|
142
|
+
* [`--popover-anchor-width`](https://ariakit.org/guide/styling#--popover-anchor-width).
|
143
|
+
* @default false
|
144
|
+
*/
|
145
|
+
sameWidth?: MenuProps['sameWidth'];
|
146
|
+
/**
|
147
|
+
* @see https://ariakit.org/reference/focusable
|
148
|
+
* @default true
|
149
|
+
*/
|
150
|
+
focusable?: MenuProps['focusable'];
|
151
|
+
/**
|
152
|
+
* This is an event handler prop triggered when the dialog's `close` event is
|
153
|
+
* dispatched. The `close` event is similar to the native dialog
|
154
|
+
* [`close`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/close_event)
|
155
|
+
* event. The only difference is that this event can be canceled with
|
156
|
+
* `event.preventDefault()`, which will prevent the dialog from hiding.
|
157
|
+
*
|
158
|
+
* It's important to note that this event only fires when the dialog store's
|
159
|
+
* [`open`](https://ariakit.org/reference/use-dialog-store#open) state is set
|
160
|
+
* to `false`. If the controlled
|
161
|
+
* [`open`](https://ariakit.org/reference/dialog#open) prop value changes, or
|
162
|
+
* if the dialog's visibility is altered in any other way (such as unmounting
|
163
|
+
* the dialog without adjusting the open state), this event won't be
|
164
|
+
* triggered.
|
165
|
+
*
|
166
|
+
* Live examples:
|
167
|
+
* - [Dialog with scrollable
|
168
|
+
* backdrop](https://ariakit.org/examples/dialog-backdrop-scrollable)
|
169
|
+
* - [Dialog with details &
|
170
|
+
* summary](https://ariakit.org/examples/dialog-details)
|
171
|
+
* - [Warning on Dialog
|
172
|
+
* hide](https://ariakit.org/examples/dialog-hide-warning)
|
173
|
+
* - [Dialog with Menu](https://ariakit.org/examples/dialog-menu)
|
174
|
+
*/
|
175
|
+
onClose?: MenuProps['onClose'];
|
176
|
+
}
|
177
|
+
/**
|
178
|
+
* **📦 A Menu Content component**
|
179
|
+
*
|
180
|
+
* @componentType Client component
|
181
|
+
*
|
182
|
+
* @description
|
183
|
+
* A content component for the menu, which is used to provide the menu context to the menu items.
|
184
|
+
*
|
185
|
+
* @see The {@link https://uds.build/docs/components/menu-content Menu.Content Docs} for more info
|
186
|
+
*
|
187
|
+
* @example
|
188
|
+
* ```tsx
|
189
|
+
* 'use client'; // Next.js client component
|
190
|
+
*
|
191
|
+
* import { Menu, Button } from "@yahoo/uds";
|
192
|
+
* import { Calendar, Clipboard } from "@yahoo/uds-icons";
|
193
|
+
*
|
194
|
+
* export function MenuProviderExample() {
|
195
|
+
* return (
|
196
|
+
* <Menu.Provider>
|
197
|
+
* <Menu.Trigger asChild>
|
198
|
+
* <Button>Menu Options</Button>
|
199
|
+
* </Menu.Trigger>
|
200
|
+
* <Menu.Content>
|
201
|
+
* <Menu.Item startIcon={Calendar}>Calendar</Menu.Item>
|
202
|
+
* <Menu.Item startIcon={Clipboard} endIcon={DiagonalRightUp}>
|
203
|
+
* Clipboard
|
204
|
+
* </Menu.Item>
|
205
|
+
* <Menu.Item active>Active Item</Menu.Item>
|
206
|
+
* </Menu.Content>
|
207
|
+
* </Menu.Provider>
|
208
|
+
* )
|
209
|
+
* }
|
210
|
+
* ```
|
211
|
+
*
|
212
|
+
* @usage
|
213
|
+
* Using Menu.Content is required to use Menu.Item and Menu.ItemCheckbox. It acts as the actual menu container.
|
214
|
+
*
|
215
|
+
* @related [Menu](https://uds.build/docs/components/menu), [Menu.ItemCheckbox](https://uds.build/docs/components/menu-item-checkbox)
|
216
|
+
**/
|
217
|
+
declare const MenuContent: react.ForwardRefExoticComponent<MenuContentProps & react.RefAttributes<HTMLDivElement>>;
|
218
|
+
|
219
|
+
interface MenuDividerProps extends Omit<DividerProps, 'variant'> {
|
220
|
+
/**
|
221
|
+
* The role of the divider.
|
222
|
+
* @default 'separator'
|
223
|
+
*/
|
224
|
+
role?: AriaRole;
|
225
|
+
}
|
226
|
+
/**
|
227
|
+
* **〰️ A Menu Divider component**
|
228
|
+
*
|
229
|
+
* @componentType Client component
|
230
|
+
*
|
231
|
+
* @description
|
232
|
+
* A divider component for the menu.
|
233
|
+
*
|
234
|
+
* @see The {@link https://uds.build/docs/components/menu-divider Menu.Divider Docs} for more info
|
235
|
+
*
|
236
|
+
* @example
|
237
|
+
* ```tsx
|
238
|
+
* 'use client'; // Next.js client component
|
239
|
+
*
|
240
|
+
* import { Menu, Button } from "@yahoo/uds";
|
241
|
+
*
|
242
|
+
* export function DividerExample() {
|
243
|
+
* return (
|
244
|
+
* <Menu>
|
245
|
+
* <Menu.Trigger asChild>
|
246
|
+
* <Button>Menu Options</Button>
|
247
|
+
* </Menu.Trigger>
|
248
|
+
* <Menu.Content>
|
249
|
+
* <Menu.Item>Calendar</Menu.Item>
|
250
|
+
* <Menu.Divider>Other actions</Menu.Divider>
|
251
|
+
* <Menu.Item>Clipboard</Menu.Item>
|
252
|
+
* <Menu.Item active>Active Item</Menu.Item>
|
253
|
+
* </Menu.Content>
|
254
|
+
* </Menu>
|
255
|
+
* )
|
256
|
+
* }
|
257
|
+
* ```
|
258
|
+
*
|
259
|
+
* @usage
|
260
|
+
* Use MenuDivider to separate groups of menu items.
|
261
|
+
*
|
262
|
+
* @related [Menu](https://uds.build/docs/components/menu), [Menu.Item](https://uds.build/docs/components/menu-item), [Divider](https://uds.build/docs/components/divider)
|
263
|
+
**/
|
264
|
+
declare const MenuDivider: react.ForwardRefExoticComponent<MenuDividerProps & react.RefAttributes<HTMLDivElement>>;
|
265
|
+
|
266
|
+
interface MenuItemProps extends PressableProps, Omit<UniversalMenuItemProps, 'name'> {
|
267
|
+
/**
|
268
|
+
* Object returned by the [`useMenuStore`](https://ariakit.org/reference/use-menu-store) hook.
|
269
|
+
* If not provided, the closest [`Menu.Content`](https://uds.build/docs/components/menu#menu-content) or
|
270
|
+
* [`Menu.Provider`](https://uds.build/docs/components/menu#menu-provider) context will be used.
|
271
|
+
*/
|
272
|
+
store?: MenuItemProps$1['store'];
|
273
|
+
/**
|
274
|
+
* Determines if the menu should hide when this item is clicked.
|
275
|
+
*
|
276
|
+
* **Note**: This behavior isn't triggered if this menu item is rendered as a
|
277
|
+
* link and modifier keys are used to either open the link in a new tab or
|
278
|
+
* download it.
|
279
|
+
*
|
280
|
+
* @default true
|
281
|
+
*/
|
282
|
+
hideOnClick?: MenuItemProps$1['hideOnClick'];
|
283
|
+
/**
|
284
|
+
* The role of the menu item.
|
285
|
+
*
|
286
|
+
* @default 'menuitem'
|
287
|
+
*/
|
288
|
+
role?: AriaRole;
|
289
|
+
/** Internal overrides for downstream components. */
|
290
|
+
layerClassNames?: {
|
291
|
+
root?: string;
|
292
|
+
startIcon?: string;
|
293
|
+
endIcon?: string;
|
294
|
+
};
|
295
|
+
}
|
296
|
+
/**
|
297
|
+
* **📋 A Menu Item component for navigation and actions**
|
298
|
+
*
|
299
|
+
* @componentType Client component
|
300
|
+
*
|
301
|
+
* @description
|
302
|
+
* A standard menu item that can be used for navigation, actions, or displaying options in a menu.
|
303
|
+
* Menu items can be styled with active states, icons, and can trigger callbacks when clicked.
|
304
|
+
* They support both visual and functional customization.
|
305
|
+
*
|
306
|
+
* @see The {@link https://uds.build/docs/components/menu-item Menu.Item Docs} for more info
|
307
|
+
*
|
308
|
+
* @example
|
309
|
+
* ```tsx
|
310
|
+
* 'use client'; // Next.js client component
|
311
|
+
*
|
312
|
+
* import { Menu, Button } from "@yahoo/uds";
|
313
|
+
* import { Calendar, Clipboard } from "@yahoo/uds-icons";
|
314
|
+
*
|
315
|
+
* export function MenuItemExample() {
|
316
|
+
* return (
|
317
|
+
* <Menu.Provider>
|
318
|
+
* <Menu.Trigger asChild>
|
319
|
+
* <Button>Menu Options</Button>
|
320
|
+
* </Menu.Trigger>
|
321
|
+
* <Menu.Content>
|
322
|
+
* <Menu.Item startIcon={Calendar}>Calendar</Menu.Item>
|
323
|
+
* <Menu.Item startIcon={Clipboard} endIcon={DiagonalRightUp}>
|
324
|
+
* Clipboard
|
325
|
+
* </Menu.Item>
|
326
|
+
* <Menu.Item active>Active Item</Menu.Item>
|
327
|
+
* </Menu.Content>
|
328
|
+
* </Menu>
|
329
|
+
* )
|
330
|
+
* }
|
331
|
+
* ```
|
332
|
+
*
|
333
|
+
* @usage
|
334
|
+
* Use MenuItem for standard menu options that trigger actions or navigate to other parts of the application.
|
335
|
+
* The active prop can be used to highlight the currently selected item.
|
336
|
+
*
|
337
|
+
* @related [Menu](https://uds.build/docs/components/menu), [Menu.ItemCheckbox](https://uds.build/docs/components/menu-item-checkbox)
|
338
|
+
**/
|
339
|
+
declare const MenuItem: react.ForwardRefExoticComponent<MenuItemProps & react.RefAttributes<HTMLButtonElement>>;
|
340
|
+
|
341
|
+
type HtmlButtonProps = HTMLAttributes<HTMLButtonElement>;
|
342
|
+
interface MenuItemCheckboxProps extends PressableProps, HtmlButtonProps, UniversalMenuItemProps {
|
343
|
+
/**
|
344
|
+
* The name of the field in the
|
345
|
+
* [`values`](https://ariakit.org/reference/menu-provider#values) state.
|
346
|
+
*
|
347
|
+
* Live examples at [MenuItemCheckbox](https://ariakit.org/examples/menu-item-checkbox)
|
348
|
+
*/
|
349
|
+
name: string;
|
350
|
+
/**
|
351
|
+
* The controlled checked state of the element. It will set the menu
|
352
|
+
* [`values`](https://ariakit.org/reference/menu-provider#values) state if
|
353
|
+
* provided.
|
354
|
+
*/
|
355
|
+
checked?: boolean;
|
356
|
+
/**
|
357
|
+
* The default checked state of the element. It will set the default value in
|
358
|
+
* the menu [`values`](https://ariakit.org/reference/menu-provider#values)
|
359
|
+
* state if provided.
|
360
|
+
*/
|
361
|
+
defaultChecked?: boolean;
|
362
|
+
/**
|
363
|
+
* Object returned by the [`useMenuStore`](https://ariakit.org/reference/use-menu-store) hook.
|
364
|
+
* If not provided, the closest [`Menu.Content`](https://uds.build/docs/components/menu#menu-content) or
|
365
|
+
* [`Menu.Provider`](https://uds.build/docs/components/menu#menu-provider) context will be used.
|
366
|
+
*/
|
367
|
+
store?: MenuItemCheckboxProps$1['store'];
|
368
|
+
/**
|
369
|
+
* Determines if the menu should hide when this item is clicked.
|
370
|
+
*
|
371
|
+
* **Note**: This behavior isn't triggered if this menu item is rendered as a
|
372
|
+
* link and modifier keys are used to either open the link in a new tab or
|
373
|
+
* download it.
|
374
|
+
*
|
375
|
+
* @default undefined
|
376
|
+
*/
|
377
|
+
hideOnClick?: MenuItemCheckboxProps$1['hideOnClick'];
|
378
|
+
}
|
379
|
+
/**
|
380
|
+
* **✅ A Menu Item Checkbox component**
|
381
|
+
*
|
382
|
+
* @componentType Client component
|
383
|
+
*
|
384
|
+
* @description
|
385
|
+
* A checkable menu item that toggles between selected and unselected states. Menu item checkboxes
|
386
|
+
* allow users to select multiple options from a menu, displaying a checkmark when active. They maintain
|
387
|
+
* their state even when the menu is closed and reopened.
|
388
|
+
*
|
389
|
+
* @see The {@link https://uds.build/docs/components/menu-item-checkbox Menu.ItemCheckbox Docs} for more info
|
390
|
+
*
|
391
|
+
* @example
|
392
|
+
* ```tsx
|
393
|
+
* 'use client'; // Next.js client component
|
394
|
+
*
|
395
|
+
* import { Menu, Button } from "@yahoo/uds";
|
396
|
+
*
|
397
|
+
* export function MenuItemCheckboxExample() {
|
398
|
+
* return (
|
399
|
+
* <Menu.Provider>
|
400
|
+
* <Menu.Trigger asChild>
|
401
|
+
* <Button>Filter Options</Button>
|
402
|
+
* </Menu.Trigger>
|
403
|
+
* <Menu.Content>
|
404
|
+
* <Menu.ItemCheckbox name="showArchived" defaultChecked={false}>
|
405
|
+
* Show Archived
|
406
|
+
* </Menu.ItemCheckbox>
|
407
|
+
* <Menu.ItemCheckbox name="includeComments" defaultChecked={true}>
|
408
|
+
* Include Comments
|
409
|
+
* </Menu.ItemCheckbox>
|
410
|
+
* </Menu.Content>
|
411
|
+
* </Menu.Provider>
|
412
|
+
* )
|
413
|
+
* }
|
414
|
+
* ```
|
415
|
+
*
|
416
|
+
* @usage
|
417
|
+
* Use MenuItemCheckbox when you need to provide users with multiple selectable options within a menu.
|
418
|
+
* Unlike radio options, checkboxes allow for multiple simultaneous selections.
|
419
|
+
*
|
420
|
+
* @related [Menu](https://uds.build/docs/components/menu), [Menu.Item](https://uds.build/docs/components/menu-item)
|
421
|
+
**/
|
422
|
+
declare const MenuItemCheckbox: react.ForwardRefExoticComponent<Omit<MenuItemCheckboxProps, "active" | "as" | "hideEndIcon" | "rootProps"> & react.RefAttributes<HTMLButtonElement>>;
|
423
|
+
|
424
|
+
/** Valid vertical placement values for the menu */
|
425
|
+
type VerticalPlacement = 'top' | 'bottom';
|
426
|
+
/** Valid horizontal placement values for the menu */
|
427
|
+
type HorizontalPlacement = 'start' | 'end';
|
428
|
+
/** Combined placement values for menu positioning */
|
429
|
+
type MenuPlacement = VerticalPlacement | HorizontalPlacement | `${VerticalPlacement}-${HorizontalPlacement}` | `${HorizontalPlacement}-${VerticalPlacement}`;
|
430
|
+
type MenuProviderProps = PropsWithChildren<{
|
431
|
+
/**
|
432
|
+
* A callback that gets called when the
|
433
|
+
* [`values`](https://ariakit.org/reference/menu-provider#values) state
|
434
|
+
* changes.
|
435
|
+
*
|
436
|
+
* Live examples:
|
437
|
+
* - [`MenuItemCheckbox`](https://uds.build/docs/components/menu-item-checkbox).
|
438
|
+
*/
|
439
|
+
setValues?: (values: Record<string, boolean>) => void | MenuProviderProps$1['setValues'];
|
440
|
+
/**
|
441
|
+
* A map of names and values that will be used by the
|
442
|
+
* [`MenuItemCheckbox`](https://uds.build/docs/components/menu-item-checkbox).
|
443
|
+
*
|
444
|
+
* Live examples:
|
445
|
+
* - [MenuItemCheckbox](https://uds.build/docs/components/menu-item-checkbox)
|
446
|
+
*/
|
447
|
+
values?: MenuProviderProps$1['values'];
|
448
|
+
/**
|
449
|
+
* The placement of the Menu.Content.
|
450
|
+
*
|
451
|
+
* @default 'bottom'
|
452
|
+
*/
|
453
|
+
placement?: MenuPlacement;
|
454
|
+
/**
|
455
|
+
* Object returned by the [`useMenuStore`](https://ariakit.org/reference/use-menu-store) hook.
|
456
|
+
* If not provided, the closest [`Menu.Content`](https://uds.build/docs/components/menu#menu-content) or
|
457
|
+
* [`Menu.Provider`](https://uds.build/docs/components/menu#menu-provider) context will be used.
|
458
|
+
*/
|
459
|
+
store?: MenuProviderProps$1['store'];
|
460
|
+
/**
|
461
|
+
* Whether the menu should be rendered in RTL direction.
|
462
|
+
*
|
463
|
+
* This only affects the some component behavior behavior. You still need to set
|
464
|
+
* `dir="rtl"` on HTML/CSS.
|
465
|
+
* @default false
|
466
|
+
*/
|
467
|
+
rtl?: MenuProviderProps$1['rtl'];
|
468
|
+
/**
|
469
|
+
* Whether the content is visible.
|
470
|
+
* @default false
|
471
|
+
*/
|
472
|
+
open?: MenuProviderProps$1['open'];
|
473
|
+
/**
|
474
|
+
* A callback that gets called when the
|
475
|
+
* [`open`](https://ariakit.org/reference/disclosure-provider#open) state
|
476
|
+
* changes.
|
477
|
+
* @example
|
478
|
+
* const [open, setOpen] = useState(false);
|
479
|
+
* const disclosure = useDisclosureStore({ open, setOpen });
|
480
|
+
*/
|
481
|
+
setOpen?: MenuProviderProps$1['setOpen'];
|
482
|
+
/**
|
483
|
+
* Whether the content should be visible by default.
|
484
|
+
* @default false
|
485
|
+
*/
|
486
|
+
defaultOpen?: MenuProviderProps$1['defaultOpen'];
|
487
|
+
/**
|
488
|
+
* Determines how the focus behaves when the user reaches the end of the
|
489
|
+
* composite widget.
|
490
|
+
*
|
491
|
+
* Live examples:
|
492
|
+
* - [Command Menu](https://uds.build/docs/components/menu)
|
493
|
+
* @default false
|
494
|
+
*/
|
495
|
+
focusLoop?: MenuProviderProps$1['focusLoop'];
|
496
|
+
/**
|
497
|
+
* If enabled, moving to the next item from the last one in a row or column
|
498
|
+
* will focus on the first item in the next row or column and vice-versa.
|
499
|
+
* `true` wraps between rows and columns, `horizontal` wraps only between rows, and `vertical` wraps only between columns.
|
500
|
+
*
|
501
|
+
* @default false
|
502
|
+
*/
|
503
|
+
focusWrap?: MenuProviderProps$1['focusWrap'];
|
504
|
+
}>;
|
505
|
+
/**
|
506
|
+
* **🏗️ A Menu Provider component**
|
507
|
+
*
|
508
|
+
* @componentType Server component
|
509
|
+
*
|
510
|
+
* @description
|
511
|
+
* A provider component for the menu, which is used to provide the menu context to the menu items.
|
512
|
+
*
|
513
|
+
* @see The {@link https://uds.build/docs/components/menu-provider Menu.Provider Docs} for more info
|
514
|
+
*
|
515
|
+
* @example
|
516
|
+
* ```tsx
|
517
|
+
* 'use client'; // Next.js client component
|
518
|
+
*
|
519
|
+
* import { Menu, Button } from "@yahoo/uds";
|
520
|
+
* import { Calendar, Clipboard } from "@yahoo/uds-icons";
|
521
|
+
*
|
522
|
+
* export function MenuProviderExample() {
|
523
|
+
* return (
|
524
|
+
* <Menu.Provider>
|
525
|
+
* <Menu.Trigger asChild>
|
526
|
+
* <Button>Menu Options</Button>
|
527
|
+
* </Menu.Trigger>
|
528
|
+
* <Menu.Content>
|
529
|
+
* <Menu.Item startIcon={Calendar}>Calendar</Menu.Item>
|
530
|
+
* <Menu.Item startIcon={Clipboard} endIcon={DiagonalRightUp}>
|
531
|
+
* Clipboard
|
532
|
+
* </Menu.Item>
|
533
|
+
* <Menu.Item active>Active Item</Menu.Item>
|
534
|
+
* </Menu.Content>
|
535
|
+
* </Menu.Provider>
|
536
|
+
* )
|
537
|
+
* }
|
538
|
+
* ```
|
539
|
+
*
|
540
|
+
* @usage
|
541
|
+
* Use MenuItem for standard menu options that trigger actions or navigate to other parts of the application.
|
542
|
+
* The active prop can be used to highlight the currently selected item.
|
543
|
+
*
|
544
|
+
* @related [Menu](https://uds.build/docs/components/menu), [Menu.ItemCheckbox](https://uds.build/docs/components/menu-item-checkbox)
|
545
|
+
**/
|
546
|
+
declare const MenuProvider: ({ placement, rtl: explicitRtl, ...props }: MenuProviderProps) => react_jsx_runtime.JSX.Element;
|
547
|
+
|
548
|
+
interface MenuTriggerProps extends PressableProps {
|
549
|
+
/**
|
550
|
+
* When asChild is set to true, the component's child will be cloned and passed
|
551
|
+
* the props and behavior required to make it functional.
|
552
|
+
*/
|
553
|
+
asChild?: BoxProps['asChild'];
|
554
|
+
/**
|
555
|
+
* Object returned by the [`useMenuStore`](https://ariakit.org/reference/use-menu-store) hook.
|
556
|
+
* If not provided, the closest [`Menu.Content`](https://uds.build/docs/components/menu#menu-content) or
|
557
|
+
* [`Menu.Provider`](https://uds.build/docs/components/menu#menu-provider) context will be used.
|
558
|
+
*/
|
559
|
+
store?: MenuButtonProps['store'];
|
560
|
+
/**
|
561
|
+
* Determines if [Focusable](https://ariakit.org/components/focusable)
|
562
|
+
* features should be active on non-native focusable elements.
|
563
|
+
*
|
564
|
+
* **Note**: This prop only turns off the additional features provided by the
|
565
|
+
* [`Focusable`](https://ariakit.org/reference/focusable) component.
|
566
|
+
* Non-native focusable elements will lose their focusability entirely.
|
567
|
+
* However, native focusable elements will retain their inherent focusability,
|
568
|
+
* but without added features such as improved
|
569
|
+
* [`autoFocus`](https://ariakit.org/reference/focusable#autofocus),
|
570
|
+
* [`accessibleWhenDisabled`](https://ariakit.org/reference/focusable#accessiblewhendisabled),
|
571
|
+
* [`onFocusVisible`](https://ariakit.org/reference/focusable#onfocusvisible),
|
572
|
+
* etc.
|
573
|
+
* @default true
|
574
|
+
*/
|
575
|
+
focusable?: MenuButtonProps['focusable'];
|
576
|
+
}
|
577
|
+
/**
|
578
|
+
* **⚡ A Menu Trigger component**
|
579
|
+
*
|
580
|
+
* @componentType Server component
|
581
|
+
*
|
582
|
+
* @description
|
583
|
+
* A trigger component for the menu, which is used to toggle the menus open state.
|
584
|
+
*
|
585
|
+
* @see The {@link https://uds.build/docs/components/menu-trigger Menu.Trigger Docs} for more info
|
586
|
+
*
|
587
|
+
* @example
|
588
|
+
* ```tsx
|
589
|
+
* 'use client'; // Next.js client component
|
590
|
+
*
|
591
|
+
* import { Menu, Button } from "@yahoo/uds";
|
592
|
+
* import { Calendar, Clipboard } from "@yahoo/uds-icons";
|
593
|
+
*
|
594
|
+
* export function MenuProviderExample() {
|
595
|
+
* return (
|
596
|
+
* <Menu.Provider>
|
597
|
+
* <Menu.Trigger asChild>
|
598
|
+
* <Button>Menu Options</Button>
|
599
|
+
* </Menu.Trigger>
|
600
|
+
* <Menu.Content>
|
601
|
+
* <Menu.Item startIcon={Calendar}>Calendar</Menu.Item>
|
602
|
+
* <Menu.Item startIcon={Clipboard} endIcon={DiagonalRightUp}>
|
603
|
+
* Clipboard
|
604
|
+
* </Menu.Item>
|
605
|
+
* <Menu.Item active>Active Item</Menu.Item>
|
606
|
+
* </Menu.Content>
|
607
|
+
* </Menu.Provider>
|
608
|
+
* )
|
609
|
+
* }
|
610
|
+
* ```
|
611
|
+
*
|
612
|
+
* @usage
|
613
|
+
* Use MenuTrigger to toggle the open state of a menu.
|
614
|
+
*
|
615
|
+
* @related [Menu](https://uds.build/docs/components/menu), [Menu.ItemCheckbox](https://uds.build/docs/components/menu-item-checkbox)
|
616
|
+
**/
|
617
|
+
declare const MenuTrigger: react.ForwardRefExoticComponent<MenuTriggerProps & react.RefAttributes<HTMLButtonElement>>;
|
618
|
+
|
619
|
+
declare const Menu_index_useMenuContext: typeof useMenuContext;
|
620
|
+
declare const Menu_index_useMenuStore: typeof useMenuStore;
|
621
|
+
declare const Menu_index_useStoreState: typeof useStoreState;
|
622
|
+
declare namespace Menu_index {
|
623
|
+
export { MenuContent as Content, MenuDivider as Divider, MenuItem as Item, MenuItemCheckbox as ItemCheckbox, MenuProvider as Provider, MenuTrigger as Trigger, Menu_index_useMenuContext as useMenuContext, Menu_index_useMenuStore as useMenuStore, Menu_index_useStoreState as useStoreState };
|
624
|
+
}
|
625
|
+
|
626
|
+
export { Menu_index as Menu, type MenuContentProps, type MenuDividerProps, type MenuItemCheckboxProps, type MenuItemProps, type MenuPlacement, type MenuProviderProps, type MenuTriggerProps };
|
@@ -0,0 +1,3 @@
|
|
1
|
+
"use client";
|
2
|
+
import{Divider as r}from"../chunk-MO2VPSXU.js";import{Pressable as a,a as e,SpringMotionConfig as d}from"../chunk-PNR3372L.js";import{VStack as t,cx as s,getStyles as i,Box as c,HStack as n,IconSlot as o}from"../chunk-3WLIHKQU.js";import"../chunk-EE3DM7SS.js";import"../chunk-EWJ3J526.js";import"../chunk-GSO3MC65.js";import"../chunk-4G4TBHHL.js";import{__export as u}from"../chunk-S5UKKXRV.js";import{useMenuStore as l,useMenuContext as m,Menu as x,MenuItem as p,MenuItemCheckbox as h,MenuProvider as b,MenuButton as f}from"@ariakit/react/menu";import{useStoreState as _}from"@ariakit/react-core/utils/store";import{spacingMap as v}from"@yahoo/uds/fixtures";import{m as g,AnimatePresence as I}from"motion/react";import{forwardRef as k,useState as w,useEffect as C,useMemo as N,Children as y,useRef as V,useCallback as S}from"react";import{jsx as E,jsxs as M}from"react/jsx-runtime";import{useStoreState as R}from"@ariakit/react";/*! © 2025 Yahoo, Inc. UDS v0.0.0-development */
|
3
|
+
var j={};u(j,{Content:()=>B,Divider:()=>W,Item:()=>$,ItemCheckbox:()=>F,Provider:()=>U,Trigger:()=>J,useMenuContext:()=>m,useMenuStore:()=>l,useStoreState:()=>R});var z=g.create(t),T=5,P=.97,A={top:{x:0,y:T},bottom:{x:0,y:-5},left:{x:T,y:0},right:{x:-5,y:0}},H=r=>N((()=>((r="bottom")=>{const[a="top"]=r?.split("-");return{closed:{...A[a],opacity:0,scale:P},open:{y:0,x:0,opacity:1,scale:1}}})(r)),[r]),B=k((function({gap:r,spacing:a,spacingBottom:e,spacingEnd:d,spacingStart:t,spacingTop:i,gutter:c="1",backgroundColor:n="primary",borderRadius:o="md",borderColor:u,borderWidth:l="thin",overflow:p,dropShadow:h="lg",className:b,sameWidth:f,focusable:g,children:k,portalElement:y,portal:V=!0,disableAutoBorderRadius:S,...M},R){const j=m(),T=_(j,"open"),P=_(j,"mounted"),A=_(j,"currentPlacement"),B=_(j,"placement"),[W,D]=w(A),[G,L]=w(A);C((()=>{B!==G&&L(B)}),[B]),C((()=>{A!==G&&L(A)}),[A]),C((()=>{P&&G!==W&&D(G)}),[P,G,W]);const $=N((()=>T&&P?"open":"closed"),[T,P]),F=N((()=>T?h:"none"),[T,h]),K=H(G),O=(({borderRadius:r,spacing:a})=>{if(void 0===a||"0"===a)switch(r){case"xs":return"[&>*:first-child]:rounded-t-[calc(var(--uds-border-radius-xs)_-_var(--uds-border-width-thin))] [&>*:last-child]:rounded-b-[calc(var(--uds-border-radius-xs)_-_var(--uds-border-width-thin))]";case"sm":return"[&>*:first-child]:rounded-t-[calc(var(--uds-border-radius-sm)_-_var(--uds-border-width-thin))] [&>*:last-child]:rounded-b-[calc(var(--uds-border-radius-sm)_-_var(--uds-border-width-thin))]";case"md":return"[&>*:first-child]:rounded-t-[calc(var(--uds-border-radius-md)_-_var(--uds-border-width-thin))] [&>*:last-child]:rounded-b-[calc(var(--uds-border-radius-md)_-_var(--uds-border-width-thin))]";case"lg":return"[&>*:first-child]:rounded-t-[calc(var(--uds-border-radius-lg)_-_var(--uds-border-width-thin))] [&>*:last-child]:rounded-b-[calc(var(--uds-border-radius-lg)_-_var(--uds-border-width-thin))]";case"xl":return"[&>*:first-child]:rounded-t-[calc(var(--uds-border-radius-xl)_-_var(--uds-border-width-thin))] [&>*:last-child]:rounded-b-[calc(var(--uds-border-radius-xl)_-_var(--uds-border-width-thin))]"}if("px"===a||"0.5"===a)switch(r){case"xs":return"[&>*:first-child]:rounded-t-[max(1px,calc(var(--uds-border-radius-xs)_-_2px))] [&>*:last-child]:rounded-b-[max(1px,calc(var(--uds-border-radius-xs)_-_2px))]";case"sm":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-sm)_-_2px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-sm)_-_2px))]";case"md":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-md)_-_2px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-md)_-_2px))]";case"lg":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-lg)_-_2px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-lg)_-_2px))]";case"xl":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-xl)_-_2px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-xl)_-_2px))]"}if("1"===a||"1.5"===a)switch(r){case"xs":return"[&>*:first-child]:rounded-t-[max(1px,calc(var(--uds-border-radius-xs)_-_4px))] [&>*:last-child]:rounded-b-[max(1px,calc(var(--uds-border-radius-xs)_-_4px))]";case"sm":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-sm)_-_4px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-sm)_-_4px))]";case"md":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-md)_-_4px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-md)_-_4px))]";case"lg":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-lg)_-_4px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-lg)_-_4px))]";case"xl":return"[&>*:first-child]:rounded-t-[calc(var(--uds-border-radius-xl)_-_4px)] [&>*:last-child]:rounded-b-[calc(var(--uds-border-radius-xl)_-_4px)]"}if("2"===a||"2.5"===a)switch(r){case"xs":return"[&>*:first-child]:rounded-t-[max(1px,calc(var(--uds-border-radius-xs)_-_8px))] [&>*:last-child]:rounded-b-[max(1px,calc(var(--uds-border-radius-xs)_-_8px))]";case"sm":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-sm)_-_8px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-sm)_-_8px))]";case"md":return"[&>*:first-child]:rounded-t-[max(4px,calc(var(--uds-border-radius-md)_-_8px))] [&>*:last-child]:rounded-b-[max(4px,calc(var(--uds-border-radius-md)_-_8px))]";case"lg":return"[&>*:first-child]:rounded-t-[max(4px,calc(var(--uds-border-radius-lg)_-_8px))] [&>*:last-child]:rounded-b-[max(4px,calc(var(--uds-border-radius-lg)_-_8px))]";case"xl":return"[&>*:first-child]:rounded-t-[calc(var(--uds-border-radius-xl)_-_8px)] [&>*:last-child]:rounded-b-[calc(var(--uds-border-radius-xl)_-_8px)]"}if("3"===a||"3.5"===a)switch(r){case"xs":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-xs)_-_6px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-xs)_-_6px))]";case"sm":return"[&>*:first-child]:rounded-t-[max(4px,calc(var(--uds-border-radius-sm)_-_6px))] [&>*:last-child]:rounded-b-[max(4px,calc(var(--uds-border-radius-sm)_-_6px))]";case"md":return"[&>*:first-child]:rounded-t-[max(6px,calc(var(--uds-border-radius-md)_-_6px))] [&>*:last-child]:rounded-b-[max(6px,calc(var(--uds-border-radius-md)_-_6px))]";case"lg":return"[&>*:first-child]:rounded-t-[max(6px,calc(var(--uds-border-radius-lg)_-_6px))] [&>*:last-child]:rounded-b-[max(6px,calc(var(--uds-border-radius-lg)_-_6px))]";case"xl":return"[&>*:first-child]:rounded-t-[min(20px,calc(var(--uds-border-radius-xl)_-_6px))] [&>*:last-child]:rounded-b-[min(20px,calc(var(--uds-border-radius-xl)_-_6px))]"}if("4"===a)switch(r){case"xs":return"[&>*:first-child]:rounded-t-[max(1px,calc(var(--uds-border-radius-xs)_-_16px))] [&>*:last-child]:rounded-b-[max(1px,calc(var(--uds-border-radius-xs)_-_16px))]";case"sm":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-sm)_-_16px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-sm)_-_16px))]";case"md":return"[&>*:first-child]:rounded-t-[max(4px,calc(var(--uds-border-radius-md)_-_16px))] [&>*:last-child]:rounded-b-[max(4px,calc(var(--uds-border-radius-md)_-_16px))]";case"lg":return"[&>*:first-child]:rounded-t-[max(6px,calc(var(--uds-border-radius-lg)_-_16px))] [&>*:last-child]:rounded-b-[max(6px,calc(var(--uds-border-radius-lg)_-_16px))]";case"xl":return"[&>*:first-child]:rounded-t-[max(6px,calc(var(--uds-border-radius-xl)_-_16px))] [&>*:last-child]:rounded-b-[max(6px,calc(var(--uds-border-radius-xl)_-_16px))]"}switch(r){case"xs":return"[&>*:first-child]:rounded-t-[max(1px,calc(var(--uds-border-radius-xs)_-_4px))] [&>*:last-child]:rounded-b-[max(1px,calc(var(--uds-border-radius-xs)_-_4px))]";case"sm":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-sm)_-_4px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-sm)_-_4px))]";case"md":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-md)_-_4px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-md)_-_4px))]";case"lg":return"[&>*:first-child]:rounded-t-[max(2px,calc(var(--uds-border-radius-lg)_-_4px))] [&>*:last-child]:rounded-b-[max(2px,calc(var(--uds-border-radius-lg)_-_4px))]";case"xl":return"[&>*:first-child]:rounded-t-[min(18px,calc(var(--uds-border-radius-xl)_-_4px))] [&>*:last-child]:rounded-b-[min(18px,calc(var(--uds-border-radius-xl)_-_4px))]"}})({borderRadius:o,spacing:a}),U=N((()=>v[c]),[c]);return E(I,{initial:!1,children:E(x,{gutter:U,sameWidth:f,focusable:g,store:j,ref:R,portalElement:y,portal:V,...M,render:E(z,{backgroundColor:n,gap:r,spacing:a,spacingBottom:e,spacingEnd:d,spacingStart:t,spacingTop:i,borderRadius:o,borderColor:u,borderWidth:l,overflow:p,animate:$,variants:K,dropShadow:F,className:s("uds-menu-content","transition-shadow","duration-200","ease-in-out","min-w-60","max-w-lg","max-h-96","overflow-auto","uds-ring","z-10","group",!S&&O,b),children:k})})})})),W=k((function({role:a="separator",contentPosition:e="start",gap:d="4",children:t,spacingVertical:s=(t?"2":"0"),spacingHorizontal:c=(t?"4":"0"),className:n,...o},u){const l={root:i({menuDividerVariantRoot:"default",className:n}),text:i({menuDividerVariantText:"default"})};return E(r,{ref:u,role:a,variant:"inherit",contentPosition:e,gap:d,spacingVertical:s,spacingHorizontal:c,className:l.root,layerClassNames:l,...o,children:t})}));W.displayName="MenuDivider";var D="uds-menu-item",G={visible:{scale:1,opacity:1},hidden:{scale:.7,opacity:0}},L=k((function({spacing:r="0",spacingBottom:e,spacingEnd:d,spacingHorizontal:t="4",spacingStart:u,spacingTop:l,spacingVertical:m="3.5",columnGap:x="2",className:p,children:h,endIcon:b,startIcon:f,hideEndIcon:_,active:v,disabled:k,as:w,rootProps:C,name:V,alignItems:S="center",justifyContent:R="space-between",layerClassNames:j,...z},T){const P=y.count(h)>1,A=(({active:r,disabled:a,className:e})=>s(D,"focus-visible:text-brand","focus-visible:bg-brand-secondary","focus-visible:z-10","uds-ring","!-outline-offset-2",r&&["[&:not([aria-checked])]:cursor-default"],a&&"opacity-25 cursor-not-allowed","duration-20 transition-[font-variation-settings] ease-in-out","z-0",e))({active:v,disabled:k,className:p}),H=i({className:s(`${D}-content truncate`,j?.text),textAlign:"start",...P&&{columnGap:x,display:"flex",alignItems:"center",width:"full",justifyContent:"space-between"}}),B=N((()=>({root:i({menuSizeRoot:"default",className:s(j?.root,A)}),startIcon:i({menuSizeStartIcon:"default",className:j?.startIcon}),endIcon:i({menuSizeEndIcon:"default",className:j?.endIcon})})),[j,A]);return E(c,{asChild:!0,spacing:r,spacingBottom:e,spacingEnd:d,spacingHorizontal:t,spacingStart:u,spacingTop:l,spacingVertical:m,columnGap:x,className:B.root,alignItems:S,justifyContent:R,children:M(w,{render:E(a,{ref:T,...z}),name:V??"",disabled:k,...C,children:[M(n,{gap:x,alignItems:"center",width:"full",children:[E(I,{initial:!1,children:f&&E(g.span,{variants:G,initial:"hidden",animate:"visible",exit:"hidden",className:"uds-start-icon",children:E(o,{icon:f,className:B.startIcon,iconProps:{size:"sm",variant:v?"fill":"outline",color:"current"}})})}),E("span",{className:H,children:h})]}),E(I,{initial:!1,mode:"popLayout",children:!_&&b&&E(g.span,{variants:G,initial:"hidden",animate:"visible",exit:"hidden",className:"uds-end-icon",children:E(o,{icon:b,className:B.endIcon,iconProps:{size:"sm",variant:v?"fill":"outline",color:"current"}})})})]})})})),$=k((function({active:r,...a},e){const d={root:i({menuItemVariantRoot:"default",menuItemVariantActiveRoot:r?"on":"off"}),text:i({menuItemVariantText:"default",menuItemVariantActiveText:r?"on":"off"}),startIcon:i({menuItemVariantIcon:"default",menuItemVariantActiveIcon:r?"on":"off"})};return E(L,{ref:e,as:p,active:r,layerClassNames:d,...a})}));$.displayName="MenuItem";var F=k((function({name:r,endIcon:a=e,checked:d,defaultChecked:t,className:c,...n},o){const u=r,l=V(!1),x=m(),p=R(x);C((()=>{!l.current&&void 0!==t&&x&&(x.setValues((r=>({...r,[u]:t}))),l.current=!0)}),[x,t,u]);const b=N((()=>{if(void 0!==d)return d;if(p?.items?.length){const r=p?.items.find((r=>r.element?.name===u));if(r?.element)return r.element.checked}const r=p?.values[u];return"boolean"==typeof r?r:t??!1}),[p?.items,p?.values,u,d,t]),f=S((r=>{void 0===d&&x?.setValues((a=>({...a,[u]:r.target.checked})))}),[u,x,d]),_={root:i({menuItemCheckboxVariantRoot:"default",menuItemCheckboxVariantActiveRoot:b?"on":"off"}),text:i({menuItemCheckboxVariantText:"default",menuItemCheckboxVariantActiveText:b?"on":"off"}),startIcon:i({menuItemCheckboxVariantStartIcon:"default",menuItemCheckboxVariantActiveStartIcon:b?"on":"off"}),endIcon:i({menuItemCheckboxVariantEndIcon:"default",menuItemCheckboxVariantActiveEndIcon:b?"on":"off"})};return E(L,{ref:o,as:h,hideEndIcon:!b,endIcon:a,active:b,className:s("uds-menu-item-checkbox",c),layerClassNames:_,rootProps:{name:r,onChange:f,defaultChecked:t,checked:void 0!==d?d:void 0},...n})}));F.displayName="MenuItemCheckbox";var K=()=>{if("undefined"==typeof document)return!1;return"rtl"===getComputedStyle(document.documentElement).direction},O=r=>{const[a,e]=w(K);return C((()=>{if(r?.explicit)return void e(r.explicit);const a=(r=>{const a=new MutationObserver((a=>{a.some((r=>"attributes"===r.type&&"dir"===r.attributeName))&&r()}));return a.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}),a})((()=>{e(K())}));return()=>a.disconnect()}),[r?.explicit]),a},U=function({placement:r="bottom",rtl:a,...e}){const t=O({explicit:a}),s=((r,a)=>{const e=a?.rtl;if("start"===r)return e?"right":"left";if("end"===r)return e?"left":"right";if(r?.includes("-")){const[a,d]=r.split("-");if(!("start"!==a&&"end"!==a||"top"!==d&&"bottom"!==d))return`${"start"===a?e?"right":"left":e?"left":"right"}-${"bottom"===d?"end":"start"}`;if("top"===a||"bottom"===a)return`${a}-${"start"===d?e?"end":"start":e?"start":"end"}`}return r})(r,{rtl:t});return E(d,{children:E(b,{placement:s,rtl:t,...e})})},J=k((function({asChild:r,className:a,...e},d){const t=V(null),i=r?E(c,{ref:t,className:"uds-ring h-fit w-fit"}):void 0,n=S((()=>{const r=t.current?.firstChild;r instanceof HTMLElement&&"function"==typeof r.focus&&r.focus()}),[t]);return E(f,{onFocus:n,onFocusVisible:n,ref:d,render:i,className:s("uds-menu-trigger",a),...e})}));export{j as Menu};
|