@docsvision/material-ui-pickers 3.2.0-beta.3 → 3.2.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{build/DatePicker → DatePicker}/DatePicker.d.ts +2 -2
- package/{build/DatePicker → DatePicker}/DatePicker.js +1 -1
- package/{build/DatePicker → DatePicker}/DatePickerToolbar.js +3 -3
- package/{build/DateTimePicker → DateTimePicker}/DateTimePicker.d.ts +2 -2
- package/{build/DateTimePicker → DateTimePicker}/DateTimePicker.js +3 -3
- package/{build/DateTimePicker → DateTimePicker}/DateTimePickerToolbar.js +4 -4
- package/{build/MuiPickersUtilsProvider.d.ts → MuiPickersUtilsProvider.d.ts} +1 -1
- package/{build/MuiPickersUtilsProvider.js → MuiPickersUtilsProvider.js} +11 -5
- package/{build/Picker → Picker}/Picker.d.ts +5 -3
- package/{build/Picker → Picker}/Picker.js +15 -12
- package/{build/Picker → Picker}/WrappedKeyboardPicker.js +2 -2
- package/{build/Picker → Picker}/WrappedPurePicker.js +4 -3
- package/{build/README.md → README.md} +1 -1
- package/Rifm/Rifm.d.ts +17 -0
- package/Rifm/Rifm.js +166 -0
- package/{build/TimePicker → TimePicker}/TimePicker.d.ts +4 -2
- package/{build/TimePicker → TimePicker}/TimePicker.js +3 -3
- package/{build/TimePicker → TimePicker}/TimePickerToolbar.js +3 -3
- package/{build/_helpers → _helpers}/date-utils.d.ts +2 -2
- package/{build/_helpers → _helpers}/date-utils.js +3 -3
- package/_helpers/text-field-helper.d.ts +32 -0
- package/_helpers/text-field-helper.js +144 -0
- package/{build/_helpers → _helpers}/time-utils.d.ts +2 -2
- package/{build/_shared → _shared}/KeyboardDateInput.d.ts +5 -0
- package/{build/_shared → _shared}/KeyboardDateInput.js +29 -5
- package/{build/_shared → _shared}/ModalDialog.d.ts +2 -2
- package/{build/_shared → _shared}/PureDateInput.js +1 -1
- package/{build/_shared → _shared}/ToolbarButton.d.ts +2 -2
- package/{build/_shared → _shared}/WithUtils.d.ts +1 -1
- package/{build/_shared → _shared}/hooks/useIsLandscape.js +1 -1
- package/{build/_shared → _shared}/hooks/useKeyboardPickerState.d.ts +1 -1
- package/{build/_shared → _shared}/hooks/useKeyboardPickerState.js +3 -3
- package/{build/_shared → _shared}/hooks/usePickerState.d.ts +1 -1
- package/{build/_shared → _shared}/hooks/usePickerState.js +2 -3
- package/{build/_shared → _shared}/hooks/useUtils.d.ts +2 -2
- package/{build/constants → constants}/prop-types.js +2 -2
- package/{build/dist → dist}/material-ui-pickers.esm.js +1467 -837
- package/dist/material-ui-pickers.esm.js.map +1 -0
- package/{build/dist → dist}/material-ui-pickers.js +1483 -853
- package/dist/material-ui-pickers.js.map +1 -0
- package/{build/dist → dist}/material-ui-pickers.umd.js +29819 -22160
- package/dist/material-ui-pickers.umd.min.js +1 -0
- package/{build/index.d.ts → index.d.ts} +11 -11
- package/package.json +14 -88
- package/{build/typings → typings}/BasePicker.d.ts +2 -0
- package/{build/typings → typings}/overrides.d.ts +2 -2
- package/{build/views → views}/Calendar/Calendar.js +4 -3
- package/{build/views → views}/Calendar/CalendarHeader.js +1 -1
- package/{build/views → views}/Clock/Clock.d.ts +1 -1
- package/{build/views → views}/Clock/Clock.js +1 -1
- package/{build/views → views}/Clock/ClockNumbers.d.ts +2 -2
- package/{build/views → views}/Clock/ClockPointer.d.ts +1 -1
- package/{build/views → views}/Clock/ClockView.js +1 -1
- package/{build/views → views}/Month/MonthView.js +1 -1
- package/{build/views → views}/Year/YearView.js +2 -2
- package/.size-snapshot.json +0 -26
- package/build/_helpers/text-field-helper.d.ts +0 -32
- package/build/_helpers/text-field-helper.js +0 -88
- package/build/dist/material-ui-pickers.esm.js.map +0 -1
- package/build/dist/material-ui-pickers.js.map +0 -1
- package/build/dist/material-ui-pickers.umd.min.js +0 -1
- package/build/package.json +0 -63
- package/copy.js +0 -58
- package/coverage/clover.xml +0 -1589
- package/coverage/coverage-final.json +0 -57
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/index.html +0 -279
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov-report/src/DatePicker/DatePicker.tsx.html +0 -342
- package/coverage/lcov-report/src/DatePicker/DatePickerToolbar.tsx.html +0 -294
- package/coverage/lcov-report/src/DatePicker/index.html +0 -123
- package/coverage/lcov-report/src/DatePicker/index.ts.html +0 -90
- package/coverage/lcov-report/src/DateTimePicker/DateTimePicker.tsx.html +0 -285
- package/coverage/lcov-report/src/DateTimePicker/DateTimePickerTabs.tsx.html +0 -327
- package/coverage/lcov-report/src/DateTimePicker/DateTimePickerToolbar.tsx.html +0 -438
- package/coverage/lcov-report/src/DateTimePicker/index.html +0 -123
- package/coverage/lcov-report/src/MuiPickersUtilsProvider.tsx.html +0 -186
- package/coverage/lcov-report/src/Picker/Picker.tsx.html +0 -873
- package/coverage/lcov-report/src/Picker/WrappedKeyboardPicker.tsx.html +0 -465
- package/coverage/lcov-report/src/Picker/WrappedPurePicker.tsx.html +0 -435
- package/coverage/lcov-report/src/Picker/index.html +0 -123
- package/coverage/lcov-report/src/TimePicker/TimePicker.tsx.html +0 -270
- package/coverage/lcov-report/src/TimePicker/TimePickerToolbar.tsx.html +0 -609
- package/coverage/lcov-report/src/TimePicker/index.html +0 -110
- package/coverage/lcov-report/src/_helpers/date-utils.ts.html +0 -345
- package/coverage/lcov-report/src/_helpers/index.html +0 -136
- package/coverage/lcov-report/src/_helpers/text-field-helper.ts.html +0 -564
- package/coverage/lcov-report/src/_helpers/time-utils.ts.html +0 -318
- package/coverage/lcov-report/src/_helpers/utils.ts.html +0 -93
- package/coverage/lcov-report/src/_shared/KeyboardDateInput.tsx.html +0 -438
- package/coverage/lcov-report/src/_shared/ModalDialog.tsx.html +0 -411
- package/coverage/lcov-report/src/_shared/PickerToolbar.tsx.html +0 -225
- package/coverage/lcov-report/src/_shared/PureDateInput.tsx.html +0 -204
- package/coverage/lcov-report/src/_shared/ToolbarButton.tsx.html +0 -258
- package/coverage/lcov-report/src/_shared/ToolbarText.tsx.html +0 -216
- package/coverage/lcov-report/src/_shared/WithUtils.tsx.html +0 -126
- package/coverage/lcov-report/src/_shared/hooks/index.html +0 -175
- package/coverage/lcov-report/src/_shared/hooks/useIsLandscape.tsx.html +0 -150
- package/coverage/lcov-report/src/_shared/hooks/useKeyDown.ts.html +0 -171
- package/coverage/lcov-report/src/_shared/hooks/useKeyboardPickerState.ts.html +0 -285
- package/coverage/lcov-report/src/_shared/hooks/useOpenState.ts.html +0 -135
- package/coverage/lcov-report/src/_shared/hooks/usePickerState.ts.html +0 -474
- package/coverage/lcov-report/src/_shared/hooks/useUtils.ts.html +0 -129
- package/coverage/lcov-report/src/_shared/hooks/useViews.tsx.html +0 -162
- package/coverage/lcov-report/src/_shared/icons/ArrowLeftIcon.tsx.html +0 -102
- package/coverage/lcov-report/src/_shared/icons/ArrowRightIcon.tsx.html +0 -102
- package/coverage/lcov-report/src/_shared/icons/DateRangeIcon.tsx.html +0 -102
- package/coverage/lcov-report/src/_shared/icons/KeyboardIcon.tsx.html +0 -102
- package/coverage/lcov-report/src/_shared/icons/TimeIcon.tsx.html +0 -105
- package/coverage/lcov-report/src/_shared/icons/index.html +0 -149
- package/coverage/lcov-report/src/_shared/index.html +0 -175
- package/coverage/lcov-report/src/constants/ClockType.ts.html +0 -102
- package/coverage/lcov-report/src/constants/dimensions.ts.html +0 -84
- package/coverage/lcov-report/src/constants/index.html +0 -123
- package/coverage/lcov-report/src/constants/prop-types.ts.html +0 -180
- package/coverage/lcov-report/src/index.html +0 -97
- package/coverage/lcov-report/src/views/Calendar/Calendar.tsx.html +0 -1149
- package/coverage/lcov-report/src/views/Calendar/CalendarHeader.tsx.html +0 -492
- package/coverage/lcov-report/src/views/Calendar/Day.tsx.html +0 -360
- package/coverage/lcov-report/src/views/Calendar/DayWrapper.tsx.html +0 -168
- package/coverage/lcov-report/src/views/Calendar/SlideTransition.tsx.html +0 -369
- package/coverage/lcov-report/src/views/Calendar/index.html +0 -149
- package/coverage/lcov-report/src/views/Clock/Clock.tsx.html +0 -585
- package/coverage/lcov-report/src/views/Clock/ClockNumber.tsx.html +0 -342
- package/coverage/lcov-report/src/views/Clock/ClockNumbers.tsx.html +0 -297
- package/coverage/lcov-report/src/views/Clock/ClockPointer.tsx.html +0 -381
- package/coverage/lcov-report/src/views/Clock/ClockView.tsx.html +0 -384
- package/coverage/lcov-report/src/views/Clock/index.html +0 -149
- package/coverage/lcov-report/src/views/Month/Month.tsx.html +0 -297
- package/coverage/lcov-report/src/views/Month/MonthView.tsx.html +0 -351
- package/coverage/lcov-report/src/views/Month/index.html +0 -110
- package/coverage/lcov-report/src/views/Year/Year.tsx.html +0 -300
- package/coverage/lcov-report/src/views/Year/YearView.tsx.html +0 -342
- package/coverage/lcov-report/src/views/Year/index.html +0 -110
- package/coverage/lcov-report/src/wrappers/InlineWrapper.tsx.html +0 -309
- package/coverage/lcov-report/src/wrappers/ModalWrapper.tsx.html +0 -408
- package/coverage/lcov-report/src/wrappers/StaticWrapper.tsx.html +0 -135
- package/coverage/lcov-report/src/wrappers/Wrapper.tsx.html +0 -294
- package/coverage/lcov-report/src/wrappers/index.html +0 -136
- package/coverage/lcov.info +0 -2815
- package/remove-prop-types.js +0 -37
- package/rollup.config.js +0 -143
- package/src/DatePicker/DatePicker.tsx +0 -91
- package/src/DatePicker/DatePickerToolbar.tsx +0 -75
- package/src/DatePicker/index.ts +0 -7
- package/src/DateTimePicker/DateTimePicker.tsx +0 -72
- package/src/DateTimePicker/DateTimePickerTabs.tsx +0 -86
- package/src/DateTimePicker/DateTimePickerToolbar.tsx +0 -123
- package/src/DateTimePicker/index.ts +0 -7
- package/src/MuiPickersUtilsProvider.tsx +0 -39
- package/src/Picker/Picker.tsx +0 -268
- package/src/Picker/WrappedKeyboardPicker.tsx +0 -132
- package/src/Picker/WrappedPurePicker.tsx +0 -124
- package/src/TimePicker/TimePicker.tsx +0 -67
- package/src/TimePicker/TimePickerToolbar.tsx +0 -180
- package/src/TimePicker/index.tsx +0 -7
- package/src/__tests__/DatePicker/Calendar.test.tsx +0 -51
- package/src/__tests__/DatePicker/Month.test.tsx +0 -36
- package/src/__tests__/DatePicker/MonthSelection.test.tsx +0 -37
- package/src/__tests__/MuiPickersUtilsProvider.test.tsx +0 -21
- package/src/__tests__/TimePicker/Clock.test.tsx +0 -68
- package/src/__tests__/_helpers/date-utils.test.tsx +0 -197
- package/src/__tests__/_helpers/text-field-helper.test.tsx +0 -34
- package/src/__tests__/_shared/ModalDialog.test.tsx +0 -109
- package/src/__tests__/e2e/DatePicker.test.tsx +0 -233
- package/src/__tests__/e2e/DatePickerProps.test.tsx +0 -18
- package/src/__tests__/e2e/DatePickerRoot.test.tsx +0 -154
- package/src/__tests__/e2e/DateTimePicker.test.tsx +0 -86
- package/src/__tests__/e2e/DateTimePickerRoot.test.tsx +0 -72
- package/src/__tests__/e2e/KeyboardDatePicker.test.tsx +0 -140
- package/src/__tests__/e2e/KeyboardDateTimePicker.test.tsx +0 -48
- package/src/__tests__/e2e/Theme.test.tsx +0 -30
- package/src/__tests__/e2e/TimePicker.test.tsx +0 -121
- package/src/__tests__/e2e/commands.tsx +0 -8
- package/src/__tests__/setup.js +0 -26
- package/src/__tests__/test-utils.tsx +0 -45
- package/src/__tests__/tsconfig.json +0 -5
- package/src/_helpers/date-utils.ts +0 -92
- package/src/_helpers/text-field-helper.ts +0 -165
- package/src/_helpers/time-utils.ts +0 -83
- package/src/_helpers/utils.ts +0 -8
- package/src/_shared/KeyboardDateInput.tsx +0 -123
- package/src/_shared/ModalDialog.tsx +0 -114
- package/src/_shared/PickerToolbar.tsx +0 -52
- package/src/_shared/PureDateInput.tsx +0 -45
- package/src/_shared/ToolbarButton.tsx +0 -63
- package/src/_shared/ToolbarText.tsx +0 -49
- package/src/_shared/WithUtils.tsx +0 -19
- package/src/_shared/hooks/useIsLandscape.tsx +0 -27
- package/src/_shared/hooks/useKeyDown.ts +0 -34
- package/src/_shared/hooks/useKeyboardPickerState.ts +0 -72
- package/src/_shared/hooks/useOpenState.ts +0 -22
- package/src/_shared/hooks/usePickerState.ts +0 -135
- package/src/_shared/hooks/useUtils.ts +0 -20
- package/src/_shared/hooks/useViews.tsx +0 -31
- package/src/_shared/icons/ArrowLeftIcon.tsx +0 -11
- package/src/_shared/icons/ArrowRightIcon.tsx +0 -11
- package/src/_shared/icons/DateRangeIcon.tsx +0 -11
- package/src/_shared/icons/KeyboardIcon.tsx +0 -11
- package/src/_shared/icons/TimeIcon.tsx +0 -12
- package/src/constants/ClockType.ts +0 -11
- package/src/constants/dimensions.ts +0 -5
- package/src/constants/prop-types.ts +0 -37
- package/src/index.ts +0 -48
- package/src/typings/BasePicker.tsx +0 -58
- package/src/typings/date.ts +0 -3
- package/src/typings/extendMui.ts +0 -10
- package/src/typings/overrides.ts +0 -54
- package/src/views/Calendar/Calendar.tsx +0 -360
- package/src/views/Calendar/CalendarHeader.tsx +0 -141
- package/src/views/Calendar/Day.tsx +0 -97
- package/src/views/Calendar/DayWrapper.tsx +0 -33
- package/src/views/Calendar/SlideTransition.tsx +0 -100
- package/src/views/Clock/Clock.tsx +0 -172
- package/src/views/Clock/ClockNumber.tsx +0 -91
- package/src/views/Clock/ClockNumbers.tsx +0 -76
- package/src/views/Clock/ClockPointer.tsx +0 -104
- package/src/views/Clock/ClockView.tsx +0 -105
- package/src/views/Month/Month.tsx +0 -76
- package/src/views/Month/MonthView.tsx +0 -94
- package/src/views/Year/Year.tsx +0 -77
- package/src/views/Year/YearView.tsx +0 -91
- package/src/wrappers/InlineWrapper.tsx +0 -80
- package/src/wrappers/ModalWrapper.tsx +0 -113
- package/src/wrappers/StaticWrapper.tsx +0 -22
- package/src/wrappers/Wrapper.tsx +0 -75
- package/tsconfig.json +0 -21
- package/typings.d.ts +0 -6
- /package/{build/DatePicker → DatePicker}/DatePickerToolbar.d.ts +0 -0
- /package/{build/DatePicker → DatePicker}/index.d.ts +0 -0
- /package/{build/DatePicker → DatePicker}/index.js +0 -0
- /package/{build/DateTimePicker → DateTimePicker}/DateTimePickerTabs.d.ts +0 -0
- /package/{build/DateTimePicker → DateTimePicker}/DateTimePickerTabs.js +0 -0
- /package/{build/DateTimePicker → DateTimePicker}/DateTimePickerToolbar.d.ts +0 -0
- /package/{build/DateTimePicker → DateTimePicker}/index.d.ts +0 -0
- /package/{build/DateTimePicker → DateTimePicker}/index.js +0 -0
- /package/{build/Picker → Picker}/WrappedKeyboardPicker.d.ts +0 -0
- /package/{build/Picker → Picker}/WrappedPurePicker.d.ts +0 -0
- /package/{build/TimePicker → TimePicker}/TimePickerToolbar.d.ts +0 -0
- /package/{build/TimePicker → TimePicker}/index.d.ts +0 -0
- /package/{build/TimePicker → TimePicker}/index.js +0 -0
- /package/{build/_helpers → _helpers}/time-utils.js +0 -0
- /package/{build/_helpers → _helpers}/utils.d.ts +0 -0
- /package/{build/_helpers → _helpers}/utils.js +0 -0
- /package/{build/_shared → _shared}/ModalDialog.js +0 -0
- /package/{build/_shared → _shared}/PickerToolbar.d.ts +0 -0
- /package/{build/_shared → _shared}/PickerToolbar.js +0 -0
- /package/{build/_shared → _shared}/PureDateInput.d.ts +0 -0
- /package/{build/_shared → _shared}/ToolbarButton.js +0 -0
- /package/{build/_shared → _shared}/ToolbarText.d.ts +0 -0
- /package/{build/_shared → _shared}/ToolbarText.js +0 -0
- /package/{build/_shared → _shared}/WithUtils.js +0 -0
- /package/{build/_shared → _shared}/hooks/useIsLandscape.d.ts +0 -0
- /package/{build/_shared → _shared}/hooks/useKeyDown.d.ts +0 -0
- /package/{build/_shared → _shared}/hooks/useKeyDown.js +0 -0
- /package/{build/_shared → _shared}/hooks/useOpenState.d.ts +0 -0
- /package/{build/_shared → _shared}/hooks/useOpenState.js +0 -0
- /package/{build/_shared → _shared}/hooks/useUtils.js +0 -0
- /package/{build/_shared → _shared}/hooks/useViews.d.ts +0 -0
- /package/{build/_shared → _shared}/hooks/useViews.js +0 -0
- /package/{build/_shared → _shared}/icons/ArrowLeftIcon.d.ts +0 -0
- /package/{build/_shared → _shared}/icons/ArrowLeftIcon.js +0 -0
- /package/{build/_shared → _shared}/icons/ArrowRightIcon.d.ts +0 -0
- /package/{build/_shared → _shared}/icons/ArrowRightIcon.js +0 -0
- /package/{build/_shared → _shared}/icons/DateRangeIcon.d.ts +0 -0
- /package/{build/_shared → _shared}/icons/DateRangeIcon.js +0 -0
- /package/{build/_shared → _shared}/icons/KeyboardIcon.d.ts +0 -0
- /package/{build/_shared → _shared}/icons/KeyboardIcon.js +0 -0
- /package/{build/_shared → _shared}/icons/TimeIcon.d.ts +0 -0
- /package/{build/_shared → _shared}/icons/TimeIcon.js +0 -0
- /package/{build/constants → constants}/ClockType.d.ts +0 -0
- /package/{build/constants → constants}/ClockType.js +0 -0
- /package/{build/constants → constants}/dimensions.d.ts +0 -0
- /package/{build/constants → constants}/dimensions.js +0 -0
- /package/{build/constants → constants}/prop-types.d.ts +0 -0
- /package/{build/index.js → index.js} +0 -0
- /package/{build/typings → typings}/BasePicker.js +0 -0
- /package/{build/typings → typings}/date.d.ts +0 -0
- /package/{build/typings → typings}/date.js +0 -0
- /package/{build/typings → typings}/extendMui.d.ts +0 -0
- /package/{build/typings → typings}/extendMui.js +0 -0
- /package/{build/typings → typings}/overrides.js +0 -0
- /package/{build/views → views}/Calendar/Calendar.d.ts +0 -0
- /package/{build/views → views}/Calendar/CalendarHeader.d.ts +0 -0
- /package/{build/views → views}/Calendar/Day.d.ts +0 -0
- /package/{build/views → views}/Calendar/Day.js +0 -0
- /package/{build/views → views}/Calendar/DayWrapper.d.ts +0 -0
- /package/{build/views → views}/Calendar/DayWrapper.js +0 -0
- /package/{build/views → views}/Calendar/SlideTransition.d.ts +0 -0
- /package/{build/views → views}/Calendar/SlideTransition.js +0 -0
- /package/{build/views → views}/Clock/ClockNumber.d.ts +0 -0
- /package/{build/views → views}/Clock/ClockNumber.js +0 -0
- /package/{build/views → views}/Clock/ClockNumbers.js +0 -0
- /package/{build/views → views}/Clock/ClockPointer.js +0 -0
- /package/{build/views → views}/Clock/ClockView.d.ts +0 -0
- /package/{build/views → views}/Month/Month.d.ts +0 -0
- /package/{build/views → views}/Month/Month.js +0 -0
- /package/{build/views → views}/Month/MonthView.d.ts +0 -0
- /package/{build/views → views}/Year/Year.d.ts +0 -0
- /package/{build/views → views}/Year/Year.js +0 -0
- /package/{build/views → views}/Year/YearView.d.ts +0 -0
- /package/{build/wrappers → wrappers}/InlineWrapper.d.ts +0 -0
- /package/{build/wrappers → wrappers}/InlineWrapper.js +0 -0
- /package/{build/wrappers → wrappers}/ModalWrapper.d.ts +0 -0
- /package/{build/wrappers → wrappers}/ModalWrapper.js +0 -0
- /package/{build/wrappers → wrappers}/StaticWrapper.d.ts +0 -0
- /package/{build/wrappers → wrappers}/StaticWrapper.js +0 -0
- /package/{build/wrappers → wrappers}/Wrapper.d.ts +0 -0
- /package/{build/wrappers → wrappers}/Wrapper.js +0 -0
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import ClockType from '../constants/ClockType';
|
|
4
|
-
import ToolbarText from '../_shared/ToolbarText';
|
|
5
|
-
import ToolbarButton from '../_shared/ToolbarButton';
|
|
6
|
-
import PickerToolbar from '../_shared/PickerToolbar';
|
|
7
|
-
import { arrayIncludes } from '../_helpers/utils';
|
|
8
|
-
import { useUtils } from '../_shared/hooks/useUtils';
|
|
9
|
-
import { MaterialUiPickersDate } from '../typings/date';
|
|
10
|
-
import { ToolbarComponentProps } from '../Picker/Picker';
|
|
11
|
-
import { useTheme, makeStyles } from '@material-ui/core/styles';
|
|
12
|
-
import { convertToMeridiem, getMeridiem } from '../_helpers/time-utils';
|
|
13
|
-
|
|
14
|
-
export const useStyles = makeStyles(
|
|
15
|
-
{
|
|
16
|
-
toolbarLandscape: {
|
|
17
|
-
flexWrap: 'wrap',
|
|
18
|
-
},
|
|
19
|
-
toolbarAmpmLeftPadding: {
|
|
20
|
-
paddingLeft: 50,
|
|
21
|
-
},
|
|
22
|
-
separator: {
|
|
23
|
-
margin: '0 4px 0 2px',
|
|
24
|
-
cursor: 'default',
|
|
25
|
-
},
|
|
26
|
-
hourMinuteLabel: {
|
|
27
|
-
display: 'flex',
|
|
28
|
-
justifyContent: 'flex-end',
|
|
29
|
-
alignItems: 'flex-end',
|
|
30
|
-
},
|
|
31
|
-
hourMinuteLabelLandscape: {
|
|
32
|
-
marginTop: 'auto',
|
|
33
|
-
},
|
|
34
|
-
hourMinuteLabelReverse: {
|
|
35
|
-
flexDirection: 'row-reverse',
|
|
36
|
-
},
|
|
37
|
-
ampmSelection: {
|
|
38
|
-
marginLeft: 20,
|
|
39
|
-
marginRight: -20,
|
|
40
|
-
display: 'flex',
|
|
41
|
-
flexDirection: 'column',
|
|
42
|
-
},
|
|
43
|
-
ampmLandscape: {
|
|
44
|
-
margin: '4px 0 auto',
|
|
45
|
-
flexDirection: 'row',
|
|
46
|
-
justifyContent: 'space-around',
|
|
47
|
-
flexBasis: '100%',
|
|
48
|
-
},
|
|
49
|
-
ampmSelectionWithSeconds: {
|
|
50
|
-
marginLeft: 15,
|
|
51
|
-
marginRight: 10,
|
|
52
|
-
},
|
|
53
|
-
ampmLabel: {
|
|
54
|
-
fontSize: 18,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
{ name: 'MuiPickersTimePickerToolbar' }
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
export function useMeridiemMode(
|
|
61
|
-
date: MaterialUiPickersDate,
|
|
62
|
-
ampm: boolean | undefined,
|
|
63
|
-
onChange: (date: MaterialUiPickersDate, isFinished?: boolean | undefined) => void
|
|
64
|
-
) {
|
|
65
|
-
const utils = useUtils();
|
|
66
|
-
const meridiemMode = getMeridiem(date, utils);
|
|
67
|
-
|
|
68
|
-
const handleMeridiemChange = React.useCallback(
|
|
69
|
-
(mode: 'am' | 'pm') => {
|
|
70
|
-
const timeWithMeridiem = convertToMeridiem(date, mode, Boolean(ampm), utils);
|
|
71
|
-
onChange(timeWithMeridiem, false);
|
|
72
|
-
},
|
|
73
|
-
[ampm, date, onChange, utils]
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return { meridiemMode, handleMeridiemChange };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const TimePickerToolbar: React.FC<ToolbarComponentProps> = ({
|
|
80
|
-
date,
|
|
81
|
-
views,
|
|
82
|
-
ampm,
|
|
83
|
-
openView,
|
|
84
|
-
onChange,
|
|
85
|
-
isLandscape,
|
|
86
|
-
setOpenView,
|
|
87
|
-
}) => {
|
|
88
|
-
const utils = useUtils();
|
|
89
|
-
const theme = useTheme();
|
|
90
|
-
const classes = useStyles();
|
|
91
|
-
const { meridiemMode, handleMeridiemChange } = useMeridiemMode(date, ampm, onChange);
|
|
92
|
-
|
|
93
|
-
const clockTypographyVariant = isLandscape ? 'h3' : 'h2';
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<PickerToolbar
|
|
97
|
-
isLandscape={isLandscape}
|
|
98
|
-
className={clsx({
|
|
99
|
-
[classes.toolbarLandscape]: isLandscape,
|
|
100
|
-
[classes.toolbarAmpmLeftPadding]: ampm && !isLandscape,
|
|
101
|
-
})}
|
|
102
|
-
>
|
|
103
|
-
<div
|
|
104
|
-
className={clsx(classes.hourMinuteLabel, {
|
|
105
|
-
[classes.hourMinuteLabelLandscape]: isLandscape,
|
|
106
|
-
[classes.hourMinuteLabelReverse]: theme.direction === 'rtl',
|
|
107
|
-
})}
|
|
108
|
-
>
|
|
109
|
-
{arrayIncludes(views, 'hours') && (
|
|
110
|
-
<ToolbarButton
|
|
111
|
-
variant={clockTypographyVariant}
|
|
112
|
-
onClick={() => setOpenView(ClockType.HOURS)}
|
|
113
|
-
selected={openView === ClockType.HOURS}
|
|
114
|
-
label={utils.getHourText(date, Boolean(ampm))}
|
|
115
|
-
/>
|
|
116
|
-
)}
|
|
117
|
-
|
|
118
|
-
{arrayIncludes(views, ['hours', 'minutes']) && (
|
|
119
|
-
<ToolbarText
|
|
120
|
-
label=":"
|
|
121
|
-
variant={clockTypographyVariant}
|
|
122
|
-
selected={false}
|
|
123
|
-
className={classes.separator}
|
|
124
|
-
/>
|
|
125
|
-
)}
|
|
126
|
-
|
|
127
|
-
{arrayIncludes(views, 'minutes') && (
|
|
128
|
-
<ToolbarButton
|
|
129
|
-
variant={clockTypographyVariant}
|
|
130
|
-
onClick={() => setOpenView(ClockType.MINUTES)}
|
|
131
|
-
selected={openView === ClockType.MINUTES}
|
|
132
|
-
label={utils.getMinuteText(date)}
|
|
133
|
-
/>
|
|
134
|
-
)}
|
|
135
|
-
|
|
136
|
-
{arrayIncludes(views, ['minutes', 'seconds']) && (
|
|
137
|
-
<ToolbarText variant="h2" label=":" selected={false} className={classes.separator} />
|
|
138
|
-
)}
|
|
139
|
-
|
|
140
|
-
{arrayIncludes(views, 'seconds') && (
|
|
141
|
-
<ToolbarButton
|
|
142
|
-
variant="h2"
|
|
143
|
-
onClick={() => setOpenView(ClockType.SECONDS)}
|
|
144
|
-
selected={openView === ClockType.SECONDS}
|
|
145
|
-
label={utils.getSecondText(date)}
|
|
146
|
-
/>
|
|
147
|
-
)}
|
|
148
|
-
</div>
|
|
149
|
-
|
|
150
|
-
{ampm && (
|
|
151
|
-
<div
|
|
152
|
-
className={clsx(classes.ampmSelection, {
|
|
153
|
-
[classes.ampmLandscape]: isLandscape,
|
|
154
|
-
[classes.ampmSelectionWithSeconds]: arrayIncludes(views, 'seconds'),
|
|
155
|
-
})}
|
|
156
|
-
>
|
|
157
|
-
<ToolbarButton
|
|
158
|
-
disableRipple
|
|
159
|
-
variant="subtitle1"
|
|
160
|
-
selected={meridiemMode === 'am'}
|
|
161
|
-
typographyClassName={classes.ampmLabel}
|
|
162
|
-
label={utils.getMeridiemText('am')}
|
|
163
|
-
onClick={() => handleMeridiemChange('am')}
|
|
164
|
-
/>
|
|
165
|
-
|
|
166
|
-
<ToolbarButton
|
|
167
|
-
disableRipple
|
|
168
|
-
variant="subtitle1"
|
|
169
|
-
selected={meridiemMode === 'pm'}
|
|
170
|
-
typographyClassName={classes.ampmLabel}
|
|
171
|
-
label={utils.getMeridiemText('pm')}
|
|
172
|
-
onClick={() => handleMeridiemChange('pm')}
|
|
173
|
-
/>
|
|
174
|
-
</div>
|
|
175
|
-
)}
|
|
176
|
-
</PickerToolbar>
|
|
177
|
-
);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default TimePickerToolbar;
|
package/src/TimePicker/index.tsx
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ShallowWrapper } from 'enzyme';
|
|
3
|
-
import { shallowRender, utilsToUse } from '../test-utils';
|
|
4
|
-
import { Calendar, CalendarProps } from '../../views/Calendar/Calendar';
|
|
5
|
-
|
|
6
|
-
describe('Calendar', () => {
|
|
7
|
-
let component: ShallowWrapper<CalendarProps>;
|
|
8
|
-
const onChangeMock = jest.fn();
|
|
9
|
-
const onMonthChangeMock = jest.fn();
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
component = shallowRender(props => (
|
|
13
|
-
<Calendar
|
|
14
|
-
date={utilsToUse.date('01-01-2017')}
|
|
15
|
-
onMonthChange={onMonthChangeMock}
|
|
16
|
-
onChange={onChangeMock}
|
|
17
|
-
{...props}
|
|
18
|
-
/>
|
|
19
|
-
));
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('Should swipe between month', () => {
|
|
23
|
-
component.find('CalendarHeader').prop<any>('onMonthChange')(utilsToUse.date());
|
|
24
|
-
expect(onMonthChangeMock).toHaveBeenCalled();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('Calendar - disabled selected date on mount', () => {
|
|
29
|
-
let component: ShallowWrapper<any, any, any>;
|
|
30
|
-
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
component = shallowRender(props => (
|
|
33
|
-
<Calendar
|
|
34
|
-
date={utilsToUse.date('01-01-2017')}
|
|
35
|
-
minDate={new Date('01-01-2018')}
|
|
36
|
-
onChange={jest.fn()}
|
|
37
|
-
utils={utilsToUse}
|
|
38
|
-
{...props}
|
|
39
|
-
/>
|
|
40
|
-
));
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('Should dispatch onDateSelect with isFinish = false on mount', () => {
|
|
44
|
-
const { onChange } = component.instance().props;
|
|
45
|
-
if (process.env.UTILS === 'moment') {
|
|
46
|
-
return expect(onChange).toHaveBeenCalled();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
expect(onChange).toHaveBeenCalledWith(utilsToUse.date('01-01-2018'), false);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ShallowWrapper } from 'enzyme';
|
|
3
|
-
import { shallow, utilsToUse } from '../test-utils';
|
|
4
|
-
import { Month, MonthProps } from '../../views/Month/Month';
|
|
5
|
-
|
|
6
|
-
describe('Month', () => {
|
|
7
|
-
let component: ShallowWrapper<MonthProps>;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
component = shallow(
|
|
11
|
-
<Month value={utilsToUse.date('01-01-2017')} onSelect={jest.fn()}>
|
|
12
|
-
Oct
|
|
13
|
-
</Month>
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('Should render', () => {
|
|
18
|
-
expect(component).toBeTruthy();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('Month - disabled state', () => {
|
|
23
|
-
let component: ShallowWrapper<MonthProps>;
|
|
24
|
-
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
component = shallow(
|
|
27
|
-
<Month disabled value={utilsToUse.date('01-01-2017')} onSelect={jest.fn()}>
|
|
28
|
-
Oct
|
|
29
|
-
</Month>
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('Should render in disabled state', () => {
|
|
34
|
-
expect(component.prop('tabIndex')).toBe(-1);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import Month from '../../views/Month/Month';
|
|
3
|
-
import { ReactWrapper } from 'enzyme';
|
|
4
|
-
import { mount, utilsToUse } from '../test-utils';
|
|
5
|
-
import { MonthSelection, MonthSelectionProps } from '../../views/Month/MonthView';
|
|
6
|
-
|
|
7
|
-
describe('MonthSelection', () => {
|
|
8
|
-
let component: ReactWrapper<MonthSelectionProps>;
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
component = mount(
|
|
12
|
-
<MonthSelection
|
|
13
|
-
minDate={new Date('03-01-2017')}
|
|
14
|
-
maxDate={new Date('05-01-2017')}
|
|
15
|
-
date={utilsToUse.date('04-01-2017')}
|
|
16
|
-
onChange={jest.fn()}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('Should render disabled months before min date and after max date', () => {
|
|
22
|
-
expect(component.find(Month).map(month => month.prop('disabled'))).toEqual([
|
|
23
|
-
true,
|
|
24
|
-
true,
|
|
25
|
-
false,
|
|
26
|
-
false,
|
|
27
|
-
false,
|
|
28
|
-
true,
|
|
29
|
-
true,
|
|
30
|
-
true,
|
|
31
|
-
true,
|
|
32
|
-
true,
|
|
33
|
-
true,
|
|
34
|
-
true,
|
|
35
|
-
]);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// required to use just shallow here because utils prop override
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import DateFnsUtils from '@date-io/date-fns';
|
|
4
|
-
import MuiPickersUtilsProvider, { MuiPickersUtilsProviderProps } from '../MuiPickersUtilsProvider';
|
|
5
|
-
import { shallow, ShallowWrapper } from 'enzyme'; // required to use just shallow here because utils prop override
|
|
6
|
-
|
|
7
|
-
describe('MuiPickersUtilsProvider', () => {
|
|
8
|
-
let component: ShallowWrapper<MuiPickersUtilsProviderProps>;
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
component = shallow(
|
|
12
|
-
<MuiPickersUtilsProvider utils={DateFnsUtils}>
|
|
13
|
-
<div />
|
|
14
|
-
</MuiPickersUtilsProvider>
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('Should render context provider', () => {
|
|
19
|
-
expect(component).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ShallowWrapper } from 'enzyme';
|
|
3
|
-
import { shallow } from '../test-utils';
|
|
4
|
-
import { Clock, ClockProps } from '../../views/Clock/Clock';
|
|
5
|
-
|
|
6
|
-
const mouseClockEvent = {
|
|
7
|
-
preventDefault: jest.fn(),
|
|
8
|
-
stopPropagation: jest.fn(),
|
|
9
|
-
buttons: 1,
|
|
10
|
-
nativeEvent: {
|
|
11
|
-
offsetX: 10,
|
|
12
|
-
offsetY: 25,
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
describe('Clock', () => {
|
|
17
|
-
let component: ShallowWrapper<ClockProps>;
|
|
18
|
-
const onChangeMock = jest.fn();
|
|
19
|
-
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
onChangeMock.mockReset();
|
|
22
|
-
component = shallow(
|
|
23
|
-
<Clock
|
|
24
|
-
type="minutes"
|
|
25
|
-
onChange={onChangeMock}
|
|
26
|
-
classes={{} as any}
|
|
27
|
-
value={12}
|
|
28
|
-
children={[<div key="foo">foo</div>]}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('Should renders', () => {
|
|
34
|
-
// console.log(component.debug());
|
|
35
|
-
expect(component).toBeTruthy();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('Should set time on mouse move with click', () => {
|
|
39
|
-
component.find('[role="menu"]').simulate('mouseMove', mouseClockEvent);
|
|
40
|
-
|
|
41
|
-
expect(onChangeMock).toHaveBeenCalledWith(52, false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('Should set isMoving = false on mouse up', () => {
|
|
45
|
-
(component.instance() as Clock).isMoving = true;
|
|
46
|
-
component.find('[role="menu"]').simulate('mouseUp', mouseClockEvent);
|
|
47
|
-
|
|
48
|
-
expect((component.instance() as Clock).isMoving).toBeFalsy();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('Should set time on touch move', () => {
|
|
52
|
-
component.find('[role="menu"]').simulate('touchMove', {
|
|
53
|
-
preventDefault: jest.fn(),
|
|
54
|
-
stopPropagation: jest.fn(),
|
|
55
|
-
changedTouches: [{ clientX: 10, clientY: 15 }],
|
|
56
|
-
target: {
|
|
57
|
-
getBoundingClientRect: () => ({ left: 0, top: 0 }),
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
expect(onChangeMock).toHaveBeenCalledWith(52, false);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('Should set isMoving = false on touch end', () => {
|
|
65
|
-
component.find('[role="menu"]').simulate('touchEnd');
|
|
66
|
-
expect((component.instance() as Clock).isMoving).toBeFalsy();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { utilsToUse } from '../test-utils';
|
|
2
|
-
import { findClosestEnabledDate } from '../../_helpers/date-utils';
|
|
3
|
-
|
|
4
|
-
describe('findClosestEnabledDate', () => {
|
|
5
|
-
const day18thText = utilsToUse.getDayText(utilsToUse.date('2018-08-18'));
|
|
6
|
-
const only18th = (date: any) => utilsToUse.getDayText(date) !== day18thText;
|
|
7
|
-
|
|
8
|
-
it('Should return null if all dates are disabled', () => {
|
|
9
|
-
const result = findClosestEnabledDate({
|
|
10
|
-
date: utilsToUse.date('2000-01-01'),
|
|
11
|
-
minDate: utilsToUse.date('1999-01-01'), // Use close-by min/max dates to reduce the test runtime.
|
|
12
|
-
maxDate: utilsToUse.date('2001-01-01'),
|
|
13
|
-
utils: utilsToUse,
|
|
14
|
-
shouldDisableDate: () => true,
|
|
15
|
-
disableFuture: false,
|
|
16
|
-
disablePast: false,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
expect(result).toBe(null);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('Should return given date if it is enabled', () => {
|
|
23
|
-
const result = findClosestEnabledDate({
|
|
24
|
-
date: utilsToUse.date('2000-01-01'),
|
|
25
|
-
minDate: utilsToUse.date('1900-01-01'),
|
|
26
|
-
maxDate: utilsToUse.date('2100-01-01'),
|
|
27
|
-
utils: utilsToUse,
|
|
28
|
-
shouldDisableDate: () => false,
|
|
29
|
-
disableFuture: false,
|
|
30
|
-
disablePast: false,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
expect(utilsToUse.isSameDay(result, utilsToUse.date('2000-01-01'))).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('Should return next 18th going from 10th', () => {
|
|
37
|
-
const result = findClosestEnabledDate({
|
|
38
|
-
date: utilsToUse.date('2018-08-10'),
|
|
39
|
-
minDate: utilsToUse.date('1900-01-01'),
|
|
40
|
-
maxDate: utilsToUse.date('2100-01-01'),
|
|
41
|
-
utils: utilsToUse,
|
|
42
|
-
shouldDisableDate: only18th,
|
|
43
|
-
disableFuture: false,
|
|
44
|
-
disablePast: false,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-08-18'))).toBe(true);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('Should return previous 18th going from 1st', () => {
|
|
51
|
-
const result = findClosestEnabledDate({
|
|
52
|
-
date: utilsToUse.date('2018-08-01'),
|
|
53
|
-
minDate: utilsToUse.date('1900-01-01'),
|
|
54
|
-
maxDate: utilsToUse.date('2100-01-01'),
|
|
55
|
-
utils: utilsToUse,
|
|
56
|
-
shouldDisableDate: only18th,
|
|
57
|
-
disableFuture: false,
|
|
58
|
-
disablePast: false,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-07-18'))).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('Should return future 18th if disablePast', () => {
|
|
65
|
-
const today = utilsToUse.startOfDay(utilsToUse.date());
|
|
66
|
-
const result = findClosestEnabledDate({
|
|
67
|
-
date: utilsToUse.date('2000-01-01'),
|
|
68
|
-
minDate: utilsToUse.date('1900-01-01'),
|
|
69
|
-
maxDate: utilsToUse.date('2100-01-01'),
|
|
70
|
-
utils: utilsToUse,
|
|
71
|
-
shouldDisableDate: only18th,
|
|
72
|
-
disableFuture: false,
|
|
73
|
-
disablePast: true,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
expect(utilsToUse.getDayText(result)).toBe(day18thText);
|
|
77
|
-
expect(utilsToUse.isBefore(result, today)).toBe(false);
|
|
78
|
-
expect(utilsToUse.isBefore(result, utilsToUse.addDays(today, 31))).toBe(true);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('Should return past Saturday if disableFuture', () => {
|
|
82
|
-
const today = utilsToUse.startOfDay(utilsToUse.date());
|
|
83
|
-
const result = findClosestEnabledDate({
|
|
84
|
-
date: utilsToUse.date('2099-01-01'),
|
|
85
|
-
minDate: utilsToUse.date('1900-01-01'),
|
|
86
|
-
maxDate: utilsToUse.date('2100-01-01'),
|
|
87
|
-
utils: utilsToUse,
|
|
88
|
-
shouldDisableDate: only18th,
|
|
89
|
-
disableFuture: true,
|
|
90
|
-
disablePast: false,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
expect(utilsToUse.isBeforeDay(result, today)).toBe(true);
|
|
94
|
-
expect(utilsToUse.getDayText(result)).toBe(day18thText);
|
|
95
|
-
expect(utilsToUse.isBefore(result, utilsToUse.addDays(today, -31))).toBe(false);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('Should return now if disablePast+disableFuture and now is valid', () => {
|
|
99
|
-
const today = utilsToUse.startOfDay(utilsToUse.date());
|
|
100
|
-
const result = findClosestEnabledDate({
|
|
101
|
-
date: utilsToUse.date('2000-01-01'),
|
|
102
|
-
minDate: utilsToUse.date('1900-01-01'),
|
|
103
|
-
maxDate: utilsToUse.date('2100-01-01'),
|
|
104
|
-
utils: utilsToUse,
|
|
105
|
-
shouldDisableDate: () => false,
|
|
106
|
-
disableFuture: true,
|
|
107
|
-
disablePast: true,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
expect(utilsToUse.isSameDay(result, today)).toBe(true);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('Should return null if disablePast+disableFuture and now is invalid', () => {
|
|
114
|
-
const today = utilsToUse.date();
|
|
115
|
-
const result = findClosestEnabledDate({
|
|
116
|
-
date: utilsToUse.date('2000-01-01'),
|
|
117
|
-
minDate: utilsToUse.date('1900-01-01'),
|
|
118
|
-
maxDate: utilsToUse.date('2100-01-01'),
|
|
119
|
-
utils: utilsToUse,
|
|
120
|
-
shouldDisableDate: date => utilsToUse.isSameDay(date, today),
|
|
121
|
-
disableFuture: true,
|
|
122
|
-
disablePast: true,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
expect(result).toBeNull();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('Should return minDate if it is after the date and valid', () => {
|
|
129
|
-
const result = findClosestEnabledDate({
|
|
130
|
-
date: utilsToUse.date('2000-01-01'),
|
|
131
|
-
minDate: utilsToUse.date('2018-08-18'),
|
|
132
|
-
maxDate: utilsToUse.date('2100-01-01'),
|
|
133
|
-
utils: utilsToUse,
|
|
134
|
-
shouldDisableDate: only18th,
|
|
135
|
-
disableFuture: false,
|
|
136
|
-
disablePast: false,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-08-18'))).toBe(true);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('Should return next 18th after minDate', () => {
|
|
143
|
-
const result = findClosestEnabledDate({
|
|
144
|
-
date: utilsToUse.date('2000-01-01'),
|
|
145
|
-
minDate: utilsToUse.date('2018-08-01'),
|
|
146
|
-
maxDate: utilsToUse.date('2100-01-01'),
|
|
147
|
-
utils: utilsToUse,
|
|
148
|
-
shouldDisableDate: only18th,
|
|
149
|
-
disableFuture: false,
|
|
150
|
-
disablePast: false,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-08-18'))).toBe(true);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('Should return maxDate if it is before the date and valid', () => {
|
|
157
|
-
const result = findClosestEnabledDate({
|
|
158
|
-
date: utilsToUse.date('2050-01-01'),
|
|
159
|
-
minDate: utilsToUse.date('1900-01-01'),
|
|
160
|
-
maxDate: utilsToUse.date('2018-07-18'),
|
|
161
|
-
utils: utilsToUse,
|
|
162
|
-
shouldDisableDate: only18th,
|
|
163
|
-
disableFuture: false,
|
|
164
|
-
disablePast: false,
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-07-18'))).toBe(true);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('Should return previous 18th before maxDate', () => {
|
|
171
|
-
const result = findClosestEnabledDate({
|
|
172
|
-
date: utilsToUse.date('2050-01-01'),
|
|
173
|
-
minDate: utilsToUse.date('1900-01-01'),
|
|
174
|
-
maxDate: utilsToUse.date('2018-08-17'),
|
|
175
|
-
utils: utilsToUse,
|
|
176
|
-
shouldDisableDate: only18th,
|
|
177
|
-
disableFuture: false,
|
|
178
|
-
disablePast: false,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
expect(utilsToUse.isSameDay(result, utilsToUse.date('2018-07-18'))).toBe(true);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('Should return null if minDate is after maxDate', () => {
|
|
185
|
-
const result = findClosestEnabledDate({
|
|
186
|
-
date: utilsToUse.date('2000-01-01'),
|
|
187
|
-
minDate: utilsToUse.date('2000-01-01'),
|
|
188
|
-
maxDate: utilsToUse.date('1999-01-01'),
|
|
189
|
-
utils: utilsToUse,
|
|
190
|
-
shouldDisableDate: () => false,
|
|
191
|
-
disableFuture: false,
|
|
192
|
-
disablePast: false,
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
expect(result).toBeNull();
|
|
196
|
-
});
|
|
197
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
makeMaskFromFormat,
|
|
3
|
-
maskedDateFormatter,
|
|
4
|
-
pick12hOr24hFormat,
|
|
5
|
-
} from '../../_helpers/text-field-helper';
|
|
6
|
-
|
|
7
|
-
const refuse = /[^\d]+/gi;
|
|
8
|
-
describe('test-field-helper', () => {
|
|
9
|
-
test('maskedDateFormatter', () => {
|
|
10
|
-
const formatterFn = maskedDateFormatter('__/__/____', '_', refuse);
|
|
11
|
-
|
|
12
|
-
expect(formatterFn('21')).toBe('21/__/____');
|
|
13
|
-
expect(formatterFn('21-12-21')).toBe('21/12/21__');
|
|
14
|
-
expect(formatterFn('21-12-2010')).toBe('21/12/2010');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('makeMaskFromFormat', () => {
|
|
18
|
-
expect(makeMaskFromFormat('yyyy-mm-dd', '_')).toBe('____-__-__');
|
|
19
|
-
expect(makeMaskFromFormat('YYYY/LL/DD', '_')).toBe('____/__/__');
|
|
20
|
-
expect(makeMaskFromFormat('yyyy-mm-dd mm:hh', '_')).toBe('____-__-__ __:__');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('pick12hOr24hFormat', () => {
|
|
24
|
-
expect(pick12hOr24hFormat(undefined, true, { '12h': 'hh:mm a', '24h': 'HH:mm' })).toBe(
|
|
25
|
-
'hh:mm a'
|
|
26
|
-
);
|
|
27
|
-
expect(pick12hOr24hFormat(undefined, undefined, { '12h': 'hh:mm a', '24h': 'HH:mm' })).toBe(
|
|
28
|
-
'hh:mm a'
|
|
29
|
-
);
|
|
30
|
-
expect(pick12hOr24hFormat(undefined, false, { '12h': 'hh:mm a', '24h': 'HH:mm' })).toBe(
|
|
31
|
-
'HH:mm'
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
});
|