@firecms/ui 3.1.0-canary.24c8270 → 3.1.0-canary.501d471
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/dist/components/BooleanSwitchWithLabel.d.ts +2 -1
- package/dist/components/Chip.d.ts +1 -1
- package/dist/components/ResizablePanels.d.ts +16 -0
- package/dist/components/SearchableSelect.d.ts +48 -0
- package/dist/components/Tabs.d.ts +8 -1
- package/dist/components/Tooltip.d.ts +18 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/icons/FirestoreIcon.d.ts +6 -0
- package/dist/icons/components/DatabaseIcon.d.ts +6 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/index.es.js +1377 -478
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1379 -480
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/components/BooleanSwitchWithLabel.tsx +4 -0
- package/src/components/Button.tsx +2 -1
- package/src/components/Chip.tsx +4 -3
- package/src/components/DateTimeField.tsx +7 -2
- package/src/components/MultiSelect.tsx +23 -4
- package/src/components/ResizablePanels.tsx +181 -0
- package/src/components/SearchableSelect.tsx +335 -0
- package/src/components/Skeleton.tsx +4 -2
- package/src/components/Tabs.tsx +44 -16
- package/src/components/TextareaAutosize.tsx +77 -212
- package/src/components/Tooltip.tsx +7 -6
- package/src/components/index.tsx +2 -0
- package/src/icons/FirestoreIcon.tsx +47 -0
- package/src/icons/components/DatabaseIcon.tsx +10 -0
- package/src/icons/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.1.0-canary.
|
|
4
|
+
"version": "3.1.0-canary.501d471",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"index.css",
|
|
115
115
|
"tailwind.config.js"
|
|
116
116
|
],
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "ed0d4e02d670aff9297a710a1d45a1095a1cbaea",
|
|
118
118
|
"publishConfig": {
|
|
119
119
|
"access": "public"
|
|
120
120
|
}
|
|
@@ -18,6 +18,7 @@ export type BooleanSwitchWithLabelProps = BooleanSwitchProps & {
|
|
|
18
18
|
fullWidth?: boolean,
|
|
19
19
|
className?: string,
|
|
20
20
|
inputClassName?: string,
|
|
21
|
+
switchAdornment?: React.ReactNode,
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -37,6 +38,7 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
|
37
38
|
className,
|
|
38
39
|
fullWidth = true,
|
|
39
40
|
inputClassName,
|
|
41
|
+
switchAdornment,
|
|
40
42
|
...props
|
|
41
43
|
}: BooleanSwitchWithLabelProps) {
|
|
42
44
|
|
|
@@ -100,6 +102,8 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
|
|
|
100
102
|
{...props}
|
|
101
103
|
/>
|
|
102
104
|
|
|
105
|
+
{switchAdornment}
|
|
106
|
+
|
|
103
107
|
<div className={cls(
|
|
104
108
|
"flex-grow",
|
|
105
109
|
position === "end" ? "mr-4" : "ml-4",
|
|
@@ -28,6 +28,7 @@ const ButtonInner = React.memo(React.forwardRef<
|
|
|
28
28
|
fullWidth = false,
|
|
29
29
|
component: Component,
|
|
30
30
|
color = "neutral",
|
|
31
|
+
loading,
|
|
31
32
|
...props
|
|
32
33
|
}: ButtonProps<any>, ref) => {
|
|
33
34
|
|
|
@@ -63,7 +64,7 @@ const ButtonInner = React.memo(React.forwardRef<
|
|
|
63
64
|
"text-text-disabled dark:text-text-disabled-dark": disabled,
|
|
64
65
|
"border border-transparent opacity-50": variant === "text" && disabled,
|
|
65
66
|
"border border-surface-500 opacity-50": variant === "outlined" && disabled,
|
|
66
|
-
"border border-transparent bg-surface-300 dark:bg-surface-500 opacity-
|
|
67
|
+
"border border-transparent bg-surface-300 dark:bg-surface-500 opacity-70 bg-surface-300/70 dark:bg-surface-500/70": variant === "filled" && disabled,
|
|
67
68
|
});
|
|
68
69
|
|
|
69
70
|
const sizeClasses = cls(
|
package/src/components/Chip.tsx
CHANGED
|
@@ -29,7 +29,7 @@ const sizeClassNames = {
|
|
|
29
29
|
/**
|
|
30
30
|
* @group Preview components
|
|
31
31
|
*/
|
|
32
|
-
export function Chip({
|
|
32
|
+
export const Chip = React.forwardRef<HTMLDivElement, ChipProps>(function Chip({
|
|
33
33
|
children,
|
|
34
34
|
colorScheme,
|
|
35
35
|
error,
|
|
@@ -39,11 +39,12 @@ export function Chip({
|
|
|
39
39
|
size = "large",
|
|
40
40
|
className,
|
|
41
41
|
style
|
|
42
|
-
}: ChipProps) {
|
|
42
|
+
}: ChipProps, ref) {
|
|
43
43
|
|
|
44
44
|
const usedColorScheme = typeof colorScheme === "string" ? getColorSchemeForKey(colorScheme) : colorScheme;
|
|
45
45
|
return (
|
|
46
46
|
<div
|
|
47
|
+
ref={ref}
|
|
47
48
|
className={cls("rounded-lg max-w-full w-max h-fit font-regular inline-flex gap-1",
|
|
48
49
|
"text-ellipsis",
|
|
49
50
|
"items-center",
|
|
@@ -67,4 +68,4 @@ export function Chip({
|
|
|
67
68
|
{icon}
|
|
68
69
|
</div>
|
|
69
70
|
);
|
|
70
|
-
}
|
|
71
|
+
});
|
|
@@ -51,7 +51,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
51
51
|
const [focused, setFocused] = useState(false);
|
|
52
52
|
const [internalValue, setInternalValue] = useState<string>("");
|
|
53
53
|
const [isTyping, setIsTyping] = useState(false);
|
|
54
|
-
const invalidValue = value !== undefined && value !== null && !(value instanceof Date);
|
|
54
|
+
const invalidValue = value !== undefined && value !== null && (!(value instanceof Date) || isNaN((value as Date).getTime()));
|
|
55
55
|
|
|
56
56
|
useInjectStyles("DateTimeField", inputStyles);
|
|
57
57
|
|
|
@@ -84,7 +84,12 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
const formatter = new Intl.DateTimeFormat("en-CA", options);
|
|
87
|
-
|
|
87
|
+
let parts: Intl.DateTimeFormatPart[];
|
|
88
|
+
try {
|
|
89
|
+
parts = formatter.formatToParts(dateValue);
|
|
90
|
+
} catch {
|
|
91
|
+
return "";
|
|
92
|
+
}
|
|
88
93
|
|
|
89
94
|
const getPart = (type: string) => parts.find(p => p.type === type)?.value ?? "";
|
|
90
95
|
|
|
@@ -90,6 +90,7 @@ export const MultiSelect = React.forwardRef<
|
|
|
90
90
|
open,
|
|
91
91
|
onOpenChange,
|
|
92
92
|
portalContainer,
|
|
93
|
+
endAdornment,
|
|
93
94
|
},
|
|
94
95
|
ref
|
|
95
96
|
) => {
|
|
@@ -269,7 +270,7 @@ export const MultiSelect = React.forwardRef<
|
|
|
269
270
|
})}
|
|
270
271
|
</div>
|
|
271
272
|
<div className="flex items-center justify-between">
|
|
272
|
-
{includeClear && <CloseIcon
|
|
273
|
+
{includeClear && !endAdornment && <CloseIcon
|
|
273
274
|
className={"ml-4"}
|
|
274
275
|
size={"small"}
|
|
275
276
|
onClick={(event) => {
|
|
@@ -277,6 +278,14 @@ export const MultiSelect = React.forwardRef<
|
|
|
277
278
|
handleClear();
|
|
278
279
|
}}
|
|
279
280
|
/>}
|
|
281
|
+
{endAdornment && (
|
|
282
|
+
<div className="ml-4 flex items-center" onClick={(e) => {
|
|
283
|
+
e.preventDefault();
|
|
284
|
+
e.stopPropagation();
|
|
285
|
+
}}>
|
|
286
|
+
{endAdornment}
|
|
287
|
+
</div>
|
|
288
|
+
)}
|
|
280
289
|
<div className={cls("px-2 h-full flex items-center")}>
|
|
281
290
|
<KeyboardArrowDownIcon size={size === "large" ? "medium" : "small"}
|
|
282
291
|
className={cls("transition", isPopoverOpen ? "rotate-180" : "")} />
|
|
@@ -288,9 +297,19 @@ export const MultiSelect = React.forwardRef<
|
|
|
288
297
|
<span className="text-sm">
|
|
289
298
|
{placeholder}
|
|
290
299
|
</span>
|
|
291
|
-
<div className=
|
|
292
|
-
|
|
293
|
-
className=
|
|
300
|
+
<div className="flex items-center justify-between">
|
|
301
|
+
{endAdornment && (
|
|
302
|
+
<div className="ml-4 flex items-center" onClick={(e) => {
|
|
303
|
+
e.preventDefault();
|
|
304
|
+
e.stopPropagation();
|
|
305
|
+
}}>
|
|
306
|
+
{endAdornment}
|
|
307
|
+
</div>
|
|
308
|
+
)}
|
|
309
|
+
<div className={cls("px-2 h-full flex items-center")}>
|
|
310
|
+
<KeyboardArrowDownIcon size={size === "large" ? "medium" : "small"}
|
|
311
|
+
className={cls("transition", isPopoverOpen ? "rotate-180" : "")} />
|
|
312
|
+
</div>
|
|
294
313
|
</div>
|
|
295
314
|
</div>
|
|
296
315
|
)}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { cls } from "../util";
|
|
3
|
+
|
|
4
|
+
export type ResizablePanelsProps = {
|
|
5
|
+
firstPanel: React.ReactNode;
|
|
6
|
+
secondPanel: React.ReactNode;
|
|
7
|
+
/** Whether the first panel is visible (e.g. Sidebar) */
|
|
8
|
+
showFirstPanel?: boolean;
|
|
9
|
+
/** Whether the second panel is visible (e.g. Results) */
|
|
10
|
+
showSecondPanel?: boolean;
|
|
11
|
+
/** 0-100 representing the width/height of the first panel */
|
|
12
|
+
panelSizePercent: number;
|
|
13
|
+
onPanelSizeChange: (sizePercent: number) => void;
|
|
14
|
+
minPanelSizePx?: number;
|
|
15
|
+
orientation?: 'horizontal' | 'vertical';
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function ResizablePanels({
|
|
20
|
+
firstPanel,
|
|
21
|
+
secondPanel,
|
|
22
|
+
showFirstPanel = true,
|
|
23
|
+
showSecondPanel = true,
|
|
24
|
+
panelSizePercent,
|
|
25
|
+
onPanelSizeChange,
|
|
26
|
+
minPanelSizePx = 200,
|
|
27
|
+
orientation = 'horizontal',
|
|
28
|
+
className
|
|
29
|
+
}: ResizablePanelsProps) {
|
|
30
|
+
|
|
31
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
32
|
+
const isResizingRef = useRef(false);
|
|
33
|
+
|
|
34
|
+
// For local layout tracking without triggering React rerenders during drag
|
|
35
|
+
const firstPanelRef = useRef<HTMLDivElement>(null);
|
|
36
|
+
const startPosRef = useRef(0);
|
|
37
|
+
const startSizeRef = useRef(0);
|
|
38
|
+
|
|
39
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
40
|
+
const isHorizontal = orientation === 'horizontal';
|
|
41
|
+
|
|
42
|
+
const handleResizeStart = useCallback((e: React.MouseEvent) => {
|
|
43
|
+
if (!showFirstPanel || !showSecondPanel) return;
|
|
44
|
+
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
isResizingRef.current = true;
|
|
47
|
+
setIsResizing(true);
|
|
48
|
+
|
|
49
|
+
startPosRef.current = isHorizontal ? e.clientX : e.clientY;
|
|
50
|
+
|
|
51
|
+
if (firstPanelRef.current) {
|
|
52
|
+
const rect = firstPanelRef.current.getBoundingClientRect();
|
|
53
|
+
startSizeRef.current = isHorizontal ? rect.width : rect.height;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
document.body.style.cursor = isHorizontal ? 'col-resize' : 'row-resize';
|
|
57
|
+
document.body.style.userSelect = 'none';
|
|
58
|
+
}, [isHorizontal, showFirstPanel, showSecondPanel]);
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const handleMouseMove = (e: MouseEvent) => {
|
|
62
|
+
if (!isResizingRef.current || !containerRef.current) return;
|
|
63
|
+
|
|
64
|
+
const currentPos = isHorizontal ? e.clientX : e.clientY;
|
|
65
|
+
const delta = currentPos - startPosRef.current; // Dragging right/down increases first panel size
|
|
66
|
+
|
|
67
|
+
let newSize = startSizeRef.current + delta;
|
|
68
|
+
|
|
69
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
70
|
+
const containerTotal = isHorizontal ? containerRect.width : containerRect.height;
|
|
71
|
+
|
|
72
|
+
// Limit the maximum size to prevent pushing the second panel offscreen
|
|
73
|
+
const maxSize = containerTotal - minPanelSizePx;
|
|
74
|
+
|
|
75
|
+
newSize = Math.max(minPanelSizePx, Math.min(newSize, maxSize));
|
|
76
|
+
|
|
77
|
+
// Directly update the DOM for performance while dragging
|
|
78
|
+
if (firstPanelRef.current) {
|
|
79
|
+
if (isHorizontal) {
|
|
80
|
+
firstPanelRef.current.style.width = `${newSize}px`;
|
|
81
|
+
} else {
|
|
82
|
+
firstPanelRef.current.style.height = `${newSize}px`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleMouseUp = () => {
|
|
88
|
+
if (isResizingRef.current && containerRef.current && firstPanelRef.current) {
|
|
89
|
+
isResizingRef.current = false;
|
|
90
|
+
setIsResizing(false);
|
|
91
|
+
document.body.style.cursor = "";
|
|
92
|
+
document.body.style.userSelect = "";
|
|
93
|
+
|
|
94
|
+
// Calculate the final percentage and notify parent
|
|
95
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
96
|
+
const firstPanelRect = firstPanelRef.current.getBoundingClientRect();
|
|
97
|
+
|
|
98
|
+
const containerSize = isHorizontal ? containerRect.width : containerRect.height;
|
|
99
|
+
const finalSize = isHorizontal ? firstPanelRect.width : firstPanelRect.height;
|
|
100
|
+
|
|
101
|
+
if (containerSize > 0) {
|
|
102
|
+
const newPercent = (finalSize / containerSize) * 100;
|
|
103
|
+
onPanelSizeChange(Math.max(0, Math.min(100, newPercent)));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
109
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
110
|
+
|
|
111
|
+
return () => {
|
|
112
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
113
|
+
window.removeEventListener("mouseup", handleMouseUp);
|
|
114
|
+
};
|
|
115
|
+
}, [onPanelSizeChange, isHorizontal, minPanelSizePx]);
|
|
116
|
+
|
|
117
|
+
// Calculate applied size
|
|
118
|
+
const appliedBasis = !showFirstPanel ? "0%" : (showSecondPanel ? `${panelSizePercent}%` : "100%");
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div
|
|
122
|
+
ref={containerRef}
|
|
123
|
+
className={cls(
|
|
124
|
+
"relative w-full h-full flex overflow-hidden",
|
|
125
|
+
isHorizontal ? "flex-row" : "flex-col",
|
|
126
|
+
className
|
|
127
|
+
)}
|
|
128
|
+
>
|
|
129
|
+
{/* First Panel */}
|
|
130
|
+
<div
|
|
131
|
+
ref={firstPanelRef}
|
|
132
|
+
className={cls(
|
|
133
|
+
"relative flex-shrink-0 flex flex-col overflow-hidden",
|
|
134
|
+
!showFirstPanel && "hidden"
|
|
135
|
+
)}
|
|
136
|
+
style={{
|
|
137
|
+
width: isHorizontal ? appliedBasis : "100%",
|
|
138
|
+
height: !isHorizontal ? appliedBasis : "100%",
|
|
139
|
+
minWidth: isHorizontal && showFirstPanel && showSecondPanel ? `${minPanelSizePx}px` : undefined,
|
|
140
|
+
minHeight: !isHorizontal && showFirstPanel && showSecondPanel ? `${minPanelSizePx}px` : undefined,
|
|
141
|
+
maxWidth: showSecondPanel ? undefined : "100%",
|
|
142
|
+
maxHeight: showSecondPanel ? undefined : "100%",
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
{firstPanel}
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
{/* Divider */}
|
|
149
|
+
{showFirstPanel && showSecondPanel && (
|
|
150
|
+
<div
|
|
151
|
+
className={cls(
|
|
152
|
+
"relative z-10 flex flex-shrink-0 items-center justify-center",
|
|
153
|
+
isHorizontal ? "w-px h-full cursor-col-resize" : "h-px w-full cursor-row-resize"
|
|
154
|
+
)}
|
|
155
|
+
onMouseDown={handleResizeStart}
|
|
156
|
+
>
|
|
157
|
+
{/* Transparent Hit Area with Pill inside */}
|
|
158
|
+
<div className={cls(
|
|
159
|
+
"absolute flex items-center justify-center group",
|
|
160
|
+
isHorizontal ? "w-4 h-full cursor-col-resize top-0" : "h-4 w-full cursor-row-resize left-0"
|
|
161
|
+
)}>
|
|
162
|
+
<div className={cls(
|
|
163
|
+
"bg-primary/60 dark:bg-primary rounded-full opacity-0 group-hover:opacity-100 transition-all duration-200",
|
|
164
|
+
isHorizontal ? "w-1 h-8" : "h-1 w-8"
|
|
165
|
+
)} />
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
)}
|
|
169
|
+
|
|
170
|
+
{/* Second Panel */}
|
|
171
|
+
<div
|
|
172
|
+
className={cls(
|
|
173
|
+
"flex-grow relative flex flex-col overflow-hidden min-w-0 min-h-0",
|
|
174
|
+
!showSecondPanel && "hidden"
|
|
175
|
+
)}
|
|
176
|
+
>
|
|
177
|
+
{secondPanel}
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
);
|
|
181
|
+
}
|