@bitrise/bitkit 13.251.0 → 13.252.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.251.0",
4
+ "version": "13.252.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -37,7 +37,7 @@ import { NoResultsFound, useSimpleSearch } from './hooks/useSimpleSearch';
37
37
  import { isSearchable } from './isNodeMatch';
38
38
  import { DropdownProps } from './DropdownProps';
39
39
 
40
- const MultiSelectContext = createContext(false);
40
+ const MultiSelectContext = createContext<{ invalidValues?: string[] } | undefined>(undefined);
41
41
 
42
42
  type DropdownSearchCustomProps = {
43
43
  value: string;
@@ -174,7 +174,8 @@ function useDropdown<T>({
174
174
  setSelectedIndex,
175
175
  } = useFloatingDropdown({ dropdownWidth, enabled: !readOnly, optionsRef, placement });
176
176
 
177
- const isMultiSelect = useContext(MultiSelectContext);
177
+ const multiSelectContext = useContext(MultiSelectContext);
178
+ const isMultiSelect = Boolean(multiSelectContext);
178
179
 
179
180
  const [formValue, setFormValue] = useControllableState<T>({
180
181
  defaultValue: isMultiSelect ? defaultValue || ([] as T) : defaultValue,
@@ -291,9 +292,10 @@ function useDropdown<T>({
291
292
  return <>{formValueItem}</>;
292
293
  }
293
294
 
295
+ const colors = multiSelectContext?.invalidValues?.includes(formValueItem) ? 'red' : 'neutral';
294
296
  return (
295
297
  <Tag
296
- colorScheme="neutral"
298
+ colorScheme={colors}
297
299
  isDisabled={disabled}
298
300
  key={formValueItem}
299
301
  onClose={(event) => {
@@ -556,13 +558,14 @@ export function typedDropdown<T>() {
556
558
  };
557
559
  }
558
560
 
559
- export const MultiSelectDropdown = (props: DropdownProps<(string | null)[]>) => {
561
+ export const MultiSelectDropdown = (props: DropdownProps<(string | null)[]> & { invalidValues?: string[] }) => {
560
562
  const { Dropdown: TypedDropdown } = typedDropdown<(string | null)[]>();
561
563
 
562
- const { children, ...rest } = props;
564
+ const { children, invalidValues, ...rest } = props;
565
+ const contextValue = useMemo(() => ({ invalidValues }), [invalidValues]);
563
566
 
564
567
  return (
565
- <MultiSelectContext.Provider value>
568
+ <MultiSelectContext.Provider value={contextValue}>
566
569
  <TypedDropdown {...rest}>{children}</TypedDropdown>
567
570
  </MultiSelectContext.Provider>
568
571
  );