@mui/x-date-pickers 6.4.0 → 6.5.0

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 (85) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/DateField/DateField.types.d.ts +1 -1
  3. package/DateField/index.d.ts +1 -1
  4. package/DateField/useDateField.d.ts +1 -1
  5. package/DateField/useDateField.js +9 -46
  6. package/DateTimeField/DateTimeField.types.d.ts +1 -1
  7. package/DateTimeField/index.d.ts +1 -1
  8. package/DateTimeField/useDateTimeField.d.ts +1 -1
  9. package/DateTimeField/useDateTimeField.js +9 -60
  10. package/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  11. package/DesktopTimePicker/DesktopTimePicker.js +1 -2
  12. package/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  13. package/MobileTimePicker/MobileTimePicker.js +1 -2
  14. package/TimeField/index.d.ts +1 -1
  15. package/TimeField/useTimeField.d.ts +1 -1
  16. package/TimeField/useTimeField.js +9 -50
  17. package/index.js +1 -1
  18. package/internals/hooks/useField/useField.js +10 -2
  19. package/internals/hooks/useViews.js +2 -0
  20. package/internals/index.d.ts +2 -1
  21. package/internals/index.js +2 -1
  22. package/internals/utils/fields.d.ts +5 -0
  23. package/internals/utils/fields.js +28 -0
  24. package/internals/utils/validation/extractValidationProps.d.ts +5 -1
  25. package/internals/utils/validation/extractValidationProps.js +4 -1
  26. package/legacy/DateField/useDateField.js +8 -44
  27. package/legacy/DateTimeField/useDateTimeField.js +8 -60
  28. package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  29. package/legacy/DesktopTimePicker/DesktopTimePicker.js +1 -2
  30. package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  31. package/legacy/MobileTimePicker/MobileTimePicker.js +1 -2
  32. package/legacy/TimeField/useTimeField.js +8 -48
  33. package/legacy/index.js +1 -1
  34. package/legacy/internals/hooks/useField/useField.js +12 -4
  35. package/legacy/internals/hooks/useViews.js +2 -0
  36. package/legacy/internals/index.js +2 -1
  37. package/legacy/internals/utils/fields.js +28 -0
  38. package/legacy/internals/utils/validation/extractValidationProps.js +4 -1
  39. package/legacy/tests/describeGregorianAdapter/testCalculations.js +1 -1
  40. package/legacy/tests/describeValue/describeValue.js +30 -3
  41. package/legacy/tests/describeValue/testControlledUnControlled.js +27 -21
  42. package/legacy/tests/describeValue/testPickerActionBar.js +40 -36
  43. package/legacy/tests/describeValue/testPickerOpenCloseLifeCycle.js +92 -71
  44. package/modern/DateField/useDateField.js +9 -46
  45. package/modern/DateTimeField/useDateTimeField.js +9 -60
  46. package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  47. package/modern/DesktopTimePicker/DesktopTimePicker.js +1 -2
  48. package/modern/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  49. package/modern/MobileTimePicker/MobileTimePicker.js +1 -2
  50. package/modern/TimeField/useTimeField.js +9 -50
  51. package/modern/index.js +1 -1
  52. package/modern/internals/hooks/useField/useField.js +10 -2
  53. package/modern/internals/hooks/useViews.js +2 -0
  54. package/modern/internals/index.js +2 -1
  55. package/modern/internals/utils/fields.js +28 -0
  56. package/modern/internals/utils/validation/extractValidationProps.js +4 -1
  57. package/modern/tests/describeGregorianAdapter/testCalculations.js +1 -1
  58. package/modern/tests/describeValue/describeValue.js +29 -3
  59. package/modern/tests/describeValue/testControlledUnControlled.js +23 -15
  60. package/modern/tests/describeValue/testPickerActionBar.js +21 -14
  61. package/modern/tests/describeValue/testPickerOpenCloseLifeCycle.js +79 -51
  62. package/node/DateField/useDateField.js +9 -46
  63. package/node/DateTimeField/useDateTimeField.js +9 -60
  64. package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +1 -2
  65. package/node/DesktopTimePicker/DesktopTimePicker.js +1 -2
  66. package/node/MobileDateTimePicker/MobileDateTimePicker.js +1 -2
  67. package/node/MobileTimePicker/MobileTimePicker.js +1 -2
  68. package/node/TimeField/useTimeField.js +9 -50
  69. package/node/index.js +1 -1
  70. package/node/internals/hooks/useField/useField.js +10 -2
  71. package/node/internals/hooks/useViews.js +2 -0
  72. package/node/internals/index.js +13 -0
  73. package/node/internals/utils/fields.js +36 -0
  74. package/node/internals/utils/validation/extractValidationProps.js +8 -2
  75. package/node/tests/describeGregorianAdapter/testCalculations.js +1 -1
  76. package/node/tests/describeValue/describeValue.js +29 -3
  77. package/node/tests/describeValue/testControlledUnControlled.js +23 -15
  78. package/node/tests/describeValue/testPickerActionBar.js +21 -14
  79. package/node/tests/describeValue/testPickerOpenCloseLifeCycle.js +79 -51
  80. package/package.json +2 -2
  81. package/tests/describeGregorianAdapter/testCalculations.js +1 -1
  82. package/tests/describeValue/describeValue.js +29 -3
  83. package/tests/describeValue/testControlledUnControlled.js +23 -15
  84. package/tests/describeValue/testPickerActionBar.js +21 -14
  85. package/tests/describeValue/testPickerOpenCloseLifeCycle.js +79 -51
