@firecms/ui 3.0.0-canary.4 → 3.0.0-canary.41
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 +2 -2
- package/dist/components/Button.d.ts +1 -1
- 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 +1 -1
- package/dist/components/DateTimeField.d.ts +2 -2
- package/dist/components/Dialog.d.ts +2 -1
- package/dist/components/Label.d.ts +4 -0
- package/dist/components/Markdown.d.ts +1 -0
- package/dist/components/Menu.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +27 -0
- package/dist/components/TextareaAutosize.d.ts +4 -2
- package/dist/components/Tooltip.d.ts +2 -1
- package/dist/components/index.d.ts +2 -0
- 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 +7701 -7613
- 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 +5 -5
- package/dist/util/index.d.ts +0 -2
- package/package.json +27 -21
- package/src/components/Alert.tsx +2 -2
- package/src/components/Autocomplete.tsx +2 -1
- package/src/components/BooleanSwitch.tsx +2 -2
- package/src/components/Button.tsx +10 -18
- package/src/components/Card.tsx +16 -10
- package/src/components/CenteredView.tsx +25 -13
- package/src/components/Checkbox.tsx +34 -23
- package/src/components/Chip.tsx +3 -3
- package/src/components/Collapse.tsx +2 -1
- package/src/components/DateTimeField.tsx +6 -5
- package/src/components/Dialog.tsx +4 -1
- package/src/components/ExpandablePanel.tsx +5 -3
- package/src/components/FileUpload.tsx +1 -1
- package/src/components/IconButton.tsx +2 -2
- package/src/components/InputLabel.tsx +8 -7
- package/src/components/Label.tsx +18 -0
- package/src/components/Markdown.tsx +14 -3
- package/src/components/Menu.tsx +11 -5
- package/src/components/MultiSelect.tsx +2 -1
- package/src/components/Popover.tsx +2 -1
- package/src/components/RadioGroup.tsx +72 -0
- package/src/components/SearchBar.tsx +1 -1
- package/src/components/Select.tsx +21 -21
- package/src/components/Table.tsx +1 -1
- package/src/components/Tabs.tsx +2 -2
- package/src/components/TextField.tsx +1 -1
- package/src/components/TextareaAutosize.tsx +1 -1
- package/src/components/Tooltip.tsx +5 -1
- package/src/components/Typography.tsx +1 -1
- package/src/components/index.tsx +2 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useLocaleConfig.tsx +18 -0
- package/src/icons/Icon.tsx +43 -40
- package/src/index.ts +1 -0
- package/src/styles.ts +5 -5
- package/src/util/index.ts +0 -2
- package/tailwind.config.js +70 -0
- /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
package/dist/styles.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
export declare const focusedMixin = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent";
|
2
2
|
export declare const focusedInvisibleMixin = "focus:bg-opacity-70 focus:bg-slate-100 focus:dark:bg-gray-800 focus:dark:bg-opacity-60";
|
3
3
|
export declare const focusedClasses = "z-30 outline-none ring-2 ring-primary ring-opacity-75 ring-offset-2 ring-offset-transparent ";
|
4
|
-
export declare const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-
|
4
|
+
export declare const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-700 dark:bg-opacity-40 transition duration-150 ease-in-out";
|
5
5
|
export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0 transition duration-150 ease-in-out";
|
6
|
-
export declare const fieldBackgroundDisabledMixin = "bg-opacity-80 dark:bg-opacity-90";
|
7
|
-
export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-opacity-
|
6
|
+
export declare const fieldBackgroundDisabledMixin = "dark:bg-gray-800 bg-opacity-80 dark:bg-opacity-90";
|
7
|
+
export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-opacity-60";
|
8
8
|
export declare const defaultBorderMixin = "border-gray-100 dark:border-gray-800 dark:border-opacity-80";
|
9
|
-
export declare const paperMixin = "bg-white rounded-md dark:bg-gray-950 border dark:border-gray-800 dark:border-opacity-
|
10
|
-
export declare const cardMixin = "bg-white rounded-md dark:bg-gray-950 dark:border-gray-800 dark:border-opacity-50 transition duration-200 ease-in-out m-1 -p-1
|
9
|
+
export declare const paperMixin = "bg-white rounded-md dark:bg-gray-950 border dark:border-gray-800 dark:border-opacity-80 border-gray-100";
|
10
|
+
export declare const cardMixin = "bg-white border border-gray-100 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-800 dark:border-opacity-50 transition duration-200 ease-in-out m-1 -p-1";
|
11
11
|
export declare const cardClickableMixin = "hover:bg-primary-bg dark:hover:bg-primary-bg hover:bg-opacity-20 dark:hover:bg-opacity-20 hover:ring-2 hover:ring-primary cursor-pointer";
|
12
12
|
export declare const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 dark:bg-opacity-10 ring-1 ring-primary ring-opacity-75";
|
package/dist/util/index.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@firecms/ui",
|
3
3
|
"type": "module",
|
4
|
-
"version": "3.0.0-canary.
|
4
|
+
"version": "3.0.0-canary.41",
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
6
6
|
"funding": {
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
@@ -31,9 +31,10 @@
|
|
31
31
|
".": {
|
32
32
|
"import": "./dist/index.es.js",
|
33
33
|
"require": "./dist/index.umd.js",
|
34
|
-
"types": "./dist/
|
34
|
+
"types": "./dist/index.d.ts"
|
35
35
|
},
|
36
|
-
"./package.json": "./package.json"
|
36
|
+
"./package.json": "./package.json",
|
37
|
+
"./tailwind.config.js": "./tailwind.config.js"
|
37
38
|
},
|
38
39
|
"scripts": {
|
39
40
|
"watch": "vite build --watch",
|
@@ -51,19 +52,23 @@
|
|
51
52
|
"@radix-ui/react-collapsible": "^1.0.3",
|
52
53
|
"@radix-ui/react-dialog": "^1.0.5",
|
53
54
|
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
55
|
+
"@radix-ui/react-label": "^2.0.2",
|
54
56
|
"@radix-ui/react-popover": "^1.0.7",
|
55
57
|
"@radix-ui/react-portal": "^1.0.4",
|
58
|
+
"@radix-ui/react-radio-group": "^1.1.3",
|
56
59
|
"@radix-ui/react-scroll-area": "^1.0.5",
|
57
|
-
"@radix-ui/react-select": "^
|
60
|
+
"@radix-ui/react-select": "^2.0.0",
|
58
61
|
"@radix-ui/react-separator": "^1.0.3",
|
59
62
|
"@radix-ui/react-switch": "^1.0.3",
|
60
63
|
"@radix-ui/react-tabs": "^1.0.4",
|
61
64
|
"@radix-ui/react-tooltip": "^1.0.7",
|
65
|
+
"clsx": "^2.1.0",
|
62
66
|
"cmdk": "^0.2.1",
|
63
|
-
"
|
67
|
+
"date-fns": "^3.6.0",
|
68
|
+
"react-datepicker": "^6.4.0",
|
64
69
|
"react-dropzone": "^14.2.3",
|
65
70
|
"react-fast-compare": "^3.2.2",
|
66
|
-
"tailwind-merge": "^2.2.
|
71
|
+
"tailwind-merge": "^2.2.2"
|
67
72
|
},
|
68
73
|
"peerDependencies": {
|
69
74
|
"react": "^18.2.0",
|
@@ -77,40 +82,41 @@
|
|
77
82
|
},
|
78
83
|
"devDependencies": {
|
79
84
|
"@jest/globals": "^29.7.0",
|
80
|
-
"@testing-library/jest-dom": "^
|
85
|
+
"@testing-library/jest-dom": "^6.4.2",
|
81
86
|
"@testing-library/react": "^14.2.1",
|
82
87
|
"@testing-library/user-event": "^14.5.2",
|
83
88
|
"@types/jest": "^29.5.12",
|
84
|
-
"@types/node": "^20.11.
|
89
|
+
"@types/node": "^20.11.30",
|
85
90
|
"@types/object-hash": "^3.0.6",
|
86
|
-
"@types/react": "^18.2.
|
87
|
-
"@types/react-dom": "^18.2.
|
91
|
+
"@types/react": "^18.2.67",
|
92
|
+
"@types/react-dom": "^18.2.22",
|
88
93
|
"@types/react-measure": "^2.0.12",
|
89
|
-
"@typescript-eslint/eslint-plugin": "^
|
90
|
-
"@typescript-eslint/parser": "^
|
94
|
+
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
95
|
+
"@typescript-eslint/parser": "^7.3.1",
|
91
96
|
"@vitejs/plugin-react": "^4.2.1",
|
92
97
|
"cross-env": "^7.0.3",
|
93
|
-
"eslint": "^8.
|
98
|
+
"eslint": "^8.57.0",
|
94
99
|
"eslint-config-standard": "^17.1.0",
|
95
100
|
"eslint-plugin-import": "^2.29.1",
|
96
|
-
"eslint-plugin-n": "^
|
101
|
+
"eslint-plugin-n": "^16.6.2",
|
97
102
|
"eslint-plugin-promise": "^6.1.1",
|
98
|
-
"eslint-plugin-react": "^7.
|
103
|
+
"eslint-plugin-react": "^7.34.1",
|
99
104
|
"eslint-plugin-react-hooks": "^4.6.0",
|
100
|
-
"firebase": "^10.
|
105
|
+
"firebase": "^10.9.0",
|
101
106
|
"jest": "^29.7.0",
|
102
107
|
"npm-run-all": "^4.1.5",
|
103
108
|
"ts-jest": "^29.1.2",
|
104
109
|
"ts-node": "^10.9.2",
|
105
|
-
"tsd": "^0.30.
|
106
|
-
"typescript": "^5.
|
107
|
-
"vite": "^5.
|
110
|
+
"tsd": "^0.30.7",
|
111
|
+
"typescript": "^5.4.2",
|
112
|
+
"vite": "^5.2.3"
|
108
113
|
},
|
109
114
|
"files": [
|
110
115
|
"dist",
|
111
|
-
"src"
|
116
|
+
"src",
|
117
|
+
"tailwind.config.js"
|
112
118
|
],
|
113
|
-
"gitHead": "
|
119
|
+
"gitHead": "d1ffa185f8930bab4e7b9941ba551c53f947aa1f",
|
114
120
|
"publishConfig": {
|
115
121
|
"access": "public"
|
116
122
|
}
|
package/src/components/Alert.tsx
CHANGED
@@ -29,12 +29,12 @@ const getColorClasses = (severity: string) => {
|
|
29
29
|
case "warning":
|
30
30
|
return "bg-amber-50 dark:bg-amber-800 dark:text-amber-100 text-amber-900";
|
31
31
|
case "info":
|
32
|
-
return "bg-blue-
|
32
|
+
return "bg-blue-100 dark:bg-blue-800 dark:text-blue-100 text-blue-900";
|
33
33
|
case "success":
|
34
34
|
return "bg-emerald-50 dark:bg-emerald-800 dark:text-emerald-100 text-emerald-900";
|
35
35
|
case "base":
|
36
36
|
default:
|
37
|
-
return "bg-slate-50 dark:bg-slate-800 dark:text-
|
37
|
+
return "bg-slate-50 dark:bg-slate-800 dark:text-white text-slate-900";
|
38
38
|
}
|
39
39
|
};
|
40
40
|
|
@@ -2,7 +2,8 @@ import React from "react";
|
|
2
2
|
|
3
3
|
import { paperMixin } from "../styles";
|
4
4
|
import { Collapse } from "./Collapse";
|
5
|
-
import { cn
|
5
|
+
import { cn } from "../util";
|
6
|
+
import { useOutsideAlerter } from "../hooks";
|
6
7
|
|
7
8
|
export type AutocompleteProps = {
|
8
9
|
children: React.ReactNode;
|
@@ -43,8 +43,8 @@ export const BooleanSwitch = React.forwardRef(function BooleanSwitch({
|
|
43
43
|
size === "small" ? "w-[38px] h-[22px] min-w-[38px] min-h-[22px]" : "w-[42px] h-[26px] min-w-[42px] min-h-[26px]",
|
44
44
|
"outline-none rounded-full relative shadow-sm",
|
45
45
|
value ? (disabled
|
46
|
-
? "bg-white bg-opacity-54 dark:bg-slate-950 border-slate-100 dark:border-slate-700 ring-1 ring-slate-
|
47
|
-
: "ring-secondary ring-1 bg-secondary dark:bg-secondary") : "bg-white bg-opacity-54 dark:bg-slate-900 ring-1 ring-slate-
|
46
|
+
? "bg-white bg-opacity-54 dark:bg-slate-950 border-slate-100 dark:border-slate-700 ring-1 ring-slate-200 dark:ring-slate-700"
|
47
|
+
: "ring-secondary ring-1 bg-secondary dark:bg-secondary") : "bg-white bg-opacity-54 dark:bg-slate-900 ring-1 ring-slate-200 dark:ring-slate-700",
|
48
48
|
className
|
49
49
|
)}
|
50
50
|
{...props}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from "react";
|
2
2
|
|
3
|
-
import {focusedMixin} from "../styles";
|
4
|
-
import {cn} from "../util";
|
3
|
+
import { focusedMixin } from "../styles";
|
4
|
+
import { cn } from "../util";
|
5
5
|
|
6
6
|
export type ButtonProps<P extends React.ElementType> =
|
7
7
|
Omit<(P extends "button" ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.ComponentProps<P>), "onClick">
|
@@ -9,7 +9,7 @@ export type ButtonProps<P extends React.ElementType> =
|
|
9
9
|
variant?: "filled" | "outlined" | "text";
|
10
10
|
disabled?: boolean;
|
11
11
|
color?: "primary" | "secondary" | "text" | "error";
|
12
|
-
size?: "small" | "medium" | "large";
|
12
|
+
size?: "small" | "medium" | "large" | "xl" | "2xl";
|
13
13
|
startIcon?: React.ReactNode;
|
14
14
|
fullWidth?: boolean;
|
15
15
|
className?: string;
|
@@ -34,18 +34,6 @@ const ButtonInner = React.forwardRef<
|
|
34
34
|
const baseClasses =
|
35
35
|
"h-fit rounded-md uppercase inline-flex items-center justify-center p-2 px-4 text-sm font-medium focus:outline-none transition ease-in-out duration-150 gap-2";
|
36
36
|
|
37
|
-
// const buttonClasses = cn(
|
38
|
-
// {
|
39
|
-
// "w-full": fullWidth,
|
40
|
-
// "w-fit": !fullWidth,
|
41
|
-
// "border-transparent bg-primary hover:bg-primary-dark focus:ring-primary !text-white shadow hover:ring-1 hover:ring-primary": variant === "filled" && !disabled,
|
42
|
-
// "border-transparent !text-primary !hover:text-primary-dark hover:bg-primary hover:bg-primary-bg": variant === "text" && !disabled,
|
43
|
-
// "border-primary !text-primary hover:bg-primary-bg hover:border-primary-dark !hover:text-primary-dark focus:ring-primary hover:ring-1 hover:ring-primary": variant === "outlined" && !disabled,
|
44
|
-
// "border-primary-dark border-opacity-50 dark:border-primary dark:border-opacity-50 opacity-50 !text-primary-dark !dark:text-primary text-opacity-50 dark:text-opacity-50": variant === "outlined" && disabled,
|
45
|
-
// "border-transparent outline-none opacity-50 !text-slate-600 !dark:text-slate-500": (variant === "filled" || variant === "text") && disabled
|
46
|
-
// }
|
47
|
-
// );
|
48
|
-
|
49
37
|
const buttonClasses = cn({
|
50
38
|
"w-full": fullWidth,
|
51
39
|
"w-fit": !fullWidth,
|
@@ -62,17 +50,21 @@ const ButtonInner = React.forwardRef<
|
|
62
50
|
// Outlined Variants
|
63
51
|
"border border-primary text-primary hover:bg-primary-bg": variant === "outlined" && color === "primary" && !disabled,
|
64
52
|
"border border-secondary text-secondary hover:bg-secondary-bg": variant === "outlined" && color === "secondary" && !disabled,
|
65
|
-
"border border-red-500 text-red-500 hover:bg-red-500": variant === "outlined" && color === "error" && !disabled,
|
53
|
+
"border border-red-500 text-red-500 hover:bg-red-500 hover:text-white": variant === "outlined" && color === "error" && !disabled,
|
66
54
|
"border border-slate-400 text-text-primary dark:text-text-primary-dark hover:bg-slate-200": variant === "outlined" && color === "text" && !disabled,
|
67
55
|
// Disabled states for all variants
|
68
|
-
"border border-transparent opacity-50": disabled
|
56
|
+
"border border-transparent opacity-50": variant === "text" && disabled,
|
57
|
+
"border border-gray-500 opacity-50": variant === "outlined" && disabled,
|
58
|
+
"border border-gray-500 bg-gray-500 opacity-50": variant === "filled" && disabled,
|
69
59
|
});
|
70
60
|
|
71
61
|
const sizeClasses = cn(
|
72
62
|
{
|
73
63
|
"py-1 px-2": size === "small",
|
74
64
|
"py-2 px-4": size === "medium",
|
75
|
-
"py-2.5 px-5": size === "large"
|
65
|
+
"py-2.5 px-5": size === "large",
|
66
|
+
"py-3 px-6": size === "xl",
|
67
|
+
"py-4 px-10": size === "2xl",
|
76
68
|
}
|
77
69
|
);
|
78
70
|
|
package/src/components/Card.tsx
CHANGED
@@ -2,18 +2,20 @@ import React, { useCallback } from "react";
|
|
2
2
|
import { cardClickableMixin, cardMixin, focusedMixin } from "../styles";
|
3
3
|
import { cn } 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
32
|
className={cn(cardMixin, onClick && focusedMixin, onClick && cardClickableMixin, className)}
|
30
|
-
style={style}
|
33
|
+
style={style}
|
34
|
+
{...props}>
|
31
35
|
{children}
|
32
36
|
</div>
|
33
|
-
)
|
34
|
-
}
|
37
|
+
);
|
38
|
+
});
|
39
|
+
|
40
|
+
export { Card };
|
@@ -2,21 +2,33 @@ import React from "react";
|
|
2
2
|
import { Container } from "./Container";
|
3
3
|
import { cn } 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={cn("flex flex-col flex-grow", fullScreen ? "h-screen" : "h-full", outerClassName)}
|
25
|
+
{...rest}>
|
26
|
+
<Container className={cn("m-auto", className)} maxWidth={maxWidth}>
|
27
|
+
{children}
|
28
|
+
</Container>
|
29
|
+
</div>
|
30
|
+
);
|
31
|
+
|
32
|
+
});
|
33
|
+
|
34
|
+
CenteredView.displayName = "CenteredView";
|
@@ -4,25 +4,35 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
4
4
|
import { Icon } from "../icons";
|
5
5
|
import { cn } 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?: "tiny" | "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
|
+
tiny: "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
|
+
tiny: "w-6 h-6"
|
30
|
+
}
|
31
|
+
const paddingClasses = {
|
32
|
+
medium: "p-2",
|
33
|
+
small: "p-2",
|
34
|
+
large: "p-2",
|
35
|
+
tiny: ""
|
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,19 +57,23 @@ export const Checkbox = ({
|
|
45
57
|
? 20
|
46
58
|
: size === "small"
|
47
59
|
? 16
|
48
|
-
:
|
60
|
+
: size === "tiny"
|
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={cn(
|
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
78
|
className={cn(
|
63
79
|
"border-2 relative transition-colors ease-in-out duration-150",
|
@@ -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
@@ -11,7 +11,7 @@ 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?: "tiny" | "small" | "medium";
|
15
15
|
colorScheme?: ChipColorScheme | ChipColorKey;
|
16
16
|
error?: boolean;
|
17
17
|
outlined?: boolean;
|
@@ -20,7 +20,7 @@ export interface ChipProps {
|
|
20
20
|
}
|
21
21
|
|
22
22
|
const sizeClassNames = {
|
23
|
-
|
23
|
+
tiny: "px-2 py-0.5 text-sm",
|
24
24
|
small: "px-3 py-1 text-sm",
|
25
25
|
medium: "px-4 py-1.5 text-sm"
|
26
26
|
}
|
@@ -46,7 +46,7 @@ export function Chip({
|
|
46
46
|
"text-ellipsis",
|
47
47
|
onClick ? "cursor-pointer hover:bg-slate-300 hover:dark:bg-slate-700" : "",
|
48
48
|
sizeClassNames[size],
|
49
|
-
error || !usedColorScheme ? "bg-slate-200 dark:bg-slate-800 text-slate-800 dark:text-
|
49
|
+
error || !usedColorScheme ? "bg-slate-200 dark:bg-slate-800 text-slate-800 dark:text-white" : "",
|
50
50
|
error ? "text-red-500 dark:text-red-400" : "",
|
51
51
|
className)}
|
52
52
|
onClick={onClick}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import * as Collapsible from "@radix-ui/react-collapsible";
|
3
3
|
|
4
|
-
import { cn
|
4
|
+
import { cn } from "../util";
|
5
|
+
import { useInjectStyles } from "../hooks";
|
5
6
|
|
6
7
|
interface CollapseProps {
|
7
8
|
children?: React.ReactNode;
|
@@ -12,17 +12,18 @@ import {
|
|
12
12
|
paperMixin
|
13
13
|
} from "../styles";
|
14
14
|
import { InputLabel } from "./InputLabel";
|
15
|
-
import { cn, useInjectStyles } from "../util";
|
16
15
|
import { Typography } from "./Typography";
|
16
|
+
import { cn } from "../util";
|
17
|
+
import { useInjectStyles } from "../hooks";
|
17
18
|
|
18
19
|
interface DateTimeFieldProps {
|
19
20
|
value?: Date;
|
20
|
-
onChange: (date: Date |
|
21
|
+
onChange: (date: Date | undefined) => void;
|
21
22
|
mode?: "date" | "date_time";
|
22
23
|
disabled?: boolean;
|
23
24
|
clearable?: boolean;
|
24
25
|
error?: boolean;
|
25
|
-
size
|
26
|
+
size?: "small" | "medium";
|
26
27
|
label?: React.ReactNode;
|
27
28
|
className?: string;
|
28
29
|
style?: React.CSSProperties;
|
@@ -40,7 +41,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
40
41
|
clearable,
|
41
42
|
mode = "date",
|
42
43
|
error,
|
43
|
-
size,
|
44
|
+
size = "medium",
|
44
45
|
className,
|
45
46
|
style,
|
46
47
|
inputClassName,
|
@@ -60,7 +61,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
60
61
|
|
61
62
|
const handleClear = (e: React.MouseEvent) => {
|
62
63
|
e.preventDefault();
|
63
|
-
onChange(
|
64
|
+
onChange(undefined);
|
64
65
|
}
|
65
66
|
|
66
67
|
return (
|
@@ -14,6 +14,7 @@ export type DialogProps = {
|
|
14
14
|
scrollable?: boolean;
|
15
15
|
maxWidth?: keyof typeof widthClasses;
|
16
16
|
modal?: boolean;
|
17
|
+
onOpenAutoFocus?: (e: Event) => void;
|
17
18
|
};
|
18
19
|
|
19
20
|
const widthClasses = {
|
@@ -41,7 +42,8 @@ export const Dialog = ({
|
|
41
42
|
fullScreen,
|
42
43
|
scrollable = true,
|
43
44
|
maxWidth = "lg",
|
44
|
-
modal = true
|
45
|
+
modal = true,
|
46
|
+
onOpenAutoFocus
|
45
47
|
}: DialogProps) => {
|
46
48
|
const [displayed, setDisplayed] = useState(false);
|
47
49
|
|
@@ -77,6 +79,7 @@ export const Dialog = ({
|
|
77
79
|
/>
|
78
80
|
|
79
81
|
<DialogPrimitive.Content
|
82
|
+
onOpenAutoFocus={onOpenAutoFocus}
|
80
83
|
className={cn("h-full outline-none flex justify-center items-center z-40 opacity-100 transition-all duration-200 ease-in-out")}
|
81
84
|
>
|
82
85
|
<div
|
@@ -3,7 +3,8 @@ import React, { PropsWithChildren, useEffect, useState } from "react";
|
|
3
3
|
import * as Collapsible from "@radix-ui/react-collapsible";
|
4
4
|
import { defaultBorderMixin, fieldBackgroundMixin, focusedMixin } from "../styles";
|
5
5
|
import { ExpandMoreIcon } from "../icons";
|
6
|
-
import { cn
|
6
|
+
import { cn } from "../util";
|
7
|
+
import { useInjectStyles } from "../hooks";
|
7
8
|
|
8
9
|
export function ExpandablePanel({
|
9
10
|
title,
|
@@ -77,7 +78,8 @@ export function ExpandablePanel({
|
|
77
78
|
<Collapsible.Root
|
78
79
|
className={cn(
|
79
80
|
!invisible && defaultBorderMixin + " border",
|
80
|
-
"rounded-md"
|
81
|
+
"rounded-md",
|
82
|
+
"w-full"
|
81
83
|
)}
|
82
84
|
open={open}
|
83
85
|
onOpenChange={(updatedOpen: boolean) => {
|
@@ -88,7 +90,7 @@ export function ExpandablePanel({
|
|
88
90
|
<Collapsible.Trigger
|
89
91
|
className={cn(focusedMixin,
|
90
92
|
"rounded flex items-center justify-between w-full min-h-[52px]",
|
91
|
-
"hover:bg-
|
93
|
+
"hover:bg-slate-50 dark:hover:bg-gray-800 dark:hover:bg-opacity-10",
|
92
94
|
invisible ? "border-b px-2" : "p-4",
|
93
95
|
invisible && defaultBorderMixin,
|
94
96
|
asField && fieldBackgroundMixin,
|
@@ -18,7 +18,7 @@ const buttonClasses =
|
|
18
18
|
"hover:bg-slate-200 hover:bg-opacity-75 dark:hover:bg-gray-700 dark:hover:bg-opacity-50";
|
19
19
|
const baseClasses =
|
20
20
|
"inline-flex items-center justify-center p-2 text-sm font-medium focus:outline-none transition-colors ease-in-out duration-150";
|
21
|
-
const colorClasses = "text-slate-600 visited:text-slate-600 dark:text-slate-300 dark:visited:text-
|
21
|
+
const colorClasses = "text-slate-600 visited:text-slate-600 dark:text-slate-300 dark:visited:text-gray-300";
|
22
22
|
const sizeClasses = {
|
23
23
|
medium: "w-10 !h-10 min-w-10 min-h-10",
|
24
24
|
small: "w-8 !h-8 min-w-8 min-h-8",
|
@@ -42,7 +42,7 @@ const IconButtonInner = <C extends React.ElementType = "button">({
|
|
42
42
|
...props
|
43
43
|
}: IconButtonProps<C>, ref: React.ForwardedRef<HTMLButtonElement>) => {
|
44
44
|
|
45
|
-
const bgClasses = variant === "ghost" ? "bg-transparent" : "bg-slate-50 dark:bg-gray-950 dark:bg-opacity-50";
|
45
|
+
const bgClasses = variant === "ghost" ? "bg-transparent" : "bg-slate-200 bg-opacity-50 dark:bg-gray-950 dark:bg-opacity-50";
|
46
46
|
const Component: React.ElementType<any> = component || "button";
|
47
47
|
return (
|
48
48
|
<Component
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import * as React from "react";
|
2
2
|
import { cn } from "../util";
|
3
|
+
import { Label } from "./Label";
|
3
4
|
|
4
5
|
export type InputLabelProps = {
|
5
6
|
children?: React.ReactNode;
|
@@ -7,6 +8,12 @@ export type InputLabelProps = {
|
|
7
8
|
shrink?: boolean;
|
8
9
|
} & React.LabelHTMLAttributes<HTMLLabelElement>;
|
9
10
|
|
11
|
+
const defaultClasses = {
|
12
|
+
root: "origin-left transition-transform block whitespace-nowrap overflow-hidden text-overflow-ellipsis max-w-full",
|
13
|
+
shrink: "transform translate-y-[2px] scale-75 translate-x-[12px]",
|
14
|
+
expanded: "translate-x-[16px] top-0 transform translate-y-[16px] scale-100"
|
15
|
+
};
|
16
|
+
|
10
17
|
export const InputLabel = React.forwardRef<HTMLLabelElement, InputLabelProps>(function InputLabel(inProps, ref) {
|
11
18
|
const {
|
12
19
|
shrink,
|
@@ -14,12 +21,6 @@ export const InputLabel = React.forwardRef<HTMLLabelElement, InputLabelProps>(fu
|
|
14
21
|
...other
|
15
22
|
} = inProps;
|
16
23
|
|
17
|
-
const defaultClasses = {
|
18
|
-
root: "origin-left transition-transform block whitespace-nowrap overflow-hidden text-overflow-ellipsis max-w-full",
|
19
|
-
shrink: "transform translate-y-[2px] scale-75 translate-x-[12px]",
|
20
|
-
expanded: "translate-x-[16px] top-0 transform translate-y-[16px] scale-100"
|
21
|
-
};
|
22
|
-
|
23
24
|
const computedClassName = cn(defaultClasses.root,
|
24
25
|
{
|
25
26
|
[defaultClasses.shrink]: shrink,
|
@@ -27,7 +28,7 @@ export const InputLabel = React.forwardRef<HTMLLabelElement, InputLabelProps>(fu
|
|
27
28
|
}, className);
|
28
29
|
|
29
30
|
return (
|
30
|
-
<
|
31
|
+
<Label
|
31
32
|
data-shrink={shrink}
|
32
33
|
ref={ref}
|
33
34
|
className={computedClassName}
|