diff --git a/striker-ui/components/OutlinedLabeledInputWithSelect.tsx b/striker-ui/components/OutlinedLabeledInputWithSelect.tsx index c473810c..2dce2deb 100644 --- a/striker-ui/components/OutlinedLabeledInputWithSelect.tsx +++ b/striker-ui/components/OutlinedLabeledInputWithSelect.tsx @@ -12,7 +12,7 @@ import { MessageBoxProps } from './MessageBox'; import OutlinedInputWithLabel, { OutlinedInputWithLabelProps, } from './OutlinedInputWithLabel'; -import SelectWithLabel, { SelectWithLabelProps } from './SelectWithLabel'; +import SelectWithLabel from './SelectWithLabel'; type OutlinedLabeledInputWithSelectOptionalProps = { inputWithLabelProps?: Partial; @@ -66,19 +66,11 @@ const OutlinedLabeledInputWithSelect: FC< }, }} > - + diff --git a/striker-ui/components/SelectWithLabel.tsx b/striker-ui/components/SelectWithLabel.tsx index 8da8980f..e2a343d6 100644 --- a/striker-ui/components/SelectWithLabel.tsx +++ b/striker-ui/components/SelectWithLabel.tsx @@ -1,48 +1,15 @@ -import { FC, useCallback, useMemo } from 'react'; import { Checkbox as MUICheckbox, FormControl as MUIFormControl, selectClasses as muiSelectClasses, } from '@mui/material'; +import { FC, useCallback, useMemo } from 'react'; import InputMessageBox from './InputMessageBox'; import MenuItem from './MenuItem'; -import { MessageBoxProps } from './MessageBox'; import OutlinedInput from './OutlinedInput'; -import OutlinedInputLabel, { - OutlinedInputLabelProps, -} from './OutlinedInputLabel'; -import Select, { SelectProps } from './Select'; - -type SelectWithLabelOptionalProps = { - checkItem?: ((value: string) => boolean) | null; - disableItem?: ((value: string) => boolean) | null; - hideItem?: ((value: string) => boolean) | null; - isCheckableItems?: boolean; - isReadOnly?: boolean; - inputLabelProps?: Partial; - label?: string | null; - messageBoxProps?: Partial; - selectProps?: Partial; -}; - -type SelectWithLabelProps = SelectWithLabelOptionalProps & { - id: string; - selectItems: Array; -}; - -const SELECT_WITH_LABEL_DEFAULT_PROPS: Required = - { - checkItem: null, - disableItem: null, - hideItem: null, - isReadOnly: false, - isCheckableItems: false, - inputLabelProps: {}, - label: null, - messageBoxProps: {}, - selectProps: {}, - }; +import OutlinedInputLabel from './OutlinedInputLabel'; +import Select from './Select'; const SelectWithLabel: FC = ({ id, @@ -51,14 +18,19 @@ const SelectWithLabel: FC = ({ checkItem, disableItem, hideItem, - inputLabelProps, - isReadOnly, - messageBoxProps, - selectProps = {}, - isCheckableItems = selectProps?.multiple, + inputLabelProps = {}, + isReadOnly = false, + messageBoxProps = {}, + onChange, + selectProps: { + multiple: selectMultiple, + sx: selectSx, + ...restSelectProps + } = {}, + value: selectValue, + // Props with initial value that depend on others. + isCheckableItems = selectMultiple, }) => { - const { sx: selectSx } = selectProps; - const combinedSx = useMemo( () => isReadOnly @@ -124,8 +96,11 @@ const SelectWithLabel: FC = ({