@meta-1/design 0.0.178 → 0.0.180
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/package.json
CHANGED
|
@@ -26,6 +26,7 @@ export interface DialogProps extends PropsWithChildren {
|
|
|
26
26
|
description?: string;
|
|
27
27
|
footer?: React.ReactNode;
|
|
28
28
|
loading?: boolean;
|
|
29
|
+
fitContent?: boolean;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
export const Dialog: FC<DialogProps> = (props) => {
|
|
@@ -40,6 +41,7 @@ export const Dialog: FC<DialogProps> = (props) => {
|
|
|
40
41
|
description,
|
|
41
42
|
footer,
|
|
42
43
|
loading = false,
|
|
44
|
+
fitContent = false,
|
|
43
45
|
} = props;
|
|
44
46
|
|
|
45
47
|
return (
|
|
@@ -58,7 +60,9 @@ export const Dialog: FC<DialogProps> = (props) => {
|
|
|
58
60
|
{description ? <DialogDescription>{description}</DialogDescription> : null}
|
|
59
61
|
</DialogHeader>
|
|
60
62
|
<div className="min-h-0 flex-1 overflow-auto">
|
|
61
|
-
<div className={cn("w-full min-w-fit px-6 py-1", contentClassName, !footer && "pb-6")}>
|
|
63
|
+
<div className={cn(fitContent && "w-full min-w-fit", "px-6 py-1", contentClassName, !footer && "pb-6")}>
|
|
64
|
+
{props.children}
|
|
65
|
+
</div>
|
|
62
66
|
</div>
|
|
63
67
|
{footer ? <DialogFooter>{footer}</DialogFooter> : null}
|
|
64
68
|
{loading ? (
|
|
@@ -45,13 +45,14 @@ export const TagsInput = forwardRef<HTMLDivElement, TagsInputProps>((props, ref)
|
|
|
45
45
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
46
46
|
const [inputValue, setInputValue] = useState("");
|
|
47
47
|
const [tags, setTags] = useState<string[]>(value || defaultValue);
|
|
48
|
+
const [isComposing, setIsComposing] = useState(false);
|
|
48
49
|
|
|
49
50
|
const isControlled = value !== undefined;
|
|
50
|
-
const currentTags = isControlled ? value : tags;
|
|
51
|
+
const currentTags = isControlled ? value || [] : tags;
|
|
51
52
|
|
|
52
53
|
useEffect(() => {
|
|
53
54
|
if (isControlled) {
|
|
54
|
-
setTags(value);
|
|
55
|
+
setTags(value || []);
|
|
55
56
|
}
|
|
56
57
|
}, [value, isControlled]);
|
|
57
58
|
|
|
@@ -93,7 +94,8 @@ export const TagsInput = forwardRef<HTMLDivElement, TagsInputProps>((props, ref)
|
|
|
93
94
|
const target = e.target as HTMLInputElement;
|
|
94
95
|
const value = target.value;
|
|
95
96
|
|
|
96
|
-
|
|
97
|
+
if (isComposing) return;
|
|
98
|
+
|
|
97
99
|
if (e.key === "Enter" || (typeof separator === "string" && e.key === separator)) {
|
|
98
100
|
e.preventDefault();
|
|
99
101
|
if (value) {
|
|
@@ -102,7 +104,6 @@ export const TagsInput = forwardRef<HTMLDivElement, TagsInputProps>((props, ref)
|
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
|
-
// Backspace 删除最后一个标签
|
|
106
107
|
if (e.key === "Backspace" && !value && currentTags.length > 0) {
|
|
107
108
|
e.preventDefault();
|
|
108
109
|
removeTag(currentTags.length - 1);
|
|
@@ -199,6 +200,8 @@ export const TagsInput = forwardRef<HTMLDivElement, TagsInputProps>((props, ref)
|
|
|
199
200
|
disabled={disabled || (maxTags !== undefined && currentTags.length >= maxTags)}
|
|
200
201
|
onBlur={handleBlur}
|
|
201
202
|
onChange={handleInputChange}
|
|
203
|
+
onCompositionEnd={() => setIsComposing(false)}
|
|
204
|
+
onCompositionStart={() => setIsComposing(true)}
|
|
202
205
|
onKeyDown={handleKeyDown}
|
|
203
206
|
placeholder={currentTags.length === 0 ? placeholder : undefined}
|
|
204
207
|
ref={inputRef}
|