@bitrise/bitkit 12.94.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,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "12.94.0",
4
+ "version": "12.96.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -146,12 +146,22 @@ const FilterForm = (props: FilterFormProps) => {
146
146
  </Text>
147
147
  </Radio>
148
148
  {items.length
149
- ? items.map((opt) => (
150
- <Radio key={opt} value={opt}>
151
- {iconsMap && iconsMap[opt] && <Icon name={iconsMap[opt]} />}
152
- {getOptionLabel(opt, optionsMap)}
153
- </Radio>
154
- ))
149
+ ? items.map((opt) => {
150
+ const hasIcon = iconsMap && iconsMap[opt];
151
+ const label = getOptionLabel(opt, optionsMap);
152
+ return (
153
+ <Radio key={opt} value={opt}>
154
+ {hasIcon ? (
155
+ <Box alignItems="center" as="span" display="flex" gap="4">
156
+ <Icon name={iconsMap[opt]} />
157
+ {label}
158
+ </Box>
159
+ ) : (
160
+ label
161
+ )}
162
+ </Radio>
163
+ );
164
+ })
155
165
  : getEmptyText()}
156
166
  </RadioGroup>
157
167
  )}
@@ -50,9 +50,6 @@ const RadioTheme = {
50
50
  },
51
51
  label: {
52
52
  _disabled: { color: 'neutral.60' },
53
- alignItems: 'center',
54
- display: 'flex',
55
- gap: '4',
56
53
  userSelect: 'none',
57
54
  },
58
55
  },
@@ -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
- if (target.value) {
55
- const newValue = target.value.split(separator)[0];
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
- const newItems = ev.clipboardData
66
- .getData('text/plain')
67
- .split(separator)
68
- .filter((item) => item && !item.match(/\s/) && !value.includes(item));
69
- onNewValues(newItems);
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}