@firecms/ui 3.0.0-canary.14 → 3.0.0-canary.141
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 +3 -3
- 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 +5 -7
- package/dist/components/Dialog.d.ts +4 -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/InputLabel.d.ts +2 -2
- package/dist/components/Label.d.ts +4 -1
- package/dist/components/Markdown.d.ts +1 -0
- package/dist/components/Menu.d.ts +6 -2
- package/dist/components/Menubar.d.ts +79 -0
- package/dist/components/MultiSelect.d.ts +31 -16
- package/dist/components/Popover.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +26 -3
- package/dist/components/Select.d.ts +6 -10
- package/dist/components/Separator.d.ts +2 -1
- 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 +1 -1
- package/dist/components/TextareaAutosize.d.ts +3 -34
- package/dist/components/Tooltip.d.ts +6 -2
- package/dist/components/Typography.d.ts +5 -4
- package/dist/components/index.d.ts +3 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/icons/Icon.d.ts +3 -3
- package/dist/index.css +73 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +13371 -14447
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19782 -857
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +8 -8
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +111 -118
- package/src/components/Alert.tsx +2 -2
- package/src/components/Autocomplete.tsx +5 -3
- package/src/components/Avatar.tsx +8 -7
- package/src/components/Badge.tsx +1 -1
- package/src/components/BooleanSwitch.tsx +15 -15
- package/src/components/BooleanSwitchWithLabel.tsx +9 -8
- package/src/components/Button.tsx +18 -20
- package/src/components/Card.tsx +4 -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 +4 -2
- package/src/components/Container.tsx +2 -2
- package/src/components/DateTimeField.tsx +142 -921
- package/src/components/DebouncedTextField.tsx +1 -0
- package/src/components/Dialog.tsx +16 -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 +20 -12
- package/src/components/FileUpload.tsx +8 -10
- package/src/components/IconButton.tsx +4 -6
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +11 -9
- package/src/components/Label.tsx +17 -4
- package/src/components/Markdown.tsx +15 -3
- package/src/components/Menu.tsx +49 -31
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +336 -165
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +18 -14
- package/src/components/RadioGroup.tsx +41 -9
- package/src/components/SearchBar.tsx +9 -9
- package/src/components/Select.tsx +97 -124
- package/src/components/Separator.tsx +10 -4
- package/src/components/Sheet.tsx +52 -30
- package/src/components/Skeleton.tsx +9 -6
- package/src/components/Slider.tsx +109 -0
- package/src/components/Table.tsx +50 -33
- package/src/components/Tabs.tsx +6 -7
- package/src/components/TextField.tsx +14 -16
- package/src/components/TextareaAutosize.tsx +4 -3
- package/src/components/Tooltip.tsx +31 -14
- package/src/components/Typography.tsx +42 -26
- package/src/components/common/SelectInputLabel.tsx +2 -2
- package/src/components/index.tsx +3 -1
- package/src/hooks/index.ts +3 -0
- package/src/icons/Icon.tsx +46 -43
- package/src/icons/icon_keys.ts +114 -1301
- package/src/index.css +73 -0
- package/src/index.ts +1 -0
- package/src/scripts/generateIconKeys.ts +20 -11
- package/src/styles.ts +8 -8
- package/src/util/cls.ts +14 -0
- package/src/util/index.ts +1 -3
- package/tailwind.config.js +8 -6
- 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
package/dist/styles.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
export declare const
|
1
|
+
export declare const focusedDisabled = "focus-visible:ring-0 focus-visible:ring-offset-0";
|
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-800 dark:bg-opacity-60
|
5
|
-
export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0
|
6
|
-
export declare const fieldBackgroundDisabledMixin = "bg-opacity-
|
7
|
-
export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-opacity-
|
8
|
-
export declare const defaultBorderMixin = "border-gray-
|
9
|
-
export declare const paperMixin = "bg-white rounded-md dark:bg-gray-950 border
|
10
|
-
export declare const cardMixin = "bg-white rounded-md dark:bg-gray-950 dark:border-gray-
|
4
|
+
export declare const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-800 dark:bg-opacity-60";
|
5
|
+
export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0";
|
6
|
+
export declare const fieldBackgroundDisabledMixin = "dark:bg-gray-800 bg-opacity-50 dark:bg-opacity-90";
|
7
|
+
export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-gray-700 dark:hover:bg-opacity-40";
|
8
|
+
export declare const defaultBorderMixin = "border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-40";
|
9
|
+
export declare const paperMixin = "bg-white rounded-md dark:bg-gray-950 border border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-40";
|
10
|
+
export declare const cardMixin = "bg-white border border-gray-200 border-opacity-40 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-700 dark:border-opacity-40 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,121 +1,114 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
"name": "@firecms/ui",
|
3
|
+
"type": "module",
|
4
|
+
"version": "3.0.0-canary.141",
|
5
|
+
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
6
|
+
"funding": {
|
7
|
+
"url": "https://github.com/sponsors/firecmsco"
|
8
|
+
},
|
9
|
+
"author": "FireCMS",
|
10
|
+
"license": "MIT",
|
11
|
+
"repository": "git@github.com:FireCMSco/firecms.git",
|
12
|
+
"main": "./dist/index.umd.js",
|
13
|
+
"module": "./dist/index.es.js",
|
14
|
+
"types": "./dist/index.d.ts",
|
15
|
+
"source": "src/index.ts",
|
16
|
+
"engines": {
|
17
|
+
"node": ">=14"
|
18
|
+
},
|
19
|
+
"keywords": [
|
20
|
+
"firebase",
|
21
|
+
"cms",
|
22
|
+
"admin",
|
23
|
+
"admin panel",
|
24
|
+
"firebase panel",
|
25
|
+
"firestore",
|
26
|
+
"headless",
|
27
|
+
"headless cms",
|
28
|
+
"content manager"
|
29
|
+
],
|
30
|
+
"exports": {
|
31
|
+
".": {
|
32
|
+
"import": "./dist/index.es.js",
|
33
|
+
"require": "./dist/index.umd.js",
|
34
|
+
"types": "./dist/index.d.ts"
|
8
35
|
},
|
9
|
-
"
|
10
|
-
"
|
11
|
-
"
|
12
|
-
"
|
13
|
-
|
14
|
-
|
15
|
-
"
|
16
|
-
"
|
17
|
-
|
18
|
-
},
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
"
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
71
|
-
"
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
"
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
"
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
"@types/node": "^20.11.30",
|
88
|
-
"@types/object-hash": "^3.0.6",
|
89
|
-
"@types/react": "^18.2.67",
|
90
|
-
"@types/react-dom": "^18.2.22",
|
91
|
-
"@types/react-measure": "^2.0.12",
|
92
|
-
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
93
|
-
"@typescript-eslint/parser": "^7.3.1",
|
94
|
-
"@vitejs/plugin-react": "^4.2.1",
|
95
|
-
"cross-env": "^7.0.3",
|
96
|
-
"eslint": "^8.57.0",
|
97
|
-
"eslint-config-standard": "^17.1.0",
|
98
|
-
"eslint-plugin-import": "^2.29.1",
|
99
|
-
"eslint-plugin-n": "^16.6.2",
|
100
|
-
"eslint-plugin-promise": "^6.1.1",
|
101
|
-
"eslint-plugin-react": "^7.34.1",
|
102
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
103
|
-
"firebase": "^10.9.0",
|
104
|
-
"jest": "^29.7.0",
|
105
|
-
"npm-run-all": "^4.1.5",
|
106
|
-
"ts-jest": "^29.1.2",
|
107
|
-
"ts-node": "^10.9.2",
|
108
|
-
"tsd": "^0.30.7",
|
109
|
-
"typescript": "^5.4.2",
|
110
|
-
"vite": "^5.2.3"
|
111
|
-
},
|
112
|
-
"files": [
|
113
|
-
"dist",
|
114
|
-
"src",
|
115
|
-
"tailwind.config.js"
|
116
|
-
],
|
117
|
-
"gitHead": "42fe62aaa86f3330c79c7cbba551d9323299c141",
|
118
|
-
"publishConfig": {
|
119
|
-
"access": "public"
|
120
|
-
}
|
36
|
+
"./package.json": "./package.json",
|
37
|
+
"./tailwind.config.js": "./tailwind.config.js",
|
38
|
+
"./index.css": "./dist/index.css",
|
39
|
+
"./dist/index.css": "./dist/index.css"
|
40
|
+
},
|
41
|
+
"scripts": {
|
42
|
+
"watch": "vite build --watch",
|
43
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
44
|
+
"prepublishOnly": "run-s build",
|
45
|
+
"createTag": "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags",
|
46
|
+
"test:lint": "eslint \"src/**\" --quiet",
|
47
|
+
"test": "jest",
|
48
|
+
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
|
49
|
+
"generateIcons": "ts-node --esm src/scripts/generateIcons.ts"
|
50
|
+
},
|
51
|
+
"dependencies": {
|
52
|
+
"@radix-ui/react-checkbox": "^1.1.2",
|
53
|
+
"@radix-ui/react-collapsible": "^1.1.1",
|
54
|
+
"@radix-ui/react-dialog": "^1.1.2",
|
55
|
+
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
56
|
+
"@radix-ui/react-label": "^2.1.0",
|
57
|
+
"@radix-ui/react-menubar": "^1.1.2",
|
58
|
+
"@radix-ui/react-popover": "^1.1.2",
|
59
|
+
"@radix-ui/react-portal": "^1.1.2",
|
60
|
+
"@radix-ui/react-radio-group": "^1.2.1",
|
61
|
+
"@radix-ui/react-scroll-area": "^1.2.0",
|
62
|
+
"@radix-ui/react-select": "^2.1.2",
|
63
|
+
"@radix-ui/react-separator": "^1.1.0",
|
64
|
+
"@radix-ui/react-slider": "^1.2.1",
|
65
|
+
"@radix-ui/react-switch": "^1.1.1",
|
66
|
+
"@radix-ui/react-tabs": "^1.1.1",
|
67
|
+
"@radix-ui/react-tooltip": "^1.1.3",
|
68
|
+
"@radix-ui/react-visually-hidden": "^1.1.0",
|
69
|
+
"clsx": "^2.1.1",
|
70
|
+
"cmdk": "^0.2.1",
|
71
|
+
"date-fns": "^3.6.0",
|
72
|
+
"markdown-it": "^14.1.0",
|
73
|
+
"material-icons": "^1.13.12",
|
74
|
+
"react-dropzone": "^14.2.10",
|
75
|
+
"react-fast-compare": "^3.2.2",
|
76
|
+
"tailwind-merge": "^2.5.4"
|
77
|
+
},
|
78
|
+
"peerDependencies": {
|
79
|
+
"react": "^18.3.1",
|
80
|
+
"react-dom": "^18.3.1"
|
81
|
+
},
|
82
|
+
"devDependencies": {
|
83
|
+
"@jest/globals": "^29.7.0",
|
84
|
+
"@testing-library/jest-dom": "^6.5.0",
|
85
|
+
"@testing-library/react": "^16.0.1",
|
86
|
+
"@testing-library/user-event": "^14.5.2",
|
87
|
+
"@types/jest": "^29.5.14",
|
88
|
+
"@types/node": "^20.16.11",
|
89
|
+
"@types/object-hash": "^3.0.6",
|
90
|
+
"@types/react": "^18.3.12",
|
91
|
+
"@types/react-dom": "^18.3.1",
|
92
|
+
"@types/react-measure": "^2.0.12",
|
93
|
+
"@vitejs/plugin-react": "^4.3.3",
|
94
|
+
"cross-env": "^7.0.3",
|
95
|
+
"firebase": "^10.14.1",
|
96
|
+
"jest": "^29.7.0",
|
97
|
+
"npm-run-all": "^4.1.5",
|
98
|
+
"ts-jest": "^29.2.5",
|
99
|
+
"ts-node": "^10.9.2",
|
100
|
+
"tsd": "^0.31.2",
|
101
|
+
"typescript": "^5.6.3",
|
102
|
+
"vite": "^5.4.10",
|
103
|
+
"vite-plugin-static-copy": "^1.0.6"
|
104
|
+
},
|
105
|
+
"files": [
|
106
|
+
"dist",
|
107
|
+
"src",
|
108
|
+
"tailwind.config.js"
|
109
|
+
],
|
110
|
+
"gitHead": "84beb9dab81946354e94b91d72a49889a2ca537c",
|
111
|
+
"publishConfig": {
|
112
|
+
"access": "public"
|
113
|
+
}
|
121
114
|
}
|
package/src/components/Alert.tsx
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import {
|
2
|
+
import { cls } from "../util";
|
3
3
|
|
4
4
|
export interface AlertProps {
|
5
5
|
children: React.ReactNode;
|
@@ -52,7 +52,7 @@ export const Alert: React.FC<AlertProps> = ({
|
|
52
52
|
return (
|
53
53
|
<div
|
54
54
|
style={style}
|
55
|
-
className={
|
55
|
+
className={cls(
|
56
56
|
getSizeClasses(size),
|
57
57
|
"w-full",
|
58
58
|
"font-medium",
|
@@ -1,8 +1,10 @@
|
|
1
|
+
"use client";
|
1
2
|
import React from "react";
|
2
3
|
|
3
4
|
import { paperMixin } from "../styles";
|
4
5
|
import { Collapse } from "./Collapse";
|
5
|
-
import {
|
6
|
+
import { cls } from "../util";
|
7
|
+
import { useOutsideAlerter } from "../hooks";
|
6
8
|
|
7
9
|
export type AutocompleteProps = {
|
8
10
|
children: React.ReactNode;
|
@@ -49,14 +51,14 @@ export function Autocomplete({
|
|
49
51
|
return <Collapse
|
50
52
|
in={open}
|
51
53
|
duration={50}
|
52
|
-
className={
|
54
|
+
className={cls(
|
53
55
|
"absolute top-full left-0 right-0 overflow-visible",
|
54
56
|
open ? "shadow" : "",
|
55
57
|
"my-2",
|
56
58
|
"z-20",
|
57
59
|
"w-full")}>
|
58
60
|
<div ref={autocompleteRef}
|
59
|
-
className={
|
61
|
+
className={cls(
|
60
62
|
open ? paperMixin : "",
|
61
63
|
"bg-slate-50 dark:bg-slate-900 py-2"
|
62
64
|
)}>
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import {
|
3
|
-
import { focusedMixin } from "../styles";
|
2
|
+
import { cls } from "../util";
|
4
3
|
|
5
4
|
export interface AvatarProps {
|
6
5
|
src?: string;
|
7
6
|
alt?: string;
|
8
7
|
children?: React.ReactNode;
|
9
8
|
className?: string;
|
9
|
+
outerClassName?: string;
|
10
10
|
style?: React.CSSProperties;
|
11
11
|
}
|
12
12
|
|
@@ -17,6 +17,7 @@ const AvatarInner: React.ForwardRefRenderFunction<HTMLButtonElement, AvatarProps
|
|
17
17
|
children,
|
18
18
|
className,
|
19
19
|
style,
|
20
|
+
outerClassName,
|
20
21
|
...props
|
21
22
|
}, ref) => {
|
22
23
|
|
@@ -25,13 +26,13 @@ const AvatarInner: React.ForwardRefRenderFunction<HTMLButtonElement, AvatarProps
|
|
25
26
|
ref={ref}
|
26
27
|
style={style}
|
27
28
|
{...props}
|
28
|
-
className={
|
29
|
-
|
30
|
-
|
29
|
+
className={cls("rounded-full flex items-center justify-center overflow-hidden",
|
30
|
+
"p-1 hover:bg-slate-200 hover:dark:bg-slate-700 w-12 h-12 min-w-12 min-h-12",
|
31
|
+
outerClassName
|
31
32
|
)}>
|
32
33
|
{src
|
33
34
|
? (
|
34
|
-
<img className={
|
35
|
+
<img className={cls(
|
35
36
|
"bg-slate-100 dark:bg-slate-800",
|
36
37
|
"w-full h-full object-cover rounded-full",
|
37
38
|
className)}
|
@@ -40,7 +41,7 @@ const AvatarInner: React.ForwardRefRenderFunction<HTMLButtonElement, AvatarProps
|
|
40
41
|
)
|
41
42
|
: (
|
42
43
|
<span
|
43
|
-
className={
|
44
|
+
className={cls(
|
44
45
|
"bg-slate-100 dark:bg-slate-800",
|
45
46
|
"flex items-center justify-center",
|
46
47
|
"w-full h-full py-1.5 text-lg font-medium text-slate-900 dark:text-white rounded-full",
|
package/src/components/Badge.tsx
CHANGED
@@ -27,7 +27,7 @@ export const Badge: React.FC<BadgeProps> = ({
|
|
27
27
|
children
|
28
28
|
}) => {
|
29
29
|
return (
|
30
|
-
<div className="relative inline-block">
|
30
|
+
<div className="relative inline-block w-fit">
|
31
31
|
{children}
|
32
32
|
<span
|
33
33
|
className={`absolute top-0.5 right-0.5 transform translate-x-1/2 -translate-y-1/2 rounded-full
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import {
|
2
|
+
import { cls } from "../util";
|
3
3
|
|
4
4
|
export type BooleanSwitchProps = {
|
5
5
|
value: boolean | null;
|
6
6
|
className?: string;
|
7
7
|
disabled?: boolean;
|
8
|
-
size?: "small" | "medium";
|
8
|
+
size?: "smallest" | "small" | "medium";
|
9
9
|
} & ({
|
10
10
|
allowIndeterminate: true;
|
11
11
|
onValueChange?: (newValue: boolean | null) => void;
|
@@ -20,7 +20,7 @@ export const BooleanSwitch = React.forwardRef(function BooleanSwitch({
|
|
20
20
|
className,
|
21
21
|
onValueChange,
|
22
22
|
disabled = false,
|
23
|
-
size = "
|
23
|
+
size = "small",
|
24
24
|
...props
|
25
25
|
}: BooleanSwitchProps, ref: React.Ref<HTMLButtonElement>) {
|
26
26
|
return <button
|
@@ -39,8 +39,8 @@ export const BooleanSwitch = React.forwardRef(function BooleanSwitch({
|
|
39
39
|
onValueChange?.(!value);
|
40
40
|
}
|
41
41
|
}}
|
42
|
-
className={
|
43
|
-
size === "
|
42
|
+
className={cls(
|
43
|
+
size === "smallest" ? "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
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"
|
@@ -51,28 +51,28 @@ export const BooleanSwitch = React.forwardRef(function BooleanSwitch({
|
|
51
51
|
>
|
52
52
|
{allowIndeterminate && (value === null || value === undefined) && <div
|
53
53
|
key={"knob"}
|
54
|
-
className={
|
54
|
+
className={cls(
|
55
55
|
"block rounded-full transition-transform duration-100 transform will-change-auto",
|
56
56
|
disabled ? "bg-slate-400 dark:bg-slate-600" : "bg-slate-400 dark:bg-slate-600",
|
57
57
|
{
|
58
|
-
"w-[21px] h-[10px]": size === "medium",
|
59
|
-
"w-[19px] h-[8px]": size === "
|
60
|
-
"translate-x-[10px]": size === "medium",
|
61
|
-
"translate-x-[9px]": size === "
|
58
|
+
"w-[21px] h-[10px]": size === "small" || size === "medium",
|
59
|
+
"w-[19px] h-[8px]": size === "smallest",
|
60
|
+
"translate-x-[10px]": size === "small" || size === "medium",
|
61
|
+
"translate-x-[9px]": size === "smallest"
|
62
62
|
}
|
63
63
|
)}
|
64
64
|
/>}
|
65
65
|
|
66
66
|
{!(allowIndeterminate && (value === null || value === undefined)) && <div
|
67
67
|
key={"knob"}
|
68
|
-
className={
|
68
|
+
className={cls(
|
69
69
|
"block rounded-full transition-transform duration-100 transform will-change-auto",
|
70
70
|
disabled ? "bg-slate-300 dark:bg-slate-700" : (value ? "bg-white" : "bg-slate-600 dark:bg-slate-400"),
|
71
71
|
{
|
72
|
-
"w-[21px] h-[21px]": size === "medium",
|
73
|
-
"w-[19px] h-[19px]": size === "
|
74
|
-
[value ? "translate-x-[19px]" : "translate-x-[3px]"]: size === "medium",
|
75
|
-
[value ? "translate-x-[17px]" : "translate-x-[2px]"]: size === "
|
72
|
+
"w-[21px] h-[21px]": size === "small" || size === "medium",
|
73
|
+
"w-[19px] h-[19px]": size === "smallest",
|
74
|
+
[value ? "translate-x-[19px]" : "translate-x-[3px]"]: size === "small" || size === "medium",
|
75
|
+
[value ? "translate-x-[17px]" : "translate-x-[2px]"]: size === "smallest"
|
76
76
|
}
|
77
77
|
)}
|
78
78
|
/>}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
"use client";
|
1
2
|
import React from "react";
|
2
3
|
import {
|
3
4
|
fieldBackgroundDisabledMixin,
|
@@ -6,7 +7,7 @@ import {
|
|
6
7
|
focusedClasses
|
7
8
|
} from "../styles";
|
8
9
|
import { BooleanSwitch, BooleanSwitchProps } from "./BooleanSwitch";
|
9
|
-
import {
|
10
|
+
import { cls } from "../util";
|
10
11
|
|
11
12
|
export type BooleanSwitchWithLabelProps = BooleanSwitchProps & {
|
12
13
|
position?: "start" | "end",
|
@@ -53,16 +54,16 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
53
54
|
onFocus={onFocus}
|
54
55
|
onBlur={onBlur}
|
55
56
|
tabIndex={-1}
|
56
|
-
className={
|
57
|
+
className={cls(
|
57
58
|
!invisible && fieldBackgroundMixin,
|
58
59
|
!invisible && (disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin),
|
59
60
|
disabled ? "cursor-default" : "cursor-pointer",
|
60
|
-
"rounded-md
|
61
|
+
"rounded-md max-w-full justify-between w-full box-border relative inline-flex items-center",
|
61
62
|
!invisible && focus && !disabled ? focusedClasses : "",
|
62
63
|
error ? "text-red-500 dark:text-red-600" : (focus && !disabled ? "text-primary" : (!disabled ? "text-text-primary dark:text-text-primary-dark" : "text-text-secondary dark:text-text-secondary-dark")),
|
63
|
-
size === "
|
64
|
-
size === "
|
65
|
-
size === "
|
64
|
+
size === "smallest" ? "min-h-[40px]" : (size === "small" ? "min-h-[48px]" : "min-h-[64px]"),
|
65
|
+
size === "smallest" ? "pl-2" : "pl-4",
|
66
|
+
size === "smallest" ? "pr-4" : "pr-6",
|
66
67
|
position === "end" ? "flex-row-reverse" : "flex-row"
|
67
68
|
)}
|
68
69
|
onClick={disabled ? undefined : (e) => {
|
@@ -86,10 +87,10 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
86
87
|
{...props}
|
87
88
|
/>
|
88
89
|
|
89
|
-
<div className={
|
90
|
+
<div className={cls(
|
90
91
|
"flex-grow",
|
91
92
|
position === "end" ? "mr-4" : "ml-4",
|
92
|
-
size === "
|
93
|
+
size === "smallest" ? "text-sm" : "text-base"
|
93
94
|
)}>
|
94
95
|
{label}
|
95
96
|
</div>
|
@@ -1,7 +1,5 @@
|
|
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">
|
@@ -32,33 +30,33 @@ const ButtonInner = React.forwardRef<
|
|
32
30
|
}: ButtonProps<any>, ref) => {
|
33
31
|
|
34
32
|
const baseClasses =
|
35
|
-
"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";
|
36
34
|
|
37
|
-
const buttonClasses =
|
35
|
+
const buttonClasses = cls({
|
38
36
|
"w-full": fullWidth,
|
39
37
|
"w-fit": !fullWidth,
|
40
38
|
// Filled Variants
|
41
|
-
"border border-
|
42
|
-
"border border-
|
43
|
-
"border border-
|
44
|
-
"border border-
|
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,
|
45
43
|
// Text Variants
|
46
|
-
"border border-transparent text-primary hover:bg-slate-200 dark:hover:bg-gray-900": variant === "text" && color === "primary" && !disabled,
|
47
|
-
"border border-transparent text-secondary hover:bg-secondary-bg": variant === "text" && color === "secondary" && !disabled,
|
48
|
-
"border border-transparent text-red-500 hover:bg-red-500 hover:bg-opacity-10": variant === "text" && color === "error" && !disabled,
|
49
|
-
"border border-transparent text-text-primary dark:text-text-primary-dark hover:bg-slate-200 hover:dark:bg-gray-700": variant === "text" && color === "text" && !disabled,
|
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,
|
50
48
|
// Outlined Variants
|
51
|
-
"border border-primary text-primary hover:bg-primary-bg": variant === "outlined" && color === "primary" && !disabled,
|
52
|
-
"border border-secondary text-secondary hover:bg-secondary-bg": variant === "outlined" && color === "secondary" && !disabled,
|
53
|
-
"border border-red-500 text-red-500 hover:bg-red-500": variant === "outlined" && color === "error" && !disabled,
|
54
|
-
"border border-slate-400 text-text-primary dark:text-text-primary-dark hover:bg-slate-200": variant === "outlined" && color === "text" && !disabled,
|
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,
|
55
53
|
// Disabled states for all variants
|
56
54
|
"border border-transparent opacity-50": variant === "text" && disabled,
|
57
55
|
"border border-gray-500 opacity-50": variant === "outlined" && disabled,
|
58
56
|
"border border-gray-500 bg-gray-500 opacity-50": variant === "filled" && disabled,
|
59
57
|
});
|
60
58
|
|
61
|
-
const sizeClasses =
|
59
|
+
const sizeClasses = cls(
|
62
60
|
{
|
63
61
|
"py-1 px-2": size === "small",
|
64
62
|
"py-2 px-4": size === "medium",
|
@@ -73,7 +71,7 @@ const ButtonInner = React.forwardRef<
|
|
73
71
|
<Component
|
74
72
|
ref={ref}
|
75
73
|
onClick={props.onClick}
|
76
|
-
className={
|
74
|
+
className={cls( startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, className)}
|
77
75
|
{...(props as React.ComponentPropsWithRef<any>)}>
|
78
76
|
{startIcon}
|
79
77
|
{children}
|
@@ -85,7 +83,7 @@ const ButtonInner = React.forwardRef<
|
|
85
83
|
<button ref={ref as any}
|
86
84
|
type={props.type ?? "button"}
|
87
85
|
onClick={props.onClick}
|
88
|
-
className={
|
86
|
+
className={cls(startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, className)}
|
89
87
|
disabled={disabled}
|
90
88
|
{...props as React.ButtonHTMLAttributes<HTMLButtonElement>}>
|
91
89
|
{startIcon}
|
package/src/components/Card.tsx
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
"use client";
|
1
2
|
import React, { useCallback } from "react";
|
2
|
-
import { cardClickableMixin, cardMixin
|
3
|
-
import {
|
3
|
+
import { cardClickableMixin, cardMixin } from "../styles";
|
4
|
+
import { cls } from "../util";
|
4
5
|
|
5
6
|
type CardProps = {
|
6
7
|
children: React.ReactNode;
|
@@ -29,7 +30,7 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(({
|
|
29
30
|
role={onClick ? "button" : undefined}
|
30
31
|
tabIndex={onClick ? 0 : undefined}
|
31
32
|
onClick={onClick}
|
32
|
-
className={
|
33
|
+
className={cls(cardMixin, onClick && cardClickableMixin, className)}
|
33
34
|
style={style}
|
34
35
|
{...props}>
|
35
36
|
{children}
|