Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/components/fields/SQFormDatePicker/SQFormDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function SQFormDatePicker({
size = 'auto',
isDisabled = false,
displayHelperText = true,
placeholder = '',
placeholder = 'MM / DD / YYYY',
onBlur,
onChange,
setDisabledDate,
Expand Down Expand Up @@ -109,28 +109,23 @@ function SQFormDatePicker({
variant="standard"
error={isFieldError}
fullWidth={true}
inputProps={{...inputProps.inputProps, ...muiTextInputProps}}
inputProps={{
...inputProps.inputProps,
placeholder,
...muiTextInputProps,
}}
InputLabelProps={{shrink: true}}
FormHelperTextProps={{error: isFieldError}}
helperText={
!isDisabled && displayHelperText && HelperTextComponent
}
placeholder={placeholder}
onBlur={handleBlur}
required={isFieldRequired}
onClick={
isCalendarOnly && !isDisabled
? toggleCalendar
: handleClickAway
}
sx={{
'& .MuiInputBase-root.Mui-focused, & .MuiInputBase-root:hover:not(.Mui-disabled)':
{
'& .MuiIconButton-root': {
color: 'var(--color-teal)',
},
},
}}
/>
);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function SQFormDatePickerWithCalendarInputOnly({
label,
size = 'auto',
isDisabled = false,
placeholder = '',
placeholder,
onBlur,
onChange,
setDisabledDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function SQFormDatePickerWithDateFNS({
label,
size = 'auto',
isDisabled = false,
placeholder = '',
placeholder = 'MM / DD / YYYY',
onBlur,
onChange,
setDisabledDate,
Expand Down Expand Up @@ -79,26 +79,21 @@ function SQFormDatePickerWithDateFNS({
variant="standard"
error={isFieldError}
fullWidth={true}
inputProps={{...inputProps.inputProps, ...muiTextInputProps}}
inputProps={{
...inputProps.inputProps,
placeholder,
...muiTextInputProps,
}}
InputLabelProps={{shrink: true}}
FormHelperTextProps={{error: isFieldError}}
helperText={!isDisabled && HelperTextComponent}
placeholder={placeholder}
onBlur={handleBlur}
required={isFieldRequired}
onClick={
isCalendarOnly && !isDisabled
? toggleCalendar
: handleClickAway
}
sx={{
'& .MuiInputBase-root.Mui-focused, & .MuiInputBase-root:hover:not(.Mui-disabled)':
{
'& .MuiIconButton-root': {
color: 'var(--color-teal)',
},
},
}}
/>
);
}}
Expand Down
12 changes: 10 additions & 2 deletions src/components/fields/SQFormDatePicker/SQFormDateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {DateTimePicker} from '@mui/x-date-pickers';
import {useForm} from '../../../hooks/useForm';
import type {MarkOptional} from 'ts-essentials';
import type {Moment} from 'moment';
import type {InputBaseComponentProps} from '@mui/material';
import type {BaseDateTimePickerProps} from '@mui/x-date-pickers/DateTimePicker/shared';
import type {BaseFieldProps} from '../../../types';

Expand All @@ -21,17 +22,20 @@ export type SQFormDateTimePickerProps = BaseFieldProps & {
BaseDateTimePickerProps<Moment, Moment>,
'onChange' | 'value' | 'renderInput'
>;
/** Any valid prop for MUI input field - https://material-ui.com/api/text-field/ & https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes */
muiTextInputProps?: InputBaseComponentProps;
};

function SQFormDateTimePicker({
name,
label,
size = 'auto',
isDisabled = false,
placeholder = '',
placeholder = 'MM / DD / YYYY HH:MM (A|P)M',
onBlur,
onChange,
muiFieldProps = {},
muiTextInputProps = {},
}: SQFormDateTimePickerProps): JSX.Element {
const {
formikField: {field, helpers},
Expand Down Expand Up @@ -80,10 +84,14 @@ function SQFormDateTimePicker({
disabled={isDisabled}
error={isFieldError}
fullWidth={true}
inputProps={{
...inputProps.inputProps,
placeholder,
...muiTextInputProps,
}}
InputLabelProps={{shrink: true}}
FormHelperTextProps={{error: isFieldError}}
helperText={!isDisabled && HelperTextComponent}
placeholder={placeholder}
onBlur={handleBlur}
onClick={handleClickAway}
required={isFieldRequired}
Expand Down