@bitrise/bitkit 13.250.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
|
@@ -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(
|
|
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
|
|
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=
|
|
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
|
);
|
package/src/index.ts
CHANGED
|
@@ -148,6 +148,7 @@ export { default as Ribbon } from './Components/Ribbon/Ribbon';
|
|
|
148
148
|
export type { DropdownProps } from './Components/Dropdown/DropdownProps';
|
|
149
149
|
export {
|
|
150
150
|
default as Dropdown,
|
|
151
|
+
MultiSelectDropdown,
|
|
151
152
|
DropdownOption,
|
|
152
153
|
DropdownGroup,
|
|
153
154
|
DropdownSearch,
|