@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,83 +0,0 @@
|
|
|
1
|
-
import { IUtils } from '@date-io/core/IUtils';
|
|
2
|
-
import { MaterialUiPickersDate } from '../typings/date';
|
|
3
|
-
|
|
4
|
-
const center = {
|
|
5
|
-
x: 260 / 2,
|
|
6
|
-
y: 260 / 2,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const basePoint = {
|
|
10
|
-
x: center.x,
|
|
11
|
-
y: 0,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const cx = basePoint.x - center.x;
|
|
15
|
-
const cy = basePoint.y - center.y;
|
|
16
|
-
|
|
17
|
-
const rad2deg = (rad: number) => rad * 57.29577951308232;
|
|
18
|
-
|
|
19
|
-
const getAngleValue = (step: number, offsetX: number, offsetY: number) => {
|
|
20
|
-
const x = offsetX - center.x;
|
|
21
|
-
const y = offsetY - center.y;
|
|
22
|
-
|
|
23
|
-
const atan = Math.atan2(cx, cy) - Math.atan2(x, y);
|
|
24
|
-
|
|
25
|
-
let deg = rad2deg(atan);
|
|
26
|
-
deg = Math.round(deg / step) * step;
|
|
27
|
-
deg %= 360;
|
|
28
|
-
|
|
29
|
-
const value = Math.floor(deg / step) || 0;
|
|
30
|
-
const delta = Math.pow(x, 2) + Math.pow(y, 2);
|
|
31
|
-
const distance = Math.sqrt(delta);
|
|
32
|
-
|
|
33
|
-
return { value, distance };
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const getHours = (offsetX: number, offsetY: number, ampm: boolean) => {
|
|
37
|
-
let { value, distance } = getAngleValue(30, offsetX, offsetY);
|
|
38
|
-
value = value || 12;
|
|
39
|
-
|
|
40
|
-
if (!ampm) {
|
|
41
|
-
if (distance < 90) {
|
|
42
|
-
value += 12;
|
|
43
|
-
value %= 24;
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
value %= 12;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return value;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const getMinutes = (offsetX: number, offsetY: number, step = 1) => {
|
|
53
|
-
const angleStep = step * 6;
|
|
54
|
-
let { value } = getAngleValue(angleStep, offsetX, offsetY);
|
|
55
|
-
value = (value * step) % 60;
|
|
56
|
-
|
|
57
|
-
return value;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const getMeridiem = (
|
|
61
|
-
date: MaterialUiPickersDate,
|
|
62
|
-
utils: IUtils<MaterialUiPickersDate>
|
|
63
|
-
): 'am' | 'pm' => {
|
|
64
|
-
return utils.getHours(date) >= 12 ? 'pm' : 'am';
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const convertToMeridiem = (
|
|
68
|
-
time: MaterialUiPickersDate,
|
|
69
|
-
meridiem: 'am' | 'pm',
|
|
70
|
-
ampm: boolean,
|
|
71
|
-
utils: IUtils<MaterialUiPickersDate>
|
|
72
|
-
) => {
|
|
73
|
-
if (ampm) {
|
|
74
|
-
const currentMeridiem = utils.getHours(time) >= 12 ? 'pm' : 'am';
|
|
75
|
-
if (currentMeridiem !== meridiem) {
|
|
76
|
-
const hours = meridiem === 'am' ? utils.getHours(time) - 12 : utils.getHours(time) + 12;
|
|
77
|
-
|
|
78
|
-
return utils.setHours(time, hours);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return time;
|
|
83
|
-
};
|
package/src/_helpers/utils.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Use it instead of .includes method for IE support */
|
|
2
|
-
export function arrayIncludes<T>(array: T[], itemOrItems: T | T[]) {
|
|
3
|
-
if (Array.isArray(itemOrItems)) {
|
|
4
|
-
return itemOrItems.every(item => array.indexOf(item) !== -1);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
return array.indexOf(itemOrItems) !== -1;
|
|
8
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import InputAdornment, { InputAdornmentProps } from '@material-ui/core/InputAdornment';
|
|
3
|
-
import TextField, { BaseTextFieldProps, TextFieldProps } from '@material-ui/core/TextField';
|
|
4
|
-
import { Rifm } from 'rifm';
|
|
5
|
-
import { IconButton } from '@material-ui/core';
|
|
6
|
-
import { ExtendMui } from '../typings/extendMui';
|
|
7
|
-
import { KeyboardIcon } from './icons/KeyboardIcon';
|
|
8
|
-
import { IconButtonProps } from '@material-ui/core/IconButton';
|
|
9
|
-
import { makeMaskFromFormat, maskedDateFormatter } from '../_helpers/text-field-helper';
|
|
10
|
-
|
|
11
|
-
export interface KeyboardDateInputProps
|
|
12
|
-
extends ExtendMui<BaseTextFieldProps, 'variant' | 'onError' | 'onChange' | 'value'> {
|
|
13
|
-
format: string;
|
|
14
|
-
onChange: (value: string | null) => void;
|
|
15
|
-
onClick?: () => void;
|
|
16
|
-
validationError?: React.ReactNode;
|
|
17
|
-
inputValue: string;
|
|
18
|
-
InputProps?: TextFieldProps['InputProps'];
|
|
19
|
-
/** Override input component */
|
|
20
|
-
TextFieldComponent?: React.ComponentType<TextFieldProps>;
|
|
21
|
-
/** Icon displaying for open picker button */
|
|
22
|
-
keyboardIcon?: React.ReactNode;
|
|
23
|
-
/** Pass material-ui text field variant down, bypass internal variant prop */
|
|
24
|
-
inputVariant?: TextFieldProps['variant'];
|
|
25
|
-
/**
|
|
26
|
-
* Custom mask. Can be used to override generate from format. (e.g. __/__/____ __:__)
|
|
27
|
-
*/
|
|
28
|
-
mask?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Char string that will be replaced with number (for "_" mask will be "__/__/____")
|
|
31
|
-
* @default '_'
|
|
32
|
-
*/
|
|
33
|
-
maskChar?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Refuse values regexp
|
|
36
|
-
* @default /[^\d]+/gi
|
|
37
|
-
*/
|
|
38
|
-
refuse?: RegExp;
|
|
39
|
-
/**
|
|
40
|
-
* Props to pass to keyboard input adornment
|
|
41
|
-
* @type {Partial<InputAdornmentProps>}
|
|
42
|
-
*/
|
|
43
|
-
InputAdornmentProps?: Partial<InputAdornmentProps>;
|
|
44
|
-
/**
|
|
45
|
-
* Props to pass to keyboard adornment button
|
|
46
|
-
* @type {Partial<IconButtonProps>}
|
|
47
|
-
*/
|
|
48
|
-
KeyboardButtonProps?: Partial<IconButtonProps>;
|
|
49
|
-
/** Custom formatter to be passed into Rifm component */
|
|
50
|
-
rifmFormatter?: (str: string) => string;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const KeyboardDateInput: React.FunctionComponent<KeyboardDateInputProps> = ({
|
|
54
|
-
inputValue,
|
|
55
|
-
inputVariant,
|
|
56
|
-
validationError,
|
|
57
|
-
KeyboardButtonProps,
|
|
58
|
-
InputAdornmentProps,
|
|
59
|
-
onClick,
|
|
60
|
-
onChange,
|
|
61
|
-
InputProps,
|
|
62
|
-
mask,
|
|
63
|
-
maskChar = '_',
|
|
64
|
-
refuse = /[^\d]+/gi,
|
|
65
|
-
format,
|
|
66
|
-
keyboardIcon,
|
|
67
|
-
disabled,
|
|
68
|
-
rifmFormatter,
|
|
69
|
-
TextFieldComponent = TextField,
|
|
70
|
-
...other
|
|
71
|
-
}) => {
|
|
72
|
-
const inputMask = mask || makeMaskFromFormat(format, maskChar);
|
|
73
|
-
// prettier-ignore
|
|
74
|
-
const formatter = React.useCallback(
|
|
75
|
-
maskedDateFormatter(inputMask, maskChar, refuse),
|
|
76
|
-
[mask, maskChar]
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const position =
|
|
80
|
-
InputAdornmentProps && InputAdornmentProps.position ? InputAdornmentProps.position : 'end';
|
|
81
|
-
|
|
82
|
-
const handleChange = (text: string) => {
|
|
83
|
-
const finalString = text === '' || text === inputMask ? null : text;
|
|
84
|
-
onChange(finalString);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<Rifm
|
|
89
|
-
value={inputValue}
|
|
90
|
-
onChange={handleChange}
|
|
91
|
-
refuse={refuse}
|
|
92
|
-
format={rifmFormatter || formatter}
|
|
93
|
-
>
|
|
94
|
-
{({ onChange, value }) => (
|
|
95
|
-
<TextFieldComponent
|
|
96
|
-
disabled={disabled}
|
|
97
|
-
error={Boolean(validationError)}
|
|
98
|
-
helperText={validationError}
|
|
99
|
-
{...other}
|
|
100
|
-
value={value}
|
|
101
|
-
onChange={onChange}
|
|
102
|
-
variant={inputVariant as any}
|
|
103
|
-
InputProps={{
|
|
104
|
-
...InputProps,
|
|
105
|
-
[`${position}Adornment`]: (
|
|
106
|
-
<InputAdornment position={position} {...InputAdornmentProps}>
|
|
107
|
-
<IconButton disabled={disabled} {...KeyboardButtonProps} onClick={onClick}>
|
|
108
|
-
{keyboardIcon}
|
|
109
|
-
</IconButton>
|
|
110
|
-
</InputAdornment>
|
|
111
|
-
),
|
|
112
|
-
}}
|
|
113
|
-
/>
|
|
114
|
-
)}
|
|
115
|
-
</Rifm>
|
|
116
|
-
);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
KeyboardDateInput.defaultProps = {
|
|
120
|
-
keyboardIcon: <KeyboardIcon />,
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export default KeyboardDateInput;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import Button from '@material-ui/core/Button';
|
|
4
|
-
import DialogActions from '@material-ui/core/DialogActions';
|
|
5
|
-
import DialogContent from '@material-ui/core/DialogContent';
|
|
6
|
-
import Dialog, { DialogProps } from '@material-ui/core/Dialog';
|
|
7
|
-
import { DIALOG_WIDTH } from '../constants/dimensions';
|
|
8
|
-
import { createStyles, WithStyles, withStyles } from '@material-ui/core/styles';
|
|
9
|
-
|
|
10
|
-
export interface ModalDialogProps extends DialogProps {
|
|
11
|
-
onAccept: () => void;
|
|
12
|
-
onDismiss: () => void;
|
|
13
|
-
onClear: () => void;
|
|
14
|
-
onSetToday: () => void;
|
|
15
|
-
okLabel?: React.ReactNode;
|
|
16
|
-
cancelLabel?: React.ReactNode;
|
|
17
|
-
clearLabel?: React.ReactNode;
|
|
18
|
-
todayLabel?: React.ReactNode;
|
|
19
|
-
clearable?: boolean;
|
|
20
|
-
showTodayButton?: boolean;
|
|
21
|
-
showTabs?: boolean;
|
|
22
|
-
wider?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const ModalDialog: React.SFC<ModalDialogProps & WithStyles<typeof styles>> = ({
|
|
26
|
-
children,
|
|
27
|
-
classes,
|
|
28
|
-
onAccept,
|
|
29
|
-
onDismiss,
|
|
30
|
-
onClear,
|
|
31
|
-
onSetToday,
|
|
32
|
-
okLabel,
|
|
33
|
-
cancelLabel,
|
|
34
|
-
clearLabel,
|
|
35
|
-
todayLabel,
|
|
36
|
-
clearable,
|
|
37
|
-
showTodayButton,
|
|
38
|
-
showTabs,
|
|
39
|
-
wider,
|
|
40
|
-
...other
|
|
41
|
-
}) => (
|
|
42
|
-
<Dialog
|
|
43
|
-
role="dialog"
|
|
44
|
-
onClose={onDismiss}
|
|
45
|
-
classes={{
|
|
46
|
-
paper: clsx(classes.dialogRoot, {
|
|
47
|
-
[classes.dialogRootWider]: wider,
|
|
48
|
-
}),
|
|
49
|
-
}}
|
|
50
|
-
{...other}
|
|
51
|
-
>
|
|
52
|
-
<DialogContent children={children} className={classes.dialog} />
|
|
53
|
-
|
|
54
|
-
<DialogActions
|
|
55
|
-
classes={{
|
|
56
|
-
root: clsx({
|
|
57
|
-
[classes.withAdditionalAction]: clearable || showTodayButton,
|
|
58
|
-
}),
|
|
59
|
-
}}
|
|
60
|
-
>
|
|
61
|
-
{clearable && (
|
|
62
|
-
<Button color="primary" onClick={onClear}>
|
|
63
|
-
{clearLabel}
|
|
64
|
-
</Button>
|
|
65
|
-
)}
|
|
66
|
-
|
|
67
|
-
{!clearable && showTodayButton && (
|
|
68
|
-
<Button color="primary" onClick={onSetToday}>
|
|
69
|
-
{todayLabel}
|
|
70
|
-
</Button>
|
|
71
|
-
)}
|
|
72
|
-
|
|
73
|
-
{cancelLabel && (
|
|
74
|
-
<Button color="primary" onClick={onDismiss}>
|
|
75
|
-
{cancelLabel}
|
|
76
|
-
</Button>
|
|
77
|
-
)}
|
|
78
|
-
|
|
79
|
-
{okLabel && (
|
|
80
|
-
<Button color="primary" onClick={onAccept}>
|
|
81
|
-
{okLabel}
|
|
82
|
-
</Button>
|
|
83
|
-
)}
|
|
84
|
-
</DialogActions>
|
|
85
|
-
</Dialog>
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
ModalDialog.displayName = 'ModalDialog';
|
|
89
|
-
|
|
90
|
-
export const styles = createStyles({
|
|
91
|
-
dialogRoot: {
|
|
92
|
-
minWidth: DIALOG_WIDTH,
|
|
93
|
-
// maxWidth: DIALOG_WIDTH_WIDER,
|
|
94
|
-
},
|
|
95
|
-
dialogRootWider: {
|
|
96
|
-
// minWidth: DIALOG_WIDTH_WIDER,
|
|
97
|
-
},
|
|
98
|
-
dialog: {
|
|
99
|
-
'&:first-child': {
|
|
100
|
-
padding: 0,
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
withAdditionalAction: {
|
|
104
|
-
// set justifyContent to default value to fix IE11 layout bug
|
|
105
|
-
// see https://github.com/dmtrKovalenko/material-ui-pickers/pull/267
|
|
106
|
-
justifyContent: 'flex-start',
|
|
107
|
-
|
|
108
|
-
'& > *:first-child': {
|
|
109
|
-
marginRight: 'auto',
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
export default withStyles(styles, { name: 'MuiPickersModal' })(ModalDialog);
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import Toolbar, { ToolbarProps } from '@material-ui/core/Toolbar';
|
|
4
|
-
import { ExtendMui } from '../typings/extendMui';
|
|
5
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
6
|
-
|
|
7
|
-
export const useStyles = makeStyles(
|
|
8
|
-
theme => ({
|
|
9
|
-
toolbar: {
|
|
10
|
-
display: 'flex',
|
|
11
|
-
flexDirection: 'row',
|
|
12
|
-
alignItems: 'center',
|
|
13
|
-
justifyContent: 'center',
|
|
14
|
-
height: 100,
|
|
15
|
-
backgroundColor:
|
|
16
|
-
theme.palette.type === 'light'
|
|
17
|
-
? theme.palette.primary.main
|
|
18
|
-
: theme.palette.background.default,
|
|
19
|
-
},
|
|
20
|
-
toolbarLandscape: {
|
|
21
|
-
height: 'auto',
|
|
22
|
-
maxWidth: 150,
|
|
23
|
-
padding: 8,
|
|
24
|
-
justifyContent: 'flex-start',
|
|
25
|
-
},
|
|
26
|
-
}),
|
|
27
|
-
{ name: 'MuiPickersToolbar' }
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
interface PickerToolbarProps extends ExtendMui<ToolbarProps> {
|
|
31
|
-
isLandscape: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const PickerToolbar: React.SFC<PickerToolbarProps> = ({
|
|
35
|
-
children,
|
|
36
|
-
isLandscape,
|
|
37
|
-
className = null,
|
|
38
|
-
...other
|
|
39
|
-
}) => {
|
|
40
|
-
const classes = useStyles();
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<Toolbar
|
|
44
|
-
className={clsx(classes.toolbar, { [classes.toolbarLandscape]: isLandscape }, className)}
|
|
45
|
-
{...other}
|
|
46
|
-
>
|
|
47
|
-
{children}
|
|
48
|
-
</Toolbar>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default PickerToolbar;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import TextField, { BaseTextFieldProps, TextFieldProps } from '@material-ui/core/TextField';
|
|
3
|
-
import { ExtendMui } from '../typings/extendMui';
|
|
4
|
-
|
|
5
|
-
export interface PureDateInputProps
|
|
6
|
-
extends ExtendMui<BaseTextFieldProps, 'variant' | 'onError' | 'onChange' | 'value'> {
|
|
7
|
-
/** Pass material-ui text field variant down, bypass internal variant prop */
|
|
8
|
-
inputVariant?: TextFieldProps['variant'];
|
|
9
|
-
/** Override input component */
|
|
10
|
-
TextFieldComponent?: React.ComponentType<TextFieldProps>;
|
|
11
|
-
InputProps?: TextFieldProps['InputProps'];
|
|
12
|
-
inputValue: string;
|
|
13
|
-
validationError?: React.ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const PureDateInput: React.FC<PureDateInputProps> = ({
|
|
17
|
-
inputValue,
|
|
18
|
-
inputVariant,
|
|
19
|
-
validationError,
|
|
20
|
-
InputProps,
|
|
21
|
-
TextFieldComponent = TextField,
|
|
22
|
-
...other
|
|
23
|
-
}) => {
|
|
24
|
-
const PureDateInputProps = React.useMemo(
|
|
25
|
-
() => ({
|
|
26
|
-
...InputProps,
|
|
27
|
-
readOnly: true,
|
|
28
|
-
}),
|
|
29
|
-
[InputProps]
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<TextFieldComponent
|
|
34
|
-
error={Boolean(validationError)}
|
|
35
|
-
helperText={validationError}
|
|
36
|
-
{...other}
|
|
37
|
-
// do not overridable
|
|
38
|
-
value={inputValue}
|
|
39
|
-
variant={inputVariant as any}
|
|
40
|
-
InputProps={PureDateInputProps}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
PureDateInput.displayName = 'PureDateInput';
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import * as PropTypes from 'prop-types';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import ToolbarText from './ToolbarText';
|
|
5
|
-
import Button, { ButtonProps } from '@material-ui/core/Button';
|
|
6
|
-
import { ExtendMui } from '../typings/extendMui';
|
|
7
|
-
import { TypographyProps } from '@material-ui/core/Typography';
|
|
8
|
-
import { createStyles, withStyles, WithStyles } from '@material-ui/core/styles';
|
|
9
|
-
|
|
10
|
-
export interface ToolbarButtonProps
|
|
11
|
-
extends ExtendMui<ButtonProps, 'variant'>,
|
|
12
|
-
WithStyles<typeof styles> {
|
|
13
|
-
variant: TypographyProps['variant'];
|
|
14
|
-
selected: boolean;
|
|
15
|
-
label: string;
|
|
16
|
-
align?: TypographyProps['align'];
|
|
17
|
-
typographyClassName?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const ToolbarButton: React.FunctionComponent<ToolbarButtonProps> = ({
|
|
21
|
-
classes,
|
|
22
|
-
className = null,
|
|
23
|
-
label,
|
|
24
|
-
selected,
|
|
25
|
-
variant,
|
|
26
|
-
align,
|
|
27
|
-
typographyClassName,
|
|
28
|
-
...other
|
|
29
|
-
}) => {
|
|
30
|
-
return (
|
|
31
|
-
<Button variant="text" className={clsx(classes.toolbarBtn, className)} {...other}>
|
|
32
|
-
<ToolbarText
|
|
33
|
-
align={align}
|
|
34
|
-
className={typographyClassName}
|
|
35
|
-
variant={variant}
|
|
36
|
-
label={label}
|
|
37
|
-
selected={selected}
|
|
38
|
-
/>
|
|
39
|
-
</Button>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
(ToolbarButton as any).propTypes = {
|
|
44
|
-
selected: PropTypes.bool.isRequired,
|
|
45
|
-
label: PropTypes.string.isRequired,
|
|
46
|
-
classes: PropTypes.any.isRequired,
|
|
47
|
-
className: PropTypes.string,
|
|
48
|
-
innerRef: PropTypes.any,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
ToolbarButton.defaultProps = {
|
|
52
|
-
className: '',
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const styles = createStyles({
|
|
56
|
-
toolbarBtn: {
|
|
57
|
-
padding: 0,
|
|
58
|
-
minWidth: '16px',
|
|
59
|
-
textTransform: 'none',
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
export default withStyles(styles, { name: 'MuiPickersToolbarButton' })(ToolbarButton);
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import Typography, { TypographyProps } from '@material-ui/core/Typography';
|
|
4
|
-
import { ExtendMui } from '../typings/extendMui';
|
|
5
|
-
import { makeStyles, fade } from '@material-ui/core/styles';
|
|
6
|
-
|
|
7
|
-
export interface ToolbarTextProps extends ExtendMui<TypographyProps> {
|
|
8
|
-
selected?: boolean;
|
|
9
|
-
label: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const useStyles = makeStyles(
|
|
13
|
-
theme => {
|
|
14
|
-
const textColor =
|
|
15
|
-
theme.palette.type === 'light'
|
|
16
|
-
? theme.palette.primary.contrastText
|
|
17
|
-
: theme.palette.getContrastText(theme.palette.background.default);
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
toolbarTxt: {
|
|
21
|
-
color: fade(textColor, 0.54),
|
|
22
|
-
},
|
|
23
|
-
toolbarBtnSelected: {
|
|
24
|
-
color: textColor,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
{ name: 'MuiPickersToolbarText' }
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const ToolbarText: React.FunctionComponent<ToolbarTextProps> = ({
|
|
32
|
-
selected,
|
|
33
|
-
label,
|
|
34
|
-
className = null,
|
|
35
|
-
...other
|
|
36
|
-
}) => {
|
|
37
|
-
const classes = useStyles();
|
|
38
|
-
return (
|
|
39
|
-
<Typography
|
|
40
|
-
children={label}
|
|
41
|
-
className={clsx(classes.toolbarTxt, className, {
|
|
42
|
-
[classes.toolbarBtnSelected]: selected,
|
|
43
|
-
})}
|
|
44
|
-
{...other}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default ToolbarText;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Omit } from '@material-ui/core';
|
|
3
|
-
import { useUtils } from './hooks/useUtils';
|
|
4
|
-
import { IUtils } from '@date-io/core/IUtils';
|
|
5
|
-
import { MaterialUiPickersDate } from '../typings/date';
|
|
6
|
-
|
|
7
|
-
export interface WithUtilsProps {
|
|
8
|
-
utils: IUtils<MaterialUiPickersDate>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const withUtils = () => <P extends WithUtilsProps>(Component: React.ComponentType<P>) => {
|
|
12
|
-
const WithUtils: React.SFC<Omit<P, keyof WithUtilsProps>> = props => {
|
|
13
|
-
const utils = useUtils();
|
|
14
|
-
return <Component utils={utils} {...(props as any)} />;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
WithUtils.displayName = `WithUtils(${Component.displayName || Component.name})`;
|
|
18
|
-
return WithUtils;
|
|
19
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useIsomorphicEffect } from './useKeyDown';
|
|
3
|
-
import { BasePickerProps } from '../../typings/BasePicker';
|
|
4
|
-
|
|
5
|
-
const getOrientation = () =>
|
|
6
|
-
typeof window !== 'undefined' &&
|
|
7
|
-
window.screen &&
|
|
8
|
-
window.orientation &&
|
|
9
|
-
Math.abs(window.screen.orientation.angle) === 90
|
|
10
|
-
? 'landscape'
|
|
11
|
-
: 'portrait';
|
|
12
|
-
|
|
13
|
-
export function useIsLandscape(customOrientation?: BasePickerProps['orientation']) {
|
|
14
|
-
const [orientation, setOrientation] = React.useState<BasePickerProps['orientation']>(
|
|
15
|
-
getOrientation()
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const eventHandler = React.useCallback(() => setOrientation(getOrientation()), []);
|
|
19
|
-
|
|
20
|
-
useIsomorphicEffect(() => {
|
|
21
|
-
window.addEventListener('orientationchange', eventHandler);
|
|
22
|
-
return () => window.removeEventListener('orientationchange', eventHandler);
|
|
23
|
-
}, [eventHandler]);
|
|
24
|
-
|
|
25
|
-
const orientationToUse = customOrientation || orientation;
|
|
26
|
-
return orientationToUse === 'landscape';
|
|
27
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export const useIsomorphicEffect =
|
|
4
|
-
typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect;
|
|
5
|
-
|
|
6
|
-
type KeyHandlers = Record<KeyboardEvent['key'], () => void>;
|
|
7
|
-
|
|
8
|
-
export function runKeyHandler(e: KeyboardEvent, keyHandlers: KeyHandlers) {
|
|
9
|
-
const handler = keyHandlers[e.key];
|
|
10
|
-
if (handler) {
|
|
11
|
-
handler();
|
|
12
|
-
// if event was handled prevent other side effects (e.g. page scroll)
|
|
13
|
-
e.preventDefault();
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function useKeyDown(active: boolean, keyHandlers: KeyHandlers) {
|
|
18
|
-
const keyHandlersRef = React.useRef(keyHandlers);
|
|
19
|
-
useIsomorphicEffect(() => {
|
|
20
|
-
keyHandlersRef.current = keyHandlers;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
React.useEffect(() => {
|
|
24
|
-
if (active) {
|
|
25
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
26
|
-
runKeyHandler(event, keyHandlers);
|
|
27
|
-
};
|
|
28
|
-
window.addEventListener('keydown', handleKeyDown);
|
|
29
|
-
return () => {
|
|
30
|
-
window.removeEventListener('keydown', handleKeyDown);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}, [active, keyHandlers]);
|
|
34
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { useUtils } from './useUtils';
|
|
2
|
-
import { Omit } from '@material-ui/core';
|
|
3
|
-
import { IUtils } from '@date-io/core/IUtils';
|
|
4
|
-
import { BasePickerProps } from '../../typings/BasePicker';
|
|
5
|
-
import { MaterialUiPickersDate } from '../../typings/date';
|
|
6
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
|
-
import { getDisplayDate } from '../../_helpers/text-field-helper';
|
|
8
|
-
import { StateHookOptions, usePickerState } from './usePickerState';
|
|
9
|
-
|
|
10
|
-
export interface BaseKeyboardPickerProps extends Omit<BasePickerProps, 'onChange'> {
|
|
11
|
-
/** String value for controlling value with pure input string. Overrides value prop */
|
|
12
|
-
inputValue?: string;
|
|
13
|
-
/** Keyboard onChange callback */
|
|
14
|
-
onChange: (date: MaterialUiPickersDate | null, value?: string | null) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function parseInputString(value: string, utils: IUtils<any>, format: string) {
|
|
18
|
-
try {
|
|
19
|
-
return utils.parse(value, format);
|
|
20
|
-
} catch {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function useKeyboardPickerState(props: BaseKeyboardPickerProps, options: StateHookOptions) {
|
|
26
|
-
const { format = options.getDefaultFormat(), inputValue, onChange, value } = props;
|
|
27
|
-
const utils = useUtils();
|
|
28
|
-
|
|
29
|
-
const displayDate = getDisplayDate(value, format, utils, value === null, props);
|
|
30
|
-
const [innerInputValue, setInnerInputValue] = useState(displayDate);
|
|
31
|
-
const dateValue = inputValue ? parseInputString(inputValue, utils, format) : value;
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (value === null || utils.isValid(value)) {
|
|
35
|
-
setInnerInputValue(displayDate);
|
|
36
|
-
}
|
|
37
|
-
}, [displayDate, setInnerInputValue, utils, value]);
|
|
38
|
-
|
|
39
|
-
const handleKeyboardChange = useCallback(
|
|
40
|
-
(date: MaterialUiPickersDate) => {
|
|
41
|
-
onChange(date, date === null ? null : utils.format(date, format));
|
|
42
|
-
},
|
|
43
|
-
[format, onChange, utils]
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const { inputProps: innerInputProps, wrapperProps, pickerProps } = usePickerState(
|
|
47
|
-
// Extend props interface
|
|
48
|
-
{ ...props, value: dateValue, onChange: handleKeyboardChange },
|
|
49
|
-
options
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const inputProps = useMemo(
|
|
53
|
-
() => ({
|
|
54
|
-
...innerInputProps, // reuse validation and open/close logic
|
|
55
|
-
format: wrapperProps.format,
|
|
56
|
-
inputValue: inputValue || innerInputValue,
|
|
57
|
-
onChange: (value: string | null) => {
|
|
58
|
-
setInnerInputValue(value || '');
|
|
59
|
-
const date = value === null ? null : utils.parse(value, wrapperProps.format);
|
|
60
|
-
|
|
61
|
-
onChange(date, value);
|
|
62
|
-
},
|
|
63
|
-
}),
|
|
64
|
-
[innerInputProps, innerInputValue, inputValue, onChange, utils, wrapperProps.format]
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
inputProps,
|
|
69
|
-
wrapperProps,
|
|
70
|
-
pickerProps,
|
|
71
|
-
};
|
|
72
|
-
}
|