@firecms/ui 3.0.0-canary.12 → 3.0.0-canary.120

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.
Files changed (101) hide show
  1. package/README.md +1 -1
  2. package/dist/components/Avatar.d.ts +1 -0
  3. package/dist/components/BooleanSwitch.d.ts +1 -1
  4. package/dist/components/CenteredView.d.ts +4 -2
  5. package/dist/components/Checkbox.d.ts +3 -2
  6. package/dist/components/Chip.d.ts +3 -2
  7. package/dist/components/DateTimeField.d.ts +3 -4
  8. package/dist/components/Dialog.d.ts +4 -1
  9. package/dist/components/InputLabel.d.ts +2 -2
  10. package/dist/components/Label.d.ts +4 -1
  11. package/dist/components/Markdown.d.ts +1 -0
  12. package/dist/components/Menu.d.ts +6 -2
  13. package/dist/components/Menubar.d.ts +79 -0
  14. package/dist/components/MultiSelect.d.ts +1 -4
  15. package/dist/components/NewMultiSelect.d.ts +60 -0
  16. package/dist/components/Popover.d.ts +2 -1
  17. package/dist/components/RadioGroup.d.ts +26 -3
  18. package/dist/components/Select.d.ts +4 -4
  19. package/dist/components/Sheet.d.ts +4 -0
  20. package/dist/components/Table.d.ts +10 -10
  21. package/dist/components/TextField.d.ts +1 -1
  22. package/dist/components/TextareaAutosize.d.ts +3 -34
  23. package/dist/components/Tooltip.d.ts +5 -2
  24. package/dist/components/index.d.ts +2 -1
  25. package/dist/hooks/index.d.ts +4 -0
  26. package/dist/hooks/useLocaleConfig.d.ts +1 -0
  27. package/dist/icons/Icon.d.ts +3 -3
  28. package/dist/index.css +77 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.es.js +13290 -13511
  31. package/dist/index.es.js.map +1 -1
  32. package/dist/index.umd.js +19828 -49
  33. package/dist/index.umd.js.map +1 -1
  34. package/dist/styles.d.ts +7 -7
  35. package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
  36. package/dist/util/index.d.ts +1 -3
  37. package/package.json +109 -118
  38. package/src/components/Alert.tsx +2 -2
  39. package/src/components/Autocomplete.tsx +4 -3
  40. package/src/components/Avatar.tsx +7 -6
  41. package/src/components/Badge.tsx +1 -1
  42. package/src/components/BooleanSwitch.tsx +15 -15
  43. package/src/components/BooleanSwitchWithLabel.tsx +8 -8
  44. package/src/components/Button.tsx +11 -13
  45. package/src/components/Card.tsx +3 -3
  46. package/src/components/CenteredView.tsx +25 -15
  47. package/src/components/Checkbox.tsx +11 -9
  48. package/src/components/Chip.tsx +8 -5
  49. package/src/components/CircularProgress.tsx +2 -2
  50. package/src/components/Collapse.tsx +3 -2
  51. package/src/components/Container.tsx +2 -2
  52. package/src/components/DateTimeField.tsx +38 -48
  53. package/src/components/Dialog.tsx +15 -6
  54. package/src/components/DialogActions.tsx +2 -2
  55. package/src/components/DialogContent.tsx +2 -2
  56. package/src/components/ExpandablePanel.tsx +10 -8
  57. package/src/components/FileUpload.tsx +6 -9
  58. package/src/components/IconButton.tsx +4 -6
  59. package/src/components/InfoLabel.tsx +2 -2
  60. package/src/components/InputLabel.tsx +12 -9
  61. package/src/components/Label.tsx +17 -4
  62. package/src/components/Markdown.tsx +14 -3
  63. package/src/components/Menu.tsx +49 -31
  64. package/src/components/Menubar.tsx +322 -0
  65. package/src/components/MultiSelect.tsx +12 -14
  66. package/src/components/NewMultiSelect.tsx +370 -0
  67. package/src/components/Paper.tsx +2 -2
  68. package/src/components/Popover.tsx +17 -14
  69. package/src/components/RadioGroup.tsx +41 -9
  70. package/src/components/SearchBar.tsx +7 -8
  71. package/src/components/Select.tsx +92 -104
  72. package/src/components/Sheet.tsx +45 -28
  73. package/src/components/Skeleton.tsx +9 -6
  74. package/src/components/Table.tsx +50 -32
  75. package/src/components/Tabs.tsx +6 -7
  76. package/src/components/TextField.tsx +10 -13
  77. package/src/components/TextareaAutosize.tsx +3 -3
  78. package/src/components/Tooltip.tsx +27 -13
  79. package/src/components/Typography.tsx +34 -19
  80. package/src/components/common/SelectInputLabel.tsx +2 -2
  81. package/src/components/index.tsx +2 -1
  82. package/src/hooks/index.ts +4 -0
  83. package/src/hooks/useLocaleConfig.tsx +18 -0
  84. package/src/icons/Icon.tsx +46 -43
  85. package/src/icons/icon_keys.ts +114 -1301
  86. package/src/index.css +77 -0
  87. package/src/index.ts +1 -0
  88. package/src/scripts/generateIconKeys.ts +20 -11
  89. package/src/styles.ts +7 -7
  90. package/src/util/cls.ts +14 -0
  91. package/src/util/index.ts +1 -3
  92. package/tailwind.config.js +5 -3
  93. package/dist/components/Spinner.d.ts +0 -1
  94. package/src/components/Spinner.tsx +0 -18
  95. package/src/util/cn.ts +0 -6
  96. /package/dist/{util → hooks}/useDebounceValue.d.ts +0 -0
  97. /package/dist/{util → hooks}/useInjectStyles.d.ts +0 -0
  98. /package/dist/{util → hooks}/useOutsideAlerter.d.ts +0 -0
  99. /package/src/{util → hooks}/useDebounceValue.tsx +0 -0
  100. /package/src/{util → hooks}/useInjectStyles.tsx +0 -0
  101. /package/src/{util → hooks}/useOutsideAlerter.tsx +0 -0
