From f87379fa980f24d9f9969f1d22b9904aa3469662 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 25 Nov 2022 00:04:06 -0500 Subject: [PATCH] fix(striker-ui): expose onBlur and onFocus in OutlinedInputWithLabel --- .../components/OutlinedInputWithLabel.tsx | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/striker-ui/components/OutlinedInputWithLabel.tsx b/striker-ui/components/OutlinedInputWithLabel.tsx index e6b8fa46..b0d8c82c 100644 --- a/striker-ui/components/OutlinedInputWithLabel.tsx +++ b/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 { FormControl as MUIFormControl, @@ -8,6 +7,7 @@ import { iconButtonClasses as muiIconButtonClasses, InputAdornment as MUIInputAdornment, } from '@mui/material'; +import { FC, useCallback, useMemo, useState } from 'react'; import { GREY } from '../lib/consts/DEFAULT_THEME'; @@ -18,7 +18,7 @@ import OutlinedInputLabel, { OutlinedInputLabelProps, } from './OutlinedInputLabel'; -type OutlinedInputWithLabelOptionalProps = { +type OutlinedInputWithLabelOptionalPropsWithDefault = { fillRow?: boolean; formControlProps?: Partial; helpMessageBoxProps?: Partial; @@ -26,28 +26,29 @@ type OutlinedInputWithLabelOptionalProps = { inputProps?: Partial; inputLabelProps?: Partial; messageBoxProps?: Partial; + required?: boolean; + value?: OutlinedInputProps['value']; +}; + +type OutlinedInputWithLabelOptionalPropsWithoutDefault = { + onBlur?: OutlinedInputProps['onBlur']; onChange?: OutlinedInputProps['onChange']; + onFocus?: OutlinedInputProps['onFocus']; onHelp?: MUIIconButtonProps['onClick']; onHelpAppend?: MUIIconButtonProps['onClick']; - required?: boolean; type?: string; - value?: OutlinedInputProps['value']; }; -type OutlinedInputWithLabelProps = { +type OutlinedInputWithLabelOptionalProps = + OutlinedInputWithLabelOptionalPropsWithDefault & + OutlinedInputWithLabelOptionalPropsWithoutDefault; + +type OutlinedInputWithLabelProps = OutlinedInputWithLabelOptionalProps & { label: string; -} & OutlinedInputWithLabelOptionalProps; - -const OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS: Required< - Omit< - OutlinedInputWithLabelOptionalProps, - 'onChange' | 'onHelp' | 'onHelpAppend' | 'type' - > -> & - Pick< - OutlinedInputWithLabelOptionalProps, - 'onChange' | 'onHelp' | 'onHelpAppend' | 'type' - > = { +}; + +const OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS: Required & + OutlinedInputWithLabelOptionalPropsWithoutDefault = { fillRow: false, formControlProps: {}, helpMessageBoxProps: {}, @@ -55,7 +56,9 @@ const OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS: Required< inputProps: {}, inputLabelProps: {}, messageBoxProps: {}, + onBlur: undefined, onChange: undefined, + onFocus: undefined, onHelp: undefined, onHelpAppend: undefined, required: false, @@ -75,7 +78,9 @@ const OutlinedInputWithLabel: FC = ({ inputLabelProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.inputLabelProps, label, messageBoxProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.messageBoxProps, + onBlur, onChange, + onFocus, onHelp, onHelpAppend, required = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.required, @@ -167,7 +172,9 @@ const OutlinedInputWithLabel: FC = ({ fullWidth={formControlProps.fullWidth} id={id} label={label} + onBlur={onBlur} onChange={onChange} + onFocus={onFocus} type={type} value={value} {...restInputProps}