@yamada-ui/menu 1.3.15-dev-20241005224505 → 1.3.15-dev-20241006032009
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-ZUOFHOX6.mjs → chunk-EJHOFPF4.mjs} +11 -11
- package/dist/chunk-EJHOFPF4.mjs.map +1 -0
- package/dist/{chunk-ZV73JKM5.mjs → chunk-ELQD4RMJ.mjs} +4 -4
- package/dist/{chunk-ZV73JKM5.mjs.map → chunk-ELQD4RMJ.mjs.map} +1 -1
- package/dist/{chunk-T7CXLEBW.mjs → chunk-HEDZYLPX.mjs} +35 -35
- package/dist/chunk-HEDZYLPX.mjs.map +1 -0
- package/dist/{chunk-NNSVX2GX.mjs → chunk-I2KIZ6OI.mjs} +28 -28
- package/dist/{chunk-NNSVX2GX.mjs.map → chunk-I2KIZ6OI.mjs.map} +1 -1
- package/dist/{chunk-O5D4LR5P.mjs → chunk-I473RINV.mjs} +8 -8
- package/dist/{chunk-O5D4LR5P.mjs.map → chunk-I473RINV.mjs.map} +1 -1
- package/dist/{chunk-OFCEMPQW.mjs → chunk-KZAACFSL.mjs} +3 -3
- package/dist/{chunk-OFCEMPQW.mjs.map → chunk-KZAACFSL.mjs.map} +1 -1
- package/dist/{chunk-HVOHR2NQ.mjs → chunk-O7MHNHWF.mjs} +4 -4
- package/dist/{chunk-HVOHR2NQ.mjs.map → chunk-O7MHNHWF.mjs.map} +1 -1
- package/dist/{chunk-SI3WI4AI.mjs → chunk-OETJECD3.mjs} +8 -8
- package/dist/chunk-OETJECD3.mjs.map +1 -0
- package/dist/{chunk-WQ626PSA.mjs → chunk-T4SSYCLG.mjs} +9 -8
- package/dist/chunk-T4SSYCLG.mjs.map +1 -0
- package/dist/{chunk-M4PPRRRC.mjs → chunk-TM7BAARA.mjs} +14 -14
- package/dist/chunk-TM7BAARA.mjs.map +1 -0
- package/dist/context-menu-trigger.js +14 -13
- package/dist/context-menu-trigger.js.map +1 -1
- package/dist/context-menu-trigger.mjs +2 -2
- package/dist/context-menu.js +33 -33
- package/dist/context-menu.js.map +1 -1
- package/dist/context-menu.mjs +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +275 -272
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/menu-button.d.mts +2 -2
- package/dist/menu-button.d.ts +2 -2
- package/dist/menu-button.js +50 -50
- package/dist/menu-button.js.map +1 -1
- package/dist/menu-button.mjs +3 -3
- package/dist/menu-context.d.mts +116 -116
- package/dist/menu-context.d.ts +116 -116
- package/dist/menu-context.js +8 -8
- package/dist/menu-context.js.map +1 -1
- package/dist/menu-context.mjs +1 -1
- package/dist/menu-divider.js +8 -8
- package/dist/menu-divider.js.map +1 -1
- package/dist/menu-divider.mjs +2 -2
- package/dist/menu-group.js +9 -9
- package/dist/menu-group.js.map +1 -1
- package/dist/menu-group.mjs +2 -2
- package/dist/menu-item.d.mts +21 -21
- package/dist/menu-item.d.ts +21 -21
- package/dist/menu-item.js +40 -40
- package/dist/menu-item.js.map +1 -1
- package/dist/menu-item.mjs +2 -2
- package/dist/menu-list.js +14 -14
- package/dist/menu-list.js.map +1 -1
- package/dist/menu-list.mjs +2 -2
- package/dist/menu-option-group.d.mts +8 -8
- package/dist/menu-option-group.d.ts +8 -8
- package/dist/menu-option-group.js +46 -46
- package/dist/menu-option-group.js.map +1 -1
- package/dist/menu-option-group.mjs +4 -4
- package/dist/menu.js +33 -33
- package/dist/menu.js.map +1 -1
- package/dist/menu.mjs +2 -2
- package/package.json +11 -11
- package/dist/chunk-M4PPRRRC.mjs.map +0 -1
- package/dist/chunk-SI3WI4AI.mjs.map +0 -1
- package/dist/chunk-T7CXLEBW.mjs.map +0 -1
- package/dist/chunk-WQ626PSA.mjs.map +0 -1
- package/dist/chunk-ZUOFHOX6.mjs.map +0 -1
package/dist/index.js
CHANGED
@@ -37,6 +37,9 @@ __export(src_exports, {
|
|
37
37
|
});
|
38
38
|
module.exports = __toCommonJS(src_exports);
|
39
39
|
|
40
|
+
// src/context-menu.tsx
|
41
|
+
var import_core2 = require("@yamada-ui/core");
|
42
|
+
|
40
43
|
// src/menu.tsx
|
41
44
|
var import_core = require("@yamada-ui/core");
|
42
45
|
var import_popover = require("@yamada-ui/popover");
|
@@ -49,25 +52,25 @@ var import_use_descendant = require("@yamada-ui/use-descendant");
|
|
49
52
|
var import_utils = require("@yamada-ui/utils");
|
50
53
|
var {
|
51
54
|
DescendantsContextProvider,
|
52
|
-
|
55
|
+
useDescendant: useMenuDescendant,
|
53
56
|
useDescendants,
|
54
|
-
|
57
|
+
useDescendantsContext: useMenuDescendantsContext
|
55
58
|
} = (0, import_use_descendant.createDescendant)();
|
56
59
|
var [MenuProvider, useMenu] = (0, import_utils.createContext)({
|
57
60
|
name: "MenuContext",
|
58
61
|
errorMessage: `useMenu returned is 'undefined'. Seems you forgot to wrap the components in "<Menu />"`
|
59
62
|
});
|
60
63
|
var [ContextMenuProvider, useContextMenu] = (0, import_utils.createContext)({
|
61
|
-
|
62
|
-
|
64
|
+
name: "ContextMenuContext",
|
65
|
+
strict: false
|
63
66
|
});
|
64
67
|
var [UpstreamMenuProvider, useUpstreamMenu] = (0, import_utils.createContext)({
|
65
|
-
|
66
|
-
|
68
|
+
name: "UpstreamMenuContext",
|
69
|
+
strict: false
|
67
70
|
});
|
68
71
|
var [UpstreamMenuItemProvider, useUpstreamMenuItem] = (0, import_utils.createContext)({
|
69
|
-
|
70
|
-
|
72
|
+
name: "UpstreamMenuItemContext",
|
73
|
+
strict: false
|
71
74
|
});
|
72
75
|
|
73
76
|
// src/menu.tsx
|
@@ -80,18 +83,18 @@ var Menu = (props) => {
|
|
80
83
|
styles: contextMenuStyles
|
81
84
|
});
|
82
85
|
let {
|
83
|
-
initialFocusRef,
|
84
|
-
closeOnSelect = true,
|
85
86
|
closeOnBlur,
|
86
|
-
|
87
|
+
closeOnSelect = true,
|
87
88
|
duration = 0.2,
|
89
|
+
initialFocusRef,
|
88
90
|
offset,
|
89
|
-
|
91
|
+
placement,
|
90
92
|
onClose: onCloseProp,
|
93
|
+
onOpen: onOpenProp,
|
91
94
|
...rest
|
92
95
|
} = (0, import_core.omitThemeProps)(mergedProps);
|
93
|
-
const { relatedRef,
|
94
|
-
const {
|
96
|
+
const { relatedRef, onDownstreamCloseMapRef, onUpstreamClose } = (_b = useUpstreamMenu()) != null ? _b : {};
|
97
|
+
const { hasDownstreamRef, setDownstreamOpen } = (_c = useUpstreamMenuItem()) != null ? _c : {};
|
95
98
|
const isNested = !!relatedRef;
|
96
99
|
if (isNested) {
|
97
100
|
placement != null ? placement : placement = "right-start";
|
@@ -141,10 +144,10 @@ var Menu = (props) => {
|
|
141
144
|
}
|
142
145
|
}, [onCloseProp]);
|
143
146
|
const id = (0, import_react.useId)();
|
144
|
-
const { isOpen,
|
147
|
+
const { isOpen, onClose, onOpen } = (0, import_use_disclosure.useDisclosure)({
|
145
148
|
...props,
|
146
|
-
|
147
|
-
|
149
|
+
onClose: onCloseInternal,
|
150
|
+
onOpen: onOpenInternal
|
148
151
|
});
|
149
152
|
(0, import_react.useEffect)(() => {
|
150
153
|
const onCloseMap = onDownstreamCloseMapRef == null ? void 0 : onDownstreamCloseMapRef.current;
|
@@ -181,19 +184,19 @@ var Menu = (props) => {
|
|
181
184
|
MenuProvider,
|
182
185
|
{
|
183
186
|
value: {
|
184
|
-
isOpen,
|
185
|
-
onOpen,
|
186
|
-
onClose,
|
187
|
-
onUpstreamClose,
|
188
|
-
onFocusFirstItem,
|
189
|
-
onFocusLastItem,
|
190
187
|
closeOnSelect,
|
191
188
|
focusedIndex,
|
192
|
-
|
189
|
+
isNested,
|
190
|
+
isOpen,
|
193
191
|
menuRef,
|
194
192
|
requestAnimationFrameId,
|
195
|
-
|
196
|
-
styles
|
193
|
+
setFocusedIndex,
|
194
|
+
styles,
|
195
|
+
onClose,
|
196
|
+
onFocusFirstItem,
|
197
|
+
onFocusLastItem,
|
198
|
+
onOpen,
|
199
|
+
onUpstreamClose
|
197
200
|
},
|
198
201
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
199
202
|
import_popover.Popover,
|
@@ -201,16 +204,16 @@ var Menu = (props) => {
|
|
201
204
|
...{
|
202
205
|
trigger: isNested ? "hover" : "click",
|
203
206
|
...rest,
|
204
|
-
|
205
|
-
|
206
|
-
onClose,
|
207
|
-
placement,
|
208
|
-
offset,
|
207
|
+
closeOnBlur,
|
208
|
+
closeOnButton: false,
|
209
209
|
duration,
|
210
210
|
initialFocusRef,
|
211
|
+
isOpen,
|
212
|
+
offset,
|
213
|
+
placement,
|
211
214
|
relatedRef,
|
212
|
-
|
213
|
-
|
215
|
+
onClose,
|
216
|
+
onOpen
|
214
217
|
}
|
215
218
|
}
|
216
219
|
)
|
@@ -220,66 +223,112 @@ var Menu = (props) => {
|
|
220
223
|
) });
|
221
224
|
};
|
222
225
|
|
223
|
-
// src/menu
|
226
|
+
// src/context-menu.tsx
|
227
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
228
|
+
var ContextMenu = (props) => {
|
229
|
+
const [styles, mergedProps] = (0, import_core2.useComponentMultiStyle)("ContextMenu", props);
|
230
|
+
const { ...rest } = (0, import_core2.omitThemeProps)(mergedProps);
|
231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ContextMenuProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Menu, { trigger: "contextmenu", ...rest }) });
|
232
|
+
};
|
233
|
+
|
234
|
+
// src/context-menu-trigger.tsx
|
224
235
|
var import_core3 = require("@yamada-ui/core");
|
225
|
-
var import_icon = require("@yamada-ui/icon");
|
226
236
|
var import_popover2 = require("@yamada-ui/popover");
|
227
|
-
var
|
228
|
-
var
|
237
|
+
var import_utils3 = require("@yamada-ui/utils");
|
238
|
+
var import_react2 = require("react");
|
239
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
240
|
+
var ContextMenuTrigger = (0, import_core3.forwardRef)(
|
241
|
+
({ className, children, ...rest }, ref) => {
|
242
|
+
var _a;
|
243
|
+
const { styles } = (_a = useContextMenu()) != null ? _a : {};
|
244
|
+
const [position, setPosition] = (0, import_react2.useState)({ left: 0, top: 0 });
|
245
|
+
const css = { ...styles == null ? void 0 : styles.container };
|
246
|
+
const onContextMenu = (ev) => {
|
247
|
+
setPosition({ left: ev.pageX, top: ev.pageY });
|
248
|
+
};
|
249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
250
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_popover2.PopoverAnchor, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
251
|
+
import_core3.ui.div,
|
252
|
+
{
|
253
|
+
className: "ui-context-menu__anchor",
|
254
|
+
style: { position: "absolute", ...position }
|
255
|
+
}
|
256
|
+
) }),
|
257
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_popover2.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
258
|
+
import_core3.ui.div,
|
259
|
+
{
|
260
|
+
ref,
|
261
|
+
className: (0, import_utils3.cx)("ui-context-menu", className),
|
262
|
+
__css: css,
|
263
|
+
...rest,
|
264
|
+
onContextMenu: (0, import_utils3.handlerAll)(rest.onContextMenu, onContextMenu),
|
265
|
+
children
|
266
|
+
}
|
267
|
+
) })
|
268
|
+
] });
|
269
|
+
}
|
270
|
+
);
|
271
|
+
|
272
|
+
// src/menu-button.tsx
|
273
|
+
var import_core5 = require("@yamada-ui/core");
|
274
|
+
var import_icon = require("@yamada-ui/icon");
|
275
|
+
var import_popover3 = require("@yamada-ui/popover");
|
276
|
+
var import_utils5 = require("@yamada-ui/utils");
|
277
|
+
var import_react4 = require("react");
|
229
278
|
|
230
279
|
// src/menu-item.tsx
|
231
|
-
var
|
280
|
+
var import_core4 = require("@yamada-ui/core");
|
232
281
|
var import_use_clickable = require("@yamada-ui/use-clickable");
|
233
|
-
var
|
234
|
-
var
|
235
|
-
var
|
282
|
+
var import_utils4 = require("@yamada-ui/utils");
|
283
|
+
var import_react3 = require("react");
|
284
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
236
285
|
var isTargetMenuItem = (target) => {
|
237
286
|
var _a;
|
238
|
-
return (0,
|
287
|
+
return (0, import_utils4.isHTMLElement)(target) && !!((_a = target.getAttribute("role")) == null ? void 0 : _a.startsWith("menuitem"));
|
239
288
|
};
|
240
|
-
var MenuItem = (0,
|
289
|
+
var MenuItem = (0, import_core4.forwardRef)(
|
241
290
|
({
|
242
291
|
className,
|
243
|
-
|
244
|
-
isFocusable,
|
292
|
+
children,
|
245
293
|
closeOnSelect: customCloseOnSelect,
|
246
|
-
icon,
|
247
294
|
command,
|
248
|
-
|
295
|
+
icon,
|
296
|
+
isDisabled,
|
297
|
+
isFocusable,
|
249
298
|
...props
|
250
299
|
}, ref) => {
|
251
300
|
var _a;
|
252
301
|
const {
|
302
|
+
closeOnSelect: generalCloseOnSelect,
|
253
303
|
focusedIndex,
|
254
|
-
|
304
|
+
isNested,
|
255
305
|
isOpen,
|
256
|
-
onClose,
|
257
|
-
onUpstreamClose,
|
258
|
-
closeOnSelect: generalCloseOnSelect,
|
259
306
|
menuRef,
|
260
307
|
requestAnimationFrameId,
|
261
|
-
|
262
|
-
styles
|
308
|
+
setFocusedIndex,
|
309
|
+
styles,
|
310
|
+
onClose,
|
311
|
+
onUpstreamClose
|
263
312
|
} = useMenu();
|
264
313
|
const { onUpstreamRestoreFocus } = (_a = useUpstreamMenuItem()) != null ? _a : {};
|
265
314
|
const trulyDisabled = isDisabled && !isFocusable;
|
266
|
-
const itemRef = (0,
|
267
|
-
const hasDownstreamRef = (0,
|
268
|
-
const onKeyDownRef = (0,
|
315
|
+
const itemRef = (0, import_react3.useRef)(null);
|
316
|
+
const hasDownstreamRef = (0, import_react3.useRef)(false);
|
317
|
+
const onKeyDownRef = (0, import_react3.useRef)(
|
269
318
|
() => void 0
|
270
319
|
);
|
271
320
|
const { index, register } = useMenuDescendant({ disabled: trulyDisabled });
|
272
|
-
const [isDownstreamOpen, setDownstreamOpen] = (0,
|
321
|
+
const [isDownstreamOpen, setDownstreamOpen] = (0, import_react3.useState)(false);
|
273
322
|
const isFocused = index === focusedIndex;
|
274
|
-
const onMouseOver = (0,
|
323
|
+
const onMouseOver = (0, import_react3.useCallback)(() => {
|
275
324
|
if (isDisabled) return;
|
276
325
|
setFocusedIndex(index);
|
277
326
|
}, [index, isDisabled, setFocusedIndex]);
|
278
|
-
const onMouseLeave = (0,
|
327
|
+
const onMouseLeave = (0, import_react3.useCallback)(() => {
|
279
328
|
if (isDisabled) return;
|
280
329
|
setFocusedIndex(-1);
|
281
330
|
}, [setFocusedIndex, isDisabled]);
|
282
|
-
const onClick = (0,
|
331
|
+
const onClick = (0, import_react3.useCallback)(
|
283
332
|
(ev) => {
|
284
333
|
if (!isTargetMenuItem(ev.currentTarget)) return;
|
285
334
|
const hasDownstream = hasDownstreamRef.current;
|
@@ -290,18 +339,18 @@ var MenuItem = (0, import_core2.forwardRef)(
|
|
290
339
|
},
|
291
340
|
[customCloseOnSelect, generalCloseOnSelect, onClose, onUpstreamClose]
|
292
341
|
);
|
293
|
-
const onFocus = (0,
|
342
|
+
const onFocus = (0, import_react3.useCallback)(() => {
|
294
343
|
setFocusedIndex(index);
|
295
344
|
}, [setFocusedIndex, index]);
|
296
|
-
const onRestoreFocus = (0,
|
345
|
+
const onRestoreFocus = (0, import_react3.useCallback)(() => {
|
297
346
|
var _a2;
|
298
347
|
(_a2 = itemRef.current) == null ? void 0 : _a2.focus();
|
299
348
|
setFocusedIndex(index);
|
300
349
|
}, [setFocusedIndex, index]);
|
301
|
-
const onKeyDown = (0,
|
350
|
+
const onKeyDown = (0, import_react3.useCallback)(
|
302
351
|
(ev) => {
|
303
352
|
const actions = {
|
304
|
-
ArrowLeft: isNested ? (0,
|
353
|
+
ArrowLeft: isNested ? (0, import_utils4.funcAll)(onUpstreamRestoreFocus, onClose) : void 0
|
305
354
|
};
|
306
355
|
const action = actions[ev.key];
|
307
356
|
if (!action) return;
|
@@ -314,16 +363,16 @@ var MenuItem = (0, import_core2.forwardRef)(
|
|
314
363
|
const rest = (0, import_use_clickable.useClickable)({
|
315
364
|
focusOnClick: false,
|
316
365
|
...props,
|
317
|
-
|
318
|
-
onFocus: (0, import_utils3.handlerAll)(props.onFocus, onFocus),
|
319
|
-
onMouseOver: (0, import_utils3.handlerAll)(props.onMouseOver, onMouseOver),
|
320
|
-
onMouseLeave: (0, import_utils3.handlerAll)(props.onMouseLeave, onMouseLeave),
|
321
|
-
onKeyDown: (0, import_utils3.handlerAll)(props.onKeyDown, onKeyDown, onKeyDownRef.current),
|
322
|
-
ref: (0, import_utils3.mergeRefs)(register, itemRef, ref),
|
366
|
+
ref: (0, import_utils4.mergeRefs)(register, itemRef, ref),
|
323
367
|
isDisabled,
|
324
|
-
isFocusable
|
368
|
+
isFocusable,
|
369
|
+
onClick: (0, import_utils4.handlerAll)(props.onClick, onClick),
|
370
|
+
onFocus: (0, import_utils4.handlerAll)(props.onFocus, onFocus),
|
371
|
+
onKeyDown: (0, import_utils4.handlerAll)(props.onKeyDown, onKeyDown, onKeyDownRef.current),
|
372
|
+
onMouseLeave: (0, import_utils4.handlerAll)(props.onMouseLeave, onMouseLeave),
|
373
|
+
onMouseOver: (0, import_utils4.handlerAll)(props.onMouseOver, onMouseOver)
|
325
374
|
});
|
326
|
-
(0,
|
375
|
+
(0, import_utils4.useUpdateEffect)(() => {
|
327
376
|
if (!isOpen) return;
|
328
377
|
const id = requestAnimationFrameId.current;
|
329
378
|
if (isFocused && !trulyDisabled && itemRef.current) {
|
@@ -333,49 +382,49 @@ var MenuItem = (0, import_core2.forwardRef)(
|
|
333
382
|
(_a2 = itemRef.current) == null ? void 0 : _a2.focus({ preventScroll: true });
|
334
383
|
requestAnimationFrameId.current = null;
|
335
384
|
});
|
336
|
-
} else if (menuRef.current && !(0,
|
385
|
+
} else if (menuRef.current && !(0, import_utils4.isActiveElement)(menuRef.current)) {
|
337
386
|
menuRef.current.focus({ preventScroll: true });
|
338
387
|
}
|
339
388
|
return () => {
|
340
389
|
if (id) cancelAnimationFrame(id);
|
341
390
|
};
|
342
391
|
}, [isFocused, trulyDisabled, menuRef, isOpen]);
|
343
|
-
children = icon || command ? /* @__PURE__ */ (0,
|
392
|
+
children = icon || command ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.span, { style: { flex: 1 }, children }) : children;
|
344
393
|
const css = {
|
345
|
-
|
394
|
+
alignItems: "center",
|
346
395
|
color: "inherit",
|
347
|
-
userSelect: "none",
|
348
396
|
display: "flex",
|
349
|
-
width: "100%",
|
350
|
-
alignItems: "center",
|
351
|
-
textAlign: "start",
|
352
397
|
flex: "0 0 auto",
|
353
|
-
outline: 0,
|
354
398
|
gap: "0.75rem",
|
399
|
+
outline: 0,
|
400
|
+
textAlign: "start",
|
401
|
+
textDecoration: "none",
|
402
|
+
userSelect: "none",
|
403
|
+
width: "100%",
|
355
404
|
...styles.item
|
356
405
|
};
|
357
|
-
return /* @__PURE__ */ (0,
|
406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
358
407
|
UpstreamMenuItemProvider,
|
359
408
|
{
|
360
409
|
value: {
|
361
|
-
|
362
|
-
onUpstreamRestoreFocus: onRestoreFocus,
|
410
|
+
hasDownstreamRef,
|
363
411
|
setDownstreamOpen,
|
364
|
-
|
412
|
+
onKeyDownRef,
|
413
|
+
onUpstreamRestoreFocus: onRestoreFocus
|
365
414
|
},
|
366
|
-
children: /* @__PURE__ */ (0,
|
367
|
-
|
415
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
416
|
+
import_core4.ui.li,
|
368
417
|
{
|
369
418
|
...rest,
|
370
419
|
...isDownstreamOpen ? { "data-active": "" } : {},
|
420
|
+
className: (0, import_utils4.cx)("ui-menu__item", className),
|
371
421
|
role: "menuitem",
|
372
422
|
tabIndex: isFocused ? 0 : -1,
|
373
|
-
className: (0, import_utils3.cx)("ui-menu__item", className),
|
374
423
|
__css: css,
|
375
424
|
children: [
|
376
|
-
icon ? /* @__PURE__ */ (0,
|
425
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MenuIcon, { children: icon }) : null,
|
377
426
|
children,
|
378
|
-
command ? /* @__PURE__ */ (0,
|
427
|
+
command ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MenuCommand, { children: command }) : null
|
379
428
|
]
|
380
429
|
}
|
381
430
|
)
|
@@ -383,62 +432,62 @@ var MenuItem = (0, import_core2.forwardRef)(
|
|
383
432
|
);
|
384
433
|
}
|
385
434
|
);
|
386
|
-
var MenuOptionItem = (0,
|
387
|
-
({ className,
|
388
|
-
return /* @__PURE__ */ (0,
|
435
|
+
var MenuOptionItem = (0, import_core4.forwardRef)(
|
436
|
+
({ className, children, closeOnSelect = false, icon, isChecked, ...rest }, ref) => {
|
437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
389
438
|
MenuItem,
|
390
439
|
{
|
391
440
|
ref,
|
392
|
-
className: (0,
|
393
|
-
"aria-checked": (0, import_utils3.ariaAttr)(isChecked),
|
441
|
+
className: (0, import_utils4.cx)("ui-menu__item--option", className),
|
394
442
|
closeOnSelect,
|
443
|
+
"aria-checked": (0, import_utils4.ariaAttr)(isChecked),
|
395
444
|
...rest,
|
396
445
|
children: [
|
397
|
-
icon !== null ? /* @__PURE__ */ (0,
|
446
|
+
icon !== null ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MenuIcon, { opacity: isChecked ? 1 : 0, children: icon || /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckIcon, {}) }) : null,
|
398
447
|
children
|
399
448
|
]
|
400
449
|
}
|
401
450
|
);
|
402
451
|
}
|
403
452
|
);
|
404
|
-
var MenuIcon = (0,
|
453
|
+
var MenuIcon = (0, import_core4.forwardRef)(
|
405
454
|
({ className, ...rest }, ref) => {
|
406
455
|
const { styles } = useMenu();
|
407
456
|
const css = {
|
408
|
-
flexShrink: 0,
|
409
|
-
display: "inline-flex",
|
410
|
-
justifyContent: "center",
|
411
457
|
alignItems: "center",
|
458
|
+
display: "inline-flex",
|
459
|
+
flexShrink: 0,
|
412
460
|
fontSize: "0.85em",
|
461
|
+
justifyContent: "center",
|
413
462
|
...styles.icon
|
414
463
|
};
|
415
|
-
return /* @__PURE__ */ (0,
|
416
|
-
|
464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
465
|
+
import_core4.ui.span,
|
417
466
|
{
|
418
467
|
ref,
|
419
|
-
className: (0,
|
468
|
+
className: (0, import_utils4.cx)("ui-menu__item__icon", className),
|
420
469
|
__css: css,
|
421
470
|
...rest
|
422
471
|
}
|
423
472
|
);
|
424
473
|
}
|
425
474
|
);
|
426
|
-
var MenuCommand = (0,
|
475
|
+
var MenuCommand = (0, import_core4.forwardRef)(
|
427
476
|
({ className, ...rest }, ref) => {
|
428
477
|
const { styles } = useMenu();
|
429
478
|
const css = { ...styles.command };
|
430
|
-
return /* @__PURE__ */ (0,
|
431
|
-
|
479
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
480
|
+
import_core4.ui.span,
|
432
481
|
{
|
433
482
|
ref,
|
434
|
-
className: (0,
|
483
|
+
className: (0, import_utils4.cx)("ui-menu__item__command", className),
|
435
484
|
__css: css,
|
436
485
|
...rest
|
437
486
|
}
|
438
487
|
);
|
439
488
|
}
|
440
489
|
);
|
441
|
-
var CheckIcon = () => /* @__PURE__ */ (0,
|
490
|
+
var CheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { height: "1em", viewBox: "0 0 14 14", width: "1em", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
442
491
|
"polygon",
|
443
492
|
{
|
444
493
|
fill: "currentColor",
|
@@ -447,18 +496,18 @@ var CheckIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { view
|
|
447
496
|
) });
|
448
497
|
|
449
498
|
// src/menu-button.tsx
|
450
|
-
var
|
451
|
-
var MenuButton = (0,
|
452
|
-
({ className, children,
|
499
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
500
|
+
var MenuButton = (0, import_core5.forwardRef)(
|
501
|
+
({ as, className, children, ...rest }, ref) => {
|
453
502
|
var _a;
|
454
503
|
const { onKeyDownRef, onUpstreamRestoreFocus } = (_a = useUpstreamMenuItem()) != null ? _a : {};
|
455
|
-
const { isOpen,
|
456
|
-
const onKeyDown = (0,
|
504
|
+
const { isOpen, onClose, onFocusFirstItem, onFocusLastItem, onOpen } = useMenu();
|
505
|
+
const onKeyDown = (0, import_react4.useCallback)(
|
457
506
|
(ev) => {
|
458
507
|
const actions = {
|
459
|
-
|
460
|
-
|
461
|
-
|
508
|
+
ArrowDown: (0, import_utils5.funcAll)(onOpen, onFocusFirstItem),
|
509
|
+
ArrowUp: (0, import_utils5.funcAll)(onOpen, onFocusLastItem),
|
510
|
+
Enter: (0, import_utils5.funcAll)(onOpen, onFocusFirstItem)
|
462
511
|
};
|
463
512
|
const action = actions[ev.key];
|
464
513
|
if (!action) return;
|
@@ -467,11 +516,11 @@ var MenuButton = (0, import_core3.forwardRef)(
|
|
467
516
|
},
|
468
517
|
[onFocusFirstItem, onFocusLastItem, onOpen]
|
469
518
|
);
|
470
|
-
const onItemKeyDown = (0,
|
519
|
+
const onItemKeyDown = (0, import_react4.useCallback)(
|
471
520
|
(ev) => {
|
472
521
|
const actions = {
|
473
|
-
|
474
|
-
|
522
|
+
ArrowLeft: isOpen ? (0, import_utils5.funcAll)(onUpstreamRestoreFocus, onClose) : void 0,
|
523
|
+
ArrowRight: !isOpen ? (0, import_utils5.funcAll)(onOpen, onFocusFirstItem) : void 0
|
475
524
|
};
|
476
525
|
const action = actions[ev.key];
|
477
526
|
if (!action) return;
|
@@ -480,46 +529,99 @@ var MenuButton = (0, import_core3.forwardRef)(
|
|
480
529
|
},
|
481
530
|
[isOpen, onOpen, onFocusFirstItem, onUpstreamRestoreFocus, onClose]
|
482
531
|
);
|
483
|
-
(0,
|
484
|
-
const Component = (0,
|
485
|
-
return /* @__PURE__ */ (0,
|
532
|
+
(0, import_utils5.assignRef)(onKeyDownRef, onItemKeyDown);
|
533
|
+
const Component = (0, import_react4.useMemo)(() => as ? (0, import_core5.ui)(as) : Button, [as]);
|
534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_popover3.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
486
535
|
Component,
|
487
536
|
{
|
488
537
|
ref,
|
489
|
-
className: (0,
|
490
|
-
"aria-haspopup": "menu",
|
538
|
+
className: (0, import_utils5.cx)("ui-menu", className),
|
491
539
|
"aria-expanded": isOpen,
|
540
|
+
"aria-haspopup": "menu",
|
492
541
|
...rest,
|
493
|
-
"data-active": (0,
|
494
|
-
onKeyDown: (0,
|
542
|
+
"data-active": (0, import_utils5.dataAttr)(isOpen),
|
543
|
+
onKeyDown: (0, import_utils5.handlerAll)(rest.onKeyDown, onKeyDown),
|
495
544
|
children
|
496
545
|
}
|
497
546
|
) });
|
498
547
|
}
|
499
548
|
);
|
500
|
-
var Button = (0,
|
549
|
+
var Button = (0, import_core5.forwardRef)((rest, ref) => {
|
501
550
|
const { styles } = useMenu();
|
502
551
|
const css = {
|
503
|
-
display: "inline-flex",
|
504
|
-
appearance: "none",
|
505
552
|
alignItems: "center",
|
553
|
+
appearance: "none",
|
554
|
+
display: "inline-flex",
|
506
555
|
outline: 0,
|
507
556
|
...styles.button
|
508
557
|
};
|
509
|
-
return /* @__PURE__ */ (0,
|
558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.button, { ref, __css: css, ...rest });
|
510
559
|
});
|
511
|
-
var MenuItemButton = (0,
|
512
|
-
({ className, children,
|
513
|
-
return /* @__PURE__ */ (0,
|
560
|
+
var MenuItemButton = (0, import_core5.forwardRef)(
|
561
|
+
({ className, children, icon, iconProps, innerProps, ...rest }, ref) => {
|
562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
514
563
|
MenuButton,
|
515
564
|
{
|
516
565
|
ref,
|
517
|
-
className: (0,
|
566
|
+
className: (0, import_utils5.cx)("ui-menu__item-button", className),
|
518
567
|
flex: "1",
|
519
568
|
...rest,
|
520
569
|
children: [
|
521
|
-
/* @__PURE__ */ (0,
|
522
|
-
/* @__PURE__ */ (0,
|
570
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.span, { as: "span", flex: "1", ...innerProps, children }),
|
571
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MenuIcon, { ...iconProps, children: icon != null ? icon : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icon.ChevronIcon, { fontSize: "1.5em", transform: "rotate(-90deg)" }) })
|
572
|
+
]
|
573
|
+
}
|
574
|
+
);
|
575
|
+
}
|
576
|
+
);
|
577
|
+
|
578
|
+
// src/menu-divider.tsx
|
579
|
+
var import_core6 = require("@yamada-ui/core");
|
580
|
+
var import_utils6 = require("@yamada-ui/utils");
|
581
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
582
|
+
var MenuDivider = (0, import_core6.forwardRef)(
|
583
|
+
({ className, ...rest }, ref) => {
|
584
|
+
const { styles } = useMenu();
|
585
|
+
const css = { ...styles.divider };
|
586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
587
|
+
import_core6.ui.hr,
|
588
|
+
{
|
589
|
+
ref,
|
590
|
+
className: (0, import_utils6.cx)("ui-menu__divider", className),
|
591
|
+
__css: css,
|
592
|
+
...rest
|
593
|
+
}
|
594
|
+
);
|
595
|
+
}
|
596
|
+
);
|
597
|
+
|
598
|
+
// src/menu-group.tsx
|
599
|
+
var import_core7 = require("@yamada-ui/core");
|
600
|
+
var import_utils7 = require("@yamada-ui/utils");
|
601
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
602
|
+
var MenuGroup = (0, import_core7.forwardRef)(
|
603
|
+
({ className, children, label, labelProps, ...rest }, ref) => {
|
604
|
+
const { styles } = useMenu();
|
605
|
+
const css = { ...styles.group };
|
606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
607
|
+
import_core7.ui.li,
|
608
|
+
{
|
609
|
+
ref,
|
610
|
+
className: (0, import_utils7.cx)("ui-menu__item", "ui-menu__item--group", className),
|
611
|
+
role: "group",
|
612
|
+
__css: css,
|
613
|
+
...rest,
|
614
|
+
children: [
|
615
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
616
|
+
import_core7.ui.span,
|
617
|
+
{
|
618
|
+
className: (0, import_utils7.cx)("ui-menu__item--group-label"),
|
619
|
+
__css: styles.groupLabel,
|
620
|
+
...labelProps,
|
621
|
+
children: label
|
622
|
+
}
|
623
|
+
) : null,
|
624
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.ui.ul, { className: "ui-menu__item__group", children })
|
523
625
|
]
|
524
626
|
}
|
525
627
|
);
|
@@ -527,40 +629,40 @@ var MenuItemButton = (0, import_core3.forwardRef)(
|
|
527
629
|
);
|
528
630
|
|
529
631
|
// src/menu-list.tsx
|
530
|
-
var
|
531
|
-
var
|
532
|
-
var
|
533
|
-
var
|
534
|
-
var
|
535
|
-
var MenuList = (0,
|
536
|
-
({ className,
|
537
|
-
const {
|
632
|
+
var import_core8 = require("@yamada-ui/core");
|
633
|
+
var import_popover4 = require("@yamada-ui/popover");
|
634
|
+
var import_utils8 = require("@yamada-ui/utils");
|
635
|
+
var import_react5 = require("react");
|
636
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
637
|
+
var MenuList = (0, import_core8.forwardRef)(
|
638
|
+
({ className, children, contentProps, ...rest }, ref) => {
|
639
|
+
const { focusedIndex, menuRef, setFocusedIndex, styles, onClose } = useMenu();
|
538
640
|
const descendants = useMenuDescendantsContext();
|
539
|
-
const onNext = (0,
|
641
|
+
const onNext = (0, import_react5.useCallback)(() => {
|
540
642
|
const next = descendants.enabledNextValue(focusedIndex);
|
541
643
|
if (next) setFocusedIndex(next.index);
|
542
644
|
}, [descendants, focusedIndex, setFocusedIndex]);
|
543
|
-
const onPrev = (0,
|
645
|
+
const onPrev = (0, import_react5.useCallback)(() => {
|
544
646
|
const prev = descendants.enabledPrevValue(focusedIndex);
|
545
647
|
if (prev) setFocusedIndex(prev.index);
|
546
648
|
}, [descendants, focusedIndex, setFocusedIndex]);
|
547
|
-
const onFirst = (0,
|
649
|
+
const onFirst = (0, import_react5.useCallback)(() => {
|
548
650
|
const first = descendants.enabledFirstValue();
|
549
651
|
if (first) setFocusedIndex(first.index);
|
550
652
|
}, [descendants, setFocusedIndex]);
|
551
|
-
const onLast = (0,
|
653
|
+
const onLast = (0, import_react5.useCallback)(() => {
|
552
654
|
const last = descendants.enabledLastValue();
|
553
655
|
if (last) setFocusedIndex(last.index);
|
554
656
|
}, [descendants, setFocusedIndex]);
|
555
|
-
const onKeyDown = (0,
|
657
|
+
const onKeyDown = (0, import_react5.useCallback)(
|
556
658
|
(ev) => {
|
557
659
|
const actions = {
|
558
|
-
Tab: (ev2) => ev2.preventDefault(),
|
559
|
-
Escape: onClose,
|
560
660
|
ArrowDown: focusedIndex === -1 ? onFirst : onNext,
|
561
661
|
ArrowUp: focusedIndex === -1 ? onLast : onPrev,
|
662
|
+
End: onLast,
|
663
|
+
Escape: onClose,
|
562
664
|
Home: onFirst,
|
563
|
-
|
665
|
+
Tab: (ev2) => ev2.preventDefault()
|
564
666
|
};
|
565
667
|
const action = actions[ev.key];
|
566
668
|
if (!action) return;
|
@@ -569,20 +671,20 @@ var MenuList = (0, import_core4.forwardRef)(
|
|
569
671
|
},
|
570
672
|
[focusedIndex, onClose, onFirst, onLast, onNext, onPrev]
|
571
673
|
);
|
572
|
-
return /* @__PURE__ */ (0,
|
573
|
-
|
674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
675
|
+
import_popover4.PopoverContent,
|
574
676
|
{
|
575
677
|
as: "div",
|
576
678
|
className: "ui-menu__content",
|
577
679
|
__css: { ...styles.content },
|
578
680
|
...contentProps,
|
579
|
-
onKeyDown: (0,
|
580
|
-
children: /* @__PURE__ */ (0,
|
581
|
-
|
681
|
+
onKeyDown: (0, import_utils8.handlerAll)(contentProps == null ? void 0 : contentProps.onKeyDown, onKeyDown),
|
682
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
683
|
+
import_core8.ui.ul,
|
582
684
|
{
|
583
|
-
ref: (0,
|
685
|
+
ref: (0, import_utils8.mergeRefs)(menuRef, ref),
|
686
|
+
className: (0, import_utils8.cx)("ui-menu__list", className),
|
584
687
|
role: "menu",
|
585
|
-
className: (0, import_utils5.cx)("ui-menu__list", className),
|
586
688
|
tabIndex: -1,
|
587
689
|
__css: { ...styles.list },
|
588
690
|
...rest,
|
@@ -594,72 +696,39 @@ var MenuList = (0, import_core4.forwardRef)(
|
|
594
696
|
}
|
595
697
|
);
|
596
698
|
|
597
|
-
// src/menu-group.tsx
|
598
|
-
var import_core5 = require("@yamada-ui/core");
|
599
|
-
var import_utils6 = require("@yamada-ui/utils");
|
600
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
601
|
-
var MenuGroup = (0, import_core5.forwardRef)(
|
602
|
-
({ className, label, children, labelProps, ...rest }, ref) => {
|
603
|
-
const { styles } = useMenu();
|
604
|
-
const css = { ...styles.group };
|
605
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
606
|
-
import_core5.ui.li,
|
607
|
-
{
|
608
|
-
ref,
|
609
|
-
className: (0, import_utils6.cx)("ui-menu__item", "ui-menu__item--group", className),
|
610
|
-
role: "group",
|
611
|
-
__css: css,
|
612
|
-
...rest,
|
613
|
-
children: [
|
614
|
-
label ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
615
|
-
import_core5.ui.span,
|
616
|
-
{
|
617
|
-
className: (0, import_utils6.cx)("ui-menu__item--group-label"),
|
618
|
-
__css: styles.groupLabel,
|
619
|
-
...labelProps,
|
620
|
-
children: label
|
621
|
-
}
|
622
|
-
) : null,
|
623
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.ul, { className: "ui-menu__item__group", children })
|
624
|
-
]
|
625
|
-
}
|
626
|
-
);
|
627
|
-
}
|
628
|
-
);
|
629
|
-
|
630
699
|
// src/menu-option-group.tsx
|
631
700
|
var import_use_controllable_state = require("@yamada-ui/use-controllable-state");
|
632
|
-
var
|
633
|
-
var
|
634
|
-
var
|
635
|
-
var MenuOptionGroup = (0,
|
701
|
+
var import_utils9 = require("@yamada-ui/utils");
|
702
|
+
var import_react6 = require("react");
|
703
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
704
|
+
var MenuOptionGroup = (0, import_react6.forwardRef)(
|
636
705
|
({
|
706
|
+
type,
|
637
707
|
className,
|
638
|
-
|
708
|
+
children,
|
639
709
|
defaultValue,
|
710
|
+
value: valueProp,
|
640
711
|
onChange: onChangeProp,
|
641
|
-
type,
|
642
|
-
children,
|
643
712
|
...rest
|
644
713
|
}, ref) => {
|
645
714
|
const isRadio = type === "radio";
|
646
715
|
defaultValue != null ? defaultValue : defaultValue = isRadio ? "" : [];
|
647
716
|
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
648
|
-
value: valueProp,
|
649
717
|
defaultValue,
|
718
|
+
value: valueProp,
|
650
719
|
onChange: onChangeProp
|
651
720
|
});
|
652
|
-
const onChange = (0,
|
721
|
+
const onChange = (0, import_react6.useCallback)(
|
653
722
|
(selectedValue) => {
|
654
723
|
if (isRadio && typeof value === "string") setValue(selectedValue);
|
655
|
-
if (!isRadio && (0,
|
724
|
+
if (!isRadio && (0, import_utils9.isArray)(value)) {
|
656
725
|
const nextValue = value.includes(selectedValue) ? value.filter((item) => item !== selectedValue) : value.concat(selectedValue);
|
657
726
|
setValue(nextValue);
|
658
727
|
}
|
659
728
|
},
|
660
729
|
[isRadio, value, setValue]
|
661
730
|
);
|
662
|
-
const validChildren = (0,
|
731
|
+
const validChildren = (0, import_utils9.getValidChildren)(children);
|
663
732
|
const cloneChildren = validChildren.map((child) => {
|
664
733
|
if (child.type !== MenuOptionItem) return child;
|
665
734
|
const onClick = (ev) => {
|
@@ -667,14 +736,14 @@ var MenuOptionGroup = (0, import_react5.forwardRef)(
|
|
667
736
|
onChange(child.props.value);
|
668
737
|
(_b = (_a = child.props).onClick) == null ? void 0 : _b.call(_a, ev);
|
669
738
|
};
|
670
|
-
const isChecked = !isRadio && (0,
|
671
|
-
return (0,
|
739
|
+
const isChecked = !isRadio && (0, import_utils9.isArray)(value) ? value.includes(child.props.value) : child.props.value === value;
|
740
|
+
return (0, import_react6.cloneElement)(child, { type, isChecked, onClick });
|
672
741
|
});
|
673
|
-
return /* @__PURE__ */ (0,
|
742
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
674
743
|
MenuGroup,
|
675
744
|
{
|
676
745
|
ref,
|
677
|
-
className: (0,
|
746
|
+
className: (0, import_utils9.cx)("ui-menu__item--group--option", className),
|
678
747
|
...rest,
|
679
748
|
children: cloneChildren
|
680
749
|
}
|
@@ -682,72 +751,6 @@ var MenuOptionGroup = (0, import_react5.forwardRef)(
|
|
682
751
|
}
|
683
752
|
);
|
684
753
|
MenuOptionGroup.displayName = "MenuOptionGroup";
|
685
|
-
|
686
|
-
// src/menu-divider.tsx
|
687
|
-
var import_core6 = require("@yamada-ui/core");
|
688
|
-
var import_utils8 = require("@yamada-ui/utils");
|
689
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
690
|
-
var MenuDivider = (0, import_core6.forwardRef)(
|
691
|
-
({ className, ...rest }, ref) => {
|
692
|
-
const { styles } = useMenu();
|
693
|
-
const css = { ...styles.divider };
|
694
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
695
|
-
import_core6.ui.hr,
|
696
|
-
{
|
697
|
-
ref,
|
698
|
-
className: (0, import_utils8.cx)("ui-menu__divider", className),
|
699
|
-
__css: css,
|
700
|
-
...rest
|
701
|
-
}
|
702
|
-
);
|
703
|
-
}
|
704
|
-
);
|
705
|
-
|
706
|
-
// src/context-menu.tsx
|
707
|
-
var import_core7 = require("@yamada-ui/core");
|
708
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
709
|
-
var ContextMenu = (props) => {
|
710
|
-
const [styles, mergedProps] = (0, import_core7.useComponentMultiStyle)("ContextMenu", props);
|
711
|
-
const { ...rest } = (0, import_core7.omitThemeProps)(mergedProps);
|
712
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ContextMenuProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Menu, { trigger: "contextmenu", ...rest }) });
|
713
|
-
};
|
714
|
-
|
715
|
-
// src/context-menu-trigger.tsx
|
716
|
-
var import_core8 = require("@yamada-ui/core");
|
717
|
-
var import_popover4 = require("@yamada-ui/popover");
|
718
|
-
var import_utils9 = require("@yamada-ui/utils");
|
719
|
-
var import_react6 = require("react");
|
720
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
721
|
-
var ContextMenuTrigger = (0, import_core8.forwardRef)(
|
722
|
-
({ children, className, ...rest }, ref) => {
|
723
|
-
const { styles } = useContextMenu();
|
724
|
-
const [position, setPosition] = (0, import_react6.useState)({ top: 0, left: 0 });
|
725
|
-
const css = { ...styles.container };
|
726
|
-
const onContextMenu = (ev) => {
|
727
|
-
setPosition({ top: ev.pageY, left: ev.pageX });
|
728
|
-
};
|
729
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
730
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover4.PopoverAnchor, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
731
|
-
import_core8.ui.div,
|
732
|
-
{
|
733
|
-
className: "ui-context-menu__anchor",
|
734
|
-
style: { position: "absolute", ...position }
|
735
|
-
}
|
736
|
-
) }),
|
737
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover4.PopoverTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
738
|
-
import_core8.ui.div,
|
739
|
-
{
|
740
|
-
ref,
|
741
|
-
className: (0, import_utils9.cx)("ui-context-menu", className),
|
742
|
-
__css: css,
|
743
|
-
...rest,
|
744
|
-
onContextMenu: (0, import_utils9.handlerAll)(rest.onContextMenu, onContextMenu),
|
745
|
-
children
|
746
|
-
}
|
747
|
-
) })
|
748
|
-
] });
|
749
|
-
}
|
750
|
-
);
|
751
754
|
// Annotate the CommonJS export names for ESM import in node:
|
752
755
|
0 && (module.exports = {
|
753
756
|
ContextMenu,
|