@mui/x-date-pickers-pro 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.
Files changed (77) hide show
  1. package/CHANGELOG.md +228 -7
  2. package/DateRangePicker/DateRangePicker.types.d.ts +2 -2
  3. package/DateRangePicker/shared.d.ts +3 -2
  4. package/DateTimeRangePicker/DateTimeRangePicker.types.d.ts +2 -2
  5. package/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
  6. package/DateTimeRangePicker/shared.d.ts +4 -3
  7. package/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
  8. package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +12 -10
  9. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
  10. package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +11 -9
  11. package/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
  12. package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +11 -9
  13. package/README.md +7 -4
  14. package/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
  15. package/SingleInputDateRangeField/SingleInputDateRangeField.types.d.ts +11 -10
  16. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
  17. package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.types.d.ts +11 -10
  18. package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
  19. package/SingleInputTimeRangeField/SingleInputTimeRangeField.types.d.ts +10 -9
  20. package/index.js +1 -1
  21. package/internals/hooks/models/useRangePicker.d.ts +1 -2
  22. package/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
  23. package/internals/hooks/useEnrichedRangePickerFieldProps.d.ts +13 -12
  24. package/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
  25. package/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
  26. package/internals/hooks/useMultiInputFieldSelectedSections.d.ts +6 -7
  27. package/internals/hooks/useRangePosition.d.ts +3 -2
  28. package/internals/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +1 -2
  29. package/internals/models/dateTimeRange.d.ts +2 -2
  30. package/internals/models/fields.d.ts +6 -6
  31. package/internals/models/timeRange.d.ts +2 -2
  32. package/internals/utils/date-fields-utils.d.ts +6 -6
  33. package/internals/utils/releaseInfo.js +1 -1
  34. package/internals/utils/valueManagers.d.ts +4 -3
  35. package/models/dateRange.d.ts +3 -3
  36. package/models/fields.d.ts +6 -9
  37. package/models/index.d.ts +1 -0
  38. package/models/index.js +2 -1
  39. package/models/range.d.ts +0 -1
  40. package/modern/DateTimeRangePicker/DateTimeRangePickerTabs.js +8 -7
  41. package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -12
  42. package/modern/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +10 -12
  43. package/modern/MultiInputTimeRangeField/MultiInputTimeRangeField.js +10 -12
  44. package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +5 -5
  45. package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +5 -5
  46. package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +5 -5
  47. package/modern/index.js +1 -1
  48. package/modern/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
  49. package/modern/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
  50. package/modern/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
  51. package/modern/internals/utils/releaseInfo.js +1 -1
  52. package/modern/models/index.js +2 -1
  53. package/modern/validation/validateDateRange.js +8 -0
  54. package/modern/validation/validateDateTimeRange.js +4 -0
  55. package/modern/validation/validateTimeRange.js +8 -0
  56. package/node/DateTimeRangePicker/DateTimeRangePickerTabs.js +7 -6
  57. package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +9 -11
  58. package/node/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.js +9 -11
  59. package/node/MultiInputTimeRangeField/MultiInputTimeRangeField.js +9 -11
  60. package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +4 -4
  61. package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +4 -4
  62. package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +4 -4
  63. package/node/index.js +1 -1
  64. package/node/internals/hooks/useDesktopRangePicker/useDesktopRangePicker.js +12 -2
  65. package/node/internals/hooks/useEnrichedRangePickerFieldProps.js +10 -11
  66. package/node/internals/hooks/useMobileRangePicker/useMobileRangePicker.js +13 -3
  67. package/node/internals/utils/releaseInfo.js +1 -1
  68. package/node/validation/validateDateRange.js +8 -0
  69. package/node/validation/validateDateTimeRange.js +4 -0
  70. package/node/validation/validateTimeRange.js +8 -0
  71. package/package.json +4 -4
  72. package/validation/validateDateRange.d.ts +9 -1
  73. package/validation/validateDateRange.js +8 -0
  74. package/validation/validateDateTimeRange.d.ts +6 -2
  75. package/validation/validateDateTimeRange.js +4 -0
  76. package/validation/validateTimeRange.d.ts +9 -1
  77. package/validation/validateTimeRange.js +8 -0
