@firecms/ui 3.0.0-canary.8 → 3.0.0-canary.80

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.
Files changed (89) hide show
  1. package/README.md +1 -1
  2. package/dist/components/Avatar.d.ts +1 -0
  3. package/dist/components/BooleanSwitch.d.ts +1 -1
  4. package/dist/components/CenteredView.d.ts +4 -2
  5. package/dist/components/Checkbox.d.ts +4 -3
  6. package/dist/components/DateTimeField.d.ts +2 -2
  7. package/dist/components/InputLabel.d.ts +2 -2
  8. package/dist/components/Label.d.ts +4 -1
  9. package/dist/components/Markdown.d.ts +1 -0
  10. package/dist/components/Menu.d.ts +2 -1
  11. package/dist/components/Menubar.d.ts +69 -0
  12. package/dist/components/RadioGroup.d.ts +25 -3
  13. package/dist/components/Select.d.ts +1 -1
  14. package/dist/components/TextField.d.ts +1 -1
  15. package/dist/components/TextareaAutosize.d.ts +3 -34
  16. package/dist/components/index.d.ts +1 -1
  17. package/dist/hooks/index.d.ts +4 -0
  18. package/dist/hooks/useLocaleConfig.d.ts +1 -0
  19. package/dist/icons/Icon.d.ts +2 -2
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.es.js +8362 -8066
  22. package/dist/index.es.js.map +1 -1
  23. package/dist/index.umd.js +10 -10
  24. package/dist/index.umd.js.map +1 -1
  25. package/dist/styles.d.ts +6 -6
  26. package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
  27. package/dist/util/index.d.ts +1 -3
  28. package/package.json +39 -49
  29. package/src/components/Alert.tsx +2 -2
  30. package/src/components/Autocomplete.tsx +4 -3
  31. package/src/components/Avatar.tsx +7 -4
  32. package/src/components/Badge.tsx +1 -1
  33. package/src/components/BooleanSwitch.tsx +9 -9
  34. package/src/components/BooleanSwitchWithLabel.tsx +5 -5
  35. package/src/components/Button.tsx +7 -7
  36. package/src/components/Card.tsx +2 -2
  37. package/src/components/CenteredView.tsx +25 -15
  38. package/src/components/Checkbox.tsx +31 -24
  39. package/src/components/Chip.tsx +2 -2
  40. package/src/components/CircularProgress.tsx +2 -2
  41. package/src/components/Collapse.tsx +3 -2
  42. package/src/components/Container.tsx +2 -2
  43. package/src/components/DateTimeField.tsx +10 -9
  44. package/src/components/Dialog.tsx +4 -4
  45. package/src/components/DialogActions.tsx +2 -2
  46. package/src/components/DialogContent.tsx +2 -2
  47. package/src/components/ExpandablePanel.tsx +8 -6
  48. package/src/components/FileUpload.tsx +5 -7
  49. package/src/components/IconButton.tsx +3 -3
  50. package/src/components/InfoLabel.tsx +2 -2
  51. package/src/components/InputLabel.tsx +10 -9
  52. package/src/components/Label.tsx +17 -4
  53. package/src/components/Markdown.tsx +14 -3
  54. package/src/components/Menu.tsx +13 -7
  55. package/src/components/Menubar.tsx +287 -0
  56. package/src/components/MultiSelect.tsx +7 -6
  57. package/src/components/Paper.tsx +2 -2
  58. package/src/components/Popover.tsx +3 -2
  59. package/src/components/RadioGroup.tsx +40 -9
  60. package/src/components/SearchBar.tsx +6 -6
  61. package/src/components/Select.tsx +24 -23
  62. package/src/components/Sheet.tsx +7 -7
  63. package/src/components/Skeleton.tsx +8 -5
  64. package/src/components/Table.tsx +6 -6
  65. package/src/components/Tabs.tsx +5 -5
  66. package/src/components/TextField.tsx +8 -7
  67. package/src/components/TextareaAutosize.tsx +3 -3
  68. package/src/components/Tooltip.tsx +4 -3
  69. package/src/components/Typography.tsx +20 -3
  70. package/src/components/common/SelectInputLabel.tsx +2 -2
  71. package/src/components/index.tsx +1 -1
  72. package/src/hooks/index.ts +4 -0
  73. package/src/hooks/useLocaleConfig.tsx +18 -0
  74. package/src/icons/Icon.tsx +44 -41
  75. package/src/index.ts +1 -0
  76. package/src/scripts/generateIconKeys.ts +0 -1
  77. package/src/styles.ts +6 -6
  78. package/src/util/cls.ts +14 -0
  79. package/src/util/index.ts +1 -3
  80. package/tailwind.config.js +70 -0
  81. package/dist/components/Spinner.d.ts +0 -1
  82. package/src/components/Spinner.tsx +0 -18
  83. package/src/util/cn.ts +0 -6
  84. /package/dist/{util → hooks}/useDebounceValue.d.ts +0 -0
  85. /package/dist/{util → hooks}/useInjectStyles.d.ts +0 -0
  86. /package/dist/{util → hooks}/useOutsideAlerter.d.ts +0 -0
  87. /package/src/{util → hooks}/useDebounceValue.tsx +0 -0
  88. /package/src/{util → hooks}/useInjectStyles.tsx +0 -0
  89. /package/src/{util → hooks}/useOutsideAlerter.tsx +0 -0
