@choice-ui/react 1.8.2 → 1.8.3
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.
|
@@ -2,6 +2,7 @@ import { MenuItemProps } from '../components/menu-item';
|
|
|
2
2
|
export interface MenuContextItemProps extends MenuItemProps {
|
|
3
3
|
customActive?: boolean;
|
|
4
4
|
exclusiveIndex?: number;
|
|
5
|
+
href?: string;
|
|
5
6
|
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
6
7
|
onKeyDown?: (e: React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
7
8
|
onMouseUp?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Check } from "@choiceform/icons-react";
|
|
2
|
+
import { Check, Launch } from "@choiceform/icons-react";
|
|
3
3
|
import { useListItem, useFloatingTree } from "@floating-ui/react";
|
|
4
4
|
import { memo, forwardRef, useContext, useMemo, startTransition, useCallback } from "react";
|
|
5
5
|
import { useEventCallback } from "usehooks-ts";
|
|
@@ -15,7 +15,9 @@ const MenuContextItem = memo(
|
|
|
15
15
|
size,
|
|
16
16
|
shortcut,
|
|
17
17
|
prefixElement,
|
|
18
|
+
suffixElement,
|
|
18
19
|
variant,
|
|
20
|
+
href,
|
|
19
21
|
onClick,
|
|
20
22
|
onMouseUp,
|
|
21
23
|
onTouchStart,
|
|
@@ -80,6 +82,13 @@ const MenuContextItem = memo(
|
|
|
80
82
|
}),
|
|
81
83
|
[shortcut == null ? void 0 : shortcut.modifier, shortcut == null ? void 0 : shortcut.keys]
|
|
82
84
|
);
|
|
85
|
+
const suffixConfig = useMemo(() => {
|
|
86
|
+
if (suffixElement !== void 0) return suffixElement;
|
|
87
|
+
if (href) {
|
|
88
|
+
return /* @__PURE__ */ jsx(Launch, { className: "h-3 w-3" });
|
|
89
|
+
}
|
|
90
|
+
return void 0;
|
|
91
|
+
}, [suffixElement, href]);
|
|
83
92
|
const combinedRef = useCallback(
|
|
84
93
|
(node) => {
|
|
85
94
|
item.ref(node);
|
|
@@ -102,6 +111,7 @@ const MenuContextItem = memo(
|
|
|
102
111
|
disabled,
|
|
103
112
|
selected,
|
|
104
113
|
prefixElement: prefixConfig,
|
|
114
|
+
suffixElement: suffixConfig,
|
|
105
115
|
shortcut: shortcutConfig,
|
|
106
116
|
variant,
|
|
107
117
|
size,
|
package/package.json
CHANGED