@firecms/ui 3.0.0-canary.12 → 3.0.0-canary.120
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 +3 -2
- package/dist/components/Chip.d.ts +3 -2
- package/dist/components/DateTimeField.d.ts +3 -4
- package/dist/components/Dialog.d.ts +4 -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 +1 -4
- package/dist/components/NewMultiSelect.d.ts +60 -0
- package/dist/components/Popover.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +26 -3
- package/dist/components/Select.d.ts +4 -4
- package/dist/components/Sheet.d.ts +4 -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 +5 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useLocaleConfig.d.ts +1 -0
- package/dist/icons/Icon.d.ts +3 -3
- package/dist/index.css +77 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +13290 -13511
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19828 -49
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +7 -7
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +109 -118
- package/src/components/Alert.tsx +2 -2
- package/src/components/Autocomplete.tsx +4 -3
- package/src/components/Avatar.tsx +7 -6
- package/src/components/Badge.tsx +1 -1
- package/src/components/BooleanSwitch.tsx +15 -15
- package/src/components/BooleanSwitchWithLabel.tsx +8 -8
- package/src/components/Button.tsx +11 -13
- package/src/components/Card.tsx +3 -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 +3 -2
- package/src/components/Container.tsx +2 -2
- package/src/components/DateTimeField.tsx +38 -48
- package/src/components/Dialog.tsx +15 -6
- package/src/components/DialogActions.tsx +2 -2
- package/src/components/DialogContent.tsx +2 -2
- package/src/components/ExpandablePanel.tsx +10 -8
- package/src/components/FileUpload.tsx +6 -9
- package/src/components/IconButton.tsx +4 -6
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +12 -9
- package/src/components/Label.tsx +17 -4
- package/src/components/Markdown.tsx +14 -3
- package/src/components/Menu.tsx +49 -31
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +12 -14
- package/src/components/NewMultiSelect.tsx +370 -0
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +17 -14
- package/src/components/RadioGroup.tsx +41 -9
- package/src/components/SearchBar.tsx +7 -8
- package/src/components/Select.tsx +92 -104
- package/src/components/Sheet.tsx +45 -28
- package/src/components/Skeleton.tsx +9 -6
- package/src/components/Table.tsx +50 -32
- package/src/components/Tabs.tsx +6 -7
- package/src/components/TextField.tsx +10 -13
- package/src/components/TextareaAutosize.tsx +3 -3
- package/src/components/Tooltip.tsx +27 -13
- package/src/components/Typography.tsx +34 -19
- package/src/components/common/SelectInputLabel.tsx +2 -2
- package/src/components/index.tsx +2 -1
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useLocaleConfig.tsx +18 -0
- package/src/icons/Icon.tsx +46 -43
- package/src/icons/icon_keys.ts +114 -1301
- package/src/index.css +77 -0
- package/src/index.ts +1 -0
- package/src/scripts/generateIconKeys.ts +20 -11
- package/src/styles.ts +7 -7
- 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,15 +1,14 @@
|
|
1
|
-
import React, { useEffect } from "react";
|
2
|
-
|
1
|
+
import React, { ChangeEvent, forwardRef, useCallback, useEffect, useState } from "react";
|
3
2
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
4
3
|
import {
|
4
|
+
defaultBorderMixin,
|
5
5
|
fieldBackgroundDisabledMixin,
|
6
6
|
fieldBackgroundHoverMixin,
|
7
7
|
fieldBackgroundInvisibleMixin,
|
8
|
-
fieldBackgroundMixin
|
9
|
-
focusedMixin
|
8
|
+
fieldBackgroundMixin
|
10
9
|
} from "../styles";
|
11
10
|
import { CheckIcon, ExpandMoreIcon } from "../icons";
|
12
|
-
import {
|
11
|
+
import { cls } from "../util";
|
13
12
|
import { SelectInputLabel } from "./common/SelectInputLabel";
|
14
13
|
|
15
14
|
export type SelectProps = {
|
@@ -20,14 +19,14 @@ export type SelectProps = {
|
|
20
19
|
value?: string | string[],
|
21
20
|
className?: string,
|
22
21
|
inputClassName?: string,
|
23
|
-
onChange?: React.EventHandler<
|
22
|
+
onChange?: React.EventHandler<ChangeEvent<HTMLSelectElement>>,
|
24
23
|
onValueChange?: (updatedValue: string) => void,
|
25
24
|
onMultiValueChange?: (updatedValue: string[]) => void,
|
26
25
|
placeholder?: React.ReactNode,
|
27
26
|
renderValue?: (value: string, index: number) => React.ReactNode,
|
28
27
|
renderValues?: (values: string[]) => React.ReactNode,
|
29
28
|
size?: "small" | "medium",
|
30
|
-
label?: React.ReactNode,
|
29
|
+
label?: React.ReactNode | string,
|
31
30
|
disabled?: boolean,
|
32
31
|
error?: boolean,
|
33
32
|
position?: "item-aligned" | "popper",
|
@@ -40,41 +39,42 @@ export type SelectProps = {
|
|
40
39
|
children?: React.ReactNode
|
41
40
|
};
|
42
41
|
|
43
|
-
export
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
42
|
+
export const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
43
|
+
inputRef,
|
44
|
+
open,
|
45
|
+
name,
|
46
|
+
id,
|
47
|
+
onOpenChange,
|
48
|
+
value,
|
49
|
+
onChange,
|
50
|
+
onValueChange,
|
51
|
+
onMultiValueChange,
|
52
|
+
className,
|
53
|
+
inputClassName,
|
54
|
+
placeholder,
|
55
|
+
renderValue,
|
56
|
+
renderValues,
|
57
|
+
label,
|
58
|
+
size = "medium",
|
59
|
+
includeFocusOutline = true,
|
60
|
+
error,
|
61
|
+
disabled,
|
62
|
+
padding = true,
|
63
|
+
position = "item-aligned",
|
64
|
+
endAdornment,
|
65
|
+
multiple,
|
66
|
+
invisible,
|
67
|
+
children,
|
68
|
+
...props
|
69
|
+
}, ref) => {
|
70
|
+
|
71
|
+
const [openInternal, setOpenInternal] = useState(false);
|
71
72
|
|
72
|
-
const [openInternal, setOpenInternal] = React.useState(false);
|
73
73
|
useEffect(() => {
|
74
74
|
setOpenInternal(open ?? false);
|
75
75
|
}, [open]);
|
76
76
|
|
77
|
-
const onValueChangeInternal =
|
77
|
+
const onValueChangeInternal = useCallback((newValue: string) => {
|
78
78
|
if (multiple) {
|
79
79
|
if (Array.isArray(value) && value.includes(newValue)) {
|
80
80
|
onMultiValueChange?.(value.filter(v => v !== newValue));
|
@@ -90,11 +90,13 @@ export function Select({
|
|
90
90
|
name,
|
91
91
|
value: newValue
|
92
92
|
}
|
93
|
-
} as
|
93
|
+
} as ChangeEvent<HTMLSelectElement>;
|
94
94
|
onChange(event);
|
95
95
|
}
|
96
96
|
}, [multiple, onChange, value, onMultiValueChange, onValueChange]);
|
97
97
|
|
98
|
+
const hasValue = Array.isArray(value) ? value.length > 0 : value != null;
|
99
|
+
|
98
100
|
return (
|
99
101
|
<SelectPrimitive.Root
|
100
102
|
name={name}
|
@@ -107,23 +109,22 @@ export function Select({
|
|
107
109
|
onOpenChange?.(open);
|
108
110
|
setOpenInternal(open);
|
109
111
|
}}
|
110
|
-
{...props}
|
111
|
-
|
112
|
+
{...props}
|
113
|
+
>
|
112
114
|
{typeof label === "string" ? <SelectInputLabel error={error}>{label}</SelectInputLabel> : label}
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
115
|
+
<div className={cls(
|
116
|
+
size === "small" ? "min-h-[42px]" : "min-h-[64px]",
|
117
|
+
"select-none rounded-md text-sm",
|
118
|
+
invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,
|
119
|
+
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
120
|
+
"relative flex items-center",
|
121
|
+
className
|
122
|
+
)}
|
123
|
+
>
|
123
124
|
<SelectPrimitive.Trigger
|
124
125
|
ref={inputRef}
|
125
126
|
id={id}
|
126
|
-
className={
|
127
|
+
className={cls(
|
127
128
|
"w-full h-full",
|
128
129
|
size === "small" ? "h-[42px]" : "h-[64px]",
|
129
130
|
padding ? "px-4 " : "",
|
@@ -133,65 +134,53 @@ export function Select({
|
|
133
134
|
error ? "border border-red-500 dark:border-red-600" : "",
|
134
135
|
disabled ? "text-slate-600 dark:text-slate-400" : "text-slate-800 dark:text-white",
|
135
136
|
"relative flex items-center",
|
136
|
-
includeFocusOutline ? focusedMixin : "",
|
137
137
|
inputClassName
|
138
|
-
)}
|
139
|
-
|
140
|
-
<div
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
{!renderValue && !renderValues && value}
|
159
|
-
|
160
|
-
</SelectPrimitive.Value>
|
138
|
+
)}
|
139
|
+
>
|
140
|
+
<div
|
141
|
+
ref={ref}
|
142
|
+
className={cls(
|
143
|
+
"flex-grow w-full max-w-full flex flex-row gap-2 items-center",
|
144
|
+
"overflow-visible",
|
145
|
+
size === "small" ? "h-[42px]" : "h-[64px]"
|
146
|
+
)}
|
147
|
+
>
|
148
|
+
<SelectPrimitive.Value placeholder={placeholder} className={"w-full"}>
|
149
|
+
{renderValue && (hasValue && Array.isArray(value) ? value.map((v, i) => (
|
150
|
+
<div key={v} className={"flex items-center gap-1 max-w-full"}>
|
151
|
+
{renderValue ? renderValue(v, i) : v}
|
152
|
+
</div>
|
153
|
+
)) : (typeof value === "string" ? (renderValue ? renderValue(value, 0) : value) : placeholder))}
|
154
|
+
{renderValues && (!hasValue || Array.isArray(value)) ? renderValues(value as string[] ?? []) : null}
|
155
|
+
{!renderValue && !renderValues && hasValue}
|
156
|
+
</SelectPrimitive.Value>
|
161
157
|
</div>
|
162
|
-
|
163
|
-
|
164
|
-
"px-2 h-full flex items-center",
|
165
|
-
)}>
|
166
|
-
<ExpandMoreIcon size={"small"}
|
167
|
-
className={cn("transition", open ? "rotate-180" : "")}/>
|
158
|
+
<SelectPrimitive.Icon className={cls("px-2 h-full flex items-center")}>
|
159
|
+
<ExpandMoreIcon size={"small"} className={cls("transition", open ? "rotate-180" : "")}/>
|
168
160
|
</SelectPrimitive.Icon>
|
169
|
-
|
170
161
|
</SelectPrimitive.Trigger>
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
162
|
+
{endAdornment && (
|
163
|
+
<div
|
164
|
+
className={cls("absolute h-full flex items-center", size === "small" ? "right-10" : "right-14")}
|
165
|
+
onClick={(e) => e.stopPropagation()}>
|
166
|
+
{endAdornment}
|
167
|
+
</div>
|
168
|
+
)}
|
178
169
|
</div>
|
179
170
|
<SelectPrimitive.Portal>
|
180
|
-
<SelectPrimitive.Content
|
181
|
-
|
182
|
-
className="
|
183
|
-
|
184
|
-
className={"p-1"}
|
185
|
-
style={{
|
186
|
-
maxHeight: "var(--radix-select-content-available-height)"
|
187
|
-
}}>
|
171
|
+
<SelectPrimitive.Content position={position}
|
172
|
+
className={cls("z-50 relative overflow-hidden border bg-white dark:bg-gray-900 p-2 rounded-lg", defaultBorderMixin)}>
|
173
|
+
<SelectPrimitive.Viewport className={"p-1"}
|
174
|
+
style={{ maxHeight: "var(--radix-select-content-available-height)" }}>
|
188
175
|
{children}
|
189
176
|
</SelectPrimitive.Viewport>
|
190
177
|
</SelectPrimitive.Content>
|
191
178
|
</SelectPrimitive.Portal>
|
192
179
|
</SelectPrimitive.Root>
|
193
180
|
);
|
194
|
-
}
|
181
|
+
});
|
182
|
+
|
183
|
+
Select.displayName = "Select";
|
195
184
|
|
196
185
|
export type SelectItemProps = {
|
197
186
|
value: string,
|
@@ -214,13 +203,12 @@ export function SelectItem({
|
|
214
203
|
e.preventDefault();
|
215
204
|
e.stopPropagation();
|
216
205
|
}}
|
217
|
-
className={
|
206
|
+
className={cls(
|
218
207
|
"w-full",
|
219
|
-
"relative
|
220
|
-
focusedMixin,
|
208
|
+
"relative flex items-center p-2 rounded-md text-sm text-slate-700 dark:text-slate-300",
|
221
209
|
"focus:z-10",
|
222
|
-
"data-[state=checked]:bg-slate-100 data-[state=checked]:dark:bg-slate-
|
223
|
-
"data-[state=checked]:focus:bg-slate-200 data-[state=checked]:dark:focus:bg-
|
210
|
+
"data-[state=checked]:bg-slate-100 data-[state=checked]:dark:bg-slate-800 focus:bg-slate-100 dark:focus:bg-gray-950",
|
211
|
+
"data-[state=checked]:focus:bg-slate-200 data-[state=checked]:dark:focus:bg-gray-950",
|
224
212
|
disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer",
|
225
213
|
"[&>*]:w-full",
|
226
214
|
"overflow-visible",
|
@@ -248,7 +236,7 @@ export function SelectGroup({
|
|
248
236
|
}: SelectGroupProps) {
|
249
237
|
return <>
|
250
238
|
<SelectPrimitive.Group
|
251
|
-
className={
|
239
|
+
className={cls(
|
252
240
|
"text-xs text-slate-900 dark:text-white uppercase tracking-wider font-bold mt-6 first:mt-2",
|
253
241
|
"px-2 py-2",
|
254
242
|
className
|
package/src/components/Sheet.tsx
CHANGED
@@ -1,37 +1,38 @@
|
|
1
|
-
import React, { useEffect } from "react";
|
1
|
+
import React, { useEffect, useState } from "react";
|
2
|
+
import { cls } from "../util";
|
3
|
+
import { defaultBorderMixin } from "../styles";
|
2
4
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
3
|
-
import { cn } from "../util";
|
4
5
|
|
5
6
|
interface SheetProps {
|
6
7
|
children: React.ReactNode;
|
7
8
|
open: boolean;
|
9
|
+
title?: string;
|
8
10
|
side?: "top" | "bottom" | "left" | "right";
|
11
|
+
darkBackground?: boolean;
|
9
12
|
transparent?: boolean;
|
10
13
|
onOpenChange?: (open: boolean) => void;
|
14
|
+
className?: string;
|
15
|
+
overlayClassName?: string;
|
11
16
|
}
|
12
17
|
|
13
18
|
export const Sheet: React.FC<SheetProps> = ({
|
14
19
|
children,
|
15
20
|
side = "right",
|
21
|
+
title,
|
16
22
|
open,
|
17
23
|
onOpenChange,
|
18
24
|
transparent,
|
25
|
+
className,
|
26
|
+
overlayClassName,
|
19
27
|
...props
|
20
28
|
}) => {
|
21
|
-
|
22
|
-
const [displayed, setDisplayed] = React.useState(false);
|
29
|
+
const [displayed, setDisplayed] = useState(false);
|
23
30
|
|
24
31
|
useEffect(() => {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
return () => clearTimeout(timeout);
|
30
|
-
} else {
|
31
|
-
setDisplayed(true);
|
32
|
-
return () => {
|
33
|
-
};
|
34
|
-
}
|
32
|
+
const timeout = setTimeout(() => {
|
33
|
+
setDisplayed(open);
|
34
|
+
}, 1);
|
35
|
+
return () => clearTimeout(timeout);
|
35
36
|
}, [open]);
|
36
37
|
|
37
38
|
const transformValue: Record<string, string> = {
|
@@ -41,36 +42,52 @@ export const Sheet: React.FC<SheetProps> = ({
|
|
41
42
|
right: "translate-x-full"
|
42
43
|
};
|
43
44
|
|
44
|
-
|
45
|
+
const borderClass: Record<string, string> = {
|
46
|
+
top: "border-b",
|
47
|
+
bottom: "border-t",
|
48
|
+
left: "border-r",
|
49
|
+
right: "border-l"
|
50
|
+
};
|
45
51
|
|
52
|
+
return (
|
46
53
|
<DialogPrimitive.Root open={displayed || open}
|
47
54
|
onOpenChange={onOpenChange}>
|
48
55
|
<DialogPrimitive.Portal>
|
56
|
+
<DialogPrimitive.Title>
|
57
|
+
{title ?? "Sheet"}
|
58
|
+
</DialogPrimitive.Title>
|
49
59
|
<DialogPrimitive.Overlay
|
50
|
-
className={
|
51
|
-
"fixed inset-0 transition-opacity z-20 ease-in-out duration-
|
52
|
-
|
53
|
-
"dark:bg-
|
54
|
-
displayed && open ? "opacity-100" : "opacity-0"
|
60
|
+
className={cls(
|
61
|
+
"fixed inset-0 transition-opacity z-20 ease-in-out duration-100 backdrop-blur-sm",
|
62
|
+
"bg-black bg-opacity-50",
|
63
|
+
"dark:bg-gray-900 dark:bg-opacity-60",
|
64
|
+
displayed && open ? "opacity-100" : "opacity-0",
|
65
|
+
overlayClassName
|
55
66
|
)}
|
56
67
|
style={{
|
57
|
-
pointerEvents: displayed ? "auto" : "none"
|
68
|
+
pointerEvents: displayed ? "auto" : "none"
|
58
69
|
}}
|
70
|
+
onClick={() => onOpenChange && onOpenChange(false)}
|
59
71
|
/>
|
60
72
|
<DialogPrimitive.Content
|
61
73
|
{...props}
|
62
|
-
|
63
|
-
|
74
|
+
onFocusCapture={(event) => event.preventDefault()}
|
75
|
+
className={cls(
|
76
|
+
borderClass[side],
|
77
|
+
defaultBorderMixin,
|
78
|
+
"transform-gpu",
|
64
79
|
"will-change-transform",
|
65
80
|
"text-slate-900 dark:text-white",
|
66
|
-
"fixed transform z-20 transition-all
|
81
|
+
"fixed transform z-20 transition-all ease-in-out",
|
82
|
+
!displayed ? "duration-150" : "duration-100",
|
67
83
|
"outline-none focus:outline-none",
|
68
|
-
|
84
|
+
transparent ? "" : "shadow-md bg-white dark:bg-gray-950",
|
69
85
|
side === "top" || side === "bottom" ? "w-full" : "h-full",
|
70
86
|
side === "left" || side === "top" ? "left-0 top-0" : "right-0 bottom-0",
|
71
|
-
displayed && open ? "opacity-100" : "opacity-
|
72
|
-
!displayed || !open ? transformValue[side] : ""
|
73
|
-
|
87
|
+
displayed && open ? "opacity-100" : "opacity-50",
|
88
|
+
!displayed || !open ? transformValue[side] : "",
|
89
|
+
className
|
90
|
+
)}
|
74
91
|
>
|
75
92
|
{children}
|
76
93
|
</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-slate-200 dark:bg-slate-800 rounded",
|
23
|
+
"bg-slate-200 dark:bg-slate-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
|
}/>;
|
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-slate-200 dark:divide-gray-700", 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,25 @@ 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={
|
85
|
+
className={cls(
|
73
86
|
"divide-slate-100 dark:divide-gray-800",
|
74
87
|
"bg-white dark:bg-gray-950",
|
75
88
|
onClick ? "hover:bg-slate-100 dark:hover:bg-gray-800 cursor-pointer" : "",
|
76
|
-
className
|
89
|
+
className
|
90
|
+
)}
|
91
|
+
{...rest}
|
77
92
|
>
|
78
93
|
{children}
|
79
94
|
</tr>
|
@@ -87,7 +102,7 @@ export type TableCellProps = {
|
|
87
102
|
style?: React.CSSProperties;
|
88
103
|
align?: "left" | "center" | "right";
|
89
104
|
colspan?: number;
|
90
|
-
}
|
105
|
+
} & React.HTMLAttributes<HTMLTableCellElement>;
|
91
106
|
|
92
107
|
export const TableCell = ({
|
93
108
|
children,
|
@@ -96,20 +111,24 @@ export const TableCell = ({
|
|
96
111
|
align,
|
97
112
|
className,
|
98
113
|
style,
|
99
|
-
colspan
|
114
|
+
colspan,
|
115
|
+
...rest
|
100
116
|
}: TableCellProps) => {
|
101
|
-
|
102
117
|
const ref = useRef<HTMLTableCellElement>(null);
|
103
|
-
|
104
118
|
const Tag = header || getParentName(ref.current) === "TableHeader" ? "th" : "td";
|
105
119
|
return (
|
106
|
-
<Tag
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
120
|
+
<Tag
|
121
|
+
scope={scope}
|
122
|
+
colSpan={colspan}
|
123
|
+
ref={ref}
|
124
|
+
style={style}
|
125
|
+
className={cls(
|
126
|
+
"px-4 py-3 text-clip ",
|
127
|
+
align === "center" ? "text-center" : (align === "right" ? "text-right" : "text-left"),
|
128
|
+
className
|
129
|
+
)}
|
130
|
+
{...rest}
|
131
|
+
>
|
113
132
|
{children}
|
114
133
|
</Tag>
|
115
134
|
);
|
@@ -124,7 +143,6 @@ function getParentName(element: HTMLElement | null): string | undefined {
|
|
124
143
|
key.startsWith("__reactInternalInstance$")
|
125
144
|
);
|
126
145
|
});
|
127
|
-
|
128
146
|
// @ts-ignore
|
129
147
|
const domFiber = element[key];
|
130
148
|
// @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>;
|