|
1 |
| -import type { ComboboxOption, SystemStyleObject } from '@invoke-ai/ui-library'; |
2 |
| -import { Combobox, FormControl, FormLabel } from '@invoke-ai/ui-library'; |
| 1 | +import { FormControl, FormLabel, Select } from '@invoke-ai/ui-library'; |
3 | 2 | import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
4 |
| -import type { SingleValue } from 'chakra-react-select'; |
5 | 3 | import { InformationalPopover } from 'common/components/InformationalPopover/InformationalPopover';
|
6 | 4 | import { bboxAspectRatioIdChanged } from 'features/controlLayers/store/canvasSlice';
|
7 | 5 | import { selectIsStaging } from 'features/controlLayers/store/canvasStagingAreaSlice';
|
8 | 6 | import { selectAspectRatioID } from 'features/controlLayers/store/selectors';
|
9 |
| -import { isAspectRatioID } from 'features/controlLayers/store/types'; |
10 |
| -import { ASPECT_RATIO_OPTIONS } from 'features/parameters/components/Bbox/constants'; |
11 |
| -import { memo, useCallback, useMemo } from 'react'; |
| 7 | +import { isAspectRatioID, zAspectRatioID } from 'features/controlLayers/store/types'; |
| 8 | +import type { ChangeEventHandler } from 'react'; |
| 9 | +import { memo, useCallback } from 'react'; |
12 | 10 | import { useTranslation } from 'react-i18next';
|
| 11 | +import { PiCaretDownBold } from 'react-icons/pi'; |
13 | 12 |
|
14 | 13 | export const BboxAspectRatioSelect = memo(() => {
|
15 | 14 | const { t } = useTranslation();
|
16 | 15 | const dispatch = useAppDispatch();
|
17 | 16 | const id = useAppSelector(selectAspectRatioID);
|
18 | 17 | const isStaging = useAppSelector(selectIsStaging);
|
19 | 18 |
|
20 |
| - const onChange = useCallback( |
21 |
| - (v: SingleValue<ComboboxOption>) => { |
22 |
| - if (!v || !isAspectRatioID(v.value)) { |
| 19 | + const onChange = useCallback<ChangeEventHandler<HTMLSelectElement>>( |
| 20 | + (e) => { |
| 21 | + if (!isAspectRatioID(e.target.value)) { |
23 | 22 | return;
|
24 | 23 | }
|
25 |
| - dispatch(bboxAspectRatioIdChanged({ id: v.value })); |
| 24 | + dispatch(bboxAspectRatioIdChanged({ id: e.target.value })); |
26 | 25 | },
|
27 | 26 | [dispatch]
|
28 | 27 | );
|
29 | 28 |
|
30 |
| - const value = useMemo(() => ASPECT_RATIO_OPTIONS.filter((o) => o.value === id)[0], [id]); |
31 |
| - |
32 | 29 | return (
|
33 | 30 | <FormControl isDisabled={isStaging}>
|
34 | 31 | <InformationalPopover feature="paramAspect">
|
35 | 32 | <FormLabel>{t('parameters.aspect')}</FormLabel>
|
36 | 33 | </InformationalPopover>
|
37 |
| - <Combobox value={value} onChange={onChange} options={ASPECT_RATIO_OPTIONS} sx={selectStyles} /> |
| 34 | + <Select size="sm" value={id} onChange={onChange} cursor="pointer" iconSize="0.75rem" icon={<PiCaretDownBold />}> |
| 35 | + {zAspectRatioID.options.map((ratio) => ( |
| 36 | + <option key={ratio} value={ratio}> |
| 37 | + {ratio} |
| 38 | + </option> |
| 39 | + ))} |
| 40 | + </Select> |
38 | 41 | </FormControl>
|
39 | 42 | );
|
40 | 43 | });
|
41 | 44 |
|
42 | 45 | BboxAspectRatioSelect.displayName = 'BboxAspectRatioSelect';
|
43 |
| - |
44 |
| -const selectStyles: SystemStyleObject = { minW: 24 }; |
|
0 commit comments