@firecms/ui 3.0.0-canary.135 → 3.0.0-canary.137
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 +1 -1
- package/dist/index.css +1 -5
- package/dist/index.es.js +67 -76
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +67 -76
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +3 -3
- package/package.json +2 -2
- package/src/components/Autocomplete.tsx +1 -0
- package/src/components/Avatar.tsx +1 -1
- package/src/components/BooleanSwitchWithLabel.tsx +1 -0
- package/src/components/Button.tsx +1 -1
- package/src/components/Card.tsx +1 -0
- package/src/components/Collapse.tsx +1 -0
- package/src/components/DateTimeField.tsx +2 -1
- package/src/components/DebouncedTextField.tsx +1 -0
- package/src/components/Dialog.tsx +1 -0
- package/src/components/DialogContent.tsx +1 -1
- package/src/components/DialogTitle.tsx +3 -2
- package/src/components/ExpandablePanel.tsx +3 -0
- package/src/components/FileUpload.tsx +1 -0
- package/src/components/InputLabel.tsx +0 -1
- package/src/components/Markdown.tsx +1 -0
- package/src/components/MultiSelect.tsx +2 -1
- package/src/components/Popover.tsx +1 -0
- package/src/components/SearchBar.tsx +1 -0
- package/src/components/Select.tsx +21 -28
- package/src/components/Sheet.tsx +1 -1
- package/src/components/TextField.tsx +3 -2
- package/src/components/TextareaAutosize.tsx +1 -0
- package/src/components/Tooltip.tsx +1 -0
- package/src/index.css +1 -5
- package/src/styles.ts +3 -3
- package/dist/components/_MultiSelect.d.ts +0 -0
- package/src/components/_MultiSelect.tsx +0 -222
package/dist/styles.d.ts
CHANGED
@@ -5,8 +5,8 @@ export declare const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-
|
|
5
5
|
export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0";
|
6
6
|
export declare const fieldBackgroundDisabledMixin = "dark:bg-gray-800 bg-opacity-50 dark:bg-opacity-90";
|
7
7
|
export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-gray-700 dark:hover:bg-opacity-40";
|
8
|
-
export declare const defaultBorderMixin = "border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-
|
9
|
-
export declare const paperMixin = "bg-white rounded-md dark:bg-gray-950 border border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-
|
10
|
-
export declare const cardMixin = "bg-white border border-gray-200 border-opacity-40 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-700 dark:border-opacity-
|
8
|
+
export declare const defaultBorderMixin = "border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-40";
|
9
|
+
export declare const paperMixin = "bg-white rounded-md dark:bg-gray-950 border border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-40";
|
10
|
+
export declare const cardMixin = "bg-white border border-gray-200 border-opacity-40 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-700 dark:border-opacity-40 m-1 -p-1";
|
11
11
|
export declare const cardClickableMixin = "hover:bg-primary-bg dark:hover:bg-primary-bg hover:bg-opacity-20 dark:hover:bg-opacity-20 hover:ring-2 hover:ring-primary cursor-pointer";
|
12
12
|
export declare const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 dark:bg-opacity-10 ring-1 ring-primary ring-opacity-75";
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@firecms/ui",
|
3
3
|
"type": "module",
|
4
|
-
"version": "3.0.0-canary.
|
4
|
+
"version": "3.0.0-canary.137",
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
6
6
|
"funding": {
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
@@ -108,7 +108,7 @@
|
|
108
108
|
"src",
|
109
109
|
"tailwind.config.js"
|
110
110
|
],
|
111
|
-
"gitHead": "
|
111
|
+
"gitHead": "f7ea02c4cd176d6c5a58b79e01ffdc4438ed1a67",
|
112
112
|
"publishConfig": {
|
113
113
|
"access": "public"
|
114
114
|
}
|
@@ -27,7 +27,7 @@ const AvatarInner: React.ForwardRefRenderFunction<HTMLButtonElement, AvatarProps
|
|
27
27
|
style={style}
|
28
28
|
{...props}
|
29
29
|
className={cls("rounded-full flex items-center justify-center overflow-hidden",
|
30
|
-
"p-1 hover:bg-slate-200 hover:dark:bg-slate-700 w-12 h-12",
|
30
|
+
"p-1 hover:bg-slate-200 hover:dark:bg-slate-700 w-12 h-12 min-w-12 min-h-12",
|
31
31
|
outerClassName
|
32
32
|
)}>
|
33
33
|
{src
|
@@ -30,7 +30,7 @@ const ButtonInner = React.forwardRef<
|
|
30
30
|
}: ButtonProps<any>, ref) => {
|
31
31
|
|
32
32
|
const baseClasses =
|
33
|
-
"h-fit rounded-md
|
33
|
+
"typography-button h-fit rounded-md whitespace-nowrap inline-flex items-center justify-center p-2 px-4 focus:outline-none transition ease-in-out duration-150 gap-2";
|
34
34
|
|
35
35
|
const buttonClasses = cls({
|
36
36
|
"w-full": fullWidth,
|
package/src/components/Card.tsx
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
"use client";
|
1
2
|
import React, { useRef } from "react";
|
2
3
|
import * as RDP from "react-datepicker"
|
3
4
|
|
@@ -107,7 +108,7 @@ export const DateTimeField: React.FC<DateTimeFieldProps> = ({
|
|
107
108
|
clearable ? "pr-14" : "pr-12",
|
108
109
|
"rounded-md",
|
109
110
|
size === "small" ? "min-h-[48px]" : "min-h-[64px]",
|
110
|
-
label ? "pt-
|
111
|
+
label ? "pt-8 pb-2" : "py-2",
|
111
112
|
inputClassName,
|
112
113
|
disabled && "border border-transparent outline-none opacity-50 dark:opacity-50 text-slate-600 dark:text-slate-500"
|
113
114
|
)}
|
@@ -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 = "
|
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 * 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 =
|
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, { 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
|
-
|
149
|
-
|
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
|
-
|
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",
|
package/src/components/Sheet.tsx
CHANGED
@@ -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-
|
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-
|
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",
|
package/src/index.css
CHANGED
@@ -60,7 +60,7 @@
|
|
60
60
|
}
|
61
61
|
|
62
62
|
.typography-button {
|
63
|
-
@apply text-sm font-
|
63
|
+
@apply text-sm font-semibold uppercase;
|
64
64
|
}
|
65
65
|
|
66
66
|
|
@@ -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
|
-
}
|
package/src/styles.ts
CHANGED
@@ -5,8 +5,8 @@ export const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-800
|
|
5
5
|
export const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0";
|
6
6
|
export const fieldBackgroundDisabledMixin = "dark:bg-gray-800 bg-opacity-50 dark:bg-opacity-90";
|
7
7
|
export const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-gray-700 dark:hover:bg-opacity-40";
|
8
|
-
export const defaultBorderMixin = "border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-
|
9
|
-
export const paperMixin = "bg-white rounded-md dark:bg-gray-950 border border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-
|
10
|
-
export const cardMixin = "bg-white border border-gray-200 border-opacity-40 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-700 dark:border-opacity-
|
8
|
+
export const defaultBorderMixin = "border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-40";
|
9
|
+
export const paperMixin = "bg-white rounded-md dark:bg-gray-950 border border-gray-200 border-opacity-40 dark:border-gray-700 dark:border-opacity-40";
|
10
|
+
export const cardMixin = "bg-white border border-gray-200 border-opacity-40 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-700 dark:border-opacity-40 m-1 -p-1";
|
11
11
|
export const cardClickableMixin = "hover:bg-primary-bg dark:hover:bg-primary-bg hover:bg-opacity-20 dark:hover:bg-opacity-20 hover:ring-2 hover:ring-primary cursor-pointer";
|
12
12
|
export const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 dark:bg-opacity-10 ring-1 ring-primary ring-opacity-75";
|
File without changes
|
@@ -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
|
-
// }
|