@mui/x-date-pickers-pro 6.0.3 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/DateRangePicker/DateRangePicker.js +12 -0
- package/DateRangePicker/DateRangePickerToolbar.d.ts +1 -1
- package/DateRangePicker/shared.d.ts +1 -1
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
- package/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +1 -1
- package/MultiInputDateTimeRangeField/MultiInputDateTimeRangeField.types.d.ts +1 -1
- package/MultiInputTimeRangeField/MultiInputTimeRangeField.types.d.ts +1 -1
- package/SingleInputDateRangeField/SingleInputDateRangeField.d.ts +1 -0
- package/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -0
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.d.ts +1 -0
- package/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -0
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.d.ts +1 -0
- package/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -0
- package/dateRangeViewRenderers/dateRangeViewRenderers.d.ts +1 -1
- package/index.js +1 -1
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.d.ts +1 -1
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +32 -40
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.types.d.ts +9 -29
- package/internal/hooks/useEnrichedRangePickerFieldProps.d.ts +53 -0
- package/internal/hooks/useEnrichedRangePickerFieldProps.js +202 -0
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.d.ts +1 -1
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +36 -39
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.types.d.ts +9 -28
- package/internal/hooks/useMultiInputRangeField/useMultiInputDateRangeField.d.ts +1 -1
- package/internal/hooks/useMultiInputRangeField/useMultiInputDateTimeRangeField.d.ts +1 -1
- package/internal/hooks/useMultiInputRangeField/useMultiInputRangeField.types.d.ts +3 -3
- package/internal/hooks/useMultiInputRangeField/useMultiInputTimeRangeField.d.ts +1 -1
- package/internal/hooks/useRangePosition.d.ts +4 -0
- package/internal/hooks/useRangePosition.js +16 -1
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.d.ts +1 -1
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.types.d.ts +3 -2
- package/internal/hooks/validation/useDateRangeValidation.d.ts +2 -1
- package/internal/hooks/validation/useDateTimeRangeValidation.d.ts +2 -1
- package/internal/hooks/validation/useTimeRangeValidation.d.ts +2 -1
- package/internal/models/fields.d.ts +7 -2
- package/internal/models/index.d.ts +1 -0
- package/internal/models/index.js +2 -1
- package/internal/models/rangePickerProps.d.ts +17 -0
- package/internal/models/rangePickerProps.js +1 -0
- package/internal/utils/releaseInfo.js +1 -1
- package/internal/utils/valueManagers.js +21 -19
- package/legacy/DateRangePicker/DateRangePicker.js +12 -0
- package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
- package/legacy/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -0
- package/legacy/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -0
- package/legacy/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -0
- package/legacy/index.js +1 -1
- package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +32 -40
- package/legacy/internal/hooks/useEnrichedRangePickerFieldProps.js +200 -0
- package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +36 -39
- package/legacy/internal/hooks/useRangePosition.js +16 -1
- package/legacy/internal/models/index.js +2 -1
- package/legacy/internal/models/rangePickerProps.js +1 -0
- package/legacy/internal/utils/releaseInfo.js +1 -1
- package/legacy/internal/utils/valueManagers.js +21 -19
- package/modern/DateRangePicker/DateRangePicker.js +12 -0
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
- package/modern/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -0
- package/modern/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -0
- package/modern/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -0
- package/modern/index.js +1 -1
- package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +30 -38
- package/modern/internal/hooks/useEnrichedRangePickerFieldProps.js +195 -0
- package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +35 -38
- package/modern/internal/hooks/useRangePosition.js +16 -1
- package/modern/internal/models/index.js +2 -1
- package/modern/internal/models/rangePickerProps.js +1 -0
- package/modern/internal/utils/releaseInfo.js +1 -1
- package/modern/internal/utils/valueManagers.js +21 -19
- package/node/DateRangePicker/DateRangePicker.js +12 -0
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +12 -0
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +12 -0
- package/node/SingleInputDateRangeField/SingleInputDateRangeField.js +1 -0
- package/node/SingleInputDateTimeRangeField/SingleInputDateTimeRangeField.js +1 -0
- package/node/SingleInputTimeRangeField/SingleInputTimeRangeField.js +1 -0
- package/node/index.js +1 -1
- package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +29 -37
- package/node/internal/hooks/useEnrichedRangePickerFieldProps.js +205 -0
- package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +34 -37
- package/node/internal/hooks/useRangePosition.js +18 -1
- package/node/internal/models/index.js +11 -0
- package/node/internal/models/rangePickerProps.js +5 -0
- package/node/internal/utils/releaseInfo.js +1 -1
- package/node/internal/utils/valueManagers.js +20 -18
- package/package.json +2 -2
- package/internal/hooks/useRangePickerInputProps.d.ts +0 -19
- package/internal/hooks/useRangePickerInputProps.js +0 -89
- package/legacy/internal/hooks/useRangePickerInputProps.js +0 -88
- package/modern/internal/hooks/useRangePickerInputProps.js +0 -86
- package/node/internal/hooks/useRangePickerInputProps.js +0 -96
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,67 @@
|
|
|
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
|
+
## 6.0.4
|
|
7
|
+
|
|
8
|
+
_Mar 30, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🌍 Add Danish (da-DK), and improve Norwegian (nb-NO), Spanish (es-ES), and Swedish (sv-SE) locales
|
|
13
|
+
- 🐞 Bugfixes
|
|
14
|
+
- 📚 Documentation improvements
|
|
15
|
+
|
|
16
|
+
### `@mui/x-data-grid@v6.0.4` / `@mui/x-data-grid-pro@v6.0.4` / `@mui/x-data-grid-premium@v6.0.4`
|
|
17
|
+
|
|
18
|
+
#### Changes
|
|
19
|
+
|
|
20
|
+
- [DataGrid] Fix column header tooltip not showing when the title is truncated (#8433) @rohitnatesh
|
|
21
|
+
- [DataGrid] Fix filter model buttons' display condition (#8415) @MBilalShafi
|
|
22
|
+
- [DataGrid] Fix infinite rerender in a flex parent (#8436) @cherniavskii
|
|
23
|
+
- [DataGrid] Prevent reopening column menu when clicking in the button while it is open (#8286) @tanuj-22
|
|
24
|
+
- [DataGrid] Rename `components` by `slots` in column menu API (#7999) @MBilalShafi
|
|
25
|
+
- [DataGrid] Remove hardcoded CSS classes' usages (#8444) @MBilalShafi
|
|
26
|
+
- [DataGridPremium] Fix aggregation initial state causing issue with quick filter (#8441) @MBilalShafi
|
|
27
|
+
- [l10n] Improve Danish (da-DK) locale (#8368) @BossElijah
|
|
28
|
+
- [l10n] Improve Danish (da-DK) locale (#8378) @BossElijah
|
|
29
|
+
- [l10n] Improve Norwegian (nb-NO) locale (#8367) @BossElijah
|
|
30
|
+
- [l10n] Improve Norwegian (nb-NO) locale (#8409) @BossElijah
|
|
31
|
+
- [l10n] Improve Spanish (es-ES) locale (#8420) @martjanz
|
|
32
|
+
- [l10n] Improve Swedish (sv-SE) locale (#8381) @BossElijah
|
|
33
|
+
|
|
34
|
+
### `@mui/x-date-pickers@v6.0.4` / `@mui/x-date-pickers-pro@v6.0.4`
|
|
35
|
+
|
|
36
|
+
#### Changes
|
|
37
|
+
|
|
38
|
+
- [fields] Add missing tokens to `AdapterDateFnsJalali` (#8402) @flaviendelangle
|
|
39
|
+
- [fields] Clean the active date manager (#8370) @flaviendelangle
|
|
40
|
+
- [fields] Cleanup `useFieldState` (#8292) @flaviendelangle
|
|
41
|
+
- [fields] Only add RTL characters when needed (#8325) @flaviendelangle
|
|
42
|
+
- [pickers] Add support for single input fields in range pickers (#7927) @flaviendelangle
|
|
43
|
+
- [pickers] Allows non token characters in format (#8256) @alexfauquette
|
|
44
|
+
- [pickers] Avoid root imports and move public models to the models folder (#8337) @flaviendelangle
|
|
45
|
+
- [pickers] Update `view` when `views` or `openTo` changes (#8361) @LukasTy
|
|
46
|
+
- [l10n] Improve Norwegian (nb-NO) locale (#8382) @BossElijah
|
|
47
|
+
- [l10n] Add Danish (da-DK) locale (#8379) @BossElijah
|
|
48
|
+
- [l10n] Improve Swedish (sv-SE) locale (#8381) @BossElijah
|
|
49
|
+
|
|
50
|
+
### `@mui/x-codemod@v6.0.4`
|
|
51
|
+
|
|
52
|
+
#### Changes
|
|
53
|
+
|
|
54
|
+
- [codemod] Fix `remove-stabilized-experimentalFeatures` codemod (#8289) @alexfauquette
|
|
55
|
+
|
|
56
|
+
### Docs
|
|
57
|
+
|
|
58
|
+
- [docs] Fix `GridCellParams` signature in migration guide (#8427) @cherniavskii
|
|
59
|
+
- [docs] Fix "Custom field" demos responsive styles (#8408) @LukasTy
|
|
60
|
+
- [docs] Remove `label` from demos where it reduces clarity (#8416) @LukasTy
|
|
61
|
+
- [docs] Update slots' references in Data Grid migration guide (#8159) @MBilalShafi
|
|
62
|
+
|
|
63
|
+
### Core
|
|
64
|
+
|
|
65
|
+
- [charts] Work on typing (#8421) @flaviendelangle
|
|
66
|
+
|
|
6
67
|
## 6.0.3
|
|
7
68
|
|
|
8
69
|
_Mar 23, 2023_
|
|
@@ -147,6 +147,18 @@ process.env.NODE_ENV !== "production" ? DateRangePicker.propTypes = {
|
|
|
147
147
|
* Defaults to localized format based on the used `views`.
|
|
148
148
|
*/
|
|
149
149
|
format: PropTypes.string,
|
|
150
|
+
/**
|
|
151
|
+
* Pass a ref to the `input` element.
|
|
152
|
+
* Ignored if the field has several inputs.
|
|
153
|
+
*/
|
|
154
|
+
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
155
|
+
current: PropTypes.object
|
|
156
|
+
})]),
|
|
157
|
+
/**
|
|
158
|
+
* The label content.
|
|
159
|
+
* Ignored if the field has several inputs.
|
|
160
|
+
*/
|
|
161
|
+
label: PropTypes.node,
|
|
150
162
|
/**
|
|
151
163
|
* If `true`, calls `renderLoading` instead of rendering the day calendar.
|
|
152
164
|
* Can be used to preload information and show it in calendar.
|
|
@@ -3,7 +3,7 @@ import { BaseToolbarProps, ExportedBaseToolbarProps } from '@mui/x-date-pickers/
|
|
|
3
3
|
import { DateRange } from '../internal/models';
|
|
4
4
|
import { UseRangePositionResponse } from '../internal/hooks/useRangePosition';
|
|
5
5
|
import { DateRangePickerToolbarClasses } from './dateRangePickerToolbarClasses';
|
|
6
|
-
export interface DateRangePickerToolbarProps<TDate> extends Omit<BaseToolbarProps<DateRange<TDate>, 'day'>, 'views' | 'view' | 'onViewChange' | 'onChange' | 'isLandscape'>, UseRangePositionResponse {
|
|
6
|
+
export interface DateRangePickerToolbarProps<TDate> extends Omit<BaseToolbarProps<DateRange<TDate>, 'day'>, 'views' | 'view' | 'onViewChange' | 'onChange' | 'isLandscape'>, Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'> {
|
|
7
7
|
classes?: Partial<DateRangePickerToolbarClasses>;
|
|
8
8
|
}
|
|
9
9
|
export interface ExportedDateRangePickerToolbarProps extends ExportedBaseToolbarProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { LocalizedComponent } from '@mui/x-date-pickers';
|
|
2
|
+
import { LocalizedComponent } from '@mui/x-date-pickers/locales';
|
|
3
3
|
import { DefaultizedProps, BaseDateValidationProps, BasePickerInputProps, PickerViewRendererLookup, UncapitalizeObjectKeys } from '@mui/x-date-pickers/internals';
|
|
4
4
|
import { DateRangeValidationError } from '../internal/hooks/validation/useDateRangeValidation';
|
|
5
5
|
import { DateRange } from '../internal/models';
|
|
@@ -155,6 +155,18 @@ DesktopDateRangePicker.propTypes = {
|
|
|
155
155
|
* Defaults to localized format based on the used `views`.
|
|
156
156
|
*/
|
|
157
157
|
format: PropTypes.string,
|
|
158
|
+
/**
|
|
159
|
+
* Pass a ref to the `input` element.
|
|
160
|
+
* Ignored if the field has several inputs.
|
|
161
|
+
*/
|
|
162
|
+
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
163
|
+
current: PropTypes.object
|
|
164
|
+
})]),
|
|
165
|
+
/**
|
|
166
|
+
* The label content.
|
|
167
|
+
* Ignored if the field has several inputs.
|
|
168
|
+
*/
|
|
169
|
+
label: PropTypes.node,
|
|
158
170
|
/**
|
|
159
171
|
* If `true`, calls `renderLoading` instead of rendering the day calendar.
|
|
160
172
|
* Can be used to preload information and show it in calendar.
|
|
@@ -158,6 +158,18 @@ MobileDateRangePicker.propTypes = {
|
|
|
158
158
|
* Defaults to localized format based on the used `views`.
|
|
159
159
|
*/
|
|
160
160
|
format: PropTypes.string,
|
|
161
|
+
/**
|
|
162
|
+
* Pass a ref to the `input` element.
|
|
163
|
+
* Ignored if the field has several inputs.
|
|
164
|
+
*/
|
|
165
|
+
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
166
|
+
current: PropTypes.object
|
|
167
|
+
})]),
|
|
168
|
+
/**
|
|
169
|
+
* The label content.
|
|
170
|
+
* Ignored if the field has several inputs.
|
|
171
|
+
*/
|
|
172
|
+
label: PropTypes.node,
|
|
161
173
|
/**
|
|
162
174
|
* If `true`, calls `renderLoading` instead of rendering the day calendar.
|
|
163
175
|
* Can be used to preload information and show it in calendar.
|
|
@@ -9,7 +9,7 @@ import { UseDateRangeFieldProps } from '../internal/models/dateRange';
|
|
|
9
9
|
import { RangePosition } from '../internal/models/range';
|
|
10
10
|
import { UseMultiInputRangeFieldParams } from '../internal/hooks/useMultiInputRangeField/useMultiInputRangeField.types';
|
|
11
11
|
import { RangeFieldSection } from '../internal/models/fields';
|
|
12
|
-
export type UseMultiInputDateRangeFieldParams<TDate,
|
|
12
|
+
export type UseMultiInputDateRangeFieldParams<TDate, TTextFieldSlotProps extends {}> = UseMultiInputRangeFieldParams<UseMultiInputDateRangeFieldProps<TDate>, TTextFieldSlotProps>;
|
|
13
13
|
export interface UseMultiInputDateRangeFieldProps<TDate> extends Omit<UseDateRangeFieldProps<TDate>, 'unstableFieldRef'> {
|
|
14
14
|
unstableStartFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
|
|
15
15
|
unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
|
|
@@ -9,7 +9,7 @@ import { UseDateTimeRangeFieldDefaultizedProps, UseDateTimeRangeFieldProps } fro
|
|
|
9
9
|
import { RangePosition } from '../internal/models/range';
|
|
10
10
|
import { RangeFieldSection } from '../internal/models/fields';
|
|
11
11
|
import { UseMultiInputRangeFieldParams } from '../internal/hooks/useMultiInputRangeField/useMultiInputRangeField.types';
|
|
12
|
-
export type UseMultiInputDateTimeRangeFieldParams<TDate,
|
|
12
|
+
export type UseMultiInputDateTimeRangeFieldParams<TDate, TTextFieldSlotProps extends {}> = UseMultiInputRangeFieldParams<UseMultiInputDateTimeRangeFieldProps<TDate>, TTextFieldSlotProps>;
|
|
13
13
|
export interface UseMultiInputDateTimeRangeFieldProps<TDate> extends Omit<UseDateTimeRangeFieldProps<TDate>, 'unstableFieldRef'> {
|
|
14
14
|
unstableStartFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
|
|
15
15
|
unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
|
|
@@ -9,7 +9,7 @@ import { UseTimeRangeFieldDefaultizedProps, UseTimeRangeFieldProps } from '../in
|
|
|
9
9
|
import { RangePosition } from '../internal/models/range';
|
|
10
10
|
import { UseMultiInputRangeFieldParams } from '../internal/hooks/useMultiInputRangeField/useMultiInputRangeField.types';
|
|
11
11
|
import { RangeFieldSection } from '../internal/models/fields';
|
|
12
|
-
export type UseMultiInputTimeRangeFieldParams<TDate,
|
|
12
|
+
export type UseMultiInputTimeRangeFieldParams<TDate, TTextFieldSlotProps extends {}> = UseMultiInputRangeFieldParams<UseMultiInputTimeRangeFieldProps<TDate>, TTextFieldSlotProps>;
|
|
13
13
|
export interface UseMultiInputTimeRangeFieldProps<TDate> extends Omit<UseTimeRangeFieldProps<TDate>, 'unstableFieldRef'> {
|
|
14
14
|
unstableStartFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
|
|
15
15
|
unstableEndFieldRef?: React.Ref<FieldRef<RangeFieldSection>>;
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { SingleInputDateRangeFieldProps } from './SingleInputDateRangeField.types';
|
|
3
3
|
type DateRangeFieldComponent = (<TDate>(props: SingleInputDateRangeFieldProps<TDate> & React.RefAttributes<HTMLInputElement>) => JSX.Element) & {
|
|
4
4
|
propTypes?: any;
|
|
5
|
+
fieldType?: string;
|
|
5
6
|
};
|
|
6
7
|
declare const SingleInputDateRangeField: DateRangeFieldComponent;
|
|
7
8
|
export { SingleInputDateRangeField };
|
|
@@ -52,6 +52,7 @@ const SingleInputDateRangeField = /*#__PURE__*/React.forwardRef(function SingleI
|
|
|
52
52
|
})
|
|
53
53
|
}));
|
|
54
54
|
});
|
|
55
|
+
SingleInputDateRangeField.fieldType = 'single-input';
|
|
55
56
|
process.env.NODE_ENV !== "production" ? SingleInputDateRangeField.propTypes = {
|
|
56
57
|
// ----------------------------- Warning --------------------------------
|
|
57
58
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { SingleInputDateTimeRangeFieldProps } from './SingleInputDateTimeRangeField.types';
|
|
3
3
|
type DateRangeFieldComponent = (<TDate>(props: SingleInputDateTimeRangeFieldProps<TDate> & React.RefAttributes<HTMLInputElement>) => JSX.Element) & {
|
|
4
4
|
propTypes?: any;
|
|
5
|
+
fieldType?: string;
|
|
5
6
|
};
|
|
6
7
|
declare const SingleInputDateTimeRangeField: DateRangeFieldComponent;
|
|
7
8
|
export { SingleInputDateTimeRangeField };
|
|
@@ -52,6 +52,7 @@ const SingleInputDateTimeRangeField = /*#__PURE__*/React.forwardRef(function Sin
|
|
|
52
52
|
})
|
|
53
53
|
}));
|
|
54
54
|
});
|
|
55
|
+
SingleInputDateTimeRangeField.fieldType = 'single-input';
|
|
55
56
|
process.env.NODE_ENV !== "production" ? SingleInputDateTimeRangeField.propTypes = {
|
|
56
57
|
// ----------------------------- Warning --------------------------------
|
|
57
58
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { SingleInputTimeRangeFieldProps } from './SingleInputTimeRangeField.types';
|
|
3
3
|
type DateRangeFieldComponent = (<TDate>(props: SingleInputTimeRangeFieldProps<TDate> & React.RefAttributes<HTMLInputElement>) => JSX.Element) & {
|
|
4
4
|
propTypes?: any;
|
|
5
|
+
fieldType?: string;
|
|
5
6
|
};
|
|
6
7
|
declare const SingleInputTimeRangeField: DateRangeFieldComponent;
|
|
7
8
|
export { SingleInputTimeRangeField };
|
|
@@ -52,6 +52,7 @@ const SingleInputTimeRangeField = /*#__PURE__*/React.forwardRef(function SingleI
|
|
|
52
52
|
})
|
|
53
53
|
}));
|
|
54
54
|
});
|
|
55
|
+
SingleInputTimeRangeField.fieldType = 'single-input';
|
|
55
56
|
process.env.NODE_ENV !== "production" ? SingleInputTimeRangeField.propTypes = {
|
|
56
57
|
// ----------------------------- Warning --------------------------------
|
|
57
58
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DateOrTimeView } from '@mui/x-date-pickers/
|
|
2
|
+
import { DateOrTimeView } from '@mui/x-date-pickers/models';
|
|
3
3
|
import { DateRangeCalendarProps } from '../DateRangeCalendar';
|
|
4
4
|
export interface DateRangeViewRendererProps<TDate, TView extends DateOrTimeView> extends DateRangeCalendarProps<TDate> {
|
|
5
5
|
view: TView;
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { DateOrTimeView } from '@mui/x-date-pickers/
|
|
2
|
+
import { DateOrTimeView } from '@mui/x-date-pickers/models';
|
|
3
3
|
import { UseDesktopRangePickerParams, UseDesktopRangePickerProps } from './useDesktopRangePicker.types';
|
|
4
4
|
export declare const useDesktopRangePicker: <TDate, TView extends DateOrTimeView, TExternalProps extends UseDesktopRangePickerProps<TDate, TView, any, TExternalProps>>({ props, valueManager, validator, }: UseDesktopRangePickerParams<TDate, TView, TExternalProps>) => {
|
|
5
5
|
renderPicker: () => JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
4
4
|
import { useLicenseVerifier } from '@mui/x-license-pro';
|
|
5
5
|
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
6
6
|
import { PickersLayout } from '@mui/x-date-pickers/PickersLayout';
|
|
7
7
|
import { executeInTheNextEventLoopTick, getActiveElement, usePicker, PickersPopper } from '@mui/x-date-pickers/internals';
|
|
8
|
-
import {
|
|
8
|
+
import { useEnrichedRangePickerFieldProps } from '../useEnrichedRangePickerFieldProps';
|
|
9
9
|
import { getReleaseInfo } from '../../utils/releaseInfo';
|
|
10
10
|
import { useRangePosition } from '../useRangePosition';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -16,7 +16,7 @@ export const useDesktopRangePicker = ({
|
|
|
16
16
|
valueManager,
|
|
17
17
|
validator
|
|
18
18
|
}) => {
|
|
19
|
-
var _slots$layout;
|
|
19
|
+
var _fieldType, _slots$layout;
|
|
20
20
|
useLicenseVerifier('x-date-pickers-pro', releaseInfo);
|
|
21
21
|
const {
|
|
22
22
|
slots,
|
|
@@ -24,17 +24,20 @@ export const useDesktopRangePicker = ({
|
|
|
24
24
|
className,
|
|
25
25
|
sx,
|
|
26
26
|
format,
|
|
27
|
+
label,
|
|
28
|
+
inputRef,
|
|
27
29
|
readOnly,
|
|
28
30
|
disabled,
|
|
29
31
|
autoFocus,
|
|
30
32
|
disableOpenPicker,
|
|
31
33
|
localeText
|
|
32
34
|
} = props;
|
|
33
|
-
const
|
|
35
|
+
const fieldContainerRef = React.useRef(null);
|
|
34
36
|
const popperRef = React.useRef(null);
|
|
35
37
|
const {
|
|
36
38
|
rangePosition,
|
|
37
|
-
onRangePositionChange
|
|
39
|
+
onRangePositionChange,
|
|
40
|
+
singleInputFieldRef
|
|
38
41
|
} = useRangePosition(props);
|
|
39
42
|
const {
|
|
40
43
|
open,
|
|
@@ -56,26 +59,15 @@ export const useDesktopRangePicker = ({
|
|
|
56
59
|
});
|
|
57
60
|
const handleBlur = () => {
|
|
58
61
|
executeInTheNextEventLoopTick(() => {
|
|
59
|
-
var
|
|
60
|
-
if ((
|
|
62
|
+
var _fieldContainerRef$cu, _popperRef$current;
|
|
63
|
+
if ((_fieldContainerRef$cu = fieldContainerRef.current) != null && _fieldContainerRef$cu.contains(getActiveElement(document)) || (_popperRef$current = popperRef.current) != null && _popperRef$current.contains(getActiveElement(document))) {
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
63
66
|
actions.onDismiss();
|
|
64
67
|
});
|
|
65
68
|
};
|
|
66
|
-
const fieldSlotProps = useRangePickerInputProps({
|
|
67
|
-
wrapperVariant: 'desktop',
|
|
68
|
-
open,
|
|
69
|
-
actions,
|
|
70
|
-
readOnly,
|
|
71
|
-
disabled,
|
|
72
|
-
disableOpenPicker,
|
|
73
|
-
localeText,
|
|
74
|
-
onBlur: handleBlur,
|
|
75
|
-
rangePosition,
|
|
76
|
-
onRangePositionChange
|
|
77
|
-
});
|
|
78
69
|
const Field = slots.field;
|
|
70
|
+
const fieldType = (_fieldType = Field.fieldType) != null ? _fieldType : 'multi-input';
|
|
79
71
|
const fieldProps = useSlotProps({
|
|
80
72
|
elementType: Field,
|
|
81
73
|
externalSlotProps: slotProps == null ? void 0 : slotProps.field,
|
|
@@ -86,25 +78,28 @@ export const useDesktopRangePicker = ({
|
|
|
86
78
|
sx,
|
|
87
79
|
format,
|
|
88
80
|
autoFocus: autoFocus && !props.open,
|
|
89
|
-
ref:
|
|
81
|
+
ref: fieldContainerRef
|
|
82
|
+
}, fieldType === 'single-input' && {
|
|
83
|
+
inputRef
|
|
90
84
|
}),
|
|
91
85
|
ownerState: props
|
|
92
86
|
});
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
87
|
+
const enrichedFieldProps = useEnrichedRangePickerFieldProps({
|
|
88
|
+
wrapperVariant: 'desktop',
|
|
89
|
+
fieldType,
|
|
90
|
+
open,
|
|
91
|
+
actions,
|
|
92
|
+
readOnly,
|
|
93
|
+
disableOpenPicker,
|
|
94
|
+
label,
|
|
95
|
+
localeText,
|
|
96
|
+
onBlur: handleBlur,
|
|
97
|
+
rangePosition,
|
|
98
|
+
onRangePositionChange,
|
|
99
|
+
singleInputFieldRef,
|
|
100
|
+
pickerSlotProps: slotProps,
|
|
101
|
+
pickerSlots: slots,
|
|
102
|
+
fieldProps
|
|
108
103
|
});
|
|
109
104
|
const slotPropsForLayout = _extends({}, slotProps, {
|
|
110
105
|
toolbar: _extends({}, slotProps == null ? void 0 : slotProps.toolbar, {
|
|
@@ -115,13 +110,10 @@ export const useDesktopRangePicker = ({
|
|
|
115
110
|
const Layout = (_slots$layout = slots == null ? void 0 : slots.layout) != null ? _slots$layout : PickersLayout;
|
|
116
111
|
const renderPicker = () => /*#__PURE__*/_jsxs(LocalizationProvider, {
|
|
117
112
|
localeText: localeText,
|
|
118
|
-
children: [/*#__PURE__*/_jsx(Field, _extends({},
|
|
119
|
-
slots: slotsForField,
|
|
120
|
-
slotProps: slotPropsForField
|
|
121
|
-
})), /*#__PURE__*/_jsx(PickersPopper, _extends({
|
|
113
|
+
children: [/*#__PURE__*/_jsx(Field, _extends({}, enrichedFieldProps)), /*#__PURE__*/_jsx(PickersPopper, _extends({
|
|
122
114
|
role: "tooltip",
|
|
123
115
|
containerRef: popperRef,
|
|
124
|
-
anchorEl:
|
|
116
|
+
anchorEl: fieldContainerRef.current,
|
|
125
117
|
onBlur: handleBlur
|
|
126
118
|
}, actions, {
|
|
127
119
|
open: open,
|
|
@@ -1,35 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { SlotComponentProps } from '@mui/base/utils';
|
|
6
|
-
import { ExportedPickersLayoutSlotsComponent, ExportedPickersLayoutSlotsComponentsProps } from '@mui/x-date-pickers/PickersLayout/PickersLayout.types';
|
|
7
|
-
import { DateOrTimeView, UsePickerParams, BasePickerProps, PickersPopperSlotsComponent, PickersPopperSlotsComponentsProps, ExportedBaseToolbarProps, UsePickerViewsProps, UncapitalizeObjectKeys, BaseNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerViewsNonStaticProps } from '@mui/x-date-pickers/internals';
|
|
8
|
-
import { DateRange, RangeFieldSection } from '../../models';
|
|
9
|
-
import { BaseMultiInputFieldProps } from '../../models/fields';
|
|
1
|
+
import { UsePickerParams, BasePickerProps, PickersPopperSlotsComponent, PickersPopperSlotsComponentsProps, ExportedBaseToolbarProps, UsePickerViewsProps, UncapitalizeObjectKeys, BaseNonStaticPickerProps, UsePickerValueNonStaticProps, UsePickerViewsNonStaticProps } from '@mui/x-date-pickers/internals';
|
|
2
|
+
import { DateOrTimeView } from '@mui/x-date-pickers/models';
|
|
3
|
+
import { ExportedPickersLayoutSlotsComponent, ExportedPickersLayoutSlotsComponentsProps } from '@mui/x-date-pickers/PickersLayout';
|
|
4
|
+
import { DateRange, RangeFieldSection, BaseRangeNonStaticPickerProps } from '../../models';
|
|
10
5
|
import { UseRangePositionProps, UseRangePositionResponse } from '../useRangePosition';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
FieldRoot?: React.ElementType<StackProps>;
|
|
14
|
-
FieldSeparator?: React.ElementType<TypographyProps>;
|
|
15
|
-
/**
|
|
16
|
-
* Form control with an input to render a date or time inside the default field.
|
|
17
|
-
* It is rendered twice: once for the start element and once for the end element.
|
|
18
|
-
* Receives the same props as `@mui/material/TextField`.
|
|
19
|
-
* @default TextField from '@mui/material'
|
|
20
|
-
*/
|
|
21
|
-
TextField?: React.ElementType<TextFieldProps>;
|
|
6
|
+
import { RangePickerFieldSlotsComponent, RangePickerFieldSlotsComponentsProps } from '../useEnrichedRangePickerFieldProps';
|
|
7
|
+
export interface UseDesktopRangePickerSlotsComponent<TDate, TView extends DateOrTimeView> extends PickersPopperSlotsComponent, ExportedPickersLayoutSlotsComponent<DateRange<TDate>, TDate, TView>, RangePickerFieldSlotsComponent {
|
|
22
8
|
}
|
|
23
|
-
export interface UseDesktopRangePickerSlotsComponentsProps<TDate, TView extends DateOrTimeView> extends PickersPopperSlotsComponentsProps, ExportedPickersLayoutSlotsComponentsProps<DateRange<TDate>, TDate, TView> {
|
|
24
|
-
field?: SlotComponentProps<React.ElementType<BaseMultiInputFieldProps<DateRange<TDate>, RangeFieldSection, unknown>>, {}, unknown>;
|
|
25
|
-
fieldRoot?: SlotComponentProps<typeof Stack, {}, unknown>;
|
|
26
|
-
fieldSeparator?: SlotComponentProps<typeof Typography, {}, unknown>;
|
|
27
|
-
textField?: SlotComponentProps<typeof TextField, {}, {
|
|
28
|
-
position?: 'start' | 'end';
|
|
29
|
-
} & Record<string, any>>;
|
|
9
|
+
export interface UseDesktopRangePickerSlotsComponentsProps<TDate, TView extends DateOrTimeView> extends PickersPopperSlotsComponentsProps, ExportedPickersLayoutSlotsComponentsProps<DateRange<TDate>, TDate, TView>, RangePickerFieldSlotsComponentsProps<TDate> {
|
|
30
10
|
toolbar?: ExportedBaseToolbarProps;
|
|
31
11
|
}
|
|
32
|
-
export interface DesktopRangeOnlyPickerProps<TDate> extends BaseNonStaticPickerProps, UsePickerValueNonStaticProps<TDate | null, RangeFieldSection>, UsePickerViewsNonStaticProps, UseRangePositionProps {
|
|
12
|
+
export interface DesktopRangeOnlyPickerProps<TDate> extends BaseNonStaticPickerProps, UsePickerValueNonStaticProps<TDate | null, RangeFieldSection>, UsePickerViewsNonStaticProps, BaseRangeNonStaticPickerProps, UseRangePositionProps {
|
|
33
13
|
/**
|
|
34
14
|
* If `true`, the start `input` element is focused during the first mount.
|
|
35
15
|
*/
|
|
@@ -47,7 +27,7 @@ export interface UseDesktopRangePickerProps<TDate, TView extends DateOrTimeView,
|
|
|
47
27
|
*/
|
|
48
28
|
slotProps?: UseDesktopRangePickerSlotsComponentsProps<TDate, TView>;
|
|
49
29
|
}
|
|
50
|
-
export interface DesktopRangePickerAdditionalViewProps extends UseRangePositionResponse {
|
|
30
|
+
export interface DesktopRangePickerAdditionalViewProps extends Pick<UseRangePositionResponse, 'rangePosition' | 'onRangePositionChange'> {
|
|
51
31
|
}
|
|
52
32
|
export interface UseDesktopRangePickerParams<TDate, TView extends DateOrTimeView, TExternalProps extends UseDesktopRangePickerProps<TDate, TView, any, TExternalProps>> extends Pick<UsePickerParams<DateRange<TDate>, TDate, TView, RangeFieldSection, TExternalProps, DesktopRangePickerAdditionalViewProps>, 'valueManager' | 'validator'> {
|
|
53
33
|
props: TExternalProps;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Stack, { StackProps } from '@mui/material/Stack';
|
|
3
|
+
import Typography, { TypographyProps } from '@mui/material/Typography';
|
|
4
|
+
import TextField, { TextFieldProps } from '@mui/material/TextField';
|
|
5
|
+
import { SlotComponentProps } from '@mui/base/utils';
|
|
6
|
+
import { BaseSingleInputFieldProps, DateOrTimeView } from '@mui/x-date-pickers/models';
|
|
7
|
+
import { PickersInputLocaleText } from '@mui/x-date-pickers/locales';
|
|
8
|
+
import { BaseFieldProps, UsePickerResponse, WrapperVariant, UncapitalizeObjectKeys, UsePickerProps } from '@mui/x-date-pickers/internals';
|
|
9
|
+
import { BaseMultiInputFieldProps, DateRange, RangeFieldSection, RangePosition, UseDateRangeFieldProps } from '../models';
|
|
10
|
+
import { UseRangePositionResponse } from './useRangePosition';
|
|
11
|
+
export interface RangePickerFieldSlotsComponent {
|
|
12
|
+
Field: React.ElementType;
|
|
13
|
+
/**
|
|
14
|
+
* Element rendered at the root.
|
|
15
|
+
* Ignored if the field has only one input.
|
|
16
|
+
*/
|
|
17
|
+
FieldRoot?: React.ElementType<StackProps>;
|
|
18
|
+
/**
|
|
19
|
+
* Element rendered between the two inputs.
|
|
20
|
+
* Ignored if the field has only one input.
|
|
21
|
+
*/
|
|
22
|
+
FieldSeparator?: React.ElementType<TypographyProps>;
|
|
23
|
+
/**
|
|
24
|
+
* Form control with an input to render a date or time inside the default field.
|
|
25
|
+
* It is rendered twice: once for the start element and once for the end element.
|
|
26
|
+
* Receives the same props as `@mui/material/TextField`.
|
|
27
|
+
* @default TextField from '@mui/material'
|
|
28
|
+
*/
|
|
29
|
+
TextField?: React.ElementType<TextFieldProps>;
|
|
30
|
+
}
|
|
31
|
+
export interface RangePickerFieldSlotsComponentsProps<TDate> {
|
|
32
|
+
field?: SlotComponentProps<React.ElementType<BaseMultiInputFieldProps<DateRange<TDate>, RangeFieldSection, unknown>>, {}, UsePickerProps<DateRange<TDate>, any, RangeFieldSection, any, any, any>>;
|
|
33
|
+
fieldRoot?: SlotComponentProps<typeof Stack, {}, Record<string, any>>;
|
|
34
|
+
fieldSeparator?: SlotComponentProps<typeof Typography, {}, Record<string, any>>;
|
|
35
|
+
textField?: SlotComponentProps<typeof TextField, {}, UseDateRangeFieldProps<TDate> & {
|
|
36
|
+
position?: RangePosition;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
export interface UseEnrichedRangePickerFieldPropsParams<TDate, TView extends DateOrTimeView, TError, FieldProps extends BaseFieldProps<DateRange<TDate>, RangeFieldSection, TError> = BaseFieldProps<DateRange<TDate>, RangeFieldSection, TError>> extends Pick<UsePickerResponse<DateRange<TDate>, TView, RangeFieldSection, any>, 'open' | 'actions'>, UseRangePositionResponse {
|
|
40
|
+
wrapperVariant: WrapperVariant;
|
|
41
|
+
fieldType: 'single-input' | 'multi-input';
|
|
42
|
+
readOnly?: boolean;
|
|
43
|
+
labelId?: string;
|
|
44
|
+
disableOpenPicker?: boolean;
|
|
45
|
+
onBlur?: () => void;
|
|
46
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
47
|
+
label?: React.ReactNode;
|
|
48
|
+
localeText: PickersInputLocaleText<TDate> | undefined;
|
|
49
|
+
pickerSlotProps: RangePickerFieldSlotsComponentsProps<TDate> | undefined;
|
|
50
|
+
pickerSlots: UncapitalizeObjectKeys<RangePickerFieldSlotsComponent> | undefined;
|
|
51
|
+
fieldProps: FieldProps;
|
|
52
|
+
}
|
|
53
|
+
export declare const useEnrichedRangePickerFieldProps: <TDate, TView extends DateOrTimeView, TError>(params: UseEnrichedRangePickerFieldPropsParams<TDate, TView, TError, BaseFieldProps<DateRange<TDate>, RangeFieldSection, TError>>) => BaseMultiInputFieldProps<DateRange<TDate>, RangeFieldSection, TError> | BaseSingleInputFieldProps<DateRange<TDate>, RangeFieldSection, TError>;
|