@yamada-ui/menu 0.2.10 → 0.2.11

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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  MenuGroup
3
- } from "./chunk-YDLVWG5I.mjs";
3
+ } from "./chunk-QBVCLEL4.mjs";
4
4
  import {
5
5
  MenuOptionItem
6
- } from "./chunk-7YDTXOPR.mjs";
6
+ } from "./chunk-PVB36WH4.mjs";
7
7
 
8
8
  // src/menu-option-group.tsx
9
9
  import { useControllableState } from "@yamada-ui/use-controllable-state";
@@ -11,7 +11,13 @@ import { cx, getValidChildren, omitObject, isArray } from "@yamada-ui/utils";
11
11
  import { cloneElement, forwardRef, useCallback } from "react";
12
12
  import { jsx } from "react/jsx-runtime";
13
13
  var MenuOptionGroup = forwardRef(
14
- ({ className, defaultValue, type, children, ...rest }, ref) => {
14
+ ({
15
+ className,
16
+ defaultValue,
17
+ type,
18
+ children,
19
+ ...rest
20
+ }, ref) => {
15
21
  const isRadio = type === "radio";
16
22
  defaultValue = isRadio ? "" : [];
17
23
  const [value, setValue] = useControllableState({
@@ -0,0 +1,72 @@
1
+ import {
2
+ useMenu,
3
+ useMenuDescendantsContext
4
+ } from "./chunk-DB6N4OUS.mjs";
5
+
6
+ // src/menu-list.tsx
7
+ import { forwardRef } from "@yamada-ui/core";
8
+ import { PopoverContent } from "@yamada-ui/popover";
9
+ import { cx, handlerAll, mergeRefs } from "@yamada-ui/utils";
10
+ import { useCallback } from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ var MenuList = forwardRef(
13
+ ({ className, ...rest }, ref) => {
14
+ const { menuRef, focusedIndex, setFocusedIndex, onClose, styles } = useMenu();
15
+ const descendants = useMenuDescendantsContext();
16
+ const onNext = useCallback(() => {
17
+ const next = descendants.enabledNextValue(focusedIndex);
18
+ if (next)
19
+ setFocusedIndex(next.index);
20
+ }, [descendants, focusedIndex, setFocusedIndex]);
21
+ const onPrev = useCallback(() => {
22
+ const prev = descendants.enabledPrevValue(focusedIndex);
23
+ if (prev)
24
+ setFocusedIndex(prev.index);
25
+ }, [descendants, focusedIndex, setFocusedIndex]);
26
+ const onFirst = useCallback(() => {
27
+ const first = descendants.enabledfirstValue();
28
+ if (first)
29
+ setFocusedIndex(first.index);
30
+ }, [descendants, setFocusedIndex]);
31
+ const onLast = useCallback(() => {
32
+ const last = descendants.enabledlastValue();
33
+ if (last)
34
+ setFocusedIndex(last.index);
35
+ }, [descendants, setFocusedIndex]);
36
+ const onKeyDown = useCallback(
37
+ (ev) => {
38
+ const actions = {
39
+ Tab: (ev2) => ev2.preventDefault(),
40
+ Escape: onClose,
41
+ ArrowDown: focusedIndex === -1 ? onFirst : onNext,
42
+ ArrowUp: focusedIndex === -1 ? onLast : onPrev,
43
+ Home: onFirst,
44
+ End: onLast
45
+ };
46
+ const action = actions[ev.key];
47
+ if (!action)
48
+ return;
49
+ ev.preventDefault();
50
+ action(ev);
51
+ },
52
+ [focusedIndex, onClose, onFirst, onLast, onNext, onPrev]
53
+ );
54
+ const css = { ...styles.list };
55
+ return /* @__PURE__ */ jsx(
56
+ PopoverContent,
57
+ {
58
+ ref: mergeRefs(menuRef, ref),
59
+ className: cx("ui-menu-list", className),
60
+ role: "menu",
61
+ tabIndex: -1,
62
+ __css: css,
63
+ ...rest,
64
+ onKeyDown: handlerAll(rest.onKeyDown, onKeyDown)
65
+ }
66
+ );
67
+ }
68
+ );
69
+
70
+ export {
71
+ MenuList
72
+ };
@@ -1,10 +1,21 @@
1
1
  // src/menu.tsx
2
- import { useMultiComponentStyle, omitThemeProps } from "@yamada-ui/core";
2
+ import {
3
+ useMultiComponentStyle,
4
+ omitThemeProps
5
+ } from "@yamada-ui/core";
3
6
  import { Popover } from "@yamada-ui/popover";
4
7
  import { createDescendant } from "@yamada-ui/use-descendant";
5
8
  import { useDisclosure } from "@yamada-ui/use-disclosure";
6
- import { createContext, useUnmountEffect, useUpdateEffect } from "@yamada-ui/utils";
7
- import { useCallback, useRef, useState } from "react";
9
+ import {
10
+ createContext,
11
+ useUnmountEffect,
12
+ useUpdateEffect
13
+ } from "@yamada-ui/utils";
14
+ import {
15
+ useCallback,
16
+ useRef,
17
+ useState
18
+ } from "react";
8
19
  import { jsx } from "react/jsx-runtime";
9
20
  var {
10
21
  DescendantsContextProvider,
@@ -30,10 +41,12 @@ var Menu = (props) => {
30
41
  const menuRef = useRef(null);
31
42
  const timeoutIds = useRef(/* @__PURE__ */ new Set([]));
32
43
  const onFocusMenu = useCallback(() => {
33
- requestAnimationFrame(() => {
34
- var _a;
35
- return (_a = menuRef.current) == null ? void 0 : _a.focus({ preventScroll: false });
36
- });
44
+ requestAnimationFrame(
45
+ () => {
46
+ var _a;
47
+ return (_a = menuRef.current) == null ? void 0 : _a.focus({ preventScroll: false });
48
+ }
49
+ );
37
50
  }, []);
38
51
  const onFocusFirstItem = useCallback(() => {
39
52
  const id = setTimeout(() => {
@@ -60,7 +73,10 @@ var Menu = (props) => {
60
73
  (_a = rest.onOpen) == null ? void 0 : _a.call(rest);
61
74
  onFocusMenu();
62
75
  }, [onFocusMenu, rest]);
63
- const { isOpen, onOpen, onClose } = useDisclosure({ ...props, onOpen: onOpenInternal });
76
+ const { isOpen, onOpen, onClose } = useDisclosure({
77
+ ...props,
78
+ onOpen: onOpenInternal
79
+ });
64
80
  useUpdateEffect(() => {
65
81
  if (!isOpen)
66
82
  setFocusedIndex(-1);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useMenu
3
- } from "./chunk-6IUWMOKW.mjs";
3
+ } from "./chunk-DB6N4OUS.mjs";
4
4
 
5
5
  // src/menu-divider.tsx
6
6
  import { ui, forwardRef } from "@yamada-ui/core";
@@ -9,7 +9,15 @@ import { jsx } from "react/jsx-runtime";
9
9
  var MenuDivider = forwardRef(({ className, ...rest }, ref) => {
10
10
  const { styles } = useMenu();
11
11
  const css = { ...styles.divider };
12
- return /* @__PURE__ */ jsx(ui.hr, { ref, className: cx("ui-menu-divider", className), __css: css, ...rest });
12
+ return /* @__PURE__ */ jsx(
13
+ ui.hr,
14
+ {
15
+ ref,
16
+ className: cx("ui-menu-divider", className),
17
+ __css: css,
18
+ ...rest
19
+ }
20
+ );
13
21
  });
14
22
 
15
23
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useMenu,
3
3
  useMenuDescendant
4
- } from "./chunk-6IUWMOKW.mjs";
4
+ } from "./chunk-DB6N4OUS.mjs";
5
5
 
6
6
  // src/menu-item.tsx
7
7
  import { ui, forwardRef } from "@yamada-ui/core";
@@ -14,7 +14,10 @@ import {
14
14
  mergeRefs,
15
15
  useUpdateEffect
16
16
  } from "@yamada-ui/utils";
17
- import { useCallback, useRef } from "react";
17
+ import {
18
+ useCallback,
19
+ useRef
20
+ } from "react";
18
21
  import { jsx, jsxs } from "react/jsx-runtime";
19
22
  var isTargetMenuItem = (target) => {
20
23
  var _a;
@@ -137,23 +140,43 @@ var MenuOptionItem = forwardRef(
137
140
  );
138
141
  }
139
142
  );
140
- var MenuIcon = forwardRef(({ className, ...rest }, ref) => {
141
- const { styles } = useMenu();
142
- const css = {
143
- flexShrink: 0,
144
- display: "inline-flex",
145
- justifyContent: "center",
146
- alignItems: "center",
147
- fontSize: "0.85em",
148
- ...styles.icon
149
- };
150
- return /* @__PURE__ */ jsx(ui.span, { ref, className: cx("ui-menu-icon", className), __css: css, ...rest });
151
- });
152
- var MenuCommand = forwardRef(({ className, ...rest }, ref) => {
153
- const { styles } = useMenu();
154
- const css = { ...styles.command };
155
- return /* @__PURE__ */ jsx(ui.span, { ref, className: cx("ui-menu-command", className), __css: css, ...rest });
156
- });
143
+ var MenuIcon = forwardRef(
144
+ ({ className, ...rest }, ref) => {
145
+ const { styles } = useMenu();
146
+ const css = {
147
+ flexShrink: 0,
148
+ display: "inline-flex",
149
+ justifyContent: "center",
150
+ alignItems: "center",
151
+ fontSize: "0.85em",
152
+ ...styles.icon
153
+ };
154
+ return /* @__PURE__ */ jsx(
155
+ ui.span,
156
+ {
157
+ ref,
158
+ className: cx("ui-menu-icon", className),
159
+ __css: css,
160
+ ...rest
161
+ }
162
+ );
163
+ }
164
+ );
165
+ var MenuCommand = forwardRef(
166
+ ({ className, ...rest }, ref) => {
167
+ const { styles } = useMenu();
168
+ const css = { ...styles.command };
169
+ return /* @__PURE__ */ jsx(
170
+ ui.span,
171
+ {
172
+ ref,
173
+ className: cx("ui-menu-command", className),
174
+ __css: css,
175
+ ...rest
176
+ }
177
+ );
178
+ }
179
+ );
157
180
  var CheckIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 14 14", width: "1em", height: "1em", children: /* @__PURE__ */ jsx(
158
181
  "polygon",
159
182
  {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useMenu
3
- } from "./chunk-6IUWMOKW.mjs";
3
+ } from "./chunk-DB6N4OUS.mjs";
4
4
 
5
5
  // src/menu-group.tsx
6
6
  import { ui, forwardRef } from "@yamada-ui/core";
@@ -19,7 +19,14 @@ var MenuGroup = forwardRef(
19
19
  __css: css,
20
20
  ...rest,
21
21
  children: [
22
- title ? /* @__PURE__ */ jsx(ui.span, { className: cx("ui-menu-group-title"), __css: styles.groupTitle, children: title }) : null,
22
+ title ? /* @__PURE__ */ jsx(
23
+ ui.span,
24
+ {
25
+ className: cx("ui-menu-group-title"),
26
+ __css: styles.groupTitle,
27
+ children: title
28
+ }
29
+ ) : null,
23
30
  children
24
31
  ]
25
32
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useMenu
3
- } from "./chunk-6IUWMOKW.mjs";
3
+ } from "./chunk-DB6N4OUS.mjs";
4
4
 
5
5
  // src/menu-button.tsx
6
6
  import { ui, forwardRef } from "@yamada-ui/core";
package/dist/index.js CHANGED
@@ -63,10 +63,12 @@ var Menu = (props) => {
63
63
  const menuRef = (0, import_react.useRef)(null);
64
64
  const timeoutIds = (0, import_react.useRef)(/* @__PURE__ */ new Set([]));
65
65
  const onFocusMenu = (0, import_react.useCallback)(() => {
66
- requestAnimationFrame(() => {
67
- var _a;
68
- return (_a = menuRef.current) == null ? void 0 : _a.focus({ preventScroll: false });
69
- });
66
+ requestAnimationFrame(
67
+ () => {
68
+ var _a;
69
+ return (_a = menuRef.current) == null ? void 0 : _a.focus({ preventScroll: false });
70
+ }
71
+ );
70
72
  }, []);
71
73
  const onFocusFirstItem = (0, import_react.useCallback)(() => {
72
74
  const id = setTimeout(() => {
@@ -93,7 +95,10 @@ var Menu = (props) => {
93
95
  (_a = rest.onOpen) == null ? void 0 : _a.call(rest);
94
96
  onFocusMenu();
95
97
  }, [onFocusMenu, rest]);
96
- const { isOpen, onOpen, onClose } = (0, import_use_disclosure.useDisclosure)({ ...props, onOpen: onOpenInternal });
98
+ const { isOpen, onOpen, onClose } = (0, import_use_disclosure.useDisclosure)({
99
+ ...props,
100
+ onOpen: onOpenInternal
101
+ });
97
102
  (0, import_utils.useUpdateEffect)(() => {
98
103
  if (!isOpen)
99
104
  setFocusedIndex(-1);
@@ -194,61 +199,63 @@ var import_popover3 = require("@yamada-ui/popover");
194
199
  var import_utils3 = require("@yamada-ui/utils");
195
200
  var import_react3 = require("react");
196
201
  var import_jsx_runtime3 = require("react/jsx-runtime");
197
- var MenuList = (0, import_core3.forwardRef)(({ className, ...rest }, ref) => {
198
- const { menuRef, focusedIndex, setFocusedIndex, onClose, styles } = useMenu();
199
- const descendants = useMenuDescendantsContext();
200
- const onNext = (0, import_react3.useCallback)(() => {
201
- const next = descendants.enabledNextValue(focusedIndex);
202
- if (next)
203
- setFocusedIndex(next.index);
204
- }, [descendants, focusedIndex, setFocusedIndex]);
205
- const onPrev = (0, import_react3.useCallback)(() => {
206
- const prev = descendants.enabledPrevValue(focusedIndex);
207
- if (prev)
208
- setFocusedIndex(prev.index);
209
- }, [descendants, focusedIndex, setFocusedIndex]);
210
- const onFirst = (0, import_react3.useCallback)(() => {
211
- const first = descendants.enabledfirstValue();
212
- if (first)
213
- setFocusedIndex(first.index);
214
- }, [descendants, setFocusedIndex]);
215
- const onLast = (0, import_react3.useCallback)(() => {
216
- const last = descendants.enabledlastValue();
217
- if (last)
218
- setFocusedIndex(last.index);
219
- }, [descendants, setFocusedIndex]);
220
- const onKeyDown = (0, import_react3.useCallback)(
221
- (ev) => {
222
- const actions = {
223
- Tab: (ev2) => ev2.preventDefault(),
224
- Escape: onClose,
225
- ArrowDown: focusedIndex === -1 ? onFirst : onNext,
226
- ArrowUp: focusedIndex === -1 ? onLast : onPrev,
227
- Home: onFirst,
228
- End: onLast
229
- };
230
- const action = actions[ev.key];
231
- if (!action)
232
- return;
233
- ev.preventDefault();
234
- action(ev);
235
- },
236
- [focusedIndex, onClose, onFirst, onLast, onNext, onPrev]
237
- );
238
- const css = { ...styles.list };
239
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
240
- import_popover3.PopoverContent,
241
- {
242
- ref: (0, import_utils3.mergeRefs)(menuRef, ref),
243
- className: (0, import_utils3.cx)("ui-menu-list", className),
244
- role: "menu",
245
- tabIndex: -1,
246
- __css: css,
247
- ...rest,
248
- onKeyDown: (0, import_utils3.handlerAll)(rest.onKeyDown, onKeyDown)
249
- }
250
- );
251
- });
202
+ var MenuList = (0, import_core3.forwardRef)(
203
+ ({ className, ...rest }, ref) => {
204
+ const { menuRef, focusedIndex, setFocusedIndex, onClose, styles } = useMenu();
205
+ const descendants = useMenuDescendantsContext();
206
+ const onNext = (0, import_react3.useCallback)(() => {
207
+ const next = descendants.enabledNextValue(focusedIndex);
208
+ if (next)
209
+ setFocusedIndex(next.index);
210
+ }, [descendants, focusedIndex, setFocusedIndex]);
211
+ const onPrev = (0, import_react3.useCallback)(() => {
212
+ const prev = descendants.enabledPrevValue(focusedIndex);
213
+ if (prev)
214
+ setFocusedIndex(prev.index);
215
+ }, [descendants, focusedIndex, setFocusedIndex]);
216
+ const onFirst = (0, import_react3.useCallback)(() => {
217
+ const first = descendants.enabledfirstValue();
218
+ if (first)
219
+ setFocusedIndex(first.index);
220
+ }, [descendants, setFocusedIndex]);
221
+ const onLast = (0, import_react3.useCallback)(() => {
222
+ const last = descendants.enabledlastValue();
223
+ if (last)
224
+ setFocusedIndex(last.index);
225
+ }, [descendants, setFocusedIndex]);
226
+ const onKeyDown = (0, import_react3.useCallback)(
227
+ (ev) => {
228
+ const actions = {
229
+ Tab: (ev2) => ev2.preventDefault(),
230
+ Escape: onClose,
231
+ ArrowDown: focusedIndex === -1 ? onFirst : onNext,
232
+ ArrowUp: focusedIndex === -1 ? onLast : onPrev,
233
+ Home: onFirst,
234
+ End: onLast
235
+ };
236
+ const action = actions[ev.key];
237
+ if (!action)
238
+ return;
239
+ ev.preventDefault();
240
+ action(ev);
241
+ },
242
+ [focusedIndex, onClose, onFirst, onLast, onNext, onPrev]
243
+ );
244
+ const css = { ...styles.list };
245
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
246
+ import_popover3.PopoverContent,
247
+ {
248
+ ref: (0, import_utils3.mergeRefs)(menuRef, ref),
249
+ className: (0, import_utils3.cx)("ui-menu-list", className),
250
+ role: "menu",
251
+ tabIndex: -1,
252
+ __css: css,
253
+ ...rest,
254
+ onKeyDown: (0, import_utils3.handlerAll)(rest.onKeyDown, onKeyDown)
255
+ }
256
+ );
257
+ }
258
+ );
252
259
 
253
260
  // src/menu-item.tsx
254
261
  var import_core4 = require("@yamada-ui/core");
@@ -377,23 +384,43 @@ var MenuOptionItem = (0, import_core4.forwardRef)(
377
384
  );
378
385
  }
379
386
  );
380
- var MenuIcon = (0, import_core4.forwardRef)(({ className, ...rest }, ref) => {
381
- const { styles } = useMenu();
382
- const css = {
383
- flexShrink: 0,
384
- display: "inline-flex",
385
- justifyContent: "center",
386
- alignItems: "center",
387
- fontSize: "0.85em",
388
- ...styles.icon
389
- };
390
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.span, { ref, className: (0, import_utils4.cx)("ui-menu-icon", className), __css: css, ...rest });
391
- });
392
- var MenuCommand = (0, import_core4.forwardRef)(({ className, ...rest }, ref) => {
393
- const { styles } = useMenu();
394
- const css = { ...styles.command };
395
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.span, { ref, className: (0, import_utils4.cx)("ui-menu-command", className), __css: css, ...rest });
396
- });
387
+ var MenuIcon = (0, import_core4.forwardRef)(
388
+ ({ className, ...rest }, ref) => {
389
+ const { styles } = useMenu();
390
+ const css = {
391
+ flexShrink: 0,
392
+ display: "inline-flex",
393
+ justifyContent: "center",
394
+ alignItems: "center",
395
+ fontSize: "0.85em",
396
+ ...styles.icon
397
+ };
398
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
399
+ import_core4.ui.span,
400
+ {
401
+ ref,
402
+ className: (0, import_utils4.cx)("ui-menu-icon", className),
403
+ __css: css,
404
+ ...rest
405
+ }
406
+ );
407
+ }
408
+ );
409
+ var MenuCommand = (0, import_core4.forwardRef)(
410
+ ({ className, ...rest }, ref) => {
411
+ const { styles } = useMenu();
412
+ const css = { ...styles.command };
413
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
414
+ import_core4.ui.span,
415
+ {
416
+ ref,
417
+ className: (0, import_utils4.cx)("ui-menu-command", className),
418
+ __css: css,
419
+ ...rest
420
+ }
421
+ );
422
+ }
423
+ );
397
424
  var CheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { viewBox: "0 0 14 14", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
398
425
  "polygon",
399
426
  {
@@ -419,7 +446,14 @@ var MenuGroup = (0, import_core5.forwardRef)(
419
446
  __css: css,
420
447
  ...rest,
421
448
  children: [
422
- title ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.span, { className: (0, import_utils5.cx)("ui-menu-group-title"), __css: styles.groupTitle, children: title }) : null,
449
+ title ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
450
+ import_core5.ui.span,
451
+ {
452
+ className: (0, import_utils5.cx)("ui-menu-group-title"),
453
+ __css: styles.groupTitle,
454
+ children: title
455
+ }
456
+ ) : null,
423
457
  children
424
458
  ]
425
459
  }
@@ -433,7 +467,13 @@ var import_utils6 = require("@yamada-ui/utils");
433
467
  var import_react5 = require("react");
434
468
  var import_jsx_runtime6 = require("react/jsx-runtime");
435
469
  var MenuOptionGroup = (0, import_react5.forwardRef)(
436
- ({ className, defaultValue, type, children, ...rest }, ref) => {
470
+ ({
471
+ className,
472
+ defaultValue,
473
+ type,
474
+ children,
475
+ ...rest
476
+ }, ref) => {
437
477
  const isRadio = type === "radio";
438
478
  defaultValue = isRadio ? "" : [];
439
479
  const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
@@ -483,7 +523,15 @@ var import_jsx_runtime7 = require("react/jsx-runtime");
483
523
  var MenuDivider = (0, import_core6.forwardRef)(({ className, ...rest }, ref) => {
484
524
  const { styles } = useMenu();
485
525
  const css = { ...styles.divider };
486
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core6.ui.hr, { ref, className: (0, import_utils7.cx)("ui-menu-divider", className), __css: css, ...rest });
526
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
527
+ import_core6.ui.hr,
528
+ {
529
+ ref,
530
+ className: (0, import_utils7.cx)("ui-menu-divider", className),
531
+ __css: css,
532
+ ...rest
533
+ }
534
+ );
487
535
  });
488
536
  // Annotate the CommonJS export names for ESM import in node:
489
537
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  MenuButton
3
- } from "./chunk-W3C6GCGE.mjs";
3
+ } from "./chunk-WXTXC73G.mjs";
4
4
  import {
5
5
  MenuDivider
6
- } from "./chunk-CSEIVNH6.mjs";
6
+ } from "./chunk-PLWLG3PU.mjs";
7
7
  import {
8
8
  MenuList
9
- } from "./chunk-47P6GKNZ.mjs";
9
+ } from "./chunk-C6C2WO75.mjs";
10
10
  import {
11
11
  MenuOptionGroup
12
- } from "./chunk-3IEZAEQF.mjs";
12
+ } from "./chunk-3RUBEAMY.mjs";
13
13
  import {
14
14
  MenuGroup
15
- } from "./chunk-YDLVWG5I.mjs";
15
+ } from "./chunk-QBVCLEL4.mjs";
16
16
  import {
17
17
  MenuItem,
18
18
  MenuOptionItem
19
- } from "./chunk-7YDTXOPR.mjs";
19
+ } from "./chunk-PVB36WH4.mjs";
20
20
  import {
21
21
  Menu
22
- } from "./chunk-6IUWMOKW.mjs";
22
+ } from "./chunk-DB6N4OUS.mjs";
23
23
  export {
24
24
  Menu,
25
25
  MenuButton,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MenuButton
3
- } from "./chunk-W3C6GCGE.mjs";
4
- import "./chunk-6IUWMOKW.mjs";
3
+ } from "./chunk-WXTXC73G.mjs";
4
+ import "./chunk-DB6N4OUS.mjs";
5
5
  export {
6
6
  MenuButton
7
7
  };
