@firecms/ui 3.0.0-canary.14 → 3.0.0-canary.140
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 +3 -3
- 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 +3 -2
- package/dist/components/Chip.d.ts +3 -2
- package/dist/components/DateTimeField.d.ts +5 -7
- package/dist/components/Dialog.d.ts +4 -1
- package/dist/components/DialogTitle.d.ts +9 -0
- package/dist/components/ExpandablePanel.d.ts +2 -1
- package/dist/components/FileUpload.d.ts +1 -1
- 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 +6 -2
- package/dist/components/Menubar.d.ts +79 -0
- package/dist/components/MultiSelect.d.ts +31 -16
- package/dist/components/Popover.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +26 -3
- package/dist/components/Select.d.ts +6 -10
- package/dist/components/Separator.d.ts +2 -1
- package/dist/components/Sheet.d.ts +6 -0
- package/dist/components/Slider.d.ts +21 -0
- package/dist/components/Table.d.ts +10 -10
- package/dist/components/TextField.d.ts +1 -1
- package/dist/components/TextareaAutosize.d.ts +3 -34
- package/dist/components/Tooltip.d.ts +6 -2
- package/dist/components/Typography.d.ts +5 -4
- package/dist/components/index.d.ts +3 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/icons/Icon.d.ts +3 -3
- package/dist/index.css +73 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +13371 -14447
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19782 -857
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +8 -8
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +111 -118
- package/src/components/Alert.tsx +2 -2
- package/src/components/Autocomplete.tsx +5 -3
- package/src/components/Avatar.tsx +8 -7
- package/src/components/Badge.tsx +1 -1
- package/src/components/BooleanSwitch.tsx +15 -15
- package/src/components/BooleanSwitchWithLabel.tsx +9 -8
- package/src/components/Button.tsx +18 -20
- package/src/components/Card.tsx +4 -3
- package/src/components/CenteredView.tsx +25 -15
- package/src/components/Checkbox.tsx +11 -9
- package/src/components/Chip.tsx +8 -5
- package/src/components/CircularProgress.tsx +2 -2
- package/src/components/Collapse.tsx +4 -2
- package/src/components/Container.tsx +2 -2
- package/src/components/DateTimeField.tsx +142 -921
- package/src/components/DebouncedTextField.tsx +1 -0
- package/src/components/Dialog.tsx +16 -6
- package/src/components/DialogActions.tsx +2 -2
- package/src/components/DialogContent.tsx +2 -2
- package/src/components/DialogTitle.tsx +35 -0
- package/src/components/ExpandablePanel.tsx +20 -12
- package/src/components/FileUpload.tsx +8 -10
- package/src/components/IconButton.tsx +4 -6
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +11 -9
- package/src/components/Label.tsx +17 -4
- package/src/components/Markdown.tsx +15 -3
- package/src/components/Menu.tsx +49 -31
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +336 -165
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +18 -14
- package/src/components/RadioGroup.tsx +41 -9
- package/src/components/SearchBar.tsx +9 -9
- package/src/components/Select.tsx +97 -124
- package/src/components/Separator.tsx +10 -4
- package/src/components/Sheet.tsx +52 -30
- package/src/components/Skeleton.tsx +9 -6
- package/src/components/Slider.tsx +109 -0
- package/src/components/Table.tsx +50 -33
- package/src/components/Tabs.tsx +6 -7
- package/src/components/TextField.tsx +14 -16
- package/src/components/TextareaAutosize.tsx +4 -3
- package/src/components/Tooltip.tsx +31 -14
- package/src/components/Typography.tsx +42 -26
- package/src/components/common/SelectInputLabel.tsx +2 -2
- package/src/components/index.tsx +3 -1
- package/src/hooks/index.ts +3 -0
- package/src/icons/Icon.tsx +46 -43
- package/src/icons/icon_keys.ts +114 -1301
- package/src/index.css +73 -0
- package/src/index.ts +1 -0
- package/src/scripts/generateIconKeys.ts +20 -11
- package/src/styles.ts +8 -8
- package/src/util/cls.ts +14 -0
- package/src/util/index.ts +1 -3
- package/tailwind.config.js +8 -6
- 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
@@ -0,0 +1,109 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { cls } from "../util";
|
3
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
4
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
5
|
+
|
6
|
+
export interface SliderProps {
|
7
|
+
className?: string;
|
8
|
+
name?: string;
|
9
|
+
disabled?: boolean;
|
10
|
+
orientation?: React.AriaAttributes["aria-orientation"];
|
11
|
+
dir?: "ltr" | "rtl";
|
12
|
+
min?: number;
|
13
|
+
max?: number;
|
14
|
+
step?: number;
|
15
|
+
minStepsBetweenThumbs?: number;
|
16
|
+
value?: number[];
|
17
|
+
defaultValue?: number[];
|
18
|
+
onValueChange?: (value: number[]) => void;
|
19
|
+
onValueCommit?: (value: number[]) => void;
|
20
|
+
inverted?: boolean;
|
21
|
+
form?: string;
|
22
|
+
size?: "small" | "regular";
|
23
|
+
}
|
24
|
+
|
25
|
+
function SliderThumb(props: {
|
26
|
+
props: Omit<React.PropsWithoutRef<SliderProps>, "size" | "className">,
|
27
|
+
index: number,
|
28
|
+
hovered: boolean,
|
29
|
+
classes: string
|
30
|
+
}) {
|
31
|
+
return <TooltipPrimitive.Root open={props.hovered}>
|
32
|
+
<TooltipPrimitive.Trigger asChild>
|
33
|
+
<SliderPrimitive.Thumb
|
34
|
+
className={cls({
|
35
|
+
"border-primary bg-primary hover:bg-primary-dark outline-none": !props.props.disabled,
|
36
|
+
"border-slate-300 bg-slate-300 dark:border-gray-700 dark:bg-gray-700": props.props.disabled
|
37
|
+
},
|
38
|
+
props.classes,
|
39
|
+
"focus-visible:ring-4 focus-visible:ring-primary focus-visible:ring-opacity-50",
|
40
|
+
"hover:ring-4 hover:ring-primary hover:ring-opacity-25",
|
41
|
+
"block rounded-full transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50")}
|
42
|
+
|
43
|
+
/>
|
44
|
+
</TooltipPrimitive.Trigger>
|
45
|
+
<TooltipPrimitive.Content side="top"
|
46
|
+
sideOffset={5}
|
47
|
+
className={cls(
|
48
|
+
"TooltipContent",
|
49
|
+
"max-w-lg leading-relaxed",
|
50
|
+
"z-50 rounded px-3 py-2 text-xs leading-none bg-slate-700 dark:bg-slate-800 bg-opacity-90 font-medium text-slate-50 shadow-2xl select-none duration-400 ease-in transform opacity-100",
|
51
|
+
)}>
|
52
|
+
{props.props.value?.[props.index]}
|
53
|
+
</TooltipPrimitive.Content>
|
54
|
+
</TooltipPrimitive.Root>;
|
55
|
+
}
|
56
|
+
|
57
|
+
const Slider = React.forwardRef<
|
58
|
+
React.ElementRef<typeof SliderPrimitive.Root>,
|
59
|
+
SliderProps
|
60
|
+
>(({
|
61
|
+
className,
|
62
|
+
size = "regular",
|
63
|
+
...props
|
64
|
+
}, ref) => {
|
65
|
+
const [hovered, setHovered] = React.useState(false);
|
66
|
+
|
67
|
+
const thumbSizeClasses =
|
68
|
+
size === "small"
|
69
|
+
? "h-4 w-4" // Smaller size for the thumb
|
70
|
+
: "h-6 w-6"; // Default size
|
71
|
+
|
72
|
+
return (
|
73
|
+
<TooltipPrimitive.Provider delayDuration={200}>
|
74
|
+
<SliderPrimitive.Root
|
75
|
+
ref={ref}
|
76
|
+
onMouseEnter={() => setHovered(true)}
|
77
|
+
onMouseLeave={() => setHovered(false)}
|
78
|
+
className={cls(
|
79
|
+
"relative flex w-full touch-none select-none items-center",
|
80
|
+
className
|
81
|
+
)}
|
82
|
+
{...props}
|
83
|
+
>
|
84
|
+
<SliderPrimitive.Track
|
85
|
+
style={{ height: size === "small" ? 4 : 8 }}
|
86
|
+
className={"relative w-full grow overflow-hidden rounded-full bg-slate-300 bg-opacity-40 dark:bg-gray-700 dark:bg-opacity-40"}>
|
87
|
+
|
88
|
+
<SliderPrimitive.Range
|
89
|
+
className={cls("absolute h-full", {
|
90
|
+
"bg-primary": !props.disabled,
|
91
|
+
"bg-slate-300 dark:bg-gray-700": props.disabled,
|
92
|
+
})}
|
93
|
+
/>
|
94
|
+
</SliderPrimitive.Track>
|
95
|
+
|
96
|
+
{(props.value ?? [0]).map((_, index) => <SliderThumb
|
97
|
+
key={index}
|
98
|
+
index={index}
|
99
|
+
props={props}
|
100
|
+
hovered={hovered}
|
101
|
+
classes={thumbSizeClasses}/>)}
|
102
|
+
</SliderPrimitive.Root>
|
103
|
+
</TooltipPrimitive.Provider>
|
104
|
+
);
|
105
|
+
});
|
106
|
+
|
107
|
+
Slider.displayName = "Slider";
|
108
|
+
|
109
|
+
export { Slider };
|
package/src/components/Table.tsx
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
import React, { useRef } from "react";
|
2
2
|
import { defaultBorderMixin } from "../styles";
|
3
|
-
import {
|
3
|
+
import { cls } from "../util";
|
4
4
|
|
5
5
|
export type TableProps = {
|
6
6
|
children: React.ReactNode;
|
7
7
|
className?: string;
|
8
8
|
style?: React.CSSProperties;
|
9
|
-
}
|
9
|
+
} & React.TableHTMLAttributes<HTMLTableElement>;
|
10
10
|
|
11
11
|
export const Table = ({
|
12
12
|
children,
|
13
13
|
className,
|
14
|
-
style
|
14
|
+
style,
|
15
|
+
...rest
|
15
16
|
}: TableProps) => (
|
16
|
-
<table
|
17
|
-
className)}
|
18
|
-
|
17
|
+
<table
|
18
|
+
className={cls("text-left text-gray-800 dark:text-white rounded-md overflow-x-auto", className)}
|
19
|
+
style={style}
|
20
|
+
{...rest}
|
21
|
+
>
|
19
22
|
{children}
|
20
23
|
</table>
|
21
24
|
);
|
@@ -23,13 +26,17 @@ export const Table = ({
|
|
23
26
|
export type TableBodyProps = {
|
24
27
|
children?: React.ReactNode;
|
25
28
|
className?: string;
|
26
|
-
}
|
29
|
+
} & React.HTMLAttributes<HTMLTableSectionElement>;
|
30
|
+
|
27
31
|
export const TableBody = ({
|
28
32
|
children,
|
29
|
-
className
|
33
|
+
className,
|
34
|
+
...rest
|
30
35
|
}: TableBodyProps) => (
|
31
36
|
<tbody
|
32
|
-
className={
|
37
|
+
className={cls("bg-white dark:bg-gray-950 text-sm divide-y divide-gray-100 dark:divide-gray-800 dark:divide-opacity-80", className)}
|
38
|
+
{...rest}
|
39
|
+
>
|
33
40
|
{children}
|
34
41
|
</tbody>
|
35
42
|
);
|
@@ -37,17 +44,22 @@ export const TableBody = ({
|
|
37
44
|
export type TableHeaderProps = {
|
38
45
|
children?: React.ReactNode;
|
39
46
|
className?: string;
|
40
|
-
}
|
47
|
+
} & React.HTMLAttributes<HTMLTableSectionElement>;
|
41
48
|
|
42
49
|
export const TableHeader = ({
|
43
50
|
children,
|
44
|
-
className
|
51
|
+
className,
|
52
|
+
...rest
|
45
53
|
}: TableHeaderProps) => (
|
46
|
-
<thead>
|
47
|
-
<tr
|
48
|
-
|
49
|
-
|
50
|
-
|
54
|
+
<thead {...rest}>
|
55
|
+
<tr
|
56
|
+
className={cls(
|
57
|
+
defaultBorderMixin,
|
58
|
+
"text-sm font-medium text-gray-700 dark:text-slate-300",
|
59
|
+
"bg-slate-50 border-b dark:bg-gray-900",
|
60
|
+
className
|
61
|
+
)}
|
62
|
+
>
|
51
63
|
{children}
|
52
64
|
</tr>
|
53
65
|
</thead>
|
@@ -58,22 +70,24 @@ export type TableRowProps = {
|
|
58
70
|
className?: string;
|
59
71
|
onClick?: React.MouseEventHandler<any>;
|
60
72
|
style?: React.CSSProperties;
|
61
|
-
}
|
73
|
+
} & React.HTMLAttributes<HTMLTableRowElement>;
|
62
74
|
|
63
75
|
export const TableRow = ({
|
64
76
|
children,
|
65
77
|
className,
|
66
78
|
onClick,
|
67
|
-
style
|
79
|
+
style,
|
80
|
+
...rest
|
68
81
|
}: TableRowProps) => (
|
69
82
|
<tr
|
70
83
|
onClick={onClick}
|
71
84
|
style={style}
|
72
|
-
className={
|
73
|
-
"divide-slate-100 dark:divide-gray-800",
|
85
|
+
className={cls(
|
74
86
|
"bg-white dark:bg-gray-950",
|
75
87
|
onClick ? "hover:bg-slate-100 dark:hover:bg-gray-800 cursor-pointer" : "",
|
76
|
-
className
|
88
|
+
className
|
89
|
+
)}
|
90
|
+
{...rest}
|
77
91
|
>
|
78
92
|
{children}
|
79
93
|
</tr>
|
@@ -87,7 +101,7 @@ export type TableCellProps = {
|
|
87
101
|
style?: React.CSSProperties;
|
88
102
|
align?: "left" | "center" | "right";
|
89
103
|
colspan?: number;
|
90
|
-
}
|
104
|
+
} & React.HTMLAttributes<HTMLTableCellElement>;
|
91
105
|
|
92
106
|
export const TableCell = ({
|
93
107
|
children,
|
@@ -96,20 +110,24 @@ export const TableCell = ({
|
|
96
110
|
align,
|
97
111
|
className,
|
98
112
|
style,
|
99
|
-
colspan
|
113
|
+
colspan,
|
114
|
+
...rest
|
100
115
|
}: TableCellProps) => {
|
101
|
-
|
102
116
|
const ref = useRef<HTMLTableCellElement>(null);
|
103
|
-
|
104
117
|
const Tag = header || getParentName(ref.current) === "TableHeader" ? "th" : "td";
|
105
118
|
return (
|
106
|
-
<Tag
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
119
|
+
<Tag
|
120
|
+
scope={scope}
|
121
|
+
colSpan={colspan}
|
122
|
+
ref={ref}
|
123
|
+
style={style}
|
124
|
+
className={cls(
|
125
|
+
"px-4 py-3 text-clip ",
|
126
|
+
align === "center" ? "text-center" : (align === "right" ? "text-right" : "text-left"),
|
127
|
+
className
|
128
|
+
)}
|
129
|
+
{...rest}
|
130
|
+
>
|
113
131
|
{children}
|
114
132
|
</Tag>
|
115
133
|
);
|
@@ -124,7 +142,6 @@ function getParentName(element: HTMLElement | null): string | undefined {
|
|
124
142
|
key.startsWith("__reactInternalInstance$")
|
125
143
|
);
|
126
144
|
});
|
127
|
-
|
128
145
|
// @ts-ignore
|
129
146
|
const domFiber = element[key];
|
130
147
|
// @ts-ignore
|
package/src/components/Tabs.tsx
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
3
|
-
import {
|
4
|
-
import { cn } from "../util";
|
3
|
+
import { cls } from "../util";
|
5
4
|
|
6
5
|
export type TabsProps = {
|
7
6
|
value: string,
|
@@ -18,7 +17,7 @@ export function Tabs({
|
|
18
17
|
}: TabsProps) {
|
19
18
|
|
20
19
|
return <TabsPrimitive.Root value={value} onValueChange={onValueChange}>
|
21
|
-
<TabsPrimitive.List className={
|
20
|
+
<TabsPrimitive.List className={cls(
|
22
21
|
"flex text-sm font-medium text-center text-slate-800 dark:text-white max-w-full overflow-auto no-scrollbar",
|
23
22
|
className)
|
24
23
|
}>
|
@@ -42,19 +41,19 @@ export function Tab({
|
|
42
41
|
}: TabProps) {
|
43
42
|
return <TabsPrimitive.Trigger value={value}
|
44
43
|
disabled={disabled}
|
45
|
-
className={
|
44
|
+
className={cls(
|
46
45
|
"border-b-2 border-transparent",
|
47
46
|
"data-[state=active]:border-secondary",
|
48
47
|
disabled
|
49
48
|
? "text-slate-400 dark:text-slate-500"
|
50
|
-
:
|
49
|
+
: cls("text-slate-700 dark:text-slate-300",
|
51
50
|
"data-[state=active]:text-slate-900 data-[state=active]:dark:text-white",
|
52
51
|
"hover:text-slate-800 dark:hover:text-slate-200"),
|
53
52
|
// disabled ? "text-slate-400 dark:text-slate-500" : "data-[state=active]:text-primary",
|
54
53
|
// "data-[state=active]:bg-slate-50 data-[state=active]:dark:bg-slate-800",
|
55
54
|
className)}>
|
56
|
-
<div className={
|
57
|
-
"hover:bg-slate-
|
55
|
+
<div className={cls("uppercase inline-block p-2 px-4 m-2 rounded",
|
56
|
+
"hover:bg-slate-200 hover:bg-opacity-75 dark:hover:bg-slate-800")}>
|
58
57
|
{children}
|
59
58
|
</div>
|
60
59
|
</TabsPrimitive.Trigger>;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
"use client";
|
1
2
|
import React, { useCallback, useEffect, useRef } from "react";
|
2
3
|
|
3
4
|
import { TextareaAutosize } from "./TextareaAutosize";
|
@@ -7,10 +8,9 @@ import {
|
|
7
8
|
fieldBackgroundInvisibleMixin,
|
8
9
|
fieldBackgroundMixin,
|
9
10
|
focusedInvisibleMixin,
|
10
|
-
focusedMixin
|
11
11
|
} from "../styles";
|
12
12
|
import { InputLabel } from "./InputLabel";
|
13
|
-
import {
|
13
|
+
import { cls } from "../util";
|
14
14
|
|
15
15
|
export type InputType =
|
16
16
|
"text"
|
@@ -40,7 +40,7 @@ export type TextFieldProps<T extends string | number> = {
|
|
40
40
|
endAdornment?: React.ReactNode,
|
41
41
|
autoFocus?: boolean,
|
42
42
|
placeholder?: string,
|
43
|
-
size?: "small" | "medium",
|
43
|
+
size?: "smallest" | "small" | "medium",
|
44
44
|
className?: string,
|
45
45
|
style?: React.CSSProperties,
|
46
46
|
inputClassName?: string,
|
@@ -70,7 +70,6 @@ export function TextField<T extends string | number>({
|
|
70
70
|
...inputProps
|
71
71
|
}: TextFieldProps<T>) {
|
72
72
|
|
73
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
74
73
|
const inputRef = inputRefProp ?? useRef(null);
|
75
74
|
|
76
75
|
// @ts-ignore
|
@@ -80,7 +79,7 @@ export function TextField<T extends string | number>({
|
|
80
79
|
useEffect(() => {
|
81
80
|
if (type !== "number") return;
|
82
81
|
const handleWheel = (event: any) => {
|
83
|
-
event.
|
82
|
+
if (event.target instanceof HTMLElement) event.target.blur()
|
84
83
|
};
|
85
84
|
|
86
85
|
// Current input element
|
@@ -106,14 +105,12 @@ export function TextField<T extends string | number>({
|
|
106
105
|
placeholder={focused || hasValue || !label ? placeholder : undefined}
|
107
106
|
autoFocus={autoFocus}
|
108
107
|
rows={rows}
|
109
|
-
// onFocus={() => setFocused(true)}
|
110
|
-
// onBlur={() => setFocused(false)}
|
111
108
|
value={value ?? ""}
|
112
109
|
onChange={onChange}
|
113
110
|
style={inputStyle}
|
114
|
-
className={
|
115
|
-
invisible ? focusedInvisibleMixin :
|
116
|
-
"rounded-md resize-none w-full outline-none p-[32px] text-base bg-transparent min-h-[64px] px-3 pt-
|
111
|
+
className={cls(
|
112
|
+
invisible ? focusedInvisibleMixin : "",
|
113
|
+
"rounded-md resize-none w-full outline-none p-[32px] text-base bg-transparent min-h-[64px] px-3 pt-8",
|
117
114
|
disabled && "border border-transparent outline-none opacity-50 text-slate-600 dark:text-slate-500"
|
118
115
|
)}
|
119
116
|
/>
|
@@ -123,13 +120,13 @@ export function TextField<T extends string | number>({
|
|
123
120
|
onWheel={type === "number" ? numberInputOnWheelPreventChange : undefined}
|
124
121
|
disabled={disabled}
|
125
122
|
style={inputStyle}
|
126
|
-
className={
|
123
|
+
className={cls(
|
127
124
|
"w-full outline-none bg-transparent leading-normal px-3",
|
128
125
|
"rounded-md",
|
129
|
-
invisible ? focusedInvisibleMixin :
|
126
|
+
invisible ? focusedInvisibleMixin : "",
|
130
127
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
131
|
-
size === "small" ? "min-h-[48px]" : "min-h-[64px]",
|
132
|
-
label ? (size === "medium" ? "pt-
|
128
|
+
size === "smallest" ? "min-h-[32px]" : (size === "small" ? "min-h-[48px]" : "min-h-[64px]"),
|
129
|
+
label ? (size === "medium" ? "pt-8 pb-2" : "pt-4 pb-2") : "py-2",
|
133
130
|
focused ? "text-text-primary dark:text-text-primary-dark" : "",
|
134
131
|
endAdornment ? "pr-10" : "pr-3",
|
135
132
|
disabled && "border border-transparent outline-none opacity-50 dark:opacity-50 text-slate-800 dark:text-white",
|
@@ -146,12 +143,13 @@ export function TextField<T extends string | number>({
|
|
146
143
|
|
147
144
|
return (
|
148
145
|
<div
|
149
|
-
className={
|
146
|
+
className={cls(
|
150
147
|
"rounded-md relative max-w-full",
|
151
148
|
invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,
|
152
149
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
153
150
|
error ? "border border-red-500 dark:border-red-600" : "",
|
154
151
|
{
|
152
|
+
"min-h-[32px]": !invisible && size === "smallest",
|
155
153
|
"min-h-[48px]": !invisible && size === "small",
|
156
154
|
"min-h-[64px]": !invisible && size === "medium"
|
157
155
|
},
|
@@ -160,7 +158,7 @@ export function TextField<T extends string | number>({
|
|
160
158
|
|
161
159
|
{label && (
|
162
160
|
<InputLabel
|
163
|
-
className={
|
161
|
+
className={cls(
|
164
162
|
"pointer-events-none absolute",
|
165
163
|
size === "medium" ? "top-1" : "-top-1",
|
166
164
|
!error ? (focused ? "text-primary dark:text-primary" : "text-text-secondary dark:text-text-secondary-dark") : "text-red-500 dark:text-red-600",
|
@@ -1,7 +1,8 @@
|
|
1
|
+
"use client";
|
1
2
|
import * as React from "react";
|
2
3
|
import { useLayoutEffect } from "react";
|
3
4
|
import * as ReactDOM from "react-dom";
|
4
|
-
import {
|
5
|
+
import { cls, debounce } from "../util";
|
5
6
|
|
6
7
|
type State = {
|
7
8
|
outerHeightStyle: number;
|
@@ -276,7 +277,7 @@ export const TextareaAutosize = React.forwardRef(function TextareaAutosize(
|
|
276
277
|
/>
|
277
278
|
<textarea
|
278
279
|
aria-hidden
|
279
|
-
className={
|
280
|
+
className={cls(props.className, props.shadowClassName)}
|
280
281
|
readOnly
|
281
282
|
ref={shadowRef}
|
282
283
|
tabIndex={-1}
|
@@ -288,7 +289,7 @@ export const TextareaAutosize = React.forwardRef(function TextareaAutosize(
|
|
288
289
|
/>
|
289
290
|
</React.Fragment>
|
290
291
|
);
|
291
|
-
})
|
292
|
+
}) as React.FC<TextareaAutosizeProps & { ref?: React.ForwardedRef<Element> }>;
|
292
293
|
|
293
294
|
export type TextareaAutosizeProps = Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "onResize"> & {
|
294
295
|
|
@@ -1,34 +1,44 @@
|
|
1
|
+
"use client";
|
1
2
|
import React from "react";
|
2
3
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
3
4
|
|
4
|
-
import {
|
5
|
+
import { cls } from "../util";
|
6
|
+
import { useInjectStyles } from "../hooks";
|
5
7
|
|
6
8
|
export type TooltipProps = {
|
7
9
|
open?: boolean,
|
10
|
+
defaultOpen?: boolean,
|
8
11
|
onOpenChange?: (open: boolean) => void,
|
9
12
|
side?: "top" | "bottom" | "left" | "right",
|
10
13
|
align?: "start" | "center" | "end",
|
11
14
|
sideOffset?: number,
|
12
15
|
title?: string | React.ReactNode,
|
13
16
|
delayDuration?: number;
|
14
|
-
|
17
|
+
asChild?: boolean;
|
15
18
|
tooltipClassName?: string,
|
19
|
+
tooltipStyle?: React.CSSProperties;
|
16
20
|
children: React.ReactNode,
|
21
|
+
className?: string,
|
22
|
+
container?: HTMLElement,
|
17
23
|
style?: React.CSSProperties;
|
18
24
|
};
|
19
25
|
|
20
26
|
export const Tooltip = ({
|
21
27
|
open,
|
28
|
+
defaultOpen,
|
22
29
|
side = "bottom",
|
23
|
-
delayDuration =
|
30
|
+
delayDuration = 200,
|
24
31
|
sideOffset,
|
25
32
|
align,
|
26
33
|
onOpenChange,
|
27
34
|
title,
|
28
|
-
className,
|
29
|
-
style,
|
30
35
|
tooltipClassName,
|
31
|
-
|
36
|
+
tooltipStyle,
|
37
|
+
children,
|
38
|
+
asChild = false,
|
39
|
+
container,
|
40
|
+
className,
|
41
|
+
style
|
32
42
|
}: TooltipProps) => {
|
33
43
|
|
34
44
|
useInjectStyles("Tooltip", styles);
|
@@ -36,20 +46,27 @@ export const Tooltip = ({
|
|
36
46
|
if (!title)
|
37
47
|
return <>{children}</>;
|
38
48
|
|
49
|
+
const trigger = asChild
|
50
|
+
? <TooltipPrimitive.Trigger asChild={true}>
|
51
|
+
{children}
|
52
|
+
</TooltipPrimitive.Trigger>
|
53
|
+
: <TooltipPrimitive.Trigger asChild={true}>
|
54
|
+
<div style={style} className={className}>
|
55
|
+
{children}
|
56
|
+
</div>
|
57
|
+
</TooltipPrimitive.Trigger>;
|
58
|
+
|
39
59
|
return (
|
40
60
|
<TooltipPrimitive.Provider delayDuration={delayDuration}>
|
41
|
-
<TooltipPrimitive.Root open={open} onOpenChange={onOpenChange}>
|
42
|
-
|
43
|
-
|
44
|
-
{children}
|
45
|
-
</div>
|
46
|
-
</TooltipPrimitive.Trigger>
|
47
|
-
<TooltipPrimitive.Portal>
|
61
|
+
<TooltipPrimitive.Root open={open} onOpenChange={onOpenChange} defaultOpen={defaultOpen}>
|
62
|
+
{trigger}
|
63
|
+
<TooltipPrimitive.Portal container={container}>
|
48
64
|
<TooltipPrimitive.Content
|
49
|
-
className={
|
65
|
+
className={cls("TooltipContent",
|
50
66
|
"max-w-lg leading-relaxed",
|
51
67
|
"z-50 rounded px-3 py-2 text-xs leading-none bg-slate-700 dark:bg-slate-800 bg-opacity-90 font-medium text-slate-50 shadow-2xl select-none duration-400 ease-in transform opacity-100",
|
52
68
|
tooltipClassName)}
|
69
|
+
style={tooltipStyle}
|
53
70
|
sideOffset={sideOffset === undefined ? 4 : sideOffset}
|
54
71
|
align={align}
|
55
72
|
side={side}>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React, { ReactEventHandler } from "react";
|
2
|
-
import {
|
3
|
-
import { cn } from "../util";
|
2
|
+
import { cls } from "../util";
|
4
3
|
|
5
|
-
export type
|
4
|
+
export type TypographyVariant = keyof typeof typographyVariants;
|
5
|
+
export type TypographyProps<C extends React.ElementType = "span"> = {
|
6
6
|
align?: "center" | "inherit" | "justify" | "left" | "right";
|
7
7
|
children?: React.ReactNode;
|
8
8
|
className?: string;
|
@@ -10,14 +10,14 @@ export type TextProps<C extends React.ElementType> = {
|
|
10
10
|
gutterBottom?: boolean;
|
11
11
|
noWrap?: boolean;
|
12
12
|
paragraph?: boolean;
|
13
|
-
variant?:
|
13
|
+
variant?: TypographyVariant;
|
14
14
|
variantMapping?: { [key: string]: string };
|
15
15
|
color?: "inherit" | "initial" | "primary" | "secondary" | "disabled" | "error";
|
16
16
|
onClick?: ReactEventHandler<HTMLElement>;
|
17
17
|
style?: React.CSSProperties;
|
18
18
|
} & React.ComponentPropsWithoutRef<C>;
|
19
19
|
|
20
|
-
const
|
20
|
+
const typographyVariants = {
|
21
21
|
h1: "h1",
|
22
22
|
h2: "h2",
|
23
23
|
h3: "h3",
|
@@ -43,24 +43,41 @@ const colorToClasses = {
|
|
43
43
|
error: "text-red-600 dark:text-red-500"
|
44
44
|
};
|
45
45
|
|
46
|
+
const gutterBottomClasses = {
|
47
|
+
h1: "mb-5",
|
48
|
+
h2: "mb-4",
|
49
|
+
h3: "mb-4",
|
50
|
+
h4: "mb-4",
|
51
|
+
h5: "mb-3",
|
52
|
+
h6: "mb-3",
|
53
|
+
subtitle1: "mb-3",
|
54
|
+
subtitle2: "mb-3",
|
55
|
+
body1: "mb-3",
|
56
|
+
body2: "mb-3",
|
57
|
+
inherit: "mb-3",
|
58
|
+
caption: "mb-2",
|
59
|
+
button: "mb-2",
|
60
|
+
label: "mb-2"
|
61
|
+
};
|
62
|
+
|
46
63
|
const variantToClasses = {
|
47
|
-
h1: "
|
48
|
-
h2: "
|
49
|
-
h3: "
|
50
|
-
h4: "
|
51
|
-
h5: "
|
52
|
-
h6: "
|
53
|
-
subtitle1: "
|
54
|
-
subtitle2: "
|
55
|
-
body1: "
|
56
|
-
body2: "
|
57
|
-
label: "
|
58
|
-
inherit: "
|
59
|
-
caption: "
|
60
|
-
button: "
|
64
|
+
h1: "typography-h1",
|
65
|
+
h2: "typography-h2",
|
66
|
+
h3: "typography-h3",
|
67
|
+
h4: "typography-h4",
|
68
|
+
h5: "typography-h5",
|
69
|
+
h6: "typography-h6",
|
70
|
+
subtitle1: "typography-subtitle1",
|
71
|
+
subtitle2: "typography-subtitle2",
|
72
|
+
body1: "typography-body1",
|
73
|
+
body2: "typography-body2",
|
74
|
+
label: "typography-label",
|
75
|
+
inherit: "typography-inherit",
|
76
|
+
caption: "typography-caption",
|
77
|
+
button: "typography-button"
|
61
78
|
};
|
62
79
|
|
63
|
-
export function Typography<C extends React.ElementType>(
|
80
|
+
export function Typography<C extends React.ElementType = "span">(
|
64
81
|
{
|
65
82
|
align = "inherit",
|
66
83
|
color = "primary",
|
@@ -71,23 +88,22 @@ export function Typography<C extends React.ElementType>(
|
|
71
88
|
noWrap = false,
|
72
89
|
paragraph = false,
|
73
90
|
variant = "body1",
|
74
|
-
variantMapping =
|
91
|
+
variantMapping = typographyVariants,
|
75
92
|
style,
|
76
93
|
onClick,
|
77
94
|
...other
|
78
|
-
}:
|
95
|
+
}: TypographyProps<C>
|
79
96
|
) {
|
80
97
|
const Component =
|
81
98
|
component ||
|
82
|
-
(paragraph ? "p" : variantMapping[variant] ||
|
99
|
+
(paragraph ? "p" : variantMapping[variant] || typographyVariants[variant]) ||
|
83
100
|
"span";
|
84
101
|
|
85
|
-
const classes =
|
86
|
-
focusedMixin,
|
102
|
+
const classes = cls(
|
87
103
|
variantToClasses[variant],
|
88
104
|
color ? colorToClasses[color] : "",
|
89
105
|
align !== "inherit" && `text-${align}`,
|
90
|
-
gutterBottom &&
|
106
|
+
gutterBottom && gutterBottomClasses[variant],
|
91
107
|
noWrap && "truncate",
|
92
108
|
paragraph && "mb-3",
|
93
109
|
className
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import {
|
2
|
+
import { cls } from "../../util";
|
3
3
|
|
4
4
|
export function SelectInputLabel({ children, error }: { children: React.ReactNode, error?: boolean }) {
|
5
|
-
return <div className={
|
5
|
+
return <div className={cls("text-sm font-medium ml-3.5 mb-1",
|
6
6
|
error ? "text-red-500 dark:text-red-600" : "text-slate-500 dark:text-slate-300",)}>
|
7
7
|
{children}
|
8
8
|
</div>;
|