@firecms/ui 3.0.0-canary.16 → 3.0.0-canary.160
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 +60 -150
- package/dist/components/Avatar.d.ts +1 -0
- package/dist/components/BooleanSwitch.d.ts +1 -1
- package/dist/components/BooleanSwitchWithLabel.d.ts +4 -1
- package/dist/components/Button.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/DialogContent.d.ts +2 -1
- package/dist/components/DialogTitle.d.ts +10 -0
- package/dist/components/ExpandablePanel.d.ts +2 -1
- package/dist/components/FileUpload.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 +6 -2
- package/dist/components/Menubar.d.ts +79 -0
- package/dist/components/MultiSelect.d.ts +32 -16
- package/dist/components/Popover.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +26 -3
- package/dist/components/Select.d.ts +8 -11
- 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/Tabs.d.ts +4 -2
- 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 +50174 -20590
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +50441 -857
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +9 -9
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +119 -118
- package/src/components/Alert.tsx +4 -4
- package/src/components/Autocomplete.tsx +7 -5
- package/src/components/Avatar.tsx +41 -26
- package/src/components/Badge.tsx +2 -2
- package/src/components/BooleanSwitch.tsx +14 -13
- package/src/components/BooleanSwitchWithLabel.tsx +17 -8
- package/src/components/Button.tsx +31 -23
- package/src/components/Card.tsx +4 -3
- package/src/components/CenteredView.tsx +26 -15
- package/src/components/Checkbox.tsx +16 -14
- package/src/components/Chip.tsx +13 -10
- package/src/components/CircularProgress.tsx +3 -3
- package/src/components/Collapse.tsx +4 -2
- package/src/components/Container.tsx +3 -2
- package/src/components/DateTimeField.tsx +144 -921
- package/src/components/DebouncedTextField.tsx +1 -0
- package/src/components/Dialog.tsx +17 -7
- package/src/components/DialogActions.tsx +3 -3
- package/src/components/DialogContent.tsx +7 -3
- package/src/components/DialogTitle.tsx +41 -0
- package/src/components/ExpandablePanel.tsx +20 -12
- package/src/components/FileUpload.tsx +11 -13
- package/src/components/IconButton.tsx +7 -11
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +12 -9
- package/src/components/Label.tsx +18 -4
- package/src/components/Markdown.tsx +15 -3
- package/src/components/Menu.tsx +50 -31
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +341 -167
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +19 -15
- package/src/components/RadioGroup.tsx +42 -9
- package/src/components/SearchBar.tsx +12 -11
- package/src/components/Select.tsx +142 -130
- package/src/components/Separator.tsx +10 -4
- package/src/components/Sheet.tsx +53 -31
- package/src/components/Skeleton.tsx +9 -6
- package/src/components/Slider.tsx +110 -0
- package/src/components/Table.tsx +54 -35
- package/src/components/Tabs.tsx +17 -15
- package/src/components/TextField.tsx +25 -23
- package/src/components/TextareaAutosize.tsx +4 -3
- package/src/components/Tooltip.tsx +33 -16
- package/src/components/Typography.tsx +42 -26
- package/src/components/common/SelectInputLabel.tsx +3 -3
- package/src/components/index.tsx +3 -1
- package/src/hooks/index.ts +3 -0
- package/src/{util → hooks}/useDebounceValue.tsx +2 -0
- package/src/{util → hooks}/useInjectStyles.tsx +1 -0
- package/src/{util → hooks}/useOutsideAlerter.tsx +2 -0
- package/src/icons/Icon.tsx +48 -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 +9 -9
- package/src/util/cls.ts +14 -0
- package/src/util/index.ts +1 -3
- package/tailwind.config.js +42 -26
- 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/dist/styles.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
export declare const
|
2
|
-
export declare const focusedInvisibleMixin = "focus:bg-opacity-70 focus:bg-
|
1
|
+
export declare const focusedDisabled = "focus-visible:ring-0 focus-visible:ring-offset-0";
|
2
|
+
export declare const focusedInvisibleMixin = "focus:bg-opacity-70 focus:bg-surface-accent-100 focus:dark:bg-surface-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-
|
5
|
-
export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-
|
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-
|
9
|
-
export declare const paperMixin = "bg-white rounded-md dark:bg-
|
10
|
-
export declare const cardMixin = "bg-white rounded-md dark:bg-
|
4
|
+
export declare const fieldBackgroundMixin = "bg-opacity-50 bg-surface-accent-200 dark:bg-surface-800 dark:bg-opacity-60";
|
5
|
+
export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-surface-accent-100 dark:bg-surface-800 dark:bg-opacity-0";
|
6
|
+
export declare const fieldBackgroundDisabledMixin = "dark:bg-surface-800 bg-opacity-50 dark:bg-opacity-90";
|
7
|
+
export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-surface-700 dark:hover:bg-opacity-40";
|
8
|
+
export declare const defaultBorderMixin = "border-surface-200 border-opacity-40 dark:border-surface-700 dark:border-opacity-40";
|
9
|
+
export declare const paperMixin = "bg-white rounded-md dark:bg-surface-950 border border-surface-200 border-opacity-40 dark:border-surface-700 dark:border-opacity-40";
|
10
|
+
export declare const cardMixin = "bg-white border border-surface-200 border-opacity-40 dark:border-transparent rounded-md dark:bg-surface-950 dark:border-surface-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,122 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
"name": "@firecms/ui",
|
3
|
+
"type": "module",
|
4
|
+
"version": "3.0.0-canary.160",
|
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": {
|
12
|
+
"type": "git",
|
13
|
+
"url": "https://github.com/firecmsco/firecms.git",
|
14
|
+
"directory": "packages/ui"
|
15
|
+
},
|
16
|
+
"main": "./dist/index.umd.js",
|
17
|
+
"module": "./dist/index.es.js",
|
18
|
+
"types": "./dist/index.d.ts",
|
19
|
+
"source": "src/index.ts",
|
20
|
+
"engines": {
|
21
|
+
"node": ">=14"
|
22
|
+
},
|
23
|
+
"keywords": [
|
24
|
+
"firebase",
|
25
|
+
"cms",
|
26
|
+
"admin",
|
27
|
+
"admin panel",
|
28
|
+
"firebase panel",
|
29
|
+
"firestore",
|
30
|
+
"headless",
|
31
|
+
"headless cms",
|
32
|
+
"content manager"
|
33
|
+
],
|
34
|
+
"exports": {
|
35
|
+
".": {
|
36
|
+
"import": "./dist/index.es.js",
|
37
|
+
"require": "./dist/index.umd.js",
|
38
|
+
"types": "./dist/index.d.ts"
|
8
39
|
},
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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": "6c7d1dd64fa4b9f31433ab6dd938835589e8a25a",
|
118
|
-
"publishConfig": {
|
119
|
-
"access": "public"
|
120
|
-
}
|
40
|
+
"./package.json": "./package.json",
|
41
|
+
"./tailwind.config.js": "./tailwind.config.js",
|
42
|
+
"./index.css": "./dist/index.css",
|
43
|
+
"./dist/index.css": "./dist/index.css"
|
44
|
+
},
|
45
|
+
"scripts": {
|
46
|
+
"watch": "vite build --watch",
|
47
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
48
|
+
"prepublishOnly": "run-s build",
|
49
|
+
"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",
|
50
|
+
"test:lint": "eslint \"src/**\" --quiet",
|
51
|
+
"test": "jest",
|
52
|
+
"clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
|
53
|
+
"generateIcons": "bun --esm src/scripts/generateIcons.ts"
|
54
|
+
},
|
55
|
+
"dependencies": {
|
56
|
+
"@radix-ui/react-checkbox": "^1.1.2",
|
57
|
+
"@radix-ui/react-collapsible": "^1.1.1",
|
58
|
+
"@radix-ui/react-dialog": "^1.1.2",
|
59
|
+
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
60
|
+
"@radix-ui/react-label": "^2.1.0",
|
61
|
+
"@radix-ui/react-menubar": "^1.1.2",
|
62
|
+
"@radix-ui/react-popover": "^1.1.2",
|
63
|
+
"@radix-ui/react-portal": "^1.1.2",
|
64
|
+
"@radix-ui/react-radio-group": "^1.2.1",
|
65
|
+
"@radix-ui/react-scroll-area": "^1.2.1",
|
66
|
+
"@radix-ui/react-select": "^2.1.2",
|
67
|
+
"@radix-ui/react-separator": "^1.1.0",
|
68
|
+
"@radix-ui/react-slider": "^1.2.1",
|
69
|
+
"@radix-ui/react-switch": "^1.1.1",
|
70
|
+
"@radix-ui/react-tabs": "^1.1.1",
|
71
|
+
"@radix-ui/react-tooltip": "^1.1.4",
|
72
|
+
"@radix-ui/react-visually-hidden": "^1.1.0",
|
73
|
+
"clsx": "^2.1.1",
|
74
|
+
"cmdk": "^0.2.1",
|
75
|
+
"date-fns": "^3.6.0",
|
76
|
+
"markdown-it": "^14.1.0",
|
77
|
+
"material-icons": "^1.13.12",
|
78
|
+
"react-dropzone": "^14.3.5",
|
79
|
+
"react-fast-compare": "^3.2.2",
|
80
|
+
"tailwind-merge": "^2.5.5"
|
81
|
+
},
|
82
|
+
"peerDependencies": {
|
83
|
+
"react": "^18.3.1",
|
84
|
+
"react-dom": "^18.3.1"
|
85
|
+
},
|
86
|
+
"devDependencies": {
|
87
|
+
"@jest/globals": "^29.7.0",
|
88
|
+
"@testing-library/jest-dom": "^6.6.3",
|
89
|
+
"@testing-library/react": "^16.0.1",
|
90
|
+
"@testing-library/user-event": "^14.5.2",
|
91
|
+
"@types/jest": "^29.5.14",
|
92
|
+
"@types/node": "^20.17.9",
|
93
|
+
"@types/object-hash": "^3.0.6",
|
94
|
+
"@types/react": "^18.3.11",
|
95
|
+
"@types/react-dom": "^18.3.1",
|
96
|
+
"@types/react-measure": "^2.0.12",
|
97
|
+
"@vitejs/plugin-react": "^4.3.4",
|
98
|
+
"babel-plugin-react-compiler": "beta",
|
99
|
+
"cross-env": "^7.0.3",
|
100
|
+
"eslint-plugin-react-compiler": "beta",
|
101
|
+
"firebase": "^10.14.1",
|
102
|
+
"jest": "^29.7.0",
|
103
|
+
"npm-run-all": "^4.1.5",
|
104
|
+
"rollup-preserve-directives": "^1.1.3",
|
105
|
+
"ts-jest": "^29.2.5",
|
106
|
+
"ts-node": "^10.9.2",
|
107
|
+
"tsd": "^0.31.2",
|
108
|
+
"typescript": "^5.7.2",
|
109
|
+
"vite": "^5.4.11",
|
110
|
+
"vite-plugin-static-copy": "^1.0.6"
|
111
|
+
},
|
112
|
+
"files": [
|
113
|
+
"dist",
|
114
|
+
"src",
|
115
|
+
"index.css",
|
116
|
+
"tailwind.config.js"
|
117
|
+
],
|
118
|
+
"gitHead": "840f2733672a90a6a56aed89259eaa5365589512",
|
119
|
+
"publishConfig": {
|
120
|
+
"access": "public"
|
121
|
+
}
|
121
122
|
}
|
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;
|
@@ -34,7 +34,7 @@ const getColorClasses = (severity: string) => {
|
|
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-
|
37
|
+
return "bg-surface-accent-50 dark:bg-surface-accent-800 dark:text-white text-surface-accent-900";
|
38
38
|
}
|
39
39
|
};
|
40
40
|
|
@@ -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",
|
@@ -61,7 +61,7 @@ export const Alert: React.FC<AlertProps> = ({
|
|
61
61
|
className)}>
|
62
62
|
<div className={"flex-grow"}>{children}</div>
|
63
63
|
{onDismiss && (
|
64
|
-
<button className="text-
|
64
|
+
<button className="text-surface-accent-400 hover:text-surface-accent-600 dark:text-surface-accent-500 dark:hover:text-surface-accent-400"
|
65
65
|
onClick={onDismiss}>
|
66
66
|
×
|
67
67
|
</button>
|
@@ -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,16 +51,16 @@ 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
|
-
"bg-
|
63
|
+
"bg-surface-accent-50 dark:bg-surface-accent-900 py-2"
|
62
64
|
)}>
|
63
65
|
{children}
|
64
66
|
</div>
|
@@ -78,7 +80,7 @@ export function AutocompleteItem({
|
|
78
80
|
|
79
81
|
return (
|
80
82
|
<div
|
81
|
-
className="flex w-full items-center pr-6 pl-14 h-[48px] cursor-pointer hover:bg-
|
83
|
+
className="flex w-full items-center pr-6 pl-14 h-[48px] cursor-pointer hover:bg-surface-accent-100 dark:hover:bg-surface-accent-800"
|
82
84
|
onClick={onClick}>
|
83
85
|
{children}
|
84
86
|
</div>
|
@@ -1,12 +1,13 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
import {
|
1
|
+
"use client";
|
2
|
+
import React, { useState } from "react";
|
3
|
+
import { cls } from "../util";
|
4
4
|
|
5
5
|
export interface AvatarProps {
|
6
6
|
src?: string;
|
7
7
|
alt?: string;
|
8
8
|
children?: React.ReactNode;
|
9
9
|
className?: string;
|
10
|
+
outerClassName?: string;
|
10
11
|
style?: React.CSSProperties;
|
11
12
|
}
|
12
13
|
|
@@ -17,37 +18,51 @@ const AvatarInner: React.ForwardRefRenderFunction<HTMLButtonElement, AvatarProps
|
|
17
18
|
children,
|
18
19
|
className,
|
19
20
|
style,
|
21
|
+
outerClassName,
|
20
22
|
...props
|
21
|
-
},
|
23
|
+
},
|
24
|
+
ref
|
25
|
+
) => {
|
26
|
+
const [isImageError, setIsImageError] = useState(false);
|
27
|
+
|
28
|
+
const handleImageError = () => {
|
29
|
+
setIsImageError(true);
|
30
|
+
};
|
22
31
|
|
23
32
|
return (
|
24
33
|
<button
|
25
34
|
ref={ref}
|
26
35
|
style={style}
|
27
36
|
{...props}
|
28
|
-
className={
|
29
|
-
|
30
|
-
"p-1 hover:bg-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
className={cls(
|
38
|
+
"rounded-full flex items-center justify-center overflow-hidden",
|
39
|
+
"p-1 hover:bg-surface-accent-200 hover:dark:bg-surface-accent-700 w-12 h-12 min-w-12 min-h-12",
|
40
|
+
outerClassName
|
41
|
+
)}
|
42
|
+
>
|
43
|
+
{src && !isImageError ? (
|
44
|
+
<img
|
45
|
+
className={cls(
|
46
|
+
"bg-surface-accent-100 dark:bg-surface-accent-800",
|
36
47
|
"w-full h-full object-cover rounded-full",
|
37
|
-
className
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
className
|
49
|
+
)}
|
50
|
+
src={src}
|
51
|
+
alt={alt}
|
52
|
+
onError={handleImageError}
|
53
|
+
/>
|
54
|
+
) : (
|
55
|
+
<span
|
56
|
+
className={cls(
|
57
|
+
"bg-surface-accent-100 dark:bg-surface-accent-800",
|
58
|
+
"flex items-center justify-center",
|
59
|
+
"w-full h-full py-1.5 text-lg font-medium text-surface-accent-900 dark:text-white rounded-full",
|
60
|
+
className
|
61
|
+
)}
|
62
|
+
>
|
63
|
+
{children}
|
64
|
+
</span>
|
65
|
+
)}
|
51
66
|
</button>
|
52
67
|
);
|
53
68
|
};
|
package/src/components/Badge.tsx
CHANGED
@@ -17,7 +17,7 @@ const getColor = (color: BadgeColor) => {
|
|
17
17
|
case "error":
|
18
18
|
return "bg-red-500";
|
19
19
|
default:
|
20
|
-
return "bg-
|
20
|
+
return "bg-surface-accent-300 dark:bg-surface-accent-700";
|
21
21
|
}
|
22
22
|
}
|
23
23
|
|
@@ -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,12 @@
|
|
1
|
+
"use client";
|
1
2
|
import React from "react";
|
2
|
-
import {
|
3
|
+
import { cls } from "../util";
|
3
4
|
|
4
5
|
export type BooleanSwitchProps = {
|
5
6
|
value: boolean | null;
|
6
7
|
className?: string;
|
7
8
|
disabled?: boolean;
|
8
|
-
size?: "small" | "medium";
|
9
|
+
size?: "small" | "medium" | "large";
|
9
10
|
} & ({
|
10
11
|
allowIndeterminate: true;
|
11
12
|
onValueChange?: (newValue: boolean | null) => void;
|
@@ -39,25 +40,25 @@ export const BooleanSwitch = React.forwardRef(function BooleanSwitch({
|
|
39
40
|
onValueChange?.(!value);
|
40
41
|
}
|
41
42
|
}}
|
42
|
-
className={
|
43
|
+
className={cls(
|
43
44
|
size === "small" ? "w-[38px] h-[22px] min-w-[38px] min-h-[22px]" : "w-[42px] h-[26px] min-w-[42px] min-h-[26px]",
|
44
45
|
"outline-none rounded-full relative shadow-sm",
|
45
46
|
value ? (disabled
|
46
|
-
? "bg-white bg-opacity-54 dark:bg-
|
47
|
-
: "ring-secondary ring-1 bg-secondary dark:bg-secondary") : "bg-white bg-opacity-54 dark:bg-
|
47
|
+
? "bg-white bg-opacity-54 dark:bg-surface-accent-950 border-surface-accent-100 dark:border-surface-accent-700 ring-1 ring-surface-accent-200 dark:ring-surface-accent-700"
|
48
|
+
: "ring-secondary ring-1 bg-secondary dark:bg-secondary") : "bg-white bg-opacity-54 dark:bg-surface-accent-900 ring-1 ring-surface-accent-200 dark:ring-surface-accent-700",
|
48
49
|
className
|
49
50
|
)}
|
50
51
|
{...props}
|
51
52
|
>
|
52
53
|
{allowIndeterminate && (value === null || value === undefined) && <div
|
53
54
|
key={"knob"}
|
54
|
-
className={
|
55
|
+
className={cls(
|
55
56
|
"block rounded-full transition-transform duration-100 transform will-change-auto",
|
56
|
-
disabled ? "bg-
|
57
|
+
disabled ? "bg-surface-accent-400 dark:bg-surface-accent-600" : "bg-surface-accent-400 dark:bg-surface-accent-600",
|
57
58
|
{
|
58
|
-
"w-[21px] h-[10px]": size === "medium",
|
59
|
+
"w-[21px] h-[10px]": size === "medium" || size === "large",
|
59
60
|
"w-[19px] h-[8px]": size === "small",
|
60
|
-
"translate-x-[10px]": size === "medium",
|
61
|
+
"translate-x-[10px]": size === "medium" || size === "large",
|
61
62
|
"translate-x-[9px]": size === "small"
|
62
63
|
}
|
63
64
|
)}
|
@@ -65,13 +66,13 @@ export const BooleanSwitch = React.forwardRef(function BooleanSwitch({
|
|
65
66
|
|
66
67
|
{!(allowIndeterminate && (value === null || value === undefined)) && <div
|
67
68
|
key={"knob"}
|
68
|
-
className={
|
69
|
+
className={cls(
|
69
70
|
"block rounded-full transition-transform duration-100 transform will-change-auto",
|
70
|
-
disabled ? "bg-
|
71
|
+
disabled ? "bg-surface-accent-300 dark:bg-surface-accent-700" : (value ? "bg-white" : "bg-surface-accent-600 dark:bg-surface-accent-400"),
|
71
72
|
{
|
72
|
-
"w-[21px] h-[21px]": size === "medium",
|
73
|
+
"w-[21px] h-[21px]": size === "medium" || size === "large",
|
73
74
|
"w-[19px] h-[19px]": size === "small",
|
74
|
-
[value ? "translate-x-[19px]" : "translate-x-[3px]"]: size === "medium",
|
75
|
+
[value ? "translate-x-[19px]" : "translate-x-[3px]"]: size === "medium" || size === "large",
|
75
76
|
[value ? "translate-x-[17px]" : "translate-x-[2px]"]: size === "small"
|
76
77
|
}
|
77
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",
|
@@ -14,6 +15,9 @@ export type BooleanSwitchWithLabelProps = BooleanSwitchProps & {
|
|
14
15
|
label?: React.ReactNode,
|
15
16
|
error?: boolean,
|
16
17
|
autoFocus?: boolean,
|
18
|
+
fullWidth?: boolean,
|
19
|
+
className?: string,
|
20
|
+
inputClassName?: string,
|
17
21
|
};
|
18
22
|
|
19
23
|
/**
|
@@ -30,6 +34,9 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
30
34
|
autoFocus,
|
31
35
|
disabled,
|
32
36
|
size,
|
37
|
+
className,
|
38
|
+
fullWidth = true,
|
39
|
+
inputClassName,
|
33
40
|
...props
|
34
41
|
}: BooleanSwitchWithLabelProps) {
|
35
42
|
|
@@ -53,23 +60,25 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
53
60
|
onFocus={onFocus}
|
54
61
|
onBlur={onBlur}
|
55
62
|
tabIndex={-1}
|
56
|
-
className={
|
63
|
+
className={cls(
|
57
64
|
!invisible && fieldBackgroundMixin,
|
58
65
|
!invisible && (disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin),
|
59
66
|
disabled ? "cursor-default" : "cursor-pointer",
|
60
|
-
"rounded-md
|
67
|
+
"rounded-md max-w-full justify-between box-border relative inline-flex items-center",
|
61
68
|
!invisible && focus && !disabled ? focusedClasses : "",
|
62
69
|
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 === "small" ? "min-h-[40px]" : "min-h-[64px]",
|
70
|
+
size === "small" ? "min-h-[40px]" : (size === "medium" ? "min-h-[48px]" : "min-h-[64px]"),
|
64
71
|
size === "small" ? "pl-2" : "pl-4",
|
65
72
|
size === "small" ? "pr-4" : "pr-6",
|
66
|
-
position === "end" ? "flex-row-reverse" : "flex-row"
|
73
|
+
position === "end" ? "flex-row-reverse" : "flex-row",
|
74
|
+
fullWidth ? "w-full" : "",
|
75
|
+
className
|
67
76
|
)}
|
68
77
|
onClick={disabled ? undefined : (e) => {
|
69
78
|
if (props.allowIndeterminate) {
|
70
79
|
if (value === null || value === undefined) onValueChange?.(true)
|
71
80
|
else if (value) onValueChange?.(false)
|
72
|
-
else onValueChange?.(null as any);
|
81
|
+
else onValueChange?.(null as any);
|
73
82
|
} else {
|
74
83
|
onValueChange?.(!value);
|
75
84
|
}
|
@@ -81,12 +90,12 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
81
90
|
value={value}
|
82
91
|
ref={refInput}
|
83
92
|
size={size}
|
84
|
-
className={invisible && focus ? focusedClasses : ""}
|
93
|
+
className={cls(invisible && focus ? focusedClasses : "", inputClassName)}
|
85
94
|
disabled={disabled}
|
86
95
|
{...props}
|
87
96
|
/>
|
88
97
|
|
89
|
-
<div className={
|
98
|
+
<div className={cls(
|
90
99
|
"flex-grow",
|
91
100
|
position === "end" ? "mr-4" : "ml-4",
|
92
101
|
size === "small" ? "text-sm" : "text-base"
|