@@ -1,5 +1,5 @@
1
1
  import React, { ForwardRefRenderFunction } from "react";
2
- import { cn } from "../util";
2
+ import { cls } from "../util";
3
3
 
4
4
  export type ContainerProps = {
5
5
  children: React.ReactNode;
@@ -37,7 +37,7 @@ const ContainerInner: ForwardRefRenderFunction<HTMLDivElement, ContainerProps> =
37
37
  return (
38
38
  <div
39
39
  ref={ref}
40
- className={cn("mx-auto px-3 md:px-4 lg-px-6",
40
+ className={cls("mx-auto px-3 md:px-4 lg-px-6",
41
41
  classForMaxWidth,
42
42
  className)}
43
43
  style={style}>
@@ -12,17 +12,18 @@ import {
12
12
  paperMixin
13
13
  } from "../styles";
14
14
  import { InputLabel } from "./InputLabel";
15
- import { cn, useInjectStyles } from "../util";
16
15
  import { Typography } from "./Typography";
16
+ import { cls } from "../util";
17
+ import { useInjectStyles } from "../hooks";
17
18
 
18
19
  interface DateTimeFieldProps {
19
20
  value?: Date;
20
- onChange: (date: Date | null) => void;
21
+ onChange: (date: Date | undefined) => void;
21
22
  mode?: "date" | "date_time";
22
23
  disabled?: boolean;
23
24
  clearable?: boolean;
24
25
  error?: boolean;
25
- size: "small" | "medium";
26
+ size?: "small" | "medium";
26
27
  label?: React.ReactNode;
27
28
  className?: string;
28
29
  style?: React.CSSProperties;
@@ -40,7 +41,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
40
41
  clearable,
41
42
  mode = "date",
42
43
  error,
43
- size,
44
+ size = "medium",
44
45
  className,
45
46
  style,
46
47
  inputClassName,
@@ -60,14 +61,14 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
60
61
 
61
62
  const handleClear = (e: React.MouseEvent) => {
62
63
  e.preventDefault();
63
- onChange(null);
64
+ onChange(undefined);
64
65
  }
65
66
 
66
67
  return (
67
68
  <>
68
69
 
69
70
  <div
70
- className={cn(
71
+ className={cls(
71
72
  "rounded-md relative max-w-full",
72
73
  !invisible && fieldBackgroundMixin,
73
74
  disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
@@ -80,7 +81,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
80
81
 
81
82
  {label && (
82
83
  <InputLabel
83
- className={cn("absolute top-1 pointer-events-none",
84
+ className={cls("absolute top-1 pointer-events-none",
84
85
  !error ? (focused ? "text-primary" : "text-text-secondary dark:text-text-secondary-dark") : "text-red-500 dark:text-red-500",
85
86
  disabled ? "opacity-50" : "")}
86
87
  shrink={hasValue || focused}
@@ -95,7 +96,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
95
96
  selected={(invalidValue ? null : value) ?? null}
96
97
  onChange={onChange}
97
98
  disabled={false}
98
- popperClassName={cn(paperMixin, "my-4 shadow")}
99
+ popperClassName={cls(paperMixin, "my-4 shadow")}
99
100
  onClick={(e: any) => e.stopPropagation()}
100
101
  onFocus={() => setFocused(true)}
101
102
  onBlur={() => setFocused(false)}
@@ -105,7 +106,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
105
106
  timeCaption="time"
106
107
  dateFormat={mode === "date_time" ? "Pp" : "P"}
107
108
  preventOpenOnFocus={true}
108
- className={cn(
109
+ className={cls(
109
110
  "w-full outline-none bg-transparent leading-normal text-base px-3",
110
111
  clearable ? "pr-14" : "pr-12",
111
112
  "rounded-md",
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState } from "react";
2
2
  import * as DialogPrimitive from "@radix-ui/react-dialog";
3
3
  import { paperMixin } from "../styles";
4
- import { cn } from "../util";
4
+ import { cls } from "../util";
5
5
 
6
6
  export type DialogProps = {
7
7
  open?: boolean;
@@ -69,7 +69,7 @@ export const Dialog = ({
69
69
  <div className={"fixed inset-0 z-30"}>
70
70
 
71
71
  <DialogPrimitive.Overlay
72
- className={cn("fixed inset-0 transition-opacity z-20 ease-in-out duration-200 bg-black bg-opacity-50 dark:bg-opacity-60 backdrop-blur-sm ",
72
+ className={cls("fixed inset-0 transition-opacity z-20 ease-in-out duration-200 bg-black bg-opacity-50 dark:bg-opacity-60 backdrop-blur-sm ",
73
73
  displayed && open ? "opacity-100" : "opacity-0",
74
74
  "z-20 fixed top-0 left-0 w-full h-full flex justify-center items-center"
75
75
  )}
@@ -80,10 +80,10 @@ export const Dialog = ({
80
80
 
81
81
  <DialogPrimitive.Content
82
82
  onOpenAutoFocus={onOpenAutoFocus}
83
- className={cn("h-full outline-none flex justify-center items-center z-40 opacity-100 transition-all duration-200 ease-in-out")}
83
+ className={cls("h-full outline-none flex justify-center items-center z-40 opacity-100 transition-all duration-200 ease-in-out")}
84
84
  >
85
85
  <div
86
- className={cn(paperMixin,
86
+ className={cls(paperMixin,
87
87
  "z-30",
88
88
  "relative",
89
89
  "outline-none focus:outline-none",
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { defaultBorderMixin } from "../styles";
3
- import { cn } from "../util";
3
+ import { cls } from "../util";
4
4
 
5
5
  export function DialogActions({
6
6
  children,
@@ -15,7 +15,7 @@ export function DialogActions({
15
15
  }) {
16
16
 
17
17
  return <div
18
- className={cn(
18
+ className={cls(
19
19
  defaultBorderMixin,
20
20
  "py-3 px-4 border-t flex flex-row items-center justify-end bottom-0 right-0 left-0 text-right z-2 gap-2",
21
21
  position,
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { cn } from "../util";
2
+ import { cls } from "../util";
3
3
 
4
4
  export function DialogContent({
5
5
  children,
@@ -17,7 +17,7 @@ export function DialogContent({
17
17
  </div>;
18
18
 
19
19
  return <div
20
- className={cn("py-6 px-6 h-full flex-grow", className)}>
20
+ className={cls("py-6 px-6 h-full flex-grow", className)}>
21
21
  {children}
22
22
  </div>;
23
23
  }
@@ -3,7 +3,8 @@ import React, { PropsWithChildren, useEffect, useState } from "react";
3
3
  import * as Collapsible from "@radix-ui/react-collapsible";
4
4
  import { defaultBorderMixin, fieldBackgroundMixin, focusedMixin } from "../styles";
5
5
  import { ExpandMoreIcon } from "../icons";
6
- import { cn, useInjectStyles } from "../util";
6
+ import { cls } from "../util";
7
+ import { useInjectStyles } from "../hooks";
7
8
 
8
9
  export function ExpandablePanel({
9
10
  title,
@@ -75,9 +76,10 @@ export function ExpandablePanel({
75
76
 
76
77
  return (<>
77
78
  <Collapsible.Root
78
- className={cn(
79
+ className={cls(
79
80
  !invisible && defaultBorderMixin + " border",
80
- "rounded-md"
81
+ "rounded-md",
82
+ "w-full"
81
83
  )}
82
84
  open={open}
83
85
  onOpenChange={(updatedOpen: boolean) => {
@@ -86,7 +88,7 @@ export function ExpandablePanel({
86
88
  }}>
87
89
 
88
90
  <Collapsible.Trigger
89
- className={cn(focusedMixin,
91
+ className={cls(focusedMixin,
90
92
  "rounded flex items-center justify-between w-full min-h-[52px]",
91
93
  "hover:bg-slate-50 dark:hover:bg-gray-800 dark:hover:bg-opacity-10",
92
94
  invisible ? "border-b px-2" : "p-4",
@@ -96,11 +98,11 @@ export function ExpandablePanel({
96
98
  )}
97
99
  >
98
100
  {title}
99
- <ExpandMoreIcon className={cn("transition", open ? "rotate-180" : "")}/>
101
+ <ExpandMoreIcon className={cls("transition", open ? "rotate-180" : "")}/>
100
102
  </Collapsible.Trigger>
101
103
 
102
104
  <Collapsible.Content
103
- className={cn("CollapsibleContent")}
105
+ className={cls("CollapsibleContent")}
104
106
  style={{
105
107
  overflow: allowOverflow ? "visible" : "hidden"
106
108
  }}
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { useDropzone } from "react-dropzone";
3
3
  import { fieldBackgroundHoverMixin, fieldBackgroundMixin, focusedMixin } from "../styles";
4
- import { cn } from "../util";
4
+ import { cls } from "../util";
5
5
  import { Typography } from "./Typography";
6
6
 
7
7
  export interface FileUploadError {
@@ -38,7 +38,7 @@ export function FileUpload({
38
38
  disabled,
39
39
  maxFiles,
40
40
  title,
41
- uploadDescription = "Drag and drop a file here or click",
41
+ uploadDescription,
42
42
  children,
43
43
  preventDropOnDocument = true,
44
44
  size
@@ -63,9 +63,8 @@ export function FileUpload({
63
63
  );
64
64
  return <div
65
65
  {...getRootProps()}
66
- className={cn(
66
+ className={cls(
67
67
  fieldBackgroundMixin,
68
- fieldBackgroundHoverMixin,
69
68
  focusedMixin,
70
69
  "flex gap-2",
71
70
  "p-4 box-border relative items-center border-2 border-solid border-transparent outline-none rounded-md duration-200 ease-[cubic-bezier(0.4,0,0.2,1)] focus:border-primary-solid",
@@ -73,11 +72,10 @@ export function FileUpload({
73
72
  "h-44": size === "medium",
74
73
  "h-28": size === "small",
75
74
  "cursor-pointer": !disabled,
76
- "hover:bg-field-hover dark:hover:bg-field-hover-dark": !isDragActive,
75
+ [fieldBackgroundHoverMixin]: !isDragActive,
77
76
  "transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-red-500": isDragReject,
78
77
  "transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-green-500": isDragAccept,
79
- })}
80
- >
78
+ })}>
81
79
 
82
80
  <Typography variant={"caption"} color={"secondary"} className={"absolute top-2 left-3.5 cursor-inherit"}>
83
81
  {title}
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { focusedMixin } from "../styles";
3
- import { cn } from "../util";
3
+ import { cls } from "../util";
4
4
 
5
5
  export type IconButtonProps<C extends React.ElementType> =
6
6
  Omit<(C extends "button" ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.ComponentProps<C>), "onClick">
@@ -42,14 +42,14 @@ const IconButtonInner = <C extends React.ElementType = "button">({
42
42
  ...props
43
43
  }: IconButtonProps<C>, ref: React.ForwardedRef<HTMLButtonElement>) => {
44
44
 
45
- const bgClasses = variant === "ghost" ? "bg-transparent" : "bg-slate-50 dark:bg-gray-950 dark:bg-opacity-50";
45
+ const bgClasses = variant === "ghost" ? "bg-transparent" : "bg-slate-200 bg-opacity-50 dark:bg-gray-950 dark:bg-opacity-50";
46
46
  const Component: React.ElementType<any> = component || "button";
47
47
  return (
48
48
  <Component
49
49
  type="button"
50
50
  ref={ref}
51
51
  {...props}
52
- className={cn(
52
+ className={cls(
53
53
  focusedMixin,
54
54
  disabled ? "opacity-50 pointer-events-none" : "cursor-pointer",
55
55
  toggled ? "outline outline-2 outline-primary" : "",
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { cn } from "../util";
2
+ import { cls } from "../util";
3
3
 
4
4
  const colorClasses = {
5
5
  info: "bg-sky-200 dark:bg-teal-900",
@@ -16,7 +16,7 @@ export function InfoLabel({
16
16
 
17
17
  return (
18
18
  <div
19
- className={cn("my-3 py-2 px-4 rounded", colorClasses[mode])}>
19
+ className={cls("my-3 py-2 px-4 rounded", colorClasses[mode])}>
20
20
  {children}
21
21
  </div>
22
22
  )
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
- import { cn } from "../util";
2
+ import { cls } from "../util";
3
+ import { Label } from "./Label";
3
4
 
4
5
  export type InputLabelProps = {
5
6
  children?: React.ReactNode;
@@ -7,6 +8,12 @@ export type InputLabelProps = {
7
8
  shrink?: boolean;
8
9
  } & React.LabelHTMLAttributes<HTMLLabelElement>;
9
10
 
11
+ const defaultClasses = {
12
+ root: "origin-left transition-transform block whitespace-nowrap overflow-hidden text-overflow-ellipsis max-w-full",
13
+ shrink: "transform translate-y-[2px] scale-75 translate-x-[12px]",
14
+ expanded: "translate-x-[16px] top-0 transform translate-y-[16px] scale-100"
15
+ };
16
+
10
17
  export const InputLabel = React.forwardRef<HTMLLabelElement, InputLabelProps>(function InputLabel(inProps, ref) {
11
18
  const {
12
19
  shrink,
@@ -14,20 +21,14 @@ export const InputLabel = React.forwardRef<HTMLLabelElement, InputLabelProps>(fu
14
21
  ...other
15
22
  } = inProps;
16
23
 
17
- const defaultClasses = {
18
- root: "origin-left transition-transform block whitespace-nowrap overflow-hidden text-overflow-ellipsis max-w-full",
19
- shrink: "transform translate-y-[2px] scale-75 translate-x-[12px]",
20
- expanded: "translate-x-[16px] top-0 transform translate-y-[16px] scale-100"
21
- };
22
-
23
- const computedClassName = cn(defaultClasses.root,
24
+ const computedClassName = cls(defaultClasses.root,
24
25
  {
25
26
  [defaultClasses.shrink]: shrink,
26
27
  [defaultClasses.expanded]: !shrink
27
28
  }, className);
28
29
 
29
30
  return (
30
- <label
31
+ <Label
31
32
  data-shrink={shrink}
32
33
  ref={ref}
33
34
  className={computedClassName}
@@ -1,15 +1,28 @@
1
1
  import * as React from "react"
2
2
  import * as LabelPrimitive from "@radix-ui/react-label"
3
- import { cn } from "../util";
3
+ import { cls } from "../util";
4
4
  import { defaultBorderMixin } from "../styles";
5
5
 
6
+ type LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & {
7
+ border?: boolean,
8
+ onClick?: React.MouseEventHandler<HTMLLabelElement>
9
+ };
6
10
  const Label = React.forwardRef<
7
11
  React.ElementRef<typeof LabelPrimitive.Root>,
8
- React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
9
- >(({ className, ...props }, ref) => (
12
+ LabelProps
13
+ >(({
14
+ className,
15
+ border,
16
+ onClick,
17
+ ...props
18
+ }, ref) => (
10
19
  <LabelPrimitive.Root
11
20
  ref={ref}
12
- className={cn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", defaultBorderMixin, className)}
21
+ onClick={onClick}
22
+ className={cls("text-sm font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
23
+ border && "border border-gray-300 dark:border-gray-700 rounded-md px-3 py-1.5",
24
+ onClick && "hover:cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-800",
25
+ defaultBorderMixin, className)}
13
26
  {...props}
14
27
  />
15
28
  ))
@@ -3,26 +3,37 @@ import equal from "react-fast-compare"
3
3
 
4
4
  // @ts-ignore
5
5
  import MarkdownIt from "markdown-it";
6
+ import { cls } from "../util";
6
7
 
7
8
  export interface MarkdownProps {
8
9
  source: string,
10
+ size?: "small" | "medium" | "large" | "xl" | "2xl";
9
11
  className?: string
10
12
  }
11
13
 
12
- const md = new MarkdownIt({ html: true, });
14
+ const proseClasses = {
15
+ small: "prose-sm text-sm",
16
+ medium: "prose text-base",
17
+ large: "prose-lg",
18
+ xl: "prose-xl",
19
+ "2xl": "prose-2xl"
20
+ };
21
+
22
+ const md = new MarkdownIt({ html: true });
13
23
  /**
14
24
  * @group Preview components
15
25
  */
16
26
  export const Markdown = React.memo<MarkdownProps>(function Markdown({
17
27
  source,
18
- className
28
+ className,
29
+ size = "medium"
19
30
  }: MarkdownProps) {
20
31
  const html = useMemo(() => {
21
32
  return md.render(typeof source === "string" ? source : "");
22
33
  }, [source]);
23
34
 
24
35
  return <div
25
- className={className}
36
+ className={cls(proseClasses[size], "dark:prose-invert prose-headings:font-title", className)}
26
37
  dangerouslySetInnerHTML={{ __html: html }}
27
38
  />;
28
39
  }
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
3
3
  import { focusedMixin, paperMixin } from "../styles";
4
- import { cn } from "../util";
4
+ import { cls } from "../util";
5
5
 
6
6
  export type MenuProps = {
7
7
  children: React.ReactNode;
@@ -31,7 +31,7 @@ export function Menu({
31
31
  {trigger}
32
32
  </DropdownMenu.Trigger>
33
33
  <DropdownMenu.Portal container={portalContainer}>
34
- <DropdownMenu.Content className={cn(paperMixin, "shadow py-2 z-30")}>
34
+ <DropdownMenu.Content className={cls(paperMixin, "shadow py-2 z-30")}>
35
35
  {children}
36
36
  </DropdownMenu.Content>
37
37
  </DropdownMenu.Portal>
@@ -43,18 +43,24 @@ export type MenuItemProps = {
43
43
  children: React.ReactNode;
44
44
  dense?: boolean;
45
45
  onClick?: (event: React.MouseEvent) => void;
46
- }
46
+ };
47
47
 
48
48
  export function MenuItem({
49
49
  children,
50
- dense,
50
+ dense = false, // Default value is false if not provided
51
51
  onClick
52
52
  }: MenuItemProps) {
53
+ // Dynamically adjusting the class based on the "dense" prop
54
+ const classNames = cls(
55
+ focusedMixin,
56
+ onClick && "cursor-pointer",
57
+ "rounded-md text-sm font-medium text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-900 flex items-center gap-4",
58
+ dense ? "px-3 py-1.5" : "px-4 py-2"
59
+ );
60
+
53
61
  return (
54
62
  <DropdownMenu.Item
55
- className={cn(focusedMixin,
56
- onClick && "cursor-pointer",
57
- "rounded-md px-4 py-2 text-sm font-medium text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-900 flex items-center gap-4")}
63
+ className={classNames}
58
64
  onClick={onClick}>
59
65
  {children}
60
66
  </DropdownMenu.Item>