package/CHANGELOG.md CHANGED
@@ -3,6 +3,62 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## v6.5.0
7
+
8
+ _May 19, 2023_
9
+
10
+ We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 💫 Introduce filtering on column headers for `DataGridPro` and `DataGridPremium`:
13
+
14
+ https://github.com/mui/mui-x/assets/12609561/c4c2bfec-59cf-4cab-932d-dc1983081de9
15
+
16
+ See [the documentation](https://mui.com/x/react-data-grid/filtering/#header-filters) for more information
17
+
18
+ - 🌍 Improve Hebrew (he-IL) and Czech (cs-CZ) locales
19
+ - 📝 Support for editing on pinned rows
20
+ - 🚀 Performance improvements
21
+ - 🐞 Bugfixes
22
+ - 📚 Documentation improvements
23
+
24
+ ### `@mui/x-data-grid@6.5.0` / `@mui/x-data-grid-pro@6.5.0` / `@mui/x-data-grid-premium@6.5.0`
25
+
26
+ #### Changes
27
+
28
+ - [DataGrid] Fix grid size calculation when `.MuiDataGrid-main` has border (#8882) @cherniavskii
29
+ - [DataGridPro] Filtering on Column Header (#7760) @MBilalShafi
30
+ - [DataGridPro] Improve `treeData` and `rowGrouping` performance (#8990) @MBilalShafi
31
+ - [DataGridPro] Support pinned rows editing (#8921) @cherniavskii
32
+ - [l10n] Improve Hebrew (he-IL) locale (#8943) @Itzik-Tech
33
+ - [l10n] Improve Czech (cs-CZ) locale (#8829) @harastaivan
34
+ - [l10n] Improve Czech (cs-CZ) locale (#8956) @davidzemancz
35
+
36
+ ### `@mui/x-date-pickers@6.5.0` / `@mui/x-date-pickers-pro@6.5.0`
37
+
38
+ #### Changes
39
+
40
+ - [fields] Select the first section instead of last when clicking right of content (#9005) @noraleonte
41
+ - [fields] Refactor prop drilling in fields (#8660) @flaviendelangle
42
+ - [pickers] Allow to render the months before `currentMonth` instead of the one after (#8592) @flaviendelangle
43
+ - [pickers] Fix view management when `openTo` or `views` is modified (#8997) @alexfauquette
44
+ - [l10n] Improve Czech (cs-CZ) locale (#8829) @harastaivan
45
+
46
+ ### Docs
47
+
48
+ - [docs] Clarify what Controlled / Uncontrolled means (#8926) @flaviendelangle
49
+ - [docs] Fix docs using wrong service worker (#9030) @cherniavskii
50
+ - [docs] Remove prop-types from JS demos (#9008) @flaviendelangle
51
+
52
+ ### Core
53
+
54
+ - [core] Add assertion about checkbox rerenders (#8974) @oliviertassinari
55
+ - [core] Allow selecting a section by type in field tests (#9009) @flaviendelangle
56
+ - [core] Fix `yarn.lock` (#8988) @flaviendelangle
57
+ - [core] Fix flacky adapter test (#8995) @flaviendelangle
58
+ - [charts] Clean the axis rendering (#8948) @alexfauquette
59
+ - [DataGrid] Memoize root props for better performance (#8942) @romgrk
60
+ - [test] Skip flaky unit tests in JSDOM (#8994) @cherniavskii
61
+
6
62
  ## v6.4.0
7
63
 
8
64
  _May 12, 2023_
@@ -13,7 +13,7 @@ export interface UseDateFieldParams<TDate, TChildProps extends {}> {
13
13
  }
14
14
  export interface UseDateFieldProps<TDate> extends MakeOptional<UseFieldInternalProps<TDate | null, FieldSection, DateValidationError>, 'format'>, DayValidationProps<TDate>, MonthValidationProps<TDate>, YearValidationProps<TDate>, BaseDateValidationProps<TDate> {
15
15
  }
16
- export type UseDateFieldDefaultizedProps<TDate> = DefaultizedProps<UseDateFieldProps<TDate>, keyof BaseDateValidationProps<TDate> | 'format'>;
16
+ export type UseDateFieldDefaultizedProps<TDate> = DefaultizedProps<UseDateFieldProps<TDate>, keyof BaseDateValidationProps<any> | 'format'>;
17
17
  export type UseDateFieldComponentProps<TDate, TChildProps extends {}> = Omit<TChildProps, keyof UseDateFieldProps<TDate>> & UseDateFieldProps<TDate>;
18
18
  export interface DateFieldProps<TDate> extends UseDateFieldComponentProps<TDate, FieldsTextFieldProps>, SlotsAndSlotProps<DateFieldSlotsComponent, DateFieldSlotsComponentsProps<TDate>> {
19
19
  }
@@ -1,3 +1,3 @@
1
1
  export { DateField } from './DateField';
2
2
  export { useDateField as unstable_useDateField } from './useDateField';
3
- export type { UseDateFieldProps, UseDateFieldComponentProps, DateFieldProps, } from './DateField.types';
3
+ export type { UseDateFieldProps, UseDateFieldComponentProps, DateFieldProps, UseDateFieldDefaultizedProps, } from './DateField.types';
@@ -1,2 +1,2 @@
1
1
  import { UseDateFieldProps, UseDateFieldParams } from './DateField.types';
2
- export declare const useDateField: <TDate, TChildProps extends {}>({ props, inputRef, }: UseDateFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<Omit<TChildProps, keyof UseDateFieldProps<TDate>>>;
2
+ export declare const useDateField: <TDate, TChildProps extends {}>({ props: inProps, inputRef, }: UseDateFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<Omit<TChildProps & Omit<UseDateFieldProps<TDate>, "format" | keyof import("../internals").BaseDateValidationProps<any>> & Required<Pick<UseDateFieldProps<TDate>, "format" | keyof import("../internals").BaseDateValidationProps<any>>>, keyof UseDateFieldProps<TDate>>>;
@@ -1,11 +1,10 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
4
2
  import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
5
3
  import { useField } from '../internals/hooks/useField';
6
4
  import { validateDate } from '../internals/utils/validation/validateDate';
7
5
  import { applyDefaultDate } from '../internals/utils/date-utils';
8
6
  import { useUtils, useDefaultDates } from '../internals/hooks/useUtils';
7
+ import { splitFieldInternalAndForwardedProps } from '../internals/utils/fields';
9
8
  const useDefaultizedDateField = props => {
10
9
  var _props$disablePast, _props$disableFuture, _props$format;
11
10
  const utils = useUtils();
@@ -19,54 +18,18 @@ const useDefaultizedDateField = props => {
19
18
  });
20
19
  };
21
20
  export const useDateField = ({
22
- props,
21
+ props: inProps,
23
22
  inputRef
24
23
  }) => {
25
- const _useDefaultizedDateFi = useDefaultizedDateField(props),
26
- {
27
- value,
28
- defaultValue,
29
- format,
30
- formatDensity,
31
- shouldRespectLeadingZeros,
32
- onChange,
33
- readOnly,
34
- onError,
35
- shouldDisableDate,
36
- shouldDisableMonth,
37
- shouldDisableYear,
38
- minDate,
39
- maxDate,
40
- disableFuture,
41
- disablePast,
42
- selectedSections,
43
- onSelectedSectionsChange,
44
- unstableFieldRef
45
- } = _useDefaultizedDateFi,
46
- other = _objectWithoutPropertiesLoose(_useDefaultizedDateFi, _excluded);
24
+ const props = useDefaultizedDateField(inProps);
25
+ const {
26
+ forwardedProps,
27
+ internalProps
28
+ } = splitFieldInternalAndForwardedProps(props, 'date');
47
29
  return useField({
48
30
  inputRef,
49
- forwardedProps: other,
50
- internalProps: {
51
- value,
52
- defaultValue,
53
- format,
54
- formatDensity,
55
- shouldRespectLeadingZeros,
56
- onChange,
57
- readOnly,
58
- onError,
59
- shouldDisableDate,
60
- shouldDisableMonth,
61
- shouldDisableYear,
62
- minDate,
63
- maxDate,
64
- disableFuture,
65
- disablePast,
66
- selectedSections,
67
- onSelectedSectionsChange,
68
- unstableFieldRef
69
- },
31
+ forwardedProps,
32
+ internalProps,
70
33
  valueManager: singleItemValueManager,
71
34
  fieldValueManager: singleItemFieldValueManager,
72
35
  validator: validateDate,
@@ -18,7 +18,7 @@ export interface UseDateTimeFieldProps<TDate> extends MakeOptional<UseFieldInter
18
18
  */
19
19
  ampm?: boolean;
20
20
  }
21
- export type UseDateTimeFieldDefaultizedProps<TDate> = DefaultizedProps<UseDateTimeFieldProps<TDate>, keyof BaseDateValidationProps<TDate> | keyof BaseTimeValidationProps | 'format'>;
21
+ export type UseDateTimeFieldDefaultizedProps<TDate> = DefaultizedProps<UseDateTimeFieldProps<TDate>, keyof BaseDateValidationProps<any> | keyof BaseTimeValidationProps | 'format'>;
22
22
  export type UseDateTimeFieldComponentProps<TDate, TChildProps extends {}> = Omit<TChildProps, keyof UseDateTimeFieldProps<TDate>> & UseDateTimeFieldProps<TDate>;
23
23
  export interface DateTimeFieldProps<TDate> extends UseDateTimeFieldComponentProps<TDate, FieldsTextFieldProps> {
24
24
  /**
@@ -1,3 +1,3 @@
1
1
  export { DateTimeField } from './DateTimeField';
2
2
  export { useDateTimeField as unstable_useDateTimeField } from './useDateTimeField';
3
- export type { UseDateTimeFieldProps, UseDateTimeFieldComponentProps, DateTimeFieldProps, } from './DateTimeField.types';
3
+ export type { UseDateTimeFieldProps, UseDateTimeFieldComponentProps, DateTimeFieldProps, UseDateTimeFieldDefaultizedProps, } from './DateTimeField.types';
@@ -1,2 +1,2 @@
1
1
  import { UseDateTimeFieldProps, UseDateTimeFieldParams } from './DateTimeField.types';
2
- export declare const useDateTimeField: <TDate, TChildProps extends {}>({ props, inputRef, }: UseDateTimeFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<Omit<TChildProps, keyof UseDateTimeFieldProps<TDate>>>;
2
+ export declare const useDateTimeField: <TDate, TChildProps extends {}>({ props: inProps, inputRef, }: UseDateTimeFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<Omit<TChildProps & Omit<UseDateTimeFieldProps<TDate>, "format" | "disableFuture" | "disablePast" | "maxDate" | "minDate"> & Required<Pick<UseDateTimeFieldProps<TDate>, "format" | "disableFuture" | "disablePast" | "maxDate" | "minDate">>, keyof UseDateTimeFieldProps<any>>>;
@@ -1,11 +1,10 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "minTime", "maxTime", "minDateTime", "maxDateTime", "minutesStep", "disableIgnoringDatePartForTimeValidation", "shouldDisableClock", "shouldDisableTime", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
4
2
  import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
5
3
  import { useField } from '../internals/hooks/useField';
6
4
  import { validateDateTime } from '../internals/utils/validation/validateDateTime';
7
5
  import { applyDefaultDate } from '../internals/utils/date-utils';
8
6
  import { useUtils, useDefaultDates } from '../internals/hooks/useUtils';
7
+ import { splitFieldInternalAndForwardedProps } from '../internals/utils/fields';
9
8
  const useDefaultizedDateTimeField = props => {
10
9
  var _props$ampm, _props$disablePast, _props$disableFuture, _props$format, _props$minDateTime, _props$maxDateTime, _props$minDateTime2, _props$maxDateTime2;
11
10
  const utils = useUtils();
@@ -24,68 +23,18 @@ const useDefaultizedDateTimeField = props => {
24
23
  });
25
24
  };
26
25
  export const useDateTimeField = ({
27
- props,
26
+ props: inProps,
28
27
  inputRef
29
28
  }) => {
30
- const _useDefaultizedDateTi = useDefaultizedDateTimeField(props),
31
- {
32
- value,
33
- defaultValue,
34
- format,
35
- formatDensity,
36
- shouldRespectLeadingZeros,
37
- onChange,
38
- readOnly,
39
- onError,
40
- shouldDisableDate,
41
- shouldDisableMonth,
42
- shouldDisableYear,
43
- minDate,
44
- maxDate,
45
- disableFuture,
46
- disablePast,
47
- minTime,
48
- maxTime,
49
- minutesStep,
50
- disableIgnoringDatePartForTimeValidation,
51
- shouldDisableClock,
52
- shouldDisableTime,
53
- selectedSections,
54
- onSelectedSectionsChange,
55
- ampm,
56
- unstableFieldRef
57
- } = _useDefaultizedDateTi,
58
- other = _objectWithoutPropertiesLoose(_useDefaultizedDateTi, _excluded);
29
+ const props = useDefaultizedDateTimeField(inProps);
30
+ const {
31
+ forwardedProps,
32
+ internalProps
33
+ } = splitFieldInternalAndForwardedProps(props, 'date-time');
59
34
  return useField({
60
35
  inputRef,
61
- forwardedProps: other,
62
- internalProps: {
63
- value,
64
- defaultValue,
65
- format,
66
- formatDensity,
67
- shouldRespectLeadingZeros,
68
- onChange,
69
- readOnly,
70
- onError,
71
- shouldDisableDate,
72
- shouldDisableMonth,
73
- shouldDisableYear,
74
- minDate,
75
- maxDate,
76
- disableFuture,
77
- disablePast,
78
- minTime,
79
- maxTime,
80
- minutesStep,
81
- shouldDisableClock,
82
- shouldDisableTime,
83
- disableIgnoringDatePartForTimeValidation,
84
- selectedSections,
85
- onSelectedSectionsChange,
86
- ampm,
87
- unstableFieldRef
88
- },
36
+ forwardedProps,
37
+ internalProps,
89
38
  valueManager: singleItemValueManager,
90
39
  fieldValueManager: singleItemFieldValueManager,
91
40
  validator: validateDateTime,
@@ -39,8 +39,7 @@ const DesktopDateTimePicker = /*#__PURE__*/React.forwardRef(function DesktopDate
39
39
  field: ownerState => {
40
40
  var _defaultizedProps$slo;
41
41
  return _extends({}, resolveComponentProps((_defaultizedProps$slo = defaultizedProps.slotProps) == null ? void 0 : _defaultizedProps$slo.field, ownerState), extractValidationProps(defaultizedProps), {
42
- ref,
43
- ampm: defaultizedProps.ampm
42
+ ref
44
43
  });
45
44
  },
46
45
  toolbar: _extends({
@@ -52,8 +52,7 @@ const DesktopTimePicker = /*#__PURE__*/React.forwardRef(function DesktopTimePick
52
52
  field: ownerState => {
53
53
  var _defaultizedProps$slo;
54
54
  return _extends({}, resolveComponentProps((_defaultizedProps$slo = defaultizedProps.slotProps) == null ? void 0 : _defaultizedProps$slo.field, ownerState), extractValidationProps(defaultizedProps), {
55
- ref,
56
- ampm: defaultizedProps.ampm
55
+ ref
57
56
  });
58
57
  },
59
58
  toolbar: _extends({
@@ -37,8 +37,7 @@ const MobileDateTimePicker = /*#__PURE__*/React.forwardRef(function MobileDateTi
37
37
  field: ownerState => {
38
38
  var _defaultizedProps$slo;
39
39
  return _extends({}, resolveComponentProps((_defaultizedProps$slo = defaultizedProps.slotProps) == null ? void 0 : _defaultizedProps$slo.field, ownerState), extractValidationProps(defaultizedProps), {
40
- ref,
41
- ampm: defaultizedProps.ampm
40
+ ref
42
41
  });
43
42
  },
44
43
  toolbar: _extends({
@@ -33,8 +33,7 @@ const MobileTimePicker = /*#__PURE__*/React.forwardRef(function MobileTimePicker
33
33
  field: ownerState => {
34
34
  var _defaultizedProps$slo;
35
35
  return _extends({}, resolveComponentProps((_defaultizedProps$slo = defaultizedProps.slotProps) == null ? void 0 : _defaultizedProps$slo.field, ownerState), extractValidationProps(defaultizedProps), {
36
- ref,
37
- ampm: defaultizedProps.ampm
36
+ ref
38
37
  });
39
38
  },
40
39
  toolbar: _extends({
@@ -1,3 +1,3 @@
1
1
  export { TimeField } from './TimeField';
2
2
  export { useTimeField as unstable_useTimeField } from './useTimeField';
3
- export type { UseTimeFieldProps, UseTimeFieldComponentProps, TimeFieldProps, } from './TimeField.types';
3
+ export type { UseTimeFieldProps, UseTimeFieldComponentProps, TimeFieldProps, UseTimeFieldDefaultizedProps, } from './TimeField.types';
@@ -1,2 +1,2 @@
1
1
  import { UseTimeFieldProps, UseTimeFieldParams } from './TimeField.types';
2
- export declare const useTimeField: <TDate, TChildProps extends {}>({ props, inputRef, }: UseTimeFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<Omit<TChildProps, keyof UseTimeFieldProps<TDate>>>;
2
+ export declare const useTimeField: <TDate, TChildProps extends {}>({ props: inProps, inputRef, }: UseTimeFieldParams<TDate, TChildProps>) => import("../internals/hooks/useField").UseFieldResponse<Omit<TChildProps & Omit<UseTimeFieldProps<TDate>, "format" | keyof import("../internals").BaseTimeValidationProps> & Required<Pick<UseTimeFieldProps<TDate>, "format" | keyof import("../internals").BaseTimeValidationProps>>, keyof UseTimeFieldProps<any>>>;
@@ -1,10 +1,9 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "onError", "disableFuture", "disablePast", "minTime", "maxTime", "minutesStep", "shouldDisableClock", "shouldDisableTime", "disableIgnoringDatePartForTimeValidation", "selectedSections", "onSelectedSectionsChange", "ampm", "unstableFieldRef"];
4
2
  import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
5
3
  import { useField } from '../internals/hooks/useField';
6
4
  import { validateTime } from '../internals/utils/validation/validateTime';
7
5
  import { useUtils } from '../internals/hooks/useUtils';
6
+ import { splitFieldInternalAndForwardedProps } from '../internals/utils/fields';
8
7
  const useDefaultizedTimeField = props => {
9
8
  var _props$ampm, _props$disablePast, _props$disableFuture, _props$format;
10
9
  const utils = useUtils();
@@ -17,58 +16,18 @@ const useDefaultizedTimeField = props => {
17
16
  });
18
17
  };
19
18
  export const useTimeField = ({
20
- props,
19
+ props: inProps,
21
20
  inputRef
22
21
  }) => {
23
- const _useDefaultizedTimeFi = useDefaultizedTimeField(props),
24
- {
25
- value,
26
- defaultValue,
27
- format,
28
- formatDensity,
29
- shouldRespectLeadingZeros,
30
- onChange,
31
- readOnly,
32
- onError,
33
- disableFuture,
34
- disablePast,
35
- minTime,
36
- maxTime,
37
- minutesStep,
38
- shouldDisableClock,
39
- shouldDisableTime,
40
- disableIgnoringDatePartForTimeValidation,
41
- selectedSections,
42
- onSelectedSectionsChange,
43
- ampm,
44
- unstableFieldRef
45
- } = _useDefaultizedTimeFi,
46
- other = _objectWithoutPropertiesLoose(_useDefaultizedTimeFi, _excluded);
22
+ const props = useDefaultizedTimeField(inProps);
23
+ const {
24
+ forwardedProps,
25
+ internalProps
26
+ } = splitFieldInternalAndForwardedProps(props, 'time');
47
27
  return useField({
48
28
  inputRef,
49
- forwardedProps: other,
50
- internalProps: {
51
- value,
52
- defaultValue,
53
- format,
54
- formatDensity,
55
- shouldRespectLeadingZeros,
56
- onChange,
57
- readOnly,
58
- onError,
59
- disableFuture,
60
- disablePast,
61
- minTime,
62
- maxTime,
63
- minutesStep,
64
- shouldDisableClock,
65
- shouldDisableTime,
66
- disableIgnoringDatePartForTimeValidation,
67
- selectedSections,
68
- onSelectedSectionsChange,
69
- ampm,
70
- unstableFieldRef
71
- },
29
+ forwardedProps,
30
+ internalProps,
72
31
  valueManager: singleItemValueManager,
73
32
  fieldValueManager: singleItemFieldValueManager,
74
33
  validator: validateTime,
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v6.4.0
2
+ * @mui/x-date-pickers v6.5.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -69,8 +69,16 @@ export const useField = params => {
69
69
  return;
70
70
  }
71
71
  const browserStartIndex = (_selectionStart = inputRef.current.selectionStart) != null ? _selectionStart : 0;
72
- const nextSectionIndex = browserStartIndex <= state.sections[0].startInInput ? 1 // Special case if browser index is in invisible characters at the beginning.
73
- : state.sections.findIndex(section => section.startInInput - section.startSeparator.length > browserStartIndex);
72
+ let nextSectionIndex;
73
+ if (browserStartIndex <= state.sections[0].startInInput) {
74
+ // Special case if browser index is in invisible characters at the beginning
75
+ nextSectionIndex = 1;
76
+ } else if (browserStartIndex >= state.sections[state.sections.length - 1].endInInput) {
77
+ // If the click is after the last character of the input, then we want to select the 1st section.
78
+ nextSectionIndex = 1;
79
+ } else {
80
+ nextSectionIndex = state.sections.findIndex(section => section.startInInput - section.startSeparator.length > browserStartIndex);
81
+ }
74
82
  const sectionIndex = nextSectionIndex === -1 ? state.sections.length - 1 : nextSectionIndex - 1;
75
83
  setSelectedSections(sectionIndex);
76
84
  };
@@ -45,6 +45,8 @@ export function useViews({
45
45
  // Update the current view when `openTo` or `views` props change
46
46
  if (previousOpenTo.current && previousOpenTo.current !== openTo || previousViews.current && previousViews.current.some(previousView => !views.includes(previousView))) {
47
47
  setView(views.includes(openTo) ? openTo : views[0]);
48
+ previousViews.current = views;
49
+ previousOpenTo.current = openTo;
48
50
  }
49
51
  }, [openTo, setView, view, views]);
50
52
  const viewIndex = views.indexOf(view);
@@ -43,13 +43,14 @@ export type { DefaultizedProps, MakeOptional } from './models/helpers';
43
43
  export type { WrapperVariant } from './models/common';
44
44
  export type { BaseDateValidationProps, BaseTimeValidationProps, TimeValidationProps, MonthValidationProps, YearValidationProps, DayValidationProps, DateTimeValidationProps, } from './models/validation';
45
45
  export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
46
+ export { splitFieldInternalAndForwardedProps } from './utils/fields';
46
47
  export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY, } from './utils/utils';
47
48
  export { defaultReduceAnimations } from './utils/defaultReduceAnimations';
48
49
  export { extractValidationProps } from './utils/validation/extractValidationProps';
49
50
  export { validateDate } from './utils/validation/validateDate';
50
51
  export { validateDateTime } from './utils/validation/validateDateTime';
51
52
  export { validateTime } from './utils/validation/validateTime';
52
- export { buildDeprecatedPropsWarning } from './utils/warning';
53
+ export { buildDeprecatedPropsWarning, buildWarning } from './utils/warning';
53
54
  export { uncapitalizeObjectKeys } from './utils/slots-migration';
54
55
  export type { UncapitalizeObjectKeys, SlotsAndSlotProps } from './utils/slots-migration';
55
56
  export { PickersCalendarHeader } from '../DateCalendar/PickersCalendarHeader';
@@ -16,13 +16,14 @@ export { useLocalizationContext, useDefaultDates, useUtils, useLocaleText, useNo
16
16
  export { useValidation } from './hooks/useValidation';
17
17
  export { usePreviousMonthDisabled, useNextMonthDisabled } from './hooks/date-helpers-hooks';
18
18
  export { applyDefaultDate, replaceInvalidDateByNull, areDatesEqual } from './utils/date-utils';
19
+ export { splitFieldInternalAndForwardedProps } from './utils/fields';
19
20
  export { executeInTheNextEventLoopTick, getActiveElement, onSpaceOrEnter, DEFAULT_DESKTOP_MODE_MEDIA_QUERY } from './utils/utils';
20
21
  export { defaultReduceAnimations } from './utils/defaultReduceAnimations';
21
22
  export { extractValidationProps } from './utils/validation/extractValidationProps';
22
23
  export { validateDate } from './utils/validation/validateDate';
23
24
  export { validateDateTime } from './utils/validation/validateDateTime';
24
25
  export { validateTime } from './utils/validation/validateTime';
25
- export { buildDeprecatedPropsWarning } from './utils/warning';
26
+ export { buildDeprecatedPropsWarning, buildWarning } from './utils/warning';
26
27
  export { uncapitalizeObjectKeys } from './utils/slots-migration';
27
28
  export { PickersCalendarHeader } from '../DateCalendar/PickersCalendarHeader';
28
29
  export { DayCalendar } from '../DateCalendar/DayCalendar';
@@ -0,0 +1,5 @@
1
+ import { FieldValueType } from '../../models';
2
+ export declare const splitFieldInternalAndForwardedProps: <TProps extends {}, TInternalPropNames extends keyof TProps>(props: TProps, valueType: FieldValueType) => {
3
+ forwardedProps: Omit<TProps, TInternalPropNames>;
4
+ internalProps: Pick<TProps, TInternalPropNames>;
5
+ };
@@ -0,0 +1,28 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { DATE_TIME_VALIDATION_PROP_NAMES, DATE_VALIDATION_PROP_NAMES, TIME_VALIDATION_PROP_NAMES } from './validation/extractValidationProps';
3
+ const SHARED_FIELD_INTERNAL_PROP_NAMES = ['value', 'defaultValue', 'format', 'formatDensity', 'onChange', 'readOnly', 'onError', 'shouldRespectLeadingZeros', 'selectedSections', 'onSelectedSectionsChange', 'unstableFieldRef'];
4
+ export const splitFieldInternalAndForwardedProps = (props, valueType) => {
5
+ const forwardedProps = _extends({}, props);
6
+ const internalProps = {};
7
+ const extractProp = propName => {
8
+ if (forwardedProps.hasOwnProperty(propName)) {
9
+ // @ts-ignore
10
+ internalProps[propName] = forwardedProps[propName];
11
+ delete forwardedProps[propName];
12
+ }
13
+ };
14
+ SHARED_FIELD_INTERNAL_PROP_NAMES.forEach(extractProp);
15
+ if (valueType === 'date') {
16
+ DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
17
+ } else if (valueType === 'time') {
18
+ TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
19
+ } else if (valueType === 'date-time') {
20
+ DATE_VALIDATION_PROP_NAMES.forEach(extractProp);
21
+ TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
22
+ DATE_TIME_VALIDATION_PROP_NAMES.forEach(extractProp);
23
+ }
24
+ return {
25
+ forwardedProps,
26
+ internalProps
27
+ };
28
+ };
@@ -1,7 +1,11 @@
1
+ import { BaseDateValidationProps, BaseTimeValidationProps, DateTimeValidationProps, DayValidationProps, MonthValidationProps, TimeValidationProps, YearValidationProps } from '../../models/validation';
2
+ export declare const DATE_VALIDATION_PROP_NAMES: (keyof BaseDateValidationProps<any> | keyof YearValidationProps<any> | keyof MonthValidationProps<any> | keyof DayValidationProps<any>)[];
3
+ export declare const TIME_VALIDATION_PROP_NAMES: (keyof BaseTimeValidationProps | keyof TimeValidationProps<any> | 'ampm')[];
4
+ export declare const DATE_TIME_VALIDATION_PROP_NAMES: (keyof DateTimeValidationProps<any>)[];
1
5
  /**
2
6
  * Extract the validation props for the props received by a component.
3
7
  * Limit the risk of forgetting some of them and reduce the bundle size.
4
8
  */
5
9
  export declare const extractValidationProps: <Props extends {
6
10
  [key: string]: any;
7
- }>(props: Props) => Pick<Props, "disableFuture" | "disablePast" | "maxDate" | "minDate" | "shouldDisableDate" | "shouldDisableMonth" | "shouldDisableYear" | "minutesStep" | "minTime" | "maxTime" | "shouldDisableTime" | "shouldDisableClock" | "disableIgnoringDatePartForTimeValidation" | "minDateTime" | "maxDateTime">;
11
+ }>(props: Props) => Pick<Props, "disableFuture" | "disablePast" | "maxDate" | "minDate" | "shouldDisableDate" | "shouldDisableMonth" | "shouldDisableYear" | "minutesStep" | "minTime" | "maxTime" | "ampm" | "shouldDisableTime" | "shouldDisableClock" | "disableIgnoringDatePartForTimeValidation" | "minDateTime" | "maxDateTime">;
@@ -1,4 +1,7 @@
1
- const VALIDATION_PROP_NAMES = ['disablePast', 'disableFuture', 'minDate', 'maxDate', 'minTime', 'maxTime', 'minDateTime', 'maxDateTime', 'shouldDisableDate', 'shouldDisableMonth', 'shouldDisableYear', 'shouldDisableClock', 'shouldDisableTime', 'minutesStep'];
1
+ export const DATE_VALIDATION_PROP_NAMES = ['disablePast', 'disableFuture', 'minDate', 'maxDate', 'shouldDisableDate', 'shouldDisableMonth', 'shouldDisableYear'];
2
+ export const TIME_VALIDATION_PROP_NAMES = ['disablePast', 'disableFuture', 'minTime', 'maxTime', 'shouldDisableClock', 'shouldDisableTime', 'minutesStep', 'ampm', 'disableIgnoringDatePartForTimeValidation'];
3
+ export const DATE_TIME_VALIDATION_PROP_NAMES = ['minDateTime', 'maxDateTime'];
4
+ const VALIDATION_PROP_NAMES = [...DATE_VALIDATION_PROP_NAMES, ...TIME_VALIDATION_PROP_NAMES, ...DATE_TIME_VALIDATION_PROP_NAMES];
2
5
  /**
3
6
  * Extract the validation props for the props received by a component.
4
7
  * Limit the risk of forgetting some of them and reduce the bundle size.
@@ -1,11 +1,10 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- var _excluded = ["value", "defaultValue", "format", "formatDensity", "shouldRespectLeadingZeros", "onChange", "readOnly", "onError", "shouldDisableDate", "shouldDisableMonth", "shouldDisableYear", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "unstableFieldRef"];
4
2
  import { singleItemFieldValueManager, singleItemValueManager } from '../internals/utils/valueManagers';
5
3
  import { useField } from '../internals/hooks/useField';
6
4
  import { validateDate } from '../internals/utils/validation/validateDate';
7
5
  import { applyDefaultDate } from '../internals/utils/date-utils';
8
6
  import { useUtils, useDefaultDates } from '../internals/hooks/useUtils';
7
+ import { splitFieldInternalAndForwardedProps } from '../internals/utils/fields';
9
8
  var useDefaultizedDateField = function useDefaultizedDateField(props) {
10
9
  var _props$disablePast, _props$disableFuture, _props$format;
11
10
  var utils = useUtils();
@@ -19,51 +18,16 @@ var useDefaultizedDateField = function useDefaultizedDateField(props) {
19
18
  });
20
19
  };
21
20
  export var useDateField = function useDateField(_ref) {
22
- var props = _ref.props,
21
+ var inProps = _ref.props,
23
22
  inputRef = _ref.inputRef;
24
- var _useDefaultizedDateFi = useDefaultizedDateField(props),
25
- value = _useDefaultizedDateFi.value,
26
- defaultValue = _useDefaultizedDateFi.defaultValue,
27
- format = _useDefaultizedDateFi.format,
28
- formatDensity = _useDefaultizedDateFi.formatDensity,
29
- shouldRespectLeadingZeros = _useDefaultizedDateFi.shouldRespectLeadingZeros,
30
- onChange = _useDefaultizedDateFi.onChange,
31
- readOnly = _useDefaultizedDateFi.readOnly,
32
- onError = _useDefaultizedDateFi.onError,
33
- shouldDisableDate = _useDefaultizedDateFi.shouldDisableDate,
34
- shouldDisableMonth = _useDefaultizedDateFi.shouldDisableMonth,
35
- shouldDisableYear = _useDefaultizedDateFi.shouldDisableYear,
36
- minDate = _useDefaultizedDateFi.minDate,
37
- maxDate = _useDefaultizedDateFi.maxDate,
38
- disableFuture = _useDefaultizedDateFi.disableFuture,
39
- disablePast = _useDefaultizedDateFi.disablePast,
40
- selectedSections = _useDefaultizedDateFi.selectedSections,
41
- onSelectedSectionsChange = _useDefaultizedDateFi.onSelectedSectionsChange,
42
- unstableFieldRef = _useDefaultizedDateFi.unstableFieldRef,
43
- other = _objectWithoutProperties(_useDefaultizedDateFi, _excluded);
23
+ var props = useDefaultizedDateField(inProps);
24
+ var _splitFieldInternalAn = splitFieldInternalAndForwardedProps(props, 'date'),
25
+ forwardedProps = _splitFieldInternalAn.forwardedProps,
26
+ internalProps = _splitFieldInternalAn.internalProps;
44
27
  return useField({
45
28
  inputRef: inputRef,
46
- forwardedProps: other,
47
- internalProps: {
48
- value: value,
49
- defaultValue: defaultValue,
50
- format: format,
51
- formatDensity: formatDensity,
52
- shouldRespectLeadingZeros: shouldRespectLeadingZeros,
53
- onChange: onChange,
54
- readOnly: readOnly,
55
- onError: onError,
56
- shouldDisableDate: shouldDisableDate,
57
- shouldDisableMonth: shouldDisableMonth,
58
- shouldDisableYear: shouldDisableYear,
59
- minDate: minDate,
60
- maxDate: maxDate,
61
- disableFuture: disableFuture,
62
- disablePast: disablePast,
63
- selectedSections: selectedSections,
64
- onSelectedSectionsChange: onSelectedSectionsChange,
65
- unstableFieldRef: unstableFieldRef
66
- },
29
+ forwardedProps: forwardedProps,
30
+ internalProps: internalProps,
67
31
  valueManager: singleItemValueManager,
68
32
  fieldValueManager: singleItemFieldValueManager,
69
33
  validator: validateDate,