@firecms/ui 3.0.0-canary.13 → 3.0.0-canary.131

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 (103) hide show
  1. package/README.md +2 -2
  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 +5 -7
  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 +31 -16
  15. package/dist/components/Popover.d.ts +2 -1
  16. package/dist/components/RadioGroup.d.ts +26 -3
  17. package/dist/components/Select.d.ts +6 -10
  18. package/dist/components/Separator.d.ts +2 -1
  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 +6 -2
  24. package/dist/components/_MultiSelect.d.ts +0 -0
  25. package/dist/components/index.d.ts +1 -1
  26. package/dist/hooks/index.d.ts +4 -0
  27. package/dist/hooks/useLocaleConfig.d.ts +1 -0
  28. package/dist/icons/Icon.d.ts +3 -3
  29. package/dist/index.css +77 -0
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.es.js +13178 -13542
  32. package/dist/index.es.js.map +1 -1
  33. package/dist/index.umd.js +19685 -49
  34. package/dist/index.umd.js.map +1 -1
  35. package/dist/styles.d.ts +7 -7
  36. package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
  37. package/dist/util/index.d.ts +1 -3
  38. package/package.json +109 -118
  39. package/src/components/Alert.tsx +2 -2
  40. package/src/components/Autocomplete.tsx +4 -3
  41. package/src/components/Avatar.tsx +7 -6
  42. package/src/components/Badge.tsx +1 -1
  43. package/src/components/BooleanSwitch.tsx +15 -15
  44. package/src/components/BooleanSwitchWithLabel.tsx +8 -8
  45. package/src/components/Button.tsx +18 -20
  46. package/src/components/Card.tsx +3 -3
  47. package/src/components/CenteredView.tsx +25 -15
  48. package/src/components/Checkbox.tsx +11 -9
  49. package/src/components/Chip.tsx +8 -5
  50. package/src/components/CircularProgress.tsx +2 -2
  51. package/src/components/Collapse.tsx +3 -2
  52. package/src/components/Container.tsx +2 -2
  53. package/src/components/DateTimeField.tsx +45 -50
  54. package/src/components/Dialog.tsx +15 -6
  55. package/src/components/DialogActions.tsx +2 -2
  56. package/src/components/DialogContent.tsx +2 -2
  57. package/src/components/ExpandablePanel.tsx +10 -8
  58. package/src/components/FileUpload.tsx +6 -9
  59. package/src/components/IconButton.tsx +4 -6
  60. package/src/components/InfoLabel.tsx +2 -2
  61. package/src/components/InputLabel.tsx +12 -9
  62. package/src/components/Label.tsx +17 -4
  63. package/src/components/Markdown.tsx +14 -3
  64. package/src/components/Menu.tsx +49 -31
  65. package/src/components/Menubar.tsx +322 -0
  66. package/src/components/MultiSelect.tsx +335 -165
  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 +8 -9
  71. package/src/components/Select.tsx +105 -125
  72. package/src/components/Separator.tsx +10 -4
  73. package/src/components/Sheet.tsx +45 -28
  74. package/src/components/Skeleton.tsx +9 -6
  75. package/src/components/Table.tsx +50 -33
  76. package/src/components/Tabs.tsx +6 -7
  77. package/src/components/TextField.tsx +10 -13
  78. package/src/components/TextareaAutosize.tsx +3 -3
  79. package/src/components/Tooltip.tsx +30 -14
  80. package/src/components/Typography.tsx +34 -19
  81. package/src/components/_MultiSelect.tsx +222 -0
  82. package/src/components/common/SelectInputLabel.tsx +2 -2
  83. package/src/components/index.tsx +1 -1
  84. package/src/hooks/index.ts +4 -0
  85. package/src/hooks/useLocaleConfig.tsx +18 -0
  86. package/src/icons/Icon.tsx +46 -43
  87. package/src/icons/icon_keys.ts +114 -1301
  88. package/src/index.css +77 -0
  89. package/src/index.ts +1 -0
  90. package/src/scripts/generateIconKeys.ts +20 -11
  91. package/src/styles.ts +7 -7
  92. package/src/util/cls.ts +14 -0
  93. package/src/util/index.ts +1 -3
  94. package/tailwind.config.js +8 -6
  95. package/dist/components/Spinner.d.ts +0 -1
  96. package/src/components/Spinner.tsx +0 -18
  97. package/src/util/cn.ts +0 -6
  98. /package/dist/{util → hooks}/useDebounceValue.d.ts +0 -0
  99. /package/dist/{util → hooks}/useInjectStyles.d.ts +0 -0
  100. /package/dist/{util → hooks}/useOutsideAlerter.d.ts +0 -0
  101. /package/src/{util → hooks}/useDebounceValue.tsx +0 -0
  102. /package/src/{util → hooks}/useInjectStyles.tsx +0 -0
  103. /package/src/{util → hooks}/useOutsideAlerter.tsx +0 -0
