@mui/x-date-pickers 8.0.0-alpha.1 → 8.0.0-alpha.2
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/AdapterMoment/AdapterMoment.js +10 -0
- package/CHANGELOG.md +228 -7
- package/DateCalendar/DateCalendar.types.d.ts +2 -1
- package/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/DateCalendar/PickersSlideTransition.js +12 -5
- package/DateCalendar/useCalendarState.d.ts +6 -4
- package/DateField/DateField.js +5 -4
- package/DateField/DateField.types.d.ts +10 -9
- package/DatePicker/DatePicker.types.d.ts +3 -3
- package/DatePicker/DatePickerToolbar.d.ts +3 -2
- package/DatePicker/shared.d.ts +6 -5
- package/DateTimeField/DateTimeField.js +5 -4
- package/DateTimeField/DateTimeField.types.d.ts +10 -10
- package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
- package/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/DateTimePicker/DateTimePickerToolbar.d.ts +2 -3
- package/DateTimePicker/shared.d.ts +6 -6
- package/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +2 -1
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -21
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +6 -6
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +4 -4
- package/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -4
- package/PickersLayout/PickersLayout.d.ts +7 -5
- package/PickersLayout/PickersLayout.js +22 -27
- package/PickersLayout/PickersLayout.types.d.ts +14 -15
- package/PickersLayout/usePickerLayout.d.ts +5 -4
- package/PickersLayout/usePickerLayout.js +19 -12
- package/PickersShortcuts/PickersShortcuts.d.ts +7 -6
- package/README.md +7 -4
- package/TimeField/TimeField.js +5 -4
- package/TimeField/TimeField.types.d.ts +10 -10
- package/TimePicker/TimePicker.types.d.ts +3 -3
- package/TimePicker/TimePickerToolbar.d.ts +2 -3
- package/TimePicker/shared.d.ts +6 -6
- package/hooks/useParsedFormat.d.ts +2 -2
- package/hooks/useParsedFormat.js +1 -1
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +11 -8
- package/internals/components/PickersToolbar.d.ts +3 -3
- package/internals/hooks/useClockReferenceDate.d.ts +2 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +14 -14
- package/internals/hooks/useField/useField.d.ts +3 -3
- package/internals/hooks/useField/useField.types.d.ts +45 -45
- package/internals/hooks/useField/useField.utils.d.ts +4 -3
- package/internals/hooks/useField/useFieldCharacterEditing.d.ts +6 -5
- package/internals/hooks/useField/useFieldState.d.ts +9 -8
- package/internals/hooks/useField/useFieldState.js +0 -1
- package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
- package/internals/hooks/useFieldOwnerState.d.ts +6 -0
- package/internals/hooks/useFieldOwnerState.js +12 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +11 -11
- package/internals/hooks/usePicker/usePicker.d.ts +3 -3
- package/internals/hooks/usePicker/usePicker.js +2 -8
- package/internals/hooks/usePicker/usePicker.types.d.ts +7 -7
- package/internals/hooks/usePicker/usePickerProvider.d.ts +4 -5
- package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
- package/internals/hooks/usePicker/usePickerValue.js +0 -1
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +25 -24
- package/internals/hooks/usePicker/usePickerViews.d.ts +10 -10
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +5 -6
- package/internals/hooks/useValueWithTimezone.d.ts +5 -4
- package/internals/hooks/useViews.d.ts +5 -5
- package/internals/index.d.ts +4 -2
- package/internals/index.js +1 -0
- package/internals/models/fields.d.ts +6 -1
- package/internals/models/pickers.d.ts +1 -0
- package/internals/models/pickers.js +1 -0
- package/internals/models/props/basePickerProps.d.ts +4 -3
- package/internals/models/props/time.d.ts +2 -1
- package/internals/models/props/toolbar.d.ts +2 -1
- package/internals/models/value.d.ts +9 -0
- package/internals/utils/date-utils.d.ts +1 -1
- package/internals/utils/valueManagers.d.ts +4 -3
- package/locales/nlNL.js +7 -7
- package/models/adapters.d.ts +4 -4
- package/models/fields.d.ts +19 -5
- package/models/validation.d.ts +2 -1
- package/modern/AdapterMoment/AdapterMoment.js +10 -0
- package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/modern/DateCalendar/PickersSlideTransition.js +12 -5
- package/modern/DateField/DateField.js +5 -4
- package/modern/DateTimeField/DateTimeField.js +5 -4
- package/modern/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -21
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/modern/PickersLayout/PickersLayout.js +22 -27
- package/modern/PickersLayout/usePickerLayout.js +19 -12
- package/modern/TimeField/TimeField.js +5 -4
- package/modern/hooks/useParsedFormat.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/modern/internals/hooks/useField/useFieldState.js +0 -1
- package/modern/internals/hooks/useFieldOwnerState.js +12 -0
- package/modern/internals/hooks/usePicker/usePicker.js +2 -8
- package/modern/internals/hooks/usePicker/usePickerValue.js +0 -1
- package/modern/internals/index.js +1 -0
- package/modern/internals/models/pickers.js +1 -0
- package/modern/locales/nlNL.js +7 -7
- package/modern/validation/useValidation.js +1 -1
- package/modern/validation/validateDate.js +8 -0
- package/modern/validation/validateDateTime.js +8 -0
- package/modern/validation/validateTime.js +8 -0
- package/node/AdapterMoment/AdapterMoment.js +10 -0
- package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/node/DateCalendar/PickersSlideTransition.js +12 -5
- package/node/DateField/DateField.js +5 -4
- package/node/DateTimeField/DateTimeField.js +5 -4
- package/node/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -22
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/node/PickersLayout/PickersLayout.js +22 -27
- package/node/PickersLayout/usePickerLayout.js +19 -12
- package/node/TimeField/TimeField.js +5 -4
- package/node/hooks/useParsedFormat.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/node/internals/hooks/useField/useFieldState.js +0 -1
- package/node/internals/hooks/useFieldOwnerState.js +20 -0
- package/node/internals/hooks/usePicker/usePicker.js +3 -8
- package/node/internals/index.js +7 -0
- package/node/internals/models/pickers.js +5 -0
- package/node/locales/nlNL.js +7 -7
- package/node/validation/useValidation.js +1 -1
- package/node/validation/validateDate.js +8 -0
- package/node/validation/validateDateTime.js +8 -0
- package/node/validation/validateTime.js +8 -0
- package/package.json +2 -2
- package/themeAugmentation/overrides.d.ts +1 -1
- package/themeAugmentation/props.d.ts +3 -2
- package/validation/useValidation.d.ts +7 -6
- package/validation/useValidation.js +1 -1
- package/validation/validateDate.d.ts +12 -3
- package/validation/validateDate.js +8 -0
- package/validation/validateDateTime.d.ts +12 -4
- package/validation/validateDateTime.js +8 -0
- package/validation/validateTime.d.ts +12 -3
- package/validation/validateTime.js +8 -0
- package/internals/hooks/useIsLandscape.d.ts +0 -4
- package/internals/hooks/useIsLandscape.js +0 -35
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +0 -32
- package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -31
- package/modern/internals/hooks/useIsLandscape.js +0 -35
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -31
- package/node/internals/hooks/useIsLandscape.js +0 -43
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-date-pickers",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.2",
|
|
4
4
|
"description": "The community edition of the Date and Time Picker components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"clsx": "^2.1.1",
|
|
42
42
|
"prop-types": "^15.8.1",
|
|
43
43
|
"react-transition-group": "^4.4.5",
|
|
44
|
-
"@mui/x-internals": "8.0.0-alpha.
|
|
44
|
+
"@mui/x-internals": "8.0.0-alpha.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@emotion/react": "^11.9.0",
|
|
@@ -57,13 +57,13 @@ export interface PickersComponentNameToClassKey {
|
|
|
57
57
|
MuiPickersCalendarHeader: PickersCalendarHeaderClassKey;
|
|
58
58
|
MuiPickersDay: PickersDayClassKey;
|
|
59
59
|
MuiPickersFadeTransitionGroup: PickersFadeTransitionGroupClassKey;
|
|
60
|
+
MuiPickersLayout: PickersLayoutClassKey;
|
|
60
61
|
MuiPickersMonth: PickersMonthClassKey;
|
|
61
62
|
MuiPickersPopper: PickersPopperClassKey;
|
|
62
63
|
MuiPickersSlideTransition: PickersSlideTransitionClassKey;
|
|
63
64
|
MuiPickersToolbar: PickersToolbarClassKey;
|
|
64
65
|
MuiPickersToolbarButton: PickersToolbarButtonClassKey;
|
|
65
66
|
MuiPickersToolbarText: PickersToolbarTextClassKey;
|
|
66
|
-
MuiPickersLayout: PickersLayoutClassKey;
|
|
67
67
|
MuiPickersYear: PickersYearClassKey;
|
|
68
68
|
MuiTimeClock: TimeClockClassKey;
|
|
69
69
|
MuiTimePickerToolbar: TimePickerToolbarClassKey;
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
PickersFilledInputProps,
|
|
53
53
|
} from '../PickersTextField';
|
|
54
54
|
import { PickersSectionListProps } from '../PickersSectionList';
|
|
55
|
+
import { PickerValidValue } from '../internals/models';
|
|
55
56
|
|
|
56
57
|
export interface PickersComponentsPropsList {
|
|
57
58
|
MuiClock: ClockProps;
|
|
@@ -77,10 +78,10 @@ export interface PickersComponentsPropsList {
|
|
|
77
78
|
MuiPickersMonth: ExportedPickersMonthProps;
|
|
78
79
|
MuiPickersPopper: PickerPopperProps;
|
|
79
80
|
MuiPickersSlideTransition: ExportedSlideTransitionProps;
|
|
80
|
-
MuiPickersToolbar: PickersToolbarProps<
|
|
81
|
+
MuiPickersToolbar: PickersToolbarProps<PickerValidValue, DateOrTimeView>;
|
|
81
82
|
MuiPickersToolbarButton: PickersToolbarButtonProps;
|
|
82
83
|
MuiPickersToolbarText: ExportedPickersToolbarTextProps;
|
|
83
|
-
MuiPickersLayout: PickersLayoutProps<
|
|
84
|
+
MuiPickersLayout: PickersLayoutProps<PickerValidValue, DateOrTimeView>;
|
|
84
85
|
MuiPickersYear: ExportedPickersYearProps;
|
|
85
86
|
MuiTimeClock: TimeClockProps;
|
|
86
87
|
MuiTimeField: TimeFieldProps<any>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MuiPickersAdapterContextValue } from '../LocalizationProvider/LocalizationProvider';
|
|
2
2
|
import { OnErrorProps, PickersTimezone } from '../models';
|
|
3
3
|
import type { PickerValueManager } from '../internals/hooks/usePicker';
|
|
4
|
-
|
|
4
|
+
import { PickerValidValue } from '../internals/models';
|
|
5
|
+
export type Validator<TValue extends PickerValidValue, TError, TValidationProps> = {
|
|
5
6
|
(params: {
|
|
6
7
|
adapter: MuiPickersAdapterContextValue;
|
|
7
8
|
value: TValue;
|
|
@@ -10,7 +11,7 @@ export type Validator<TValue, TError, TValidationProps> = {
|
|
|
10
11
|
}): TError;
|
|
11
12
|
valueManager: PickerValueManager<TValue, any>;
|
|
12
13
|
};
|
|
13
|
-
interface UseValidationOptions<TValue, TError, TValidationProps extends {}> extends OnErrorProps<TValue, TError> {
|
|
14
|
+
interface UseValidationOptions<TValue extends PickerValidValue, TError, TValidationProps extends {}> extends OnErrorProps<TValue, TError> {
|
|
14
15
|
/**
|
|
15
16
|
* The value to validate.
|
|
16
17
|
*/
|
|
@@ -32,7 +33,7 @@ interface UseValidationOptions<TValue, TError, TValidationProps extends {}> exte
|
|
|
32
33
|
*/
|
|
33
34
|
props: TValidationProps;
|
|
34
35
|
}
|
|
35
|
-
interface UseValidationReturnValue<TValue, TError> {
|
|
36
|
+
interface UseValidationReturnValue<TValue extends PickerValidValue, TError> {
|
|
36
37
|
/**
|
|
37
38
|
* The validation error associated to the value passed to the `useValidation` hook.
|
|
38
39
|
*/
|
|
@@ -46,7 +47,7 @@ interface UseValidationReturnValue<TValue, TError> {
|
|
|
46
47
|
/**
|
|
47
48
|
* Get the validation error for a new value.
|
|
48
49
|
* This can be used to validate the value in a change handler before updating the state.
|
|
49
|
-
* @template TValue The value type.
|
|
50
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
50
51
|
* @param {TValue} newValue The value to validate.
|
|
51
52
|
* @returns {TError} The validation error associated to the new value.
|
|
52
53
|
*/
|
|
@@ -54,7 +55,7 @@ interface UseValidationReturnValue<TValue, TError> {
|
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
56
57
|
* Utility hook to check if a given value is valid based on the provided validation props.
|
|
57
|
-
* @template TValue The value type. It will be
|
|
58
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
58
59
|
* @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
|
|
59
60
|
* @param {UseValidationOptions<TValue, TError, TValidationProps>} options The options to configure the hook.
|
|
60
61
|
* @param {TValue} options.value The value to validate.
|
|
@@ -63,5 +64,5 @@ interface UseValidationReturnValue<TValue, TError> {
|
|
|
63
64
|
* @param {TValidationProps} options.props The validation props, they differ depending on the component.
|
|
64
65
|
* @param {(error: TError, value: TValue) => void} options.onError Callback fired when the error associated with the current value changes.
|
|
65
66
|
*/
|
|
66
|
-
export declare function useValidation<TValue, TError, TValidationProps extends {}>(options: UseValidationOptions<TValue, TError, TValidationProps>): UseValidationReturnValue<TValue, TError>;
|
|
67
|
+
export declare function useValidation<TValue extends PickerValidValue, TError, TValidationProps extends {}>(options: UseValidationOptions<TValue, TError, TValidationProps>): UseValidationReturnValue<TValue, TError>;
|
|
67
68
|
export {};
|
|
@@ -5,7 +5,7 @@ import useEventCallback from '@mui/utils/useEventCallback';
|
|
|
5
5
|
import { useLocalizationContext } from "../internals/hooks/useUtils.js";
|
|
6
6
|
/**
|
|
7
7
|
* Utility hook to check if a given value is valid based on the provided validation props.
|
|
8
|
-
* @template TValue The value type. It will be
|
|
8
|
+
* @template TValue The value type. It will be the same type as `value` or `null`. It can be in `[start, end]` format in case of range value.
|
|
9
9
|
* @template TError The validation error type. It will be either `string` or a `null`. It can be in `[start, end]` format in case of range value.
|
|
10
10
|
* @param {UseValidationOptions<TValue, TError, TValidationProps>} options The options to configure the hook.
|
|
11
11
|
* @param {TValue} options.value The value to validate.
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import type { MakeRequired } from '@mui/x-internals/types';
|
|
1
2
|
import { Validator } from './useValidation';
|
|
2
3
|
import { BaseDateValidationProps, DayValidationProps, MonthValidationProps, YearValidationProps } from '../internals/models/validation';
|
|
3
|
-
import { DateValidationError
|
|
4
|
+
import { DateValidationError } from '../models';
|
|
5
|
+
import { PickerValue } from '../internals/models';
|
|
4
6
|
/**
|
|
5
7
|
* Validation props used by the Date Picker, Date Field and Date Calendar components.
|
|
6
8
|
*/
|
|
7
9
|
export interface ExportedValidateDateProps extends DayValidationProps, MonthValidationProps, YearValidationProps, BaseDateValidationProps {
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Validation props as received by the validateDate method.
|
|
13
|
+
*/
|
|
14
|
+
export interface ValidateDateProps extends MakeRequired<ExportedValidateDateProps, ValidateDatePropsToDefault> {
|
|
10
15
|
}
|
|
11
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Name of the props that should be defaulted before being passed to the validateDate method.
|
|
18
|
+
*/
|
|
19
|
+
export type ValidateDatePropsToDefault = keyof BaseDateValidationProps;
|
|
20
|
+
export declare const validateDate: Validator<PickerValue, DateValidationError, ValidateDateProps>;
|
|
@@ -5,6 +5,14 @@ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
|
5
5
|
* Validation props used by the Date Picker, Date Field and Date Calendar components.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Validation props as received by the validateDate method.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Name of the props that should be defaulted before being passed to the validateDate method.
|
|
14
|
+
*/
|
|
15
|
+
|
|
8
16
|
export const validateDate = ({
|
|
9
17
|
props,
|
|
10
18
|
value,
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { Validator } from './useValidation';
|
|
2
|
-
import { ExportedValidateDateProps, ValidateDateProps } from './validateDate';
|
|
3
|
-
import { ExportedValidateTimeProps, ValidateTimeProps } from './validateTime';
|
|
4
|
-
import { DateTimeValidationError
|
|
2
|
+
import { ExportedValidateDateProps, ValidateDateProps, ValidateDatePropsToDefault } from './validateDate';
|
|
3
|
+
import { ExportedValidateTimeProps, ValidateTimeProps, ValidateTimePropsToDefault } from './validateTime';
|
|
4
|
+
import { DateTimeValidationError } from '../models';
|
|
5
5
|
import { DateTimeValidationProps } from '../internals/models/validation';
|
|
6
|
+
import { PickerValue } from '../internals/models';
|
|
6
7
|
/**
|
|
7
8
|
* Validation props used by the Date Time Picker and Date Time Field components.
|
|
8
9
|
*/
|
|
9
10
|
export interface ExportedValidateDateTimeProps extends ExportedValidateDateProps, ExportedValidateTimeProps, DateTimeValidationProps {
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Validation props as received by the validateDateTime method.
|
|
14
|
+
*/
|
|
11
15
|
export interface ValidateDateTimeProps extends ValidateDateProps, ValidateTimeProps {
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Name of the props that should be defaulted before being passed to the validateDateTime method.
|
|
19
|
+
*/
|
|
20
|
+
export type ValidateDateTimePropsToDefault = ValidateDatePropsToDefault | ValidateTimePropsToDefault;
|
|
21
|
+
export declare const validateDateTime: Validator<PickerValue, DateTimeValidationError, ValidateDateTimeProps>;
|
|
@@ -6,6 +6,14 @@ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
|
6
6
|
* Validation props used by the Date Time Picker and Date Time Field components.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Validation props as received by the validateDateTime method.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Name of the props that should be defaulted before being passed to the validateDateTime method.
|
|
15
|
+
*/
|
|
16
|
+
|
|
9
17
|
export const validateDateTime = ({
|
|
10
18
|
adapter,
|
|
11
19
|
value,
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import type { MakeRequired } from '@mui/x-internals/types';
|
|
1
2
|
import { Validator } from './useValidation';
|
|
2
3
|
import { BaseTimeValidationProps, TimeValidationProps } from '../internals/models/validation';
|
|
3
|
-
import {
|
|
4
|
+
import { TimeValidationError } from '../models';
|
|
5
|
+
import { PickerValue } from '../internals/models';
|
|
4
6
|
/**
|
|
5
7
|
* Validation props used by the Time Picker, Time Field and Clock components.
|
|
6
8
|
*/
|
|
7
9
|
export interface ExportedValidateTimeProps extends BaseTimeValidationProps, TimeValidationProps {
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Validation props as received by the validateTime method.
|
|
13
|
+
*/
|
|
14
|
+
export interface ValidateTimeProps extends MakeRequired<ExportedValidateTimeProps, ValidateTimePropsToDefault> {
|
|
10
15
|
}
|
|
11
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Name of the props that should be defaulted before being passed to the validateTime method.
|
|
18
|
+
*/
|
|
19
|
+
export type ValidateTimePropsToDefault = keyof BaseTimeValidationProps;
|
|
20
|
+
export declare const validateTime: Validator<PickerValue, TimeValidationError, ValidateTimeProps>;
|
|
@@ -5,6 +5,14 @@ import { singleItemValueManager } from "../internals/utils/valueManagers.js";
|
|
|
5
5
|
* Validation props used by the Time Picker, Time Field and Clock components.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Validation props as received by the validateTime method.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Name of the props that should be defaulted before being passed to the validateTime method.
|
|
14
|
+
*/
|
|
15
|
+
|
|
8
16
|
export const validateTime = ({
|
|
9
17
|
adapter,
|
|
10
18
|
value,
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
3
|
-
import { arrayIncludes } from "../utils/utils.js";
|
|
4
|
-
function getOrientation() {
|
|
5
|
-
if (typeof window === 'undefined') {
|
|
6
|
-
return 'portrait';
|
|
7
|
-
}
|
|
8
|
-
if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
|
|
9
|
-
return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Support IOS safari
|
|
13
|
-
if (window.orientation) {
|
|
14
|
-
return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';
|
|
15
|
-
}
|
|
16
|
-
return 'portrait';
|
|
17
|
-
}
|
|
18
|
-
export const useIsLandscape = (views, customOrientation) => {
|
|
19
|
-
const [orientation, setOrientation] = React.useState(getOrientation);
|
|
20
|
-
useEnhancedEffect(() => {
|
|
21
|
-
const eventHandler = () => {
|
|
22
|
-
setOrientation(getOrientation());
|
|
23
|
-
};
|
|
24
|
-
window.addEventListener('orientationchange', eventHandler);
|
|
25
|
-
return () => {
|
|
26
|
-
window.removeEventListener('orientationchange', eventHandler);
|
|
27
|
-
};
|
|
28
|
-
}, []);
|
|
29
|
-
if (arrayIncludes(views, ['hours', 'minutes', 'seconds'])) {
|
|
30
|
-
// could not display 13:34:44 in landscape mode
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
const orientationToUse = customOrientation || orientation;
|
|
34
|
-
return orientationToUse === 'landscape';
|
|
35
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { UsePickerValueLayoutResponse } from './usePickerValue.types';
|
|
2
|
-
import { UsePickerViewsLayoutResponse } from './usePickerViews';
|
|
3
|
-
import { DateOrTimeViewWithMeridiem, PickerVariant } from '../../models/common';
|
|
4
|
-
/**
|
|
5
|
-
* Props used to create the layout of the views.
|
|
6
|
-
*/
|
|
7
|
-
interface UsePickerLayoutProps {
|
|
8
|
-
/**
|
|
9
|
-
* Force rendering in particular orientation.
|
|
10
|
-
*/
|
|
11
|
-
orientation?: 'portrait' | 'landscape';
|
|
12
|
-
}
|
|
13
|
-
export interface UsePickerLayoutPropsResponseLayoutProps<TValue, TView extends DateOrTimeViewWithMeridiem> extends UsePickerValueLayoutResponse<TValue>, UsePickerViewsLayoutResponse<TView>, UsePickerLayoutProps {
|
|
14
|
-
isLandscape: boolean;
|
|
15
|
-
isRtl: boolean;
|
|
16
|
-
wrapperVariant: PickerVariant;
|
|
17
|
-
isValid: (value: TValue) => boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface UsePickerLayoutPropsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
20
|
-
layoutProps: UsePickerLayoutPropsResponseLayoutProps<TValue, TView>;
|
|
21
|
-
}
|
|
22
|
-
export interface UsePickerLayoutPropsParams<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
23
|
-
props: UsePickerLayoutProps;
|
|
24
|
-
propsFromPickerValue: UsePickerValueLayoutResponse<TValue>;
|
|
25
|
-
propsFromPickerViews: UsePickerViewsLayoutResponse<TView>;
|
|
26
|
-
variant: PickerVariant;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
30
|
-
*/
|
|
31
|
-
export declare const usePickerLayoutProps: <TValue, TView extends DateOrTimeViewWithMeridiem>({ props, propsFromPickerValue, propsFromPickerViews, variant, }: UsePickerLayoutPropsParams<TValue, TView>) => UsePickerLayoutPropsResponse<TValue, TView>;
|
|
32
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { useRtl } from '@mui/system/RtlProvider';
|
|
3
|
-
import { useIsLandscape } from "../useIsLandscape.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Props used to create the layout of the views.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
11
|
-
*/
|
|
12
|
-
export const usePickerLayoutProps = ({
|
|
13
|
-
props,
|
|
14
|
-
propsFromPickerValue,
|
|
15
|
-
propsFromPickerViews,
|
|
16
|
-
variant
|
|
17
|
-
}) => {
|
|
18
|
-
const {
|
|
19
|
-
orientation
|
|
20
|
-
} = props;
|
|
21
|
-
const isLandscape = useIsLandscape(propsFromPickerViews.views, orientation);
|
|
22
|
-
const isRtl = useRtl();
|
|
23
|
-
const layoutProps = _extends({}, propsFromPickerViews, propsFromPickerValue, {
|
|
24
|
-
isLandscape,
|
|
25
|
-
isRtl,
|
|
26
|
-
wrapperVariant: variant
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
layoutProps
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
|
|
3
|
-
import { arrayIncludes } from "../utils/utils.js";
|
|
4
|
-
function getOrientation() {
|
|
5
|
-
if (typeof window === 'undefined') {
|
|
6
|
-
return 'portrait';
|
|
7
|
-
}
|
|
8
|
-
if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
|
|
9
|
-
return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Support IOS safari
|
|
13
|
-
if (window.orientation) {
|
|
14
|
-
return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';
|
|
15
|
-
}
|
|
16
|
-
return 'portrait';
|
|
17
|
-
}
|
|
18
|
-
export const useIsLandscape = (views, customOrientation) => {
|
|
19
|
-
const [orientation, setOrientation] = React.useState(getOrientation);
|
|
20
|
-
useEnhancedEffect(() => {
|
|
21
|
-
const eventHandler = () => {
|
|
22
|
-
setOrientation(getOrientation());
|
|
23
|
-
};
|
|
24
|
-
window.addEventListener('orientationchange', eventHandler);
|
|
25
|
-
return () => {
|
|
26
|
-
window.removeEventListener('orientationchange', eventHandler);
|
|
27
|
-
};
|
|
28
|
-
}, []);
|
|
29
|
-
if (arrayIncludes(views, ['hours', 'minutes', 'seconds'])) {
|
|
30
|
-
// could not display 13:34:44 in landscape mode
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
const orientationToUse = customOrientation || orientation;
|
|
34
|
-
return orientationToUse === 'landscape';
|
|
35
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { useRtl } from '@mui/system/RtlProvider';
|
|
3
|
-
import { useIsLandscape } from "../useIsLandscape.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Props used to create the layout of the views.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
11
|
-
*/
|
|
12
|
-
export const usePickerLayoutProps = ({
|
|
13
|
-
props,
|
|
14
|
-
propsFromPickerValue,
|
|
15
|
-
propsFromPickerViews,
|
|
16
|
-
variant
|
|
17
|
-
}) => {
|
|
18
|
-
const {
|
|
19
|
-
orientation
|
|
20
|
-
} = props;
|
|
21
|
-
const isLandscape = useIsLandscape(propsFromPickerViews.views, orientation);
|
|
22
|
-
const isRtl = useRtl();
|
|
23
|
-
const layoutProps = _extends({}, propsFromPickerViews, propsFromPickerValue, {
|
|
24
|
-
isLandscape,
|
|
25
|
-
isRtl,
|
|
26
|
-
wrapperVariant: variant
|
|
27
|
-
});
|
|
28
|
-
return {
|
|
29
|
-
layoutProps
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useIsLandscape = void 0;
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _utils = require("@mui/utils");
|
|
10
|
-
var _utils2 = require("../utils/utils");
|
|
11
|
-
function getOrientation() {
|
|
12
|
-
if (typeof window === 'undefined') {
|
|
13
|
-
return 'portrait';
|
|
14
|
-
}
|
|
15
|
-
if (window.screen && window.screen.orientation && window.screen.orientation.angle) {
|
|
16
|
-
return Math.abs(window.screen.orientation.angle) === 90 ? 'landscape' : 'portrait';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Support IOS safari
|
|
20
|
-
if (window.orientation) {
|
|
21
|
-
return Math.abs(Number(window.orientation)) === 90 ? 'landscape' : 'portrait';
|
|
22
|
-
}
|
|
23
|
-
return 'portrait';
|
|
24
|
-
}
|
|
25
|
-
const useIsLandscape = (views, customOrientation) => {
|
|
26
|
-
const [orientation, setOrientation] = React.useState(getOrientation);
|
|
27
|
-
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
28
|
-
const eventHandler = () => {
|
|
29
|
-
setOrientation(getOrientation());
|
|
30
|
-
};
|
|
31
|
-
window.addEventListener('orientationchange', eventHandler);
|
|
32
|
-
return () => {
|
|
33
|
-
window.removeEventListener('orientationchange', eventHandler);
|
|
34
|
-
};
|
|
35
|
-
}, []);
|
|
36
|
-
if ((0, _utils2.arrayIncludes)(views, ['hours', 'minutes', 'seconds'])) {
|
|
37
|
-
// could not display 13:34:44 in landscape mode
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
const orientationToUse = customOrientation || orientation;
|
|
41
|
-
return orientationToUse === 'landscape';
|
|
42
|
-
};
|
|
43
|
-
exports.useIsLandscape = useIsLandscape;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.usePickerLayoutProps = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
10
|
-
var _useIsLandscape = require("../useIsLandscape");
|
|
11
|
-
/**
|
|
12
|
-
* Props used to create the layout of the views.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
17
|
-
*/
|
|
18
|
-
const usePickerLayoutProps = ({
|
|
19
|
-
props,
|
|
20
|
-
propsFromPickerValue,
|
|
21
|
-
propsFromPickerViews,
|
|
22
|
-
variant
|
|
23
|
-
}) => {
|
|
24
|
-
const {
|
|
25
|
-
orientation
|
|
26
|
-
} = props;
|
|
27
|
-
const isLandscape = (0, _useIsLandscape.useIsLandscape)(propsFromPickerViews.views, orientation);
|
|
28
|
-
const isRtl = (0, _RtlProvider.useRtl)();
|
|
29
|
-
const layoutProps = (0, _extends2.default)({}, propsFromPickerViews, propsFromPickerValue, {
|
|
30
|
-
isLandscape,
|
|
31
|
-
isRtl,
|
|
32
|
-
wrapperVariant: variant
|
|
33
|
-
});
|
|
34
|
-
return {
|
|
35
|
-
layoutProps
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
exports.usePickerLayoutProps = usePickerLayoutProps;
|