@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
@@ -1,7 +1,8 @@
|
|
1
|
+
"use client";
|
1
2
|
import * as React from "react";
|
2
3
|
import { useLayoutEffect } from "react";
|
3
4
|
import * as ReactDOM from "react-dom";
|
4
|
-
import {
|
5
|
+
import { cls, debounce } from "../util";
|
5
6
|
|
6
7
|
type State = {
|
7
8
|
outerHeightStyle: number;
|
@@ -276,7 +277,7 @@ export const TextareaAutosize = React.forwardRef(function TextareaAutosize(
|
|
276
277
|
/>
|
277
278
|
<textarea
|
278
279
|
aria-hidden
|
279
|
-
className={
|
280
|
+
className={cls(props.className, props.shadowClassName)}
|
280
281
|
readOnly
|
281
282
|
ref={shadowRef}
|
282
283
|
tabIndex={-1}
|
@@ -288,7 +289,7 @@ export const TextareaAutosize = React.forwardRef(function TextareaAutosize(
|
|
288
289
|
/>
|
289
290
|
</React.Fragment>
|
290
291
|
);
|
291
|
-
})
|
292
|
+
}) as React.FC<TextareaAutosizeProps & { ref?: React.ForwardedRef<Element> }>;
|
292
293
|
|
293
294
|
export type TextareaAutosizeProps = Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "onResize"> & {
|
294
295
|
|
@@ -1,34 +1,44 @@
|
|
1
|
+
"use client";
|
1
2
|
import React from "react";
|
2
3
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
3
4
|
|
4
|
-
import {
|
5
|
+
import { cls } from "../util";
|
6
|
+
import { useInjectStyles } from "../hooks";
|
5
7
|
|
6
8
|
export type TooltipProps = {
|
7
9
|
open?: boolean,
|
10
|
+
defaultOpen?: boolean,
|
8
11
|
onOpenChange?: (open: boolean) => void,
|
9
12
|
side?: "top" | "bottom" | "left" | "right",
|
10
13
|
align?: "start" | "center" | "end",
|
11
14
|
sideOffset?: number,
|
12
15
|
title?: string | React.ReactNode,
|
13
16
|
delayDuration?: number;
|
14
|
-
|
17
|
+
asChild?: boolean;
|
15
18
|
tooltipClassName?: string,
|
19
|
+
tooltipStyle?: React.CSSProperties;
|
16
20
|
children: React.ReactNode,
|
21
|
+
className?: string,
|
22
|
+
container?: HTMLElement,
|
17
23
|
style?: React.CSSProperties;
|
18
24
|
};
|
19
25
|
|
20
26
|
export const Tooltip = ({
|
21
27
|
open,
|
28
|
+
defaultOpen,
|
22
29
|
side = "bottom",
|
23
|
-
delayDuration =
|
30
|
+
delayDuration = 200,
|
24
31
|
sideOffset,
|
25
32
|
align,
|
26
33
|
onOpenChange,
|
27
34
|
title,
|
28
|
-
className,
|
29
|
-
style,
|
30
35
|
tooltipClassName,
|
31
|
-
|
36
|
+
tooltipStyle,
|
37
|
+
children,
|
38
|
+
asChild = false,
|
39
|
+
container,
|
40
|
+
className,
|
41
|
+
style
|
32
42
|
}: TooltipProps) => {
|
33
43
|
|
34
44
|
useInjectStyles("Tooltip", styles);
|
@@ -36,25 +46,32 @@ export const Tooltip = ({
|
|
36
46
|
if (!title)
|
37
47
|
return <>{children}</>;
|
38
48
|
|
49
|
+
const trigger = asChild
|
50
|
+
? <TooltipPrimitive.Trigger asChild={true}>
|
51
|
+
{children}
|
52
|
+
</TooltipPrimitive.Trigger>
|
53
|
+
: <TooltipPrimitive.Trigger asChild={true}>
|
54
|
+
<div style={style} className={className}>
|
55
|
+
{children}
|
56
|
+
</div>
|
57
|
+
</TooltipPrimitive.Trigger>;
|
58
|
+
|
39
59
|
return (
|
40
60
|
<TooltipPrimitive.Provider delayDuration={delayDuration}>
|
41
|
-
<TooltipPrimitive.Root open={open} onOpenChange={onOpenChange}>
|
42
|
-
|
43
|
-
|
44
|
-
{children}
|
45
|
-
</div>
|
46
|
-
</TooltipPrimitive.Trigger>
|
47
|
-
<TooltipPrimitive.Portal>
|
61
|
+
<TooltipPrimitive.Root open={open} onOpenChange={onOpenChange} defaultOpen={defaultOpen}>
|
62
|
+
{trigger}
|
63
|
+
<TooltipPrimitive.Portal container={container}>
|
48
64
|
<TooltipPrimitive.Content
|
49
|
-
className={
|
65
|
+
className={cls("TooltipContent",
|
50
66
|
"max-w-lg leading-relaxed",
|
51
|
-
"z-50 rounded px-3 py-2 text-xs leading-none bg-
|
67
|
+
"z-50 rounded px-3 py-2 text-xs leading-none bg-surface-accent-700 dark:bg-surface-accent-800 bg-opacity-90 font-medium text-surface-accent-50 shadow-2xl select-none duration-400 ease-in transform opacity-100",
|
52
68
|
tooltipClassName)}
|
69
|
+
style={tooltipStyle}
|
53
70
|
sideOffset={sideOffset === undefined ? 4 : sideOffset}
|
54
71
|
align={align}
|
55
72
|
side={side}>
|
56
73
|
{title}
|
57
|
-
{/*<TooltipPrimitive.Arrow className="fill-
|
74
|
+
{/*<TooltipPrimitive.Arrow className="fill-surface-accent-600"/>*/}
|
58
75
|
</TooltipPrimitive.Content>
|
59
76
|
</TooltipPrimitive.Portal>
|
60
77
|
</TooltipPrimitive.Root>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React, { ReactEventHandler } from "react";
|
2
|
-
import {
|
3
|
-
import { cn } from "../util";
|
2
|
+
import { cls } from "../util";
|
4
3
|
|
5
|
-
export type
|
4
|
+
export type TypographyVariant = keyof typeof typographyVariants;
|
5
|
+
export type TypographyProps<C extends React.ElementType = "span"> = {
|
6
6
|
align?: "center" | "inherit" | "justify" | "left" | "right";
|
7
7
|
children?: React.ReactNode;
|
8
8
|
className?: string;
|
@@ -10,14 +10,14 @@ export type TextProps<C extends React.ElementType> = {
|
|
10
10
|
gutterBottom?: boolean;
|
11
11
|
noWrap?: boolean;
|
12
12
|
paragraph?: boolean;
|
13
|
-
variant?:
|
13
|
+
variant?: TypographyVariant;
|
14
14
|
variantMapping?: { [key: string]: string };
|
15
15
|
color?: "inherit" | "initial" | "primary" | "secondary" | "disabled" | "error";
|
16
16
|
onClick?: ReactEventHandler<HTMLElement>;
|
17
17
|
style?: React.CSSProperties;
|
18
18
|
} & React.ComponentPropsWithoutRef<C>;
|
19
19
|
|
20
|
-
const
|
20
|
+
const typographyVariants = {
|
21
21
|
h1: "h1",
|
22
22
|
h2: "h2",
|
23
23
|
h3: "h3",
|
@@ -43,24 +43,41 @@ 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
|
-
h1: "
|
48
|
-
h2: "
|
49
|
-
h3: "
|
50
|
-
h4: "
|
51
|
-
h5: "
|
52
|
-
h6: "
|
53
|
-
subtitle1: "
|
54
|
-
subtitle2: "
|
55
|
-
body1: "
|
56
|
-
body2: "
|
57
|
-
label: "
|
58
|
-
inherit: "
|
59
|
-
caption: "
|
60
|
-
button: "
|
64
|
+
h1: "typography-h1",
|
65
|
+
h2: "typography-h2",
|
66
|
+
h3: "typography-h3",
|
67
|
+
h4: "typography-h4",
|
68
|
+
h5: "typography-h5",
|
69
|
+
h6: "typography-h6",
|
70
|
+
subtitle1: "typography-subtitle1",
|
71
|
+
subtitle2: "typography-subtitle2",
|
72
|
+
body1: "typography-body1",
|
73
|
+
body2: "typography-body2",
|
74
|
+
label: "typography-label",
|
75
|
+
inherit: "typography-inherit",
|
76
|
+
caption: "typography-caption",
|
77
|
+
button: "typography-button"
|
61
78
|
};
|
62
79
|
|
63
|
-
export function Typography<C extends React.ElementType>(
|
80
|
+
export function Typography<C extends React.ElementType = "span">(
|
64
81
|
{
|
65
82
|
align = "inherit",
|
66
83
|
color = "primary",
|
@@ -71,23 +88,22 @@ export function Typography<C extends React.ElementType>(
|
|
71
88
|
noWrap = false,
|
72
89
|
paragraph = false,
|
73
90
|
variant = "body1",
|
74
|
-
variantMapping =
|
91
|
+
variantMapping = typographyVariants,
|
75
92
|
style,
|
76
93
|
onClick,
|
77
94
|
...other
|
78
|
-
}:
|
95
|
+
}: TypographyProps<C>
|
79
96
|
) {
|
80
97
|
const Component =
|
81
98
|
component ||
|
82
|
-
(paragraph ? "p" : variantMapping[variant] ||
|
99
|
+
(paragraph ? "p" : variantMapping[variant] || typographyVariants[variant]) ||
|
83
100
|
"span";
|
84
101
|
|
85
|
-
const classes =
|
86
|
-
focusedMixin,
|
102
|
+
const classes = cls(
|
87
103
|
variantToClasses[variant],
|
88
104
|
color ? colorToClasses[color] : "",
|
89
105
|
align !== "inherit" && `text-${align}`,
|
90
|
-
gutterBottom &&
|
106
|
+
gutterBottom && gutterBottomClasses[variant],
|
91
107
|
noWrap && "truncate",
|
92
108
|
paragraph && "mb-3",
|
93
109
|
className
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import {
|
2
|
+
import { cls } from "../../util";
|
3
3
|
|
4
4
|
export function SelectInputLabel({ children, error }: { children: React.ReactNode, error?: boolean }) {
|
5
|
-
return <div className={
|
6
|
-
error ? "text-red-500 dark:text-red-600" : "text-
|
5
|
+
return <div className={cls("text-sm font-medium ml-3.5 mb-1",
|
6
|
+
error ? "text-red-500 dark:text-red-600" : "text-surface-accent-500 dark:text-surface-accent-300",)}>
|
7
7
|
{children}
|
8
8
|
</div>;
|
9
9
|
}
|
package/src/components/index.tsx
CHANGED
@@ -15,6 +15,7 @@ export * from "./DateTimeField";
|
|
15
15
|
export * from "./Dialog";
|
16
16
|
export * from "./DialogActions";
|
17
17
|
export * from "./DialogContent";
|
18
|
+
export * from "./DialogTitle";
|
18
19
|
export * from "./ExpandablePanel";
|
19
20
|
export * from "./FileUpload";
|
20
21
|
export * from "./IconButton";
|
@@ -24,14 +25,15 @@ export * from "./Label";
|
|
24
25
|
export * from "./LoadingButton";
|
25
26
|
export * from "./Markdown";
|
26
27
|
export * from "./Menu";
|
28
|
+
export * from "./Menubar";
|
27
29
|
export * from "./MultiSelect";
|
28
30
|
export * from "./Paper";
|
29
31
|
export * from "./RadioGroup";
|
30
32
|
export * from "./SearchBar";
|
31
33
|
export * from "./Select";
|
32
34
|
export * from "./Separator";
|
35
|
+
export * from "./Slider";
|
33
36
|
export * from "./Sheet";
|
34
|
-
export * from "./Spinner";
|
35
37
|
export * from "./TextareaAutosize";
|
36
38
|
export * from "./TextField";
|
37
39
|
export * from "./Tooltip";
|
package/src/icons/Icon.tsx
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
"use client";
|
2
|
+
|
1
3
|
import * as React from "react";
|
2
|
-
import "
|
3
|
-
import
|
4
|
+
import { cls } from "../util";
|
5
|
+
import "material-icons/iconfont/filled.css";
|
4
6
|
|
5
7
|
export type IconColor = "inherit" | "primary" | "secondary" | "disabled" | "error" | "success" | "warning";
|
6
8
|
export type IconProps = {
|
@@ -8,7 +10,7 @@ export type IconProps = {
|
|
8
10
|
color?: IconColor,
|
9
11
|
className?: string,
|
10
12
|
onClick?: (e: React.SyntheticEvent) => void,
|
11
|
-
style?: React.CSSProperties
|
13
|
+
style?: React.CSSProperties,
|
12
14
|
}
|
13
15
|
|
14
16
|
const colorClassesMapping: Record<IconColor, string> = {
|
@@ -17,47 +19,50 @@ const colorClassesMapping: Record<IconColor, string> = {
|
|
17
19
|
success: "text-green-500",
|
18
20
|
warning: "text-yellow-500",
|
19
21
|
secondary: "text-secondary",
|
20
|
-
disabled: "text-disabled dark:text-disabled-dark",
|
22
|
+
disabled: "text-text-disabled dark:text-text-disabled-dark",
|
21
23
|
error: "text-red-500"
|
22
24
|
}
|
23
25
|
|
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
|
-
|
26
|
+
export const Icon = React.forwardRef<HTMLSpanElement, IconProps & { iconKey: string }>(
|
27
|
+
({
|
28
|
+
iconKey,
|
29
|
+
size = "medium",
|
30
|
+
color,
|
31
|
+
className,
|
32
|
+
onClick,
|
33
|
+
style
|
34
|
+
}, ref) => {
|
35
|
+
let sizeInPx: number;
|
36
|
+
switch (size) {
|
37
|
+
case "smallest":
|
38
|
+
sizeInPx = 16;
|
39
|
+
break;
|
40
|
+
case "small":
|
41
|
+
sizeInPx = 20;
|
42
|
+
break;
|
43
|
+
case "medium":
|
44
|
+
sizeInPx = 24;
|
45
|
+
break;
|
46
|
+
case "large":
|
47
|
+
sizeInPx = 28;
|
48
|
+
break
|
49
|
+
default:
|
50
|
+
sizeInPx = typeof size === "number" ? size : 24;
|
51
|
+
}
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}
|
53
|
+
return <span
|
54
|
+
ref={ref} // Attach the ref to the span
|
55
|
+
style={{
|
56
|
+
fontSize: `${sizeInPx}px`,
|
57
|
+
display: "block",
|
58
|
+
...style
|
59
|
+
}}
|
60
|
+
className={
|
61
|
+
cls("material-icons",
|
62
|
+
color ? colorClassesMapping[color] : "",
|
63
|
+
"select-none",
|
64
|
+
className)}
|
65
|
+
onClick={onClick}>{iconKey}</span>
|
66
|
+
});
|
67
|
+
|
68
|
+
Icon.displayName = "Icon";
|