@firecms/ui 3.0.0-canary.136 → 3.0.0-canary.138

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 (36) hide show
  1. package/README.md +1 -1
  2. package/dist/hooks/index.d.ts +0 -1
  3. package/dist/index.css +0 -4
  4. package/dist/index.es.js +141 -965
  5. package/dist/index.es.js.map +1 -1
  6. package/dist/index.umd.js +143 -966
  7. package/dist/index.umd.js.map +1 -1
  8. package/package.json +2 -3
  9. package/src/components/Autocomplete.tsx +1 -0
  10. package/src/components/Avatar.tsx +1 -1
  11. package/src/components/BooleanSwitchWithLabel.tsx +1 -0
  12. package/src/components/Card.tsx +1 -0
  13. package/src/components/Collapse.tsx +1 -0
  14. package/src/components/DateTimeField.tsx +133 -907
  15. package/src/components/DebouncedTextField.tsx +1 -0
  16. package/src/components/Dialog.tsx +1 -0
  17. package/src/components/DialogContent.tsx +1 -1
  18. package/src/components/DialogTitle.tsx +3 -2
  19. package/src/components/ExpandablePanel.tsx +3 -0
  20. package/src/components/FileUpload.tsx +1 -0
  21. package/src/components/InputLabel.tsx +0 -1
  22. package/src/components/Markdown.tsx +1 -0
  23. package/src/components/MultiSelect.tsx +2 -1
  24. package/src/components/Popover.tsx +1 -0
  25. package/src/components/SearchBar.tsx +1 -0
  26. package/src/components/Select.tsx +21 -28
  27. package/src/components/Sheet.tsx +1 -1
  28. package/src/components/TextField.tsx +3 -2
  29. package/src/components/TextareaAutosize.tsx +1 -0
  30. package/src/components/Tooltip.tsx +1 -0
  31. package/src/hooks/index.ts +0 -1
  32. package/src/index.css +0 -4
  33. package/dist/components/_MultiSelect.d.ts +0 -0
  34. package/dist/hooks/useLocaleConfig.d.ts +0 -1
  35. package/src/components/_MultiSelect.tsx +0 -222
  36. package/src/hooks/useLocaleConfig.tsx +0 -18
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React, { ChangeEvent, useCallback, useDeferredValue, useEffect } from "react";
2
3
  import { TextField, TextFieldProps } from "./index";
3
4
 
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React, { useEffect, useState } from "react";
2
3
  import * as DialogPrimitive from "@radix-ui/react-dialog";
3
4
  import { paperMixin } from "../styles";
