@firecms/ui 3.0.0-canary.11 → 3.0.0-canary.110
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 +4 -2
- package/dist/components/Menubar.d.ts +79 -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 +1 -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 +79 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +12979 -13497
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19531 -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 +108 -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 +14 -5
- 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 +42 -31
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +8 -8
- 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 +89 -102
- 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 +1 -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 +79 -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,36 @@
|
|
1
1
|
import * as React from "react"
|
2
2
|
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
3
|
-
import {
|
4
|
-
|
3
|
+
import { cls } from "../util";
|
4
|
+
|
5
|
+
export interface RadioGroupProps {
|
6
|
+
id?: string;
|
7
|
+
children: React.ReactNode;
|
8
|
+
name?: string
|
9
|
+
required?: boolean;
|
10
|
+
disabled?: boolean;
|
11
|
+
/**
|
12
|
+
* Whether keyboard navigation should loop around
|
13
|
+
* @defaultValue false
|
14
|
+
*/
|
15
|
+
loop?: boolean;
|
16
|
+
defaultValue?: string;
|
17
|
+
value?: string;
|
18
|
+
|
19
|
+
onValueChange?(value: string): void;
|
20
|
+
|
21
|
+
className?: string;
|
22
|
+
}
|
5
23
|
|
6
24
|
const RadioGroup = React.forwardRef<
|
7
25
|
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
8
|
-
|
9
|
-
>(({
|
26
|
+
RadioGroupProps
|
27
|
+
>(({
|
28
|
+
className,
|
29
|
+
...props
|
30
|
+
}, ref) => {
|
10
31
|
return (
|
11
32
|
<RadioGroupPrimitive.Root
|
12
|
-
className={
|
33
|
+
className={cls("grid gap-2", className)}
|
13
34
|
{...props}
|
14
35
|
ref={ref}
|
15
36
|
/>
|
@@ -17,21 +38,32 @@ const RadioGroup = React.forwardRef<
|
|
17
38
|
})
|
18
39
|
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
|
19
40
|
|
41
|
+
export interface RadioGroupItemProps {
|
42
|
+
id?: string;
|
43
|
+
value: string;
|
44
|
+
checked?: boolean;
|
45
|
+
required?: boolean;
|
46
|
+
className?: string;
|
47
|
+
disabled?: boolean;
|
48
|
+
}
|
20
49
|
const RadioGroupItem = React.forwardRef<
|
21
50
|
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
22
|
-
|
23
|
-
>(({
|
51
|
+
RadioGroupItemProps
|
52
|
+
>(({
|
53
|
+
className,
|
54
|
+
...props
|
55
|
+
}, ref) => {
|
24
56
|
return (
|
25
57
|
<RadioGroupPrimitive.Item
|
26
58
|
ref={ref}
|
27
|
-
className={
|
59
|
+
className={cls(
|
28
60
|
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
29
61
|
className
|
30
62
|
)}
|
31
63
|
{...props}
|
32
64
|
>
|
33
65
|
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
34
|
-
<div className="h-2.5 w-2.5 fill-current text-current bg-primary rounded-lg"
|
66
|
+
<div className="h-2.5 w-2.5 fill-current text-current bg-primary rounded-lg"/>
|
35
67
|
</RadioGroupPrimitive.Indicator>
|
36
68
|
</RadioGroupPrimitive.Item>
|
37
69
|
)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
2
2
|
|
3
|
-
import { defaultBorderMixin
|
3
|
+
import { defaultBorderMixin } from "../styles";
|
4
4
|
import { CircularProgress, IconButton } from "./index";
|
5
5
|
import { ClearIcon, SearchIcon } from "../icons";
|
6
|
-
import {
|
7
|
-
import { useDebounceValue } from "../
|
6
|
+
import { cls } from "../util";
|
7
|
+
import { useDebounceValue } from "../hooks";
|
8
8
|
|
9
9
|
interface SearchBarProps {
|
10
10
|
onClick?: () => void;
|
@@ -60,14 +60,14 @@ export function SearchBar({
|
|
60
60
|
return (
|
61
61
|
<div
|
62
62
|
onClick={onClick}
|
63
|
-
className={
|
63
|
+
className={cls("relative",
|
64
64
|
large ? "h-14" : "h-[42px]",
|
65
|
-
"bg-slate-50 dark:bg-gray-800
|
65
|
+
"bg-slate-50 dark:bg-gray-800 border",
|
66
66
|
defaultBorderMixin,
|
67
67
|
"rounded",
|
68
68
|
className)}>
|
69
69
|
<div
|
70
|
-
className="absolute p-0 px-4 h-full
|
70
|
+
className="absolute p-0 px-4 h-full pointer-events-none flex items-center justify-center top-0">
|
71
71
|
{loading ? <CircularProgress size={"small"}/> : <SearchIcon className={"text-slate-500 dark:text-gray-500"}/>}
|
72
72
|
</div>
|
73
73
|
<input
|
@@ -84,12 +84,11 @@ export function SearchBar({
|
|
84
84
|
autoFocus={autoFocus}
|
85
85
|
onFocus={() => setActive(true)}
|
86
86
|
onBlur={() => setActive(false)}
|
87
|
-
className={
|
87
|
+
className={cls(
|
88
88
|
(disabled || loading) && "pointer-events-none",
|
89
89
|
"relative flex items-center rounded transition-all bg-transparent outline-none appearance-none border-none",
|
90
90
|
"pl-12 h-full text-current ",
|
91
91
|
expandable ? (active ? "w-[220px]" : "w-[180px]") : "",
|
92
|
-
focusedMixin,
|
93
92
|
innerClassName
|
94
93
|
)}
|
95
94
|
/>
|
@@ -1,15 +1,13 @@
|
|
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 {
|
5
4
|
fieldBackgroundDisabledMixin,
|
6
5
|
fieldBackgroundHoverMixin,
|
7
6
|
fieldBackgroundInvisibleMixin,
|
8
|
-
fieldBackgroundMixin
|
9
|
-
focusedMixin
|
7
|
+
fieldBackgroundMixin
|
10
8
|
} from "../styles";
|
11
9
|
import { CheckIcon, ExpandMoreIcon } from "../icons";
|
12
|
-
import {
|
10
|
+
import { cls } from "../util";
|
13
11
|
import { SelectInputLabel } from "./common/SelectInputLabel";
|
14
12
|
|
15
13
|
export type SelectProps = {
|
@@ -20,14 +18,14 @@ export type SelectProps = {
|
|
20
18
|
value?: string | string[],
|
21
19
|
className?: string,
|
22
20
|
inputClassName?: string,
|
23
|
-
onChange?: React.EventHandler<
|
21
|
+
onChange?: React.EventHandler<ChangeEvent<HTMLSelectElement>>,
|
24
22
|
onValueChange?: (updatedValue: string) => void,
|
25
23
|
onMultiValueChange?: (updatedValue: string[]) => void,
|
26
24
|
placeholder?: React.ReactNode,
|
27
25
|
renderValue?: (value: string, index: number) => React.ReactNode,
|
28
26
|
renderValues?: (values: string[]) => React.ReactNode,
|
29
27
|
size?: "small" | "medium",
|
30
|
-
label?: React.ReactNode,
|
28
|
+
label?: React.ReactNode | string,
|
31
29
|
disabled?: boolean,
|
32
30
|
error?: boolean,
|
33
31
|
position?: "item-aligned" | "popper",
|
@@ -40,41 +38,42 @@ export type SelectProps = {
|
|
40
38
|
children?: React.ReactNode
|
41
39
|
};
|
42
40
|
|
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
|
-
|
41
|
+
export const Select = forwardRef<HTMLDivElement, SelectProps>(({
|
42
|
+
inputRef,
|
43
|
+
open,
|
44
|
+
name,
|
45
|
+
id,
|
46
|
+
onOpenChange,
|
47
|
+
value,
|
48
|
+
onChange,
|
49
|
+
onValueChange,
|
50
|
+
onMultiValueChange,
|
51
|
+
className,
|
52
|
+
inputClassName,
|
53
|
+
placeholder,
|
54
|
+
renderValue,
|
55
|
+
renderValues,
|
56
|
+
label,
|
57
|
+
size = "medium",
|
58
|
+
includeFocusOutline = true,
|
59
|
+
error,
|
60
|
+
disabled,
|
61
|
+
padding = true,
|
62
|
+
position = "item-aligned",
|
63
|
+
endAdornment,
|
64
|
+
multiple,
|
65
|
+
invisible,
|
66
|
+
children,
|
67
|
+
...props
|
68
|
+
}, ref) => {
|
69
|
+
|
70
|
+
const [openInternal, setOpenInternal] = useState(false);
|
71
71
|
|
72
|
-
const [openInternal, setOpenInternal] = React.useState(false);
|
73
72
|
useEffect(() => {
|
74
73
|
setOpenInternal(open ?? false);
|
75
74
|
}, [open]);
|
76
75
|
|
77
|
-
const onValueChangeInternal =
|
76
|
+
const onValueChangeInternal = useCallback((newValue: string) => {
|
78
77
|
if (multiple) {
|
79
78
|
if (Array.isArray(value) && value.includes(newValue)) {
|
80
79
|
onMultiValueChange?.(value.filter(v => v !== newValue));
|
@@ -90,11 +89,13 @@ export function Select({
|
|
90
89
|
name,
|
91
90
|
value: newValue
|
92
91
|
}
|
93
|
-
} as
|
92
|
+
} as ChangeEvent<HTMLSelectElement>;
|
94
93
|
onChange(event);
|
95
94
|
}
|
96
95
|
}, [multiple, onChange, value, onMultiValueChange, onValueChange]);
|
97
96
|
|
97
|
+
const hasValue = Array.isArray(value) ? value.length > 0 : value != null;
|
98
|
+
|
98
99
|
return (
|
99
100
|
<SelectPrimitive.Root
|
100
101
|
name={name}
|
@@ -107,23 +108,22 @@ export function Select({
|
|
107
108
|
onOpenChange?.(open);
|
108
109
|
setOpenInternal(open);
|
109
110
|
}}
|
110
|
-
{...props}
|
111
|
-
|
111
|
+
{...props}
|
112
|
+
>
|
112
113
|
{typeof label === "string" ? <SelectInputLabel error={error}>{label}</SelectInputLabel> : label}
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
114
|
+
<div className={cls(
|
115
|
+
size === "small" ? "min-h-[42px]" : "min-h-[64px]",
|
116
|
+
"select-none rounded-md text-sm",
|
117
|
+
invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,
|
118
|
+
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
119
|
+
"relative flex items-center",
|
120
|
+
className
|
121
|
+
)}
|
122
|
+
>
|
123
123
|
<SelectPrimitive.Trigger
|
124
124
|
ref={inputRef}
|
125
125
|
id={id}
|
126
|
-
className={
|
126
|
+
className={cls(
|
127
127
|
"w-full h-full",
|
128
128
|
size === "small" ? "h-[42px]" : "h-[64px]",
|
129
129
|
padding ? "px-4 " : "",
|
@@ -133,65 +133,53 @@ export function Select({
|
|
133
133
|
error ? "border border-red-500 dark:border-red-600" : "",
|
134
134
|
disabled ? "text-slate-600 dark:text-slate-400" : "text-slate-800 dark:text-white",
|
135
135
|
"relative flex items-center",
|
136
|
-
includeFocusOutline ? focusedMixin : "",
|
137
136
|
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>
|
137
|
+
)}
|
138
|
+
>
|
139
|
+
<div
|
140
|
+
ref={ref}
|
141
|
+
className={cls(
|
142
|
+
"flex-grow w-full max-w-full flex flex-row gap-2 items-center",
|
143
|
+
"overflow-visible",
|
144
|
+
size === "small" ? "h-[42px]" : "h-[64px]"
|
145
|
+
)}
|
146
|
+
>
|
147
|
+
<SelectPrimitive.Value placeholder={placeholder} className={"w-full"}>
|
148
|
+
{renderValue && (hasValue && Array.isArray(value) ? value.map((v, i) => (
|
149
|
+
<div key={v} className={"flex items-center gap-1 max-w-full"}>
|
150
|
+
{renderValue ? renderValue(v, i) : v}
|
151
|
+
</div>
|
152
|
+
)) : (typeof value === "string" ? (renderValue ? renderValue(value, 0) : value) : placeholder))}
|
153
|
+
{renderValues && (!hasValue || Array.isArray(value)) ? renderValues(value as string[] ?? []) : null}
|
154
|
+
{!renderValue && !renderValues && hasValue}
|
155
|
+
</SelectPrimitive.Value>
|
161
156
|
</div>
|
162
|
-
|
163
|
-
|
164
|
-
"px-2 h-full flex items-center",
|
165
|
-
)}>
|
166
|
-
<ExpandMoreIcon size={"small"}
|
167
|
-
className={cn("transition", open ? "rotate-180" : "")}/>
|
157
|
+
<SelectPrimitive.Icon className={cls("px-2 h-full flex items-center")}>
|
158
|
+
<ExpandMoreIcon size={"small"} className={cls("transition", open ? "rotate-180" : "")}/>
|
168
159
|
</SelectPrimitive.Icon>
|
169
|
-
|
170
160
|
</SelectPrimitive.Trigger>
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
161
|
+
{endAdornment && (
|
162
|
+
<div
|
163
|
+
className={cls("absolute h-full flex items-center", size === "small" ? "right-10" : "right-14")}
|
164
|
+
onClick={(e) => e.stopPropagation()}>
|
165
|
+
{endAdornment}
|
166
|
+
</div>
|
167
|
+
)}
|
178
168
|
</div>
|
179
169
|
<SelectPrimitive.Portal>
|
180
|
-
<SelectPrimitive.Content
|
181
|
-
|
182
|
-
className="
|
183
|
-
|
184
|
-
className={"p-1"}
|
185
|
-
style={{
|
186
|
-
maxHeight: "var(--radix-select-content-available-height)"
|
187
|
-
}}>
|
170
|
+
<SelectPrimitive.Content position={position}
|
171
|
+
className="z-50 relative overflow-hidden border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-800 p-2 rounded-lg shadow-lg">
|
172
|
+
<SelectPrimitive.Viewport className={"p-1"}
|
173
|
+
style={{ maxHeight: "var(--radix-select-content-available-height)" }}>
|
188
174
|
{children}
|
189
175
|
</SelectPrimitive.Viewport>
|
190
176
|
</SelectPrimitive.Content>
|
191
177
|
</SelectPrimitive.Portal>
|
192
178
|
</SelectPrimitive.Root>
|
193
179
|
);
|
194
|
-
}
|
180
|
+
});
|
181
|
+
|
182
|
+
Select.displayName = "Select";
|
195
183
|
|
196
184
|
export type SelectItemProps = {
|
197
185
|
value: string,
|
@@ -214,10 +202,9 @@ export function SelectItem({
|
|
214
202
|
e.preventDefault();
|
215
203
|
e.stopPropagation();
|
216
204
|
}}
|
217
|
-
className={
|
205
|
+
className={cls(
|
218
206
|
"w-full",
|
219
|
-
"relative
|
220
|
-
focusedMixin,
|
207
|
+
"relative flex items-center p-2 rounded-md text-sm text-slate-700 dark:text-slate-300",
|
221
208
|
"focus:z-10",
|
222
209
|
"data-[state=checked]:bg-slate-100 data-[state=checked]:dark:bg-slate-900 focus:bg-slate-100 dark:focus:bg-slate-950",
|
223
210
|
"data-[state=checked]:focus:bg-slate-200 data-[state=checked]:dark:focus:bg-slate-950",
|
@@ -248,7 +235,7 @@ export function SelectGroup({
|
|
248
235
|
}: SelectGroupProps) {
|
249
236
|
return <>
|
250
237
|
<SelectPrimitive.Group
|
251
|
-
className={
|
238
|
+
className={cls(
|
252
239
|
"text-xs text-slate-900 dark:text-white uppercase tracking-wider font-bold mt-6 first:mt-2",
|
253
240
|
"px-2 py-2",
|
254
241
|
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
|
}/>;
|