@@ -50,7 +50,15 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
50
50
  var MenuDivider = (0, import_core2.forwardRef)(({ className, ...rest }, ref) => {
51
51
  const { styles } = useMenu();
52
52
  const css = { ...styles.divider };
53
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.hr, { ref, className: (0, import_utils2.cx)("ui-menu-divider", className), __css: css, ...rest });
53
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
54
+ import_core2.ui.hr,
55
+ {
56
+ ref,
57
+ className: (0, import_utils2.cx)("ui-menu-divider", className),
58
+ __css: css,
59
+ ...rest
60
+ }
61
+ );
54
62
  });
55
63
  // Annotate the CommonJS export names for ESM import in node:
56
64
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MenuDivider
3
- } from "./chunk-CSEIVNH6.mjs";
4
- import "./chunk-6IUWMOKW.mjs";
3
+ } from "./chunk-PLWLG3PU.mjs";
4
+ import "./chunk-DB6N4OUS.mjs";
5
5
  export {
6
6
  MenuDivider
7
7
  };
@@ -60,7 +60,14 @@ var MenuGroup = (0, import_core2.forwardRef)(
60
60
  __css: css,
61
61
  ...rest,
62
62
  children: [
63
- title ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { className: (0, import_utils2.cx)("ui-menu-group-title"), __css: styles.groupTitle, children: title }) : null,
63
+ title ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
64
+ import_core2.ui.span,
65
+ {
66
+ className: (0, import_utils2.cx)("ui-menu-group-title"),
67
+ __css: styles.groupTitle,
68
+ children: title
69
+ }
70
+ ) : null,
64
71
  children
