@bitrise/bitkit 12.95.0 → 12.96.0
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,4 +1,4 @@
|
|
|
1
|
-
import { ClipboardEventHandler, KeyboardEventHandler, ReactNode, useId } from 'react';
|
|
1
|
+
import { ClipboardEventHandler, FocusEventHandler, KeyboardEventHandler, ReactNode, useId } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
chakra,
|
|
4
4
|
FormControl,
|
|
@@ -47,26 +47,30 @@ const TagsInput = ({
|
|
|
47
47
|
onRemove(value[value.length - 1]);
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
+
const addValues = (maybeValues: string) => {
|
|
51
|
+
const newValue = maybeValues.split(separator).filter((item) => item && !item.match(/\s/) && !value.includes(item));
|
|
52
|
+
if (newValue.length > 0) {
|
|
53
|
+
onNewValues(newValue);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
50
56
|
const keydownHandler: KeyboardEventHandler<HTMLInputElement> = (ev) => {
|
|
51
57
|
const target = ev.currentTarget;
|
|
52
58
|
if (ev.key.match(separator)) {
|
|
53
59
|
ev.preventDefault();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (!value.includes(newValue)) {
|
|
57
|
-
onNewValues([newValue]);
|
|
58
|
-
}
|
|
59
|
-
target.value = '';
|
|
60
|
-
}
|
|
60
|
+
addValues(target.value);
|
|
61
|
+
target.value = '';
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
const pasteEventHandler: ClipboardEventHandler<HTMLInputElement> = (ev) => {
|
|
64
65
|
ev.preventDefault();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
addValues(ev.clipboardData.getData('text/plain'));
|
|
67
|
+
};
|
|
68
|
+
const blurHandler: FocusEventHandler<HTMLInputElement> = (ev) => {
|
|
69
|
+
const target = ev.currentTarget;
|
|
70
|
+
if (target.value) {
|
|
71
|
+
addValues(target.value);
|
|
72
|
+
target.value = '';
|
|
73
|
+
}
|
|
70
74
|
};
|
|
71
75
|
const removeItem = (deleted: string) => {
|
|
72
76
|
onRemove(deleted);
|
|
@@ -135,6 +139,7 @@ const TagsInput = ({
|
|
|
135
139
|
_focusVisible={{ boxShadow: 'none' }}
|
|
136
140
|
flexGrow="1"
|
|
137
141
|
id={id}
|
|
142
|
+
onBlur={blurHandler}
|
|
138
143
|
onKeyDown={keydownHandler}
|
|
139
144
|
onKeyUp={keyupHandler}
|
|
140
145
|
onPaste={pasteEventHandler}
|