@@ -0,0 +1,222 @@
1
+ // import * as React from "react";
2
+ // import { useEffect } from "react";
3
+ // import * as Dialog from "@radix-ui/react-dialog";
4
+ //
5
+ // import { Command as CommandPrimitive } from "cmdk";
6
+ //
7
+ // import { ExpandMoreIcon } from "../icons";
8
+ // import { fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, fieldBackgroundMixin, focusedDisabled } from "../styles";
9
+ // import { cls } from "../util";
10
+ // import { SelectInputLabel } from "./common/SelectInputLabel";
11
+ // import { useOutsideAlerter } from "../hooks";
12
+ //
13
+ // export type MultiSelectProps = {
14
+ // open?: boolean,
15
+ // name?: string,
16
+ // id?: string,
17
+ // onOpenChange?: (open: boolean) => void,
18
+ // value?: string[],
19
+ // containerClassName?: string,
20
+ // className?: string,
21
+ // inputClassName?: string,
22
+ // onMultiValueChange?: (updatedValue: string[]) => void,
23
+ // placeholder?: React.ReactNode,
24
+ // renderValue?: (values: string, index:number) => React.ReactNode,
25
+ // renderValues?: (values: string[]) => React.ReactNode,
26
+ // size?: "small" | "medium",
27
+ // label?: React.ReactNode,
28
+ // disabled?: boolean,
29
+ // error?: boolean,
30
+ // position?: "item-aligned" | "popper",
31
+ // inputRef?: React.RefObject<HTMLButtonElement>,
32
+ // children?: React.ReactNode,
33
+ // };
34
+ //
35
+ // interface MultiSelectContextProps {
36
+ // fieldValue?: string[];
37
+ // setInputValue: (v: string) => void;
38
+ // onValueChangeInternal: (v: string) => void;
39
+ // }
40
+ //
41
+ // export const MultiSelectContext = React.createContext<MultiSelectContextProps>({} as any);
42
+ //
43
+ // export function MultiSelect({
44
+ // value,
45
+ // open,
46
+ // onMultiValueChange,
47
+ // size = "medium",
48
+ // label,
49
+ // disabled,
50
+ // renderValue,
51
+ // renderValues,
52
+ // containerClassName,
53
+ // className,
54
+ // children,
55
+ // error
56
+ // }: MultiSelectProps) {
57
+ //
58
+ // const containerRef = React.useRef<HTMLInputElement>(null);
59
+ // const inputRef = React.useRef<HTMLInputElement>(null);
60
+ // const listRef = React.useRef<HTMLDivElement>(null);
61
+ // useOutsideAlerter(listRef, () => setOpenInternal(false));
62
+ //
63
+ // const [openInternal, setOpenInternal] = React.useState(false);
64
+ // useEffect(() => {
65
+ // setOpenInternal(open ?? false);
66
+ // }, [open]);
67
+ //
68
+ // const onValueChangeInternal = React.useCallback((newValue: string) => {
69
+ // if (Array.isArray(value) && value.includes(newValue)) {
70
+ // onMultiValueChange?.(value.filter(v => v !== newValue));
71
+ // } else {
72
+ // onMultiValueChange?.([...(value ?? []), newValue]);
73
+ // }
74
+ // }, [value, onMultiValueChange]);
75
+ //
76
+ // const [inputValue, setInputValue] = React.useState("");
77
+ // const [boundingRect, setBoundingRect] = React.useState<DOMRect | null>(null);
78
+ //
79
+ // const handleKeyDown = React.useCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
80
+ // const input = inputRef.current
81
+ // if (input) {
82
+ // if (e.key === "Delete" || e.key === "Backspace") {
83
+ // if (input.value === "") {
84
+ // const newSelected = [...(value ?? [])];
85
+ // newSelected.pop();
86
+ // onMultiValueChange?.(newSelected);
87
+ // }
88
+ // }
89
+ // // This is not a default behaviour of the <input /> field
90
+ // if (e.key === "Escape") {
91
+ // input.blur();
92
+ // setOpenInternal(false);
93
+ // e.stopPropagation();
94
+ // }
95
+ // }
96
+ // }, [onMultiValueChange, value]);
97
+ //
98
+ // const openDialog = React.useCallback(() => {
99
+ // setBoundingRect(containerRef.current?.getBoundingClientRect() ?? null);
100
+ // setOpenInternal(true);
101
+ // }, []);
102
+ //
103
+ // const usedBoundingRect = boundingRect ?? containerRef.current?.getBoundingClientRect();
104
+ // const maxHeight = window.innerHeight - (usedBoundingRect?.top ?? 0) - (usedBoundingRect?.height ?? 0) - 16;
105
+ //
106
+ // return (<>
107
+ //
108
+ // {typeof label === "string" ? <SelectInputLabel error={error}>{label}</SelectInputLabel> : label}
109
+ //
110
+ // <CommandPrimitive onKeyDown={handleKeyDown}
111
+ // onClick={() => {
112
+ // inputRef.current?.focus();
113
+ // openDialog()
114
+ // }}
115
+ // className={cls("relative overflow-visible bg-transparent", containerClassName)}>
116
+ // <div
117
+ // ref={containerRef}
118
+ // className={cls(
119
+ // "flex flex-row",
120
+ // size === "small" ? "min-h-[42px]" : "min-h-[64px]",
121
+ // "select-none rounded-md text-sm",
122
+ // fieldBackgroundMixin,
123
+ // disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
124
+ // "relative flex items-center",
125
+ // "p-4",
126
+ // error ? "text-red-500 dark:text-red-600" : "focus:text-text-primary dark:focus:text-text-primary-dark",
127
+ // error ? "border border-red-500 dark:border-red-600" : "",
128
+ // className)}
129
+ // >
130
+ // <div className={cls("flex-grow flex gap-1.5 flex-wrap items-center")}>
131
+ // {renderValue && (value ?? []).map((v, i) => renderValue(v, i))}
132
+ // {renderValues && renderValues(value ?? [])}
133
+ // <CommandPrimitive.Input
134
+ // ref={inputRef}
135
+ // value={inputValue}
136
+ // onValueChange={setInputValue}
137
+ // // onBlur={() => setOpenInternal(false)}
138
+ // onFocus={openDialog}
139
+ // className={cls("ml-2 bg-transparent outline-none flex-1 h-full w-full ", focusedDisabled)}
140
+ // />
141
+ // </div>
142
+ // <div className={"px-2 h-full flex items-center"}>
143
+ // <ExpandMoreIcon size={"small"}
144
+ // className={cls("transition ", openInternal ? "rotate-180" : "")}/>
145
+ // </div>
146
+ //
147
+ // </div>
148
+ //
149
+ // <Dialog.Root open={openInternal}
150
+ // modal={true}
151
+ // onOpenChange={setOpenInternal}>
152
+ // <Dialog.Portal>
153
+ // <MultiSelectContext.Provider
154
+ // value={{
155
+ // fieldValue: value,
156
+ // setInputValue,
157
+ // onValueChangeInternal
158
+ // }}>
159
+ // <div
160
+ // ref={listRef}
161
+ // className={"z-50 absolute overflow-auto outline-none"}
162
+ // style={{
163
+ // pointerEvents: openInternal ? "auto" : "none",
164
+ // top: (usedBoundingRect?.top ?? 0) + (usedBoundingRect?.height ?? 0),
165
+ // left: usedBoundingRect?.left,
166
+ // width: usedBoundingRect?.width,
167
+ // maxHeight: maxHeight,
168
+ //
169
+ // }}>
170
+ //
171
+ // <CommandPrimitive.Group
172
+ // className="mt-2 text-slate-900 dark:text-white animate-in z-50 border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-800 p-2 rounded-lg shadow-lg flex flex-col outline-none w-full"
173
+ // >
174
+ //
175
+ // {children}
176
+ // </CommandPrimitive.Group>
177
+ //
178
+ // </div>
179
+ // </MultiSelectContext.Provider>
180
+ // </Dialog.Portal>
181
+ // </Dialog.Root>
182
+ // </CommandPrimitive>
183
+ //
184
+ // </>
185
+ // )
186
+ // }
187
+ //
188
+ // export interface MultiSelectItemProps {
189
+ // value: string;
190
+ // children?: React.ReactNode,
191
+ // className?: string;
192
+ // }
193
+ //
194
+ // export function MultiSelectItem({ children, value, className }: MultiSelectItemProps) {
195
+ //
196
+ // const context = React.useContext(MultiSelectContext);
197
+ // if (!context) throw new Error("MultiSelectItem must be used inside a MultiSelect");
198
+ // const { fieldValue, setInputValue, onValueChangeInternal } = context;
199
+ //
200
+ // return <CommandPrimitive.Item
201
+ // onMouseDown={(e) => {
202
+ // e.preventDefault();
203
+ // e.stopPropagation();
204
+ // }}
205
+ // onSelect={(_) => {
206
+ // setInputValue("");
207
+ // onValueChangeInternal(value);
208
+ // }}
209
+ // className={cls(
210
+ // (fieldValue ?? []).includes(value) ? "bg-slate-200 dark:bg-slate-950" : "",
211
+ // "cursor-pointer",
212
+ // "m-1",
213
+ // "ring-offset-transparent",
214
+ // "p-2 rounded aria-[selected=true]:outline-none aria-[selected=true]:ring-2 aria-[selected=true]:ring-primary aria-[selected=true]:ring-opacity-75 aria-[selected=true]:ring-offset-2",
215
+ // "aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
216
+ // "cursor-pointer p-2 rounded aria-[selected=true]:bg-slate-100 aria-[selected=true]:dark:bg-slate-900",
217
+ // className
218
+ // )}
219
+ // >
220
+ // {children}
221
+ // </CommandPrimitive.Item>;
222
+ // }
@@ -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,6 +24,7 @@ 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";
28
29
  export * from "./Paper";
29
30
  export * from "./RadioGroup";
@@ -31,7 +32,6 @@ export * from "./SearchBar";
31
32
  export * from "./Select";
32
33
  export * from "./Separator";
33
34
  export * from "./Sheet";
34
- export * from "./Spinner";
35
35
  export * from "./TextareaAutosize";
36
36
  export * from "./TextField";
37
37
  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";