65
72
  ]
66
73
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MenuGroup
3
- } from "./chunk-YDLVWG5I.mjs";
4
- import "./chunk-6IUWMOKW.mjs";
3
+ } from "./chunk-QBVCLEL4.mjs";
4
+ import "./chunk-DB6N4OUS.mjs";
5
5
  export {
6
6
  MenuGroup
7
7
  };
package/dist/menu-item.js CHANGED
@@ -171,23 +171,43 @@ var MenuOptionItem = (0, import_core2.forwardRef)(
171
171
  );
172
172
  }
173
173
  );
174
- var MenuIcon = (0, import_core2.forwardRef)(({ className, ...rest }, ref) => {
175
- const { styles } = useMenu();
176
- const css = {
177
- flexShrink: 0,
178
- display: "inline-flex",
179
- justifyContent: "center",
180
- alignItems: "center",
181
- fontSize: "0.85em",
182
- ...styles.icon
183
- };
184
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { ref, className: (0, import_utils2.cx)("ui-menu-icon", className), __css: css, ...rest });
185
- });
186
- var MenuCommand = (0, import_core2.forwardRef)(({ className, ...rest }, ref) => {
187
- const { styles } = useMenu();
188
- const css = { ...styles.command };
189
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { ref, className: (0, import_utils2.cx)("ui-menu-command", className), __css: css, ...rest });
190
- });
174
+ var MenuIcon = (0, import_core2.forwardRef)(
175
+ ({ className, ...rest }, ref) => {
176
+ const { styles } = useMenu();
177
+ const css = {
178
+ flexShrink: 0,
179
+ display: "inline-flex",
180
+ justifyContent: "center",
181
+ alignItems: "center",
182
+ fontSize: "0.85em",
183
+ ...styles.icon
184
+ };
185
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
186
+ import_core2.ui.span,
187
+ {
188
+ ref,
189
+ className: (0, import_utils2.cx)("ui-menu-icon", className),
190
+ __css: css,
191
+ ...rest
192
+ }
193
+ );
194
+ }
195
+ );
196
+ var MenuCommand = (0, import_core2.forwardRef)(
197
+ ({ className, ...rest }, ref) => {
198
+ const { styles } = useMenu();
199
+ const css = { ...styles.command };
200
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
201
+ import_core2.ui.span,
202
+ {
203
+ ref,
204
+ className: (0, import_utils2.cx)("ui-menu-command", className),
205
+ __css: css,
206
+ ...rest
207
+ }
208
+ );
209
+ }
210
+ );
191
211
  var CheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { viewBox: "0 0 14 14", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
192
212
  "polygon",
193
213
  {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  MenuItem,
3
3
  MenuOptionItem
4
- } from "./chunk-7YDTXOPR.mjs";
5
- import "./chunk-6IUWMOKW.mjs";
4
+ } from "./chunk-PVB36WH4.mjs";
5
+ import "./chunk-DB6N4OUS.mjs";
6
6
  export {
7
7
  MenuItem,
8
8
  MenuOptionItem
package/dist/menu-list.js CHANGED
@@ -49,61 +49,63 @@ var [MenuProvider, useMenu] = (0, import_utils.createContext)({
49
49
 
50
50
  // src/menu-list.tsx
51
51
  var import_jsx_runtime2 = require("react/jsx-runtime");
52
- var MenuList = (0, import_core2.forwardRef)(({ className, ...rest }, ref) => {
53
- const { menuRef, focusedIndex, setFocusedIndex, onClose, styles } = useMenu();
54
- const descendants = useMenuDescendantsContext();
55
- const onNext = (0, import_react2.useCallback)(() => {
56
- const next = descendants.enabledNextValue(focusedIndex);
57
- if (next)
58
- setFocusedIndex(next.index);
59
- }, [descendants, focusedIndex, setFocusedIndex]);
60
- const onPrev = (0, import_react2.useCallback)(() => {
61
- const prev = descendants.enabledPrevValue(focusedIndex);
62
- if (prev)
63
- setFocusedIndex(prev.index);
64
- }, [descendants, focusedIndex, setFocusedIndex]);
65
- const onFirst = (0, import_react2.useCallback)(() => {
66
- const first = descendants.enabledfirstValue();
67
- if (first)
68
- setFocusedIndex(first.index);
69
- }, [descendants, setFocusedIndex]);
70
- const onLast = (0, import_react2.useCallback)(() => {
71
- const last = descendants.enabledlastValue();
72
- if (last)
73
- setFocusedIndex(last.index);
74
- }, [descendants, setFocusedIndex]);
75
- const onKeyDown = (0, import_react2.useCallback)(
76
- (ev) => {
77
- const actions = {
78
- Tab: (ev2) => ev2.preventDefault(),
79
- Escape: onClose,
80
- ArrowDown: focusedIndex === -1 ? onFirst : onNext,
81
- ArrowUp: focusedIndex === -1 ? onLast : onPrev,
82
- Home: onFirst,
83
- End: onLast
84
- };
85
- const action = actions[ev.key];
86
- if (!action)
87
- return;
88
- ev.preventDefault();
89
- action(ev);
90
- },
91
- [focusedIndex, onClose, onFirst, onLast, onNext, onPrev]
92
- );
93
- const css = { ...styles.list };
94
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
95
- import_popover2.PopoverContent,
96
- {
97
- ref: (0, import_utils2.mergeRefs)(menuRef, ref),
98
- className: (0, import_utils2.cx)("ui-menu-list", className),
99
- role: "menu",
100
- tabIndex: -1,
101
- __css: css,
102
- ...rest,
103
- onKeyDown: (0, import_utils2.handlerAll)(rest.onKeyDown, onKeyDown)
104
- }
105
- );
106
- });
52
+ var MenuList = (0, import_core2.forwardRef)(
53
+ ({ className, ...rest }, ref) => {
54
+ const { menuRef, focusedIndex, setFocusedIndex, onClose, styles } = useMenu();
55
+ const descendants = useMenuDescendantsContext();
56
+ const onNext = (0, import_react2.useCallback)(() => {
57
+ const next = descendants.enabledNextValue(focusedIndex);
58
+ if (next)
59
+ setFocusedIndex(next.index);
60
+ }, [descendants, focusedIndex, setFocusedIndex]);
61
+ const onPrev = (0, import_react2.useCallback)(() => {
62
+ const prev = descendants.enabledPrevValue(focusedIndex);
63
+ if (prev)
64
+ setFocusedIndex(prev.index);
65
+ }, [descendants, focusedIndex, setFocusedIndex]);
66
+ const onFirst = (0, import_react2.useCallback)(() => {
67
+ const first = descendants.enabledfirstValue();
68
+ if (first)
69
+ setFocusedIndex(first.index);
70
+ }, [descendants, setFocusedIndex]);
71
+ const onLast = (0, import_react2.useCallback)(() => {
72
+ const last = descendants.enabledlastValue();
73
+ if (last)
74
+ setFocusedIndex(last.index);
75
+ }, [descendants, setFocusedIndex]);
76
+ const onKeyDown = (0, import_react2.useCallback)(
77
+ (ev) => {
78
+ const actions = {
79
+ Tab: (ev2) => ev2.preventDefault(),
80
+ Escape: onClose,
81
+ ArrowDown: focusedIndex === -1 ? onFirst : onNext,
82
+ ArrowUp: focusedIndex === -1 ? onLast : onPrev,
83
+ Home: onFirst,
84
+ End: onLast
85
+ };
86
+ const action = actions[ev.key];
87
+ if (!action)
88
+ return;
89
+ ev.preventDefault();
90
+ action(ev);
91
+ },
92
+ [focusedIndex, onClose, onFirst, onLast, onNext, onPrev]
93
+ );
94
+ const css = { ...styles.list };
95
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
96
+ import_popover2.PopoverContent,
97
+ {
98
+ ref: (0, import_utils2.mergeRefs)(menuRef, ref),
99
+ className: (0, import_utils2.cx)("ui-menu-list", className),
100
+ role: "menu",
101
+ tabIndex: -1,
102
+ __css: css,
103
+ ...rest,
104
+ onKeyDown: (0, import_utils2.handlerAll)(rest.onKeyDown, onKeyDown)
105
+ }
106
+ );
107
+ }
108
+ );
107
109
  // Annotate the CommonJS export names for ESM import in node:
108
110
  0 && (module.exports = {
109
111
  MenuList
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MenuList
3
- } from "./chunk-47P6GKNZ.mjs";
4
- import "./chunk-6IUWMOKW.mjs";
3
+ } from "./chunk-C6C2WO75.mjs";
4
+ import "./chunk-DB6N4OUS.mjs";
5
5
  export {
6
6
  MenuList
7
7
  };
@@ -65,7 +65,14 @@ var MenuGroup = (0, import_core2.forwardRef)(
65
65
  __css: css,
66
66
  ...rest,
67
67
  children: [
68
- title ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.span, { className: (0, import_utils2.cx)("ui-menu-group-title"), __css: styles.groupTitle, children: title }) : null,
68
+ title ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
69
+ import_core2.ui.span,
70
+ {
71
+ className: (0, import_utils2.cx)("ui-menu-group-title"),
72
+ __css: styles.groupTitle,
73
+ children: title
74
+ }
75
+ ) : null,
69
76
  children
70
77
  ]
