@firecms/ui 3.0.0-canary.9 → 3.0.0-canary.91
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/README.md +1 -1
- package/dist/components/Avatar.d.ts +1 -0
- package/dist/components/BooleanSwitch.d.ts +1 -1
- package/dist/components/CenteredView.d.ts +4 -2
- package/dist/components/Checkbox.d.ts +4 -3
- package/dist/components/DateTimeField.d.ts +2 -3
- package/dist/components/InputLabel.d.ts +2 -2
- package/dist/components/Label.d.ts +4 -1
- package/dist/components/Markdown.d.ts +1 -0
- package/dist/components/Menu.d.ts +2 -1
- package/dist/components/Menubar.d.ts +79 -0
- package/dist/components/RadioGroup.d.ts +26 -3
- package/dist/components/Select.d.ts +1 -1
- package/dist/components/TextField.d.ts +1 -1
- package/dist/components/TextareaAutosize.d.ts +3 -34
- package/dist/components/Tooltip.d.ts +3 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useLocaleConfig.d.ts +1 -0
- package/dist/icons/Icon.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +12802 -12153
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +20691 -49
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +6 -6
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +35 -47
- package/src/components/Alert.tsx +2 -2
- package/src/components/Autocomplete.tsx +4 -3
- package/src/components/Avatar.tsx +7 -4
- package/src/components/Badge.tsx +1 -1
- package/src/components/BooleanSwitch.tsx +9 -9
- package/src/components/BooleanSwitchWithLabel.tsx +5 -5
- package/src/components/Button.tsx +7 -7
- package/src/components/Card.tsx +2 -2
- package/src/components/CenteredView.tsx +25 -15
- package/src/components/Checkbox.tsx +31 -24
- package/src/components/Chip.tsx +2 -2
- package/src/components/CircularProgress.tsx +2 -2
- package/src/components/Collapse.tsx +3 -2
- package/src/components/Container.tsx +2 -2
- package/src/components/DateTimeField.tsx +36 -39
- package/src/components/Dialog.tsx +4 -4
- package/src/components/DialogActions.tsx +2 -2
- package/src/components/DialogContent.tsx +2 -2
- package/src/components/ExpandablePanel.tsx +8 -6
- package/src/components/FileUpload.tsx +5 -7
- package/src/components/IconButton.tsx +3 -3
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +10 -9
- package/src/components/Label.tsx +17 -4
- package/src/components/Markdown.tsx +14 -3
- package/src/components/Menu.tsx +13 -7
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +7 -6
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +3 -2
- package/src/components/RadioGroup.tsx +41 -9
- package/src/components/SearchBar.tsx +6 -6
- package/src/components/Select.tsx +25 -24
- package/src/components/Sheet.tsx +7 -7
- package/src/components/Skeleton.tsx +9 -6
- package/src/components/Table.tsx +6 -6
- package/src/components/Tabs.tsx +5 -5
- package/src/components/TextField.tsx +8 -7
- package/src/components/TextareaAutosize.tsx +3 -3
- package/src/components/Tooltip.tsx +10 -4
- package/src/components/Typography.tsx +20 -3
- package/src/components/common/SelectInputLabel.tsx +2 -2
- package/src/components/index.tsx +1 -1
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useLocaleConfig.tsx +18 -0
- package/src/icons/Icon.tsx +45 -42
- package/src/index.ts +1 -0
- package/src/scripts/generateIconKeys.ts +0 -1
- package/src/styles.ts +6 -6
- package/src/util/cls.ts +14 -0
- package/src/util/index.ts +1 -3
- package/tailwind.config.js +5 -3
- package/dist/components/Spinner.d.ts +0 -1
- package/src/components/Spinner.tsx +0 -18
- package/src/util/cn.ts +0 -6
- /package/dist/{util → hooks}/useDebounceValue.d.ts +0 -0
- /package/dist/{util → hooks}/useInjectStyles.d.ts +0 -0
- /package/dist/{util → hooks}/useOutsideAlerter.d.ts +0 -0
- /package/src/{util → hooks}/useDebounceValue.tsx +0 -0
- /package/src/{util → hooks}/useInjectStyles.tsx +0 -0
- /package/src/{util → hooks}/useOutsideAlerter.tsx +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
import React, { ForwardRefRenderFunction } from "react";
|
2
|
-
import {
|
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={
|
40
|
+
className={cls("mx-auto px-3 md:px-4 lg-px-6",
|
41
41
|
classForMaxWidth,
|
42
42
|
className)}
|
43
43
|
style={style}>
|
@@ -1,5 +1,4 @@
|
|
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";
|
@@ -12,23 +11,24 @@ import {
|
|
12
11
|
paperMixin
|
13
12
|
} from "../styles";
|
14
13
|
import { InputLabel } from "./InputLabel";
|
15
|
-
import { cn, useInjectStyles } from "../util";
|
16
14
|
import { Typography } from "./Typography";
|
15
|
+
import { cls } from "../util";
|
16
|
+
import { useInjectStyles } from "../hooks";
|
17
17
|
|
18
18
|
interface DateTimeFieldProps {
|
19
19
|
value?: Date;
|
20
|
-
onChange
|
20
|
+
onChange?: (date: Date | null) => void;
|
21
|
+
|
21
22
|
mode?: "date" | "date_time";
|
22
23
|
disabled?: boolean;
|
23
24
|
clearable?: boolean;
|
24
25
|
error?: boolean;
|
25
|
-
size
|
26
|
+
size?: "small" | "medium";
|
26
27
|
label?: React.ReactNode;
|
27
28
|
className?: string;
|
28
29
|
style?: React.CSSProperties;
|
29
30
|
inputClassName?: string;
|
30
31
|
invisible?: boolean;
|
31
|
-
preventOpenOnFocus?: boolean;
|
32
32
|
locale?: string;
|
33
33
|
}
|
34
34
|
|
@@ -40,11 +40,10 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
40
40
|
clearable,
|
41
41
|
mode = "date",
|
42
42
|
error,
|
43
|
-
size,
|
43
|
+
size = "medium",
|
44
44
|
className,
|
45
45
|
style,
|
46
46
|
inputClassName,
|
47
|
-
preventOpenOnFocus,
|
48
47
|
invisible,
|
49
48
|
locale
|
50
49
|
}) => {
|
@@ -60,14 +59,14 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
60
59
|
|
61
60
|
const handleClear = (e: React.MouseEvent) => {
|
62
61
|
e.preventDefault();
|
63
|
-
onChange(null);
|
62
|
+
onChange?.(null);
|
64
63
|
}
|
65
64
|
|
66
65
|
return (
|
67
66
|
<>
|
68
67
|
|
69
68
|
<div
|
70
|
-
className={
|
69
|
+
className={cls(
|
71
70
|
"rounded-md relative max-w-full",
|
72
71
|
!invisible && fieldBackgroundMixin,
|
73
72
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
@@ -80,7 +79,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
80
79
|
|
81
80
|
{label && (
|
82
81
|
<InputLabel
|
83
|
-
className={
|
82
|
+
className={cls("absolute top-1 pointer-events-none",
|
84
83
|
!error ? (focused ? "text-primary" : "text-text-secondary dark:text-text-secondary-dark") : "text-red-500 dark:text-red-500",
|
85
84
|
disabled ? "opacity-50" : "")}
|
86
85
|
shrink={hasValue || focused}
|
@@ -95,8 +94,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
95
94
|
selected={(invalidValue ? null : value) ?? null}
|
96
95
|
onChange={onChange}
|
97
96
|
disabled={false}
|
98
|
-
popperClassName={
|
99
|
-
onClick={(e: any) => e.stopPropagation()}
|
97
|
+
popperClassName={cls(paperMixin, "my-4 shadow")}
|
100
98
|
onFocus={() => setFocused(true)}
|
101
99
|
onBlur={() => setFocused(false)}
|
102
100
|
showTimeSelect={mode === "date_time"}
|
@@ -105,7 +103,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
105
103
|
timeCaption="time"
|
106
104
|
dateFormat={mode === "date_time" ? "Pp" : "P"}
|
107
105
|
preventOpenOnFocus={true}
|
108
|
-
className={
|
106
|
+
className={cls(
|
109
107
|
"w-full outline-none bg-transparent leading-normal text-base px-3",
|
110
108
|
clearable ? "pr-14" : "pr-12",
|
111
109
|
"rounded-md",
|
@@ -117,7 +115,6 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
117
115
|
)}
|
118
116
|
/>
|
119
117
|
|
120
|
-
|
121
118
|
<IconButton
|
122
119
|
onClick={() => {
|
123
120
|
// @ts-ignore
|
@@ -527,7 +524,7 @@ const datePickerCss = `
|
|
527
524
|
.react-datepicker__year-text--in-selecting-range,
|
528
525
|
.react-datepicker__year-text--in-range {
|
529
526
|
border-radius: 100%;
|
530
|
-
background-color: #
|
527
|
+
background-color: #186ef0;
|
531
528
|
color: #fff;
|
532
529
|
}
|
533
530
|
.react-datepicker__day--selected:hover, .react-datepicker__day--in-selecting-range:hover, .react-datepicker__day--in-range:hover,
|
@@ -540,22 +537,22 @@ const datePickerCss = `
|
|
540
537
|
.react-datepicker__year-text--selected:hover,
|
541
538
|
.react-datepicker__year-text--in-selecting-range:hover,
|
542
539
|
.react-datepicker__year-text--in-range:hover {
|
543
|
-
background-color: #
|
544
|
-
}
|
545
|
-
.react-datepicker__day--keyboard-selected,
|
546
|
-
.react-datepicker__month-text--keyboard-selected,
|
547
|
-
.react-datepicker__quarter-text--keyboard-selected,
|
548
|
-
.react-datepicker__year-text--keyboard-selected {
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
}
|
553
|
-
.react-datepicker__day--keyboard-selected:hover,
|
554
|
-
.react-datepicker__month-text--keyboard-selected:hover,
|
555
|
-
.react-datepicker__quarter-text--keyboard-selected:hover,
|
556
|
-
.react-datepicker__year-text--keyboard-selected:hover {
|
557
|
-
|
558
|
-
}
|
540
|
+
background-color: #5698f9;
|
541
|
+
}
|
542
|
+
// .react-datepicker__day--keyboard-selected,
|
543
|
+
// .react-datepicker__month-text--keyboard-selected,
|
544
|
+
// .react-datepicker__quarter-text--keyboard-selected,
|
545
|
+
// .react-datepicker__year-text--keyboard-selected {
|
546
|
+
// border-radius: 100%;
|
547
|
+
// background-color: #5193f6;
|
548
|
+
// color: rgb(0, 0, 0);
|
549
|
+
// }
|
550
|
+
// .react-datepicker__day--keyboard-selected:hover,
|
551
|
+
// .react-datepicker__month-text--keyboard-selected:hover,
|
552
|
+
// .react-datepicker__quarter-text--keyboard-selected:hover,
|
553
|
+
// .react-datepicker__year-text--keyboard-selected:hover {
|
554
|
+
// background-color: #5193f6;
|
555
|
+
// }
|
559
556
|
.react-datepicker__day--in-selecting-range:not(.react-datepicker__day--in-range,
|
560
557
|
.react-datepicker__month-text--in-range,
|
561
558
|
.react-datepicker__quarter-text--in-range,
|
@@ -838,7 +835,7 @@ const datePickerCss = `
|
|
838
835
|
:is([data-theme="dark"]) .react-datepicker__month-read-view--down-arrow,
|
839
836
|
:is([data-theme="dark"]) .react-datepicker__month-year-read-view--down-arrow,
|
840
837
|
:is([data-theme="dark"]) .react-datepicker__navigation-icon::before {
|
841
|
-
border-color: #
|
838
|
+
border-color: #999;
|
842
839
|
}
|
843
840
|
|
844
841
|
|
@@ -912,7 +909,7 @@ const datePickerCss = `
|
|
912
909
|
:is([data-theme="dark"]) .react-datepicker__year-text--selected:hover,
|
913
910
|
: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
|
914
911
|
{
|
915
|
-
background-color: #
|
912
|
+
background-color: #262626;
|
916
913
|
}
|
917
914
|
|
918
915
|
:is([data-theme="dark"]) .react-datepicker__day--selected,
|
@@ -930,12 +927,12 @@ const datePickerCss = `
|
|
930
927
|
background-color: #0e528f;
|
931
928
|
}
|
932
929
|
|
933
|
-
:is([data-theme="dark"]) .react-datepicker__day--keyboard-selected,
|
934
|
-
:is([data-theme="dark"]) .react-datepicker__month-text--keyboard-selected,
|
935
|
-
:is([data-theme="dark"]) .react-datepicker__quarter-text--keyboard-selected,
|
936
|
-
:is([data-theme="dark"]) .react-datepicker__year-text--keyboard-selected {
|
937
|
-
|
938
|
-
}
|
930
|
+
// :is([data-theme="dark"]) .react-datepicker__day--keyboard-selected,
|
931
|
+
// :is([data-theme="dark"]) .react-datepicker__month-text--keyboard-selected,
|
932
|
+
// :is([data-theme="dark"]) .react-datepicker__quarter-text--keyboard-selected,
|
933
|
+
// :is([data-theme="dark"]) .react-datepicker__year-text--keyboard-selected {
|
934
|
+
// background-color: #0e529f;
|
935
|
+
// }
|
939
936
|
|
940
937
|
:is([data-theme="dark"]) .react-datepicker__today-button {
|
941
938
|
background-color: #262626;
|
@@ -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 {
|
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={
|
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={
|
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={
|
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 {
|
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={
|
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 {
|
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={
|
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 {
|
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={
|
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={
|
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={
|
101
|
+
<ExpandMoreIcon className={cls("transition", open ? "rotate-180" : "")}/>
|
100
102
|
</Collapsible.Trigger>
|
101
103
|
|
102
104
|
<Collapsible.Content
|
103
|
-
className={
|
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 {
|
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
|
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={
|
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
|
-
|
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 {
|
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={
|
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 {
|
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={
|
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 {
|
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
|
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
|
-
<
|
31
|
+
<Label
|
31
32
|
data-shrink={shrink}
|
32
33
|
ref={ref}
|
33
34
|
className={computedClassName}
|
package/src/components/Label.tsx
CHANGED
@@ -1,15 +1,28 @@
|
|
1
1
|
import * as React from "react"
|
2
2
|
import * as LabelPrimitive from "@radix-ui/react-label"
|
3
|
-
import {
|
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
|
-
|
9
|
-
>(({
|
12
|
+
LabelProps
|
13
|
+
>(({
|
14
|
+
className,
|
15
|
+
border,
|
16
|
+
onClick,
|
17
|
+
...props
|
18
|
+
}, ref) => (
|
10
19
|
<LabelPrimitive.Root
|
11
20
|
ref={ref}
|
12
|
-
|
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
|
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
|
}
|
package/src/components/Menu.tsx
CHANGED
@@ -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 {
|
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={
|
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={
|
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>
|