@firecms/ui 3.0.0-canary.5 → 3.0.0-canary.51
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/Avatar.d.ts +1 -0
- 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 +7 -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/TextField.d.ts +1 -1
- 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 +7735 -7619
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10 -10
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +6 -6
- package/dist/util/index.d.ts +0 -2
- package/package.json +29 -23
- package/src/components/Alert.tsx +2 -2
- package/src/components/Autocomplete.tsx +2 -1
- package/src/components/Avatar.tsx +3 -0
- package/src/components/BooleanSwitch.tsx +2 -2
- package/src/components/Button.tsx +11 -19
- 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 +29 -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 +4 -3
- package/src/components/TextareaAutosize.tsx +1 -1
- package/src/components/Tooltip.tsx +5 -1
- package/src/components/Typography.tsx +18 -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 +6 -6
- 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
@@ -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}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import * as React from "react"
|
2
|
+
import * as LabelPrimitive from "@radix-ui/react-label"
|
3
|
+
import { cn } from "../util";
|
4
|
+
import { defaultBorderMixin } from "../styles";
|
5
|
+
|
6
|
+
type LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & {
|
7
|
+
border?: boolean,
|
8
|
+
onClick?: React.MouseEventHandler<HTMLLabelElement>
|
9
|
+
};
|
10
|
+
const Label = React.forwardRef<
|
11
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
12
|
+
LabelProps
|
13
|
+
>(({
|
14
|
+
className,
|
15
|
+
...props
|
16
|
+
}, ref) => (
|
17
|
+
<LabelPrimitive.Root
|
18
|
+
ref={ref}
|
19
|
+
onClick={props.onClick}
|
20
|
+
className={cn("text-sm font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
21
|
+
props.border && "border border-gray-300 dark:border-gray-700 rounded-md px-3 py-1.5",
|
22
|
+
props.onClick && "hover:cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-800",
|
23
|
+
defaultBorderMixin, className)}
|
24
|
+
{...props}
|
25
|
+
/>
|
26
|
+
))
|
27
|
+
Label.displayName = LabelPrimitive.Root.displayName
|
28
|
+
|
29
|
+
export { Label }
|
@@ -3,26 +3,37 @@ import equal from "react-fast-compare"
|
|
3
3
|
|
4
4
|
// @ts-ignore
|
5
5
|
import MarkdownIt from "markdown-it";
|
6
|
+
import { cn } from "../util";
|
6
7
|
|
7
8
|
export interface MarkdownProps {
|
8
9
|
source: string,
|
10
|
+
size?: "small" | "medium" | "large" | "xl" | "2xl";
|
9
11
|
className?: string
|
10
12
|
}
|
11
13
|
|
12
|
-
const
|
14
|
+
const proseClasses = {
|
15
|
+
small: "prose-sm text-sm",
|
16
|
+
medium: "prose text-base",
|
17
|
+
large: "prose-lg",
|
18
|
+
xl: "prose-xl",
|
19
|
+
"2xl": "prose-2xl"
|
20
|
+
};
|
21
|
+
|
22
|
+
const md = new MarkdownIt({ html: true });
|
13
23
|
/**
|
14
24
|
* @group Preview components
|
15
25
|
*/
|
16
26
|
export const Markdown = React.memo<MarkdownProps>(function Markdown({
|
17
27
|
source,
|
18
|
-
className
|
28
|
+
className,
|
29
|
+
size = "medium"
|
19
30
|
}: MarkdownProps) {
|
20
31
|
const html = useMemo(() => {
|
21
32
|
return md.render(typeof source === "string" ? source : "");
|
22
33
|
}, [source]);
|
23
34
|
|
24
35
|
return <div
|
25
|
-
className={className}
|
36
|
+
className={cn(proseClasses[size], "dark:prose-invert prose-headings:font-title", className)}
|
26
37
|
dangerouslySetInnerHTML={{ __html: html }}
|
27
38
|
/>;
|
28
39
|
}
|
package/src/components/Menu.tsx
CHANGED
@@ -43,18 +43,24 @@ export type MenuItemProps = {
|
|
43
43
|
children: React.ReactNode;
|
44
44
|
dense?: boolean;
|
45
45
|
onClick?: (event: React.MouseEvent) => void;
|
46
|
-
}
|
46
|
+
};
|
47
47
|
|
48
48
|
export function MenuItem({
|
49
49
|
children,
|
50
|
-
dense,
|
50
|
+
dense = false, // Default value is false if not provided
|
51
51
|
onClick
|
52
52
|
}: MenuItemProps) {
|
53
|
+
// Dynamically adjusting the class based on the "dense" prop
|
54
|
+
const classNames = cn(
|
55
|
+
focusedMixin,
|
56
|
+
onClick && "cursor-pointer",
|
57
|
+
"rounded-md text-sm font-medium text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-900 flex items-center gap-4",
|
58
|
+
dense ? "px-3 py-1.5" : "px-4 py-2"
|
59
|
+
);
|
60
|
+
|
53
61
|
return (
|
54
62
|
<DropdownMenu.Item
|
55
|
-
className={
|
56
|
-
onClick && "cursor-pointer",
|
57
|
-
"rounded-md px-4 py-2 text-sm font-medium text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-900 flex items-center gap-4")}
|
63
|
+
className={classNames}
|
58
64
|
onClick={onClick}>
|
59
65
|
{children}
|
60
66
|
</DropdownMenu.Item>
|
@@ -6,8 +6,9 @@ import { Command as CommandPrimitive } from "cmdk";
|
|
6
6
|
|
7
7
|
import { ExpandMoreIcon } from "../icons";
|
8
8
|
import { fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, fieldBackgroundMixin, focusedMixin } from "../styles";
|
9
|
-
import { cn
|
9
|
+
import { cn } from "../util";
|
10
10
|
import { SelectInputLabel } from "./common/SelectInputLabel";
|
11
|
+
import { useOutsideAlerter } from "../hooks";
|
11
12
|
|
12
13
|
export type MultiSelectProps = {
|
13
14
|
open?: boolean,
|
@@ -2,7 +2,8 @@ import React from "react";
|
|
2
2
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
3
3
|
|
4
4
|
import { paperMixin } from "../styles";
|
5
|
-
import { cn
|
5
|
+
import { cn } from "../util";
|
6
|
+
import { useInjectStyles } from "../hooks";
|
6
7
|
|
7
8
|
export type PopoverSide = "top" | "right" | "bottom" | "left";
|
8
9
|
export type PopoverAlign = "start" | "center" | "end";
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import * as React from "react"
|
2
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
3
|
+
import { cn } from "../util";
|
4
|
+
|
5
|
+
export interface RadioGroupProps {
|
6
|
+
id?: string;
|
7
|
+
children: React.ReactNode;
|
8
|
+
name?: string
|
9
|
+
required?: boolean;
|
10
|
+
disabled?: boolean;
|
11
|
+
/**
|
12
|
+
* Whether keyboard navigation should loop around
|
13
|
+
* @defaultValue false
|
14
|
+
*/
|
15
|
+
loop?: boolean;
|
16
|
+
defaultValue?: string;
|
17
|
+
value?: string;
|
18
|
+
|
19
|
+
onValueChange?(value: string): void;
|
20
|
+
|
21
|
+
className?: string;
|
22
|
+
}
|
23
|
+
|
24
|
+
const RadioGroup = React.forwardRef<
|
25
|
+
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
26
|
+
RadioGroupProps
|
27
|
+
>(({
|
28
|
+
className,
|
29
|
+
...props
|
30
|
+
}, ref) => {
|
31
|
+
return (
|
32
|
+
<RadioGroupPrimitive.Root
|
33
|
+
className={cn("grid gap-2", className)}
|
34
|
+
{...props}
|
35
|
+
ref={ref}
|
36
|
+
/>
|
37
|
+
)
|
38
|
+
})
|
39
|
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
|
40
|
+
|
41
|
+
export interface RadioGroupItemProps {
|
42
|
+
id?: string;
|
43
|
+
value: string;
|
44
|
+
checked?: boolean;
|
45
|
+
required?: boolean;
|
46
|
+
className?: string;
|
47
|
+
}
|
48
|
+
const RadioGroupItem = React.forwardRef<
|
49
|
+
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
50
|
+
RadioGroupItemProps
|
51
|
+
>(({
|
52
|
+
className,
|
53
|
+
...props
|
54
|
+
}, ref) => {
|
55
|
+
return (
|
56
|
+
<RadioGroupPrimitive.Item
|
57
|
+
ref={ref}
|
58
|
+
className={cn(
|
59
|
+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
60
|
+
className
|
61
|
+
)}
|
62
|
+
{...props}
|
63
|
+
>
|
64
|
+
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
65
|
+
<div className="h-2.5 w-2.5 fill-current text-current bg-primary rounded-lg"/>
|
66
|
+
</RadioGroupPrimitive.Indicator>
|
67
|
+
</RadioGroupPrimitive.Item>
|
68
|
+
)
|
69
|
+
})
|
70
|
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
|
71
|
+
|
72
|
+
export { RadioGroup, RadioGroupItem }
|
@@ -4,7 +4,7 @@ import { defaultBorderMixin, focusedMixin } from "../styles";
|
|
4
4
|
import { CircularProgress, IconButton } from "./index";
|
5
5
|
import { ClearIcon, SearchIcon } from "../icons";
|
6
6
|
import { cn } from "../util";
|
7
|
-
import { useDebounceValue } from "../
|
7
|
+
import { useDebounceValue } from "../hooks";
|
8
8
|
|
9
9
|
interface SearchBarProps {
|
10
10
|
onClick?: () => void;
|
@@ -127,38 +127,38 @@ export function Select({
|
|
127
127
|
"w-full h-full",
|
128
128
|
size === "small" ? "h-[42px]" : "h-[64px]",
|
129
129
|
padding ? "px-4 " : "",
|
130
|
-
"
|
130
|
+
"outline-none focus:outline-none",
|
131
131
|
"select-none rounded-md text-sm",
|
132
132
|
error ? "text-red-500 dark:text-red-600" : "focus:text-text-primary dark:focus:text-text-primary-dark",
|
133
133
|
error ? "border border-red-500 dark:border-red-600" : "",
|
134
|
-
disabled ? "text-slate-600 dark:text-slate-400" : "text-slate-800 dark:text-
|
134
|
+
disabled ? "text-slate-600 dark:text-slate-400" : "text-slate-800 dark:text-white",
|
135
135
|
"relative flex items-center",
|
136
136
|
includeFocusOutline ? focusedMixin : "",
|
137
137
|
inputClassName
|
138
138
|
)}>
|
139
139
|
|
140
|
-
<
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
140
|
+
<div className={cn(
|
141
|
+
"flex-grow w-full max-w-full flex flex-row gap-2 items-center",
|
142
|
+
"overflow-visible",
|
143
|
+
size === "small" ? "h-[42px]" : "h-[64px]"
|
144
|
+
)}>
|
145
|
+
<SelectPrimitive.Value placeholder={placeholder}>
|
146
|
+
{renderValue &&
|
147
|
+
(value && Array.isArray(value)
|
148
|
+
? value.map((v, i) => (
|
149
|
+
<div key={v} className={"flex items-center gap-1 max-w-full"}>
|
150
|
+
{renderValue ? renderValue(v, i) : v}
|
151
|
+
</div>))
|
152
|
+
: (typeof value === "string" ? (renderValue ? renderValue(value, 0) : value) : placeholder))}
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
154
|
+
{renderValues && (!value || Array.isArray(value))
|
155
|
+
? renderValues(value as string[] ?? [])
|
156
|
+
: null}
|
157
157
|
|
158
|
-
|
158
|
+
{!renderValue && !renderValues && value}
|
159
159
|
|
160
|
-
</div>
|
161
160
|
</SelectPrimitive.Value>
|
161
|
+
</div>
|
162
162
|
|
163
163
|
<SelectPrimitive.Icon className={cn(
|
164
164
|
"px-2 h-full flex items-center",
|
@@ -249,7 +249,7 @@ export function SelectGroup({
|
|
249
249
|
return <>
|
250
250
|
<SelectPrimitive.Group
|
251
251
|
className={cn(
|
252
|
-
"text-xs text-slate-900 dark:text-
|
252
|
+
"text-xs text-slate-900 dark:text-white uppercase tracking-wider font-bold mt-6 first:mt-2",
|
253
253
|
"px-2 py-2",
|
254
254
|
className
|
255
255
|
)}>
|
package/src/components/Table.tsx
CHANGED
@@ -13,7 +13,7 @@ export const Table = ({
|
|
13
13
|
className,
|
14
14
|
style
|
15
15
|
}: TableProps) => (
|
16
|
-
<table className={cn("w-full text-left text-gray-800 dark:text-
|
16
|
+
<table className={cn("w-full text-left text-gray-800 dark:text-white rounded-md overflow-x-auto",
|
17
17
|
className)}
|
18
18
|
style={style}>
|
19
19
|
{children}
|
package/src/components/Tabs.tsx
CHANGED
@@ -19,7 +19,7 @@ export function Tabs({
|
|
19
19
|
|
20
20
|
return <TabsPrimitive.Root value={value} onValueChange={onValueChange}>
|
21
21
|
<TabsPrimitive.List className={cn(
|
22
|
-
"flex text-sm font-medium text-center text-slate-800 dark:text-
|
22
|
+
"flex text-sm font-medium text-center text-slate-800 dark:text-white max-w-full overflow-auto no-scrollbar",
|
23
23
|
className)
|
24
24
|
}>
|
25
25
|
{children}
|
@@ -48,7 +48,7 @@ export function Tab({
|
|
48
48
|
disabled
|
49
49
|
? "text-slate-400 dark:text-slate-500"
|
50
50
|
: cn("text-slate-700 dark:text-slate-300",
|
51
|
-
"data-[state=active]:text-slate-900 data-[state=active]:dark:text-
|
51
|
+
"data-[state=active]:text-slate-900 data-[state=active]:dark:text-white",
|
52
52
|
"hover:text-slate-800 dark:hover:text-slate-200"),
|
53
53
|
// disabled ? "text-slate-400 dark:text-slate-500" : "data-[state=active]:text-primary",
|
54
54
|
// "data-[state=active]:bg-slate-50 data-[state=active]:dark:bg-slate-800",
|
@@ -40,7 +40,7 @@ export type TextFieldProps<T extends string | number> = {
|
|
40
40
|
endAdornment?: React.ReactNode,
|
41
41
|
autoFocus?: boolean,
|
42
42
|
placeholder?: string,
|
43
|
-
size?: "small" | "medium",
|
43
|
+
size?: "smallest" | "small" | "medium",
|
44
44
|
className?: string,
|
45
45
|
style?: React.CSSProperties,
|
46
46
|
inputClassName?: string,
|
@@ -128,11 +128,11 @@ export function TextField<T extends string | number>({
|
|
128
128
|
"rounded-md",
|
129
129
|
invisible ? focusedInvisibleMixin : focusedMixin,
|
130
130
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
131
|
-
size === "small" ? "min-h-[48px]" : "min-h-[64px]",
|
131
|
+
size === "smallest" ? "min-h-[32px]" : (size === "small" ? "min-h-[48px]" : "min-h-[64px]"),
|
132
132
|
label ? (size === "medium" ? "pt-[28px] pb-2" : "pt-4 pb-2") : "py-2",
|
133
133
|
focused ? "text-text-primary dark:text-text-primary-dark" : "",
|
134
134
|
endAdornment ? "pr-10" : "pr-3",
|
135
|
-
disabled && "border border-transparent outline-none opacity-50 dark:opacity-50 text-slate-800 dark:text-
|
135
|
+
disabled && "border border-transparent outline-none opacity-50 dark:opacity-50 text-slate-800 dark:text-white",
|
136
136
|
inputClassName
|
137
137
|
)}
|
138
138
|
placeholder={focused || hasValue || !label ? placeholder : undefined}
|
@@ -152,6 +152,7 @@ export function TextField<T extends string | number>({
|
|
152
152
|
disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
|
153
153
|
error ? "border border-red-500 dark:border-red-600" : "",
|
154
154
|
{
|
155
|
+
"min-h-[32px]": !invisible && size === "smallest",
|
155
156
|
"min-h-[48px]": !invisible && size === "small",
|
156
157
|
"min-h-[64px]": !invisible && size === "medium"
|
157
158
|
},
|
@@ -288,7 +288,7 @@ export const TextareaAutosize = React.forwardRef(function TextareaAutosize(
|
|
288
288
|
/>
|
289
289
|
</React.Fragment>
|
290
290
|
);
|
291
|
-
})
|
291
|
+
}) as React.FC<TextareaAutosizeProps & { ref?: React.ForwardedRef<Element> }>;
|
292
292
|
|
293
293
|
export type TextareaAutosizeProps = Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "onResize"> & {
|
294
294
|
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
3
3
|
|
4
|
-
import { cn
|
4
|
+
import { cn } from "../util";
|
5
|
+
import { useInjectStyles } from "../hooks";
|
5
6
|
|
6
7
|
export type TooltipProps = {
|
7
8
|
open?: boolean,
|
8
9
|
onOpenChange?: (open: boolean) => void,
|
9
10
|
side?: "top" | "bottom" | "left" | "right",
|
11
|
+
align?: "start" | "center" | "end",
|
10
12
|
sideOffset?: number,
|
11
13
|
title?: string | React.ReactNode,
|
12
14
|
delayDuration?: number;
|
@@ -21,6 +23,7 @@ export const Tooltip = ({
|
|
21
23
|
side = "bottom",
|
22
24
|
delayDuration = 250,
|
23
25
|
sideOffset,
|
26
|
+
align,
|
24
27
|
onOpenChange,
|
25
28
|
title,
|
26
29
|
className,
|
@@ -49,6 +52,7 @@ export const Tooltip = ({
|
|
49
52
|
"z-50 rounded px-3 py-2 text-xs leading-none bg-slate-700 dark:bg-slate-800 bg-opacity-90 font-medium text-slate-50 shadow-2xl select-none duration-400 ease-in transform opacity-100",
|
50
53
|
tooltipClassName)}
|
51
54
|
sideOffset={sideOffset === undefined ? 4 : sideOffset}
|
55
|
+
align={align}
|
52
56
|
side={side}>
|
53
57
|
{title}
|
54
58
|
{/*<TooltipPrimitive.Arrow className="fill-slate-600"/>*/}
|
@@ -43,6 +43,23 @@ const colorToClasses = {
|
|
43
43
|
error: "text-red-600 dark:text-red-500"
|
44
44
|
};
|
45
45
|
|
46
|
+
const gutterBottomClasses = {
|
47
|
+
h1: "mb-5",
|
48
|
+
h2: "mb-4",
|
49
|
+
h3: "mb-4",
|
50
|
+
h4: "mb-4",
|
51
|
+
h5: "mb-3",
|
52
|
+
h6: "mb-3",
|
53
|
+
subtitle1: "mb-3",
|
54
|
+
subtitle2: "mb-3",
|
55
|
+
body1: "mb-3",
|
56
|
+
body2: "mb-3",
|
57
|
+
inherit: "mb-3",
|
58
|
+
caption: "mb-2",
|
59
|
+
button: "mb-2",
|
60
|
+
label: "mb-2"
|
61
|
+
};
|
62
|
+
|
46
63
|
const variantToClasses = {
|
47
64
|
h1: "text-6xl font-headers font-light",
|
48
65
|
h2: "text-5xl font-headers font-light",
|
@@ -87,7 +104,7 @@ export function Typography<C extends React.ElementType>(
|
|
87
104
|
variantToClasses[variant],
|
88
105
|
color ? colorToClasses[color] : "",
|
89
106
|
align !== "inherit" && `text-${align}`,
|
90
|
-
gutterBottom &&
|
107
|
+
gutterBottom && gutterBottomClasses[variant],
|
91
108
|
noWrap && "truncate",
|
92
109
|
paragraph && "mb-3",
|
93
110
|
className
|
package/src/components/index.tsx
CHANGED
@@ -20,11 +20,13 @@ export * from "./FileUpload";
|
|
20
20
|
export * from "./IconButton";
|
21
21
|
export * from "./InputLabel";
|
22
22
|
export * from "./InfoLabel";
|
23
|
+
export * from "./Label";
|
23
24
|
export * from "./LoadingButton";
|
24
25
|
export * from "./Markdown";
|
25
26
|
export * from "./Menu";
|
26
27
|
export * from "./MultiSelect";
|
27
28
|
export * from "./Paper";
|
29
|
+
export * from "./RadioGroup";
|
28
30
|
export * from "./SearchBar";
|
29
31
|
export * from "./Select";
|
30
32
|
export * from "./Separator";
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import * as locales from "date-fns/locale";
|
2
|
+
// @ts-ignore
|
3
|
+
import { registerLocale, setDefaultLocale } from "react-datepicker";
|
4
|
+
import { useEffect } from "react";
|
5
|
+
|
6
|
+
export function useLocaleConfig(locale?: string) {
|
7
|
+
useEffect(() => {
|
8
|
+
if (!locale) {
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
// @ts-ignore
|
12
|
+
const dateFnsLocale = locales[locale];
|
13
|
+
if (dateFnsLocale) {
|
14
|
+
registerLocale(locale, dateFnsLocale);
|
15
|
+
setDefaultLocale(locale);
|
16
|
+
}
|
17
|
+
}, [locale])
|
18
|
+
}
|
package/src/icons/Icon.tsx
CHANGED
@@ -8,7 +8,7 @@ export type IconProps = {
|
|
8
8
|
color?: IconColor,
|
9
9
|
className?: string,
|
10
10
|
onClick?: (e: React.SyntheticEvent) => void,
|
11
|
-
style?: React.CSSProperties
|
11
|
+
style?: React.CSSProperties,
|
12
12
|
}
|
13
13
|
|
14
14
|
const colorClassesMapping: Record<IconColor, string> = {
|
@@ -21,43 +21,46 @@ const colorClassesMapping: Record<IconColor, string> = {
|
|
21
21
|
error: "text-red-500"
|
22
22
|
}
|
23
23
|
|
24
|
-
export
|
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
|
-
|
24
|
+
export const Icon = React.forwardRef<HTMLSpanElement, IconProps & { iconKey: string }>(
|
25
|
+
({
|
26
|
+
iconKey,
|
27
|
+
size = "medium",
|
28
|
+
color,
|
29
|
+
className,
|
30
|
+
onClick,
|
31
|
+
style
|
32
|
+
}, ref) => {
|
33
|
+
let sizeInPx: number;
|
34
|
+
switch (size) {
|
35
|
+
case "smallest":
|
36
|
+
sizeInPx = 16;
|
37
|
+
break;
|
38
|
+
case "small":
|
39
|
+
sizeInPx = 20;
|
40
|
+
break;
|
41
|
+
case "medium":
|
42
|
+
sizeInPx = 24;
|
43
|
+
break;
|
44
|
+
case "large":
|
45
|
+
sizeInPx = 28;
|
46
|
+
break
|
47
|
+
default:
|
48
|
+
sizeInPx = typeof size === "number" ? size : 24;
|
49
|
+
}
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}
|
51
|
+
return <span
|
52
|
+
ref={ref} // Attach the ref to the span
|
53
|
+
style={{
|
54
|
+
fontSize: `${sizeInPx}px`,
|
55
|
+
display: "block",
|
56
|
+
...style
|
57
|
+
}}
|
58
|
+
className={
|
59
|
+
cn("material-icons",
|
60
|
+
color ? colorClassesMapping[color] : "",
|
61
|
+
"select-none",
|
62
|
+
className)}
|
63
|
+
onClick={onClick}>{iconKey}</span>
|
64
|
+
});
|
65
|
+
|
66
|
+
Icon.displayName = "Icon";
|
package/src/index.ts
CHANGED
package/src/styles.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
export 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 const focusedInvisibleMixin = "focus:bg-opacity-70 focus:bg-slate-100 focus:dark:bg-gray-800 focus:dark:bg-opacity-60";
|
3
3
|
export const focusedClasses = "z-30 outline-none ring-2 ring-primary ring-opacity-75 ring-offset-2 ring-offset-transparent ";
|
4
|
-
export const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-
|
5
|
-
export const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0 transition duration-
|
6
|
-
export const fieldBackgroundDisabledMixin = "bg-opacity-80 dark:bg-opacity-90";
|
7
|
-
export const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-opacity-
|
4
|
+
export const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-700 dark:bg-opacity-40 transition duration-100 ease-in-out";
|
5
|
+
export const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0 transition duration-100 ease-in-out";
|
6
|
+
export const fieldBackgroundDisabledMixin = "dark:bg-gray-800 bg-opacity-80 dark:bg-opacity-90";
|
7
|
+
export const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-opacity-60";
|
8
8
|
export const defaultBorderMixin = "border-gray-100 dark:border-gray-800 dark:border-opacity-80";
|
9
|
-
export const paperMixin = "bg-white rounded-md dark:bg-gray-950 border dark:border-gray-800 dark:border-opacity-
|
10
|
-
export const cardMixin = "bg-white rounded-md dark:bg-gray-950 dark:border-gray-800 dark:border-opacity-50 transition duration-
|
9
|
+
export const paperMixin = "bg-white rounded-md dark:bg-gray-950 border dark:border-gray-800 dark:border-opacity-80 border-gray-100";
|
10
|
+
export 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-100 ease-in-out m-1 -p-1";
|
11
11
|
export 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 const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 dark:bg-opacity-10 ring-1 ring-primary ring-opacity-75";
|