@@ -1,8 +1,8 @@
1
1
  import { MakeOptional } from '@mui/x-internals/types';
2
2
  import { UseFieldInternalProps, DateOrTimeViewWithMeridiem, AmPmProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
3
- import { DateTimeRangeValidationError, RangeFieldSection, RangeFieldSeparatorProps } from '../../models';
3
+ import { DateTimeRangeValidationError, RangeFieldSeparatorProps } from '../../models';
4
4
  import { ExportedValidateDateTimeRangeProps } from '../../validation/validateDateTimeRange';
5
- export interface UseDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, ExportedValidateDateTimeRangeProps, AmPmProps {
5
+ export interface UseDateTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateTimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, ExportedValidateDateTimeRangeProps, AmPmProps {
6
6
  }
7
7
  export type DateTimeRangePickerView = Exclude<DateOrTimeViewWithMeridiem, 'month' | 'year'>;
8
8
  export type DateTimeRangePickerViewExternal = Exclude<DateTimeRangePickerView, 'meridiem'>;
@@ -1,15 +1,15 @@
1
1
  import { SxProps } from '@mui/material/styles';
2
2
  import { SlotComponentProps } from '@mui/utils';
3
3
  import { MakeRequired } from '@mui/x-internals/types';
4
- import { UseFieldInternalProps } from '@mui/x-date-pickers/internals';
5
- import { FieldSection } from '@mui/x-date-pickers/models';
4
+ import { PickerRangeValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
5
+ import { FieldOwnerState } from '@mui/x-date-pickers/models';
6
6
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
7
7
  import type { MultiInputFieldRefs, MultiInputFieldSlotRootProps, RangeFieldSeparatorProps, RangePosition } from '../../models';
8
8
  /**
9
9
  * Props the multi input field can receive when used inside a picker.
10
10
  * Only contains what the MUI components are passing to the field, not what users can pass using the `props.slotProps.field`.
11
11
  */
12
- export interface BaseMultiInputFieldProps<TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean, TError> extends MakeRequired<Pick<UseFieldInternalProps<TValue, TSection, TEnableAccessibleFieldDOMStructure, TError>, 'readOnly' | 'disabled' | 'format' | 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange' | 'timezone' | 'autoFocus' | 'value' | 'onChange'>, 'format' | 'value' | 'onChange' | 'timezone'>, RangeFieldSeparatorProps, MultiInputFieldRefs {
12
+ export interface BaseMultiInputFieldProps<TEnableAccessibleFieldDOMStructure extends boolean, TError> extends MakeRequired<Pick<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TError>, 'readOnly' | 'disabled' | 'format' | 'formatDensity' | 'enableAccessibleFieldDOMStructure' | 'selectedSections' | 'onSelectedSectionsChange' | 'timezone' | 'autoFocus' | 'value' | 'onChange'>, 'format' | 'value' | 'onChange' | 'timezone'>, RangeFieldSeparatorProps, MultiInputFieldRefs {
13
13
  className: string | undefined;
14
14
  sx: SxProps<any> | undefined;
15
15
  slots?: {
@@ -18,9 +18,9 @@ export interface BaseMultiInputFieldProps<TValue, TSection extends FieldSection,
18
18
  textField?: React.ElementType;
19
19
  };
20
20
  slotProps?: {
21
- root?: SlotComponentProps<React.ElementType<MultiInputFieldSlotRootProps>, {}, Record<string, any>>;
22
- textField?: SlotComponentProps<typeof PickersTextField, {}, {
21
+ root?: SlotComponentProps<React.ElementType<MultiInputFieldSlotRootProps>, {}, FieldOwnerState>;
22
+ textField?: SlotComponentProps<typeof PickersTextField, {}, FieldOwnerState & {
23
23
  position?: RangePosition;
24
- } & Record<string, any>>;
24
+ }>;
25
25
  };
26
26
  }
@@ -1,6 +1,6 @@
1
1
  import { MakeOptional } from '@mui/x-internals/types';
2
2
  import { UseFieldInternalProps, AmPmProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
3
- import { TimeRangeValidationError, RangeFieldSection, RangeFieldSeparatorProps } from '../../models';
3
+ import { TimeRangeValidationError, RangeFieldSeparatorProps } from '../../models';
4
4
  import type { ExportedValidateTimeRangeProps } from '../../validation/validateTimeRange';
5
- export interface UseTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, ExportedValidateTimeRangeProps, AmPmProps {
5
+ export interface UseTimeRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, TimeRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, ExportedValidateTimeRangeProps, AmPmProps {
6
6
  }
@@ -1,11 +1,11 @@
1
- import { RangeFieldSection } from '../../models';
2
- export declare const splitDateRangeSections: (sections: RangeFieldSection[]) => {
3
- startDate: RangeFieldSection[];
4
- endDate: RangeFieldSection[];
1
+ import { FieldRangeSection } from '@mui/x-date-pickers/internals';
2
+ export declare const splitDateRangeSections: (sections: FieldRangeSection[]) => {
3
+ startDate: FieldRangeSection[];
4
+ endDate: FieldRangeSection[];
5
5
  };
6
- export declare const removeLastSeparator: (dateSections: RangeFieldSection[]) => (RangeFieldSection | {
6
+ export declare const removeLastSeparator: (dateSections: FieldRangeSection[]) => (FieldRangeSection | {
7
7
  separator: null;
8
- dateName: import("../..").RangePosition;
8
+ dateName: import("@mui/x-date-pickers/internals").RangePosition;
9
9
  value: string;
10
10
  format: string;
11
11
  maxLength: number | null;
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTczMjIzMDAwMDAwMA==";
3
+ const releaseInfo = "MTczMjgzNDgwMDAwMA==";
4
4
  if (process.env.NODE_ENV !== 'production') {
5
5
  // A simple hack to set the value in the test environment (has no build step).
6
6
  // eslint-disable-next-line no-useless-concat
@@ -1,7 +1,8 @@
1
1
  import { PickerValueManager, FieldValueManager, PickerRangeValue } from '@mui/x-date-pickers/internals';
2
- import type { DateRangeValidationError, DateTimeRangeValidationError, TimeRangeValidationError, RangeFieldSection } from '../../models';
3
- export type RangePickerValueManager<TValue = [any, any], TError extends DateRangeValidationError | TimeRangeValidationError | DateTimeRangeValidationError = any> = PickerValueManager<TValue, TError>;
2
+ import type { DateRangeValidationError, DateTimeRangeValidationError, TimeRangeValidationError } from '../../models';
3
+ type RangePickerValueManager<TError extends DateRangeValidationError | TimeRangeValidationError | DateTimeRangeValidationError = any> = PickerValueManager<PickerRangeValue, TError>;
4
4
  export declare const rangeValueManager: RangePickerValueManager;
5
5
  export declare const getRangeFieldValueManager: ({ dateSeparator, }: {
6
6
  dateSeparator: string | undefined;
7
- }) => FieldValueManager<PickerRangeValue, RangeFieldSection>;
7
+ }) => FieldValueManager<PickerRangeValue>;
8
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { MakeOptional } from '@mui/x-internals/types';
2
- import { UseFieldInternalProps, PickerRangeValue } from '@mui/x-date-pickers/internals';
3
- import { RangeFieldSection, RangeFieldSeparatorProps } from './fields';
2
+ import { PickerRangeValue, UseFieldInternalProps } from '@mui/x-date-pickers/internals';
3
+ import { RangeFieldSeparatorProps } from './fields';
4
4
  import { DateRangeValidationError } from './validation';
5
5
  import type { ExportedValidateDateRangeProps } from '../validation/validateDateRange';
6
- export interface UseDateRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<PickerRangeValue, RangeFieldSection, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, ExportedValidateDateRangeProps {
6
+ export interface UseDateRangeFieldProps<TEnableAccessibleFieldDOMStructure extends boolean> extends MakeOptional<Omit<UseFieldInternalProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure, DateRangeValidationError>, 'unstableFieldRef'>, 'format'>, RangeFieldSeparatorProps, ExportedValidateDateRangeProps {
7
7
  }
@@ -1,11 +1,8 @@
1
1
  import * as React from 'react';
2
- import { UseFieldResponse, FormProps } from '@mui/x-date-pickers/internals';
3
- import { FieldRef, FieldSection, PickerFieldSlotProps } from '@mui/x-date-pickers/models';
2
+ import { UseFieldResponse, FormProps, PickerValue, PickerRangeValue } from '@mui/x-date-pickers/internals';
3
+ import { FieldRef, PickerFieldSlotProps } from '@mui/x-date-pickers/models';
4
4
  import { UseClearableFieldResponse } from '@mui/x-date-pickers/hooks';
5
- import { RangePosition } from './range';
6
- export interface RangeFieldSection extends FieldSection {
7
- dateName: RangePosition;
8
- }
5
+ export type { FieldRangeSection } from '@mui/x-date-pickers/internals';
9
6
  export type FieldType = 'single-input' | 'multi-input';
10
7
  /**
11
8
  * Props the `textField` slot of the multi input field can receive when used inside a picker.
@@ -30,8 +27,8 @@ export interface MultiInputFieldSlotRootProps {
30
27
  onBlur?: React.FocusEventHandler;
31
28
  }
32
29
  export interface MultiInputFieldRefs {
33
- unstableStartFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
34
- unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
30
+ unstableStartFieldRef?: React.Ref<FieldRef<PickerValue>>;
31
+ unstableEndFieldRef?: React.Ref<FieldRef<PickerValue>>;
35
32
  }
36
33
  export interface RangeFieldSeparatorProps {
37
34
  /**
@@ -43,7 +40,7 @@ export interface RangeFieldSeparatorProps {
43
40
  /**
44
41
  * Props the `slotProps.field` of a range picker component can receive.
45
42
  */
46
- export type PickerRangeFieldSlotProps<TValue, TSection extends FieldSection, TEnableAccessibleFieldDOMStructure extends boolean> = PickerFieldSlotProps<TValue, TSection, TEnableAccessibleFieldDOMStructure> & RangeFieldSeparatorProps;
43
+ export type PickerRangeFieldSlotProps<TEnableAccessibleFieldDOMStructure extends boolean> = PickerFieldSlotProps<PickerRangeValue, TEnableAccessibleFieldDOMStructure> & RangeFieldSeparatorProps;
47
44
  /**
48
45
  * Props the text field receives when used with a multi input picker.
49
46
  * Only contains what the MUI components are passing to the text field, not what users can pass using the `props.slotProps.textField`.
package/models/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './fields';
3
3
  export * from './range';
4
4
  export * from './validation';
5
5
  export * from './multiInputRangeFieldClasses';
6
+ export type { RangePosition } from '@mui/x-date-pickers/internals';
package/models/index.js CHANGED
@@ -2,4 +2,5 @@ export * from "./dateRange.js";
2
2
  export * from "./fields.js";
3
3
  export * from "./range.js";
4
4
  export * from "./validation.js";
5
- export * from "./multiInputRangeFieldClasses.js";
5
+ export * from "./multiInputRangeFieldClasses.js";
6
+ export {};
package/models/range.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import { PickerValidDate } from '@mui/x-date-pickers/models';
2
2
  export type DateRange<TDate extends PickerValidDate> = [TDate | null, TDate | null];
3
3
  export type NonEmptyDateRange = [PickerValidDate, PickerValidDate];
4
- export type RangePosition = 'start' | 'end';
@@ -7,7 +7,7 @@ import { styled, useThemeProps } from '@mui/material/styles';
7
7
  import composeClasses from '@mui/utils/composeClasses';
8
8
  import useEventCallback from '@mui/utils/useEventCallback';
9
9
  import { TimeIcon, DateRangeIcon, ArrowLeftIcon, ArrowRightIcon } from '@mui/x-date-pickers/icons';
10
- import { isDatePickerView } from '@mui/x-date-pickers/internals';
10
+ import { isDatePickerView, usePickerPrivateContext } from '@mui/x-date-pickers/internals';
11
11
  import { usePickerTranslations } from '@mui/x-date-pickers/hooks';
12
12
  import IconButton from '@mui/material/IconButton';
13
13
  import Button from '@mui/material/Button';
@@ -25,10 +25,7 @@ const tabToView = tab => {
25
25
  }
26
26
  return 'hours';
27
27
  };
28
- const useUtilityClasses = ownerState => {
29
- const {
30
- classes
31
- } = ownerState;
28
+ const useUtilityClasses = classes => {
32
29
  const slots = {
33
30
  root: ['root'],
34
31
  tabButton: ['tabButton'],
@@ -79,10 +76,14 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
79
76
  rangePosition,
80
77
  onRangePositionChange,
81
78
  className,
79
+ classes: classesProp,
82
80
  sx
83
81
  } = props;
84
82
  const translations = usePickerTranslations();
85
- const classes = useUtilityClasses(props);
83
+ const {
84
+ ownerState
85
+ } = usePickerPrivateContext();
86
+ const classes = useUtilityClasses(classesProp);
86
87
  const value = React.useMemo(() => viewToTab(view, rangePosition), [view, rangePosition]);
87
88
  const isPreviousHidden = value === 'start-date';
88
89
  const isNextHidden = value === 'end-time';
@@ -121,7 +122,7 @@ const DateTimeRangePickerTabs = function DateTimeRangePickerTabs(inProps) {
121
122
  return null;
122
123
  }
123
124
  return /*#__PURE__*/_jsxs(DateTimeRangePickerTabsRoot, {
124
- ownerState: props,
125
+ ownerState: ownerState,
125
126
  className: clsx(classes.root, className),
126
127
  sx: sx,
127
128
  children: [!isPreviousHidden ? /*#__PURE__*/_jsx(IconButton, {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
- const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
5
+ const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
@@ -12,17 +12,14 @@ import Typography from '@mui/material/Typography';
12
12
  import { styled, useThemeProps } from '@mui/material/styles';
13
13
  import useSlotProps from '@mui/utils/useSlotProps';
14
14
  import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
15
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
15
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
16
16
  import { useSplitFieldProps } from '@mui/x-date-pickers/hooks';
17
17
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
18
18
  import { useMultiInputDateRangeField } from "../internals/hooks/useMultiInputRangeField/useMultiInputDateRangeField.js";
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  export const multiInputDateRangeFieldClasses = generateUtilityClasses('MuiMultiInputDateRangeField', ['root', 'separator']);
21
21
  export const getMultiInputDateRangeFieldUtilityClass = slot => generateUtilityClass('MuiMultiInputDateRangeField', slot);
22
- const useUtilityClasses = ownerState => {
23
- const {
24
- classes
25
- } = ownerState;
22
+ const useUtilityClasses = classes => {
26
23
  const slots = {
27
24
  root: ['root'],
28
25
  separator: ['separator']
@@ -70,11 +67,12 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
70
67
  slotProps,
71
68
  unstableStartFieldRef,
72
69
  unstableEndFieldRef,
73
- className
70
+ className,
71
+ classes: classesProp
74
72
  } = forwardedProps,
75
73
  otherForwardedProps = _objectWithoutPropertiesLoose(forwardedProps, _excluded);
76
- const ownerState = themeProps;
77
- const classes = useUtilityClasses(ownerState);
74
+ const ownerState = useFieldOwnerState(internalProps);
75
+ const classes = useUtilityClasses(classesProp);
78
76
  const Root = slots?.root ?? MultiInputDateRangeFieldRoot;
79
77
  const rootProps = useSlotProps({
80
78
  elementType: Root,
@@ -258,10 +256,10 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
258
256
  */
259
257
  shouldDisableDate: PropTypes.func,
260
258
  /**
261
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
262
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
259
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
260
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
263
261
  *
264
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
262
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
265
263
  *
266
264
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
267
265
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
- const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
5
+ const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
@@ -12,17 +12,14 @@ import Typography from '@mui/material/Typography';
12
12
  import { styled, useThemeProps } from '@mui/material/styles';
13
13
  import useSlotProps from '@mui/utils/useSlotProps';
14
14
  import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
15
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
15
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
16
16
  import { useSplitFieldProps } from '@mui/x-date-pickers/hooks';
17
17
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
18
18
  import { useMultiInputDateTimeRangeField } from "../internals/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.js";
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  export const multiInputDateTimeRangeFieldClasses = generateUtilityClasses('MuiMultiInputDateTimeRangeField', ['root', 'separator']);
21
21
  export const getMultiInputDateTimeRangeFieldUtilityClass = slot => generateUtilityClass('MuiMultiInputDateTimeRangeField', slot);
22
- const useUtilityClasses = ownerState => {
23
- const {
24
- classes
25
- } = ownerState;
22
+ const useUtilityClasses = classes => {
26
23
  const slots = {
27
24
  root: ['root'],
28
25
  separator: ['separator']
@@ -70,11 +67,12 @@ const MultiInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Mult
70
67
  slotProps,
71
68
  unstableStartFieldRef,
72
69
  unstableEndFieldRef,
73
- className
70
+ className,
71
+ classes: classesProp
74
72
  } = forwardedProps,
75
73
  otherForwardedProps = _objectWithoutPropertiesLoose(forwardedProps, _excluded);
76
- const ownerState = themeProps;
77
- const classes = useUtilityClasses(ownerState);
74
+ const ownerState = useFieldOwnerState(themeProps);
75
+ const classes = useUtilityClasses(classesProp);
78
76
  const Root = slots?.root ?? MultiInputDateTimeRangeFieldRoot;
79
77
  const rootProps = useSlotProps({
80
78
  elementType: Root,
@@ -298,10 +296,10 @@ process.env.NODE_ENV !== "production" ? MultiInputDateTimeRangeField.propTypes =
298
296
  */
299
297
  shouldDisableTime: PropTypes.func,
300
298
  /**
301
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
302
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
299
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
300
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
303
301
  *
304
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
302
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
305
303
  *
306
304
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
307
305
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
- const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className"];
5
+ const _excluded = ["slots", "slotProps", "unstableStartFieldRef", "unstableEndFieldRef", "className", "classes"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { clsx } from 'clsx';
@@ -12,17 +12,14 @@ import Typography from '@mui/material/Typography';
12
12
  import { styled, useThemeProps } from '@mui/material/styles';
13
13
  import useSlotProps from '@mui/utils/useSlotProps';
14
14
  import { unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
15
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
15
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
16
16
  import { useSplitFieldProps } from '@mui/x-date-pickers/hooks';
17
17
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
18
18
  import { useMultiInputTimeRangeField } from "../internals/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.js";
19
19
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
20
  export const multiInputTimeRangeFieldClasses = generateUtilityClasses('MuiMultiInputTimeRangeField', ['root', 'separator']);
21
21
  export const getMultiInputTimeRangeFieldUtilityClass = slot => generateUtilityClass('MuiMultiInputTimeRangeField', slot);
22
- const useUtilityClasses = ownerState => {
23
- const {
24
- classes
25
- } = ownerState;
22
+ const useUtilityClasses = classes => {
26
23
  const slots = {
27
24
  root: ['root'],
28
25
  separator: ['separator']
@@ -70,11 +67,12 @@ const MultiInputTimeRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
70
67
  slotProps,
71
68
  unstableStartFieldRef,
72
69
  unstableEndFieldRef,
73
- className
70
+ className,
71
+ classes: classesProp
74
72
  } = forwardedProps,
75
73
  otherForwardedProps = _objectWithoutPropertiesLoose(forwardedProps, _excluded);
76
- const ownerState = themeProps;
77
- const classes = useUtilityClasses(ownerState);
74
+ const ownerState = useFieldOwnerState(themeProps);
75
+ const classes = useUtilityClasses(classesProp);
78
76
  const Root = slots?.root ?? MultiInputTimeRangeFieldRoot;
79
77
  const rootProps = useSlotProps({
80
78
  elementType: Root,
@@ -270,10 +268,10 @@ process.env.NODE_ENV !== "production" ? MultiInputTimeRangeField.propTypes = {
270
268
  */
271
269
  shouldDisableTime: PropTypes.func,
272
270
  /**
273
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
274
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
271
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
272
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
275
273
  *
276
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
274
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
277
275
  *
278
276
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
279
277
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -10,7 +10,7 @@ import { useThemeProps } from '@mui/material/styles';
10
10
  import useSlotProps from '@mui/utils/useSlotProps';
11
11
  import { refType } from '@mui/utils';
12
12
  import { useClearableField } from '@mui/x-date-pickers/hooks';
13
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
13
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
14
14
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
15
15
  import { useSingleInputDateRangeField } from "./useSingleInputDateRangeField.js";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -36,7 +36,7 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
36
36
  inputProps
37
37
  } = themeProps,
38
38
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
39
+ const ownerState = useFieldOwnerState(themeProps);
40
40
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
41
  const textFieldProps = useSlotProps({
42
42
  elementType: TextField,
@@ -262,10 +262,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
262
262
  */
263
263
  shouldDisableDate: PropTypes.func,
264
264
  /**
265
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
266
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
265
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
266
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
267
267
  *
268
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
268
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
269
269
  *
270
270
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
271
271
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -6,7 +6,7 @@ const _excluded = ["slots", "slotProps", "InputProps", "inputProps"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import MuiTextField from '@mui/material/TextField';
9
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
9
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
10
10
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
11
11
  import { useThemeProps } from '@mui/material/styles';
12
12
  import { refType } from '@mui/utils';
@@ -36,7 +36,7 @@ const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Sin
36
36
  inputProps
37
37
  } = themeProps,
38
38
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
39
+ const ownerState = useFieldOwnerState(themeProps);
40
40
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
41
  const textFieldProps = useSlotProps({
42
42
  elementType: TextField,
@@ -302,10 +302,10 @@ process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes
302
302
  */
303
303
  shouldDisableTime: PropTypes.func,
304
304
  /**
305
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
306
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
305
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
306
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
307
307
  *
308
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
308
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
309
309
  *
310
310
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
311
311
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
@@ -7,7 +7,7 @@ import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import MuiTextField from '@mui/material/TextField';
9
9
  import { useClearableField } from '@mui/x-date-pickers/hooks';
10
- import { convertFieldResponseIntoMuiTextFieldProps } from '@mui/x-date-pickers/internals';
10
+ import { convertFieldResponseIntoMuiTextFieldProps, useFieldOwnerState } from '@mui/x-date-pickers/internals';
11
11
  import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
12
12
  import { useThemeProps } from '@mui/material/styles';
13
13
  import useSlotProps from '@mui/utils/useSlotProps';
@@ -36,7 +36,7 @@ const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleI
36
36
  inputProps
37
37
  } = themeProps,
38
38
  other = _objectWithoutPropertiesLoose(themeProps, _excluded);
39
- const ownerState = themeProps;
39
+ const ownerState = useFieldOwnerState(themeProps);
40
40
  const TextField = slots?.textField ?? (inProps.enableAccessibleFieldDOMStructure === false ? MuiTextField : PickersTextField);
41
41
  const textFieldProps = useSlotProps({
42
42
  elementType: TextField,
@@ -274,10 +274,10 @@ process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
274
274
  */
275
275
  shouldDisableTime: PropTypes.func,
276
276
  /**
277
- * If `true`, the format will respect the leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
278
- * If `false`, the format will always add leading zeroes (e.g: on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
277
+ * If `true`, the format will respect the leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `8/16/2018`)
278
+ * If `false`, the format will always add leading zeroes (for example on dayjs, the format `M/D/YYYY` will render `08/16/2018`)
279
279
  *
280
- * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (e.g: "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
280
+ * Warning n°1: Luxon is not able to respect the leading zeroes when using macro tokens (for example "DD"), so `shouldRespectLeadingZeros={true}` might lead to inconsistencies when using `AdapterLuxon`.
281
281
  *
282
282
  * Warning n°2: When `shouldRespectLeadingZeros={true}`, the field will add an invisible character on the sections containing a single digit to make sure `onChange` is fired.
283
283
  * If you need to get the clean value from the input, you can remove this character using `input.value.replace(/\u200e/g, '')`.
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers-pro v8.0.0-alpha.1
2
+ * @mui/x-date-pickers-pro v8.0.0-alpha.2
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -43,12 +43,21 @@ export const useDesktopRangePicker = _ref => {
43
43
  const popperRef = React.useRef(null);
44
44
  const startFieldRef = React.useRef(null);
45
45
  const endFieldRef = React.useRef(null);
46
+ const singleInputFieldRef = React.useRef(null);
46
47
  const initialView = React.useRef(props.openTo ?? null);
47
48
  const fieldType = slots.field.fieldType ?? 'multi-input';
48
49
  const {
49
50
  rangePosition,
50
51
  onRangePositionChange
51
- } = useRangePosition(props, fieldType === 'single-input' ? startFieldRef : undefined);
52
+ } = useRangePosition(props, fieldType === 'single-input' ? singleInputFieldRef : undefined);
53
+ let fieldRef;
54
+ if (fieldType === 'single-input') {
55
+ fieldRef = singleInputFieldRef;
56
+ } else if (rangePosition === 'start') {
57
+ fieldRef = startFieldRef;
58
+ } else {
59
+ fieldRef = endFieldRef;
60
+ }
52
61
  const {
53
62
  open,
54
63
  actions,
@@ -62,7 +71,7 @@ export const useDesktopRangePicker = _ref => {
62
71
  props,
63
72
  variant: 'desktop',
64
73
  autoFocusView: false,
65
- fieldRef: rangePosition === 'start' ? startFieldRef : endFieldRef,
74
+ fieldRef,
66
75
  localeText,
67
76
  additionalViewProps: {
68
77
  rangePosition,
@@ -130,6 +139,7 @@ export const useDesktopRangePicker = _ref => {
130
139
  anchorRef,
131
140
  startFieldRef,
132
141
  endFieldRef,
142
+ singleInputFieldRef,
133
143
  currentView: layoutProps.view !== props.openTo ? layoutProps.view : undefined,
134
144
  initialView: initialView.current ?? undefined,
135
145
  onViewChange: layoutProps.onViewChange
@@ -156,36 +156,35 @@ const useSingleInputFieldSlotProps = ({
156
156
  onBlur,
157
157
  rangePosition,
158
158
  onRangePositionChange,
159
- startFieldRef,
160
- endFieldRef,
159
+ singleInputFieldRef,
161
160
  pickerSlots,
162
161
  pickerSlotProps,
163
162
  fieldProps,
164
163
  anchorRef,
165
164
  currentView
166
165
  }) => {
167
- const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, startFieldRef, endFieldRef);
166
+ const handleFieldRef = useForkRef(fieldProps.unstableFieldRef, singleInputFieldRef);
168
167
  React.useEffect(() => {
169
- if (!open || !startFieldRef.current || variant === 'mobile') {
168
+ if (!open || !singleInputFieldRef.current || variant === 'mobile') {
170
169
  return;
171
170
  }
172
- if (startFieldRef.current.isFieldFocused()) {
171
+ if (singleInputFieldRef.current.isFieldFocused()) {
173
172
  return;
174
173
  }
175
174
 
176
175
  // bring back focus to the field with the current view section selected
177
176
  if (currentView) {
178
- const sections = startFieldRef.current.getSections().map(section => section.type);
177
+ const sections = singleInputFieldRef.current.getSections().map(section => section.type);
179
178
  const newSelectedSection = rangePosition === 'start' ? sections.indexOf(currentView) : sections.lastIndexOf(currentView);
180
- startFieldRef.current?.focusField(newSelectedSection);
179
+ singleInputFieldRef.current?.focusField(newSelectedSection);
181
180
  }
182
- }, [rangePosition, open, currentView, startFieldRef, variant]);
181
+ }, [rangePosition, open, currentView, singleInputFieldRef, variant]);
183
182
  const updateRangePosition = () => {
184
- if (!startFieldRef.current?.isFieldFocused()) {
183
+ if (!singleInputFieldRef.current?.isFieldFocused()) {
185
184
  return;
186
185
  }
187
- const sections = startFieldRef.current.getSections();
188
- const activeSectionIndex = startFieldRef.current?.getActiveSectionIndex();
186
+ const sections = singleInputFieldRef.current.getSections();
187
+ const activeSectionIndex = singleInputFieldRef.current?.getActiveSectionIndex();
189
188
  const domRangePosition = activeSectionIndex == null || activeSectionIndex < sections.length / 2 ? 'start' : 'end';
190
189
  if (domRangePosition != null && domRangePosition !== rangePosition) {
191
190
  onRangePositionChange(domRangePosition);