@@ -7,10 +7,9 @@ import {
7
7
  fieldBackgroundInvisibleMixin,
8
8
  fieldBackgroundMixin,
9
9
  focusedInvisibleMixin,
10
- focusedMixin
11
10
  } from "../styles";
12
11
  import { InputLabel } from "./InputLabel";
13
- import { cn } from "../util";
12
+ import { cls } from "../util";
14
13
 
15
14
  export type InputType =
16
15
  "text"
@@ -40,7 +39,7 @@ export type TextFieldProps<T extends string | number> = {
40
39
  endAdornment?: React.ReactNode,
41
40
  autoFocus?: boolean,
42
41
  placeholder?: string,
43
- size?: "small" | "medium",
42
+ size?: "smallest" | "small" | "medium",
44
43
  className?: string,
45
44
  style?: React.CSSProperties,
46
45
  inputClassName?: string,
@@ -70,7 +69,6 @@ export function TextField<T extends string | number>({
70
69
  ...inputProps
71
70
  }: TextFieldProps<T>) {
72
71
 
73
- // eslint-disable-next-line react-hooks/rules-of-hooks
74
72
  const inputRef = inputRefProp ?? useRef(null);
75
73
 
76
74
  // @ts-ignore
@@ -106,13 +104,11 @@ export function TextField<T extends string | number>({
106
104
  placeholder={focused || hasValue || !label ? placeholder : undefined}
107
105
  autoFocus={autoFocus}
108
106
  rows={rows}
109
- // onFocus={() => setFocused(true)}
110
- // onBlur={() => setFocused(false)}
111
107
  value={value ?? ""}
112
108
  onChange={onChange}
113
109
  style={inputStyle}
114
- className={cn(
115
- invisible ? focusedInvisibleMixin : focusedMixin,
110
+ className={cls(
111
+ invisible ? focusedInvisibleMixin : "",
116
112
  "rounded-md resize-none w-full outline-none p-[32px] text-base bg-transparent min-h-[64px] px-3 pt-[28px]",
117
113
  disabled && "border border-transparent outline-none opacity-50 text-slate-600 dark:text-slate-500"
118
114
  )}
@@ -123,12 +119,12 @@ export function TextField<T extends string | number>({
123
119
  onWheel={type === "number" ? numberInputOnWheelPreventChange : undefined}
124
120
  disabled={disabled}
125
121
  style={inputStyle}
126
- className={cn(
122
+ className={cls(
127
123
  "w-full outline-none bg-transparent leading-normal px-3",
128
124
  "rounded-md",
129
- invisible ? focusedInvisibleMixin : focusedMixin,
125
+ invisible ? focusedInvisibleMixin : "",
130
126
  disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
131
- size === "small" ? "min-h-[48px]" : "min-h-[64px]",
127
+ size === "smallest" ? "min-h-[32px]" : (size === "small" ? "min-h-[48px]" : "min-h-[64px]"),
132
128
  label ? (size === "medium" ? "pt-[28px] pb-2" : "pt-4 pb-2") : "py-2",
133
129
  focused ? "text-text-primary dark:text-text-primary-dark" : "",
134
130
  endAdornment ? "pr-10" : "pr-3",
@@ -146,12 +142,13 @@ export function TextField<T extends string | number>({
146
142
 
147
143
  return (
148
144
  <div
149
- className={cn(
145
+ className={cls(
150
146
  "rounded-md relative max-w-full",
151
147
  invisible ? fieldBackgroundInvisibleMixin : fieldBackgroundMixin,
152
148
  disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
153
149
  error ? "border border-red-500 dark:border-red-600" : "",
154
150
  {
151
+ "min-h-[32px]": !invisible && size === "smallest",
155
152
  "min-h-[48px]": !invisible && size === "small",
156
153
  "min-h-[64px]": !invisible && size === "medium"
157
154
  },
@@ -160,7 +157,7 @@ export function TextField<T extends string | number>({
160
157
 
161
158
  {label && (
162
159
  <InputLabel
163
- className={cn(
160
+ className={cls(
164
161
  "pointer-events-none absolute",
165
162
  size === "medium" ? "top-1" : "-top-1",
166
163
  !error ? (focused ? "text-primary dark:text-primary" : "text-text-secondary dark:text-text-secondary-dark") : "text-red-500 dark:text-red-600",
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { useLayoutEffect } from "react";
3
3
  import * as ReactDOM from "react-dom";
4
- import { cn, debounce } from "../util";
4
+ import { cls, debounce } from "../util";
5
5
 
6
6
  type State = {
7
7
  outerHeightStyle: number;
@@ -276,7 +276,7 @@ export const TextareaAutosize = React.forwardRef(function TextareaAutosize(
276
276
  />
277
277
  <textarea
278
278
  aria-hidden
279
- className={cn(props.className, props.shadowClassName)}
279
+ className={cls(props.className, props.shadowClassName)}
280
280
  readOnly
281
281
  ref={shadowRef}
282
282
  tabIndex={-1}
@@ -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,34 +1,41 @@
1
1
  import React from "react";
2
2
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
3
 
4
- import { cn, useInjectStyles } from "../util";
4
+ import { cls } from "../util";
5
+ import { useInjectStyles } from "../hooks";
5
6
 
6
7
  export type TooltipProps = {
7
8
  open?: boolean,
9
+ defaultOpen?: boolean,
8
10
  onOpenChange?: (open: boolean) => void,
9
11
  side?: "top" | "bottom" | "left" | "right",
10
12
  align?: "start" | "center" | "end",
11
13
  sideOffset?: number,
12
14
  title?: string | React.ReactNode,
13
15
  delayDuration?: number;
14
- className?: string,
16
+ asChild?: boolean;
15
17
  tooltipClassName?: string,
18
+ tooltipStyle?: React.CSSProperties;
16
19
  children: React.ReactNode,
20
+ className?: string,
17
21
  style?: React.CSSProperties;
18
22
  };
19
23
 
20
24
  export const Tooltip = ({
21
25
  open,
26
+ defaultOpen,
22
27
  side = "bottom",
23
- delayDuration = 250,
28
+ delayDuration = 200,
24
29
  sideOffset,
25
30
  align,
26
31
  onOpenChange,
27
32
  title,
28
- className,
29
- style,
30
33
  tooltipClassName,
31
- children
34
+ tooltipStyle,
35
+ children,
36
+ asChild = false,
37
+ className,
38
+ style
32
39
  }: TooltipProps) => {
33
40
 
34
41
  useInjectStyles("Tooltip", styles);
@@ -36,20 +43,27 @@ export const Tooltip = ({
36
43
  if (!title)
37
44
  return <>{children}</>;
38
45
 
46
+ const trigger = asChild
47
+ ? <TooltipPrimitive.Trigger asChild={true}>
48
+ {children}
49
+ </TooltipPrimitive.Trigger>
50
+ : <TooltipPrimitive.Trigger asChild={true}>
51
+ <div style={style} className={className}>
52
+ {children}
53
+ </div>
54
+ </TooltipPrimitive.Trigger>;
55
+
39
56
  return (
40
57
  <TooltipPrimitive.Provider delayDuration={delayDuration}>
41
- <TooltipPrimitive.Root open={open} onOpenChange={onOpenChange}>
42
- <TooltipPrimitive.Trigger asChild>
43
- <div className={className} style={style}>
44
- {children}
45
- </div>
46
- </TooltipPrimitive.Trigger>
58
+ <TooltipPrimitive.Root open={open} onOpenChange={onOpenChange} defaultOpen={defaultOpen}>
59
+ {trigger}
47
60
  <TooltipPrimitive.Portal>
48
61
  <TooltipPrimitive.Content
49
- className={cn("TooltipContent",
62
+ className={cls("TooltipContent",
50
63
  "max-w-lg leading-relaxed",
51
64
  "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",
52
65
  tooltipClassName)}
66
+ style={tooltipStyle}
53
67
  sideOffset={sideOffset === undefined ? 4 : sideOffset}
54
68
  align={align}
55
69
  side={side}>
@@ -1,6 +1,5 @@
1
1
  import React, { ReactEventHandler } from "react";
2
- import { focusedMixin } from "../styles";
3
- import { cn } from "../util";
2
+ import { cls } from "../util";
4
3
 
5
4
  export type TextProps<C extends React.ElementType> = {
6
5
  align?: "center" | "inherit" | "justify" | "left" | "right";
@@ -43,21 +42,38 @@ const colorToClasses = {
43
42
  error: "text-red-600 dark:text-red-500"
44
43
  };
45
44
 
45
+ const gutterBottomClasses = {
46
+ h1: "mb-5",
47
+ h2: "mb-4",
48
+ h3: "mb-4",
49
+ h4: "mb-4",
50
+ h5: "mb-3",
51
+ h6: "mb-3",
52
+ subtitle1: "mb-3",
53
+ subtitle2: "mb-3",
54
+ body1: "mb-3",
55
+ body2: "mb-3",
56
+ inherit: "mb-3",
57
+ caption: "mb-2",
58
+ button: "mb-2",
59
+ label: "mb-2"
60
+ };
61
+
46
62
  const variantToClasses = {
47
- h1: "text-6xl font-headers font-light",
48
- h2: "text-5xl font-headers font-light",
49
- h3: "text-4xl font-headers font-normal",
50
- h4: "text-3xl font-headers font-normal",
51
- h5: "text-2xl font-headers font-normal",
52
- h6: "text-xl font-headers font-medium",
53
- subtitle1: "text-lg font-headers font-medium",
54
- subtitle2: "text-base font-headers font-medium",
55
- body1: "text-base",
56
- body2: "text-sm",
57
- label: "text-sm font-medium text-slate-500",
58
- inherit: "text-inherit",
59
- caption: "text-xs",
60
- button: "text-sm font-medium"
63
+ h1: "typography-h1",
64
+ h2: "typography-h2",
65
+ h3: "typography-h3",
66
+ h4: "typography-h4",
67
+ h5: "typography-h5",
68
+ h6: "typography-h6",
69
+ subtitle1: "typography-subtitle1",
70
+ subtitle2: "typography-subtitle2",
71
+ body1: "typography-body1",
72
+ body2: "typography-body2",
73
+ label: "typography-label",
74
+ inherit: "typography-inherit",
75
+ caption: "typography-caption",
76
+ button: "typography-button"
61
77
  };
62
78
 
63
79
  export function Typography<C extends React.ElementType>(
@@ -82,12 +98,11 @@ export function Typography<C extends React.ElementType>(
82
98
  (paragraph ? "p" : variantMapping[variant] || defaultVariantMapping[variant]) ||
83
99
  "span";
84
100
 
85
- const classes = cn(
86
- focusedMixin,
101
+ const classes = cls(
87
102
  variantToClasses[variant],
88
103
  color ? colorToClasses[color] : "",
89
104
  align !== "inherit" && `text-${align}`,
90
- gutterBottom && "mb-[0.35em]",
105
+ gutterBottom && gutterBottomClasses[variant],
91
106
  noWrap && "truncate",
92
107
  paragraph && "mb-3",
93
108
  className
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
- import { cn } from "../../util";
2
+ import { cls } from "../../util";
3
3
 
4
4
  export function SelectInputLabel({ children, error }: { children: React.ReactNode, error?: boolean }) {
5
- return <div className={cn("text-sm font-medium ml-3.5 mb-1",
5
+ return <div className={cls("text-sm font-medium ml-3.5 mb-1",
6
6
  error ? "text-red-500 dark:text-red-600" : "text-slate-500 dark:text-slate-300",)}>
7
7
  {children}
8
8
  </div>;
@@ -24,14 +24,15 @@ export * from "./Label";
24
24
  export * from "./LoadingButton";
25
25
  export * from "./Markdown";
26
26
  export * from "./Menu";
27
+ export * from "./Menubar";
27
28
  export * from "./MultiSelect";
29
+ export * from "./NewMultiSelect";
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";
33
35
  export * from "./Sheet";
34
- export * from "./Spinner";
35
36
  export * from "./TextareaAutosize";
36
37
  export * from "./TextField";
37
38
  export * from "./Tooltip";
@@ -0,0 +1,4 @@
1
+ export * from "./useLocaleConfig";
2
+ export * from "./useInjectStyles";
3
+ export * from "./useOutsideAlerter";
4
+ export * from "./useDebounceValue";
@@ -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
+ }
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
- import "@material-design-icons/font/filled.css";
3
- import { cn } from "../util";
2
+ import { cls } from "../util";
3
+ import 'material-icons/iconfont/filled.css';
4
4
 
5
5
  export type IconColor = "inherit" | "primary" | "secondary" | "disabled" | "error" | "success" | "warning";
6
6
  export type IconProps = {
@@ -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> = {
@@ -17,47 +17,50 @@ const colorClassesMapping: Record<IconColor, string> = {
17
17
  success: "text-green-500",
18
18
  warning: "text-yellow-500",
19
19
  secondary: "text-secondary",
20
- disabled: "text-disabled dark:text-disabled-dark",
20
+ disabled: "text-text-disabled dark:text-text-disabled-dark",
21
21
  error: "text-red-500"
22
22
  }
23
23
 
24
- export function Icon({
25
- iconKey,
26
- size = "medium",
27
- color,
28
- className,
29
- onClick,
30
- style
31
- }: IconProps & { iconKey: string }) {
32
- let sizeInPx: number;
33
- switch (size) {
34
- case "smallest":
35
- sizeInPx = 16;
36
- break;
37
- case "small":
38
- sizeInPx = 20;
39
- break;
40
- case "medium":
41
- sizeInPx = 24;
42
- break;
43
- case "large":
44
- sizeInPx = 28;
45
- break
46
- default:
47
- sizeInPx = size;
48
- }
49
- if (!sizeInPx) sizeInPx = 24;
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
- return <span
52
- style={{
53
- fontSize: `${sizeInPx}px`,
54
- display: "block",
55
- ...style
56
- }}
57
- className={
58
- cn("material-icons",
59
- color ? colorClassesMapping[color] : "",
60
- "select-none",
61
- className)}
62
- onClick={onClick}>{iconKey}</span>
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
+ cls("material-icons",
60
+ color ? colorClassesMapping[color] : "",
61
+ "select-none",
62
+ className)}
63
+ onClick={onClick}>{iconKey}</span>
64
+ });
65
+
66
+ Icon.displayName = "Icon";