@meta-1/design 0.0.179 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meta-1/design",
3
- "version": "0.0.179",
3
+ "version": "0.0.180",
4
4
  "keywords": [
5
5
  "easykit",
6
6
  "design",
@@ -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
- // Enter 或分隔符键
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}