@firecms/ui 3.0.0-beta.7 → 3.0.0-beta.9
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/dist/components/BooleanSwitch.d.ts +1 -1
- package/dist/components/Checkbox.d.ts +1 -1
- package/dist/components/Chip.d.ts +3 -2
- package/dist/components/DateTimeField.d.ts +2 -3
- package/dist/components/Dialog.d.ts +4 -1
- package/dist/components/InputLabel.d.ts +2 -2
- package/dist/components/Label.d.ts +2 -2
- package/dist/components/Menu.d.ts +4 -1
- package/dist/components/Menubar.d.ts +19 -9
- package/dist/components/MultiSelect.d.ts +31 -16
- package/dist/components/Popover.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +1 -0
- package/dist/components/Select.d.ts +5 -9
- package/dist/components/Separator.d.ts +2 -1
- package/dist/components/Sheet.d.ts +4 -0
- package/dist/components/Table.d.ts +10 -10
- package/dist/components/TextareaAutosize.d.ts +2 -35
- package/dist/components/Tooltip.d.ts +6 -2
- package/dist/components/_MultiSelect.d.ts +0 -0
- package/dist/icons/Icon.d.ts +1 -1
- package/dist/index.css +77 -0
- package/dist/index.es.js +13044 -13693
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19684 -49
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +4 -4
- package/package.json +109 -121
- package/src/components/Avatar.tsx +0 -2
- package/src/components/BooleanSwitch.tsx +11 -11
- package/src/components/BooleanSwitchWithLabel.tsx +5 -5
- package/src/components/Button.tsx +6 -8
- package/src/components/Card.tsx +2 -2
- package/src/components/Checkbox.tsx +5 -5
- package/src/components/Chip.tsx +7 -4
- package/src/components/DateTimeField.tsx +30 -41
- package/src/components/Dialog.tsx +11 -2
- package/src/components/ExpandablePanel.tsx +3 -3
- package/src/components/FileUpload.tsx +3 -6
- package/src/components/IconButton.tsx +1 -3
- package/src/components/InputLabel.tsx +4 -2
- package/src/components/Menu.tsx +38 -26
- package/src/components/Menubar.tsx +50 -12
- package/src/components/MultiSelect.tsx +333 -164
- package/src/components/Popover.tsx +15 -13
- package/src/components/RadioGroup.tsx +1 -0
- package/src/components/SearchBar.tsx +1 -2
- package/src/components/Select.tsx +98 -119
- package/src/components/Separator.tsx +10 -4
- package/src/components/Sheet.tsx +43 -26
- package/src/components/Skeleton.tsx +1 -1
- package/src/components/Table.tsx +48 -30
- package/src/components/Tabs.tsx +2 -3
- package/src/components/TextField.tsx +2 -6
- package/src/components/Tooltip.tsx +27 -12
- package/src/components/Typography.tsx +14 -16
- package/src/components/_MultiSelect.tsx +222 -0
- package/src/icons/Icon.tsx +2 -2
- package/src/icons/icon_keys.ts +114 -1301
- package/src/index.css +77 -0
- package/src/scripts/generateIconKeys.ts +20 -10
- package/src/styles.ts +4 -4
- package/tailwind.config.js +3 -3
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import React, { useRef } from "react";
|
|
2
|
-
// @ts-ignore
|
|
3
2
|
import DatePicker from "react-datepicker";
|
|
4
3
|
|
|
5
4
|
import { CalendarMonthIcon, ClearIcon, ErrorIcon } from "../icons";
|
|
6
5
|
import { IconButton } from "./IconButton";
|
|
7
|
-
import {
|
|
8
|
-
fieldBackgroundDisabledMixin,
|
|
9
|
-
fieldBackgroundHoverMixin,
|
|
10
|
-
fieldBackgroundMixin,
|
|
11
|
-
focusedMixin,
|
|
12
|
-
paperMixin
|
|
13
|
-
} from "../styles";
|
|
6
|
+
import { fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, fieldBackgroundMixin, paperMixin } from "../styles";
|
|
14
7
|
import { InputLabel } from "./InputLabel";
|
|
15
8
|
import { Typography } from "./Typography";
|
|
16
9
|
import { cls } from "../util";
|
|
17
10
|
import { useInjectStyles } from "../hooks";
|
|
18
11
|
|
|
19
12
|
interface DateTimeFieldProps {
|
|
20
|
-
value?: Date;
|
|
21
|
-
onChange
|
|
13
|
+
value?: Date | null;
|
|
14
|
+
onChange?: (date: Date | null) => void;
|
|
15
|
+
|
|
22
16
|
mode?: "date" | "date_time";
|
|
23
17
|
disabled?: boolean;
|
|
24
18
|
clearable?: boolean;
|
|
@@ -29,7 +23,6 @@ interface DateTimeFieldProps {
|
|
|
29
23
|
style?: React.CSSProperties;
|
|
30
24
|
inputClassName?: string;
|
|
31
25
|
invisible?: boolean;
|
|
32
|
-
preventOpenOnFocus?: boolean;
|
|
33
26
|
locale?: string;
|
|
34
27
|
}
|
|
35
28
|
|
|
@@ -45,7 +38,6 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
45
38
|
className,
|
|
46
39
|
style,
|
|
47
40
|
inputClassName,
|
|
48
|
-
preventOpenOnFocus,
|
|
49
41
|
invisible,
|
|
50
42
|
locale
|
|
51
43
|
}) => {
|
|
@@ -61,7 +53,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
61
53
|
|
|
62
54
|
const handleClear = (e: React.MouseEvent) => {
|
|
63
55
|
e.preventDefault();
|
|
64
|
-
onChange(
|
|
56
|
+
onChange?.(null);
|
|
65
57
|
}
|
|
66
58
|
|
|
67
59
|
return (
|
|
@@ -97,7 +89,6 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
97
89
|
onChange={onChange}
|
|
98
90
|
disabled={false}
|
|
99
91
|
popperClassName={cls(paperMixin, "my-4 shadow")}
|
|
100
|
-
onClick={(e: any) => e.stopPropagation()}
|
|
101
92
|
onFocus={() => setFocused(true)}
|
|
102
93
|
onBlur={() => setFocused(false)}
|
|
103
94
|
showTimeSelect={mode === "date_time"}
|
|
@@ -110,7 +101,6 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
110
101
|
"w-full outline-none bg-transparent leading-normal text-base px-3",
|
|
111
102
|
clearable ? "pr-14" : "pr-12",
|
|
112
103
|
"rounded-md",
|
|
113
|
-
!invisible && focusedMixin,
|
|
114
104
|
size === "small" ? "min-h-[48px]" : "min-h-[64px]",
|
|
115
105
|
label ? "pt-[28px] pb-2" : "py-2",
|
|
116
106
|
inputClassName,
|
|
@@ -118,7 +108,6 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
118
108
|
)}
|
|
119
109
|
/>
|
|
120
110
|
|
|
121
|
-
|
|
122
111
|
<IconButton
|
|
123
112
|
onClick={() => {
|
|
124
113
|
// @ts-ignore
|
|
@@ -528,7 +517,7 @@ const datePickerCss = `
|
|
|
528
517
|
.react-datepicker__year-text--in-selecting-range,
|
|
529
518
|
.react-datepicker__year-text--in-range {
|
|
530
519
|
border-radius: 100%;
|
|
531
|
-
background-color: #
|
|
520
|
+
background-color: #186ef0;
|
|
532
521
|
color: #fff;
|
|
533
522
|
}
|
|
534
523
|
.react-datepicker__day--selected:hover, .react-datepicker__day--in-selecting-range:hover, .react-datepicker__day--in-range:hover,
|
|
@@ -541,22 +530,22 @@ const datePickerCss = `
|
|
|
541
530
|
.react-datepicker__year-text--selected:hover,
|
|
542
531
|
.react-datepicker__year-text--in-selecting-range:hover,
|
|
543
532
|
.react-datepicker__year-text--in-range:hover {
|
|
544
|
-
background-color: #
|
|
545
|
-
}
|
|
546
|
-
.react-datepicker__day--keyboard-selected,
|
|
547
|
-
.react-datepicker__month-text--keyboard-selected,
|
|
548
|
-
.react-datepicker__quarter-text--keyboard-selected,
|
|
549
|
-
.react-datepicker__year-text--keyboard-selected {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
.react-datepicker__day--keyboard-selected:hover,
|
|
555
|
-
.react-datepicker__month-text--keyboard-selected:hover,
|
|
556
|
-
.react-datepicker__quarter-text--keyboard-selected:hover,
|
|
557
|
-
.react-datepicker__year-text--keyboard-selected:hover {
|
|
558
|
-
|
|
559
|
-
}
|
|
533
|
+
background-color: #5698f9;
|
|
534
|
+
}
|
|
535
|
+
// .react-datepicker__day--keyboard-selected,
|
|
536
|
+
// .react-datepicker__month-text--keyboard-selected,
|
|
537
|
+
// .react-datepicker__quarter-text--keyboard-selected,
|
|
538
|
+
// .react-datepicker__year-text--keyboard-selected {
|
|
539
|
+
// border-radius: 100%;
|
|
540
|
+
// background-color: #5193f6;
|
|
541
|
+
// color: rgb(0, 0, 0);
|
|
542
|
+
// }
|
|
543
|
+
// .react-datepicker__day--keyboard-selected:hover,
|
|
544
|
+
// .react-datepicker__month-text--keyboard-selected:hover,
|
|
545
|
+
// .react-datepicker__quarter-text--keyboard-selected:hover,
|
|
546
|
+
// .react-datepicker__year-text--keyboard-selected:hover {
|
|
547
|
+
// background-color: #5193f6;
|
|
548
|
+
// }
|
|
560
549
|
.react-datepicker__day--in-selecting-range:not(.react-datepicker__day--in-range,
|
|
561
550
|
.react-datepicker__month-text--in-range,
|
|
562
551
|
.react-datepicker__quarter-text--in-range,
|
|
@@ -839,7 +828,7 @@ const datePickerCss = `
|
|
|
839
828
|
:is([data-theme="dark"]) .react-datepicker__month-read-view--down-arrow,
|
|
840
829
|
:is([data-theme="dark"]) .react-datepicker__month-year-read-view--down-arrow,
|
|
841
830
|
:is([data-theme="dark"]) .react-datepicker__navigation-icon::before {
|
|
842
|
-
border-color: #
|
|
831
|
+
border-color: #999;
|
|
843
832
|
}
|
|
844
833
|
|
|
845
834
|
|
|
@@ -913,7 +902,7 @@ const datePickerCss = `
|
|
|
913
902
|
:is([data-theme="dark"]) .react-datepicker__year-text--selected:hover,
|
|
914
903
|
:is([data-theme="dark"]) .react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list li.react-datepicker__time-list-item:hover
|
|
915
904
|
{
|
|
916
|
-
background-color: #
|
|
905
|
+
background-color: #262626;
|
|
917
906
|
}
|
|
918
907
|
|
|
919
908
|
:is([data-theme="dark"]) .react-datepicker__day--selected,
|
|
@@ -931,12 +920,12 @@ const datePickerCss = `
|
|
|
931
920
|
background-color: #0e528f;
|
|
932
921
|
}
|
|
933
922
|
|
|
934
|
-
:is([data-theme="dark"]) .react-datepicker__day--keyboard-selected,
|
|
935
|
-
:is([data-theme="dark"]) .react-datepicker__month-text--keyboard-selected,
|
|
936
|
-
:is([data-theme="dark"]) .react-datepicker__quarter-text--keyboard-selected,
|
|
937
|
-
:is([data-theme="dark"]) .react-datepicker__year-text--keyboard-selected {
|
|
938
|
-
|
|
939
|
-
}
|
|
923
|
+
// :is([data-theme="dark"]) .react-datepicker__day--keyboard-selected,
|
|
924
|
+
// :is([data-theme="dark"]) .react-datepicker__month-text--keyboard-selected,
|
|
925
|
+
// :is([data-theme="dark"]) .react-datepicker__quarter-text--keyboard-selected,
|
|
926
|
+
// :is([data-theme="dark"]) .react-datepicker__year-text--keyboard-selected {
|
|
927
|
+
// background-color: #0e529f;
|
|
928
|
+
// }
|
|
940
929
|
|
|
941
930
|
:is([data-theme="dark"]) .react-datepicker__today-button {
|
|
942
931
|
background-color: #262626;
|
|
@@ -15,6 +15,9 @@ export type DialogProps = {
|
|
|
15
15
|
maxWidth?: keyof typeof widthClasses;
|
|
16
16
|
modal?: boolean;
|
|
17
17
|
onOpenAutoFocus?: (e: Event) => void;
|
|
18
|
+
onEscapeKeyDown?: (e: KeyboardEvent) => void;
|
|
19
|
+
onPointerDownOutside?: (e: Event) => void;
|
|
20
|
+
onInteractOutside?: (e: Event) => void;
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
const widthClasses = {
|
|
@@ -43,7 +46,10 @@ export const Dialog = ({
|
|
|
43
46
|
scrollable = true,
|
|
44
47
|
maxWidth = "lg",
|
|
45
48
|
modal = true,
|
|
46
|
-
onOpenAutoFocus
|
|
49
|
+
onOpenAutoFocus,
|
|
50
|
+
onEscapeKeyDown,
|
|
51
|
+
onPointerDownOutside,
|
|
52
|
+
onInteractOutside
|
|
47
53
|
}: DialogProps) => {
|
|
48
54
|
const [displayed, setDisplayed] = useState(false);
|
|
49
55
|
|
|
@@ -51,7 +57,7 @@ export const Dialog = ({
|
|
|
51
57
|
if (!open) {
|
|
52
58
|
const timeout = setTimeout(() => {
|
|
53
59
|
setDisplayed(false);
|
|
54
|
-
},
|
|
60
|
+
}, 150);
|
|
55
61
|
return () => clearTimeout(timeout);
|
|
56
62
|
} else {
|
|
57
63
|
setDisplayed(true);
|
|
@@ -79,7 +85,10 @@ export const Dialog = ({
|
|
|
79
85
|
/>
|
|
80
86
|
|
|
81
87
|
<DialogPrimitive.Content
|
|
88
|
+
onEscapeKeyDown={onEscapeKeyDown}
|
|
82
89
|
onOpenAutoFocus={onOpenAutoFocus}
|
|
90
|
+
onPointerDownOutside={onPointerDownOutside}
|
|
91
|
+
onInteractOutside={onInteractOutside}
|
|
83
92
|
className={cls("h-full outline-none flex justify-center items-center z-40 opacity-100 transition-all duration-200 ease-in-out")}
|
|
84
93
|
>
|
|
85
94
|
<div
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useEffect, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
4
|
-
import { defaultBorderMixin, fieldBackgroundMixin
|
|
4
|
+
import { defaultBorderMixin, fieldBackgroundMixin } from "../styles";
|
|
5
5
|
import { ExpandMoreIcon } from "../icons";
|
|
6
6
|
import { cls } from "../util";
|
|
7
7
|
import { useInjectStyles } from "../hooks";
|
|
@@ -88,9 +88,9 @@ export function ExpandablePanel({
|
|
|
88
88
|
}}>
|
|
89
89
|
|
|
90
90
|
<Collapsible.Trigger
|
|
91
|
-
className={cls(
|
|
91
|
+
className={cls(
|
|
92
92
|
"rounded flex items-center justify-between w-full min-h-[52px]",
|
|
93
|
-
"hover:bg-slate-50 dark:hover:bg-gray-800 dark:hover:bg-opacity-
|
|
93
|
+
"hover:bg-slate-50 dark:hover:bg-gray-800 dark:hover:bg-opacity-20",
|
|
94
94
|
invisible ? "border-b px-2" : "p-4",
|
|
95
95
|
invisible && defaultBorderMixin,
|
|
96
96
|
asField && fieldBackgroundMixin,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { useDropzone } from "react-dropzone";
|
|
3
|
-
import { fieldBackgroundHoverMixin, fieldBackgroundMixin
|
|
3
|
+
import { fieldBackgroundHoverMixin, fieldBackgroundMixin } from "../styles";
|
|
4
4
|
import { cls } from "../util";
|
|
5
5
|
import { Typography } from "./Typography";
|
|
6
6
|
|
|
@@ -65,19 +65,16 @@ export function FileUpload({
|
|
|
65
65
|
{...getRootProps()}
|
|
66
66
|
className={cls(
|
|
67
67
|
fieldBackgroundMixin,
|
|
68
|
-
fieldBackgroundHoverMixin,
|
|
69
|
-
focusedMixin,
|
|
70
68
|
"flex gap-2",
|
|
71
69
|
"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",
|
|
72
70
|
{
|
|
73
71
|
"h-44": size === "medium",
|
|
74
72
|
"h-28": size === "small",
|
|
75
73
|
"cursor-pointer": !disabled,
|
|
76
|
-
|
|
74
|
+
[fieldBackgroundHoverMixin]: !isDragActive,
|
|
77
75
|
"transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-red-500": isDragReject,
|
|
78
76
|
"transition-colors duration-200 ease-[cubic-bezier(0,0,0.2,1)] border-green-500": isDragAccept,
|
|
79
|
-
})}
|
|
80
|
-
>
|
|
77
|
+
})}>
|
|
81
78
|
|
|
82
79
|
<Typography variant={"caption"} color={"secondary"} className={"absolute top-2 left-3.5 cursor-inherit"}>
|
|
83
80
|
{title}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { focusedMixin } from "../styles";
|
|
3
2
|
import { cls } from "../util";
|
|
4
3
|
|
|
5
4
|
export type IconButtonProps<C extends React.ElementType> =
|
|
@@ -15,7 +14,7 @@ export type IconButtonProps<C extends React.ElementType> =
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
const buttonClasses =
|
|
18
|
-
"hover:bg-slate-200 hover:bg-opacity-75 dark:hover:bg-
|
|
17
|
+
"hover:bg-slate-200 hover:bg-opacity-75 dark:hover:bg-slate-800";
|
|
19
18
|
const baseClasses =
|
|
20
19
|
"inline-flex items-center justify-center p-2 text-sm font-medium focus:outline-none transition-colors ease-in-out duration-150";
|
|
21
20
|
const colorClasses = "text-slate-600 visited:text-slate-600 dark:text-slate-300 dark:visited:text-gray-300";
|
|
@@ -50,7 +49,6 @@ const IconButtonInner = <C extends React.ElementType = "button">({
|
|
|
50
49
|
ref={ref}
|
|
51
50
|
{...props}
|
|
52
51
|
className={cls(
|
|
53
|
-
focusedMixin,
|
|
54
52
|
disabled ? "opacity-50 pointer-events-none" : "cursor-pointer",
|
|
55
53
|
toggled ? "outline outline-2 outline-primary" : "",
|
|
56
54
|
colorClasses,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { cls } from "../util";
|
|
3
3
|
import { Label } from "./Label";
|
|
4
|
+
import { defaultBorderMixin } from "../styles";
|
|
4
5
|
|
|
5
6
|
export type InputLabelProps = {
|
|
6
7
|
children?: React.ReactNode;
|
|
@@ -28,10 +29,11 @@ export const InputLabel = React.forwardRef<HTMLLabelElement, InputLabelProps>(fu
|
|
|
28
29
|
}, className);
|
|
29
30
|
|
|
30
31
|
return (
|
|
31
|
-
<
|
|
32
|
+
<label
|
|
33
|
+
className={cls("text-sm font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
34
|
+
defaultBorderMixin, computedClassName)}
|
|
32
35
|
data-shrink={shrink}
|
|
33
36
|
ref={ref}
|
|
34
|
-
className={computedClassName}
|
|
35
37
|
{...other}
|
|
36
38
|
/>
|
|
37
39
|
);
|
package/src/components/Menu.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
3
|
-
import {
|
|
3
|
+
import { focusedDisabled, paperMixin } from "../styles";
|
|
4
4
|
import { cls } from "../util";
|
|
5
5
|
|
|
6
6
|
export type MenuProps = {
|
|
@@ -12,32 +12,45 @@ export type MenuProps = {
|
|
|
12
12
|
onOpenChange?(open: boolean): void;
|
|
13
13
|
|
|
14
14
|
portalContainer?: HTMLElement | null;
|
|
15
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
16
|
+
align?: "start" | "center" | "end";
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</DropdownMenu.
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
const Menu = React.forwardRef<
|
|
20
|
+
React.ElementRef<typeof DropdownMenu.Trigger>,
|
|
21
|
+
MenuProps
|
|
22
|
+
>(({
|
|
23
|
+
children,
|
|
24
|
+
trigger,
|
|
25
|
+
open,
|
|
26
|
+
defaultOpen,
|
|
27
|
+
side,
|
|
28
|
+
align,
|
|
29
|
+
onOpenChange,
|
|
30
|
+
portalContainer
|
|
31
|
+
}, ref) => (
|
|
32
|
+
<DropdownMenu.Root
|
|
33
|
+
open={open}
|
|
34
|
+
defaultOpen={defaultOpen}
|
|
35
|
+
onOpenChange={onOpenChange}>
|
|
36
|
+
<DropdownMenu.Trigger
|
|
37
|
+
ref={ref}
|
|
38
|
+
asChild>
|
|
39
|
+
{trigger}
|
|
40
|
+
</DropdownMenu.Trigger>
|
|
41
|
+
<DropdownMenu.Portal container={portalContainer}>
|
|
42
|
+
<DropdownMenu.Content
|
|
43
|
+
side={side}
|
|
44
|
+
align={align}
|
|
45
|
+
className={cls(paperMixin, focusedDisabled, "shadow py-2 z-30")}>
|
|
46
|
+
{children}
|
|
47
|
+
</DropdownMenu.Content>
|
|
48
|
+
</DropdownMenu.Portal>
|
|
49
|
+
</DropdownMenu.Root>
|
|
50
|
+
))
|
|
51
|
+
Menu.displayName = "Menu"
|
|
52
|
+
|
|
53
|
+
export { Menu }
|
|
41
54
|
|
|
42
55
|
export type MenuItemProps = {
|
|
43
56
|
children: React.ReactNode;
|
|
@@ -52,7 +65,6 @@ export function MenuItem({
|
|
|
52
65
|
}: MenuItemProps) {
|
|
53
66
|
// Dynamically adjusting the class based on the "dense" prop
|
|
54
67
|
const classNames = cls(
|
|
55
|
-
focusedMixin,
|
|
56
68
|
onClick && "cursor-pointer",
|
|
57
69
|
"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
70
|
dense ? "px-3 py-1.5" : "px-4 py-2"
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
|
2
4
|
import { cls } from "../util";
|
|
3
5
|
import { CheckIcon, ChevronRightIcon } from "../icons";
|
|
4
6
|
|
|
5
7
|
export function Menubar({
|
|
6
8
|
children,
|
|
9
|
+
onSelect,
|
|
7
10
|
className
|
|
8
|
-
}: {
|
|
11
|
+
}: {
|
|
12
|
+
children: React.ReactNode,
|
|
13
|
+
onSelect?: (event: React.SyntheticEvent) => void,
|
|
14
|
+
className?: string
|
|
15
|
+
}) {
|
|
9
16
|
return (
|
|
10
|
-
<MenubarPrimitive.Root
|
|
17
|
+
<MenubarPrimitive.Root
|
|
18
|
+
onSelect={onSelect}
|
|
19
|
+
className={cls("z-10 flex bg-white dark:bg-gray-950 p-[3px] rounded-sm shadow-sm", className)}>
|
|
11
20
|
{children}
|
|
12
21
|
</MenubarPrimitive.Root>
|
|
13
22
|
)
|
|
@@ -25,11 +34,17 @@ export function MenubarMenu({
|
|
|
25
34
|
|
|
26
35
|
export function MenubarTrigger({
|
|
27
36
|
children,
|
|
37
|
+
onSelect,
|
|
28
38
|
className
|
|
29
|
-
}: {
|
|
39
|
+
}: {
|
|
40
|
+
children: React.ReactNode,
|
|
41
|
+
onSelect?: (event: React.SyntheticEvent) => void,
|
|
42
|
+
className?: string
|
|
43
|
+
}) {
|
|
30
44
|
return (
|
|
31
45
|
<MenubarPrimitive.Trigger
|
|
32
|
-
|
|
46
|
+
onSelect={onSelect}
|
|
47
|
+
className={cls("py-2 px-3 outline-none select-none font-medium leading-none rounded text-text-primary dark:text-text-primary-dark text-[13px] flex items-center justify-between gap-[2px] data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[state=open]:bg-slate-100 data-[state=open]:dark:bg-gray-800 hover:bg-slate-200 hover:bg-opacity-75 dark:hover:bg-gray-700 dark:hover:bg-opacity-50",
|
|
33
48
|
className)}>
|
|
34
49
|
{children}
|
|
35
50
|
</MenubarPrimitive.Trigger>
|
|
@@ -52,16 +67,19 @@ export function MenubarContent({
|
|
|
52
67
|
align,
|
|
53
68
|
sideOffset,
|
|
54
69
|
alignOffset,
|
|
70
|
+
onSelect,
|
|
55
71
|
...rest
|
|
56
72
|
}: {
|
|
57
73
|
children: React.ReactNode,
|
|
58
74
|
className?: string,
|
|
75
|
+
onSelect?: (event: React.SyntheticEvent) => void,
|
|
59
76
|
align?: "start" | "center" | "end",
|
|
60
77
|
sideOffset?: number,
|
|
61
78
|
alignOffset?: number
|
|
62
79
|
}) {
|
|
63
80
|
return (
|
|
64
81
|
<MenubarPrimitive.Content
|
|
82
|
+
onSelect={onSelect}
|
|
65
83
|
className={cls("min-w-[220px] bg-white dark:bg-gray-950 rounded-md p-[6px] shadow-[0px_10px_38px_-10px_rgba(22,_23,_24,_0.35),_0px_10px_20px_-15px_rgba(22,_23,_24,_0.2)] [animation-duration:_400ms] [animation-timing-function:_cubic-bezier(0.16,_1,_0.3,_1)] will-change-[transform,opacity]", className)}
|
|
66
84
|
align={align ?? "start"}
|
|
67
85
|
sideOffset={sideOffset ?? 5}
|
|
@@ -78,17 +96,21 @@ export function MenubarItem({
|
|
|
78
96
|
leftPadding,
|
|
79
97
|
className,
|
|
80
98
|
disabled,
|
|
99
|
+
onSelect,
|
|
81
100
|
...rest
|
|
82
101
|
}: {
|
|
83
102
|
children: React.ReactNode,
|
|
103
|
+
onSelect?: (event: Event) => void;
|
|
84
104
|
leftPadding?: boolean,
|
|
85
105
|
className?: string,
|
|
86
106
|
disabled?: boolean
|
|
87
107
|
}) {
|
|
88
108
|
return (
|
|
89
109
|
<MenubarPrimitive.Item
|
|
90
|
-
|
|
110
|
+
onSelect={onSelect}
|
|
111
|
+
className={cls("group text-[13px] leading-none rounded flex items-center h-[32px] px-[10px] py-[2px] relative select-none outline-none data-[state=open]:bg-slate-100 data-[state=open]:dark:bg-gray-800 data-[state=open]:text-text-primary data-[state=open]:dark:text-text-primary-dark data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[disabled]:text-text-disabled data-[disabled]:dark:text-text-disabled-dark data-[disabled]:pointer-events-none",
|
|
91
112
|
leftPadding ? "pl-5" : "",
|
|
113
|
+
disabled ? "pointer-events-none text-text-secondary dark:text-text-secondary-dark" : "text-text-primary dark:text-text-primary-dark",
|
|
92
114
|
className)}
|
|
93
115
|
disabled={disabled}
|
|
94
116
|
{...rest}
|
|
@@ -108,7 +130,7 @@ export function MenubarSeparator({
|
|
|
108
130
|
}) {
|
|
109
131
|
return (
|
|
110
132
|
<MenubarPrimitive.Separator
|
|
111
|
-
className={cls("h-[1px] bg-
|
|
133
|
+
className={cls("h-[1px] bg-slate-100 dark:bg-gray-800 m-[5px]", className)}
|
|
112
134
|
{...rest}
|
|
113
135
|
>
|
|
114
136
|
{children}
|
|
@@ -134,14 +156,17 @@ export function MenubarSub({
|
|
|
134
156
|
export function MenubarSubTrigger({
|
|
135
157
|
children,
|
|
136
158
|
className,
|
|
159
|
+
onSelect,
|
|
137
160
|
...rest
|
|
138
161
|
}: {
|
|
139
162
|
children?: React.ReactNode,
|
|
163
|
+
onSelect?: (event: React.SyntheticEvent) => void,
|
|
140
164
|
className?: string,
|
|
141
165
|
}) {
|
|
142
166
|
return (
|
|
143
167
|
<MenubarPrimitive.SubTrigger
|
|
144
|
-
|
|
168
|
+
onSelect={onSelect}
|
|
169
|
+
className={cls("group text-[13px] leading-none text-text-primary dark:text-text-primary-dark rounded flex items-center h-[32px] px-[10px] py-[2px] relative select-none outline-none data-[state=open]:bg-slate-100 data-[state=open]:dark:bg-gray-800 data-[state=open]:text-text-primary data-[state=open]:dark:text-text-primary-dark data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[disabled]:text-text-disabled data-[disabled]:dark:text-text-disabled-dark data-[disabled]:pointer-events-none",
|
|
145
170
|
className)}
|
|
146
171
|
{...rest}
|
|
147
172
|
>
|
|
@@ -154,14 +179,17 @@ export function MenubarSubContent({
|
|
|
154
179
|
children,
|
|
155
180
|
alignOffset,
|
|
156
181
|
className,
|
|
182
|
+
onSelect,
|
|
157
183
|
...rest
|
|
158
184
|
}: {
|
|
159
185
|
children?: React.ReactNode,
|
|
186
|
+
onSelect?: (event: React.SyntheticEvent) => void,
|
|
160
187
|
alignOffset?: number,
|
|
161
188
|
className?: string,
|
|
162
189
|
}) {
|
|
163
190
|
return (
|
|
164
191
|
<MenubarPrimitive.SubContent
|
|
192
|
+
onSelect={onSelect}
|
|
165
193
|
alignOffset={alignOffset ?? -5}
|
|
166
194
|
className={cls("min-w-[220px] bg-white dark:bg-gray-950 rounded-md p-[6px] shadow-[0px_10px_38px_-10px_rgba(22,_23,_24,_0.35),_0px_10px_20px_-15px_rgba(22,_23,_24,_0.2)] [animation-duration:_400ms] [animation-timing-function:_cubic-bezier(0.16,_1,_0.3,_1)] will-change-[transform,opacity]",
|
|
167
195
|
className)}
|
|
@@ -177,16 +205,19 @@ export function MenubarCheckboxItem({
|
|
|
177
205
|
checked,
|
|
178
206
|
onCheckedChange,
|
|
179
207
|
className,
|
|
208
|
+
onSelect,
|
|
180
209
|
...rest
|
|
181
210
|
}: {
|
|
182
211
|
children?: React.ReactNode,
|
|
212
|
+
onSelect?: (event: Event) => void;
|
|
183
213
|
checked?: boolean,
|
|
184
214
|
onCheckedChange?: () => void,
|
|
185
215
|
className?: string,
|
|
186
216
|
}) {
|
|
187
217
|
return (
|
|
188
218
|
<MenubarPrimitive.CheckboxItem
|
|
189
|
-
|
|
219
|
+
onSelect={onSelect}
|
|
220
|
+
className={cls("text-[13px] leading-none text-text-primary dark:text-text-primary-dark rounded flex items-center h-[32px] px-[10px] py-[2px] relative select-none pl-5 outline-none data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[disabled]:text-text-disabled data-[disabled]:dark:text-text-disabled-dark data-[disabled]:pointer-events-none",
|
|
190
221
|
className)}
|
|
191
222
|
checked={checked}
|
|
192
223
|
onCheckedChange={onCheckedChange}
|
|
@@ -219,9 +250,11 @@ export function MenubarRadioGroup({
|
|
|
219
250
|
className,
|
|
220
251
|
value,
|
|
221
252
|
onValueChange,
|
|
253
|
+
onSelect,
|
|
222
254
|
...rest
|
|
223
255
|
}: {
|
|
224
256
|
children?: React.ReactNode,
|
|
257
|
+
onSelect?: (event: React.SyntheticEvent) => void,
|
|
225
258
|
value?: string,
|
|
226
259
|
onValueChange?: (value: string) => void,
|
|
227
260
|
className?: string,
|
|
@@ -231,6 +264,7 @@ export function MenubarRadioGroup({
|
|
|
231
264
|
className={cls(className)}
|
|
232
265
|
value={value}
|
|
233
266
|
onValueChange={onValueChange}
|
|
267
|
+
onSelect={onSelect}
|
|
234
268
|
{...rest}>
|
|
235
269
|
{children ?? <CheckIcon size={"small"}/>}
|
|
236
270
|
</MenubarPrimitive.RadioGroup>
|
|
@@ -241,15 +275,18 @@ export function MenubarRadioItem({
|
|
|
241
275
|
children,
|
|
242
276
|
className,
|
|
243
277
|
value,
|
|
278
|
+
onSelect,
|
|
244
279
|
...rest
|
|
245
280
|
}: {
|
|
246
281
|
children?: React.ReactNode,
|
|
282
|
+
onSelect?: (event: Event) => void;
|
|
247
283
|
value: string,
|
|
248
284
|
className?: string,
|
|
249
285
|
}) {
|
|
250
286
|
return (
|
|
251
287
|
<MenubarPrimitive.RadioItem
|
|
252
|
-
|
|
288
|
+
onSelect={onSelect}
|
|
289
|
+
className={cls("text-[13px] leading-none text-text-primary dark:text-text-primary-dark rounded flex items-center h-[32px] px-[10px] py-[2px] relative select-none pl-5 outline-none data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[disabled]:text-text-disabled data-[disabled]:dark:text-text-disabled-dark data-[disabled]:pointer-events-none",
|
|
253
290
|
className)}
|
|
254
291
|
value={value}
|
|
255
292
|
{...rest}>
|
|
@@ -268,8 +305,9 @@ export function MenubarShortcut({
|
|
|
268
305
|
}) {
|
|
269
306
|
return (
|
|
270
307
|
<div
|
|
271
|
-
className={cls("ml-auto pl-5 group-data-[
|
|
272
|
-
className)}
|
|
308
|
+
className={cls("ml-auto pl-5 group-data-[disabled]:text-text-disabled data-[disabled]:dark:text-text-disabled-dark",
|
|
309
|
+
className)}
|
|
310
|
+
{...rest}>
|
|
273
311
|
{children}
|
|
274
312
|
</div>
|
|
275
313
|
)
|