@firecms/ui 3.0.0-alpha.84 → 3.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -7
- package/dist/components/Avatar.d.ts +1 -0
- package/dist/components/BooleanSwitch.d.ts +1 -1
- package/dist/components/Button.d.ts +3 -2
- package/dist/components/Card.d.ts +4 -2
- package/dist/components/CenteredView.d.ts +5 -2
- package/dist/components/Checkbox.d.ts +5 -4
- package/dist/components/Chip.d.ts +3 -2
- package/dist/components/DateTimeField.d.ts +5 -7
- package/dist/components/Dialog.d.ts +5 -1
- package/dist/components/DialogTitle.d.ts +9 -0
- package/dist/components/ExpandablePanel.d.ts +2 -1
- package/dist/components/FileUpload.d.ts +1 -1
- package/dist/components/IconButton.d.ts +1 -1
- package/dist/components/InputLabel.d.ts +2 -2
- package/dist/components/Label.d.ts +7 -0
- package/dist/components/Markdown.d.ts +1 -0
- package/dist/components/Menu.d.ts +7 -2
- package/dist/components/Menubar.d.ts +79 -0
- package/dist/components/MultiSelect.d.ts +31 -16
- package/dist/components/Popover.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +28 -0
- package/dist/components/Select.d.ts +6 -10
- package/dist/components/Separator.d.ts +5 -0
- package/dist/components/Sheet.d.ts +6 -0
- package/dist/components/Slider.d.ts +21 -0
- package/dist/components/Table.d.ts +10 -10
- package/dist/components/TextField.d.ts +3 -3
- package/dist/components/TextareaAutosize.d.ts +3 -34
- package/dist/components/Tooltip.d.ts +9 -3
- package/dist/components/Typography.d.ts +5 -4
- package/dist/components/_MultiSelect.d.ts +0 -0
- package/dist/components/index.d.ts +7 -2
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useLocaleConfig.d.ts +1 -0
- package/dist/icons/HandleIcon.d.ts +1 -0
- package/dist/icons/Icon.d.ts +3 -3
- package/dist/icons/index.d.ts +1 -0
- package/dist/index.css +73 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +13341 -13478
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19788 -49
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +10 -10
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +112 -105
- package/src/components/Alert.tsx +6 -5
- package/src/components/Autocomplete.tsx +4 -3
- package/src/components/Avatar.tsx +8 -7
- package/src/components/Badge.tsx +1 -1
- package/src/components/BooleanSwitch.tsx +18 -17
- package/src/components/BooleanSwitchWithLabel.tsx +8 -8
- package/src/components/Button.tsx +59 -35
- package/src/components/Card.tsx +19 -13
- package/src/components/CenteredView.tsx +26 -14
- package/src/components/Checkbox.tsx +36 -25
- package/src/components/Chip.tsx +9 -6
- package/src/components/CircularProgress.tsx +2 -2
- package/src/components/Collapse.tsx +3 -2
- package/src/components/Container.tsx +2 -2
- package/src/components/DateTimeField.tsx +45 -50
- package/src/components/DebouncedTextField.tsx +3 -2
- package/src/components/Dialog.tsx +18 -6
- package/src/components/DialogActions.tsx +2 -2
- package/src/components/DialogContent.tsx +2 -2
- package/src/components/DialogTitle.tsx +35 -0
- package/src/components/ExpandablePanel.tsx +19 -11
- package/src/components/FileUpload.tsx +7 -10
- package/src/components/IconButton.tsx +7 -8
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +12 -9
- package/src/components/Label.tsx +31 -0
- package/src/components/Markdown.tsx +14 -3
- package/src/components/Menu.tsx +51 -30
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +335 -165
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +17 -13
- package/src/components/RadioGroup.tsx +73 -0
- package/src/components/SearchBar.tsx +8 -9
- package/src/components/Select.tsx +97 -125
- package/src/components/Separator.tsx +28 -0
- package/src/components/Sheet.tsx +51 -30
- package/src/components/Skeleton.tsx +9 -6
- package/src/components/Slider.tsx +109 -0
- package/src/components/Table.tsx +52 -35
- package/src/components/Tabs.tsx +8 -9
- package/src/components/TextField.tsx +35 -23
- package/src/components/TextareaAutosize.tsx +3 -3
- package/src/components/Tooltip.tsx +37 -16
- package/src/components/Typography.tsx +43 -27
- package/src/components/_MultiSelect.tsx +222 -0
- package/src/components/common/SelectInputLabel.tsx +2 -2
- package/src/components/index.tsx +7 -2
- package/src/hooks/index.ts +4 -0
- package/src/{util → hooks}/useInjectStyles.tsx +1 -1
- package/src/hooks/useLocaleConfig.tsx +18 -0
- package/src/icons/GitHubIcon.tsx +1 -0
- package/src/icons/HandleIcon.tsx +10 -0
- package/src/icons/Icon.tsx +46 -43
- package/src/icons/icon_keys.ts +114 -1301
- package/src/icons/index.ts +1 -0
- package/src/index.css +73 -0
- package/src/index.ts +1 -0
- package/src/scripts/generateIconKeys.ts +20 -12
- package/src/scripts/saveIconFiles.ts +2 -1
- package/src/styles.ts +10 -10
- package/src/util/cls.ts +14 -0
- package/src/util/index.ts +1 -3
- package/tailwind.config.js +70 -0
- package/dist/components/Spinner.d.ts +0 -1
- package/src/components/Spinner.tsx +0 -17
- package/src/util/cn.ts +0 -6
- /package/dist/{util → hooks}/useDebounceValue.d.ts +0 -0
- /package/dist/{util → hooks}/useInjectStyles.d.ts +0 -0
- /package/dist/{util → hooks}/useOutsideAlerter.d.ts +0 -0
- /package/src/{util → hooks}/useDebounceValue.tsx +0 -0
- /package/src/{util → hooks}/useOutsideAlerter.tsx +0 -0
|
@@ -1,60 +1,78 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
import { focusedMixin } from "../styles";
|
|
4
|
-
import { cn } from "../util";
|
|
2
|
+
import { cls } from "../util";
|
|
5
3
|
|
|
6
4
|
export type ButtonProps<P extends React.ElementType> =
|
|
7
5
|
Omit<(P extends "button" ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.ComponentProps<P>), "onClick">
|
|
8
6
|
& {
|
|
9
7
|
variant?: "filled" | "outlined" | "text";
|
|
10
8
|
disabled?: boolean;
|
|
11
|
-
|
|
9
|
+
color?: "primary" | "secondary" | "text" | "error";
|
|
10
|
+
size?: "small" | "medium" | "large" | "xl" | "2xl";
|
|
12
11
|
startIcon?: React.ReactNode;
|
|
13
12
|
fullWidth?: boolean;
|
|
14
13
|
className?: string;
|
|
15
14
|
onClick?: React.MouseEventHandler<any>
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
const ButtonInner = React.forwardRef<
|
|
18
|
+
ButtonProps<React.ElementType<any>>
|
|
19
|
+
>(({
|
|
20
|
+
children,
|
|
21
|
+
className,
|
|
22
|
+
variant = "filled",
|
|
23
|
+
disabled = false,
|
|
24
|
+
size = "medium",
|
|
25
|
+
startIcon = null,
|
|
26
|
+
fullWidth = false,
|
|
27
|
+
component: Component,
|
|
28
|
+
color = "primary",
|
|
29
|
+
...props
|
|
30
|
+
}: ButtonProps<any>, ref) => {
|
|
29
31
|
|
|
30
32
|
const baseClasses =
|
|
31
|
-
"h-fit rounded-md
|
|
33
|
+
"typography-button h-fit rounded-md whitespace-nowrap inline-flex items-center justify-center p-2 px-4 focus:outline-none transition ease-in-out duration-150 gap-2";
|
|
32
34
|
|
|
33
|
-
const buttonClasses =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
const buttonClasses = cls({
|
|
36
|
+
"w-full": fullWidth,
|
|
37
|
+
"w-fit": !fullWidth,
|
|
38
|
+
// Filled Variants
|
|
39
|
+
"border border-primary bg-primary hover:bg-primary-dark focus:ring-primary shadow hover:ring-1 hover:ring-primary text-white hover:text-white": variant === "filled" && color === "primary" && !disabled,
|
|
40
|
+
"border border-secondary bg-secondary hover:bg-secondary-dark focus:ring-secondary shadow hover:ring-1 hover:ring-secondary text-white hover:text-white": variant === "filled" && color === "secondary" && !disabled,
|
|
41
|
+
"border border-red-500 bg-red-500 hover:bg-red-500 focus:ring-red-500 shadow hover:ring-1 hover:ring-red-600 text-white hover:text-white": variant === "filled" && color === "error" && !disabled,
|
|
42
|
+
"border border-slate-200 bg-slate-200 hover:bg-slate-300 focus:ring-slate-400 shadow hover:ring-1 hover:ring-slate-400 text-text-primary hover:text-text-primary dark:text-text-primary-dark hover:dark:text-text-primary-dark": variant === "filled" && color === "text" && !disabled,
|
|
43
|
+
// Text Variants
|
|
44
|
+
"border border-transparent text-primary hover:text-primary hover:bg-slate-200 dark:hover:bg-gray-900": variant === "text" && color === "primary" && !disabled,
|
|
45
|
+
"border border-transparent text-secondary hover:text-secondary hover:bg-secondary-bg": variant === "text" && color === "secondary" && !disabled,
|
|
46
|
+
"border border-transparent text-red-500 hover:text-red-500 hover:bg-red-500 hover:bg-opacity-10": variant === "text" && color === "error" && !disabled,
|
|
47
|
+
"border border-transparent text-text-primary hover:text-text-primary dark:text-text-primary-dark hover:dark:text-text-primary-dark hover:bg-slate-200 hover:dark:bg-gray-700": variant === "text" && color === "text" && !disabled,
|
|
48
|
+
// Outlined Variants
|
|
49
|
+
"border border-primary text-primary hover:text-primary hover:bg-primary-bg": variant === "outlined" && color === "primary" && !disabled,
|
|
50
|
+
"border border-secondary text-secondary hover:text-secondary hover:bg-secondary-bg": variant === "outlined" && color === "secondary" && !disabled,
|
|
51
|
+
"border border-red-500 text-red-500 hover:text-red-500 hover:bg-red-500 hover:text-white": variant === "outlined" && color === "error" && !disabled,
|
|
52
|
+
"border border-slate-400 text-text-primary hover:text-text-primary dark:text-text-primary-dark hover:bg-slate-200": variant === "outlined" && color === "text" && !disabled,
|
|
53
|
+
// Disabled states for all variants
|
|
54
|
+
"border border-transparent opacity-50": variant === "text" && disabled,
|
|
55
|
+
"border border-gray-500 opacity-50": variant === "outlined" && disabled,
|
|
56
|
+
"border border-gray-500 bg-gray-500 opacity-50": variant === "filled" && disabled,
|
|
57
|
+
});
|
|
44
58
|
|
|
45
|
-
const sizeClasses =
|
|
59
|
+
const sizeClasses = cls(
|
|
46
60
|
{
|
|
47
61
|
"py-1 px-2": size === "small",
|
|
48
62
|
"py-2 px-4": size === "medium",
|
|
49
|
-
"py-2.5 px-5": size === "large"
|
|
63
|
+
"py-2.5 px-5": size === "large",
|
|
64
|
+
"py-3 px-6": size === "xl",
|
|
65
|
+
"py-4 px-10": size === "2xl",
|
|
50
66
|
}
|
|
51
67
|
);
|
|
52
68
|
|
|
53
69
|
if (Component) {
|
|
54
70
|
return (
|
|
55
|
-
<Component
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
<Component
|
|
72
|
+
ref={ref}
|
|
73
|
+
onClick={props.onClick}
|
|
74
|
+
className={cls( startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, className)}
|
|
75
|
+
{...(props as React.ComponentPropsWithRef<any>)}>
|
|
58
76
|
{startIcon}
|
|
59
77
|
{children}
|
|
60
78
|
</Component>
|
|
@@ -62,13 +80,19 @@ export function Button<P extends React.ElementType>({
|
|
|
62
80
|
}
|
|
63
81
|
|
|
64
82
|
return (
|
|
65
|
-
<button
|
|
83
|
+
<button ref={ref as any}
|
|
84
|
+
type={props.type ?? "button"}
|
|
66
85
|
onClick={props.onClick}
|
|
67
|
-
className={
|
|
86
|
+
className={cls(startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, className)}
|
|
68
87
|
disabled={disabled}
|
|
69
88
|
{...props as React.ButtonHTMLAttributes<HTMLButtonElement>}>
|
|
70
89
|
{startIcon}
|
|
71
90
|
{children}
|
|
72
91
|
</button>
|
|
73
92
|
);
|
|
74
|
-
|
|
93
|
+
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
ButtonInner.displayName = "Button"
|
|
97
|
+
|
|
98
|
+
export const Button = ButtonInner as React.FC<ButtonProps<any>>;
|
package/src/components/Card.tsx
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
|
-
import { cardClickableMixin, cardMixin
|
|
3
|
-
import {
|
|
2
|
+
import { cardClickableMixin, cardMixin } from "../styles";
|
|
3
|
+
import { cls } from "../util";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
children,
|
|
7
|
-
style,
|
|
8
|
-
onClick,
|
|
9
|
-
className
|
|
10
|
-
}: {
|
|
5
|
+
type CardProps = {
|
|
11
6
|
children: React.ReactNode;
|
|
12
7
|
style?: React.CSSProperties;
|
|
13
8
|
onClick?: () => void;
|
|
14
9
|
className?: string;
|
|
15
|
-
}
|
|
10
|
+
};
|
|
16
11
|
|
|
12
|
+
const Card = React.forwardRef<HTMLDivElement, CardProps>(({
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
onClick,
|
|
16
|
+
style,
|
|
17
|
+
...props
|
|
18
|
+
}, ref) => {
|
|
17
19
|
const onKeyPress = useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
18
20
|
if (e.key === "Enter" || e.key === " ") {
|
|
19
21
|
onClick?.();
|
|
@@ -22,13 +24,17 @@ export function Card({
|
|
|
22
24
|
|
|
23
25
|
return (
|
|
24
26
|
<div
|
|
27
|
+
ref={ref}
|
|
25
28
|
onKeyPress={onKeyPress}
|
|
26
29
|
role={onClick ? "button" : undefined}
|
|
27
30
|
tabIndex={onClick ? 0 : undefined}
|
|
28
31
|
onClick={onClick}
|
|
29
|
-
className={
|
|
30
|
-
style={style}
|
|
32
|
+
className={cls(cardMixin, onClick && cardClickableMixin, className)}
|
|
33
|
+
style={style}
|
|
34
|
+
{...props}>
|
|
31
35
|
{children}
|
|
32
36
|
</div>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export { Card };
|
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Container } from "./Container";
|
|
3
|
-
import {
|
|
3
|
+
import { cls } from "../util";
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
children,
|
|
7
|
-
maxWidth,
|
|
8
|
-
className
|
|
9
|
-
}: {
|
|
5
|
+
export type CenteredViewProps = {
|
|
10
6
|
children: React.ReactNode;
|
|
11
7
|
maxWidth?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl";
|
|
8
|
+
outerClassName?: string;
|
|
12
9
|
className?: string;
|
|
13
|
-
|
|
10
|
+
fullScreen?: boolean;
|
|
11
|
+
};
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
export const CenteredView = React.forwardRef<HTMLDivElement, CenteredViewProps>(({
|
|
14
|
+
children,
|
|
15
|
+
maxWidth,
|
|
16
|
+
outerClassName,
|
|
17
|
+
className,
|
|
18
|
+
fullScreen,
|
|
19
|
+
...rest
|
|
20
|
+
}, ref) => { // Notice how the ref is now received as the second argument
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
return (
|
|
23
|
+
<div ref={ref}
|
|
24
|
+
className={cls("flex flex-col flex-grow", fullScreen ? "h-screen" : "h-full", outerClassName)}
|
|
25
|
+
{...rest}>
|
|
26
|
+
<Container className={cls("m-auto", className)} maxWidth={maxWidth}>
|
|
27
|
+
{children}
|
|
28
|
+
</Container>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
CenteredView.displayName = "CenteredView";
|
|
@@ -2,27 +2,37 @@ import React from "react";
|
|
|
2
2
|
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
3
3
|
|
|
4
4
|
import { Icon } from "../icons";
|
|
5
|
-
import {
|
|
5
|
+
import { cls } from "../util";
|
|
6
6
|
|
|
7
|
-
interface CheckboxProps {
|
|
7
|
+
export interface CheckboxProps {
|
|
8
8
|
checked: boolean;
|
|
9
|
+
id?: string;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
indeterminate?: boolean;
|
|
11
12
|
onCheckedChange?: (checked: boolean) => void;
|
|
12
|
-
|
|
13
|
+
padding?: boolean;
|
|
14
|
+
size?: "smallest" | "small" | "medium" | "large";
|
|
13
15
|
color?: "primary" | "secondary";
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
const sizeClasses = {
|
|
17
19
|
large: "w-6 h-6 rounded flex items-center justify-center",
|
|
18
20
|
medium: "w-5 h-5 rounded flex items-center justify-center",
|
|
19
|
-
small: "w-4 h-4 rounded flex items-center justify-center"
|
|
21
|
+
small: "w-4 h-4 rounded flex items-center justify-center",
|
|
22
|
+
smallest: "w-4 h-4 rounded flex items-center justify-center"
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
const outerSizeClasses = {
|
|
23
26
|
medium: "w-10 h-10",
|
|
24
27
|
small: "w-8 h-8",
|
|
25
|
-
large: "w-12 h-12"
|
|
28
|
+
large: "w-12 h-12 ",
|
|
29
|
+
smallest: "w-6 h-6"
|
|
30
|
+
}
|
|
31
|
+
const paddingClasses = {
|
|
32
|
+
medium: "p-2",
|
|
33
|
+
small: "p-2",
|
|
34
|
+
large: "p-2",
|
|
35
|
+
smallest: ""
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
const colorClasses = {
|
|
@@ -31,8 +41,10 @@ const colorClasses = {
|
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
export const Checkbox = ({
|
|
44
|
+
id,
|
|
34
45
|
checked,
|
|
35
46
|
indeterminate = false,
|
|
47
|
+
padding = true,
|
|
36
48
|
disabled,
|
|
37
49
|
size = "medium",
|
|
38
50
|
onCheckedChange,
|
|
@@ -45,21 +57,25 @@ export const Checkbox = ({
|
|
|
45
57
|
? 20
|
|
46
58
|
: size === "small"
|
|
47
59
|
? 16
|
|
48
|
-
:
|
|
60
|
+
: size === "smallest"
|
|
61
|
+
? 14
|
|
62
|
+
: 24;
|
|
49
63
|
return (
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
onCheckedChange ?
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
onCheckedChange
|
|
64
|
+
<CheckboxPrimitive.Root
|
|
65
|
+
id={id}
|
|
66
|
+
checked={indeterminate || isChecked}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
onCheckedChange={disabled ? undefined : onCheckedChange}>
|
|
69
|
+
|
|
70
|
+
<div className={cls(
|
|
71
|
+
padding ? paddingClasses[size] : "",
|
|
72
|
+
outerSizeClasses[size],
|
|
73
|
+
"inline-flex items-center justify-center text-sm font-medium focus:outline-none transition-colors ease-in-out duration-150",
|
|
74
|
+
onCheckedChange ? "rounded-full hover:bg-slate-200 hover:bg-opacity-75 dark:hover:bg-slate-700 dark:hover:bg-opacity-75" : "",
|
|
75
|
+
onCheckedChange ? "cursor-pointer" : "cursor-default"
|
|
76
|
+
)}>
|
|
61
77
|
<div
|
|
62
|
-
className={
|
|
78
|
+
className={cls(
|
|
63
79
|
"border-2 relative transition-colors ease-in-out duration-150",
|
|
64
80
|
sizeClasses[size],
|
|
65
81
|
disabled
|
|
@@ -80,12 +96,7 @@ export const Checkbox = ({
|
|
|
80
96
|
)}
|
|
81
97
|
</CheckboxPrimitive.Indicator>
|
|
82
98
|
</div>
|
|
83
|
-
</
|
|
84
|
-
|
|
85
|
-
{/* <div >*/}
|
|
86
|
-
{/* YO*/}
|
|
87
|
-
{/* </div>*/}
|
|
88
|
-
{/*)}*/}
|
|
89
|
-
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</CheckboxPrimitive.Root>
|
|
90
101
|
);
|
|
91
102
|
};
|
package/src/components/Chip.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CHIP_COLORS,
|
|
2
|
+
import { CHIP_COLORS, cls, getColorSchemeForKey } from "../util";
|
|
3
3
|
|
|
4
4
|
export type ChipColorScheme = {
|
|
5
5
|
color: string;
|
|
@@ -11,16 +11,17 @@ export type ChipColorKey = keyof typeof CHIP_COLORS;
|
|
|
11
11
|
export interface ChipProps {
|
|
12
12
|
className?: string;
|
|
13
13
|
children: React.ReactNode;
|
|
14
|
-
size?: "
|
|
14
|
+
size?: "smallest" | "small" | "medium";
|
|
15
15
|
colorScheme?: ChipColorScheme | ChipColorKey;
|
|
16
16
|
error?: boolean;
|
|
17
17
|
outlined?: boolean;
|
|
18
18
|
onClick?: () => void;
|
|
19
19
|
icon?: React.ReactNode;
|
|
20
|
+
style?: React.CSSProperties;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
const sizeClassNames = {
|
|
23
|
-
|
|
24
|
+
smallest: "px-2 py-0.5 text-sm",
|
|
24
25
|
small: "px-3 py-1 text-sm",
|
|
25
26
|
medium: "px-4 py-1.5 text-sm"
|
|
26
27
|
}
|
|
@@ -36,17 +37,18 @@ export function Chip({
|
|
|
36
37
|
onClick,
|
|
37
38
|
icon,
|
|
38
39
|
size = "medium",
|
|
39
|
-
className
|
|
40
|
+
className,
|
|
41
|
+
style
|
|
40
42
|
}: ChipProps) {
|
|
41
43
|
|
|
42
44
|
const usedColorScheme = typeof colorScheme === "string" ? getColorSchemeForKey(colorScheme) : colorScheme;
|
|
43
45
|
return (
|
|
44
46
|
<div
|
|
45
|
-
className={
|
|
47
|
+
className={cls("rounded-lg max-w-full w-max h-fit font-regular inline-flex gap-1",
|
|
46
48
|
"text-ellipsis",
|
|
47
49
|
onClick ? "cursor-pointer hover:bg-slate-300 hover:dark:bg-slate-700" : "",
|
|
48
50
|
sizeClassNames[size],
|
|
49
|
-
error || !usedColorScheme ? "bg-slate-200 dark:bg-slate-800 text-slate-800 dark:text-
|
|
51
|
+
error || !usedColorScheme ? "bg-slate-200 dark:bg-slate-800 text-slate-800 dark:text-white" : "",
|
|
50
52
|
error ? "text-red-500 dark:text-red-400" : "",
|
|
51
53
|
className)}
|
|
52
54
|
onClick={onClick}
|
|
@@ -54,6 +56,7 @@ export function Chip({
|
|
|
54
56
|
backgroundColor: error || !usedColorScheme ? undefined : usedColorScheme.color,
|
|
55
57
|
color: error || !usedColorScheme ? undefined : usedColorScheme.text,
|
|
56
58
|
overflow: "hidden",
|
|
59
|
+
...style
|
|
57
60
|
// display: "-webkit-box",
|
|
58
61
|
// WebkitLineClamp: 1,
|
|
59
62
|
// WebkitBoxOrient: "vertical",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { cls } from "../util";
|
|
3
3
|
|
|
4
4
|
export type CircularProgressProps = {
|
|
5
5
|
size?: "small" | "medium" | "large",
|
|
@@ -31,7 +31,7 @@ export function CircularProgress({
|
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<div
|
|
34
|
-
className={
|
|
34
|
+
className={cls(
|
|
35
35
|
sizeClasses,
|
|
36
36
|
borderClasses,
|
|
37
37
|
"inline-block animate-spin rounded-full border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { cls } from "../util";
|
|
5
|
+
import { useInjectStyles } from "../hooks";
|
|
5
6
|
|
|
6
7
|
interface CollapseProps {
|
|
7
8
|
children?: React.ReactNode;
|
|
@@ -53,7 +54,7 @@ export function Collapse({
|
|
|
53
54
|
className={className}>
|
|
54
55
|
|
|
55
56
|
<Collapsible.Content
|
|
56
|
-
className={
|
|
57
|
+
className={cls(`CollapseContent-${duration}`)}
|
|
57
58
|
>
|
|
58
59
|
{children}
|
|
59
60
|
</Collapsible.Content>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ForwardRefRenderFunction } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { cls } from "../util";
|
|
3
3
|
|
|
4
4
|
export type ContainerProps = {
|
|
5
5
|
children: React.ReactNode;
|
|
@@ -37,7 +37,7 @@ const ContainerInner: ForwardRefRenderFunction<HTMLDivElement, ContainerProps> =
|
|
|
37
37
|
return (
|
|
38
38
|
<div
|
|
39
39
|
ref={ref}
|
|
40
|
-
className={
|
|
40
|
+
className={cls("mx-auto px-3 md:px-4 lg-px-6",
|
|
41
41
|
classForMaxWidth,
|
|
42
42
|
className)}
|
|
43
43
|
style={style}>
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
import React, { useRef } from "react";
|
|
2
|
-
|
|
3
|
-
import DatePicker from "react-datepicker";
|
|
2
|
+
import * as RDP from "react-datepicker"
|
|
4
3
|
|
|
5
4
|
import { CalendarMonthIcon, ClearIcon, ErrorIcon } from "../icons";
|
|
6
5
|
import { IconButton } from "./IconButton";
|
|
7
|
-
import {
|
|
8
|
-
fieldBackgroundDisabledMixin,
|
|
9
|
-
fieldBackgroundHoverMixin,
|
|
10
|
-
fieldBackgroundMixin,
|
|
11
|
-
focusedMixin,
|
|
12
|
-
paperMixin
|
|
13
|
-
} from "../styles";
|
|
6
|
+
import { fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, fieldBackgroundMixin, paperMixin } from "../styles";
|
|
14
7
|
import { InputLabel } from "./InputLabel";
|
|
15
|
-
import { cn, useInjectStyles } from "../util";
|
|
16
8
|
import { Typography } from "./Typography";
|
|
9
|
+
import { cls } from "../util";
|
|
10
|
+
import { useInjectStyles } from "../hooks";
|
|
11
|
+
|
|
12
|
+
// this fixes the issue with the default export, affecting Next.js
|
|
13
|
+
const DatePicker = (((RDP.default as any).default as any) ||
|
|
14
|
+
(RDP.default as any) ||
|
|
15
|
+
(RDP as any)) as typeof RDP.default
|
|
16
|
+
|
|
17
|
+
export type DateTimeFieldProps = {
|
|
18
|
+
value?: Date | null;
|
|
19
|
+
onChange?: (date: Date | null) => void;
|
|
17
20
|
|
|
18
|
-
interface DateTimeFieldProps {
|
|
19
|
-
value?: Date;
|
|
20
|
-
onChange: (date: Date | null) => void;
|
|
21
21
|
mode?: "date" | "date_time";
|
|
22
22
|
disabled?: boolean;
|
|
23
23
|
clearable?: boolean;
|
|
24
24
|
error?: boolean;
|
|
25
|
-
size
|
|
25
|
+
size?: "small" | "medium";
|
|
26
26
|
label?: React.ReactNode;
|
|
27
27
|
className?: string;
|
|
28
28
|
style?: React.CSSProperties;
|
|
29
29
|
inputClassName?: string;
|
|
30
30
|
invisible?: boolean;
|
|
31
|
-
preventOpenOnFocus?: boolean;
|
|
32
31
|
locale?: string;
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -40,11 +39,10 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
40
39
|
clearable,
|
|
41
40
|
mode = "date",
|
|
42
41
|
error,
|
|
43
|
-
size,
|
|
42
|
+
size = "medium",
|
|
44
43
|
className,
|
|
45
44
|
style,
|
|
46
45
|
inputClassName,
|
|
47
|
-
preventOpenOnFocus,
|
|
48
46
|
invisible,
|
|
49
47
|
locale
|
|
50
48
|
}) => {
|
|
@@ -60,14 +58,14 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
60
58
|
|
|
61
59
|
const handleClear = (e: React.MouseEvent) => {
|
|
62
60
|
e.preventDefault();
|
|
63
|
-
onChange(null);
|
|
61
|
+
onChange?.(null);
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
return (
|
|
67
65
|
<>
|
|
68
66
|
|
|
69
67
|
<div
|
|
70
|
-
className={
|
|
68
|
+
className={cls(
|
|
71
69
|
"rounded-md relative max-w-full",
|
|
72
70
|
!invisible && fieldBackgroundMixin,
|
|
73
71
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
|
@@ -80,7 +78,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
80
78
|
|
|
81
79
|
{label && (
|
|
82
80
|
<InputLabel
|
|
83
|
-
className={
|
|
81
|
+
className={cls("absolute top-1 pointer-events-none",
|
|
84
82
|
!error ? (focused ? "text-primary" : "text-text-secondary dark:text-text-secondary-dark") : "text-red-500 dark:text-red-500",
|
|
85
83
|
disabled ? "opacity-50" : "")}
|
|
86
84
|
shrink={hasValue || focused}
|
|
@@ -95,8 +93,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
95
93
|
selected={(invalidValue ? null : value) ?? null}
|
|
96
94
|
onChange={onChange}
|
|
97
95
|
disabled={false}
|
|
98
|
-
popperClassName={
|
|
99
|
-
onClick={(e: any) => e.stopPropagation()}
|
|
96
|
+
popperClassName={cls(paperMixin, "my-4 shadow")}
|
|
100
97
|
onFocus={() => setFocused(true)}
|
|
101
98
|
onBlur={() => setFocused(false)}
|
|
102
99
|
showTimeSelect={mode === "date_time"}
|
|
@@ -105,11 +102,10 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
105
102
|
timeCaption="time"
|
|
106
103
|
dateFormat={mode === "date_time" ? "Pp" : "P"}
|
|
107
104
|
preventOpenOnFocus={true}
|
|
108
|
-
className={
|
|
105
|
+
className={cls(
|
|
109
106
|
"w-full outline-none bg-transparent leading-normal text-base px-3",
|
|
110
107
|
clearable ? "pr-14" : "pr-12",
|
|
111
108
|
"rounded-md",
|
|
112
|
-
!invisible && focusedMixin,
|
|
113
109
|
size === "small" ? "min-h-[48px]" : "min-h-[64px]",
|
|
114
110
|
label ? "pt-[28px] pb-2" : "py-2",
|
|
115
111
|
inputClassName,
|
|
@@ -117,7 +113,6 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
117
113
|
)}
|
|
118
114
|
/>
|
|
119
115
|
|
|
120
|
-
|
|
121
116
|
<IconButton
|
|
122
117
|
onClick={() => {
|
|
123
118
|
// @ts-ignore
|
|
@@ -527,7 +522,7 @@ const datePickerCss = `
|
|
|
527
522
|
.react-datepicker__year-text--in-selecting-range,
|
|
528
523
|
.react-datepicker__year-text--in-range {
|
|
529
524
|
border-radius: 100%;
|
|
530
|
-
background-color: #
|
|
525
|
+
background-color: #186ef0;
|
|
531
526
|
color: #fff;
|
|
532
527
|
}
|
|
533
528
|
.react-datepicker__day--selected:hover, .react-datepicker__day--in-selecting-range:hover, .react-datepicker__day--in-range:hover,
|
|
@@ -540,22 +535,22 @@ const datePickerCss = `
|
|
|
540
535
|
.react-datepicker__year-text--selected:hover,
|
|
541
536
|
.react-datepicker__year-text--in-selecting-range:hover,
|
|
542
537
|
.react-datepicker__year-text--in-range:hover {
|
|
543
|
-
background-color: #
|
|
544
|
-
}
|
|
545
|
-
.react-datepicker__day--keyboard-selected,
|
|
546
|
-
.react-datepicker__month-text--keyboard-selected,
|
|
547
|
-
.react-datepicker__quarter-text--keyboard-selected,
|
|
548
|
-
.react-datepicker__year-text--keyboard-selected {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
.react-datepicker__day--keyboard-selected:hover,
|
|
554
|
-
.react-datepicker__month-text--keyboard-selected:hover,
|
|
555
|
-
.react-datepicker__quarter-text--keyboard-selected:hover,
|
|
556
|
-
.react-datepicker__year-text--keyboard-selected:hover {
|
|
557
|
-
|
|
558
|
-
}
|
|
538
|
+
background-color: #5698f9;
|
|
539
|
+
}
|
|
540
|
+
// .react-datepicker__day--keyboard-selected,
|
|
541
|
+
// .react-datepicker__month-text--keyboard-selected,
|
|
542
|
+
// .react-datepicker__quarter-text--keyboard-selected,
|
|
543
|
+
// .react-datepicker__year-text--keyboard-selected {
|
|
544
|
+
// border-radius: 100%;
|
|
545
|
+
// background-color: #5193f6;
|
|
546
|
+
// color: rgb(0, 0, 0);
|
|
547
|
+
// }
|
|
548
|
+
// .react-datepicker__day--keyboard-selected:hover,
|
|
549
|
+
// .react-datepicker__month-text--keyboard-selected:hover,
|
|
550
|
+
// .react-datepicker__quarter-text--keyboard-selected:hover,
|
|
551
|
+
// .react-datepicker__year-text--keyboard-selected:hover {
|
|
552
|
+
// background-color: #5193f6;
|
|
553
|
+
// }
|
|
559
554
|
.react-datepicker__day--in-selecting-range:not(.react-datepicker__day--in-range,
|
|
560
555
|
.react-datepicker__month-text--in-range,
|
|
561
556
|
.react-datepicker__quarter-text--in-range,
|
|
@@ -838,7 +833,7 @@ const datePickerCss = `
|
|
|
838
833
|
:is([data-theme="dark"]) .react-datepicker__month-read-view--down-arrow,
|
|
839
834
|
:is([data-theme="dark"]) .react-datepicker__month-year-read-view--down-arrow,
|
|
840
835
|
:is([data-theme="dark"]) .react-datepicker__navigation-icon::before {
|
|
841
|
-
border-color: #
|
|
836
|
+
border-color: #999;
|
|
842
837
|
}
|
|
843
838
|
|
|
844
839
|
|
|
@@ -912,7 +907,7 @@ const datePickerCss = `
|
|
|
912
907
|
:is([data-theme="dark"]) .react-datepicker__year-text--selected:hover,
|
|
913
908
|
:is([data-theme="dark"]) .react-datepicker__time-container .react-datepicker__time .react-datepicker__time-box ul.react-datepicker__time-list li.react-datepicker__time-list-item:hover
|
|
914
909
|
{
|
|
915
|
-
background-color: #
|
|
910
|
+
background-color: #262626;
|
|
916
911
|
}
|
|
917
912
|
|
|
918
913
|
:is([data-theme="dark"]) .react-datepicker__day--selected,
|
|
@@ -930,12 +925,12 @@ const datePickerCss = `
|
|
|
930
925
|
background-color: #0e528f;
|
|
931
926
|
}
|
|
932
927
|
|
|
933
|
-
:is([data-theme="dark"]) .react-datepicker__day--keyboard-selected,
|
|
934
|
-
:is([data-theme="dark"]) .react-datepicker__month-text--keyboard-selected,
|
|
935
|
-
:is([data-theme="dark"]) .react-datepicker__quarter-text--keyboard-selected,
|
|
936
|
-
:is([data-theme="dark"]) .react-datepicker__year-text--keyboard-selected {
|
|
937
|
-
|
|
938
|
-
}
|
|
928
|
+
// :is([data-theme="dark"]) .react-datepicker__day--keyboard-selected,
|
|
929
|
+
// :is([data-theme="dark"]) .react-datepicker__month-text--keyboard-selected,
|
|
930
|
+
// :is([data-theme="dark"]) .react-datepicker__quarter-text--keyboard-selected,
|
|
931
|
+
// :is([data-theme="dark"]) .react-datepicker__year-text--keyboard-selected {
|
|
932
|
+
// background-color: #0e529f;
|
|
933
|
+
// }
|
|
939
934
|
|
|
940
935
|
:is([data-theme="dark"]) .react-datepicker__today-button {
|
|
941
936
|
background-color: #262626;
|