@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.
Files changed (223) hide show
  1. package/AdapterMoment/AdapterMoment.js +10 -0
  2. package/CHANGELOG.md +651 -6
  3. package/DateCalendar/DateCalendar.js +1 -0
  4. package/DateCalendar/DateCalendar.types.d.ts +2 -1
  5. package/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  6. package/DateCalendar/PickersSlideTransition.js +12 -5
  7. package/DateCalendar/useCalendarState.d.ts +6 -4
  8. package/DateField/DateField.js +5 -4
  9. package/DateField/DateField.types.d.ts +10 -9
  10. package/DatePicker/DatePicker.types.d.ts +3 -3
  11. package/DatePicker/DatePickerToolbar.d.ts +3 -2
  12. package/DatePicker/DatePickerToolbar.js +0 -12
  13. package/DatePicker/shared.d.ts +6 -5
  14. package/DateTimeField/DateTimeField.js +5 -4
  15. package/DateTimeField/DateTimeField.types.d.ts +10 -10
  16. package/DateTimePicker/DateTimePicker.types.d.ts +3 -3
  17. package/DateTimePicker/DateTimePickerTabs.js +8 -6
  18. package/DateTimePicker/DateTimePickerToolbar.d.ts +3 -4
  19. package/DateTimePicker/DateTimePickerToolbar.js +6 -15
  20. package/DateTimePicker/shared.d.ts +6 -6
  21. package/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  22. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.d.ts +2 -1
  23. package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
  24. package/DigitalClock/DigitalClock.js +1 -0
  25. package/MonthCalendar/MonthCalendar.js +1 -0
  26. package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  27. package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +6 -6
  28. package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.d.ts +4 -4
  29. package/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  30. package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +3 -4
  31. package/PickersLayout/PickersLayout.d.ts +7 -5
  32. package/PickersLayout/PickersLayout.js +22 -39
  33. package/PickersLayout/PickersLayout.types.d.ts +14 -15
  34. package/PickersLayout/usePickerLayout.d.ts +5 -4
  35. package/PickersLayout/usePickerLayout.js +20 -17
  36. package/PickersShortcuts/PickersShortcuts.d.ts +7 -6
  37. package/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  38. package/PickersTextField/PickersTextField.js +2 -2
  39. package/README.md +9 -6
  40. package/TimeClock/Clock.js +1 -0
  41. package/TimeClock/TimeClock.js +1 -0
  42. package/TimeField/TimeField.js +5 -4
  43. package/TimeField/TimeField.types.d.ts +10 -10
  44. package/TimePicker/TimePicker.types.d.ts +3 -3
  45. package/TimePicker/TimePickerToolbar.d.ts +2 -3
  46. package/TimePicker/TimePickerToolbar.js +6 -15
  47. package/TimePicker/shared.d.ts +6 -6
  48. package/YearCalendar/YearCalendar.js +1 -0
  49. package/hooks/useParsedFormat.d.ts +2 -2
  50. package/hooks/useParsedFormat.js +1 -1
  51. package/hooks/useSplitFieldProps.d.ts +3 -3
  52. package/index.js +1 -1
  53. package/internals/components/PickerProvider.d.ts +26 -0
  54. package/internals/components/PickerProvider.js +3 -1
  55. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  56. package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.types.d.ts +11 -8
  57. package/internals/components/PickersToolbar.d.ts +3 -3
  58. package/internals/components/PickersToolbar.js +2 -4
  59. package/internals/hooks/useClockReferenceDate.d.ts +2 -1
  60. package/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
  61. package/internals/hooks/useDesktopPicker/useDesktopPicker.types.d.ts +14 -14
  62. package/internals/hooks/useField/useField.d.ts +3 -3
  63. package/internals/hooks/useField/useField.types.d.ts +46 -46
  64. package/internals/hooks/useField/useField.utils.d.ts +4 -3
  65. package/internals/hooks/useField/useFieldCharacterEditing.d.ts +6 -5
  66. package/internals/hooks/useField/useFieldState.d.ts +9 -8
  67. package/internals/hooks/useField/useFieldState.js +1 -1
  68. package/internals/hooks/useField/useFieldV6TextField.d.ts +4 -3
  69. package/internals/hooks/useField/useFieldV7TextField.js +2 -1
  70. package/internals/hooks/useFieldOwnerState.d.ts +6 -0
  71. package/internals/hooks/useFieldOwnerState.js +12 -0
  72. package/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
  73. package/internals/hooks/useMobilePicker/useMobilePicker.types.d.ts +11 -11
  74. package/internals/hooks/usePicker/usePicker.d.ts +3 -3
  75. package/internals/hooks/usePicker/usePicker.js +10 -19
  76. package/internals/hooks/usePicker/usePicker.types.d.ts +8 -8
  77. package/internals/hooks/usePicker/usePickerProvider.d.ts +21 -6
  78. package/internals/hooks/usePicker/usePickerProvider.js +61 -5
  79. package/internals/hooks/usePicker/usePickerValue.d.ts +3 -2
  80. package/internals/hooks/usePicker/usePickerValue.js +18 -7
  81. package/internals/hooks/usePicker/usePickerValue.types.d.ts +32 -30
  82. package/internals/hooks/usePicker/usePickerViews.d.ts +11 -10
  83. package/internals/hooks/usePicker/usePickerViews.js +1 -0
  84. package/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
  85. package/internals/hooks/useStaticPicker/useStaticPicker.types.d.ts +5 -6
  86. package/internals/hooks/useValueWithTimezone.d.ts +20 -15
  87. package/internals/hooks/useValueWithTimezone.js +13 -1
  88. package/internals/hooks/useViews.d.ts +5 -5
  89. package/internals/index.d.ts +5 -3
  90. package/internals/index.js +1 -0
  91. package/internals/models/common.d.ts +2 -1
  92. package/internals/models/fields.d.ts +6 -1
  93. package/internals/models/pickers.d.ts +1 -0
  94. package/internals/models/pickers.js +1 -0
  95. package/internals/models/props/basePickerProps.d.ts +4 -3
  96. package/internals/models/props/time.d.ts +2 -1
  97. package/internals/models/props/toolbar.d.ts +2 -2
  98. package/internals/models/value.d.ts +9 -0
  99. package/internals/utils/date-utils.d.ts +3 -3
  100. package/internals/utils/valueManagers.d.ts +4 -3
  101. package/locales/nlNL.js +7 -7
  102. package/models/adapters.d.ts +4 -4
  103. package/models/common.d.ts +1 -0
  104. package/models/fields.d.ts +19 -6
  105. package/models/pickers.d.ts +18 -0
  106. package/models/validation.d.ts +2 -1
  107. package/modern/AdapterMoment/AdapterMoment.js +10 -0
  108. package/modern/DateCalendar/DateCalendar.js +1 -0
  109. package/modern/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  110. package/modern/DateCalendar/PickersSlideTransition.js +12 -5
  111. package/modern/DateField/DateField.js +5 -4
  112. package/modern/DatePicker/DatePickerToolbar.js +0 -12
  113. package/modern/DateTimeField/DateTimeField.js +5 -4
  114. package/modern/DateTimePicker/DateTimePickerTabs.js +8 -6
  115. package/modern/DateTimePicker/DateTimePickerToolbar.js +6 -15
  116. package/modern/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  117. package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +10 -33
  118. package/modern/DigitalClock/DigitalClock.js +1 -0
  119. package/modern/MonthCalendar/MonthCalendar.js +1 -0
  120. package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  121. package/modern/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  122. package/modern/PickersLayout/PickersLayout.js +22 -39
  123. package/modern/PickersLayout/usePickerLayout.js +20 -17
  124. package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  125. package/modern/PickersTextField/PickersTextField.js +2 -2
  126. package/modern/TimeClock/Clock.js +1 -0
  127. package/modern/TimeClock/TimeClock.js +1 -0
  128. package/modern/TimeField/TimeField.js +5 -4
  129. package/modern/TimePicker/TimePickerToolbar.js +6 -15
  130. package/modern/YearCalendar/YearCalendar.js +1 -0
  131. package/modern/hooks/useParsedFormat.js +1 -1
  132. package/modern/index.js +1 -1
  133. package/modern/internals/components/PickerProvider.js +3 -1
  134. package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  135. package/modern/internals/components/PickersToolbar.js +2 -4
  136. package/modern/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
  137. package/modern/internals/hooks/useField/useFieldState.js +1 -1
  138. package/modern/internals/hooks/useField/useFieldV7TextField.js +2 -1
  139. package/modern/internals/hooks/useFieldOwnerState.js +12 -0
  140. package/modern/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
  141. package/modern/internals/hooks/usePicker/usePicker.js +10 -19
  142. package/modern/internals/hooks/usePicker/usePickerProvider.js +61 -5
  143. package/modern/internals/hooks/usePicker/usePickerValue.js +18 -7
  144. package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
  145. package/modern/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
  146. package/modern/internals/hooks/useValueWithTimezone.js +13 -1
  147. package/modern/internals/index.js +1 -0
  148. package/modern/internals/models/pickers.js +1 -0
  149. package/modern/locales/nlNL.js +7 -7
  150. package/modern/validation/useValidation.js +1 -1
  151. package/modern/validation/validateDate.js +8 -0
  152. package/modern/validation/validateDateTime.js +8 -0
  153. package/modern/validation/validateTime.js +8 -0
  154. package/node/AdapterMoment/AdapterMoment.js +10 -0
  155. package/node/DateCalendar/DateCalendar.js +1 -0
  156. package/node/DateCalendar/PickersFadeTransitionGroup.js +4 -6
  157. package/node/DateCalendar/PickersSlideTransition.js +12 -5
  158. package/node/DateField/DateField.js +5 -4
  159. package/node/DatePicker/DatePickerToolbar.js +0 -12
  160. package/node/DateTimeField/DateTimeField.js +5 -4
  161. package/node/DateTimePicker/DateTimePickerTabs.js +8 -6
  162. package/node/DateTimePicker/DateTimePickerToolbar.js +6 -15
  163. package/node/DayCalendarSkeleton/DayCalendarSkeleton.js +10 -19
  164. package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -34
  165. package/node/DigitalClock/DigitalClock.js +1 -0
  166. package/node/MonthCalendar/MonthCalendar.js +1 -0
  167. package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
  168. package/node/PickersCalendarHeader/PickersCalendarHeader.js +8 -7
  169. package/node/PickersLayout/PickersLayout.js +22 -39
  170. package/node/PickersLayout/usePickerLayout.js +20 -17
  171. package/node/PickersTextField/PickersInputBase/PickersInputBase.js +10 -9
  172. package/node/PickersTextField/PickersTextField.js +2 -2
  173. package/node/TimeClock/Clock.js +1 -0
  174. package/node/TimeClock/TimeClock.js +1 -0
  175. package/node/TimeField/TimeField.js +5 -4
  176. package/node/TimePicker/TimePickerToolbar.js +6 -15
  177. package/node/YearCalendar/YearCalendar.js +1 -0
  178. package/node/hooks/useParsedFormat.js +1 -1
  179. package/node/index.js +1 -1
  180. package/node/internals/components/PickerProvider.js +3 -1
  181. package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +11 -10
  182. package/node/internals/components/PickersToolbar.js +2 -4
  183. package/node/internals/hooks/useDesktopPicker/useDesktopPicker.js +1 -1
  184. package/node/internals/hooks/useField/useFieldState.js +1 -1
  185. package/node/internals/hooks/useField/useFieldV7TextField.js +2 -1
  186. package/node/internals/hooks/useFieldOwnerState.js +20 -0
  187. package/node/internals/hooks/useMobilePicker/useMobilePicker.js +1 -1
  188. package/node/internals/hooks/usePicker/usePicker.js +11 -19
  189. package/node/internals/hooks/usePicker/usePickerProvider.js +64 -5
  190. package/node/internals/hooks/usePicker/usePickerValue.js +18 -6
  191. package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
  192. package/node/internals/hooks/useStaticPicker/useStaticPicker.js +1 -1
  193. package/node/internals/hooks/useValueWithTimezone.js +13 -1
  194. package/node/internals/index.js +7 -0
  195. package/node/internals/models/pickers.js +5 -0
  196. package/node/locales/nlNL.js +7 -7
  197. package/node/validation/useValidation.js +1 -1
  198. package/node/validation/validateDate.js +8 -0
  199. package/node/validation/validateDateTime.js +8 -0
  200. package/node/validation/validateTime.js +8 -0
  201. package/package.json +4 -4
  202. package/themeAugmentation/overrides.d.ts +1 -1
  203. package/themeAugmentation/props.d.ts +3 -2
  204. package/validation/useValidation.d.ts +7 -6
  205. package/validation/useValidation.js +1 -1
  206. package/validation/validateDate.d.ts +12 -3
  207. package/validation/validateDate.js +8 -0
  208. package/validation/validateDateTime.d.ts +12 -4
  209. package/validation/validateDateTime.js +8 -0
  210. package/validation/validateTime.d.ts +12 -3
  211. package/validation/validateTime.js +8 -0
  212. package/internals/hooks/useIsLandscape.d.ts +0 -4
  213. package/internals/hooks/useIsLandscape.js +0 -35
  214. package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +0 -33
  215. package/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
  216. package/internals/hooks/usePicker/usePickerOwnerState.d.ts +0 -10
  217. package/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
  218. package/modern/internals/hooks/useIsLandscape.js +0 -35
  219. package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +0 -34
  220. package/modern/internals/hooks/usePicker/usePickerOwnerState.js +0 -16
  221. package/node/internals/hooks/useIsLandscape.js +0 -43
  222. package/node/internals/hooks/usePicker/usePickerLayoutProps.js +0 -41
  223. 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,4 +0,0 @@
1
- import { DateOrTimeViewWithMeridiem } from '../models';
2
- type Orientation = 'portrait' | 'landscape';
3
- export declare const useIsLandscape: (views: readonly DateOrTimeViewWithMeridiem[], customOrientation: Orientation | undefined) => boolean;
4
- export {};
@@ -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
- }