@docsvision/material-ui-pickers 3.2.0-beta.26 → 3.2.0-beta.27
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/package.json +62 -135
- package/.size-snapshot.json +0 -26
- package/9db1cba1a61cb58db53f38425bbd1f95.7z +0 -0
- package/build/package.json +0 -62
- package/copy.js +0 -58
- package/remove-prop-types.js +0 -37
- package/rollup.config.js +0 -145
- 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 -275
- package/src/Picker/WrappedKeyboardPicker.tsx +0 -136
- package/src/Picker/WrappedPurePicker.tsx +0 -128
- package/src/Rifm/Rifm.ts +0 -213
- 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 -239
- package/src/_helpers/time-utils.ts +0 -83
- package/src/_helpers/utils.ts +0 -8
- package/src/_shared/KeyboardDateInput.tsx +0 -161
- 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 -134
- 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 -60
- package/src/typings/date.ts +0 -3
- package/src/typings/extendMui.ts +0 -10
- package/src/typings/overrides.ts +0 -44
- package/src/views/Calendar/Calendar.tsx +0 -361
- 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}/DatePicker.d.ts +0 -0
- /package/{build/DatePicker → DatePicker}/DatePicker.js +0 -0
- /package/{build/DatePicker → DatePicker}/DatePickerToolbar.d.ts +0 -0
- /package/{build/DatePicker → DatePicker}/DatePickerToolbar.js +0 -0
- /package/{build/DatePicker → DatePicker}/index.d.ts +0 -0
- /package/{build/DatePicker → DatePicker}/index.js +0 -0
- /package/{build/DateTimePicker → DateTimePicker}/DateTimePicker.d.ts +0 -0
- /package/{build/DateTimePicker → DateTimePicker}/DateTimePicker.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}/DateTimePickerToolbar.js +0 -0
- /package/{build/DateTimePicker → DateTimePicker}/index.d.ts +0 -0
- /package/{build/DateTimePicker → DateTimePicker}/index.js +0 -0
- /package/{build/MuiPickersUtilsProvider.d.ts → MuiPickersUtilsProvider.d.ts} +0 -0
- /package/{build/MuiPickersUtilsProvider.js → MuiPickersUtilsProvider.js} +0 -0
- /package/{build/Picker → Picker}/Picker.d.ts +0 -0
- /package/{build/Picker → Picker}/Picker.js +0 -0
- /package/{build/Picker → Picker}/WrappedKeyboardPicker.d.ts +0 -0
- /package/{build/Picker → Picker}/WrappedKeyboardPicker.js +0 -0
- /package/{build/Picker → Picker}/WrappedPurePicker.d.ts +0 -0
- /package/{build/Picker → Picker}/WrappedPurePicker.js +0 -0
- /package/{build/README.md → README.md} +0 -0
- /package/{build/Rifm → Rifm}/Rifm.d.ts +0 -0
- /package/{build/Rifm → Rifm}/Rifm.js +0 -0
- /package/{build/TimePicker → TimePicker}/TimePicker.d.ts +0 -0
- /package/{build/TimePicker → TimePicker}/TimePicker.js +0 -0
- /package/{build/TimePicker → TimePicker}/TimePickerToolbar.d.ts +0 -0
- /package/{build/TimePicker → TimePicker}/TimePickerToolbar.js +0 -0
- /package/{build/TimePicker → TimePicker}/index.d.ts +0 -0
- /package/{build/TimePicker → TimePicker}/index.js +0 -0
- /package/{build/_helpers → _helpers}/date-utils.d.ts +0 -0
- /package/{build/_helpers → _helpers}/date-utils.js +0 -0
- /package/{build/_helpers → _helpers}/text-field-helper.d.ts +0 -0
- /package/{build/_helpers → _helpers}/text-field-helper.js +0 -0
- /package/{build/_helpers → _helpers}/time-utils.d.ts +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}/KeyboardDateInput.d.ts +0 -0
- /package/{build/_shared → _shared}/KeyboardDateInput.js +0 -0
- /package/{build/_shared → _shared}/ModalDialog.d.ts +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}/PureDateInput.js +0 -0
- /package/{build/_shared → _shared}/ToolbarButton.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.d.ts +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/useIsLandscape.js +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/useKeyboardPickerState.d.ts +0 -0
- /package/{build/_shared → _shared}/hooks/useKeyboardPickerState.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/usePickerState.d.ts +0 -0
- /package/{build/_shared → _shared}/hooks/usePickerState.js +0 -0
- /package/{build/_shared → _shared}/hooks/useUtils.d.ts +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/constants → constants}/prop-types.js +0 -0
- /package/{build/dist → dist}/material-ui-pickers.esm.js +0 -0
- /package/{build/dist → dist}/material-ui-pickers.esm.js.map +0 -0
- /package/{build/dist → dist}/material-ui-pickers.js +0 -0
- /package/{build/dist → dist}/material-ui-pickers.js.map +0 -0
- /package/{build/dist → dist}/material-ui-pickers.umd.js +0 -0
- /package/{build/dist → dist}/material-ui-pickers.umd.min.js +0 -0
- /package/{build/index.d.ts → index.d.ts} +0 -0
- /package/{build/index.js → index.js} +0 -0
- /package/{build/typings → typings}/BasePicker.d.ts +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.d.ts +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/Calendar.js +0 -0
- /package/{build/views → views}/Calendar/CalendarHeader.d.ts +0 -0
- /package/{build/views → views}/Calendar/CalendarHeader.js +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/Clock.d.ts +0 -0
- /package/{build/views → views}/Clock/Clock.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.d.ts +0 -0
- /package/{build/views → views}/Clock/ClockNumbers.js +0 -0
- /package/{build/views → views}/Clock/ClockPointer.d.ts +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}/Clock/ClockView.js +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}/Month/MonthView.js +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/views → views}/Year/YearView.js +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,239 +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
|
-
const replaceAt = (str: string, index: number, replacement: string) => {
|
|
8
|
-
replacement = replacement || '';
|
|
9
|
-
return str.substr(0, index) + replacement + str.substr(index + replacement.length);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const getDisplayDate = (
|
|
13
|
-
value: ParsableDate,
|
|
14
|
-
format: string,
|
|
15
|
-
utils: IUtils<any>,
|
|
16
|
-
isEmpty: boolean,
|
|
17
|
-
{ invalidLabel, emptyLabel, labelFunc }: Omit<BasePickerProps, 'value' | 'onChange'>
|
|
18
|
-
) => {
|
|
19
|
-
const date = utils.date(value);
|
|
20
|
-
if (labelFunc) {
|
|
21
|
-
return labelFunc(isEmpty ? null : date, invalidLabel!);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (isEmpty) {
|
|
25
|
-
return emptyLabel || '';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return utils.isValid(date) ? utils.format(date, format) : invalidLabel!;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export interface BaseValidationProps {
|
|
32
|
-
/**
|
|
33
|
-
* Message, appearing when date cannot be parsed
|
|
34
|
-
* @default 'Invalid Date Format'
|
|
35
|
-
*/
|
|
36
|
-
invalidDateMessage?: React.ReactNode;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface DateValidationProps extends BaseValidationProps {
|
|
40
|
-
/**
|
|
41
|
-
* Error message, shown if date is less then minimal date
|
|
42
|
-
* @default 'Date should not be before minimal date'
|
|
43
|
-
*/
|
|
44
|
-
minDateMessage?: React.ReactNode;
|
|
45
|
-
/**
|
|
46
|
-
* Error message, shown if date is more then maximal date
|
|
47
|
-
* @default 'Date should not be after maximal date'
|
|
48
|
-
*/
|
|
49
|
-
maxDateMessage?: React.ReactNode;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const getComparisonMaxDate = (utils: IUtils<any>, strictCompareDates: boolean, date: Date) => {
|
|
53
|
-
if (strictCompareDates) {
|
|
54
|
-
return date;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return utils.endOfDay(date);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const getComparisonMinDate = (utils: IUtils<any>, strictCompareDates: boolean, date: Date) => {
|
|
61
|
-
if (strictCompareDates) {
|
|
62
|
-
return date;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return utils.startOfDay(date);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const validate = (
|
|
69
|
-
value: ParsableDate,
|
|
70
|
-
utils: IUtils<any>,
|
|
71
|
-
{
|
|
72
|
-
maxDate,
|
|
73
|
-
minDate,
|
|
74
|
-
disablePast,
|
|
75
|
-
disableFuture,
|
|
76
|
-
maxDateMessage,
|
|
77
|
-
minDateMessage,
|
|
78
|
-
invalidDateMessage,
|
|
79
|
-
strictCompareDates,
|
|
80
|
-
}: Omit<DatePickerProps, 'views' | 'openTo'> // DateTimePicker doesn't support
|
|
81
|
-
): React.ReactNode => {
|
|
82
|
-
const parsedValue = utils.date(value);
|
|
83
|
-
|
|
84
|
-
// if null - do not show error
|
|
85
|
-
if (value === null) {
|
|
86
|
-
return '';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (!utils.isValid(value)) {
|
|
90
|
-
return invalidDateMessage;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
maxDate &&
|
|
95
|
-
utils.isAfter(
|
|
96
|
-
parsedValue,
|
|
97
|
-
getComparisonMaxDate(utils, !!strictCompareDates, utils.date(maxDate))
|
|
98
|
-
)
|
|
99
|
-
) {
|
|
100
|
-
return maxDateMessage;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (
|
|
104
|
-
disableFuture &&
|
|
105
|
-
utils.isAfter(parsedValue, getComparisonMaxDate(utils, !!strictCompareDates, utils.date()))
|
|
106
|
-
) {
|
|
107
|
-
return maxDateMessage;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
minDate &&
|
|
112
|
-
utils.isBefore(
|
|
113
|
-
parsedValue,
|
|
114
|
-
getComparisonMinDate(utils, !!strictCompareDates, utils.date(minDate))
|
|
115
|
-
)
|
|
116
|
-
) {
|
|
117
|
-
return minDateMessage;
|
|
118
|
-
}
|
|
119
|
-
if (
|
|
120
|
-
disablePast &&
|
|
121
|
-
utils.isBefore(parsedValue, getComparisonMinDate(utils, !!strictCompareDates, utils.date()))
|
|
122
|
-
) {
|
|
123
|
-
return minDateMessage;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return '';
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export function pick12hOr24hFormat(
|
|
130
|
-
userFormat: string | undefined,
|
|
131
|
-
ampm: boolean | undefined = true,
|
|
132
|
-
formats: { '12h': string; '24h': string }
|
|
133
|
-
) {
|
|
134
|
-
if (userFormat) {
|
|
135
|
-
return userFormat;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return ampm ? formats['12h'] : formats['24h'];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export function makeMaskFromFormat(format: string, numberMaskChar: string) {
|
|
142
|
-
return format.replace(/[a-z]/gi, numberMaskChar);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export const maskedDateFormatter = (mask: string, numberMaskChar: string) => (
|
|
146
|
-
value: string,
|
|
147
|
-
oldValue: string,
|
|
148
|
-
currentCaretPosition?: number
|
|
149
|
-
) => {
|
|
150
|
-
const refuse = /[^\d\w_]+/gi;
|
|
151
|
-
|
|
152
|
-
if (!value || value === '') {
|
|
153
|
-
return value;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (!oldValue) {
|
|
157
|
-
oldValue = '';
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (value == oldValue) {
|
|
161
|
-
return value;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (value.length < oldValue.length && currentCaretPosition != null) {
|
|
165
|
-
value =
|
|
166
|
-
value.slice(0, currentCaretPosition) +
|
|
167
|
-
'_' +
|
|
168
|
-
value.slice(currentCaretPosition, oldValue.length);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
let refusedOldValue = oldValue.replace(refuse, '');
|
|
172
|
-
let refusedNewValue = value.replace(refuse, '');
|
|
173
|
-
let refusedMaskSymbols = mask.replace(refuse, '');
|
|
174
|
-
|
|
175
|
-
const minLength =
|
|
176
|
-
refusedOldValue.length > refusedNewValue.length
|
|
177
|
-
? refusedNewValue.length
|
|
178
|
-
: refusedOldValue.length;
|
|
179
|
-
|
|
180
|
-
let startPos = 0;
|
|
181
|
-
let endPosShift = 0;
|
|
182
|
-
while (startPos < minLength) {
|
|
183
|
-
if (refusedNewValue[startPos] == refusedOldValue[startPos]) {
|
|
184
|
-
startPos++;
|
|
185
|
-
} else {
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
while (
|
|
191
|
-
endPosShift < minLength &&
|
|
192
|
-
startPos < refusedNewValue.length - endPosShift &&
|
|
193
|
-
startPos < refusedOldValue.length - endPosShift
|
|
194
|
-
) {
|
|
195
|
-
if (
|
|
196
|
-
refusedNewValue[refusedNewValue.length - endPosShift - 1] ==
|
|
197
|
-
refusedOldValue[refusedOldValue.length - endPosShift - 1]
|
|
198
|
-
) {
|
|
199
|
-
endPosShift++;
|
|
200
|
-
} else {
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
let endStartPos = refusedNewValue.length - endPosShift;
|
|
206
|
-
endStartPos = endStartPos < startPos ? startPos : endStartPos;
|
|
207
|
-
|
|
208
|
-
let firstPart = refusedNewValue.slice(0, startPos);
|
|
209
|
-
let addedPart = refusedNewValue.slice(startPos, endStartPos);
|
|
210
|
-
let endPart = refusedNewValue.slice(endStartPos, refusedNewValue.length);
|
|
211
|
-
|
|
212
|
-
let maxSymbolsInEnd = refusedMaskSymbols.length - firstPart.length - addedPart.length;
|
|
213
|
-
while (maxSymbolsInEnd > endPart.length) {
|
|
214
|
-
addedPart += numberMaskChar;
|
|
215
|
-
maxSymbolsInEnd--;
|
|
216
|
-
}
|
|
217
|
-
let entireRefusedString =
|
|
218
|
-
firstPart + addedPart + endPart.slice(endPart.length - maxSymbolsInEnd, endPart.length);
|
|
219
|
-
|
|
220
|
-
// Do nothing ?...
|
|
221
|
-
entireRefusedString = entireRefusedString.slice(0, refusedMaskSymbols.length);
|
|
222
|
-
|
|
223
|
-
let i = 0;
|
|
224
|
-
let n = 0;
|
|
225
|
-
let result = '';
|
|
226
|
-
while (i < mask.length) {
|
|
227
|
-
const maskChar = mask[i];
|
|
228
|
-
if (maskChar === numberMaskChar && n < entireRefusedString.length) {
|
|
229
|
-
const parsedChar = entireRefusedString[n];
|
|
230
|
-
result += parsedChar;
|
|
231
|
-
n += 1;
|
|
232
|
-
} else {
|
|
233
|
-
result += maskChar;
|
|
234
|
-
}
|
|
235
|
-
i += 1;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return result;
|
|
239
|
-
};
|
|
@@ -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,161 +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 { IconButton } from '@material-ui/core';
|
|
5
|
-
import { ExtendMui } from '../typings/extendMui';
|
|
6
|
-
import { KeyboardIcon } from './icons/KeyboardIcon';
|
|
7
|
-
import { IconButtonProps } from '@material-ui/core/IconButton';
|
|
8
|
-
import { makeMaskFromFormat, maskedDateFormatter } from '../_helpers/text-field-helper';
|
|
9
|
-
import { useState } from 'react';
|
|
10
|
-
import { Rifm } from '../Rifm/Rifm';
|
|
11
|
-
|
|
12
|
-
export interface KeyboardDateInputProps
|
|
13
|
-
extends ExtendMui<BaseTextFieldProps, 'variant' | 'onError' | 'onChange' | 'value'> {
|
|
14
|
-
format: string;
|
|
15
|
-
onChange: (value: string | null) => void;
|
|
16
|
-
onBlur?: () => void;
|
|
17
|
-
onClick?: () => void;
|
|
18
|
-
validationError?: React.ReactNode;
|
|
19
|
-
inputValue: string;
|
|
20
|
-
InputProps?: TextFieldProps['InputProps'];
|
|
21
|
-
/** Override input component */
|
|
22
|
-
TextFieldComponent?: React.ComponentType<TextFieldProps>;
|
|
23
|
-
/** Icon displaying for open picker button */
|
|
24
|
-
keyboardIcon?: React.ReactNode;
|
|
25
|
-
/** Pass material-ui text field variant down, bypass internal variant prop */
|
|
26
|
-
inputVariant?: TextFieldProps['variant'];
|
|
27
|
-
/**
|
|
28
|
-
* Custom mask. Can be used to override generate from format. (e.g. __/__/____ __:__)
|
|
29
|
-
*/
|
|
30
|
-
mask?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Char string that will be replaced with number (for "_" mask will be "__/__/____")
|
|
33
|
-
* @default '_'
|
|
34
|
-
*/
|
|
35
|
-
maskChar?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Refuse values regexp
|
|
38
|
-
* @default /[^\d]+/gi
|
|
39
|
-
*/
|
|
40
|
-
refuse?: RegExp;
|
|
41
|
-
/**
|
|
42
|
-
* Props to pass to keyboard input adornment
|
|
43
|
-
* @type {Partial<InputAdornmentProps>}
|
|
44
|
-
*/
|
|
45
|
-
InputAdornmentProps?: Partial<InputAdornmentProps>;
|
|
46
|
-
/**
|
|
47
|
-
* Props to pass to keyboard adornment button
|
|
48
|
-
* @type {Partial<IconButtonProps>}
|
|
49
|
-
*/
|
|
50
|
-
KeyboardButtonProps?: Partial<IconButtonProps>;
|
|
51
|
-
/** Custom formatter to be passed into Rifm component */
|
|
52
|
-
rifmFormatter?: (str: string) => string;
|
|
53
|
-
/**
|
|
54
|
-
* Show errors only when input blur
|
|
55
|
-
*/
|
|
56
|
-
showErrorOnBlur?: boolean;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const KeyboardDateInput: React.FunctionComponent<KeyboardDateInputProps> = ({
|
|
60
|
-
inputValue,
|
|
61
|
-
showErrorOnBlur = false,
|
|
62
|
-
inputVariant,
|
|
63
|
-
validationError,
|
|
64
|
-
KeyboardButtonProps,
|
|
65
|
-
InputAdornmentProps,
|
|
66
|
-
onClick,
|
|
67
|
-
onChange,
|
|
68
|
-
onBlur,
|
|
69
|
-
onFocus,
|
|
70
|
-
InputProps,
|
|
71
|
-
mask,
|
|
72
|
-
maskChar = '_',
|
|
73
|
-
refuse = /[^\d_]+/gi,
|
|
74
|
-
format,
|
|
75
|
-
keyboardIcon,
|
|
76
|
-
disabled,
|
|
77
|
-
rifmFormatter,
|
|
78
|
-
TextFieldComponent = TextField,
|
|
79
|
-
...other
|
|
80
|
-
}) => {
|
|
81
|
-
const inputMask = mask || makeMaskFromFormat(format, maskChar);
|
|
82
|
-
const letterPosition = format.indexOf('a');
|
|
83
|
-
// prettier-ignore
|
|
84
|
-
const formatter = React.useCallback(
|
|
85
|
-
maskedDateFormatter(inputMask, maskChar),
|
|
86
|
-
[mask, maskChar]
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const position =
|
|
90
|
-
InputAdornmentProps && InputAdornmentProps.position ? InputAdornmentProps.position : 'end';
|
|
91
|
-
|
|
92
|
-
const handleChange = (text: string) => {
|
|
93
|
-
const finalString = text === '' || text === inputMask ? null : text;
|
|
94
|
-
onChange(finalString);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const replace = (text: string): string => {
|
|
98
|
-
return text;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const [showErrorFlag, handleBlur] = useState(showErrorOnBlur ? true : false);
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<Rifm
|
|
105
|
-
value={inputValue}
|
|
106
|
-
onChange={handleChange}
|
|
107
|
-
format={rifmFormatter || formatter}
|
|
108
|
-
replace={replace}
|
|
109
|
-
mask={true}
|
|
110
|
-
maskChar={maskChar}
|
|
111
|
-
letterPosition={letterPosition}
|
|
112
|
-
>
|
|
113
|
-
{({ onChange, value }) => (
|
|
114
|
-
<TextFieldComponent
|
|
115
|
-
disabled={disabled}
|
|
116
|
-
error={Boolean(validationError) && !showErrorFlag}
|
|
117
|
-
helperText={!showErrorFlag && validationError}
|
|
118
|
-
{...other}
|
|
119
|
-
value={value}
|
|
120
|
-
onChange={onChange}
|
|
121
|
-
// onInput={changeInputStringValue}
|
|
122
|
-
// onKeyUp={handleKeyUp}
|
|
123
|
-
// onMouseUp={handleClick}
|
|
124
|
-
onBlur={() => {
|
|
125
|
-
if (onBlur) {
|
|
126
|
-
onBlur();
|
|
127
|
-
}
|
|
128
|
-
if (showErrorOnBlur) {
|
|
129
|
-
handleBlur(false);
|
|
130
|
-
}
|
|
131
|
-
}}
|
|
132
|
-
onFocus={(ev: any) => {
|
|
133
|
-
if (onFocus) {
|
|
134
|
-
onFocus(ev);
|
|
135
|
-
}
|
|
136
|
-
if (showErrorOnBlur) {
|
|
137
|
-
handleBlur(true);
|
|
138
|
-
}
|
|
139
|
-
}}
|
|
140
|
-
variant={inputVariant as any}
|
|
141
|
-
InputProps={{
|
|
142
|
-
...InputProps,
|
|
143
|
-
[`${position}Adornment`]: (
|
|
144
|
-
<InputAdornment position={position} {...InputAdornmentProps}>
|
|
145
|
-
<IconButton disabled={disabled} {...KeyboardButtonProps} onClick={onClick}>
|
|
146
|
-
{keyboardIcon}
|
|
147
|
-
</IconButton>
|
|
148
|
-
</InputAdornment>
|
|
149
|
-
),
|
|
150
|
-
}}
|
|
151
|
-
/>
|
|
152
|
-
)}
|
|
153
|
-
</Rifm>
|
|
154
|
-
);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
KeyboardDateInput.defaultProps = {
|
|
158
|
-
keyboardIcon: <KeyboardIcon />,
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
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';
|