@trackunit/react-components 0.5.25 → 0.5.26
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/index.cjs.js
CHANGED
|
@@ -3908,7 +3908,7 @@ const cvaMenuList = cssClassVarianceUtilities.cvaMerge([
|
|
|
3908
3908
|
});
|
|
3909
3909
|
const cvaMenuListDivider = cssClassVarianceUtilities.cvaMerge(["mx-[-4px]", "my-1", "min-h-px", "bg-slate-300"]);
|
|
3910
3910
|
const cvaMenuListMultiSelect = cssClassVarianceUtilities.cvaMerge("hover:!bg-blue-200");
|
|
3911
|
-
const cvaMenuListItem = cssClassVarianceUtilities.cvaMerge("max-w-[
|
|
3911
|
+
const cvaMenuListItem = cssClassVarianceUtilities.cvaMerge("max-w-[292px]");
|
|
3912
3912
|
|
|
3913
3913
|
/**
|
|
3914
3914
|
* The MenuDivider component is used to separate items in a menu list.
|
|
@@ -3974,15 +3974,11 @@ const cvaInteractableItem = cssClassVarianceUtilities.cvaMerge("", {
|
|
|
3974
3974
|
* The cvaInteractableItem variant is used to set the standardized styles that change through interaction with the element (background color, hover, focus, and disabled).
|
|
3975
3975
|
*/
|
|
3976
3976
|
const cvaMenuItem = (props) => {
|
|
3977
|
-
const {
|
|
3978
|
-
return tailwindMerge.twMerge(cvaMenuItemStyle({
|
|
3977
|
+
const { selected, disabled, focused, className, variant } = props !== null && props !== void 0 ? props : {};
|
|
3978
|
+
return tailwindMerge.twMerge(cvaMenuItemStyle({ variant, selected, disabled }), cvaInteractableItem({ selected, disabled, cursor: "pointer", focused }), className);
|
|
3979
3979
|
};
|
|
3980
3980
|
const cvaMenuItemStyle = cssClassVarianceUtilities.cvaMerge(["py-2", "px-2", "h-auto", "flex", "flex-row", "items-center", "gap-x-2", "select-none", "rounded", "text-sm"], {
|
|
3981
3981
|
variants: {
|
|
3982
|
-
size: {
|
|
3983
|
-
small: "py-1",
|
|
3984
|
-
medium: "py-2",
|
|
3985
|
-
},
|
|
3986
3982
|
variant: {
|
|
3987
3983
|
primary: [],
|
|
3988
3984
|
danger: [
|
|
@@ -4079,7 +4075,7 @@ const cvaMenuItemSuffix = cssClassVarianceUtilities.cvaMerge(["text-secondary-40
|
|
|
4079
4075
|
* @param {MenuItemProps} props - The props for the MenuItem component
|
|
4080
4076
|
* @returns {JSX.Element} MenuItem component
|
|
4081
4077
|
*/
|
|
4082
|
-
const MenuItem = ({ className, dataTestId, label,
|
|
4078
|
+
const MenuItem = ({ className, dataTestId, label, children, selected, prefix, suffix, disabled, onClick, stopPropagation = true, id, tabIndex, optionLabelDescription, variant = "primary", }) => {
|
|
4083
4079
|
/* Handle tab navigation */
|
|
4084
4080
|
const handleKeyDown = (e) => {
|
|
4085
4081
|
if (e.key === "Enter" && onClick && !disabled) {
|
|
@@ -4091,7 +4087,6 @@ const MenuItem = ({ className, dataTestId, label, size, children, selected, pref
|
|
|
4091
4087
|
return (jsxRuntime.jsxs("div", { "aria-disabled": disabled, className: cvaMenuItem({
|
|
4092
4088
|
selected,
|
|
4093
4089
|
disabled,
|
|
4094
|
-
size,
|
|
4095
4090
|
className,
|
|
4096
4091
|
variant,
|
|
4097
4092
|
}), "data-testid": dataTestId ? `${dataTestId}-menu-item` : "menu-item", id: id, onClick: e => {
|
|
@@ -4146,7 +4141,7 @@ const MenuList = ({ dataTestId, className, children, withStickyHeader = false, i
|
|
|
4146
4141
|
? cvaMenuListMultiSelect({ className: menuItem.props.className })
|
|
4147
4142
|
: cvaMenuListItem({ className: menuItem.props.className }),
|
|
4148
4143
|
selected: isSelected,
|
|
4149
|
-
suffix: isMulti && isSelected ?
|
|
4144
|
+
suffix: isMulti && isSelected ? jsxRuntime.jsx(Icon, { className: "block text-blue-600", name: "Check", size: "medium" }) : null,
|
|
4150
4145
|
}) }, index));
|
|
4151
4146
|
}
|
|
4152
4147
|
return null;
|
|
@@ -4164,14 +4159,15 @@ const cvaMoreMenu = cssClassVarianceUtilities.cvaMerge(["p-0"]);
|
|
|
4164
4159
|
*/
|
|
4165
4160
|
const MoreMenu = ({ className, dataTestId, popoverProps, iconProps = {
|
|
4166
4161
|
size: "medium",
|
|
4162
|
+
className: "text-secondary-800",
|
|
4167
4163
|
}, iconButtonProps = {
|
|
4168
|
-
size: "
|
|
4164
|
+
size: "medium",
|
|
4169
4165
|
circular: false,
|
|
4170
4166
|
square: true,
|
|
4171
4167
|
variant: "secondary",
|
|
4172
4168
|
}, customButton, customPortalId, children, }) => {
|
|
4173
4169
|
const actionMenuRef = React.useRef(null);
|
|
4174
|
-
return (jsxRuntime.jsx("div", { className: cvaMoreMenu({ className }), "data-testid": dataTestId, ref: actionMenuRef, children: jsxRuntime.jsxs(Popover, { placement: "bottom-end", ...popoverProps, children: [jsxRuntime.jsx(PopoverTrigger, { children: customButton !== null && customButton !== void 0 ? customButton : (jsxRuntime.jsx(IconButton, { dataTestId: "more-menu-icon", ...iconButtonProps, icon: jsxRuntime.jsx(Icon, { name: "EllipsisHorizontal", ...iconProps }) })) }), jsxRuntime.jsx(PopoverContent, { portalId: customPortalId, children: close => (typeof children === "function" ? children(close) : children) })] }) }));
|
|
4170
|
+
return (jsxRuntime.jsx("div", { className: cvaMoreMenu({ className }), "data-testid": dataTestId ? dataTestId : "more-menu", ref: actionMenuRef, children: jsxRuntime.jsxs(Popover, { placement: "bottom-end", ...popoverProps, children: [jsxRuntime.jsx(PopoverTrigger, { children: customButton !== null && customButton !== void 0 ? customButton : (jsxRuntime.jsx(IconButton, { dataTestId: "more-menu-icon", ...iconButtonProps, icon: jsxRuntime.jsx(Icon, { name: "EllipsisHorizontal", ...iconProps }) })) }), jsxRuntime.jsx(PopoverContent, { portalId: customPortalId, children: close => (typeof children === "function" ? children(close) : children) })] }) }));
|
|
4175
4171
|
};
|
|
4176
4172
|
|
|
4177
4173
|
const cvaNotice = cssClassVarianceUtilities.cvaMerge(["flex", "items-center"]);
|
|
@@ -4595,7 +4591,6 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
4595
4591
|
className: tailwindMerge.twMerge(child.props.className, itemVisibilityClassName(child.props.id)),
|
|
4596
4592
|
});
|
|
4597
4593
|
}) }), overflowItemCount > 0 ? (jsxRuntime.jsx(MoreMenu, { iconButtonProps: {
|
|
4598
|
-
circular: false,
|
|
4599
4594
|
variant: "ghost-neutral",
|
|
4600
4595
|
}, ...moreMenuProps, className: moreMenuProps === null || moreMenuProps === void 0 ? void 0 : moreMenuProps.className, dataTestId: dataTestId ? `${dataTestId}-more-menu` : undefined, children: close => (jsxRuntime.jsx(MenuList, { ...menuListProps, dataTestId: dataTestId, children: React.Children.map(children, child => {
|
|
4601
4596
|
return itemOverflowMap[child.props.id]
|
package/index.esm.js
CHANGED
|
@@ -3888,7 +3888,7 @@ const cvaMenuList = cvaMerge([
|
|
|
3888
3888
|
});
|
|
3889
3889
|
const cvaMenuListDivider = cvaMerge(["mx-[-4px]", "my-1", "min-h-px", "bg-slate-300"]);
|
|
3890
3890
|
const cvaMenuListMultiSelect = cvaMerge("hover:!bg-blue-200");
|
|
3891
|
-
const cvaMenuListItem = cvaMerge("max-w-[
|
|
3891
|
+
const cvaMenuListItem = cvaMerge("max-w-[292px]");
|
|
3892
3892
|
|
|
3893
3893
|
/**
|
|
3894
3894
|
* The MenuDivider component is used to separate items in a menu list.
|
|
@@ -3954,15 +3954,11 @@ const cvaInteractableItem = cvaMerge("", {
|
|
|
3954
3954
|
* The cvaInteractableItem variant is used to set the standardized styles that change through interaction with the element (background color, hover, focus, and disabled).
|
|
3955
3955
|
*/
|
|
3956
3956
|
const cvaMenuItem = (props) => {
|
|
3957
|
-
const {
|
|
3958
|
-
return twMerge(cvaMenuItemStyle({
|
|
3957
|
+
const { selected, disabled, focused, className, variant } = props !== null && props !== void 0 ? props : {};
|
|
3958
|
+
return twMerge(cvaMenuItemStyle({ variant, selected, disabled }), cvaInteractableItem({ selected, disabled, cursor: "pointer", focused }), className);
|
|
3959
3959
|
};
|
|
3960
3960
|
const cvaMenuItemStyle = cvaMerge(["py-2", "px-2", "h-auto", "flex", "flex-row", "items-center", "gap-x-2", "select-none", "rounded", "text-sm"], {
|
|
3961
3961
|
variants: {
|
|
3962
|
-
size: {
|
|
3963
|
-
small: "py-1",
|
|
3964
|
-
medium: "py-2",
|
|
3965
|
-
},
|
|
3966
3962
|
variant: {
|
|
3967
3963
|
primary: [],
|
|
3968
3964
|
danger: [
|
|
@@ -4059,7 +4055,7 @@ const cvaMenuItemSuffix = cvaMerge(["text-secondary-400", "text-sm"], {
|
|
|
4059
4055
|
* @param {MenuItemProps} props - The props for the MenuItem component
|
|
4060
4056
|
* @returns {JSX.Element} MenuItem component
|
|
4061
4057
|
*/
|
|
4062
|
-
const MenuItem = ({ className, dataTestId, label,
|
|
4058
|
+
const MenuItem = ({ className, dataTestId, label, children, selected, prefix, suffix, disabled, onClick, stopPropagation = true, id, tabIndex, optionLabelDescription, variant = "primary", }) => {
|
|
4063
4059
|
/* Handle tab navigation */
|
|
4064
4060
|
const handleKeyDown = (e) => {
|
|
4065
4061
|
if (e.key === "Enter" && onClick && !disabled) {
|
|
@@ -4071,7 +4067,6 @@ const MenuItem = ({ className, dataTestId, label, size, children, selected, pref
|
|
|
4071
4067
|
return (jsxs("div", { "aria-disabled": disabled, className: cvaMenuItem({
|
|
4072
4068
|
selected,
|
|
4073
4069
|
disabled,
|
|
4074
|
-
size,
|
|
4075
4070
|
className,
|
|
4076
4071
|
variant,
|
|
4077
4072
|
}), "data-testid": dataTestId ? `${dataTestId}-menu-item` : "menu-item", id: id, onClick: e => {
|
|
@@ -4126,7 +4121,7 @@ const MenuList = ({ dataTestId, className, children, withStickyHeader = false, i
|
|
|
4126
4121
|
? cvaMenuListMultiSelect({ className: menuItem.props.className })
|
|
4127
4122
|
: cvaMenuListItem({ className: menuItem.props.className }),
|
|
4128
4123
|
selected: isSelected,
|
|
4129
|
-
suffix: isMulti && isSelected ?
|
|
4124
|
+
suffix: isMulti && isSelected ? jsx(Icon, { className: "block text-blue-600", name: "Check", size: "medium" }) : null,
|
|
4130
4125
|
}) }, index));
|
|
4131
4126
|
}
|
|
4132
4127
|
return null;
|
|
@@ -4144,14 +4139,15 @@ const cvaMoreMenu = cvaMerge(["p-0"]);
|
|
|
4144
4139
|
*/
|
|
4145
4140
|
const MoreMenu = ({ className, dataTestId, popoverProps, iconProps = {
|
|
4146
4141
|
size: "medium",
|
|
4142
|
+
className: "text-secondary-800",
|
|
4147
4143
|
}, iconButtonProps = {
|
|
4148
|
-
size: "
|
|
4144
|
+
size: "medium",
|
|
4149
4145
|
circular: false,
|
|
4150
4146
|
square: true,
|
|
4151
4147
|
variant: "secondary",
|
|
4152
4148
|
}, customButton, customPortalId, children, }) => {
|
|
4153
4149
|
const actionMenuRef = useRef(null);
|
|
4154
|
-
return (jsx("div", { className: cvaMoreMenu({ className }), "data-testid": dataTestId, ref: actionMenuRef, children: jsxs(Popover, { placement: "bottom-end", ...popoverProps, children: [jsx(PopoverTrigger, { children: customButton !== null && customButton !== void 0 ? customButton : (jsx(IconButton, { dataTestId: "more-menu-icon", ...iconButtonProps, icon: jsx(Icon, { name: "EllipsisHorizontal", ...iconProps }) })) }), jsx(PopoverContent, { portalId: customPortalId, children: close => (typeof children === "function" ? children(close) : children) })] }) }));
|
|
4150
|
+
return (jsx("div", { className: cvaMoreMenu({ className }), "data-testid": dataTestId ? dataTestId : "more-menu", ref: actionMenuRef, children: jsxs(Popover, { placement: "bottom-end", ...popoverProps, children: [jsx(PopoverTrigger, { children: customButton !== null && customButton !== void 0 ? customButton : (jsx(IconButton, { dataTestId: "more-menu-icon", ...iconButtonProps, icon: jsx(Icon, { name: "EllipsisHorizontal", ...iconProps }) })) }), jsx(PopoverContent, { portalId: customPortalId, children: close => (typeof children === "function" ? children(close) : children) })] }) }));
|
|
4155
4151
|
};
|
|
4156
4152
|
|
|
4157
4153
|
const cvaNotice = cvaMerge(["flex", "items-center"]);
|
|
@@ -4575,7 +4571,6 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
4575
4571
|
className: twMerge(child.props.className, itemVisibilityClassName(child.props.id)),
|
|
4576
4572
|
});
|
|
4577
4573
|
}) }), overflowItemCount > 0 ? (jsx(MoreMenu, { iconButtonProps: {
|
|
4578
|
-
circular: false,
|
|
4579
4574
|
variant: "ghost-neutral",
|
|
4580
4575
|
}, ...moreMenuProps, className: moreMenuProps === null || moreMenuProps === void 0 ? void 0 : moreMenuProps.className, dataTestId: dataTestId ? `${dataTestId}-more-menu` : undefined, children: close => (jsx(MenuList, { ...menuListProps, dataTestId: dataTestId, children: React__default.Children.map(children, child => {
|
|
4581
4576
|
return itemOverflowMap[child.props.id]
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CommonProps
|
|
2
|
-
type MenuItemSize = Extract<Size, "small" | "medium">;
|
|
1
|
+
import { CommonProps } from "../../../common";
|
|
3
2
|
export type MenuItemVariant = "primary" | "danger";
|
|
4
3
|
export interface MenuItemProps extends CommonProps {
|
|
5
4
|
/**
|
|
@@ -15,10 +14,6 @@ export interface MenuItemProps extends CommonProps {
|
|
|
15
14
|
* If you use this prop, the label prop will be ignored.
|
|
16
15
|
*/
|
|
17
16
|
children?: React.ReactNode;
|
|
18
|
-
/**
|
|
19
|
-
* Size of the menu item
|
|
20
|
-
*/
|
|
21
|
-
size?: MenuItemSize;
|
|
22
17
|
/**
|
|
23
18
|
* An React element to render before the label.
|
|
24
19
|
* This is typically used to render an icon.
|
|
@@ -73,5 +68,4 @@ export interface MenuItemProps extends CommonProps {
|
|
|
73
68
|
* @param {MenuItemProps} props - The props for the MenuItem component
|
|
74
69
|
* @returns {JSX.Element} MenuItem component
|
|
75
70
|
*/
|
|
76
|
-
export declare const MenuItem: ({ className, dataTestId, label,
|
|
77
|
-
export {};
|
|
71
|
+
export declare const MenuItem: ({ className, dataTestId, label, children, selected, prefix, suffix, disabled, onClick, stopPropagation, id, tabIndex, optionLabelDescription, variant, }: MenuItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,6 @@ import { MappedOmit } from "@trackunit/shared-utils";
|
|
|
3
3
|
import { cvaInteractableItem } from "../../InteractableItem/InteractableItem.variants";
|
|
4
4
|
import { MenuItemVariant } from "./MenuItem";
|
|
5
5
|
type CvaMenuItemProps = Partial<MappedOmit<VariantProps<typeof cvaInteractableItem>, "cursor">> & {
|
|
6
|
-
size?: "small" | "medium";
|
|
7
6
|
variant?: MenuItemVariant;
|
|
8
7
|
selected?: boolean | null | undefined;
|
|
9
8
|
};
|
|
@@ -13,7 +12,6 @@ type CvaMenuItemProps = Partial<MappedOmit<VariantProps<typeof cvaInteractableIt
|
|
|
13
12
|
*/
|
|
14
13
|
export declare const cvaMenuItem: (props?: CvaMenuItemProps) => string;
|
|
15
14
|
export declare const cvaMenuItemStyle: (props?: ({
|
|
16
|
-
size?: "small" | "medium" | null | undefined;
|
|
17
15
|
variant?: "primary" | "danger" | null | undefined;
|
|
18
16
|
selected?: boolean | null | undefined;
|
|
19
17
|
disabled?: boolean | null | undefined;
|