mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): add custom label to IAIMantineSelects
needed to have their label styles match chakras
This commit is contained in:
parent
7daafc03d3
commit
4ac0ce59fb
@ -1,17 +1,25 @@
|
|||||||
import { Tooltip } from '@chakra-ui/react';
|
import { FormControl, FormLabel, Tooltip } from '@chakra-ui/react';
|
||||||
import { MultiSelect, MultiSelectProps } from '@mantine/core';
|
import { MultiSelect, MultiSelectProps } from '@mantine/core';
|
||||||
import { useAppDispatch } from 'app/store/storeHooks';
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
import { shiftKeyPressed } from 'features/ui/store/hotkeysSlice';
|
import { shiftKeyPressed } from 'features/ui/store/hotkeysSlice';
|
||||||
import { useMantineMultiSelectStyles } from 'mantine-theme/hooks/useMantineMultiSelectStyles';
|
import { useMantineMultiSelectStyles } from 'mantine-theme/hooks/useMantineMultiSelectStyles';
|
||||||
import { KeyboardEvent, RefObject, memo, useCallback } from 'react';
|
import { KeyboardEvent, RefObject, memo, useCallback } from 'react';
|
||||||
|
|
||||||
type IAIMultiSelectProps = MultiSelectProps & {
|
type IAIMultiSelectProps = Omit<MultiSelectProps, 'label'> & {
|
||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
inputRef?: RefObject<HTMLInputElement>;
|
inputRef?: RefObject<HTMLInputElement>;
|
||||||
|
label?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const IAIMantineMultiSelect = (props: IAIMultiSelectProps) => {
|
const IAIMantineMultiSelect = (props: IAIMultiSelectProps) => {
|
||||||
const { searchable = true, tooltip, inputRef, ...rest } = props;
|
const {
|
||||||
|
searchable = true,
|
||||||
|
tooltip,
|
||||||
|
inputRef,
|
||||||
|
label,
|
||||||
|
disabled,
|
||||||
|
...rest
|
||||||
|
} = props;
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const handleKeyDown = useCallback(
|
const handleKeyDown = useCallback(
|
||||||
@ -37,7 +45,15 @@ const IAIMantineMultiSelect = (props: IAIMultiSelectProps) => {
|
|||||||
return (
|
return (
|
||||||
<Tooltip label={tooltip} placement="top" hasArrow isOpen={true}>
|
<Tooltip label={tooltip} placement="top" hasArrow isOpen={true}>
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
|
label={
|
||||||
|
label ? (
|
||||||
|
<FormControl isDisabled={disabled}>
|
||||||
|
<FormLabel>{label}</FormLabel>
|
||||||
|
</FormControl>
|
||||||
|
) : undefined
|
||||||
|
}
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
|
disabled={disabled}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
onKeyUp={handleKeyUp}
|
onKeyUp={handleKeyUp}
|
||||||
searchable={searchable}
|
searchable={searchable}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Tooltip } from '@chakra-ui/react';
|
import { FormControl, FormLabel, Tooltip } from '@chakra-ui/react';
|
||||||
import { Select, SelectProps } from '@mantine/core';
|
import { Select, SelectProps } from '@mantine/core';
|
||||||
import { useAppDispatch } from 'app/store/storeHooks';
|
import { useAppDispatch } from 'app/store/storeHooks';
|
||||||
import { shiftKeyPressed } from 'features/ui/store/hotkeysSlice';
|
import { shiftKeyPressed } from 'features/ui/store/hotkeysSlice';
|
||||||
@ -11,13 +11,22 @@ export type IAISelectDataType = {
|
|||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IAISelectProps = SelectProps & {
|
type IAISelectProps = Omit<SelectProps, 'label'> & {
|
||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
|
label?: string;
|
||||||
inputRef?: RefObject<HTMLInputElement>;
|
inputRef?: RefObject<HTMLInputElement>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const IAIMantineSearchableSelect = (props: IAISelectProps) => {
|
const IAIMantineSearchableSelect = (props: IAISelectProps) => {
|
||||||
const { searchable = true, tooltip, inputRef, onChange, ...rest } = props;
|
const {
|
||||||
|
searchable = true,
|
||||||
|
tooltip,
|
||||||
|
inputRef,
|
||||||
|
onChange,
|
||||||
|
label,
|
||||||
|
disabled,
|
||||||
|
...rest
|
||||||
|
} = props;
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const [searchValue, setSearchValue] = useState('');
|
const [searchValue, setSearchValue] = useState('');
|
||||||
@ -61,6 +70,14 @@ const IAIMantineSearchableSelect = (props: IAISelectProps) => {
|
|||||||
<Tooltip label={tooltip} placement="top" hasArrow>
|
<Tooltip label={tooltip} placement="top" hasArrow>
|
||||||
<Select
|
<Select
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
|
label={
|
||||||
|
label ? (
|
||||||
|
<FormControl isDisabled={disabled}>
|
||||||
|
<FormLabel>{label}</FormLabel>
|
||||||
|
</FormControl>
|
||||||
|
) : undefined
|
||||||
|
}
|
||||||
|
disabled={disabled}
|
||||||
searchValue={searchValue}
|
searchValue={searchValue}
|
||||||
onSearchChange={setSearchValue}
|
onSearchChange={setSearchValue}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Tooltip } from '@chakra-ui/react';
|
import { FormControl, FormLabel, Tooltip } from '@chakra-ui/react';
|
||||||
import { Select, SelectProps } from '@mantine/core';
|
import { Select, SelectProps } from '@mantine/core';
|
||||||
import { useMantineSelectStyles } from 'mantine-theme/hooks/useMantineSelectStyles';
|
import { useMantineSelectStyles } from 'mantine-theme/hooks/useMantineSelectStyles';
|
||||||
import { RefObject, memo } from 'react';
|
import { RefObject, memo } from 'react';
|
||||||
@ -9,19 +9,32 @@ export type IAISelectDataType = {
|
|||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IAISelectProps = SelectProps & {
|
type IAISelectProps = Omit<SelectProps, 'label'> & {
|
||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
inputRef?: RefObject<HTMLInputElement>;
|
inputRef?: RefObject<HTMLInputElement>;
|
||||||
|
label?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const IAIMantineSelect = (props: IAISelectProps) => {
|
const IAIMantineSelect = (props: IAISelectProps) => {
|
||||||
const { tooltip, inputRef, ...rest } = props;
|
const { tooltip, inputRef, label, disabled, ...rest } = props;
|
||||||
|
|
||||||
const styles = useMantineSelectStyles();
|
const styles = useMantineSelectStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip label={tooltip} placement="top" hasArrow>
|
<Tooltip label={tooltip} placement="top" hasArrow>
|
||||||
<Select ref={inputRef} styles={styles} {...rest} />
|
<Select
|
||||||
|
label={
|
||||||
|
label ? (
|
||||||
|
<FormControl isDisabled={disabled}>
|
||||||
|
<FormLabel>{label}</FormLabel>
|
||||||
|
</FormControl>
|
||||||
|
) : undefined
|
||||||
|
}
|
||||||
|
disabled={disabled}
|
||||||
|
ref={inputRef}
|
||||||
|
styles={styles}
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -187,15 +187,14 @@ const ControlNet = (props: ControlNetProps) => {
|
|||||||
{isExpanded && (
|
{isExpanded && (
|
||||||
<>
|
<>
|
||||||
<ParamControlNetControlMode controlNetId={controlNetId} />
|
<ParamControlNetControlMode controlNetId={controlNetId} />
|
||||||
<ParamControlNetProcessorSelect controlNetId={controlNetId} />
|
|
||||||
<ParamControlNetShouldAutoConfig controlNetId={controlNetId} />
|
|
||||||
|
|
||||||
<Box mt={2}>
|
<Box mt={2}>
|
||||||
<ControlNetImagePreview
|
<ControlNetImagePreview
|
||||||
controlNetId={controlNetId}
|
controlNetId={controlNetId}
|
||||||
height="392px"
|
height="392px"
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
<ParamControlNetShouldAutoConfig controlNetId={controlNetId} />
|
||||||
|
<ParamControlNetProcessorSelect controlNetId={controlNetId} />
|
||||||
<ControlNetProcessorComponent controlNetId={controlNetId} />
|
<ControlNetProcessorComponent controlNetId={controlNetId} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -54,7 +54,7 @@ export default function ParamControlNetControlMode(
|
|||||||
return (
|
return (
|
||||||
<IAIMantineSelect
|
<IAIMantineSelect
|
||||||
disabled={!isEnabled}
|
disabled={!isEnabled}
|
||||||
label={t('parameters.controlNetControlMode')}
|
label="Control Mode"
|
||||||
data={CONTROL_MODE_DATA}
|
data={CONTROL_MODE_DATA}
|
||||||
value={String(controlMode)}
|
value={String(controlMode)}
|
||||||
onChange={handleControlModeChange}
|
onChange={handleControlModeChange}
|
||||||
|
@ -13,6 +13,7 @@ import { memo, useCallback, useMemo } from 'react';
|
|||||||
import { CONTROLNET_PROCESSORS } from '../../store/constants';
|
import { CONTROLNET_PROCESSORS } from '../../store/constants';
|
||||||
import { controlNetProcessorTypeChanged } from '../../store/controlNetSlice';
|
import { controlNetProcessorTypeChanged } from '../../store/controlNetSlice';
|
||||||
import { ControlNetProcessorType } from '../../store/types';
|
import { ControlNetProcessorType } from '../../store/types';
|
||||||
|
import { FormControl, FormLabel } from '@chakra-ui/react';
|
||||||
|
|
||||||
type ParamControlNetProcessorSelectProps = {
|
type ParamControlNetProcessorSelectProps = {
|
||||||
controlNetId: string;
|
controlNetId: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user