@firecms/ui 3.0.0-canary.8 → 3.0.0-canary.80
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 +4 -3
- package/dist/components/DateTimeField.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 +2 -1
- package/dist/components/Menubar.d.ts +69 -0
- package/dist/components/RadioGroup.d.ts +25 -3
- package/dist/components/Select.d.ts +1 -1
- package/dist/components/TextField.d.ts +1 -1
- package/dist/components/TextareaAutosize.d.ts +3 -34
- 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 +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +8362 -8066
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10 -10
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +6 -6
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +39 -49
- package/src/components/Alert.tsx +2 -2
- package/src/components/Autocomplete.tsx +4 -3
- package/src/components/Avatar.tsx +7 -4
- package/src/components/Badge.tsx +1 -1
- package/src/components/BooleanSwitch.tsx +9 -9
- package/src/components/BooleanSwitchWithLabel.tsx +5 -5
- package/src/components/Button.tsx +7 -7
- package/src/components/Card.tsx +2 -2
- package/src/components/CenteredView.tsx +25 -15
- package/src/components/Checkbox.tsx +31 -24
- package/src/components/Chip.tsx +2 -2
- 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 +10 -9
- package/src/components/Dialog.tsx +4 -4
- package/src/components/DialogActions.tsx +2 -2
- package/src/components/DialogContent.tsx +2 -2
- package/src/components/ExpandablePanel.tsx +8 -6
- package/src/components/FileUpload.tsx +5 -7
- package/src/components/IconButton.tsx +3 -3
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +10 -9
- package/src/components/Label.tsx +17 -4
- package/src/components/Markdown.tsx +14 -3
- package/src/components/Menu.tsx +13 -7
- package/src/components/Menubar.tsx +287 -0
- package/src/components/MultiSelect.tsx +7 -6
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +3 -2
- package/src/components/RadioGroup.tsx +40 -9
- package/src/components/SearchBar.tsx +6 -6
- package/src/components/Select.tsx +24 -23
- package/src/components/Sheet.tsx +7 -7
- package/src/components/Skeleton.tsx +8 -5
- package/src/components/Table.tsx +6 -6
- package/src/components/Tabs.tsx +5 -5
- package/src/components/TextField.tsx +8 -7
- package/src/components/TextareaAutosize.tsx +3 -3
- package/src/components/Tooltip.tsx +4 -3
- package/src/components/Typography.tsx +20 -3
- 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 +44 -41
- package/src/index.ts +1 -0
- package/src/scripts/generateIconKeys.ts +0 -1
- package/src/styles.ts +6 -6
- 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 -18
- package/src/util/cn.ts +0 -6
- /package/dist/{util → hooks}/useDebounceValue.d.ts +0 -0
- /package/dist/{util → hooks}/useInjectStyles.d.ts +0 -0
- /package/dist/{util → hooks}/useOutsideAlerter.d.ts +0 -0
- /package/src/{util → hooks}/useDebounceValue.tsx +0 -0
- /package/src/{util → hooks}/useInjectStyles.tsx +0 -0
- /package/src/{util → hooks}/useOutsideAlerter.tsx +0 -0
@@ -0,0 +1,287 @@
|
|
1
|
+
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
2
|
+
import { cls } from "../util";
|
3
|
+
import { CheckIcon, ChevronRightIcon } from "../icons";
|
4
|
+
|
5
|
+
export function Menubar({
|
6
|
+
children,
|
7
|
+
className
|
8
|
+
}: { children: React.ReactNode, className?: string }) {
|
9
|
+
return (
|
10
|
+
<MenubarPrimitive.Root
|
11
|
+
className={cls("z-10 flex bg-white dark:bg-gray-950 p-[3px] rounded-sm shadow-sm", className)}>
|
12
|
+
{children}
|
13
|
+
</MenubarPrimitive.Root>
|
14
|
+
)
|
15
|
+
}
|
16
|
+
|
17
|
+
export function MenubarMenu({
|
18
|
+
children,
|
19
|
+
}: { children: React.ReactNode }) {
|
20
|
+
return (
|
21
|
+
<MenubarPrimitive.Menu>
|
22
|
+
{children}
|
23
|
+
</MenubarPrimitive.Menu>
|
24
|
+
)
|
25
|
+
}
|
26
|
+
|
27
|
+
export function MenubarTrigger({
|
28
|
+
children,
|
29
|
+
className
|
30
|
+
}: { children: React.ReactNode, className?: string }) {
|
31
|
+
return (
|
32
|
+
<MenubarPrimitive.Trigger
|
33
|
+
className={cls("py-2 px-3 outline-none select-none font-medium leading-none rounded text-text-primary dark:text-text-primary-dark text-[13px] flex items-center justify-between gap-[2px] data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[state=open]:bg-slate-100 data-[state=open]:dark:bg-gray-800 hover:bg-slate-200 hover:bg-opacity-75 dark:hover:bg-gray-700 dark:hover:bg-opacity-50",
|
34
|
+
className)}>
|
35
|
+
{children}
|
36
|
+
</MenubarPrimitive.Trigger>
|
37
|
+
)
|
38
|
+
}
|
39
|
+
|
40
|
+
export function MenubarPortal({
|
41
|
+
children,
|
42
|
+
}: { children: React.ReactNode }) {
|
43
|
+
return (
|
44
|
+
<MenubarPrimitive.Portal>
|
45
|
+
{children}
|
46
|
+
</MenubarPrimitive.Portal>
|
47
|
+
)
|
48
|
+
}
|
49
|
+
|
50
|
+
export function MenubarContent({
|
51
|
+
children,
|
52
|
+
className,
|
53
|
+
align,
|
54
|
+
sideOffset,
|
55
|
+
alignOffset,
|
56
|
+
...rest
|
57
|
+
}: {
|
58
|
+
children: React.ReactNode,
|
59
|
+
className?: string,
|
60
|
+
align?: "start" | "center" | "end",
|
61
|
+
sideOffset?: number,
|
62
|
+
alignOffset?: number
|
63
|
+
}) {
|
64
|
+
return (
|
65
|
+
<MenubarPrimitive.Content
|
66
|
+
className={cls("min-w-[220px] bg-white dark:bg-gray-950 rounded-md p-[6px] shadow-[0px_10px_38px_-10px_rgba(22,_23,_24,_0.35),_0px_10px_20px_-15px_rgba(22,_23,_24,_0.2)] [animation-duration:_400ms] [animation-timing-function:_cubic-bezier(0.16,_1,_0.3,_1)] will-change-[transform,opacity]", className)}
|
67
|
+
align={align ?? "start"}
|
68
|
+
sideOffset={sideOffset ?? 5}
|
69
|
+
alignOffset={alignOffset ?? -3}
|
70
|
+
{...rest}
|
71
|
+
>
|
72
|
+
{children}
|
73
|
+
</MenubarPrimitive.Content>
|
74
|
+
)
|
75
|
+
}
|
76
|
+
|
77
|
+
export function MenubarItem({
|
78
|
+
children,
|
79
|
+
leftPadding,
|
80
|
+
className,
|
81
|
+
disabled,
|
82
|
+
...rest
|
83
|
+
}: {
|
84
|
+
children: React.ReactNode,
|
85
|
+
leftPadding?: boolean,
|
86
|
+
className?: string,
|
87
|
+
disabled?: boolean
|
88
|
+
}) {
|
89
|
+
return (
|
90
|
+
<MenubarPrimitive.Item
|
91
|
+
className={cls("group text-[13px] leading-none rounded flex items-center h-[32px] px-[10px] py-[2px] relative select-none outline-none data-[state=open]:bg-slate-100 data-[state=open]:dark:bg-gray-800 data-[state=open]:text-text-primary data-[state=open]:dark:text-text-primary-dark data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[disabled]:text-disabled data-[disabled]:dark:text-disabled-dark data-[disabled]:pointer-events-none",
|
92
|
+
leftPadding ? "pl-5" : "",
|
93
|
+
disabled ? "pointer-events-none text-text-secondary dark:text-text-secondary-dark" : "text-text-primary dark:text-text-primary-dark",
|
94
|
+
className)}
|
95
|
+
disabled={disabled}
|
96
|
+
{...rest}
|
97
|
+
>
|
98
|
+
{children}
|
99
|
+
</MenubarPrimitive.Item>
|
100
|
+
)
|
101
|
+
}
|
102
|
+
|
103
|
+
export function MenubarSeparator({
|
104
|
+
children,
|
105
|
+
className,
|
106
|
+
...rest
|
107
|
+
}: {
|
108
|
+
children?: React.ReactNode,
|
109
|
+
className?: string,
|
110
|
+
}) {
|
111
|
+
return (
|
112
|
+
<MenubarPrimitive.Separator
|
113
|
+
className={cls("h-[1px] bg-slate-100 dark:bg-gray-800 m-[5px]", className)}
|
114
|
+
{...rest}
|
115
|
+
>
|
116
|
+
{children}
|
117
|
+
</MenubarPrimitive.Separator>
|
118
|
+
)
|
119
|
+
}
|
120
|
+
|
121
|
+
export function MenubarSub({
|
122
|
+
children,
|
123
|
+
...rest
|
124
|
+
}: {
|
125
|
+
children?: React.ReactNode,
|
126
|
+
}) {
|
127
|
+
return (
|
128
|
+
<MenubarPrimitive.Sub
|
129
|
+
{...rest}
|
130
|
+
>
|
131
|
+
{children}
|
132
|
+
</MenubarPrimitive.Sub>
|
133
|
+
)
|
134
|
+
}
|
135
|
+
|
136
|
+
export function MenubarSubTrigger({
|
137
|
+
children,
|
138
|
+
className,
|
139
|
+
...rest
|
140
|
+
}: {
|
141
|
+
children?: React.ReactNode,
|
142
|
+
className?: string,
|
143
|
+
}) {
|
144
|
+
return (
|
145
|
+
<MenubarPrimitive.SubTrigger
|
146
|
+
className={cls("group text-[13px] leading-none text-text-primary dark:text-text-primary-dark rounded flex items-center h-[32px] px-[10px] py-[2px] relative select-none outline-none data-[state=open]:bg-slate-100 data-[state=open]:dark:bg-gray-800 data-[state=open]:text-text-primary data-[state=open]:dark:text-text-primary-dark data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[disabled]:text-disabled data-[disabled]:dark:text-disabled-dark data-[disabled]:pointer-events-none",
|
147
|
+
className)}
|
148
|
+
{...rest}
|
149
|
+
>
|
150
|
+
{children}
|
151
|
+
</MenubarPrimitive.SubTrigger>
|
152
|
+
)
|
153
|
+
}
|
154
|
+
|
155
|
+
export function MenubarSubContent({
|
156
|
+
children,
|
157
|
+
alignOffset,
|
158
|
+
className,
|
159
|
+
...rest
|
160
|
+
}: {
|
161
|
+
children?: React.ReactNode,
|
162
|
+
alignOffset?: number,
|
163
|
+
className?: string,
|
164
|
+
}) {
|
165
|
+
return (
|
166
|
+
<MenubarPrimitive.SubContent
|
167
|
+
alignOffset={alignOffset ?? -5}
|
168
|
+
className={cls("min-w-[220px] bg-white dark:bg-gray-950 rounded-md p-[6px] shadow-[0px_10px_38px_-10px_rgba(22,_23,_24,_0.35),_0px_10px_20px_-15px_rgba(22,_23,_24,_0.2)] [animation-duration:_400ms] [animation-timing-function:_cubic-bezier(0.16,_1,_0.3,_1)] will-change-[transform,opacity]",
|
169
|
+
className)}
|
170
|
+
{...rest}
|
171
|
+
>
|
172
|
+
{children}
|
173
|
+
</MenubarPrimitive.SubContent>
|
174
|
+
)
|
175
|
+
}
|
176
|
+
|
177
|
+
export function MenubarCheckboxItem({
|
178
|
+
children,
|
179
|
+
checked,
|
180
|
+
onCheckedChange,
|
181
|
+
className,
|
182
|
+
...rest
|
183
|
+
}: {
|
184
|
+
children?: React.ReactNode,
|
185
|
+
checked?: boolean,
|
186
|
+
onCheckedChange?: () => void,
|
187
|
+
className?: string,
|
188
|
+
}) {
|
189
|
+
return (
|
190
|
+
<MenubarPrimitive.CheckboxItem
|
191
|
+
className={cls("text-[13px] leading-none text-text-primary dark:text-text-primary-dark rounded flex items-center h-[32px] px-[10px] py-[2px] relative select-none pl-5 outline-none data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[disabled]:text-disabled data-[disabled]:dark:text-disabled-dark data-[disabled]:pointer-events-none",
|
192
|
+
className)}
|
193
|
+
checked={checked}
|
194
|
+
onCheckedChange={onCheckedChange}
|
195
|
+
{...rest}
|
196
|
+
>
|
197
|
+
{children}
|
198
|
+
</MenubarPrimitive.CheckboxItem>
|
199
|
+
)
|
200
|
+
}
|
201
|
+
|
202
|
+
export function MenubarItemIndicator({
|
203
|
+
children,
|
204
|
+
className,
|
205
|
+
...rest
|
206
|
+
}: {
|
207
|
+
children?: React.ReactNode,
|
208
|
+
className?: string,
|
209
|
+
}) {
|
210
|
+
return (
|
211
|
+
<MenubarPrimitive.ItemIndicator
|
212
|
+
className={cls("absolute left-0 w-4 inline-flex items-center justify-center", className)}
|
213
|
+
{...rest}>
|
214
|
+
{children ?? <CheckIcon size={"smallest"}/>}
|
215
|
+
</MenubarPrimitive.ItemIndicator>
|
216
|
+
)
|
217
|
+
}
|
218
|
+
|
219
|
+
export function MenubarRadioGroup({
|
220
|
+
children,
|
221
|
+
className,
|
222
|
+
value,
|
223
|
+
onValueChange,
|
224
|
+
...rest
|
225
|
+
}: {
|
226
|
+
children?: React.ReactNode,
|
227
|
+
value?: string,
|
228
|
+
onValueChange?: (value: string) => void,
|
229
|
+
className?: string,
|
230
|
+
}) {
|
231
|
+
return (
|
232
|
+
<MenubarPrimitive.RadioGroup
|
233
|
+
className={cls(className)}
|
234
|
+
value={value}
|
235
|
+
onValueChange={onValueChange}
|
236
|
+
{...rest}>
|
237
|
+
{children ?? <CheckIcon size={"small"}/>}
|
238
|
+
</MenubarPrimitive.RadioGroup>
|
239
|
+
)
|
240
|
+
}
|
241
|
+
|
242
|
+
export function MenubarRadioItem({
|
243
|
+
children,
|
244
|
+
className,
|
245
|
+
value,
|
246
|
+
...rest
|
247
|
+
}: {
|
248
|
+
children?: React.ReactNode,
|
249
|
+
value: string,
|
250
|
+
className?: string,
|
251
|
+
}) {
|
252
|
+
return (
|
253
|
+
<MenubarPrimitive.RadioItem
|
254
|
+
className={cls("text-[13px] leading-none text-text-primary dark:text-text-primary-dark rounded flex items-center h-[32px] px-[10px] py-[2px] relative select-none pl-5 outline-none data-[highlighted]:bg-slate-100 data-[highlighted]:dark:bg-gray-800 data-[disabled]:text-disabled data-[disabled]:dark:text-disabled-dark data-[disabled]:pointer-events-none",
|
255
|
+
className)}
|
256
|
+
value={value}
|
257
|
+
{...rest}>
|
258
|
+
{children ?? <CheckIcon size={"small"}/>}
|
259
|
+
</MenubarPrimitive.RadioItem>
|
260
|
+
)
|
261
|
+
}
|
262
|
+
|
263
|
+
export function MenubarShortcut({
|
264
|
+
children,
|
265
|
+
className,
|
266
|
+
...rest
|
267
|
+
}: {
|
268
|
+
children?: React.ReactNode,
|
269
|
+
className?: string,
|
270
|
+
}) {
|
271
|
+
return (
|
272
|
+
<div
|
273
|
+
className={cls("ml-auto pl-5 group-data-[disabled]:text-disabled data-[disabled]:dark:text-disabled-dark",
|
274
|
+
className)}
|
275
|
+
{...rest}>
|
276
|
+
{children}
|
277
|
+
</div>
|
278
|
+
)
|
279
|
+
}
|
280
|
+
|
281
|
+
export function MenubarSubTriggerIndicator() {
|
282
|
+
return (
|
283
|
+
<div className="ml-auto pl-5 ">
|
284
|
+
<ChevronRightIcon size={"small"}/>
|
285
|
+
</div>
|
286
|
+
)
|
287
|
+
}
|
@@ -6,8 +6,9 @@ import { Command as CommandPrimitive } from "cmdk";
|
|
6
6
|
|
7
7
|
import { ExpandMoreIcon } from "../icons";
|
8
8
|
import { fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, fieldBackgroundMixin, focusedMixin } from "../styles";
|
9
|
-
import {
|
9
|
+
import { cls } from "../util";
|
10
10
|
import { SelectInputLabel } from "./common/SelectInputLabel";
|
11
|
+
import { useOutsideAlerter } from "../hooks";
|
11
12
|
|
12
13
|
export type MultiSelectProps = {
|
13
14
|
open?: boolean,
|
@@ -115,10 +116,10 @@ export function MultiSelect({
|
|
115
116
|
inputRef.current?.focus();
|
116
117
|
openDialog()
|
117
118
|
}}
|
118
|
-
className={
|
119
|
+
className={cls("relative overflow-visible bg-transparent", containerClassName)}>
|
119
120
|
<div
|
120
121
|
ref={containerRef}
|
121
|
-
className={
|
122
|
+
className={cls(
|
122
123
|
"flex flex-row",
|
123
124
|
size === "small" ? "min-h-[42px]" : "min-h-[64px]",
|
124
125
|
"select-none rounded-md text-sm",
|
@@ -131,7 +132,7 @@ export function MultiSelect({
|
|
131
132
|
includeFocusOutline ? focusedMixin : "",
|
132
133
|
className)}
|
133
134
|
>
|
134
|
-
<div className={
|
135
|
+
<div className={cls("flex-grow flex gap-1.5 flex-wrap items-center")}>
|
135
136
|
{renderValue && (value ?? []).map((v, i) => renderValue(v, i))}
|
136
137
|
{renderValues && renderValues(value ?? [])}
|
137
138
|
<CommandPrimitive.Input
|
@@ -145,7 +146,7 @@ export function MultiSelect({
|
|
145
146
|
</div>
|
146
147
|
<div className={"px-2 h-full flex items-center"}>
|
147
148
|
<ExpandMoreIcon size={"small"}
|
148
|
-
className={
|
149
|
+
className={cls("transition ", openInternal ? "rotate-180" : "")}/>
|
149
150
|
</div>
|
150
151
|
|
151
152
|
</div>
|
@@ -209,7 +210,7 @@ export function MultiSelectItem({ children, value, className }: MultiSelectItemP
|
|
209
210
|
setInputValue("");
|
210
211
|
onValueChangeInternal(value);
|
211
212
|
}}
|
212
|
-
className={
|
213
|
+
className={cls(
|
213
214
|
(fieldValue ?? []).includes(value) ? "bg-slate-200 dark:bg-slate-950" : "",
|
214
215
|
"cursor-pointer",
|
215
216
|
"m-1",
|
package/src/components/Paper.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from "react";
|
2
2
|
|
3
3
|
import { paperMixin } from "../styles";
|
4
|
-
import {
|
4
|
+
import { cls } from "../util";
|
5
5
|
|
6
6
|
export function Paper({
|
7
7
|
children,
|
@@ -15,7 +15,7 @@ export function Paper({
|
|
15
15
|
}) {
|
16
16
|
return (
|
17
17
|
<div
|
18
|
-
className={
|
18
|
+
className={cls(paperMixin, className)}
|
19
19
|
style={style}>
|
20
20
|
{children}
|
21
21
|
</div>
|
@@ -2,7 +2,8 @@ import React from "react";
|
|
2
2
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
3
3
|
|
4
4
|
import { paperMixin } from "../styles";
|
5
|
-
import {
|
5
|
+
import { cls } from "../util";
|
6
|
+
import { useInjectStyles } from "../hooks";
|
6
7
|
|
7
8
|
export type PopoverSide = "top" | "right" | "bottom" | "left";
|
8
9
|
export type PopoverAlign = "start" | "center" | "end";
|
@@ -56,7 +57,7 @@ export function Popover({
|
|
56
57
|
{trigger}
|
57
58
|
</PopoverPrimitive.Trigger>
|
58
59
|
<PopoverPrimitive.Portal>
|
59
|
-
<PopoverPrimitive.Content className={
|
60
|
+
<PopoverPrimitive.Content className={cls(paperMixin,
|
60
61
|
"PopoverContent shadow z-40", className)}
|
61
62
|
side={side}
|
62
63
|
sideOffset={sideOffset}
|
@@ -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,31 @@ 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
|
+
}
|
20
48
|
const RadioGroupItem = React.forwardRef<
|
21
49
|
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
22
|
-
|
23
|
-
>(({
|
50
|
+
RadioGroupItemProps
|
51
|
+
>(({
|
52
|
+
className,
|
53
|
+
...props
|
54
|
+
}, ref) => {
|
24
55
|
return (
|
25
56
|
<RadioGroupPrimitive.Item
|
26
57
|
ref={ref}
|
27
|
-
className={
|
58
|
+
className={cls(
|
28
59
|
"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
60
|
className
|
30
61
|
)}
|
31
62
|
{...props}
|
32
63
|
>
|
33
64
|
<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"
|
65
|
+
<div className="h-2.5 w-2.5 fill-current text-current bg-primary rounded-lg"/>
|
35
66
|
</RadioGroupPrimitive.Indicator>
|
36
67
|
</RadioGroupPrimitive.Item>
|
37
68
|
)
|
@@ -3,8 +3,8 @@ import React, { useCallback, useState } from "react";
|
|
3
3
|
import { defaultBorderMixin, focusedMixin } 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,7 +84,7 @@ 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 ",
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
focusedMixin
|
10
10
|
} from "../styles";
|
11
11
|
import { CheckIcon, ExpandMoreIcon } from "../icons";
|
12
|
-
import {
|
12
|
+
import { cls } from "../util";
|
13
13
|
import { SelectInputLabel } from "./common/SelectInputLabel";
|
14
14
|
|
15
15
|
export type SelectProps = {
|
@@ -27,7 +27,7 @@ export type SelectProps = {
|
|
27
27
|
renderValue?: (value: string, index: number) => React.ReactNode,
|
28
28
|
renderValues?: (values: string[]) => React.ReactNode,
|
29
29
|
size?: "small" | "medium",
|
30
|
-
label?: React.ReactNode,
|
30
|
+
label?: React.ReactNode | string,
|
31
31
|
disabled?: boolean,
|
32
32
|
error?: boolean,
|
33
33
|
position?: "item-aligned" | "popper",
|
@@ -95,6 +95,7 @@ export function Select({
|
|
95
95
|
}
|
96
96
|
}, [multiple, onChange, value, onMultiValueChange, onValueChange]);
|
97
97
|
|
98
|
+
const hasValue = Array.isArray(value) ? value.length > 0 : value != null;
|
98
99
|
return (
|
99
100
|
<SelectPrimitive.Root
|
100
101
|
name={name}
|
@@ -112,7 +113,7 @@ export function Select({
|
|
112
113
|
{typeof label === "string" ? <SelectInputLabel error={error}>{label}</SelectInputLabel> : label}
|
113
114
|
|
114
115
|
<div
|
115
|
-
className={
|
116
|
+
className={cls(
|
116
117
|
size === "small" ? "min-h-[42px]" : "min-h-[64px]",
|
117
118
|
"select-none rounded-md text-sm",
|
118
119
|
invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,
|
@@ -123,7 +124,7 @@ export function Select({
|
|
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 " : "",
|
@@ -137,39 +138,39 @@ export function Select({
|
|
137
138
|
inputClassName
|
138
139
|
)}>
|
139
140
|
|
140
|
-
<div className={
|
141
|
+
<div className={cls(
|
141
142
|
"flex-grow w-full max-w-full flex flex-row gap-2 items-center",
|
142
143
|
"overflow-visible",
|
143
144
|
size === "small" ? "h-[42px]" : "h-[64px]"
|
144
145
|
)}>
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
146
|
+
<SelectPrimitive.Value placeholder={placeholder}>
|
147
|
+
{renderValue &&
|
148
|
+
(hasValue && Array.isArray(value)
|
149
|
+
? 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))}
|
153
154
|
|
154
|
-
|
155
|
-
|
156
|
-
|
155
|
+
{renderValues && (!hasValue || Array.isArray(value))
|
156
|
+
? renderValues(value as string[] ?? [])
|
157
|
+
: null}
|
157
158
|
|
158
|
-
|
159
|
+
{!renderValue && !renderValues && hasValue}
|
159
160
|
|
160
|
-
|
161
|
+
</SelectPrimitive.Value>
|
161
162
|
</div>
|
162
163
|
|
163
|
-
<SelectPrimitive.Icon className={
|
164
|
+
<SelectPrimitive.Icon className={cls(
|
164
165
|
"px-2 h-full flex items-center",
|
165
166
|
)}>
|
166
167
|
<ExpandMoreIcon size={"small"}
|
167
|
-
className={
|
168
|
+
className={cls("transition", open ? "rotate-180" : "")}/>
|
168
169
|
</SelectPrimitive.Icon>
|
169
170
|
|
170
171
|
</SelectPrimitive.Trigger>
|
171
172
|
|
172
|
-
{endAdornment && <div className={
|
173
|
+
{endAdornment && <div className={cls("absolute h-full flex items-center",
|
173
174
|
size === "small" ? "right-10" : "right-14")}
|
174
175
|
onClick={(e) => e.stopPropagation()}>
|
175
176
|
{endAdornment}
|
@@ -214,7 +215,7 @@ export function SelectItem({
|
|
214
215
|
e.preventDefault();
|
215
216
|
e.stopPropagation();
|
216
217
|
}}
|
217
|
-
className={
|
218
|
+
className={cls(
|
218
219
|
"w-full",
|
219
220
|
"relative relative flex items-center p-2 rounded-md text-sm text-slate-700 dark:text-slate-300",
|
220
221
|
focusedMixin,
|
@@ -248,7 +249,7 @@ export function SelectGroup({
|
|
248
249
|
}: SelectGroupProps) {
|
249
250
|
return <>
|
250
251
|
<SelectPrimitive.Group
|
251
|
-
className={
|
252
|
+
className={cls(
|
252
253
|
"text-xs text-slate-900 dark:text-white uppercase tracking-wider font-bold mt-6 first:mt-2",
|
253
254
|
"px-2 py-2",
|
254
255
|
className
|
package/src/components/Sheet.tsx
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useEffect } from "react";
|
2
2
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
3
|
-
import {
|
3
|
+
import { cls } from "../util";
|
4
4
|
|
5
5
|
interface SheetProps {
|
6
6
|
children: React.ReactNode;
|
@@ -47,10 +47,10 @@ export const Sheet: React.FC<SheetProps> = ({
|
|
47
47
|
onOpenChange={onOpenChange}>
|
48
48
|
<DialogPrimitive.Portal>
|
49
49
|
<DialogPrimitive.Overlay
|
50
|
-
className={
|
50
|
+
className={cls(
|
51
51
|
"fixed inset-0 transition-opacity z-20 ease-in-out duration-200 backdrop-blur-sm",
|
52
|
-
|
53
|
-
"dark:bg-
|
52
|
+
"bg-black bg-opacity-50",
|
53
|
+
"dark:bg-gray-900 dark:bg-opacity-60",
|
54
54
|
displayed && open ? "opacity-100" : "opacity-0"
|
55
55
|
)}
|
56
56
|
style={{
|
@@ -59,13 +59,13 @@ export const Sheet: React.FC<SheetProps> = ({
|
|
59
59
|
/>
|
60
60
|
<DialogPrimitive.Content
|
61
61
|
{...props}
|
62
|
-
className={
|
63
|
-
|
62
|
+
className={cls(
|
63
|
+
"transform-gpu",
|
64
64
|
"will-change-transform",
|
65
65
|
"text-slate-900 dark:text-white",
|
66
66
|
"fixed transform z-20 transition-all duration-[240ms] ease-in-out",
|
67
67
|
"outline-none focus:outline-none",
|
68
|
-
|
68
|
+
transparent ? "" : "shadow-md bg-white dark:bg-gray-950",
|
69
69
|
side === "top" || side === "bottom" ? "w-full" : "h-full",
|
70
70
|
side === "left" || side === "top" ? "left-0 top-0" : "right-0 bottom-0",
|
71
71
|
displayed && open ? "opacity-100" : "opacity-0",
|
@@ -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
23
|
"bg-slate-200 dark:bg-slate-800 rounded",
|
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
|
}/>;
|