@firecms/ui 3.0.0-canary.16 → 3.0.0-canary.160
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 +60 -150
- package/dist/components/Avatar.d.ts +1 -0
- package/dist/components/BooleanSwitch.d.ts +1 -1
- package/dist/components/BooleanSwitchWithLabel.d.ts +4 -1
- package/dist/components/Button.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/DialogContent.d.ts +2 -1
- package/dist/components/DialogTitle.d.ts +10 -0
- package/dist/components/ExpandablePanel.d.ts +2 -1
- package/dist/components/FileUpload.d.ts +2 -2
- 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 +32 -16
- package/dist/components/Popover.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +26 -3
- package/dist/components/Select.d.ts +8 -11
- 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/Tabs.d.ts +4 -2
- 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 +50174 -20590
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +50441 -857
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +9 -9
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +119 -118
- package/src/components/Alert.tsx +4 -4
- package/src/components/Autocomplete.tsx +7 -5
- package/src/components/Avatar.tsx +41 -26
- package/src/components/Badge.tsx +2 -2
- package/src/components/BooleanSwitch.tsx +14 -13
- package/src/components/BooleanSwitchWithLabel.tsx +17 -8
- package/src/components/Button.tsx +31 -23
- package/src/components/Card.tsx +4 -3
- package/src/components/CenteredView.tsx +26 -15
- package/src/components/Checkbox.tsx +16 -14
- package/src/components/Chip.tsx +13 -10
- package/src/components/CircularProgress.tsx +3 -3
- package/src/components/Collapse.tsx +4 -2
- package/src/components/Container.tsx +3 -2
- package/src/components/DateTimeField.tsx +144 -921
- package/src/components/DebouncedTextField.tsx +1 -0
- package/src/components/Dialog.tsx +17 -7
- package/src/components/DialogActions.tsx +3 -3
- package/src/components/DialogContent.tsx +7 -3
- package/src/components/DialogTitle.tsx +41 -0
- package/src/components/ExpandablePanel.tsx +20 -12
- package/src/components/FileUpload.tsx +11 -13
- package/src/components/IconButton.tsx +7 -11
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +12 -9
- package/src/components/Label.tsx +18 -4
- package/src/components/Markdown.tsx +15 -3
- package/src/components/Menu.tsx +50 -31
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +341 -167
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +19 -15
- package/src/components/RadioGroup.tsx +42 -9
- package/src/components/SearchBar.tsx +12 -11
- package/src/components/Select.tsx +142 -130
- package/src/components/Separator.tsx +10 -4
- package/src/components/Sheet.tsx +53 -31
- package/src/components/Skeleton.tsx +9 -6
- package/src/components/Slider.tsx +110 -0
- package/src/components/Table.tsx +54 -35
- package/src/components/Tabs.tsx +17 -15
- package/src/components/TextField.tsx +25 -23
- package/src/components/TextareaAutosize.tsx +4 -3
- package/src/components/Tooltip.tsx +33 -16
- package/src/components/Typography.tsx +42 -26
- package/src/components/common/SelectInputLabel.tsx +3 -3
- package/src/components/index.tsx +3 -1
- package/src/hooks/index.ts +3 -0
- package/src/{util → hooks}/useDebounceValue.tsx +2 -0
- package/src/{util → hooks}/useInjectStyles.tsx +1 -0
- package/src/{util → hooks}/useOutsideAlerter.tsx +2 -0
- package/src/icons/Icon.tsx +48 -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 +9 -9
- package/src/util/cls.ts +14 -0
- package/src/util/index.ts +1 -3
- package/tailwind.config.js +42 -26
- 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/components/Sheet.tsx
CHANGED
@@ -1,37 +1,43 @@
|
|
1
|
-
|
1
|
+
"use client";
|
2
|
+
import React, { useEffect, useState } from "react";
|
3
|
+
import { cls } from "../util";
|
4
|
+
import { defaultBorderMixin } from "../styles";
|
2
5
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
3
|
-
import { cn } from "../util";
|
4
6
|
|
5
7
|
interface SheetProps {
|
6
8
|
children: React.ReactNode;
|
7
9
|
open: boolean;
|
10
|
+
title?: string;
|
11
|
+
modal?: boolean;
|
12
|
+
includeBackgroundOverlay?: boolean;
|
8
13
|
side?: "top" | "bottom" | "left" | "right";
|
14
|
+
darkBackground?: boolean;
|
9
15
|
transparent?: boolean;
|
10
16
|
onOpenChange?: (open: boolean) => void;
|
17
|
+
className?: string;
|
18
|
+
overlayClassName?: string;
|
11
19
|
}
|
12
20
|
|
13
21
|
export const Sheet: React.FC<SheetProps> = ({
|
14
22
|
children,
|
15
23
|
side = "right",
|
24
|
+
title,
|
25
|
+
modal = true,
|
26
|
+
includeBackgroundOverlay = true,
|
16
27
|
open,
|
17
28
|
onOpenChange,
|
18
29
|
transparent,
|
30
|
+
className,
|
31
|
+
overlayClassName,
|
19
32
|
...props
|
20
33
|
}) => {
|
21
|
-
|
22
|
-
const [displayed, setDisplayed] = React.useState(false);
|
34
|
+
const [displayed, setDisplayed] = useState(false);
|
23
35
|
|
24
36
|
useEffect(() => {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
return () => clearTimeout(timeout);
|
30
|
-
} else {
|
31
|
-
setDisplayed(true);
|
32
|
-
return () => {
|
33
|
-
};
|
34
|
-
}
|
37
|
+
const timeout = setTimeout(() => {
|
38
|
+
setDisplayed(open);
|
39
|
+
}, 1);
|
40
|
+
return () => clearTimeout(timeout);
|
35
41
|
}, [open]);
|
36
42
|
|
37
43
|
const transformValue: Record<string, string> = {
|
@@ -41,36 +47,52 @@ export const Sheet: React.FC<SheetProps> = ({
|
|
41
47
|
right: "translate-x-full"
|
42
48
|
};
|
43
49
|
|
44
|
-
|
50
|
+
const borderClass: Record<string, string> = {
|
51
|
+
top: "border-b",
|
52
|
+
bottom: "border-t",
|
53
|
+
left: "border-r",
|
54
|
+
right: "border-l"
|
55
|
+
};
|
45
56
|
|
57
|
+
return (
|
46
58
|
<DialogPrimitive.Root open={displayed || open}
|
59
|
+
modal={modal}
|
47
60
|
onOpenChange={onOpenChange}>
|
48
61
|
<DialogPrimitive.Portal>
|
49
|
-
<DialogPrimitive.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
62
|
+
<DialogPrimitive.Title autoFocus tabIndex={0}>
|
63
|
+
{title ?? "Sheet"}
|
64
|
+
</DialogPrimitive.Title>
|
65
|
+
{includeBackgroundOverlay && <DialogPrimitive.Overlay
|
66
|
+
className={cls(
|
67
|
+
"fixed inset-0 transition-opacity z-20 ease-in-out duration-100 backdrop-blur-sm",
|
68
|
+
"bg-black bg-opacity-50",
|
69
|
+
"dark:bg-surface-900 dark:bg-opacity-60",
|
70
|
+
displayed && open ? "opacity-100" : "opacity-0",
|
71
|
+
overlayClassName
|
55
72
|
)}
|
56
73
|
style={{
|
57
|
-
pointerEvents: displayed ? "auto" : "none"
|
74
|
+
pointerEvents: displayed ? "auto" : "none"
|
58
75
|
}}
|
59
|
-
/>
|
76
|
+
/>}
|
60
77
|
<DialogPrimitive.Content
|
61
78
|
{...props}
|
62
|
-
|
63
|
-
|
79
|
+
onFocusCapture={(event) => event.preventDefault()}
|
80
|
+
className={cls(
|
81
|
+
borderClass[side],
|
82
|
+
defaultBorderMixin,
|
83
|
+
"transform-gpu",
|
64
84
|
"will-change-transform",
|
65
|
-
"text-
|
66
|
-
"fixed transform z-20 transition-all
|
85
|
+
"text-surface-accent-900 dark:text-white",
|
86
|
+
"fixed transform z-20 transition-all ease-in-out",
|
87
|
+
!displayed ? "duration-150" : "duration-100",
|
67
88
|
"outline-none focus:outline-none",
|
68
|
-
|
89
|
+
transparent ? "" : "shadow-md bg-white dark:bg-surface-950",
|
69
90
|
side === "top" || side === "bottom" ? "w-full" : "h-full",
|
70
91
|
side === "left" || side === "top" ? "left-0 top-0" : "right-0 bottom-0",
|
71
|
-
displayed && open ? "opacity-100" : "opacity-
|
72
|
-
!displayed || !open ? transformValue[side] : ""
|
73
|
-
|
92
|
+
displayed && open ? "opacity-100" : "opacity-50",
|
93
|
+
!displayed || !open ? transformValue[side] : "",
|
94
|
+
className
|
95
|
+
)}
|
74
96
|
>
|
75
97
|
{children}
|
76
98
|
</DialogPrimitive.Content>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import {
|
2
|
+
import { cls } from "../util";
|
3
3
|
|
4
4
|
export type SkeletonProps = {
|
5
5
|
width?: number;
|
@@ -12,13 +12,16 @@ export function Skeleton({
|
|
12
12
|
height,
|
13
13
|
className
|
14
14
|
}: SkeletonProps) {
|
15
|
-
return <span
|
16
|
-
|
15
|
+
return <span
|
16
|
+
style={{
|
17
|
+
width: width ? `${width}px` : "100%",
|
18
|
+
height: height ? `${height}px` : "12px"
|
19
|
+
}}
|
20
|
+
className={
|
21
|
+
cls(
|
17
22
|
"block",
|
18
|
-
"bg-
|
23
|
+
"bg-surface-accent-200 dark:bg-surface-accent-800 rounded-md",
|
19
24
|
"animate-pulse",
|
20
|
-
width ? `w-[${width}px]` : "w-full",
|
21
|
-
height ? `h-[${height}px]` : "h-3",
|
22
25
|
"max-w-full max-h-full",
|
23
26
|
className)
|
24
27
|
}/>;
|
@@ -0,0 +1,110 @@
|
|
1
|
+
"use client";
|
2
|
+
import * as React from "react";
|
3
|
+
import { cls } from "../util";
|
4
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
5
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
6
|
+
|
7
|
+
export interface SliderProps {
|
8
|
+
className?: string;
|
9
|
+
name?: string;
|
10
|
+
disabled?: boolean;
|
11
|
+
orientation?: React.AriaAttributes["aria-orientation"];
|
12
|
+
dir?: "ltr" | "rtl";
|
13
|
+
min?: number;
|
14
|
+
max?: number;
|
15
|
+
step?: number;
|
16
|
+
minStepsBetweenThumbs?: number;
|
17
|
+
value?: number[];
|
18
|
+
defaultValue?: number[];
|
19
|
+
onValueChange?: (value: number[]) => void;
|
20
|
+
onValueCommit?: (value: number[]) => void;
|
21
|
+
inverted?: boolean;
|
22
|
+
form?: string;
|
23
|
+
size?: "small" | "regular";
|
24
|
+
}
|
25
|
+
|
26
|
+
function SliderThumb(props: {
|
27
|
+
props: Omit<React.PropsWithoutRef<SliderProps>, "size" | "className">,
|
28
|
+
index: number,
|
29
|
+
hovered: boolean,
|
30
|
+
classes: string
|
31
|
+
}) {
|
32
|
+
return <TooltipPrimitive.Root open={props.hovered}>
|
33
|
+
<TooltipPrimitive.Trigger asChild>
|
34
|
+
<SliderPrimitive.Thumb
|
35
|
+
className={cls({
|
36
|
+
"border-primary bg-primary hover:bg-primary-dark outline-none": !props.props.disabled,
|
37
|
+
"border-surface-accent-300 bg-surface-accent-300 dark:border-surface-700 dark:bg-surface-700": props.props.disabled
|
38
|
+
},
|
39
|
+
props.classes,
|
40
|
+
"focus-visible:ring-4 focus-visible:ring-primary focus-visible:ring-opacity-50",
|
41
|
+
"hover:ring-4 hover:ring-primary hover:ring-opacity-25",
|
42
|
+
"block rounded-full transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50")}
|
43
|
+
|
44
|
+
/>
|
45
|
+
</TooltipPrimitive.Trigger>
|
46
|
+
<TooltipPrimitive.Content side="top"
|
47
|
+
sideOffset={5}
|
48
|
+
className={cls(
|
49
|
+
"TooltipContent",
|
50
|
+
"max-w-lg leading-relaxed",
|
51
|
+
"z-50 rounded px-3 py-2 text-xs leading-none bg-surface-accent-700 dark:bg-surface-accent-800 bg-opacity-90 font-medium text-surface-accent-50 shadow-2xl select-none duration-400 ease-in transform opacity-100",
|
52
|
+
)}>
|
53
|
+
{props.props.value?.[props.index]}
|
54
|
+
</TooltipPrimitive.Content>
|
55
|
+
</TooltipPrimitive.Root>;
|
56
|
+
}
|
57
|
+
|
58
|
+
const Slider = React.forwardRef<
|
59
|
+
React.ElementRef<typeof SliderPrimitive.Root>,
|
60
|
+
SliderProps
|
61
|
+
>(({
|
62
|
+
className,
|
63
|
+
size = "regular",
|
64
|
+
...props
|
65
|
+
}, ref) => {
|
66
|
+
const [hovered, setHovered] = React.useState(false);
|
67
|
+
|
68
|
+
const thumbSizeClasses =
|
69
|
+
size === "small"
|
70
|
+
? "h-4 w-4" // Smaller size for the thumb
|
71
|
+
: "h-6 w-6"; // Default size
|
72
|
+
|
73
|
+
return (
|
74
|
+
<TooltipPrimitive.Provider delayDuration={200}>
|
75
|
+
<SliderPrimitive.Root
|
76
|
+
ref={ref}
|
77
|
+
onMouseEnter={() => setHovered(true)}
|
78
|
+
onMouseLeave={() => setHovered(false)}
|
79
|
+
className={cls(
|
80
|
+
"relative flex w-full touch-none select-none items-center",
|
81
|
+
className
|
82
|
+
)}
|
83
|
+
{...props}
|
84
|
+
>
|
85
|
+
<SliderPrimitive.Track
|
86
|
+
style={{ height: size === "small" ? 4 : 8 }}
|
87
|
+
className={"relative w-full grow overflow-hidden rounded-full bg-surface-accent-300 bg-opacity-40 dark:bg-surface-700 dark:bg-opacity-40"}>
|
88
|
+
|
89
|
+
<SliderPrimitive.Range
|
90
|
+
className={cls("absolute h-full", {
|
91
|
+
"bg-primary": !props.disabled,
|
92
|
+
"bg-surface-accent-300 dark:bg-surface-700": props.disabled,
|
93
|
+
})}
|
94
|
+
/>
|
95
|
+
</SliderPrimitive.Track>
|
96
|
+
|
97
|
+
{(props.value ?? [0]).map((_, index) => <SliderThumb
|
98
|
+
key={index}
|
99
|
+
index={index}
|
100
|
+
props={props}
|
101
|
+
hovered={hovered}
|
102
|
+
classes={thumbSizeClasses}/>)}
|
103
|
+
</SliderPrimitive.Root>
|
104
|
+
</TooltipPrimitive.Provider>
|
105
|
+
);
|
106
|
+
});
|
107
|
+
|
108
|
+
Slider.displayName = "Slider";
|
109
|
+
|
110
|
+
export { Slider };
|
package/src/components/Table.tsx
CHANGED
@@ -1,21 +1,26 @@
|
|
1
|
+
"use client";
|
2
|
+
|
1
3
|
import React, { useRef } from "react";
|
2
4
|
import { defaultBorderMixin } from "../styles";
|
3
|
-
import {
|
5
|
+
import { cls } from "../util";
|
4
6
|
|
5
7
|
export type TableProps = {
|
6
8
|
children: React.ReactNode;
|
7
9
|
className?: string;
|
8
10
|
style?: React.CSSProperties;
|
9
|
-
}
|
11
|
+
} & React.TableHTMLAttributes<HTMLTableElement>;
|
10
12
|
|
11
13
|
export const Table = ({
|
12
14
|
children,
|
13
15
|
className,
|
14
|
-
style
|
16
|
+
style,
|
17
|
+
...rest
|
15
18
|
}: TableProps) => (
|
16
|
-
<table
|
17
|
-
className)}
|
18
|
-
|
19
|
+
<table
|
20
|
+
className={cls("text-left text-surface-800 dark:text-white rounded-md overflow-x-auto", className)}
|
21
|
+
style={style}
|
22
|
+
{...rest}
|
23
|
+
>
|
19
24
|
{children}
|
20
25
|
</table>
|
21
26
|
);
|
@@ -23,13 +28,17 @@ export const Table = ({
|
|
23
28
|
export type TableBodyProps = {
|
24
29
|
children?: React.ReactNode;
|
25
30
|
className?: string;
|
26
|
-
}
|
31
|
+
} & React.HTMLAttributes<HTMLTableSectionElement>;
|
32
|
+
|
27
33
|
export const TableBody = ({
|
28
34
|
children,
|
29
|
-
className
|
35
|
+
className,
|
36
|
+
...rest
|
30
37
|
}: TableBodyProps) => (
|
31
38
|
<tbody
|
32
|
-
className={
|
39
|
+
className={cls("bg-white dark:bg-surface-950 text-sm divide-y divide-surface-100 dark:divide-surface-700 dark:divide-opacity-70", className)}
|
40
|
+
{...rest}
|
41
|
+
>
|
33
42
|
{children}
|
34
43
|
</tbody>
|
35
44
|
);
|
@@ -37,17 +46,22 @@ export const TableBody = ({
|
|
37
46
|
export type TableHeaderProps = {
|
38
47
|
children?: React.ReactNode;
|
39
48
|
className?: string;
|
40
|
-
}
|
49
|
+
} & React.HTMLAttributes<HTMLTableSectionElement>;
|
41
50
|
|
42
51
|
export const TableHeader = ({
|
43
52
|
children,
|
44
|
-
className
|
53
|
+
className,
|
54
|
+
...rest
|
45
55
|
}: TableHeaderProps) => (
|
46
|
-
<thead>
|
47
|
-
<tr
|
48
|
-
|
49
|
-
|
50
|
-
|
56
|
+
<thead {...rest}>
|
57
|
+
<tr
|
58
|
+
className={cls(
|
59
|
+
defaultBorderMixin,
|
60
|
+
"text-sm font-medium text-surface-700 dark:text-surface-accent-300",
|
61
|
+
"bg-surface-accent-50 border-b dark:bg-surface-900",
|
62
|
+
className
|
63
|
+
)}
|
64
|
+
>
|
51
65
|
{children}
|
52
66
|
</tr>
|
53
67
|
</thead>
|
@@ -58,22 +72,24 @@ export type TableRowProps = {
|
|
58
72
|
className?: string;
|
59
73
|
onClick?: React.MouseEventHandler<any>;
|
60
74
|
style?: React.CSSProperties;
|
61
|
-
}
|
75
|
+
} & React.HTMLAttributes<HTMLTableRowElement>;
|
62
76
|
|
63
77
|
export const TableRow = ({
|
64
78
|
children,
|
65
79
|
className,
|
66
80
|
onClick,
|
67
|
-
style
|
81
|
+
style,
|
82
|
+
...rest
|
68
83
|
}: TableRowProps) => (
|
69
84
|
<tr
|
70
85
|
onClick={onClick}
|
71
86
|
style={style}
|
72
|
-
className={
|
73
|
-
"
|
74
|
-
"bg-
|
75
|
-
|
76
|
-
|
87
|
+
className={cls(
|
88
|
+
"bg-white dark:bg-surface-950",
|
89
|
+
onClick ? "hover:bg-surface-accent-100 dark:hover:bg-surface-accent-800 cursor-pointer" : "",
|
90
|
+
className
|
91
|
+
)}
|
92
|
+
{...rest}
|
77
93
|
>
|
78
94
|
{children}
|
79
95
|
</tr>
|
@@ -87,7 +103,7 @@ export type TableCellProps = {
|
|
87
103
|
style?: React.CSSProperties;
|
88
104
|
align?: "left" | "center" | "right";
|
89
105
|
colspan?: number;
|
90
|
-
}
|
106
|
+
} & React.HTMLAttributes<HTMLTableCellElement>;
|
91
107
|
|
92
108
|
export const TableCell = ({
|
93
109
|
children,
|
@@ -96,20 +112,24 @@ export const TableCell = ({
|
|
96
112
|
align,
|
97
113
|
className,
|
98
114
|
style,
|
99
|
-
colspan
|
115
|
+
colspan,
|
116
|
+
...rest
|
100
117
|
}: TableCellProps) => {
|
101
|
-
|
102
118
|
const ref = useRef<HTMLTableCellElement>(null);
|
103
|
-
|
104
119
|
const Tag = header || getParentName(ref.current) === "TableHeader" ? "th" : "td";
|
105
120
|
return (
|
106
|
-
<Tag
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
121
|
+
<Tag
|
122
|
+
scope={scope}
|
123
|
+
colSpan={colspan}
|
124
|
+
ref={ref}
|
125
|
+
style={style}
|
126
|
+
className={cls(
|
127
|
+
"px-4 py-3 text-clip ",
|
128
|
+
align === "center" ? "text-center" : (align === "right" ? "text-right" : "text-left"),
|
129
|
+
className
|
130
|
+
)}
|
131
|
+
{...rest}
|
132
|
+
>
|
113
133
|
{children}
|
114
134
|
</Tag>
|
115
135
|
);
|
@@ -124,7 +144,6 @@ function getParentName(element: HTMLElement | null): string | undefined {
|
|
124
144
|
key.startsWith("__reactInternalInstance$")
|
125
145
|
);
|
126
146
|
});
|
127
|
-
|
128
147
|
// @ts-ignore
|
129
148
|
const domFiber = element[key];
|
130
149
|
// @ts-ignore
|
package/src/components/Tabs.tsx
CHANGED
@@ -1,11 +1,11 @@
|
|
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,
|
8
7
|
children: React.ReactNode,
|
8
|
+
innerClassName?: string,
|
9
9
|
className?: string,
|
10
10
|
onValueChange: (value: string) => void
|
11
11
|
};
|
@@ -14,13 +14,14 @@ export function Tabs({
|
|
14
14
|
value,
|
15
15
|
onValueChange,
|
16
16
|
className,
|
17
|
+
innerClassName,
|
17
18
|
children
|
18
19
|
}: TabsProps) {
|
19
20
|
|
20
|
-
return <TabsPrimitive.Root value={value} onValueChange={onValueChange}>
|
21
|
-
<TabsPrimitive.List className={
|
22
|
-
"flex text-sm font-medium text-center text-
|
23
|
-
|
21
|
+
return <TabsPrimitive.Root value={value} onValueChange={onValueChange} className={className}>
|
22
|
+
<TabsPrimitive.List className={cls(
|
23
|
+
"flex text-sm font-medium text-center text-surface-accent-800 dark:text-white max-w-full overflow-auto no-scrollbar items-end",
|
24
|
+
innerClassName)
|
24
25
|
}>
|
25
26
|
{children}
|
26
27
|
</TabsPrimitive.List>
|
@@ -30,6 +31,7 @@ export function Tabs({
|
|
30
31
|
export type TabProps = {
|
31
32
|
value: string,
|
32
33
|
className?: string,
|
34
|
+
innerClassName?: string,
|
33
35
|
children: React.ReactNode,
|
34
36
|
disabled?: boolean
|
35
37
|
};
|
@@ -37,24 +39,24 @@ export type TabProps = {
|
|
37
39
|
export function Tab({
|
38
40
|
value,
|
39
41
|
className,
|
42
|
+
innerClassName,
|
40
43
|
children,
|
41
44
|
disabled
|
42
45
|
}: TabProps) {
|
43
46
|
return <TabsPrimitive.Trigger value={value}
|
44
47
|
disabled={disabled}
|
45
|
-
className={
|
48
|
+
className={cls(
|
46
49
|
"border-b-2 border-transparent",
|
47
50
|
"data-[state=active]:border-secondary",
|
48
51
|
disabled
|
49
|
-
? "text-
|
50
|
-
:
|
51
|
-
"data-[state=active]:text-
|
52
|
-
"hover:text-
|
53
|
-
// disabled ? "text-slate-400 dark:text-slate-500" : "data-[state=active]:text-primary",
|
54
|
-
// "data-[state=active]:bg-slate-50 data-[state=active]:dark:bg-slate-800",
|
52
|
+
? "text-surface-accent-400 dark:text-surface-accent-500"
|
53
|
+
: cls("text-surface-accent-700 dark:text-surface-accent-300",
|
54
|
+
"data-[state=active]:text-surface-accent-900 data-[state=active]:dark:text-white",
|
55
|
+
"hover:text-surface-accent-800 dark:hover:text-surface-accent-200"),
|
55
56
|
className)}>
|
56
|
-
<div className={
|
57
|
-
"hover:bg-
|
57
|
+
<div className={cls("uppercase inline-block p-2 px-4 m-2 rounded",
|
58
|
+
"hover:bg-surface-accent-200 hover:bg-opacity-75 dark:hover:bg-surface-accent-800",
|
59
|
+
innerClassName)}>
|
58
60
|
{children}
|
59
61
|
</div>
|
60
62
|
</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?: "small" | "medium" | "large",
|
44
44
|
className?: string,
|
45
45
|
style?: React.CSSProperties,
|
46
46
|
inputClassName?: string,
|
@@ -61,7 +61,7 @@ export function TextField<T extends string | number>({
|
|
61
61
|
endAdornment,
|
62
62
|
autoFocus,
|
63
63
|
placeholder,
|
64
|
-
size = "
|
64
|
+
size = "large",
|
65
65
|
className,
|
66
66
|
style,
|
67
67
|
inputClassName,
|
@@ -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,15 +105,13 @@ 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-
|
117
|
-
disabled && "border border-transparent outline-none opacity-50 text-
|
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",
|
114
|
+
disabled && "border border-transparent outline-none opacity-50 text-surface-accent-600 dark:text-surface-accent-500"
|
118
115
|
)}
|
119
116
|
/>
|
120
117
|
: <input
|
@@ -123,16 +120,16 @@ 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 === "
|
128
|
+
size === "small" ? "min-h-[32px]" : (size === "medium" ? "min-h-[48px]" : "min-h-[64px]"),
|
129
|
+
label ? (size === "large" ? "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
|
-
disabled && "border border-transparent outline-none opacity-50 dark:opacity-50 text-
|
132
|
+
disabled && "border border-transparent outline-none opacity-50 dark:opacity-50 text-surface-accent-800 dark:text-white",
|
136
133
|
inputClassName
|
137
134
|
)}
|
138
135
|
placeholder={focused || hasValue || !label ? placeholder : undefined}
|
@@ -146,23 +143,24 @@ 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
|
{
|
155
|
-
"min-h-[
|
156
|
-
"min-h-[
|
152
|
+
"min-h-[32px]": !invisible && size === "small",
|
153
|
+
"min-h-[48px]": !invisible && size === "medium",
|
154
|
+
"min-h-[64px]": !invisible && size === "large"
|
157
155
|
},
|
158
156
|
className)}
|
159
157
|
style={style}>
|
160
158
|
|
161
159
|
{label && (
|
162
160
|
<InputLabel
|
163
|
-
className={
|
161
|
+
className={cls(
|
164
162
|
"pointer-events-none absolute",
|
165
|
-
size === "
|
163
|
+
size === "large" ? "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",
|
167
165
|
disabled ? "opacity-50" : "")}
|
168
166
|
shrink={hasValue || focused}
|
@@ -174,7 +172,11 @@ export function TextField<T extends string | number>({
|
|
174
172
|
{input}
|
175
173
|
|
176
174
|
{endAdornment && <div
|
177
|
-
className="flex flex-row justify-center items-center absolute h-full right-0 top-0
|
175
|
+
className={cls("flex flex-row justify-center items-center absolute h-full right-0 top-0", {
|
176
|
+
"mr-4": size === "large",
|
177
|
+
"mr-3": size === "medium",
|
178
|
+
"mr-2": size === "small"
|
179
|
+
})}>{endAdornment}</div>}
|
178
180
|
|
179
181
|
</div>
|
180
182
|
);
|