2022-10-28 09:04:57 +00:00
|
|
|
import {
|
|
|
|
FormControl,
|
|
|
|
FormControlProps,
|
|
|
|
FormLabel,
|
|
|
|
FormLabelProps,
|
|
|
|
Switch,
|
|
|
|
SwitchProps,
|
|
|
|
} from '@chakra-ui/react';
|
2022-09-16 17:18:15 +00:00
|
|
|
|
|
|
|
interface Props extends SwitchProps {
|
|
|
|
label?: string;
|
|
|
|
width?: string | number;
|
2023-03-06 01:29:39 +00:00
|
|
|
styleClass?: string;
|
2022-10-28 09:04:57 +00:00
|
|
|
formControlProps?: FormControlProps;
|
|
|
|
formLabelProps?: FormLabelProps;
|
2022-09-16 17:18:15 +00:00
|
|
|
}
|
|
|
|
|
2022-09-17 06:32:59 +00:00
|
|
|
/**
|
|
|
|
* Customized Chakra FormControl + Switch multi-part component.
|
|
|
|
*/
|
2022-10-03 16:15:26 +00:00
|
|
|
const IAISwitch = (props: Props) => {
|
2022-09-16 17:18:15 +00:00
|
|
|
const {
|
|
|
|
label,
|
|
|
|
isDisabled = false,
|
2022-10-03 16:15:26 +00:00
|
|
|
width = 'auto',
|
2022-10-28 09:04:57 +00:00
|
|
|
formControlProps,
|
|
|
|
formLabelProps,
|
2023-03-06 01:29:39 +00:00
|
|
|
styleClass,
|
2022-09-16 17:18:15 +00:00
|
|
|
...rest
|
|
|
|
} = props;
|
|
|
|
return (
|
2022-10-27 04:24:00 +00:00
|
|
|
<FormControl
|
|
|
|
isDisabled={isDisabled}
|
|
|
|
width={width}
|
2023-03-06 01:29:39 +00:00
|
|
|
className={`invokeai__switch-form-control ${styleClass}`}
|
2022-12-24 18:23:21 +00:00
|
|
|
display="flex"
|
2023-03-06 01:29:39 +00:00
|
|
|
columnGap="1rem"
|
2022-12-24 18:23:21 +00:00
|
|
|
alignItems="center"
|
|
|
|
justifyContent="space-between"
|
2022-10-28 09:04:57 +00:00
|
|
|
{...formControlProps}
|
2022-10-27 04:24:00 +00:00
|
|
|
>
|
2023-03-06 01:29:39 +00:00
|
|
|
<FormLabel
|
|
|
|
className="invokeai__switch-form-label"
|
|
|
|
whiteSpace="nowrap"
|
|
|
|
marginRight={0}
|
|
|
|
marginTop={0.5}
|
|
|
|
marginBottom={0.5}
|
|
|
|
fontSize="sm"
|
|
|
|
fontWeight="bold"
|
|
|
|
width="auto"
|
|
|
|
{...formLabelProps}
|
|
|
|
>
|
2022-10-27 04:24:00 +00:00
|
|
|
{label}
|
|
|
|
</FormLabel>
|
2023-03-06 01:29:39 +00:00
|
|
|
<Switch className="invokeai__switch-root" {...rest} />
|
2022-09-16 17:18:15 +00:00
|
|
|
</FormControl>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-10-03 16:15:26 +00:00
|
|
|
export default IAISwitch;
|