@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.
- package/README.md +2 -2
- package/dist/components/Avatar.d.ts +1 -0
- package/dist/components/BooleanSwitch.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/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 +31 -16
- package/dist/components/Popover.d.ts +2 -1
- package/dist/components/RadioGroup.d.ts +26 -3
- package/dist/components/Select.d.ts +6 -10
- package/dist/components/Separator.d.ts +2 -1
- package/dist/components/Sheet.d.ts +4 -0
- package/dist/components/Table.d.ts +10 -10
- 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/_MultiSelect.d.ts +0 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useLocaleConfig.d.ts +1 -0
- package/dist/icons/Icon.d.ts +3 -3
- package/dist/index.css +77 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +13178 -13542
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19685 -49
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +7 -7
- package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
- package/dist/util/index.d.ts +1 -3
- package/package.json +109 -118
- package/src/components/Alert.tsx +2 -2
- package/src/components/Autocomplete.tsx +4 -3
- package/src/components/Avatar.tsx +7 -6
- package/src/components/Badge.tsx +1 -1
- package/src/components/BooleanSwitch.tsx +15 -15
- package/src/components/BooleanSwitchWithLabel.tsx +8 -8
- package/src/components/Button.tsx +18 -20
- package/src/components/Card.tsx +3 -3
- package/src/components/CenteredView.tsx +25 -15
- package/src/components/Checkbox.tsx +11 -9
- package/src/components/Chip.tsx +8 -5
- package/src/components/CircularProgress.tsx +2 -2
- package/src/components/Collapse.tsx +3 -2
- package/src/components/Container.tsx +2 -2
- package/src/components/DateTimeField.tsx +45 -50
- package/src/components/Dialog.tsx +15 -6
- package/src/components/DialogActions.tsx +2 -2
- package/src/components/DialogContent.tsx +2 -2
- package/src/components/ExpandablePanel.tsx +10 -8
- package/src/components/FileUpload.tsx +6 -9
- package/src/components/IconButton.tsx +4 -6
- package/src/components/InfoLabel.tsx +2 -2
- package/src/components/InputLabel.tsx +12 -9
- package/src/components/Label.tsx +17 -4
- package/src/components/Markdown.tsx +14 -3
- package/src/components/Menu.tsx +49 -31
- package/src/components/Menubar.tsx +322 -0
- package/src/components/MultiSelect.tsx +335 -165
- package/src/components/Paper.tsx +2 -2
- package/src/components/Popover.tsx +17 -14
- package/src/components/RadioGroup.tsx +41 -9
- package/src/components/SearchBar.tsx +8 -9
- package/src/components/Select.tsx +105 -125
- package/src/components/Separator.tsx +10 -4
- package/src/components/Sheet.tsx +45 -28
- package/src/components/Skeleton.tsx +9 -6
- package/src/components/Table.tsx +50 -33
- package/src/components/Tabs.tsx +6 -7
- package/src/components/TextField.tsx +10 -13
- package/src/components/TextareaAutosize.tsx +3 -3
- package/src/components/Tooltip.tsx +30 -14
- package/src/components/Typography.tsx +34 -19
- package/src/components/_MultiSelect.tsx +222 -0
- package/src/components/common/SelectInputLabel.tsx +2 -2
- package/src/components/index.tsx +1 -1
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useLocaleConfig.tsx +18 -0
- package/src/icons/Icon.tsx +46 -43
- package/src/icons/icon_keys.ts +114 -1301
- package/src/index.css +77 -0
- package/src/index.ts +1 -0
- package/src/scripts/generateIconKeys.ts +20 -11
- package/src/styles.ts +7 -7
- package/src/util/cls.ts +14 -0
- package/src/util/index.ts +1 -3
- package/tailwind.config.js +8 -6
- 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/src/{util → hooks}/useDebounceValue.tsx +0 -0
- /package/src/{util → hooks}/useInjectStyles.tsx +0 -0
- /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 {
|
2
|
+
import { cls } from "../../util";
|
3
3
|
|
4
4
|
export function SelectInputLabel({ children, error }: { children: React.ReactNode, error?: boolean }) {
|
5
|
-
return <div className={
|
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>;
|
package/src/components/index.tsx
CHANGED
@@ -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,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
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React from "react";
|
2
|
-
import "
|
3
|
-
import
|
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
|
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
|
+
cls("material-icons",
|
60
|
+
color ? colorClassesMapping[color] : "",
|
61
|
+
"select-none",
|
62
|
+
className)}
|
63
|
+
onClick={onClick}>{iconKey}</span>
|
64
|
+
});
|
65
|
+
|
66
|
+
Icon.displayName = "Icon";
|