fix(striker-ui): expose onBlur and onFocus in OutlinedInputWithLabel

main
Tsu-ba-me 2 years ago
parent 1be005669e
commit f87379fa98
  1. 41
      striker-ui/components/OutlinedInputWithLabel.tsx

@ -1,4 +1,3 @@
import { FC, useCallback, useMemo, useState } from 'react';
import { QuestionMark as MUIQuestionMarkIcon } from '@mui/icons-material'; import { QuestionMark as MUIQuestionMarkIcon } from '@mui/icons-material';
import { import {
FormControl as MUIFormControl, FormControl as MUIFormControl,
@ -8,6 +7,7 @@ import {
iconButtonClasses as muiIconButtonClasses, iconButtonClasses as muiIconButtonClasses,
InputAdornment as MUIInputAdornment, InputAdornment as MUIInputAdornment,
} from '@mui/material'; } from '@mui/material';
import { FC, useCallback, useMemo, useState } from 'react';
import { GREY } from '../lib/consts/DEFAULT_THEME'; import { GREY } from '../lib/consts/DEFAULT_THEME';
@ -18,7 +18,7 @@ import OutlinedInputLabel, {
OutlinedInputLabelProps, OutlinedInputLabelProps,
} from './OutlinedInputLabel'; } from './OutlinedInputLabel';
type OutlinedInputWithLabelOptionalProps = { type OutlinedInputWithLabelOptionalPropsWithDefault = {
fillRow?: boolean; fillRow?: boolean;
formControlProps?: Partial<MUIFormControlProps>; formControlProps?: Partial<MUIFormControlProps>;
helpMessageBoxProps?: Partial<MessageBoxProps>; helpMessageBoxProps?: Partial<MessageBoxProps>;
@ -26,28 +26,29 @@ type OutlinedInputWithLabelOptionalProps = {
inputProps?: Partial<OutlinedInputProps>; inputProps?: Partial<OutlinedInputProps>;
inputLabelProps?: Partial<OutlinedInputLabelProps>; inputLabelProps?: Partial<OutlinedInputLabelProps>;
messageBoxProps?: Partial<MessageBoxProps>; messageBoxProps?: Partial<MessageBoxProps>;
required?: boolean;
value?: OutlinedInputProps['value'];
};
type OutlinedInputWithLabelOptionalPropsWithoutDefault = {
onBlur?: OutlinedInputProps['onBlur'];
onChange?: OutlinedInputProps['onChange']; onChange?: OutlinedInputProps['onChange'];
onFocus?: OutlinedInputProps['onFocus'];
onHelp?: MUIIconButtonProps['onClick']; onHelp?: MUIIconButtonProps['onClick'];
onHelpAppend?: MUIIconButtonProps['onClick']; onHelpAppend?: MUIIconButtonProps['onClick'];
required?: boolean;
type?: string; type?: string;
value?: OutlinedInputProps['value'];
}; };
type OutlinedInputWithLabelProps = { type OutlinedInputWithLabelOptionalProps =
OutlinedInputWithLabelOptionalPropsWithDefault &
OutlinedInputWithLabelOptionalPropsWithoutDefault;
type OutlinedInputWithLabelProps = OutlinedInputWithLabelOptionalProps & {
label: string; label: string;
} & OutlinedInputWithLabelOptionalProps; };
const OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS: Required< const OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS: Required<OutlinedInputWithLabelOptionalPropsWithDefault> &
Omit< OutlinedInputWithLabelOptionalPropsWithoutDefault = {
OutlinedInputWithLabelOptionalProps,
'onChange' | 'onHelp' | 'onHelpAppend' | 'type'
>
> &
Pick<
OutlinedInputWithLabelOptionalProps,
'onChange' | 'onHelp' | 'onHelpAppend' | 'type'
> = {
fillRow: false, fillRow: false,
formControlProps: {}, formControlProps: {},
helpMessageBoxProps: {}, helpMessageBoxProps: {},
@ -55,7 +56,9 @@ const OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS: Required<
inputProps: {}, inputProps: {},
inputLabelProps: {}, inputLabelProps: {},
messageBoxProps: {}, messageBoxProps: {},
onBlur: undefined,
onChange: undefined, onChange: undefined,
onFocus: undefined,
onHelp: undefined, onHelp: undefined,
onHelpAppend: undefined, onHelpAppend: undefined,
required: false, required: false,
@ -75,7 +78,9 @@ const OutlinedInputWithLabel: FC<OutlinedInputWithLabelProps> = ({
inputLabelProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.inputLabelProps, inputLabelProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.inputLabelProps,
label, label,
messageBoxProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.messageBoxProps, messageBoxProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.messageBoxProps,
onBlur,
onChange, onChange,
onFocus,
onHelp, onHelp,
onHelpAppend, onHelpAppend,
required = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.required, required = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.required,
@ -167,7 +172,9 @@ const OutlinedInputWithLabel: FC<OutlinedInputWithLabelProps> = ({
fullWidth={formControlProps.fullWidth} fullWidth={formControlProps.fullWidth}
id={id} id={id}
label={label} label={label}
onBlur={onBlur}
onChange={onChange} onChange={onChange}
onFocus={onFocus}
type={type} type={type}
value={value} value={value}
{...restInputProps} {...restInputProps}

Loading…
Cancel
Save