-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from lyytioy/next
Version 1.0.2
- Loading branch information
Showing
11 changed files
with
2,555 additions
and
2,311 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,144 +1,31 @@ | ||
import Autocomplete, { AutocompleteProps } from './Autocomplete'; | ||
import { SizeTypes } from './TextField'; | ||
import { Clock } from '../icons'; | ||
import MuiTimePicker, { TimePickerProps as MuiTimePickerProps } from '@mui/lab/TimePicker'; | ||
import TextField, { TextFieldProps } from './TextField'; | ||
|
||
const twentyFourHourTimes = [ | ||
{ id: '00:00', value: '00:00' }, | ||
{ id: '00:30', value: '00:30' }, | ||
{ id: '01:00', value: '01:00' }, | ||
{ id: '01:30', value: '01:30' }, | ||
{ id: '02:00', value: '02:00' }, | ||
{ id: '02:30', value: '02:30' }, | ||
{ id: '03:00', value: '03:00' }, | ||
{ id: '03:30', value: '03:30' }, | ||
{ id: '04:00', value: '04:00' }, | ||
{ id: '04:30', value: '04:30' }, | ||
{ id: '05:00', value: '05:00' }, | ||
{ id: '05:30', value: '05:30' }, | ||
{ id: '06:00', value: '06:00' }, | ||
{ id: '07:00', value: '07:00' }, | ||
{ id: '07:30', value: '07:30' }, | ||
{ id: '08:00', value: '08:00' }, | ||
{ id: '08:30', value: '08:30' }, | ||
{ id: '09:00', value: '09:00' }, | ||
{ id: '09:30', value: '09:30' }, | ||
{ id: '10:00', value: '10:00' }, | ||
{ id: '10:30', value: '10:30' }, | ||
{ id: '11:00', value: '11:00' }, | ||
{ id: '11:30', value: '11:30' }, | ||
{ id: '12:00', value: '12:00' }, | ||
{ id: '12:30', value: '12:30' }, | ||
{ id: '13:00', value: '13:00' }, | ||
{ id: '13:30', value: '13:30' }, | ||
{ id: '14:00', value: '14:00' }, | ||
{ id: '14:30', value: '14:30' }, | ||
{ id: '15:00', value: '15:00' }, | ||
{ id: '15:30', value: '15:30' }, | ||
{ id: '16:00', value: '16:00' }, | ||
{ id: '16:30', value: '16:30' }, | ||
{ id: '17:00', value: '17:00' }, | ||
{ id: '17:30', value: '17:30' }, | ||
{ id: '18:00', value: '18:00' }, | ||
{ id: '18:30', value: '18:30' }, | ||
{ id: '19:00', value: '19:00' }, | ||
{ id: '19:30', value: '19:30' }, | ||
{ id: '20:00', value: '20:00' }, | ||
{ id: '20:30', value: '20:30' }, | ||
{ id: '21:00', value: '21:00' }, | ||
{ id: '21:30', value: '21:30' }, | ||
{ id: '22:00', value: '22:00' }, | ||
{ id: '22:30', value: '22:30' }, | ||
{ id: '23:00', value: '23:00' }, | ||
{ id: '23:30', value: '23:30' }, | ||
]; | ||
|
||
const twelveHourTimes = [ | ||
{ id: '12:00 AM', value: '12:00 AM' }, | ||
{ id: '12:30 AM', value: '12:30 AM' }, | ||
{ id: '01:00 AM', value: '01:00 AM' }, | ||
{ id: '01:30 AM', value: '01:30 AM' }, | ||
{ id: '02:00 AM', value: '02:00 AM' }, | ||
{ id: '02:30 AM', value: '02:30 AM' }, | ||
{ id: '03:00 AM', value: '03:00 AM' }, | ||
{ id: '03:30 AM', value: '03:30 AM' }, | ||
{ id: '04:00 AM', value: '04:00 AM' }, | ||
{ id: '04:30 AM', value: '04:30 AM' }, | ||
{ id: '05:00 AM', value: '05:00 AM' }, | ||
{ id: '05:30 AM', value: '05:30 AM' }, | ||
{ id: '06:00 AM', value: '06:00 AM' }, | ||
{ id: '07:00 AM', value: '07:00 AM' }, | ||
{ id: '07:30 AM', value: '07:30 AM' }, | ||
{ id: '08:00 AM', value: '08:00 AM' }, | ||
{ id: '08:30 AM', value: '08:30 AM' }, | ||
{ id: '09:00 AM', value: '09:00 AM' }, | ||
{ id: '09:30 AM', value: '09:30 AM' }, | ||
{ id: '10:00 AM', value: '10:00 AM' }, | ||
{ id: '10:30 AM', value: '10:30 AM' }, | ||
{ id: '11:00 AM', value: '11:00 AM' }, | ||
{ id: '11:30 AM', value: '11:30 AM' }, | ||
{ id: '12:00 PM', value: '12:00 PM' }, | ||
{ id: '12:30 PM', value: '12:30 PM' }, | ||
{ id: '01:00 PM', value: '01:00 PM' }, | ||
{ id: '01:30 PM', value: '01:30 PM' }, | ||
{ id: '02:00 PM', value: '02:00 PM' }, | ||
{ id: '02:30 PM', value: '02:30 PM' }, | ||
{ id: '03:00 PM', value: '03:00 PM' }, | ||
{ id: '03:30 PM', value: '03:30 PM' }, | ||
{ id: '04:00 PM', value: '04:00 PM' }, | ||
{ id: '04:30 PM', value: '04:30 PM' }, | ||
{ id: '05:00 PM', value: '05:00 PM' }, | ||
{ id: '05:30 PM', value: '05:30 PM' }, | ||
{ id: '06:00 PM', value: '06:00 PM' }, | ||
{ id: '07:00 PM', value: '07:00 PM' }, | ||
{ id: '07:30 PM', value: '07:30 PM' }, | ||
{ id: '08:00 PM', value: '08:00 PM' }, | ||
{ id: '08:30 PM', value: '08:30 PM' }, | ||
{ id: '09:00 PM', value: '09:00 PM' }, | ||
{ id: '09:30 PM', value: '09:30 PM' }, | ||
{ id: '10:00 PM', value: '10:00 PM' }, | ||
{ id: '10:30 PM', value: '10:30 PM' }, | ||
{ id: '11:00 PM', value: '11:00 PM' }, | ||
{ id: '11:30 PM', value: '11:30 PM' }, | ||
]; | ||
|
||
export interface TimePickerProps extends Omit<AutocompleteProps, 'renderInput' | 'options'> { | ||
twelvehour?: boolean; | ||
error?: boolean; | ||
helperText?: string; | ||
size?: SizeTypes; | ||
label?: string; | ||
export interface TimePickerProps extends Omit<MuiTimePickerProps, 'renderInput' | 'InputProps'> { | ||
InputProps?: TextFieldProps; | ||
'data-testid'?: string; | ||
} | ||
|
||
const TimePicker = ({ | ||
twelvehour, | ||
error, | ||
helperText, | ||
size = 'small', | ||
label, | ||
...props | ||
}: TimePickerProps): JSX.Element => { | ||
const TimePicker = ({ ampm = false, InputProps = {}, ...props }: TimePickerProps): JSX.Element => { | ||
return ( | ||
<Autocomplete | ||
freeSolo | ||
forcePopupIcon | ||
popupIcon={<Clock color="inherit" />} | ||
options={twelvehour ? twelveHourTimes : twentyFourHourTimes} | ||
disableClearable={true} | ||
size={size} | ||
label={label} | ||
error={error} | ||
helperText={helperText} | ||
sx={{ | ||
'& .MuiAutocomplete-popupIndicatorOpen': { transform: 'none' }, | ||
}} | ||
<MuiTimePicker | ||
ampm={ampm} | ||
{...props} | ||
PopperProps={{ | ||
// @ts-ignore | ||
sx: { | ||
'& .MuiClockPicker-arrowSwitcher': { | ||
width: '70px', | ||
|
||
'& button:hover': { | ||
backgroundColor: 'primary.light', | ||
}, | ||
}, | ||
}, | ||
}} | ||
renderInput={(params) => <TextField {...(params as TextFieldProps)} {...InputProps} />} | ||
/> | ||
); | ||
}; | ||
|
||
TimePicker.defaultProps = { | ||
twelvehour: false, | ||
}; | ||
|
||
export default TimePicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.