@bitrise/bitkit 12.95.0 → 12.97.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,
|
|
@@ -41,32 +41,32 @@ const TagsInput = ({
|
|
|
41
41
|
...rest
|
|
42
42
|
}: TagsInputProps) => {
|
|
43
43
|
const theme = useStyleConfig('TagsInput');
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
|
|
44
|
+
const addValues = (maybeValues: string) => {
|
|
45
|
+
const newValue = maybeValues.split(separator).filter((item) => item && !item.match(/\s/) && !value.includes(item));
|
|
46
|
+
if (newValue.length > 0) {
|
|
47
|
+
onNewValues(newValue);
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
const keydownHandler: KeyboardEventHandler<HTMLInputElement> = (ev) => {
|
|
51
51
|
const target = ev.currentTarget;
|
|
52
52
|
if (ev.key.match(separator)) {
|
|
53
53
|
ev.preventDefault();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
target.value = '';
|
|
60
|
-
}
|
|
54
|
+
addValues(target.value);
|
|
55
|
+
target.value = '';
|
|
56
|
+
} else if (ev.key === 'Backspace' && target.value.length === 0) {
|
|
57
|
+
onRemove(value[value.length - 1]);
|
|
61
58
|
}
|
|
62
59
|
};
|
|
63
60
|
const pasteEventHandler: ClipboardEventHandler<HTMLInputElement> = (ev) => {
|
|
64
61
|
ev.preventDefault();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
addValues(ev.clipboardData.getData('text/plain'));
|
|
63
|
+
};
|
|
64
|
+
const blurHandler: FocusEventHandler<HTMLInputElement> = (ev) => {
|
|
65
|
+
const target = ev.currentTarget;
|
|
66
|
+
if (target.value) {
|
|
67
|
+
addValues(target.value);
|
|
68
|
+
target.value = '';
|
|
69
|
+
}
|
|
70
70
|
};
|
|
71
71
|
const removeItem = (deleted: string) => {
|
|
72
72
|
onRemove(deleted);
|
|
@@ -121,23 +121,15 @@ const TagsInput = ({
|
|
|
121
121
|
{item}
|
|
122
122
|
</Tag>
|
|
123
123
|
))}
|
|
124
|
-
{value.length === 0 && placeholder && (
|
|
125
|
-
<Text
|
|
126
|
-
color="sys.fg.subtle"
|
|
127
|
-
pointerEvents="none"
|
|
128
|
-
position="absolute"
|
|
129
|
-
sx={{ ':has(+ :focus-visible)': { display: 'none' } }}
|
|
130
|
-
>
|
|
131
|
-
{placeholder}
|
|
132
|
-
</Text>
|
|
133
|
-
)}
|
|
134
124
|
<chakra.input
|
|
135
125
|
_focusVisible={{ boxShadow: 'none' }}
|
|
136
126
|
flexGrow="1"
|
|
127
|
+
height="26px"
|
|
137
128
|
id={id}
|
|
129
|
+
onBlur={blurHandler}
|
|
138
130
|
onKeyDown={keydownHandler}
|
|
139
|
-
onKeyUp={keyupHandler}
|
|
140
131
|
onPaste={pasteEventHandler}
|
|
132
|
+
placeholder={value.length === 0 ? placeholder : undefined}
|
|
141
133
|
/>
|
|
142
134
|
{isInvalid && <Icon color="icon.negative" name="ErrorCircleFilled" position="absolute" right="16" />}
|
|
143
135
|
</Box>
|