@mui/x-date-pickers 8.0.0-alpha.0 → 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 +651 -6
- package/DateCalendar/DateCalendar.js +1 -0
- 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/DatePickerToolbar.js +0 -12
- 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 +3 -4
- package/DateTimePicker/DateTimePickerToolbar.js +6 -15
- 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 -33
- package/DigitalClock/DigitalClock.js +1 -0
- package/MonthCalendar/MonthCalendar.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- 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 -39
- package/PickersLayout/PickersLayout.types.d.ts +14 -15
- package/PickersLayout/usePickerLayout.d.ts +5 -4
- package/PickersLayout/usePickerLayout.js +20 -17
- package/PickersShortcuts/PickersShortcuts.d.ts +7 -6
- package/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/PickersTextField/PickersTextField.js +2 -2
- package/README.md +9 -6
- package/TimeClock/Clock.js +1 -0
- package/TimeClock/TimeClock.js +1 -0
- 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/TimePickerToolbar.js +6 -15
- package/TimePicker/shared.d.ts +6 -6
- package/YearCalendar/YearCalendar.js +1 -0
- package/hooks/useParsedFormat.d.ts +2 -2
- package/hooks/useParsedFormat.js +1 -1
- package/hooks/useSplitFieldProps.d.ts +3 -3
- package/index.js +1 -1
- package/internals/components/PickerProvider.d.ts +26 -0
- package/internals/components/PickerProvider.js +3 -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/components/PickersToolbar.js +2 -4
- package/internals/hooks/useClockReferenceDate.d.ts +2 -1
- package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -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 +46 -46
- 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 +1 -1
- package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
- package/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/internals/hooks/useFieldOwnerState.d.ts +6 -0
- package/internals/hooks/useFieldOwnerState.js +12 -0
- package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- 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 +10 -19
- package/internals/hooks/usePicker/usePicker.types.d.ts +8 -8
- package/internals/hooks/usePicker/usePickerProvider.d.ts +21 -6
- package/internals/hooks/usePicker/usePickerProvider.js +61 -5
- package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
- package/internals/hooks/usePicker/usePickerValue.js +18 -7
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -30
- package/internals/hooks/usePicker/usePickerViews.d.ts +11 -10
- package/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +5 -6
- package/internals/hooks/useValueWithTimezone.d.ts +20 -15
- package/internals/hooks/useValueWithTimezone.js +13 -1
- package/internals/hooks/useViews.d.ts +5 -5
- package/internals/index.d.ts +5 -3
- package/internals/index.js +1 -0
- package/internals/models/common.d.ts +2 -1
- 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 -2
- package/internals/models/value.d.ts +9 -0
- package/internals/utils/date-utils.d.ts +3 -3
- package/internals/utils/valueManagers.d.ts +4 -3
- package/locales/nlNL.js +7 -7
- package/models/adapters.d.ts +4 -4
- package/models/common.d.ts +1 -0
- package/models/fields.d.ts +19 -6
- package/models/pickers.d.ts +18 -0
- package/models/validation.d.ts +2 -1
- package/modern/AdapterMoment/AdapterMoment.js +10 -0
- package/modern/DateCalendar/DateCalendar.js +1 -0
- package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/modern/DateCalendar/PickersSlideTransition.js +12 -5
- package/modern/DateField/DateField.js +5 -4
- package/modern/DatePicker/DatePickerToolbar.js +0 -12
- package/modern/DateTimeField/DateTimeField.js +5 -4
- package/modern/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/modern/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/MonthCalendar/MonthCalendar.js +1 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/modern/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/modern/PickersLayout/PickersLayout.js +22 -39
- package/modern/PickersLayout/usePickerLayout.js +20 -17
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/modern/PickersTextField/PickersTextField.js +2 -2
- package/modern/TimeClock/Clock.js +1 -0
- package/modern/TimeClock/TimeClock.js +1 -0
- package/modern/TimeField/TimeField.js +5 -4
- package/modern/TimePicker/TimePickerToolbar.js +6 -15
- package/modern/YearCalendar/YearCalendar.js +1 -0
- package/modern/hooks/useParsedFormat.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickerProvider.js +3 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/modern/internals/components/PickersToolbar.js +2 -4
- package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/modern/internals/hooks/useField/useFieldState.js +1 -1
- package/modern/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/modern/internals/hooks/useFieldOwnerState.js +12 -0
- package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/modern/internals/hooks/usePicker/usePicker.js +10 -19
- package/modern/internals/hooks/usePicker/usePickerProvider.js +61 -5
- package/modern/internals/hooks/usePicker/usePickerValue.js +18 -7
- package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/modern/internals/hooks/useValueWithTimezone.js +13 -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/DateCalendar.js +1 -0
- package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
- package/node/DateCalendar/PickersSlideTransition.js +12 -5
- package/node/DateField/DateField.js +5 -4
- package/node/DatePicker/DatePickerToolbar.js +0 -12
- package/node/DateTimeField/DateTimeField.js +5 -4
- package/node/DateTimePicker/DateTimePickerTabs.js +8 -6
- package/node/DateTimePicker/DateTimePickerToolbar.js +6 -15
- package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -34
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/MonthCalendar/MonthCalendar.js +1 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
- package/node/PickersLayout/PickersLayout.js +22 -39
- package/node/PickersLayout/usePickerLayout.js +20 -17
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
- package/node/PickersTextField/PickersTextField.js +2 -2
- package/node/TimeClock/Clock.js +1 -0
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/TimeField/TimeField.js +5 -4
- package/node/TimePicker/TimePickerToolbar.js +6 -15
- package/node/YearCalendar/YearCalendar.js +1 -0
- package/node/hooks/useParsedFormat.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickerProvider.js +3 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
- package/node/internals/components/PickersToolbar.js +2 -4
- package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
- package/node/internals/hooks/useField/useFieldState.js +1 -1
- package/node/internals/hooks/useField/useFieldV7TextField.js +2 -1
- package/node/internals/hooks/useFieldOwnerState.js +20 -0
- package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
- package/node/internals/hooks/usePicker/usePicker.js +11 -19
- package/node/internals/hooks/usePicker/usePickerProvider.js +64 -5
- package/node/internals/hooks/usePicker/usePickerValue.js +18 -6
- package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
- package/node/internals/hooks/useValueWithTimezone.js +13 -1
- 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 +4 -4
- 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 -33
- package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
- package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -10
- package/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- package/modern/internals/hooks/useIsLandscape.js +0 -35
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
- package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
- package/node/internals/hooks/useIsLandscape.js +0 -43
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -41
- package/node/internals/hooks/usePicker/usePickerOwnerState.js +0 -23
|
@@ -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,33 +0,0 @@
|
|
|
1
|
-
import { UsePickerValueLayoutResponse } from './usePickerValue.types';
|
|
2
|
-
import { UsePickerViewsLayoutResponse } from './usePickerViews';
|
|
3
|
-
import { DateOrTimeViewWithMeridiem, WrapperVariant } from '../../models/common';
|
|
4
|
-
import { FormProps } from '../../models';
|
|
5
|
-
/**
|
|
6
|
-
* Props used to create the layout of the views.
|
|
7
|
-
* Those props are exposed on all the pickers.
|
|
8
|
-
*/
|
|
9
|
-
export interface UsePickerLayoutProps extends FormProps {
|
|
10
|
-
/**
|
|
11
|
-
* Force rendering in particular orientation.
|
|
12
|
-
*/
|
|
13
|
-
orientation?: 'portrait' | 'landscape';
|
|
14
|
-
}
|
|
15
|
-
export interface UsePickerLayoutPropsResponseLayoutProps<TValue, TView extends DateOrTimeViewWithMeridiem> extends UsePickerValueLayoutResponse<TValue>, UsePickerViewsLayoutResponse<TView>, UsePickerLayoutProps {
|
|
16
|
-
isLandscape: boolean;
|
|
17
|
-
isRtl: boolean;
|
|
18
|
-
wrapperVariant: WrapperVariant;
|
|
19
|
-
isValid: (value: TValue) => boolean;
|
|
20
|
-
}
|
|
21
|
-
export interface UsePickerLayoutPropsResponse<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
22
|
-
layoutProps: UsePickerLayoutPropsResponseLayoutProps<TValue, TView>;
|
|
23
|
-
}
|
|
24
|
-
export interface UsePickerLayoutPropsParams<TValue, TView extends DateOrTimeViewWithMeridiem> {
|
|
25
|
-
props: UsePickerLayoutProps;
|
|
26
|
-
propsFromPickerValue: UsePickerValueLayoutResponse<TValue>;
|
|
27
|
-
propsFromPickerViews: UsePickerViewsLayoutResponse<TView>;
|
|
28
|
-
wrapperVariant: WrapperVariant;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
32
|
-
*/
|
|
33
|
-
export declare const usePickerLayoutProps: <TValue, TView extends DateOrTimeViewWithMeridiem>({ props, propsFromPickerValue, propsFromPickerViews, wrapperVariant, }: UsePickerLayoutPropsParams<TValue, TView>) => UsePickerLayoutPropsResponse<TValue, TView>;
|
|
@@ -1,34 +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
|
-
* Those props are exposed on all the pickers.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
12
|
-
*/
|
|
13
|
-
export const usePickerLayoutProps = ({
|
|
14
|
-
props,
|
|
15
|
-
propsFromPickerValue,
|
|
16
|
-
propsFromPickerViews,
|
|
17
|
-
wrapperVariant
|
|
18
|
-
}) => {
|
|
19
|
-
const {
|
|
20
|
-
orientation
|
|
21
|
-
} = props;
|
|
22
|
-
const isLandscape = useIsLandscape(propsFromPickerViews.views, orientation);
|
|
23
|
-
const isRtl = useRtl();
|
|
24
|
-
const layoutProps = _extends({}, propsFromPickerViews, propsFromPickerValue, {
|
|
25
|
-
isLandscape,
|
|
26
|
-
isRtl,
|
|
27
|
-
wrapperVariant,
|
|
28
|
-
disabled: props.disabled,
|
|
29
|
-
readOnly: props.readOnly
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
layoutProps
|
|
33
|
-
};
|
|
34
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FieldSection, PickerOwnerState } from '../../../models';
|
|
2
|
-
import type { UsePickerProps } from './usePicker.types';
|
|
3
|
-
import { PickerValueManager, UsePickerValueResponse } from './usePickerValue.types';
|
|
4
|
-
interface UsePickerOwnerStateParameters<TValue> {
|
|
5
|
-
props: UsePickerProps<TValue, any, any, any, any>;
|
|
6
|
-
pickerValueResponse: UsePickerValueResponse<TValue, FieldSection, any>;
|
|
7
|
-
valueManager: PickerValueManager<TValue, any>;
|
|
8
|
-
}
|
|
9
|
-
export declare function usePickerOwnerState<TValue>(parameters: UsePickerOwnerStateParameters<TValue>): PickerOwnerState;
|
|
10
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useUtils } from "../useUtils.js";
|
|
3
|
-
export function usePickerOwnerState(parameters) {
|
|
4
|
-
const {
|
|
5
|
-
props,
|
|
6
|
-
pickerValueResponse,
|
|
7
|
-
valueManager
|
|
8
|
-
} = parameters;
|
|
9
|
-
const utils = useUtils();
|
|
10
|
-
return React.useMemo(() => ({
|
|
11
|
-
isPickerValueEmpty: valueManager.areValuesEqual(utils, pickerValueResponse.viewProps.value, valueManager.emptyValue),
|
|
12
|
-
isPickerOpen: pickerValueResponse.open,
|
|
13
|
-
isPickerDisabled: props.disabled ?? false,
|
|
14
|
-
isPickerReadOnly: props.readOnly ?? false
|
|
15
|
-
}), [utils, valueManager, pickerValueResponse.viewProps.value, pickerValueResponse.open, props.disabled, props.readOnly]);
|
|
16
|
-
}
|
|
@@ -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,34 +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
|
-
* Those props are exposed on all the pickers.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
12
|
-
*/
|
|
13
|
-
export const usePickerLayoutProps = ({
|
|
14
|
-
props,
|
|
15
|
-
propsFromPickerValue,
|
|
16
|
-
propsFromPickerViews,
|
|
17
|
-
wrapperVariant
|
|
18
|
-
}) => {
|
|
19
|
-
const {
|
|
20
|
-
orientation
|
|
21
|
-
} = props;
|
|
22
|
-
const isLandscape = useIsLandscape(propsFromPickerViews.views, orientation);
|
|
23
|
-
const isRtl = useRtl();
|
|
24
|
-
const layoutProps = _extends({}, propsFromPickerViews, propsFromPickerValue, {
|
|
25
|
-
isLandscape,
|
|
26
|
-
isRtl,
|
|
27
|
-
wrapperVariant,
|
|
28
|
-
disabled: props.disabled,
|
|
29
|
-
readOnly: props.readOnly
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
layoutProps
|
|
33
|
-
};
|
|
34
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useUtils } from "../useUtils.js";
|
|
3
|
-
export function usePickerOwnerState(parameters) {
|
|
4
|
-
const {
|
|
5
|
-
props,
|
|
6
|
-
pickerValueResponse,
|
|
7
|
-
valueManager
|
|
8
|
-
} = parameters;
|
|
9
|
-
const utils = useUtils();
|
|
10
|
-
return React.useMemo(() => ({
|
|
11
|
-
isPickerValueEmpty: valueManager.areValuesEqual(utils, pickerValueResponse.viewProps.value, valueManager.emptyValue),
|
|
12
|
-
isPickerOpen: pickerValueResponse.open,
|
|
13
|
-
isPickerDisabled: props.disabled ?? false,
|
|
14
|
-
isPickerReadOnly: props.readOnly ?? false
|
|
15
|
-
}), [utils, valueManager, pickerValueResponse.viewProps.value, pickerValueResponse.open, props.disabled, props.readOnly]);
|
|
16
|
-
}
|
|
@@ -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,41 +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
|
-
* Those props are exposed on all the pickers.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Prepare the props for the view layout (managed by `PickersLayout`)
|
|
18
|
-
*/
|
|
19
|
-
const usePickerLayoutProps = ({
|
|
20
|
-
props,
|
|
21
|
-
propsFromPickerValue,
|
|
22
|
-
propsFromPickerViews,
|
|
23
|
-
wrapperVariant
|
|
24
|
-
}) => {
|
|
25
|
-
const {
|
|
26
|
-
orientation
|
|
27
|
-
} = props;
|
|
28
|
-
const isLandscape = (0, _useIsLandscape.useIsLandscape)(propsFromPickerViews.views, orientation);
|
|
29
|
-
const isRtl = (0, _RtlProvider.useRtl)();
|
|
30
|
-
const layoutProps = (0, _extends2.default)({}, propsFromPickerViews, propsFromPickerValue, {
|
|
31
|
-
isLandscape,
|
|
32
|
-
isRtl,
|
|
33
|
-
wrapperVariant,
|
|
34
|
-
disabled: props.disabled,
|
|
35
|
-
readOnly: props.readOnly
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
layoutProps
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
exports.usePickerLayoutProps = usePickerLayoutProps;
|
|
@@ -1,23 +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.usePickerOwnerState = usePickerOwnerState;
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _useUtils = require("../useUtils");
|
|
10
|
-
function usePickerOwnerState(parameters) {
|
|
11
|
-
const {
|
|
12
|
-
props,
|
|
13
|
-
pickerValueResponse,
|
|
14
|
-
valueManager
|
|
15
|
-
} = parameters;
|
|
16
|
-
const utils = (0, _useUtils.useUtils)();
|
|
17
|
-
return React.useMemo(() => ({
|
|
18
|
-
isPickerValueEmpty: valueManager.areValuesEqual(utils, pickerValueResponse.viewProps.value, valueManager.emptyValue),
|
|
19
|
-
isPickerOpen: pickerValueResponse.open,
|
|
20
|
-
isPickerDisabled: props.disabled ?? false,
|
|
21
|
-
isPickerReadOnly: props.readOnly ?? false
|
|
22
|
-
}), [utils, valueManager, pickerValueResponse.viewProps.value, pickerValueResponse.open, props.disabled, props.readOnly]);
|
|
23
|
-
}
|