@docsvision/material-ui-pickers 3.2.0-beta.24 → 3.2.0-beta.26
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/.size-snapshot.json +11 -11
- package/9db1cba1a61cb58db53f38425bbd1f95.7z +0 -0
- package/build/DatePicker/DatePicker.d.ts +2 -2
- package/build/DatePicker/DatePicker.js +1 -1
- package/build/DateTimePicker/DateTimePicker.js +1 -1
- package/build/Picker/Picker.js +1 -1
- package/build/TimePicker/TimePicker.js +1 -1
- package/build/_helpers/text-field-helper.d.ts +1 -1
- package/build/_shared/KeyboardDateInput.js +1 -1
- package/build/_shared/ModalDialog.d.ts +2 -2
- package/build/_shared/PureDateInput.js +1 -1
- package/build/_shared/ToolbarButton.d.ts +2 -2
- package/build/_shared/hooks/useKeyboardPickerState.js +2 -2
- package/build/constants/prop-types.js +2 -2
- package/build/dist/material-ui-pickers.esm.js +12 -12
- package/build/dist/material-ui-pickers.esm.js.map +1 -1
- package/build/dist/material-ui-pickers.js +62 -62
- package/build/dist/material-ui-pickers.js.map +1 -1
- package/build/dist/material-ui-pickers.umd.js +5790 -4511
- package/build/dist/material-ui-pickers.umd.min.js +1 -1
- package/build/package.json +1 -1
- package/build/views/Calendar/Calendar.js +2 -2
- package/build/views/Clock/Clock.d.ts +1 -1
- package/build/views/Clock/ClockPointer.d.ts +1 -1
- package/package.json +1 -1
- package/src/DatePicker/DatePicker.tsx +91 -0
- package/src/DatePicker/DatePickerToolbar.tsx +75 -0
- package/src/DatePicker/index.ts +7 -0
- package/src/DateTimePicker/DateTimePicker.tsx +72 -0
- package/src/DateTimePicker/DateTimePickerTabs.tsx +86 -0
- package/src/DateTimePicker/DateTimePickerToolbar.tsx +123 -0
- package/src/DateTimePicker/index.ts +7 -0
- package/src/MuiPickersUtilsProvider.tsx +39 -0
- package/src/Picker/Picker.tsx +275 -0
- package/src/Picker/WrappedKeyboardPicker.tsx +136 -0
- package/src/Picker/WrappedPurePicker.tsx +128 -0
- package/src/Rifm/Rifm.ts +213 -0
- package/src/TimePicker/TimePicker.tsx +67 -0
- package/src/TimePicker/TimePickerToolbar.tsx +180 -0
- package/src/TimePicker/index.tsx +7 -0
- package/src/__tests__/DatePicker/Calendar.test.tsx +51 -0
- package/src/__tests__/DatePicker/Month.test.tsx +36 -0
- package/src/__tests__/DatePicker/MonthSelection.test.tsx +37 -0
- package/src/__tests__/MuiPickersUtilsProvider.test.tsx +21 -0
- package/src/__tests__/TimePicker/Clock.test.tsx +68 -0
- package/src/__tests__/_helpers/date-utils.test.tsx +197 -0
- package/src/__tests__/_helpers/text-field-helper.test.tsx +34 -0
- package/src/__tests__/_shared/ModalDialog.test.tsx +109 -0
- package/src/__tests__/e2e/DatePicker.test.tsx +233 -0
- package/src/__tests__/e2e/DatePickerProps.test.tsx +18 -0
- package/src/__tests__/e2e/DatePickerRoot.test.tsx +154 -0
- package/src/__tests__/e2e/DateTimePicker.test.tsx +86 -0
- package/src/__tests__/e2e/DateTimePickerRoot.test.tsx +72 -0
- package/src/__tests__/e2e/KeyboardDatePicker.test.tsx +140 -0
- package/src/__tests__/e2e/KeyboardDateTimePicker.test.tsx +48 -0
- package/src/__tests__/e2e/Theme.test.tsx +30 -0
- package/src/__tests__/e2e/TimePicker.test.tsx +121 -0
- package/src/__tests__/e2e/commands.tsx +8 -0
- package/src/__tests__/setup.js +26 -0
- package/src/__tests__/test-utils.tsx +45 -0
- package/src/__tests__/tsconfig.json +5 -0
- package/src/_helpers/date-utils.ts +92 -0
- package/src/_helpers/text-field-helper.ts +239 -0
- package/src/_helpers/time-utils.ts +83 -0
- package/src/_helpers/utils.ts +8 -0
- package/src/_shared/KeyboardDateInput.tsx +161 -0
- package/src/_shared/ModalDialog.tsx +114 -0
- package/src/_shared/PickerToolbar.tsx +52 -0
- package/src/_shared/PureDateInput.tsx +45 -0
- package/src/_shared/ToolbarButton.tsx +63 -0
- package/src/_shared/ToolbarText.tsx +49 -0
- package/src/_shared/WithUtils.tsx +19 -0
- package/src/_shared/hooks/useIsLandscape.tsx +27 -0
- package/src/_shared/hooks/useKeyDown.ts +34 -0
- package/src/_shared/hooks/useKeyboardPickerState.ts +72 -0
- package/src/_shared/hooks/useOpenState.ts +22 -0
- package/src/_shared/hooks/usePickerState.ts +134 -0
- package/src/_shared/hooks/useUtils.ts +20 -0
- package/src/_shared/hooks/useViews.tsx +31 -0
- package/src/_shared/icons/ArrowLeftIcon.tsx +11 -0
- package/src/_shared/icons/ArrowRightIcon.tsx +11 -0
- package/src/_shared/icons/DateRangeIcon.tsx +11 -0
- package/src/_shared/icons/KeyboardIcon.tsx +11 -0
- package/src/_shared/icons/TimeIcon.tsx +12 -0
- package/src/constants/ClockType.ts +11 -0
- package/src/constants/dimensions.ts +5 -0
- package/src/constants/prop-types.ts +37 -0
- package/src/index.ts +48 -0
- package/src/typings/BasePicker.tsx +60 -0
- package/src/typings/date.ts +3 -0
- package/src/typings/extendMui.ts +10 -0
- package/src/typings/overrides.ts +44 -0
- package/src/views/Calendar/Calendar.tsx +361 -0
- package/src/views/Calendar/CalendarHeader.tsx +141 -0
- package/src/views/Calendar/Day.tsx +97 -0
- package/src/views/Calendar/DayWrapper.tsx +33 -0
- package/src/views/Calendar/SlideTransition.tsx +100 -0
- package/src/views/Clock/Clock.tsx +172 -0
- package/src/views/Clock/ClockNumber.tsx +91 -0
- package/src/views/Clock/ClockNumbers.tsx +76 -0
- package/src/views/Clock/ClockPointer.tsx +104 -0
- package/src/views/Clock/ClockView.tsx +105 -0
- package/src/views/Month/Month.tsx +76 -0
- package/src/views/Month/MonthView.tsx +94 -0
- package/src/views/Year/Year.tsx +77 -0
- package/src/views/Year/YearView.tsx +91 -0
- package/src/wrappers/InlineWrapper.tsx +80 -0
- package/src/wrappers/ModalWrapper.tsx +113 -0
- package/src/wrappers/StaticWrapper.tsx +22 -0
- package/src/wrappers/Wrapper.tsx +75 -0
- package/coverage/clover.xml +0 -601
- package/coverage/coverage-final.json +0 -22
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/index.html +0 -201
- 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/MuiPickersUtilsProvider.tsx.html +0 -186
- package/coverage/lcov-report/src/_helpers/date-utils.ts.html +0 -345
- package/coverage/lcov-report/src/_helpers/index.html +0 -123
- 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/ModalDialog.tsx.html +0 -411
- package/coverage/lcov-report/src/_shared/WithUtils.tsx.html +0 -126
- package/coverage/lcov-report/src/_shared/hooks/index.html +0 -110
- package/coverage/lcov-report/src/_shared/hooks/useKeyDown.ts.html +0 -171
- package/coverage/lcov-report/src/_shared/hooks/useUtils.ts.html +0 -129
- 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/index.html +0 -110
- package/coverage/lcov-report/src/_shared/index.html +0 -110
- 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 -110
- package/coverage/lcov-report/src/index.html +0 -97
- package/coverage/lcov-report/src/views/Calendar/Calendar.tsx.html +0 -1152
- 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/ClockPointer.tsx.html +0 -381
- package/coverage/lcov-report/src/views/Clock/index.html +0 -110
- 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.info +0 -1094
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PropTypes from 'prop-types';
|
|
3
|
+
import ModalDialog from '../_shared/ModalDialog';
|
|
4
|
+
import { Omit } from '@material-ui/core';
|
|
5
|
+
import { WrapperProps } from './Wrapper';
|
|
6
|
+
import { useKeyDown } from '../_shared/hooks/useKeyDown';
|
|
7
|
+
import { DialogProps as MuiDialogProps } from '@material-ui/core/Dialog';
|
|
8
|
+
|
|
9
|
+
export interface ModalWrapperProps<T = {}> extends WrapperProps<T> {
|
|
10
|
+
/**
|
|
11
|
+
* "OK" label message
|
|
12
|
+
* @default "OK"
|
|
13
|
+
*/
|
|
14
|
+
okLabel?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* "CANCEL" label message
|
|
17
|
+
* @default "CANCEL"
|
|
18
|
+
*/
|
|
19
|
+
cancelLabel?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* "CLEAR" label message
|
|
22
|
+
* @default "CLEAR"
|
|
23
|
+
*/
|
|
24
|
+
clearLabel?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* "TODAY" label message
|
|
27
|
+
* @default "TODAY"
|
|
28
|
+
*/
|
|
29
|
+
todayLabel?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* If true today button will be displayed <b>Note*</b> that clear button has higher priority
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
showTodayButton?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Show clear action in picker dialog
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
clearable?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Props to be passed directly to material-ui Dialog
|
|
42
|
+
* @type {Partial<MuiDialogProps>}
|
|
43
|
+
*/
|
|
44
|
+
DialogProps?: Partial<Omit<MuiDialogProps, 'classes'>>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const ModalWrapper: React.FC<ModalWrapperProps<any>> = ({
|
|
48
|
+
open,
|
|
49
|
+
children,
|
|
50
|
+
okLabel,
|
|
51
|
+
cancelLabel,
|
|
52
|
+
clearLabel,
|
|
53
|
+
todayLabel,
|
|
54
|
+
showTodayButton,
|
|
55
|
+
clearable,
|
|
56
|
+
DialogProps,
|
|
57
|
+
showTabs,
|
|
58
|
+
wider,
|
|
59
|
+
InputComponent,
|
|
60
|
+
DateInputProps,
|
|
61
|
+
onClear,
|
|
62
|
+
onAccept,
|
|
63
|
+
onDismiss,
|
|
64
|
+
onSetToday,
|
|
65
|
+
...other
|
|
66
|
+
}) => {
|
|
67
|
+
useKeyDown(open, {
|
|
68
|
+
Enter: onAccept,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<React.Fragment>
|
|
73
|
+
<InputComponent {...other} {...DateInputProps} />
|
|
74
|
+
|
|
75
|
+
<ModalDialog
|
|
76
|
+
wider={wider}
|
|
77
|
+
showTabs={showTabs}
|
|
78
|
+
open={open}
|
|
79
|
+
onClear={onClear}
|
|
80
|
+
onAccept={onAccept}
|
|
81
|
+
onDismiss={onDismiss}
|
|
82
|
+
onSetToday={onSetToday}
|
|
83
|
+
clearLabel={clearLabel}
|
|
84
|
+
todayLabel={todayLabel}
|
|
85
|
+
okLabel={okLabel}
|
|
86
|
+
cancelLabel={cancelLabel}
|
|
87
|
+
clearable={clearable}
|
|
88
|
+
showTodayButton={showTodayButton}
|
|
89
|
+
children={children}
|
|
90
|
+
{...DialogProps}
|
|
91
|
+
/>
|
|
92
|
+
</React.Fragment>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
ModalWrapper.propTypes = {
|
|
97
|
+
okLabel: PropTypes.node,
|
|
98
|
+
cancelLabel: PropTypes.node,
|
|
99
|
+
clearLabel: PropTypes.node,
|
|
100
|
+
clearable: PropTypes.bool,
|
|
101
|
+
todayLabel: PropTypes.node,
|
|
102
|
+
showTodayButton: PropTypes.bool,
|
|
103
|
+
DialogProps: PropTypes.object,
|
|
104
|
+
} as any;
|
|
105
|
+
|
|
106
|
+
ModalWrapper.defaultProps = {
|
|
107
|
+
okLabel: 'OK',
|
|
108
|
+
cancelLabel: 'Cancel',
|
|
109
|
+
clearLabel: 'Clear',
|
|
110
|
+
todayLabel: 'Today',
|
|
111
|
+
clearable: false,
|
|
112
|
+
showTodayButton: false,
|
|
113
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { makeStyles } from '@material-ui/core';
|
|
3
|
+
import { DIALOG_WIDTH } from '../constants/dimensions';
|
|
4
|
+
|
|
5
|
+
const useStyles = makeStyles(
|
|
6
|
+
theme => ({
|
|
7
|
+
staticWrapperRoot: {
|
|
8
|
+
overflow: 'hidden',
|
|
9
|
+
minWidth: DIALOG_WIDTH,
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'column',
|
|
12
|
+
backgroundColor: theme.palette.background.paper,
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
15
|
+
{ name: 'MuiPickersStaticWrapper' }
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export const StaticWrapper: React.FC = ({ children }) => {
|
|
19
|
+
const classes = useStyles();
|
|
20
|
+
|
|
21
|
+
return <div className={classes.staticWrapperRoot} children={children} />;
|
|
22
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Omit } from '@material-ui/core';
|
|
3
|
+
import { StaticWrapper } from './StaticWrapper';
|
|
4
|
+
import { PureDateInputProps } from '../_shared/PureDateInput';
|
|
5
|
+
import { ModalWrapper, ModalWrapperProps } from './ModalWrapper';
|
|
6
|
+
import { InlineWrapper, InlineWrapperProps } from './InlineWrapper';
|
|
7
|
+
import { KeyboardDateInputProps } from '../_shared/KeyboardDateInput';
|
|
8
|
+
|
|
9
|
+
export type WrapperVariant = 'dialog' | 'inline' | 'static';
|
|
10
|
+
|
|
11
|
+
export interface WrapperProps<T> {
|
|
12
|
+
open: boolean;
|
|
13
|
+
onAccept: () => void;
|
|
14
|
+
onDismiss: () => void;
|
|
15
|
+
onClear: () => void;
|
|
16
|
+
onSetToday: () => void;
|
|
17
|
+
InputComponent: React.FC<T>;
|
|
18
|
+
DateInputProps: T;
|
|
19
|
+
wider?: boolean;
|
|
20
|
+
showTabs?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type OmitInnerWrapperProps<T extends WrapperProps<any>> = Omit<
|
|
24
|
+
T,
|
|
25
|
+
keyof WrapperProps<any> | 'showTabs'
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
export type ModalRoot = OmitInnerWrapperProps<ModalWrapperProps>;
|
|
29
|
+
|
|
30
|
+
export type InlineRoot = OmitInnerWrapperProps<InlineWrapperProps>;
|
|
31
|
+
|
|
32
|
+
// prettier-ignore
|
|
33
|
+
export type ExtendWrapper<TInput extends PureDateInputProps | KeyboardDateInputProps> = {
|
|
34
|
+
/**
|
|
35
|
+
* Picker container option
|
|
36
|
+
* @default 'dialog'
|
|
37
|
+
*/
|
|
38
|
+
variant?: WrapperVariant
|
|
39
|
+
} & ModalRoot
|
|
40
|
+
& InlineRoot
|
|
41
|
+
& Omit<TInput, 'inputValue' | 'onChange' | 'format' | 'validationError' | 'format' | 'forwardedRef'>
|
|
42
|
+
|
|
43
|
+
export function getWrapperFromVariant<T>(
|
|
44
|
+
variant?: WrapperVariant
|
|
45
|
+
): React.ComponentType<InlineWrapperProps<T> | ModalWrapperProps<T>> {
|
|
46
|
+
switch (variant) {
|
|
47
|
+
case 'inline':
|
|
48
|
+
return InlineWrapper as any;
|
|
49
|
+
|
|
50
|
+
case 'static':
|
|
51
|
+
return StaticWrapper as any;
|
|
52
|
+
|
|
53
|
+
default:
|
|
54
|
+
return ModalWrapper as any;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type Props<T> = {
|
|
59
|
+
variant?: WrapperVariant;
|
|
60
|
+
children?: React.ReactChild;
|
|
61
|
+
} & (ModalWrapperProps<T> | InlineWrapperProps<T>);
|
|
62
|
+
|
|
63
|
+
export const VariantContext = React.createContext<WrapperVariant | null>(null);
|
|
64
|
+
|
|
65
|
+
export const Wrapper: <T extends KeyboardDateInputProps | PureDateInputProps>(
|
|
66
|
+
p: Props<T>
|
|
67
|
+
) => React.ReactElement<Props<T>> = ({ variant, ...props }) => {
|
|
68
|
+
const Component = getWrapperFromVariant<typeof props.DateInputProps>(variant);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<VariantContext.Provider value={variant || 'dialog'}>
|
|
72
|
+
<Component {...props} />
|
|
73
|
+
</VariantContext.Provider>
|
|
74
|
+
);
|
|
75
|
+
};
|