@bitrise/bitkit 13.202.0 → 13.204.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": "13.202.0",
4
+ "version": "13.204.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -13,7 +13,7 @@ import RadioGroup from '../../Form/Radio/RadioGroup';
13
13
  import SearchInput from '../../SearchInput/SearchInput';
14
14
  import Text from '../../Text/Text';
15
15
  import { FilterStyle } from '../Filter.theme';
16
- import { FilterOptions, FilterValue } from '../Filter.types';
16
+ import { FilterOptions, FilterOptionsMap, FilterValue } from '../Filter.types';
17
17
  import { isEqual, useDebounce } from '../../../utils/utils';
18
18
  import { getOptionLabel } from '../Filter.utils';
19
19
  import { useFilterContext } from '../Filter.context';
@@ -50,6 +50,7 @@ const FilterForm = (props: FilterFormProps) => {
50
50
 
51
51
  const [isLoading, setLoading] = useState(Boolean(isInitialLoading));
52
52
  const [foundOptions, setFoundOptions] = useState<FilterOptions>([]);
53
+ const [foundOptionsMap, setFoundOptionsMap] = useState<FilterOptionsMap>();
53
54
 
54
55
  const isAsync = !!onAsyncSearch;
55
56
  const withSearch = (options && options.length > 5) || isAsync;
@@ -105,6 +106,7 @@ const FilterForm = (props: FilterFormProps) => {
105
106
  const response = await onAsyncSearch(category, searchValue);
106
107
  setLoading(false);
107
108
  setFoundOptions(response.options);
109
+ setFoundOptionsMap(response.optionsMap || optionsMap);
108
110
  }
109
111
  };
110
112
 
@@ -122,10 +124,13 @@ const FilterForm = (props: FilterFormProps) => {
122
124
 
123
125
  const isEditMode = value.length !== 0;
124
126
 
125
- const items =
126
- isAsync && !!searchValue
127
- ? Array.from(new Set(preserveOptionOrder ? [...foundOptions] : [...value, ...foundOptions]))
128
- : Array.from(new Set(preserveOptionOrder ? [...filteredOptions] : [...value, ...filteredOptions]));
127
+ const isAsyncSearch = isAsync && !!searchValue;
128
+
129
+ const items = isAsyncSearch
130
+ ? Array.from(new Set(preserveOptionOrder ? [...foundOptions] : [...value, ...foundOptions]))
131
+ : Array.from(new Set(preserveOptionOrder ? [...filteredOptions] : [...value, ...filteredOptions]));
132
+
133
+ const currentOptionMap = isAsyncSearch ? foundOptionsMap : optionsMap;
129
134
 
130
135
  return (
131
136
  <FocusLock>
@@ -156,7 +161,7 @@ const FilterForm = (props: FilterFormProps) => {
156
161
  ? items.map((opt) => (
157
162
  <Checkbox key={opt} value={opt}>
158
163
  {iconsMap && iconsMap[opt] && <Icon name={iconsMap[opt]} />}
159
- {getOptionLabel(opt, optionsMap)}
164
+ {getOptionLabel(opt, currentOptionMap)}
160
165
  </Checkbox>
161
166
  ))
162
167
  : getEmptyText()}
@@ -174,7 +179,7 @@ const FilterForm = (props: FilterFormProps) => {
174
179
  {items.length
175
180
  ? items.map((opt) => {
176
181
  const hasIcon = iconsMap && iconsMap[opt];
177
- const label = getOptionLabel(opt, optionsMap);
182
+ const label = getOptionLabel(opt, currentOptionMap);
178
183
  return (
179
184
  <Radio key={opt} value={opt}>
180
185
  {hasIcon ? (
@@ -1,5 +1,5 @@
1
1
  import { forwardRef, ListItem as ChakraListItem, ListItemProps as ChakraListItemProps } from '@chakra-ui/react';
2
- import { BoxProps } from '../Box/Box';
2
+ import Box, { BoxProps } from '../Box/Box';
3
3
  import Icon, { IconProps, TypeIconName } from '../Icon/Icon';
4
4
 
5
5
  export interface ListItemProps extends ChakraListItemProps {
@@ -23,12 +23,23 @@ const ListItem = forwardRef<ListItemProps, 'li'>((props, ref) => {
23
23
  if (iconSize === '32') {
24
24
  iconVerticalAlign = '-11px';
25
25
  }
26
+
26
27
  return (
27
- <ChakraListItem {...rest} ref={ref}>
28
- {!!iconName && (
29
- <Icon name={iconName} color={iconColor} marginEnd="6" size={iconSize} verticalAlign={iconVerticalAlign} />
30
- )}
31
- {children}
28
+ <ChakraListItem {...rest} ref={ref} listStylePosition="outside">
29
+ <Box display="flex" alignItems="flex-start">
30
+ {!!iconName && (
31
+ <Icon
32
+ flexShrink={0}
33
+ name={iconName}
34
+ height="100%"
35
+ color={iconColor}
36
+ marginEnd="6"
37
+ size={iconSize}
38
+ verticalAlign={iconVerticalAlign}
39
+ />
40
+ )}
41
+ <Box flexGrow={1}>{children}</Box>
42
+ </Box>
32
43
  </ChakraListItem>
33
44
  );
34
45
  });