@firecms/ui 3.0.0-beta.1 → 3.0.0-beta.10
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 +6 -7
- package/dist/components/Avatar.d.ts +1 -0
- package/dist/components/BooleanSwitch.d.ts +1 -1
- package/dist/components/Button.d.ts +3 -2
- package/dist/components/Card.d.ts +4 -2
- package/dist/components/CenteredView.d.ts +5 -2
- package/dist/components/Checkbox.d.ts +5 -4
- package/dist/components/Chip.d.ts +3 -2
- package/dist/components/DateTimeField.d.ts +5 -7
- package/dist/components/Dialog.d.ts +5 -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/IconButton.d.ts +1 -1
- package/dist/components/InputLabel.d.ts +2 -2
- package/dist/components/Label.d.ts +7 -0
- package/dist/components/Markdown.d.ts +1 -0
- package/dist/components/Menu.d.ts +7 -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 +28 -0
- package/dist/components/Select.d.ts +6 -10
- package/dist/components/Separator.d.ts +5 -0
- 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 +3 -3
- package/dist/components/TextareaAutosize.d.ts +3 -34
- package/dist/components/Tooltip.d.ts +9 -3
- package/dist/components/Typography.d.ts +5 -4
- package/dist/components/_MultiSelect.d.ts +0 -0
- package/dist/components/index.d.ts +7 -2
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useLocaleConfig.d.ts +1 -0
- package/dist/icons/HandleIcon.d.ts +1 -0
- package/dist/icons/Icon.d.ts +3 -3
- package/dist/icons/index.d.ts +1 -0
- package/dist/index.css +73 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +13341 -13478
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19788 -49
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +10 -10
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +112 -105
- package/src/components/Alert.tsx +6 -5
- package/src/components/Autocomplete.tsx +4 -3
- package/src/components/Avatar.tsx +8 -7
- package/src/components/Badge.tsx +1 -1
- package/src/components/BooleanSwitch.tsx +18 -17
- package/src/components/BooleanSwitchWithLabel.tsx +8 -8
- package/src/components/Button.tsx +59 -35
- package/src/components/Card.tsx +19 -13
- package/src/components/CenteredView.tsx +26 -14
- package/src/components/Checkbox.tsx +36 -25
- package/src/components/Chip.tsx +9 -6
- 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 +45 -50
- package/src/components/DebouncedTextField.tsx +3 -2
- package/src/components/Dialog.tsx +18 -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 +19 -11
- package/src/components/FileUpload.tsx +7 -10
- package/src/components/IconButton.tsx +7 -8
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +12 -9
- package/src/components/Label.tsx +31 -0
- package/src/components/Markdown.tsx +14 -3
- package/src/components/Menu.tsx +51 -30
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +335 -165
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +17 -13
- package/src/components/RadioGroup.tsx +73 -0
- package/src/components/SearchBar.tsx +8 -9
- package/src/components/Select.tsx +97 -125
- package/src/components/Separator.tsx +28 -0
- package/src/components/Sheet.tsx +51 -30
- package/src/components/Skeleton.tsx +9 -6
- package/src/components/Slider.tsx +109 -0
- package/src/components/Table.tsx +52 -35
- package/src/components/Tabs.tsx +8 -9
- package/src/components/TextField.tsx +35 -23
- package/src/components/TextareaAutosize.tsx +3 -3
- package/src/components/Tooltip.tsx +37 -16
- package/src/components/Typography.tsx +43 -27
- package/src/components/_MultiSelect.tsx +222 -0
- package/src/components/common/SelectInputLabel.tsx +2 -2
- package/src/components/index.tsx +7 -2
- package/src/hooks/index.ts +4 -0
- package/src/{util → hooks}/useInjectStyles.tsx +1 -1
- package/src/hooks/useLocaleConfig.tsx +18 -0
- package/src/icons/GitHubIcon.tsx +1 -0
- package/src/icons/HandleIcon.tsx +10 -0
- package/src/icons/Icon.tsx +46 -43
- package/src/icons/icon_keys.ts +114 -1301
- package/src/icons/index.ts +1 -0
- package/src/index.css +73 -0
- package/src/index.ts +1 -0
- package/src/scripts/generateIconKeys.ts +20 -12
- package/src/scripts/saveIconFiles.ts +2 -1
- package/src/styles.ts +10 -10
- package/src/util/cls.ts +14 -0
- package/src/util/index.ts +1 -3
- package/tailwind.config.js +70 -0
- package/dist/components/Spinner.d.ts +0 -1
- package/src/components/Spinner.tsx +0 -17
- 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}/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
|
-
"
|
|
74
|
-
"bg-
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
className={cls(
|
|
86
|
+
"bg-white dark:bg-gray-950",
|
|
87
|
+
onClick ? "hover:bg-slate-100 dark:hover:bg-gray-800 cursor-pointer" : "",
|
|
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,8 +17,8 @@ export function Tabs({
|
|
|
18
17
|
}: TabsProps) {
|
|
19
18
|
|
|
20
19
|
return <TabsPrimitive.Root value={value} onValueChange={onValueChange}>
|
|
21
|
-
<TabsPrimitive.List className={
|
|
22
|
-
"flex text-sm font-medium text-center text-slate-800 dark:text-
|
|
20
|
+
<TabsPrimitive.List className={cls(
|
|
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
|
}>
|
|
25
24
|
{children}
|
|
@@ -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
|
-
:
|
|
51
|
-
"data-[state=active]:text-slate-900 data-[state=active]:dark:text-
|
|
49
|
+
: cls("text-slate-700 dark:text-slate-300",
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useRef } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from "react";
|
|
2
2
|
|
|
3
3
|
import { TextareaAutosize } from "./TextareaAutosize";
|
|
4
4
|
import {
|
|
@@ -7,10 +7,9 @@ import {
|
|
|
7
7
|
fieldBackgroundInvisibleMixin,
|
|
8
8
|
fieldBackgroundMixin,
|
|
9
9
|
focusedInvisibleMixin,
|
|
10
|
-
focusedMixin
|
|
11
10
|
} from "../styles";
|
|
12
11
|
import { InputLabel } from "./InputLabel";
|
|
13
|
-
import {
|
|
12
|
+
import { cls } from "../util";
|
|
14
13
|
|
|
15
14
|
export type InputType =
|
|
16
15
|
"text"
|
|
@@ -29,7 +28,7 @@ export type InputType =
|
|
|
29
28
|
|
|
30
29
|
export type TextFieldProps<T extends string | number> = {
|
|
31
30
|
type?: InputType,
|
|
32
|
-
value
|
|
31
|
+
value?: T,
|
|
33
32
|
onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void,
|
|
34
33
|
label?: React.ReactNode,
|
|
35
34
|
multiline?: boolean,
|
|
@@ -40,12 +39,12 @@ export type TextFieldProps<T extends string | number> = {
|
|
|
40
39
|
endAdornment?: React.ReactNode,
|
|
41
40
|
autoFocus?: boolean,
|
|
42
41
|
placeholder?: string,
|
|
43
|
-
size?: "small" | "medium",
|
|
42
|
+
size?: "smallest" | "small" | "medium",
|
|
44
43
|
className?: string,
|
|
45
44
|
style?: React.CSSProperties,
|
|
46
45
|
inputClassName?: string,
|
|
47
46
|
inputStyle?: React.CSSProperties,
|
|
48
|
-
inputRef?: React.
|
|
47
|
+
inputRef?: React.ForwardedRef<any>
|
|
49
48
|
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">;
|
|
50
49
|
|
|
51
50
|
export function TextField<T extends string | number>({
|
|
@@ -70,19 +69,32 @@ export function TextField<T extends string | number>({
|
|
|
70
69
|
...inputProps
|
|
71
70
|
}: TextFieldProps<T>) {
|
|
72
71
|
|
|
73
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
74
72
|
const inputRef = inputRefProp ?? useRef(null);
|
|
75
73
|
|
|
76
74
|
// @ts-ignore
|
|
77
75
|
const [focused, setFocused] = React.useState(document.activeElement === inputRef.current);
|
|
78
76
|
const hasValue = value !== undefined && value !== null && value !== "";
|
|
79
77
|
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (type !== "number") return;
|
|
80
|
+
const handleWheel = (event: any) => {
|
|
81
|
+
event.preventDefault(); // Prevent scrolling the number input
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Current input element
|
|
85
|
+
const element = "current" in inputRef ? inputRef.current : inputRef;
|
|
86
|
+
|
|
87
|
+
// Add the event listener
|
|
88
|
+
element.addEventListener("wheel", handleWheel);
|
|
89
|
+
|
|
90
|
+
// Remove event listener on cleanup
|
|
91
|
+
return () => {
|
|
92
|
+
element.removeEventListener("wheel", handleWheel);
|
|
93
|
+
};
|
|
94
|
+
}, [inputRef, type]);
|
|
95
|
+
|
|
80
96
|
const numberInputOnWheelPreventChange = useCallback((e: any) => {
|
|
81
|
-
e.
|
|
82
|
-
e.stopPropagation()
|
|
83
|
-
setTimeout(() => {
|
|
84
|
-
e.target.focus()
|
|
85
|
-
}, 0)
|
|
97
|
+
e.preventDefault()
|
|
86
98
|
}, []);
|
|
87
99
|
|
|
88
100
|
const input = multiline
|
|
@@ -92,13 +104,11 @@ export function TextField<T extends string | number>({
|
|
|
92
104
|
placeholder={focused || hasValue || !label ? placeholder : undefined}
|
|
93
105
|
autoFocus={autoFocus}
|
|
94
106
|
rows={rows}
|
|
95
|
-
// onFocus={() => setFocused(true)}
|
|
96
|
-
// onBlur={() => setFocused(false)}
|
|
97
107
|
value={value ?? ""}
|
|
98
108
|
onChange={onChange}
|
|
99
109
|
style={inputStyle}
|
|
100
|
-
className={
|
|
101
|
-
invisible ? focusedInvisibleMixin :
|
|
110
|
+
className={cls(
|
|
111
|
+
invisible ? focusedInvisibleMixin : "",
|
|
102
112
|
"rounded-md resize-none w-full outline-none p-[32px] text-base bg-transparent min-h-[64px] px-3 pt-[28px]",
|
|
103
113
|
disabled && "border border-transparent outline-none opacity-50 text-slate-600 dark:text-slate-500"
|
|
104
114
|
)}
|
|
@@ -109,16 +119,16 @@ export function TextField<T extends string | number>({
|
|
|
109
119
|
onWheel={type === "number" ? numberInputOnWheelPreventChange : undefined}
|
|
110
120
|
disabled={disabled}
|
|
111
121
|
style={inputStyle}
|
|
112
|
-
className={
|
|
122
|
+
className={cls(
|
|
113
123
|
"w-full outline-none bg-transparent leading-normal px-3",
|
|
114
124
|
"rounded-md",
|
|
115
|
-
invisible ? focusedInvisibleMixin :
|
|
125
|
+
invisible ? focusedInvisibleMixin : "",
|
|
116
126
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
|
117
|
-
size === "small" ? "min-h-[48px]" : "min-h-[64px]",
|
|
127
|
+
size === "smallest" ? "min-h-[32px]" : (size === "small" ? "min-h-[48px]" : "min-h-[64px]"),
|
|
118
128
|
label ? (size === "medium" ? "pt-[28px] pb-2" : "pt-4 pb-2") : "py-2",
|
|
119
129
|
focused ? "text-text-primary dark:text-text-primary-dark" : "",
|
|
120
130
|
endAdornment ? "pr-10" : "pr-3",
|
|
121
|
-
disabled && "border border-transparent outline-none opacity-50 dark:opacity-50 text-slate-800 dark:text-
|
|
131
|
+
disabled && "border border-transparent outline-none opacity-50 dark:opacity-50 text-slate-800 dark:text-white",
|
|
122
132
|
inputClassName
|
|
123
133
|
)}
|
|
124
134
|
placeholder={focused || hasValue || !label ? placeholder : undefined}
|
|
@@ -132,12 +142,13 @@ export function TextField<T extends string | number>({
|
|
|
132
142
|
|
|
133
143
|
return (
|
|
134
144
|
<div
|
|
135
|
-
className={
|
|
145
|
+
className={cls(
|
|
136
146
|
"rounded-md relative max-w-full",
|
|
137
147
|
invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,
|
|
138
148
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
|
139
149
|
error ? "border border-red-500 dark:border-red-600" : "",
|
|
140
150
|
{
|
|
151
|
+
"min-h-[32px]": !invisible && size === "smallest",
|
|
141
152
|
"min-h-[48px]": !invisible && size === "small",
|
|
142
153
|
"min-h-[64px]": !invisible && size === "medium"
|
|
143
154
|
},
|
|
@@ -146,7 +157,7 @@ export function TextField<T extends string | number>({
|
|
|
146
157
|
|
|
147
158
|
{label && (
|
|
148
159
|
<InputLabel
|
|
149
|
-
className={
|
|
160
|
+
className={cls(
|
|
150
161
|
"pointer-events-none absolute",
|
|
151
162
|
size === "medium" ? "top-1" : "-top-1",
|
|
152
163
|
!error ? (focused ? "text-primary dark:text-primary" : "text-text-secondary dark:text-text-secondary-dark") : "text-red-500 dark:text-red-600",
|
|
@@ -159,7 +170,8 @@ export function TextField<T extends string | number>({
|
|
|
159
170
|
|
|
160
171
|
{input}
|
|
161
172
|
|
|
162
|
-
{endAdornment && <div
|
|
173
|
+
{endAdornment && <div
|
|
174
|
+
className="flex flex-row justify-center items-center absolute h-full right-0 top-0 mr-4 ">{endAdornment}</div>}
|
|
163
175
|
|
|
164
176
|
</div>
|
|
165
177
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useLayoutEffect } from "react";
|
|
3
3
|
import * as ReactDOM from "react-dom";
|
|
4
|
-
import {
|
|
4
|
+
import { cls, debounce } from "../util";
|
|
5
5
|
|
|
6
6
|
type State = {
|
|
7
7
|
outerHeightStyle: number;
|
|
@@ -276,7 +276,7 @@ export const TextareaAutosize = React.forwardRef(function TextareaAutosize(
|
|
|
276
276
|
/>
|
|
277
277
|
<textarea
|
|
278
278
|
aria-hidden
|
|
279
|
-
className={
|
|
279
|
+
className={cls(props.className, props.shadowClassName)}
|
|
280
280
|
readOnly
|
|
281
281
|
ref={shadowRef}
|
|
282
282
|
tabIndex={-1}
|
|
@@ -288,7 +288,7 @@ export const TextareaAutosize = React.forwardRef(function TextareaAutosize(
|
|
|
288
288
|
/>
|
|
289
289
|
</React.Fragment>
|
|
290
290
|
);
|
|
291
|
-
})
|
|
291
|
+
}) as React.FC<TextareaAutosizeProps & { ref?: React.ForwardedRef<Element> }>;
|
|
292
292
|
|
|
293
293
|
export type TextareaAutosizeProps = Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "onResize"> & {
|
|
294
294
|
|
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { cls } from "../util";
|
|
5
|
+
import { useInjectStyles } from "../hooks";
|
|
5
6
|
|
|
6
7
|
export type TooltipProps = {
|
|
7
8
|
open?: boolean,
|
|
9
|
+
defaultOpen?: boolean,
|
|
8
10
|
onOpenChange?: (open: boolean) => void,
|
|
9
11
|
side?: "top" | "bottom" | "left" | "right",
|
|
12
|
+
align?: "start" | "center" | "end",
|
|
10
13
|
sideOffset?: number,
|
|
11
|
-
title?: string,
|
|
12
|
-
|
|
14
|
+
title?: string | React.ReactNode,
|
|
15
|
+
delayDuration?: number;
|
|
16
|
+
asChild?: boolean;
|
|
13
17
|
tooltipClassName?: string,
|
|
18
|
+
tooltipStyle?: React.CSSProperties;
|
|
14
19
|
children: React.ReactNode,
|
|
15
|
-
|
|
20
|
+
className?: string,
|
|
21
|
+
container?: HTMLElement,
|
|
22
|
+
style?: React.CSSProperties;
|
|
16
23
|
};
|
|
17
24
|
|
|
18
25
|
export const Tooltip = ({
|
|
19
26
|
open,
|
|
27
|
+
defaultOpen,
|
|
20
28
|
side = "bottom",
|
|
29
|
+
delayDuration = 200,
|
|
21
30
|
sideOffset,
|
|
31
|
+
align,
|
|
22
32
|
onOpenChange,
|
|
23
33
|
title,
|
|
24
|
-
className,
|
|
25
|
-
style,
|
|
26
34
|
tooltipClassName,
|
|
27
|
-
|
|
35
|
+
tooltipStyle,
|
|
36
|
+
children,
|
|
37
|
+
asChild = false,
|
|
38
|
+
container,
|
|
39
|
+
className,
|
|
40
|
+
style
|
|
28
41
|
}: TooltipProps) => {
|
|
29
42
|
|
|
30
43
|
useInjectStyles("Tooltip", styles);
|
|
@@ -32,21 +45,29 @@ export const Tooltip = ({
|
|
|
32
45
|
if (!title)
|
|
33
46
|
return <>{children}</>;
|
|
34
47
|
|
|
48
|
+
const trigger = asChild
|
|
49
|
+
? <TooltipPrimitive.Trigger asChild={true}>
|
|
50
|
+
{children}
|
|
51
|
+
</TooltipPrimitive.Trigger>
|
|
52
|
+
: <TooltipPrimitive.Trigger asChild={true}>
|
|
53
|
+
<div style={style} className={className}>
|
|
54
|
+
{children}
|
|
55
|
+
</div>
|
|
56
|
+
</TooltipPrimitive.Trigger>;
|
|
57
|
+
|
|
35
58
|
return (
|
|
36
|
-
<TooltipPrimitive.Provider delayDuration={
|
|
37
|
-
<TooltipPrimitive.Root open={open} onOpenChange={onOpenChange}>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{children}
|
|
41
|
-
</div>
|
|
42
|
-
</TooltipPrimitive.Trigger>
|
|
43
|
-
<TooltipPrimitive.Portal>
|
|
59
|
+
<TooltipPrimitive.Provider delayDuration={delayDuration}>
|
|
60
|
+
<TooltipPrimitive.Root open={open} onOpenChange={onOpenChange} defaultOpen={defaultOpen}>
|
|
61
|
+
{trigger}
|
|
62
|
+
<TooltipPrimitive.Portal container={container}>
|
|
44
63
|
<TooltipPrimitive.Content
|
|
45
|
-
className={
|
|
64
|
+
className={cls("TooltipContent",
|
|
46
65
|
"max-w-lg leading-relaxed",
|
|
47
66
|
"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",
|
|
48
67
|
tooltipClassName)}
|
|
68
|
+
style={tooltipStyle}
|
|
49
69
|
sideOffset={sideOffset === undefined ? 4 : sideOffset}
|
|
70
|
+
align={align}
|
|
50
71
|
side={side}>
|
|
51
72
|
{title}
|
|
52
73
|
{/*<TooltipPrimitive.Arrow className="fill-slate-600"/>*/}
|