71
78
  }
@@ -200,23 +207,43 @@ var MenuOptionItem = (0, import_core3.forwardRef)(
200
207
  );
201
208
  }
202
209
  );
203
- var MenuIcon = (0, import_core3.forwardRef)(({ className, ...rest }, ref) => {
204
- const { styles } = useMenu();
205
- const css = {
206
- flexShrink: 0,
207
- display: "inline-flex",
208
- justifyContent: "center",
209
- alignItems: "center",
210
- fontSize: "0.85em",
211
- ...styles.icon
212
- };
213
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { ref, className: (0, import_utils3.cx)("ui-menu-icon", className), __css: css, ...rest });
214
- });
215
- var MenuCommand = (0, import_core3.forwardRef)(({ className, ...rest }, ref) => {
216
- const { styles } = useMenu();
217
- const css = { ...styles.command };
218
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.ui.span, { ref, className: (0, import_utils3.cx)("ui-menu-command", className), __css: css, ...rest });
219
- });
210
+ var MenuIcon = (0, import_core3.forwardRef)(
211
+ ({ className, ...rest }, ref) => {
212
+ const { styles } = useMenu();
213
+ const css = {
214
+ flexShrink: 0,
215
+ display: "inline-flex",
216
+ justifyContent: "center",
217
+ alignItems: "center",
218
+ fontSize: "0.85em",
219
+ ...styles.icon
220
+ };
221
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
222
+ import_core3.ui.span,
223
+ {
224
+ ref,
225
+ className: (0, import_utils3.cx)("ui-menu-icon", className),
226
+ __css: css,
227
+ ...rest
228
+ }
229
+ );
230
+ }
231
+ );
232
+ var MenuCommand = (0, import_core3.forwardRef)(
233
+ ({ className, ...rest }, ref) => {
234
+ const { styles } = useMenu();
235
+ const css = { ...styles.command };
236
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
237
+ import_core3.ui.span,
238
+ {
239
+ ref,
240
+ className: (0, import_utils3.cx)("ui-menu-command", className),
241
+ __css: css,
242
+ ...rest
243
+ }
244
+ );
245
+ }
246
+ );
220
247
  var CheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { viewBox: "0 0 14 14", width: "1em", height: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
221
248
  "polygon",
222
249
  {
@@ -228,7 +255,13 @@ var CheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { view
228
255
  // src/menu-option-group.tsx
229
256
  var import_jsx_runtime4 = require("react/jsx-runtime");
230
257
  var MenuOptionGroup = (0, import_react3.forwardRef)(
231
- ({ className, defaultValue, type, children, ...rest }, ref) => {
258
+ ({
259
+ className,
260
+ defaultValue,
261
+ type,
262
+ children,
263
+ ...rest
264
+ }, ref) => {
232
265
  const isRadio = type === "radio";
233
266
  defaultValue = isRadio ? "" : [];
234
267
  const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  MenuOptionGroup
3
- } from "./chunk-3IEZAEQF.mjs";
4
- import "./chunk-YDLVWG5I.mjs";
5
- import "./chunk-7YDTXOPR.mjs";
6
- import "./chunk-6IUWMOKW.mjs";
3
+ } from "./chunk-3RUBEAMY.mjs";
4
+ import "./chunk-QBVCLEL4.mjs";
5
+ import "./chunk-PVB36WH4.mjs";
6
+ import "./chunk-DB6N4OUS.mjs";
7
7
  export {
8
8
  MenuOptionGroup
9
9
  };
package/dist/menu.js CHANGED
@@ -57,10 +57,12 @@ var Menu = (props) => {
57
57
  const menuRef = (0, import_react.useRef)(null);
58
58
  const timeoutIds = (0, import_react.useRef)(/* @__PURE__ */ new Set([]));
59
59
  const onFocusMenu = (0, import_react.useCallback)(() => {
60
- requestAnimationFrame(() => {
61
- var _a;
62
- return (_a = menuRef.current) == null ? void 0 : _a.focus({ preventScroll: false });
63
- });
60
+ requestAnimationFrame(
61
+ () => {
62
+ var _a;
63
+ return (_a = menuRef.current) == null ? void 0 : _a.focus({ preventScroll: false });
64
+ }
65
+ );
64
66
  }, []);
65
67
  const onFocusFirstItem = (0, import_react.useCallback)(() => {
66
68
  const id = setTimeout(() => {
@@ -87,7 +89,10 @@ var Menu = (props) => {
87
89
  (_a = rest.onOpen) == null ? void 0 : _a.call(rest);
88
90
  onFocusMenu();
89
91
  }, [onFocusMenu, rest]);
90
- const { isOpen, onOpen, onClose } = (0, import_use_disclosure.useDisclosure)({ ...props, onOpen: onOpenInternal });
92
+ const { isOpen, onOpen, onClose } = (0, import_use_disclosure.useDisclosure)({
93
+ ...props,
94
+ onOpen: onOpenInternal
95
+ });
91
96
  (0, import_utils.useUpdateEffect)(() => {
92
97
  if (!isOpen)
93
98
  setFocusedIndex(-1);
package/dist/menu.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  useMenu,
4
4
  useMenuDescendant,
5
5
  useMenuDescendantsContext
6
- } from "./chunk-6IUWMOKW.mjs";
6
+ } from "./chunk-DB6N4OUS.mjs";
7
7
  export {
8
8
  Menu,
9
9
  useMenu,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/menu",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "Yamada UI menu component",
5
5
  "keywords": [
6
6
  "yamada",
@@ -35,14 +35,14 @@
35
35
  "url": "https://github.com/hirotomoyamada/yamada-ui/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@yamada-ui/core": "0.5.1",
39
- "@yamada-ui/utils": "0.1.3",
40
- "@yamada-ui/popover": "0.2.9",
41
- "@yamada-ui/transitions": "0.2.7",
42
- "@yamada-ui/use-disclosure": "0.2.4",
43
- "@yamada-ui/use-descendant": "0.1.4",
44
- "@yamada-ui/use-clickable": "0.2.2",
45
- "@yamada-ui/use-controllable-state": "0.1.4"
38
+ "@yamada-ui/core": "0.5.2",
39
+ "@yamada-ui/utils": "0.1.4",
40
+ "@yamada-ui/popover": "0.2.10",
41
+ "@yamada-ui/transitions": "0.2.8",
42
+ "@yamada-ui/use-disclosure": "0.2.5",
43
+ "@yamada-ui/use-descendant": "0.1.5",
44
+ "@yamada-ui/use-clickable": "0.2.3",
45
+ "@yamada-ui/use-controllable-state": "0.1.5"
46
46
  },
47
47
  "devDependencies": {
48
48
  "react": "^18.0.0",
@@ -1,70 +0,0 @@
1
- import {
2
- useMenu,
3
- useMenuDescendantsContext
4
- } from "./chunk-6IUWMOKW.mjs";
5
-
6
- // src/menu-list.tsx
7
- import { forwardRef } from "@yamada-ui/core";
8
- import { PopoverContent } from "@yamada-ui/popover";
9
- import { cx, handlerAll, mergeRefs } from "@yamada-ui/utils";
10
- import { useCallback } from "react";
11
- import { jsx } from "react/jsx-runtime";
12
- var MenuList = forwardRef(({ className, ...rest }, ref) => {
13
- const { menuRef, focusedIndex, setFocusedIndex, onClose, styles } = useMenu();
14
- const descendants = useMenuDescendantsContext();
15
- const onNext = useCallback(() => {
16
- const next = descendants.enabledNextValue(focusedIndex);
17
- if (next)
18
- setFocusedIndex(next.index);
19
- }, [descendants, focusedIndex, setFocusedIndex]);
20
- const onPrev = useCallback(() => {
21
- const prev = descendants.enabledPrevValue(focusedIndex);
22
- if (prev)
23
- setFocusedIndex(prev.index);
24
- }, [descendants, focusedIndex, setFocusedIndex]);
25
- const onFirst = useCallback(() => {
26
- const first = descendants.enabledfirstValue();
27
- if (first)
28
- setFocusedIndex(first.index);
29
- }, [descendants, setFocusedIndex]);
30
- const onLast = useCallback(() => {
31
- const last = descendants.enabledlastValue();
32
- if (last)
33
- setFocusedIndex(last.index);
34
- }, [descendants, setFocusedIndex]);
35
- const onKeyDown = useCallback(
36
- (ev) => {
37
- const actions = {
38
- Tab: (ev2) => ev2.preventDefault(),
39
- Escape: onClose,
40
- ArrowDown: focusedIndex === -1 ? onFirst : onNext,
41
- ArrowUp: focusedIndex === -1 ? onLast : onPrev,
42
- Home: onFirst,
43
- End: onLast
44
- };
45
- const action = actions[ev.key];
46
- if (!action)
47
- return;
48
- ev.preventDefault();
49
- action(ev);
50
- },
51
- [focusedIndex, onClose, onFirst, onLast, onNext, onPrev]
52
- );
53
- const css = { ...styles.list };
54
- return /* @__PURE__ */ jsx(
55
- PopoverContent,
56
- {
57
- ref: mergeRefs(menuRef, ref),
58
- className: cx("ui-menu-list", className),
59
- role: "menu",
60
- tabIndex: -1,
61
- __css: css,
62
- ...rest,
63
- onKeyDown: handlerAll(rest.onKeyDown, onKeyDown)
64
- }
65
- );
66
- });
67
-
68
- export {
69
- MenuList
70
- };