@@ -17,7 +17,7 @@ export function DialogContent({
17
17
  </div>;
18
18
 
19
19
  return <div
20
- className={cls("py-6 px-6 h-full flex-grow", className)}>
20
+ className={cls("my-6 mx-6 h-full flex-grow", className)}>
21
21
  {children}
22
22
  </div>;
23
23
  }
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import * as DialogPrimitive from "@radix-ui/react-dialog";
3
3
  import * as VisuallyHidden from "@radix-ui/react-visually-hidden";
4
4
  import { Typography, TypographyProps, TypographyVariant } from "./Typography";
5
+ import { cls } from "../util";
5
6
 
6
7
  export type DialogContentProps = TypographyProps & {
7
8
  children: React.ReactNode,
@@ -14,13 +15,13 @@ export function DialogTitle({
14
15
  children,
15
16
  hidden,
16
17
  className,
17
- variant = "h4",
18
+ variant = "subtitle2",
18
19
  ...props
19
20
  }: DialogContentProps) {
20
21
 
21
22
  const title = <DialogPrimitive.Title asChild>
22
23
  <Typography variant={variant}
23
- className={className}
24
+ className={cls("mt-8 mb-6 mx-6", className)}
24
25
  {...props}>
25
26
  {children}
26
27
  </Typography>
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React, { PropsWithChildren, useEffect, useState } from "react";
2
3
 
3
4
  import * as Collapsible from "@radix-ui/react-collapsible";
@@ -95,6 +96,8 @@ export function ExpandablePanel({
95
96
  "rounded-t flex items-center justify-between w-full min-h-[52px]",
96
97
  "hover:bg-slate-200 hover:bg-opacity-20 dark:hover:bg-gray-800 dark:hover:bg-opacity-20",
97
98
  invisible ? "border-b px-2" : "p-4",
99
+ open ? "py-6" : "py-4",
100
+ "transition-all duration-200",
98
101
  invisible && defaultBorderMixin,
99
102
  asField && fieldBackgroundMixin,
100
103
  titleClassName
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React from "react";
2
3
  import { useDropzone } from "react-dropzone";
3
4
  import { fieldBackgroundHoverMixin, fieldBackgroundMixin } from "../styles";
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
2
  import { cls } from "../util";
3
- import { Label } from "./Label";
4
3
  import { defaultBorderMixin } from "../styles";
5
4
 
6
5
  export type InputLabelProps = {
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React, { useMemo } from "react";
2
3
  import equal from "react-fast-compare"
3
4
 
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import * as PopoverPrimitive from "@radix-ui/react-popover";
2
3
  import * as React from "react";
3
4
  import { ChangeEvent, Children, useEffect } from "react";
@@ -81,7 +82,7 @@ export const MultiSelect = React.forwardRef<
81
82
  invisible,
82
83
  disabled,
83
84
  placeholder,
84
- modalPopover = false,
85
+ modalPopover = true,
85
86
  includeClear = true,
86
87
  useChips = true,
87
88
  className,
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React from "react";
2
3
  import * as PopoverPrimitive from "@radix-ui/react-popover";
3
4
 
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React, { useCallback, useState } from "react";
2
3
 
3
4
  import { defaultBorderMixin } from "../styles";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React, { ChangeEvent, forwardRef, useCallback, useEffect, useState } from "react";
2
3
  import * as SelectPrimitive from "@radix-ui/react-select";
3
4
  import {
@@ -80,7 +81,7 @@ export const Select = forwardRef<HTMLDivElement, SelectProps>(({
80
81
  }
81
82
  }, [onChange, value, onValueChange]);
82
83
 
83
- const hasValue = Array.isArray(value) ? value.length > 0 : value != null;
84
+ const hasValue = Array.isArray(value) ? value.length > 0 : (value != null && value !== "" && value !== undefined);
84
85
 
85
86
  return (
86
87
  <SelectPrimitive.Root
@@ -93,8 +94,7 @@ export const Select = forwardRef<HTMLDivElement, SelectProps>(({
93
94
  onOpenChange?.(open);
94
95
  setOpenInternal(open);
95
96
  }}
96
- {...props}
97
- >
97
+ {...props}>
98
98
  {typeof label === "string" ? <SelectInputLabel error={error}>{label}</SelectInputLabel> : label}
99
99
  <div className={cls(
100
100
  size === "small" ? "min-h-[42px]" : "min-h-[64px]",
@@ -103,8 +103,7 @@ export const Select = forwardRef<HTMLDivElement, SelectProps>(({
103
103
  disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
104
104
  "relative flex items-center",
105
105
  className
106
- )}
107
- >
106
+ )}>
108
107
  <SelectPrimitive.Trigger
109
108
  ref={inputRef}
110
109
  id={id}
@@ -117,15 +116,10 @@ export const Select = forwardRef<HTMLDivElement, SelectProps>(({
117
116
  error ? "text-red-500 dark:text-red-600" : "focus:text-text-primary dark:focus:text-text-primary-dark",
118
117
  error ? "border border-red-500 dark:border-red-600" : "",
119
118
  disabled ? "text-slate-600 dark:text-slate-400" : "text-slate-800 dark:text-white",
120
- "relative flex items-center",
119
+ "relative flex flex-row items-center",
121
120
  inputClassName
122
- )}
121
+ )}>
123
122
 
124
- onClick={(e) => {
125
- e.preventDefault();
126
- e.stopPropagation();
127
- }}
128
- >
129
123
  <div
130
124
  ref={ref}
131
125
  className={cls(
@@ -145,20 +139,23 @@ export const Select = forwardRef<HTMLDivElement, SelectProps>(({
145
139
  {hasValue && !renderValue && value}
146
140
  </SelectPrimitive.Value>
147
141
  </div>
148
- <SelectPrimitive.Icon className={cls("px-2 h-full flex items-center")}>
149
- <ExpandMoreIcon size={"small"} className={cls("transition", open ? "rotate-180" : "")}/>
142
+
143
+ {endAdornment && (
144
+ <div
145
+ className={cls("h-full flex items-center")}
146
+ onClick={(e) => {
147
+ e.preventDefault();
148
+ e.stopPropagation();
149
+ }}>
150
+ {endAdornment}
151
+ </div>
152
+ )}
153
+ <SelectPrimitive.Icon asChild>
154
+ <ExpandMoreIcon size={"small"}
155
+ className={cls("px-2 transition", open ? "rotate-180" : "")}/>
150
156
  </SelectPrimitive.Icon>
151
157
  </SelectPrimitive.Trigger>
152
- {endAdornment && (
153
- <div
154
- className={cls("absolute h-full flex items-center", size === "small" ? "right-10" : "right-14")}
155
- onClick={(e) => {
156
- e.preventDefault();
157
- e.stopPropagation();
158
- }}>
159
- {endAdornment}
160
- </div>
161
- )}
158
+
162
159
  </div>
163
160
  <SelectPrimitive.Portal>
164
161
  <SelectPrimitive.Content position={position}
@@ -192,10 +189,6 @@ export function SelectItem({
192
189
  key={value}
193
190
  value={value}
194
191
  disabled={disabled}
195
- onClick={(e) => {
196
- e.preventDefault();
197
- e.stopPropagation();
198
- }}
199
192
  className={cls(
200
193
  "w-full",
201
194
  "relative flex items-center p-2 rounded-md text-sm text-slate-700 dark:text-slate-300",
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React, { useEffect, useState } from "react";
2
3
  import { cls } from "../util";
3
4
  import { defaultBorderMixin } from "../styles";
@@ -72,7 +73,6 @@ export const Sheet: React.FC<SheetProps> = ({
72
73
  style={{
73
74
  pointerEvents: displayed ? "auto" : "none"
74
75
  }}
75
- onClick={() => onOpenChange && onOpenChange(false)}
76
76
  />}
77
77
  <DialogPrimitive.Content
78
78
  {...props}
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React, { useCallback, useEffect, useRef } from "react";
2
3
 
3
4
  import { TextareaAutosize } from "./TextareaAutosize";
@@ -109,7 +110,7 @@ export function TextField<T extends string | number>({
109
110
  style={inputStyle}
110
111
  className={cls(
111
112
  invisible ? focusedInvisibleMixin : "",
112
- "rounded-md resize-none w-full outline-none p-[32px] text-base bg-transparent min-h-[64px] px-3 pt-[28px]",
113
+ "rounded-md resize-none w-full outline-none p-[32px] text-base bg-transparent min-h-[64px] px-3 pt-8",
113
114
  disabled && "border border-transparent outline-none opacity-50 text-slate-600 dark:text-slate-500"
114
115
  )}
115
116
  />
@@ -125,7 +126,7 @@ export function TextField<T extends string | number>({
125
126
  invisible ? focusedInvisibleMixin : "",
126
127
  disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
127
128
  size === "smallest" ? "min-h-[32px]" : (size === "small" ? "min-h-[48px]" : "min-h-[64px]"),
128
- label ? (size === "medium" ? "pt-[28px] pb-2" : "pt-4 pb-2") : "py-2",
129
+ label ? (size === "medium" ? "pt-8 pb-2" : "pt-4 pb-2") : "py-2",
129
130
  focused ? "text-text-primary dark:text-text-primary-dark" : "",
130
131
  endAdornment ? "pr-10" : "pr-3",
131
132
  disabled && "border border-transparent outline-none opacity-50 dark:opacity-50 text-slate-800 dark:text-white",
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import * as React from "react";
2
3
  import { useLayoutEffect } from "react";
3
4
  import * as ReactDOM from "react-dom";
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React from "react";
2
3
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
4
 
@@ -1,4 +1,3 @@
1
- export * from "./useLocaleConfig";
2
1
  export * from "./useInjectStyles";
3
2
  export * from "./useOutsideAlerter";
4
3
  export * from "./useDebounceValue";
package/src/index.css CHANGED
@@ -71,7 +71,3 @@
71
71
  a {
72
72
  @apply text-blue-600 dark:text-blue-400 dark:hover:text-blue-600 hover:text-blue-800
73
73
  }
74
-
75
- body {
76
- @apply w-full min-h-screen bg-gray-50 dark:bg-gray-900 flex flex-col items-center justify-center;
77
- }
File without changes
@@ -1 +0,0 @@
1
- export declare function useLocaleConfig(locale?: string): void;
@@ -1,222 +0,0 @@
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,18 +0,0 @@
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
- }