@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,140 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import addDays from 'date-fns/addDays';
|
|
3
|
-
import { ReactWrapper } from 'enzyme';
|
|
4
|
-
import { mount } from '../test-utils';
|
|
5
|
-
import { KeyboardDatePicker, KeyboardDatePickerProps } from '../../DatePicker/DatePicker';
|
|
6
|
-
|
|
7
|
-
describe('e2e -- DatePicker keyboard input', () => {
|
|
8
|
-
const onChangeMock = jest.fn();
|
|
9
|
-
let component: ReactWrapper<KeyboardDatePickerProps>;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
component = mount(
|
|
13
|
-
<KeyboardDatePicker
|
|
14
|
-
label="Masked input"
|
|
15
|
-
placeholder="10/10/2018"
|
|
16
|
-
format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
|
|
17
|
-
value={new Date('2018-01-01T00:00:00.000Z')}
|
|
18
|
-
onChange={onChangeMock}
|
|
19
|
-
InputAdornmentProps={{
|
|
20
|
-
disableTypography: true,
|
|
21
|
-
}}
|
|
22
|
-
InputLabelProps={{
|
|
23
|
-
htmlFor: 'your-id',
|
|
24
|
-
}}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('Should properly set value on change keyboard', () => {
|
|
30
|
-
const e = { target: { value: '10/11/2018' } };
|
|
31
|
-
|
|
32
|
-
component.find('input').simulate('change', e);
|
|
33
|
-
expect(component.find('input').prop('value')).toBe('10/11/2018');
|
|
34
|
-
|
|
35
|
-
component.find('input').simulate('blur');
|
|
36
|
-
expect(onChangeMock).toBeCalled();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe('e2e -- KeyboardDatePicker validation errors', () => {
|
|
41
|
-
it('Should render error message if date is unparseable', () => {
|
|
42
|
-
const component = mount(
|
|
43
|
-
<KeyboardDatePicker
|
|
44
|
-
format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
|
|
45
|
-
value={new Date(NaN)}
|
|
46
|
-
onChange={jest.fn()}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
expect(component.find('ForwardRef(TextField)').prop('helperText')).toBe('Invalid Date Format');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('Should render error message if date is after disableFuture', () => {
|
|
54
|
-
const component = mount(
|
|
55
|
-
<KeyboardDatePicker
|
|
56
|
-
onChange={jest.fn()}
|
|
57
|
-
disableFuture
|
|
58
|
-
value={addDays(new Date(), 2)}
|
|
59
|
-
format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
expect(component.find('ForwardRef(TextField)').prop('helperText')).toBe(
|
|
64
|
-
'Date should not be after maximal date'
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('Should render error message if date is before disablePast', () => {
|
|
69
|
-
const component = mount(
|
|
70
|
-
<KeyboardDatePicker
|
|
71
|
-
onChange={jest.fn()}
|
|
72
|
-
disablePast
|
|
73
|
-
value={addDays(new Date(), -2)}
|
|
74
|
-
format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
|
|
75
|
-
/>
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
expect(component.find('ForwardRef(TextField)').prop('helperText')).toBe(
|
|
79
|
-
'Date should not be before minimal date'
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('Should not render error message if date is after maxDate without strict comparison', () => {
|
|
84
|
-
const component = mount(
|
|
85
|
-
<KeyboardDatePicker
|
|
86
|
-
onChange={jest.fn()}
|
|
87
|
-
maxDate={new Date('2018-01-01T00:00:00.000Z')}
|
|
88
|
-
value={new Date('2018-01-01T01:00:00.000Z')}
|
|
89
|
-
format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
|
|
90
|
-
/>
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
expect(component.find('ForwardRef(TextField)').prop('helperText')).toBe('');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('Should render error message if date is after maxDate with strict comparison', () => {
|
|
97
|
-
const component = mount(
|
|
98
|
-
<KeyboardDatePicker
|
|
99
|
-
onChange={jest.fn()}
|
|
100
|
-
maxDate={new Date('2018-01-01T00:00:00.000Z')}
|
|
101
|
-
value={new Date('2018-01-01T01:00:00.000Z')}
|
|
102
|
-
strictCompareDates
|
|
103
|
-
format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
|
|
104
|
-
/>
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
expect(component.find('ForwardRef(TextField)').prop('helperText')).toBe(
|
|
108
|
-
'Date should not be after maximal date'
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('Should not render error message if date is after minDate without strict comparison', () => {
|
|
113
|
-
const component = mount(
|
|
114
|
-
<KeyboardDatePicker
|
|
115
|
-
onChange={jest.fn()}
|
|
116
|
-
minDate={new Date('2018-01-01T01:00:00.000Z')}
|
|
117
|
-
value={new Date('2018-01-01T00:00:00.000Z')}
|
|
118
|
-
format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
|
|
119
|
-
/>
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
expect(component.find('ForwardRef(TextField)').prop('helperText')).toBe('');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('Should render error message if date is after minDate with strict comparison', () => {
|
|
126
|
-
const component = mount(
|
|
127
|
-
<KeyboardDatePicker
|
|
128
|
-
onChange={jest.fn()}
|
|
129
|
-
minDate={new Date('2018-01-01T01:00:00.000Z')}
|
|
130
|
-
value={new Date('2018-01-01T00:00:00.000Z')}
|
|
131
|
-
strictCompareDates
|
|
132
|
-
format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
|
|
133
|
-
/>
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
expect(component.find('ForwardRef(TextField)').prop('helperText')).toBe(
|
|
137
|
-
'Date should not be before minimal date'
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ReactWrapper } from 'enzyme';
|
|
3
|
-
import { mount, utilsToUse } from '../test-utils';
|
|
4
|
-
import {
|
|
5
|
-
KeyboardDateTimePicker,
|
|
6
|
-
KeyboardDateTimePickerProps,
|
|
7
|
-
} from '../../DateTimePicker/DateTimePicker';
|
|
8
|
-
|
|
9
|
-
const format = process.env.UTILS === 'moment' ? 'MM/DD/YYYY HH:mm' : 'MM/dd/yyyy hh:mm';
|
|
10
|
-
|
|
11
|
-
describe('e2e - KeyboardDateTimePicker (inline)', () => {
|
|
12
|
-
let component: ReactWrapper<KeyboardDateTimePickerProps>;
|
|
13
|
-
const onChangeMock = jest.fn();
|
|
14
|
-
const onCloseMock = jest.fn();
|
|
15
|
-
const onOpenMock = jest.fn();
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
jest.clearAllMocks();
|
|
19
|
-
component = mount(
|
|
20
|
-
<KeyboardDateTimePicker
|
|
21
|
-
autoOk
|
|
22
|
-
variant="inline"
|
|
23
|
-
inputVariant="outlined"
|
|
24
|
-
onChange={onChangeMock}
|
|
25
|
-
onClose={onCloseMock}
|
|
26
|
-
onOpen={onOpenMock}
|
|
27
|
-
format={format}
|
|
28
|
-
KeyboardButtonProps={{ id: 'keyboard-button' }}
|
|
29
|
-
value={utilsToUse.date('2018-01-01T00:00:00.000Z')}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('Should renders', () => {
|
|
35
|
-
expect(component).toBeTruthy();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('Should open modal with picker on click', () => {
|
|
39
|
-
component.find('button#keyboard-button').simulate('click');
|
|
40
|
-
expect(component.find('WithStyles(ForwardRef(Popover))').props().open).toBeTruthy();
|
|
41
|
-
expect(onOpenMock).toHaveBeenCalled();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('Should apply keyboard input', () => {
|
|
45
|
-
component.find('input').simulate('change', { target: { value: '02/01/2018 10:00' } });
|
|
46
|
-
expect(onChangeMock).toHaveBeenCalled();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { mount } from '../test-utils';
|
|
3
|
-
import { DatePicker } from '../../DatePicker';
|
|
4
|
-
import { createMuiTheme } from '@material-ui/core';
|
|
5
|
-
import { ThemeProvider } from '@material-ui/styles';
|
|
6
|
-
import { DateTimePicker } from '../../DateTimePicker/DateTimePicker';
|
|
7
|
-
|
|
8
|
-
const theme = createMuiTheme({
|
|
9
|
-
palette: {
|
|
10
|
-
type: 'dark',
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('Should renders without crash in dark theme', () => {
|
|
15
|
-
const component = mount(
|
|
16
|
-
<ThemeProvider theme={theme}>
|
|
17
|
-
<DateTimePicker open openTo="hours" value={null} onChange={jest.fn()} />
|
|
18
|
-
</ThemeProvider>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
expect(component).toBeTruthy();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('Should render component with different orientation', () => {
|
|
25
|
-
const component = mount(
|
|
26
|
-
<DatePicker open orientation="landscape" value={null} onChange={jest.fn()} />
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
expect(component).toBeTruthy();
|
|
30
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ReactWrapper } from 'enzyme';
|
|
3
|
-
import { clickOKButton } from './commands';
|
|
4
|
-
import { TimePicker, TimePickerProps } from '../../TimePicker/TimePicker';
|
|
5
|
-
import { mount, utilsToUse, toHaveBeenCalledExceptMoment } from '../test-utils';
|
|
6
|
-
|
|
7
|
-
const fakeTouchEvent = {
|
|
8
|
-
buttons: 1,
|
|
9
|
-
nativeEvent: {
|
|
10
|
-
offsetX: 20,
|
|
11
|
-
offsetY: 15,
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('e2e - TimePicker', () => {
|
|
16
|
-
let component: ReactWrapper<TimePickerProps>;
|
|
17
|
-
const onChangeMock = jest.fn();
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
jest.clearAllMocks();
|
|
21
|
-
component = mount(
|
|
22
|
-
<TimePicker open value={utilsToUse.date('2018-01-01T00:00:00.000')} onChange={onChangeMock} />
|
|
23
|
-
);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('Should renders', () => {
|
|
27
|
-
expect(component).toBeTruthy();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('Should submit onChange on moving', () => {
|
|
31
|
-
component.find('Clock div[role="menu"]').simulate('mouseMove', fakeTouchEvent);
|
|
32
|
-
component.find('Clock div[role="menu"]').simulate('mouseUp', fakeTouchEvent);
|
|
33
|
-
|
|
34
|
-
expect(
|
|
35
|
-
component
|
|
36
|
-
.find('WithStyles(ToolbarButton)')
|
|
37
|
-
.at(0)
|
|
38
|
-
.text()
|
|
39
|
-
).toBe('11');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('Should change minutes (touch)', () => {
|
|
43
|
-
component
|
|
44
|
-
.find('WithStyles(ToolbarButton)')
|
|
45
|
-
.at(1)
|
|
46
|
-
.simulate('click');
|
|
47
|
-
|
|
48
|
-
component.find('Clock div[role="menu"]').simulate('touchMove', {
|
|
49
|
-
buttons: 1,
|
|
50
|
-
changedTouches: [
|
|
51
|
-
{
|
|
52
|
-
clientX: 20,
|
|
53
|
-
clientY: 15,
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
expect(
|
|
59
|
-
component
|
|
60
|
-
.find('WithStyles(ToolbarButton)')
|
|
61
|
-
.at(1)
|
|
62
|
-
.text()
|
|
63
|
-
).toBe('53');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('Should change meridiem mode', () => {
|
|
67
|
-
component
|
|
68
|
-
.find('WithStyles(ToolbarButton)')
|
|
69
|
-
.at(3)
|
|
70
|
-
.simulate('click');
|
|
71
|
-
|
|
72
|
-
clickOKButton(component);
|
|
73
|
-
toHaveBeenCalledExceptMoment(onChangeMock, [utilsToUse.date('2018-01-01T12:00:00.000')]);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('e2e - TimePicker with seconds', () => {
|
|
78
|
-
let component: ReactWrapper<TimePickerProps>;
|
|
79
|
-
const onChangeMock = jest.fn();
|
|
80
|
-
|
|
81
|
-
beforeEach(() => {
|
|
82
|
-
jest.clearAllMocks();
|
|
83
|
-
component = mount(
|
|
84
|
-
<TimePicker
|
|
85
|
-
open
|
|
86
|
-
views={['hours', 'minutes', 'seconds']}
|
|
87
|
-
value={utilsToUse.date('2018-01-01T00:00:12.000')}
|
|
88
|
-
onChange={onChangeMock}
|
|
89
|
-
/>
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('Should show seconds number', () => {
|
|
94
|
-
expect(
|
|
95
|
-
component
|
|
96
|
-
.find('WithStyles(ToolbarButton)')
|
|
97
|
-
.at(2)
|
|
98
|
-
.text()
|
|
99
|
-
).toBe('12');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('Should change seconds', () => {
|
|
103
|
-
component
|
|
104
|
-
.find('WithStyles(ToolbarButton)')
|
|
105
|
-
.at(2)
|
|
106
|
-
.simulate('click');
|
|
107
|
-
|
|
108
|
-
component.find('Clock div[role="menu"]').simulate('touchMove', {
|
|
109
|
-
buttons: 1,
|
|
110
|
-
changedTouches: [
|
|
111
|
-
{
|
|
112
|
-
clientX: 20,
|
|
113
|
-
clientY: 15,
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
clickOKButton(component);
|
|
119
|
-
toHaveBeenCalledExceptMoment(onChangeMock, [utilsToUse.date('2018-01-01T00:00:53.000')]);
|
|
120
|
-
});
|
|
121
|
-
});
|
package/src/__tests__/setup.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const Enzyme = require('enzyme');
|
|
2
|
-
const EnzymeAdapter = require('enzyme-adapter-react-16');
|
|
3
|
-
|
|
4
|
-
// Setup enzyme's react adapter
|
|
5
|
-
Enzyme.configure({ adapter: new EnzymeAdapter() });
|
|
6
|
-
|
|
7
|
-
// Convert any console error into a thrown error
|
|
8
|
-
const error = console.error;
|
|
9
|
-
console.error = (...args) => {
|
|
10
|
-
error.apply(console, args);
|
|
11
|
-
if (args[0] instanceof Error) {
|
|
12
|
-
throw args[0];
|
|
13
|
-
} else {
|
|
14
|
-
// combine multi args into a string
|
|
15
|
-
const message = args
|
|
16
|
-
.map(value => {
|
|
17
|
-
if (typeof value === 'object') {
|
|
18
|
-
return JSON.stringify(value);
|
|
19
|
-
} else {
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
.join(' ');
|
|
24
|
-
throw new Error(message);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as enzyme from 'enzyme';
|
|
3
|
-
import LuxonUtils from '@date-io/luxon';
|
|
4
|
-
import MomentUtils from '@date-io/moment';
|
|
5
|
-
import DateFnsUtils from '@date-io/date-fns';
|
|
6
|
-
import MuiPickersUtilsProvider from '../MuiPickersUtilsProvider';
|
|
7
|
-
import { WithUtilsProps } from '../_shared/WithUtils';
|
|
8
|
-
|
|
9
|
-
const getUtilClass = () => {
|
|
10
|
-
switch (process.env.UTILS) {
|
|
11
|
-
case 'moment':
|
|
12
|
-
return MomentUtils;
|
|
13
|
-
case 'date-fns':
|
|
14
|
-
return DateFnsUtils;
|
|
15
|
-
case 'luxon':
|
|
16
|
-
return LuxonUtils;
|
|
17
|
-
default:
|
|
18
|
-
return DateFnsUtils;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const UtilClassToUse: any = getUtilClass();
|
|
23
|
-
export const utilsToUse = new UtilClassToUse();
|
|
24
|
-
|
|
25
|
-
const getComponentWithUtils = <P extends WithUtilsProps>(element: React.ReactElement<P>) =>
|
|
26
|
-
React.cloneElement(element, { utils: utilsToUse } as any);
|
|
27
|
-
|
|
28
|
-
export const shallow = <P extends WithUtilsProps>(element: React.ReactElement<P>) =>
|
|
29
|
-
enzyme.shallow(getComponentWithUtils(element));
|
|
30
|
-
|
|
31
|
-
export const mount = <P extends WithUtilsProps>(element: React.ReactElement<P>) =>
|
|
32
|
-
enzyme.mount(<MuiPickersUtilsProvider utils={UtilClassToUse}>{element}</MuiPickersUtilsProvider>);
|
|
33
|
-
|
|
34
|
-
export const shallowRender = (render: (props: any) => React.ReactElement<any>) => {
|
|
35
|
-
return enzyme.shallow(render({ utils: utilsToUse, classes: {} as any, theme: {} as any }));
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// toHaveBeenCalledWith doesn't work with moment because of changing some internal props
|
|
39
|
-
export const toHaveBeenCalledExceptMoment = (mock: jest.Mock<any, any>, params: any[]) => {
|
|
40
|
-
if (process.env.UTILS === 'moment') {
|
|
41
|
-
return expect(mock).toHaveBeenCalled();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return expect(mock).toHaveBeenCalledWith(...params);
|
|
45
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { arrayIncludes } from './utils';
|
|
2
|
-
import { IUtils } from '@date-io/core/IUtils';
|
|
3
|
-
import { MaterialUiPickersDate } from '../typings/date';
|
|
4
|
-
import { DatePickerView } from '../DatePicker/DatePicker';
|
|
5
|
-
|
|
6
|
-
interface FindClosestDateParams {
|
|
7
|
-
date: MaterialUiPickersDate;
|
|
8
|
-
utils: IUtils<MaterialUiPickersDate>;
|
|
9
|
-
minDate: MaterialUiPickersDate;
|
|
10
|
-
maxDate: MaterialUiPickersDate;
|
|
11
|
-
disableFuture: boolean;
|
|
12
|
-
disablePast: boolean;
|
|
13
|
-
shouldDisableDate: (date: MaterialUiPickersDate) => boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const findClosestEnabledDate = ({
|
|
17
|
-
date,
|
|
18
|
-
utils,
|
|
19
|
-
minDate,
|
|
20
|
-
maxDate,
|
|
21
|
-
disableFuture,
|
|
22
|
-
disablePast,
|
|
23
|
-
shouldDisableDate,
|
|
24
|
-
}: FindClosestDateParams) => {
|
|
25
|
-
const today = utils.startOfDay(utils.date());
|
|
26
|
-
|
|
27
|
-
if (disablePast && utils.isBefore(minDate!, today)) {
|
|
28
|
-
minDate = today;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (disableFuture && utils.isAfter(maxDate, today)) {
|
|
32
|
-
maxDate = today;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let forward = date;
|
|
36
|
-
let backward = date;
|
|
37
|
-
if (utils.isBefore(date, minDate)) {
|
|
38
|
-
forward = utils.date(minDate);
|
|
39
|
-
backward = null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (utils.isAfter(date, maxDate)) {
|
|
43
|
-
if (backward) {
|
|
44
|
-
backward = utils.date(maxDate);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
forward = null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
while (forward || backward) {
|
|
51
|
-
if (forward && utils.isAfter(forward, maxDate)) {
|
|
52
|
-
forward = null;
|
|
53
|
-
}
|
|
54
|
-
if (backward && utils.isBefore(backward, minDate)) {
|
|
55
|
-
backward = null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (forward) {
|
|
59
|
-
if (!shouldDisableDate(forward)) {
|
|
60
|
-
return forward;
|
|
61
|
-
}
|
|
62
|
-
forward = utils.addDays(forward, 1);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (backward) {
|
|
66
|
-
if (!shouldDisableDate(backward)) {
|
|
67
|
-
return backward;
|
|
68
|
-
}
|
|
69
|
-
backward = utils.addDays(backward, -1);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return null;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const isYearOnlyView = (views: DatePickerView[]) =>
|
|
77
|
-
views.length === 1 && views[0] === 'year';
|
|
78
|
-
|
|
79
|
-
export const isYearAndMonthViews = (views: DatePickerView[]) =>
|
|
80
|
-
views.length === 2 && arrayIncludes(views, 'month') && arrayIncludes(views, 'year');
|
|
81
|
-
|
|
82
|
-
export const getFormatByViews = (views: DatePickerView[], utils: IUtils<MaterialUiPickersDate>) => {
|
|
83
|
-
if (isYearOnlyView(views)) {
|
|
84
|
-
return utils.yearFormat;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (isYearAndMonthViews(views)) {
|
|
88
|
-
return utils.yearMonthFormat;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return utils.dateFormat;
|
|
92
|
-
};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { DatePickerProps } from '..';
|
|
2
|
-
import { Omit } from '@material-ui/core';
|
|
3
|
-
import { IUtils } from '@date-io/core/IUtils';
|
|
4
|
-
import { ParsableDate } from '../constants/prop-types';
|
|
5
|
-
import { BasePickerProps } from '../typings/BasePicker';
|
|
6
|
-
|
|
7
|
-
export const getDisplayDate = (
|
|
8
|
-
value: ParsableDate,
|
|
9
|
-
format: string,
|
|
10
|
-
utils: IUtils<any>,
|
|
11
|
-
isEmpty: boolean,
|
|
12
|
-
{ invalidLabel, emptyLabel, labelFunc }: Omit<BasePickerProps, 'value' | 'onChange'>
|
|
13
|
-
) => {
|
|
14
|
-
const date = utils.date(value);
|
|
15
|
-
if (labelFunc) {
|
|
16
|
-
return labelFunc(isEmpty ? null : date, invalidLabel!);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (isEmpty) {
|
|
20
|
-
return emptyLabel || '';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return utils.isValid(date) ? utils.format(date, format) : invalidLabel!;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export interface BaseValidationProps {
|
|
27
|
-
/**
|
|
28
|
-
* Message, appearing when date cannot be parsed
|
|
29
|
-
* @default 'Invalid Date Format'
|
|
30
|
-
*/
|
|
31
|
-
invalidDateMessage?: React.ReactNode;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface DateValidationProps extends BaseValidationProps {
|
|
35
|
-
/**
|
|
36
|
-
* Error message, shown if date is less then minimal date
|
|
37
|
-
* @default 'Date should not be before minimal date'
|
|
38
|
-
*/
|
|
39
|
-
minDateMessage?: React.ReactNode;
|
|
40
|
-
/**
|
|
41
|
-
* Error message, shown if date is more then maximal date
|
|
42
|
-
* @default 'Date should not be after maximal date'
|
|
43
|
-
*/
|
|
44
|
-
maxDateMessage?: React.ReactNode;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const getComparisonMaxDate = (utils: IUtils<any>, strictCompareDates: boolean, date: Date) => {
|
|
48
|
-
if (strictCompareDates) {
|
|
49
|
-
return date;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return utils.endOfDay(date);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const getComparisonMinDate = (utils: IUtils<any>, strictCompareDates: boolean, date: Date) => {
|
|
56
|
-
if (strictCompareDates) {
|
|
57
|
-
return date;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return utils.startOfDay(date);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const validate = (
|
|
64
|
-
value: ParsableDate,
|
|
65
|
-
utils: IUtils<any>,
|
|
66
|
-
{
|
|
67
|
-
maxDate,
|
|
68
|
-
minDate,
|
|
69
|
-
disablePast,
|
|
70
|
-
disableFuture,
|
|
71
|
-
maxDateMessage,
|
|
72
|
-
minDateMessage,
|
|
73
|
-
invalidDateMessage,
|
|
74
|
-
strictCompareDates,
|
|
75
|
-
}: Omit<DatePickerProps, 'views' | 'openTo'> // DateTimePicker doesn't support
|
|
76
|
-
): React.ReactNode => {
|
|
77
|
-
const parsedValue = utils.date(value);
|
|
78
|
-
|
|
79
|
-
// if null - do not show error
|
|
80
|
-
if (value === null) {
|
|
81
|
-
return '';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (!utils.isValid(value)) {
|
|
85
|
-
return invalidDateMessage;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
maxDate &&
|
|
90
|
-
utils.isAfter(
|
|
91
|
-
parsedValue,
|
|
92
|
-
getComparisonMaxDate(utils, !!strictCompareDates, utils.date(maxDate))
|
|
93
|
-
)
|
|
94
|
-
) {
|
|
95
|
-
return maxDateMessage;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
disableFuture &&
|
|
100
|
-
utils.isAfter(parsedValue, getComparisonMaxDate(utils, !!strictCompareDates, utils.date()))
|
|
101
|
-
) {
|
|
102
|
-
return maxDateMessage;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
minDate &&
|
|
107
|
-
utils.isBefore(
|
|
108
|
-
parsedValue,
|
|
109
|
-
getComparisonMinDate(utils, !!strictCompareDates, utils.date(minDate))
|
|
110
|
-
)
|
|
111
|
-
) {
|
|
112
|
-
return minDateMessage;
|
|
113
|
-
}
|
|
114
|
-
if (
|
|
115
|
-
disablePast &&
|
|
116
|
-
utils.isBefore(parsedValue, getComparisonMinDate(utils, !!strictCompareDates, utils.date()))
|
|
117
|
-
) {
|
|
118
|
-
return minDateMessage;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return '';
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export function pick12hOr24hFormat(
|
|
125
|
-
userFormat: string | undefined,
|
|
126
|
-
ampm: boolean | undefined = true,
|
|
127
|
-
formats: { '12h': string; '24h': string }
|
|
128
|
-
) {
|
|
129
|
-
if (userFormat) {
|
|
130
|
-
return userFormat;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return ampm ? formats['12h'] : formats['24h'];
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function makeMaskFromFormat(format: string, numberMaskChar: string) {
|
|
137
|
-
return format.replace(/[a-z]/gi, numberMaskChar);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export const maskedDateFormatter = (mask: string, numberMaskChar: string, refuse: RegExp) => (
|
|
141
|
-
value: string
|
|
142
|
-
) => {
|
|
143
|
-
if (value === '') {
|
|
144
|
-
return value;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
let result = '';
|
|
148
|
-
const parsed = value.replace(refuse, '');
|
|
149
|
-
|
|
150
|
-
let i = 0;
|
|
151
|
-
let n = 0;
|
|
152
|
-
while (i < mask.length) {
|
|
153
|
-
const maskChar = mask[i];
|
|
154
|
-
if (maskChar === numberMaskChar && n < parsed.length) {
|
|
155
|
-
const parsedChar = parsed[n];
|
|
156
|
-
result += parsedChar;
|
|
157
|
-
n += 1;
|
|
158
|
-
} else {
|
|
159
|
-
result += maskChar;
|
|
160
|
-
}
|
|
161
|
-
i += 1;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return result;
|
|
165
|
-
};
|