@mui/x-date-pickers-pro 6.0.0-alpha.11 → 6.0.0-alpha.12
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 +128 -0
- package/DateRangeCalendar/DateRangeCalendar.js +23 -2
- package/DateRangePicker/DateRangePicker.js +0 -1
- package/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -1
- package/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +0 -1
- package/MobileDateRangePicker/MobileDateRangePicker.js +0 -1
- package/MobileNextDateRangePicker/MobileNextDateRangePicker.js +0 -1
- package/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -3
- package/MultiInputDateRangeField/MultiInputDateRangeField.types.d.ts +3 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +4 -0
- package/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -0
- package/internal/hooks/useRangePickerInputProps.d.ts +3 -1
- package/internal/hooks/useRangePickerInputProps.js +7 -5
- package/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -1
- package/internal/models/fields.d.ts +6 -1
- package/internal/models/range.d.ts +0 -4
- package/internal/utils/date-fields-utils.d.ts +5 -5
- package/internal/utils/releaseInfo.js +1 -1
- package/internal/utils/valueManagers.d.ts +3 -2
- package/internal/utils/valueManagers.js +11 -6
- package/legacy/DateRangeCalendar/DateRangeCalendar.js +29 -2
- package/legacy/DateRangePicker/DateRangePicker.js +0 -1
- package/legacy/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -1
- package/legacy/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +0 -1
- package/legacy/MobileDateRangePicker/MobileDateRangePicker.js +0 -1
- package/legacy/MobileNextDateRangePicker/MobileNextDateRangePicker.js +0 -1
- package/legacy/MultiInputDateRangeField/MultiInputDateRangeField.js +9 -2
- package/legacy/index.js +1 -1
- package/legacy/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +4 -0
- package/legacy/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -0
- package/legacy/internal/hooks/useRangePickerInputProps.js +7 -5
- package/legacy/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -1
- package/legacy/internal/utils/releaseInfo.js +1 -1
- package/legacy/internal/utils/valueManagers.js +10 -5
- package/modern/DateRangeCalendar/DateRangeCalendar.js +22 -2
- package/modern/DateRangePicker/DateRangePicker.js +0 -1
- package/modern/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -1
- package/modern/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +0 -1
- package/modern/MobileDateRangePicker/MobileDateRangePicker.js +0 -1
- package/modern/MobileNextDateRangePicker/MobileNextDateRangePicker.js +0 -1
- package/modern/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -3
- package/modern/index.js +1 -1
- package/modern/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +4 -0
- package/modern/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -0
- package/modern/internal/hooks/useRangePickerInputProps.js +6 -5
- package/modern/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -1
- package/modern/internal/utils/releaseInfo.js +1 -1
- package/modern/internal/utils/valueManagers.js +11 -6
- package/node/DateRangeCalendar/DateRangeCalendar.js +21 -1
- package/node/DateRangePicker/DateRangePicker.js +0 -1
- package/node/DesktopDateRangePicker/DesktopDateRangePicker.js +0 -1
- package/node/DesktopNextDateRangePicker/DesktopNextDateRangePicker.js +0 -1
- package/node/MobileDateRangePicker/MobileDateRangePicker.js +0 -1
- package/node/MobileNextDateRangePicker/MobileNextDateRangePicker.js +0 -1
- package/node/MultiInputDateRangeField/MultiInputDateRangeField.js +10 -3
- package/node/index.js +1 -1
- package/node/internal/hooks/useDesktopRangePicker/useDesktopRangePicker.js +4 -0
- package/node/internal/hooks/useMobileRangePicker/useMobileRangePicker.js +2 -0
- package/node/internal/hooks/useRangePickerInputProps.js +6 -5
- package/node/internal/hooks/useStaticRangePicker/useStaticRangePicker.js +3 -1
- package/node/internal/utils/releaseInfo.js +1 -1
- package/node/internal/utils/valueManagers.js +10 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,80 @@
|
|
|
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.0-alpha.12
|
|
7
|
+
|
|
8
|
+
_Dec 16, 2022_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🚀 The `apiRef` prop is now available in the `@mui/x-data-grid` package:
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
const apiRef = useGridApiRef();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<DataGrid apiRef={apiRef} {...other} />
|
|
19
|
+
)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
See [the documentation](https://next.mui.com/x/react-data-grid/api-object/) for more information.
|
|
23
|
+
|
|
24
|
+
- 🎁 The `DataGridPremium` now supports cell selection:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
<DataGridPremium unstable_cellSelection />
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See [the documentation](https://next.mui.com/x/react-data-grid/selection/#cell-selection) for more information
|
|
31
|
+
|
|
32
|
+
- 🌍 Support the Right To Left orientation on the fields components
|
|
33
|
+
- 📚 Documentation improvements
|
|
34
|
+
- 🐞 Bugfixes
|
|
35
|
+
|
|
36
|
+
### `@mui/x-data-grid@v6.0.0-alpha.12` / `@mui/x-data-grid-pro@v6.0.0-alpha.12` / `@mui/x-data-grid-premium@v6.0.0-alpha.12`
|
|
37
|
+
|
|
38
|
+
#### Breaking changes
|
|
39
|
+
|
|
40
|
+
- The `showCellRightBorder` was renamed to `showCellVerticalBorder`
|
|
41
|
+
- The `showColumnRightBorder` was renamed to `showColumnVerticalBorder`
|
|
42
|
+
- The `.MuiDataGrid-withBorder` CSS class was renamed to `.MuiDataGrid-withBorderColor` and it only sets `border-color` CSS property now.
|
|
43
|
+
- The following undocumented properties from `apiRef` were removed: `footerRef`, `headerRef`, `columnHeadersElementRef`, `columnHeadersContainerElementRef`
|
|
44
|
+
- The `GridHeaderPlaceholder` component was removed.
|
|
45
|
+
- The `MAX_PAGE_SIZE` constant was removed.
|
|
46
|
+
- The `useGridScrollFn` hook was removed.
|
|
47
|
+
|
|
48
|
+
#### Changes
|
|
49
|
+
|
|
50
|
+
- [DataGrid] Display sort column menu items as per `sortingOrder` prop (#7180) @MBilalShafi
|
|
51
|
+
- [DataGrid] Support `apiRef` in Community package (#6773) @cherniavskii
|
|
52
|
+
- [DataGridPremium] Add support for cell selection (#6567) @m4theushw
|
|
53
|
+
- [DataGridPremium] Use separate cache for aggregation columns pre-processor (#7142) @m4theushw
|
|
54
|
+
- [DataGridPro] Fix missing border in right-pinned columns (#4197) @cherniavskii
|
|
55
|
+
- [DataGridPro] Fix wrong border color on skeleton cells (#7202) @cherniavskii
|
|
56
|
+
|
|
57
|
+
### `@mui/x-date-pickers@v6.0.0-alpha.12` / `@mui/x-date-pickers-pro@v6.0.0-alpha.12`
|
|
58
|
+
|
|
59
|
+
#### Changes
|
|
60
|
+
|
|
61
|
+
- [fields] Fix bug introduced by RTL in single input range fields (#7189) @alexfauquette
|
|
62
|
+
- [fields] Support RTL out of the box (#6715) @alexfauquette
|
|
63
|
+
- [pickers] Clean `autoFocus` behavior on fields and new pickers (#7153) @flaviendelangle
|
|
64
|
+
- [pickers] Fix label on the new range pickers (#7210) @flaviendelangle
|
|
65
|
+
- [pickers] Fix wrong component name on `StaticNextDateTime` (#7187) @flaviendelangle
|
|
66
|
+
|
|
67
|
+
### Docs
|
|
68
|
+
|
|
69
|
+
- [docs] Add docs section about field placeholders' localization (#7139) @flaviendelangle
|
|
70
|
+
- [docs] Create a `DemoGrid` component to unify demos with several components (#7057) @flaviendelangle
|
|
71
|
+
- [docs] Document aggregation selectors (#7148) @cherniavskii
|
|
72
|
+
- [docs] Fix 301 links to demo pages in API pages (#7197) @oliviertassinari
|
|
73
|
+
- [docs] Fix errors and warning in demos (#7209) @LukasTy
|
|
74
|
+
- [docs] Use `DemoContainer` and `DemoItem` on every picker demo (#7149) @flaviendelangle
|
|
75
|
+
|
|
76
|
+
### Core
|
|
77
|
+
|
|
78
|
+
- [core] Fix broken test (#7179) @flaviendelangle
|
|
79
|
+
|
|
6
80
|
## 6.0.0-alpha.11
|
|
7
81
|
|
|
8
82
|
_Dec 8, 2022_
|
|
@@ -1301,6 +1375,60 @@ You can find more information about the new api, including how to set those tran
|
|
|
1301
1375
|
- [test] Skip tests for column pinning and dynamic row height (#5997) @m4theushw
|
|
1302
1376
|
- [website] Improve security header @oliviertassinari
|
|
1303
1377
|
|
|
1378
|
+
## 5.17.16
|
|
1379
|
+
|
|
1380
|
+
_Dec 16, 2022_
|
|
1381
|
+
|
|
1382
|
+
We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
|
|
1383
|
+
|
|
1384
|
+
- 🐞 Bugfixes
|
|
1385
|
+
|
|
1386
|
+
### `@mui/x-data-grid@v5.17.16` / `@mui/x-data-grid-pro@v5.17.16` / `@mui/x-data-grid-premium@v5.17.16`
|
|
1387
|
+
|
|
1388
|
+
#### Changes
|
|
1389
|
+
|
|
1390
|
+
- [DataGrid] Display sort column menu items as per `sortingOrder` prop (#7125) @hanbin9775
|
|
1391
|
+
- [DataGrid] Fix flickering on mount (#7155) @cherniavskii
|
|
1392
|
+
- [DataGridPremium] Use separate cache for aggregation columns pre-processor (#7174) @m4theushw
|
|
1393
|
+
|
|
1394
|
+
### `@mui/x-date-pickers@v5.0.11` / `@mui/x-date-pickers-pro@v5.0.11`
|
|
1395
|
+
|
|
1396
|
+
#### Changes
|
|
1397
|
+
|
|
1398
|
+
- [DateTimePicker] Update export pattern (#7172) @kealjones-wk
|
|
1399
|
+
|
|
1400
|
+
### Docs
|
|
1401
|
+
|
|
1402
|
+
- [docs] Document aggregation selectors (#7151) @cherniavskii
|
|
1403
|
+
|
|
1404
|
+
## 5.17.15
|
|
1405
|
+
|
|
1406
|
+
_Dec 8, 2022_
|
|
1407
|
+
|
|
1408
|
+
We'd like to offer a big thanks to the 4 contributors who made this release possible. Here are some highlights ✨:
|
|
1409
|
+
|
|
1410
|
+
- ✨ Fix lazy-loading not working in `DataGridPremium` (#7130) @m4theushw
|
|
1411
|
+
- 🐞 Bugfixes
|
|
1412
|
+
|
|
1413
|
+
### `@mui/x-data-grid@v5.17.15` / `@mui/x-data-grid-pro@v5.17.15` / `@mui/x-data-grid-premium@v5.17.15`
|
|
1414
|
+
|
|
1415
|
+
#### Changes
|
|
1416
|
+
|
|
1417
|
+
- [DataGridPremium] Add support for lazy-loading (#7130) @m4theushw
|
|
1418
|
+
- [DataGridPremium] Pass `groupId` to the aggregation function (#7143) @m4theushw
|
|
1419
|
+
|
|
1420
|
+
### `@mui/x-date-pickers@v5.0.10` / `@mui/x-date-pickers-pro@v5.0.10`
|
|
1421
|
+
|
|
1422
|
+
#### Changes
|
|
1423
|
+
|
|
1424
|
+
- [pickers] Initialize date without time when selecting year or month (#7136) @LukasTy
|
|
1425
|
+
|
|
1426
|
+
### Docs
|
|
1427
|
+
|
|
1428
|
+
- [docs] Fix the nested import on the api pages (#7134) @flaviendelangle
|
|
1429
|
+
- [docs] Keep track of the localization completion (#7099) @alexfauquette
|
|
1430
|
+
- [docs] Update localization doc to use existing locale (#7104) @LukasTy
|
|
1431
|
+
|
|
1304
1432
|
## 5.17.14
|
|
1305
1433
|
|
|
1306
1434
|
_Dec 1, 2022_
|
|
@@ -11,7 +11,7 @@ import { resolveComponentProps } from '@mui/base/utils';
|
|
|
11
11
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
12
12
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
13
13
|
import { Watermark } from '@mui/x-license-pro';
|
|
14
|
-
import { applyDefaultDate, DAY_MARGIN, DayCalendar, defaultReduceAnimations, PickersArrowSwitcher, PickersCalendarHeader, useCalendarState, useDefaultDates, useLocaleText, useNextMonthDisabled, usePreviousMonthDisabled, useUtils, WrapperVariantContext } from '@mui/x-date-pickers/internals';
|
|
14
|
+
import { applyDefaultDate, DAY_MARGIN, DayCalendar, defaultReduceAnimations, PickersArrowSwitcher, PickersCalendarHeader, useCalendarState, useDefaultDates, useLocaleText, useNextMonthDisabled, usePreviousMonthDisabled, useUtils, WrapperVariantContext, useNow } from '@mui/x-date-pickers/internals';
|
|
15
15
|
import { getReleaseInfo } from '../internal/utils/releaseInfo';
|
|
16
16
|
import { dateRangeCalendarClasses, getDateRangeCalendarUtilityClass } from './dateRangeCalendarClasses';
|
|
17
17
|
import { isEndOfRange, isRangeValid, isStartOfRange, isWithinRange } from '../internal/utils/date-utils';
|
|
@@ -108,6 +108,7 @@ const useUtilityClasses = ownerState => {
|
|
|
108
108
|
const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar(inProps, ref) {
|
|
109
109
|
const utils = useUtils();
|
|
110
110
|
const localeText = useLocaleText();
|
|
111
|
+
const now = useNow();
|
|
111
112
|
const props = useDateRangeCalendarDefaultizedProps(inProps, 'MuiDateRangeCalendar');
|
|
112
113
|
const isMobile = React.useContext(WrapperVariantContext) === 'mobile';
|
|
113
114
|
const {
|
|
@@ -350,6 +351,26 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
350
351
|
const visibleMonths = React.useMemo(() => Array.from({
|
|
351
352
|
length: calendars
|
|
352
353
|
}).map((_, index) => utils.setMonth(calendarState.currentMonth, utils.getMonth(calendarState.currentMonth) + index)), [utils, calendarState.currentMonth, calendars]);
|
|
354
|
+
const focusedMonth = React.useMemo(() => {
|
|
355
|
+
var _visibleMonths$find;
|
|
356
|
+
if (!autoFocus) {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// The focus priority of the "day" view is as follows:
|
|
361
|
+
// 1. Month of the `start` date
|
|
362
|
+
// 2. Month of the `end` date
|
|
363
|
+
// 3. Month of the current date
|
|
364
|
+
// 4. First visible month
|
|
365
|
+
|
|
366
|
+
if (value[0] != null) {
|
|
367
|
+
return visibleMonths.find(month => utils.isSameMonth(month, value[0]));
|
|
368
|
+
}
|
|
369
|
+
if (value[1] != null) {
|
|
370
|
+
return visibleMonths.find(month => utils.isSameMonth(month, value[1]));
|
|
371
|
+
}
|
|
372
|
+
return (_visibleMonths$find = visibleMonths.find(month => utils.isSameMonth(month, now))) != null ? _visibleMonths$find : visibleMonths[0];
|
|
373
|
+
}, [utils, value, visibleMonths, autoFocus, now]);
|
|
353
374
|
return /*#__PURE__*/_jsxs(DateRangeCalendarRoot, _extends({
|
|
354
375
|
ref: ref,
|
|
355
376
|
className: clsx(className, classes.root),
|
|
@@ -405,7 +426,7 @@ const DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalend
|
|
|
405
426
|
renderLoading: renderLoading,
|
|
406
427
|
components: componentsForDayCalendar,
|
|
407
428
|
componentsProps: componentsPropsForDayCalendar,
|
|
408
|
-
autoFocus:
|
|
429
|
+
autoFocus: month === focusedMonth,
|
|
409
430
|
fixedWeekNumber: fixedWeekNumber,
|
|
410
431
|
displayWeekNumber: displayWeekNumber
|
|
411
432
|
}), index)]
|
|
@@ -28,7 +28,6 @@ const DesktopNextDateRangePicker = /*#__PURE__*/React.forwardRef(function Deskto
|
|
|
28
28
|
views: ['day'],
|
|
29
29
|
openTo: 'day',
|
|
30
30
|
showToolbar: (_defaultizedProps$sho = defaultizedProps.showToolbar) != null ? _defaultizedProps$sho : false,
|
|
31
|
-
autoFocus: true,
|
|
32
31
|
components: _extends({
|
|
33
32
|
Field: MultiInputDateRangeField
|
|
34
33
|
}, defaultizedProps.components),
|
|
@@ -28,7 +28,6 @@ const MobileNextDateRangePicker = /*#__PURE__*/React.forwardRef(function MobileN
|
|
|
28
28
|
views: ['day'],
|
|
29
29
|
openTo: 'day',
|
|
30
30
|
showToolbar: (_defaultizedProps$sho = defaultizedProps.showToolbar) != null ? _defaultizedProps$sho : true,
|
|
31
|
-
autoFocus: true,
|
|
32
31
|
components: _extends({
|
|
33
32
|
Field: MultiInputDateRangeField
|
|
34
33
|
}, defaultizedProps.components),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange"],
|
|
3
|
+
const _excluded = ["components", "componentsProps", "value", "defaultValue", "format", "onChange", "readOnly", "onError", "shouldDisableDate", "minDate", "maxDate", "disableFuture", "disablePast", "selectedSections", "onSelectedSectionsChange", "autoFocus"],
|
|
4
4
|
_excluded2 = ["onKeyDown", "ref"],
|
|
5
5
|
_excluded3 = ["onKeyDown", "ref"];
|
|
6
6
|
import * as React from 'react';
|
|
@@ -23,7 +23,9 @@ const MultiInputDateRangeFieldRoot = styled( /*#__PURE__*/React.forwardRef((prop
|
|
|
23
23
|
name: 'MuiMultiInputDateRangeField',
|
|
24
24
|
slot: 'Root',
|
|
25
25
|
overridesResolver: (props, styles) => styles.root
|
|
26
|
-
})({
|
|
26
|
+
})({
|
|
27
|
+
alignItems: 'baseline'
|
|
28
|
+
});
|
|
27
29
|
const MultiInputDateRangeFieldSeparator = styled(props => {
|
|
28
30
|
var _props$children;
|
|
29
31
|
return /*#__PURE__*/_jsx(Typography, _extends({}, props, {
|
|
@@ -55,7 +57,8 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
55
57
|
disableFuture,
|
|
56
58
|
disablePast,
|
|
57
59
|
selectedSections,
|
|
58
|
-
onSelectedSectionsChange
|
|
60
|
+
onSelectedSectionsChange,
|
|
61
|
+
autoFocus
|
|
59
62
|
} = themeProps,
|
|
60
63
|
other = _objectWithoutPropertiesLoose(themeProps, _excluded);
|
|
61
64
|
const ownerState = themeProps;
|
|
@@ -73,6 +76,9 @@ const MultiInputDateRangeField = /*#__PURE__*/React.forwardRef(function MultiInp
|
|
|
73
76
|
const startInputProps = useSlotProps({
|
|
74
77
|
elementType: Input,
|
|
75
78
|
externalSlotProps: componentsProps == null ? void 0 : componentsProps.input,
|
|
79
|
+
additionalProps: {
|
|
80
|
+
autoFocus
|
|
81
|
+
},
|
|
76
82
|
ownerState: _extends({}, ownerState, {
|
|
77
83
|
position: 'start'
|
|
78
84
|
})
|
|
@@ -142,6 +148,7 @@ process.env.NODE_ENV !== "production" ? MultiInputDateRangeField.propTypes = {
|
|
|
142
148
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
143
149
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
144
150
|
// ----------------------------------------------------------------------
|
|
151
|
+
autoFocus: PropTypes.bool,
|
|
145
152
|
/**
|
|
146
153
|
* Overrideable components.
|
|
147
154
|
* @default {}
|
|
@@ -15,7 +15,9 @@ export interface UseMultiInputDateRangeFieldParams<TDate, TChildProps extends {}
|
|
|
15
15
|
export interface UseMultiInputDateRangeFieldProps<TDate> extends UseDateRangeFieldProps<TDate> {
|
|
16
16
|
}
|
|
17
17
|
export type UseMultiInputDateRangeFieldComponentProps<TDate, TChildProps extends {}> = Omit<TChildProps, keyof UseMultiInputDateRangeFieldProps<TDate>> & UseMultiInputDateRangeFieldProps<TDate>;
|
|
18
|
-
export interface MultiInputDateRangeFieldProps<TDate> extends UseMultiInputDateRangeFieldComponentProps<TDate, {
|
|
18
|
+
export interface MultiInputDateRangeFieldProps<TDate> extends UseMultiInputDateRangeFieldComponentProps<TDate, {
|
|
19
|
+
autoFocus?: boolean;
|
|
20
|
+
}> {
|
|
19
21
|
/**
|
|
20
22
|
* Overrideable components.
|
|
21
23
|
* @default {}
|
package/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './MultiInputDateRangeField';
|
|
|
9
9
|
export * from './MultiInputTimeRangeField';
|
|
10
10
|
export * from './MultiInputDateTimeRangeField';
|
|
11
11
|
export * from './SingleInputDateRangeField';
|
|
12
|
-
export type {
|
|
12
|
+
export type { RangeFieldSection } from './internal/models/fields';
|
|
13
13
|
export * from './DateRangeCalendar';
|
|
14
14
|
export * from './NextDateRangePicker';
|
|
15
15
|
export * from './DesktopNextDateRangePicker';
|
package/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export const useDesktopRangePicker = ({
|
|
|
23
23
|
format,
|
|
24
24
|
readOnly,
|
|
25
25
|
disabled,
|
|
26
|
+
autoFocus,
|
|
26
27
|
disableOpenPicker,
|
|
27
28
|
localeText
|
|
28
29
|
} = props;
|
|
@@ -42,6 +43,7 @@ export const useDesktopRangePicker = ({
|
|
|
42
43
|
wrapperVariant: 'desktop',
|
|
43
44
|
viewLookup,
|
|
44
45
|
validator,
|
|
46
|
+
autoFocusView: true,
|
|
45
47
|
additionalViewProps: {
|
|
46
48
|
rangePosition,
|
|
47
49
|
onRangePositionChange: setRangePosition
|
|
@@ -63,6 +65,7 @@ export const useDesktopRangePicker = ({
|
|
|
63
65
|
readOnly,
|
|
64
66
|
disabled,
|
|
65
67
|
disableOpenPicker,
|
|
68
|
+
localeText,
|
|
66
69
|
onBlur: handleBlur,
|
|
67
70
|
rangePosition,
|
|
68
71
|
onRangePositionChange: setRangePosition
|
|
@@ -76,6 +79,7 @@ export const useDesktopRangePicker = ({
|
|
|
76
79
|
disabled,
|
|
77
80
|
className,
|
|
78
81
|
format,
|
|
82
|
+
autoFocus: autoFocus && !props.open,
|
|
79
83
|
ref: fieldRef
|
|
80
84
|
}),
|
|
81
85
|
ownerState: props
|
|
@@ -40,6 +40,7 @@ export const useMobileRangePicker = ({
|
|
|
40
40
|
wrapperVariant: 'mobile',
|
|
41
41
|
viewLookup,
|
|
42
42
|
validator,
|
|
43
|
+
autoFocusView: true,
|
|
43
44
|
additionalViewProps: {
|
|
44
45
|
rangePosition,
|
|
45
46
|
onRangePositionChange: setRangePosition
|
|
@@ -52,6 +53,7 @@ export const useMobileRangePicker = ({
|
|
|
52
53
|
readOnly,
|
|
53
54
|
disabled,
|
|
54
55
|
disableOpenPicker,
|
|
56
|
+
localeText,
|
|
55
57
|
rangePosition,
|
|
56
58
|
onRangePositionChange: setRangePosition
|
|
57
59
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { PickersInputLocaleText } from '@mui/x-date-pickers';
|
|
2
3
|
import { DateOrTimeView, UsePickerResponse, WrapperVariant } from '@mui/x-date-pickers/internals';
|
|
3
4
|
import { DateRange, RangePosition } from '../models';
|
|
4
5
|
interface UseRangePickerFieldParams<TDate, TView extends DateOrTimeView> extends Pick<UsePickerResponse<DateRange<TDate>, TView, any>, 'open' | 'actions'> {
|
|
@@ -9,8 +10,9 @@ interface UseRangePickerFieldParams<TDate, TView extends DateOrTimeView> extends
|
|
|
9
10
|
onBlur?: () => void;
|
|
10
11
|
rangePosition: RangePosition;
|
|
11
12
|
onRangePositionChange: (newPosition: RangePosition) => void;
|
|
13
|
+
localeText: PickersInputLocaleText<TDate> | undefined;
|
|
12
14
|
}
|
|
13
|
-
export declare const useRangePickerInputProps: <TDate, TView extends DateOrTimeView>({ wrapperVariant, open, actions, readOnly, disabled, disableOpenPicker, onBlur, rangePosition, onRangePositionChange, }: UseRangePickerFieldParams<TDate, TView>) => {
|
|
15
|
+
export declare const useRangePickerInputProps: <TDate, TView extends DateOrTimeView>({ wrapperVariant, open, actions, readOnly, disabled, disableOpenPicker, onBlur, rangePosition, onRangePositionChange, localeText: inLocaleText, }: UseRangePickerFieldParams<TDate, TView>) => {
|
|
14
16
|
startInput: {
|
|
15
17
|
inputProps: {
|
|
16
18
|
readOnly: boolean;
|
|
@@ -10,8 +10,10 @@ export const useRangePickerInputProps = ({
|
|
|
10
10
|
disableOpenPicker,
|
|
11
11
|
onBlur,
|
|
12
12
|
rangePosition,
|
|
13
|
-
onRangePositionChange
|
|
13
|
+
onRangePositionChange,
|
|
14
|
+
localeText: inLocaleText
|
|
14
15
|
}) => {
|
|
16
|
+
var _inLocaleText$start, _inLocaleText$end;
|
|
15
17
|
const localeText = useLocaleText();
|
|
16
18
|
const startRef = React.useRef(null);
|
|
17
19
|
const endRef = React.useRef(null);
|
|
@@ -28,14 +30,14 @@ export const useRangePickerInputProps = ({
|
|
|
28
30
|
}
|
|
29
31
|
}, [rangePosition, open]);
|
|
30
32
|
const openRangeStartSelection = event => {
|
|
31
|
-
event
|
|
33
|
+
event.stopPropagation();
|
|
32
34
|
onRangePositionChange('start');
|
|
33
35
|
if (!readOnly && !disableOpenPicker) {
|
|
34
36
|
actions.onOpen();
|
|
35
37
|
}
|
|
36
38
|
};
|
|
37
39
|
const openRangeEndSelection = event => {
|
|
38
|
-
event
|
|
40
|
+
event.stopPropagation();
|
|
39
41
|
onRangePositionChange('end');
|
|
40
42
|
if (!readOnly && !disableOpenPicker) {
|
|
41
43
|
actions.onOpen();
|
|
@@ -53,7 +55,7 @@ export const useRangePickerInputProps = ({
|
|
|
53
55
|
};
|
|
54
56
|
const startInputProps = _extends({
|
|
55
57
|
inputRef: startRef,
|
|
56
|
-
label: localeText.start,
|
|
58
|
+
label: (_inLocaleText$start = inLocaleText == null ? void 0 : inLocaleText.start) != null ? _inLocaleText$start : localeText.start,
|
|
57
59
|
onKeyDown: onSpaceOrEnter(openRangeStartSelection),
|
|
58
60
|
onFocus: focusOnRangeStart,
|
|
59
61
|
focused: open ? rangePosition === 'start' : undefined
|
|
@@ -66,7 +68,7 @@ export const useRangePickerInputProps = ({
|
|
|
66
68
|
});
|
|
67
69
|
const endInputProps = _extends({
|
|
68
70
|
inputRef: endRef,
|
|
69
|
-
label: localeText.end,
|
|
71
|
+
label: (_inLocaleText$end = inLocaleText == null ? void 0 : inLocaleText.end) != null ? _inLocaleText$end : localeText.end,
|
|
70
72
|
onKeyDown: onSpaceOrEnter(openRangeEndSelection),
|
|
71
73
|
onFocus: focusOnRangeEnd,
|
|
72
74
|
focused: open ? rangePosition === 'end' : undefined
|
|
@@ -27,7 +27,8 @@ export const useStaticRangePicker = ({
|
|
|
27
27
|
localeText,
|
|
28
28
|
components,
|
|
29
29
|
componentsProps,
|
|
30
|
-
displayStaticWrapperAs
|
|
30
|
+
displayStaticWrapperAs,
|
|
31
|
+
autoFocus
|
|
31
32
|
} = props;
|
|
32
33
|
const [rangePosition, setRangePosition] = React.useState('start');
|
|
33
34
|
const {
|
|
@@ -38,6 +39,7 @@ export const useStaticRangePicker = ({
|
|
|
38
39
|
viewLookup,
|
|
39
40
|
valueManager,
|
|
40
41
|
validator,
|
|
42
|
+
autoFocusView: autoFocus != null ? autoFocus : false,
|
|
41
43
|
additionalViewProps: {},
|
|
42
44
|
wrapperVariant: displayStaticWrapperAs
|
|
43
45
|
});
|
|
@@ -3,7 +3,12 @@ import { SlotComponentProps } from '@mui/base/utils';
|
|
|
3
3
|
import TextField, { TextFieldProps } from '@mui/material/TextField';
|
|
4
4
|
import Stack, { StackProps } from '@mui/material/Stack';
|
|
5
5
|
import Typography, { TypographyProps } from '@mui/material/Typography';
|
|
6
|
-
import { BaseFieldProps } from '@mui/x-date-pickers/internals';
|
|
6
|
+
import { BaseFieldProps, FieldSection } from '@mui/x-date-pickers/internals';
|
|
7
|
+
export interface RangeFieldSection extends FieldSection {
|
|
8
|
+
dateName: 'start' | 'end';
|
|
9
|
+
}
|
|
10
|
+
export interface RangeFieldSectionWithoutPosition extends Omit<RangeFieldSection, 'start' | 'end' | 'startInInput' | 'endInInput'> {
|
|
11
|
+
}
|
|
7
12
|
export interface BaseMultiInputFieldProps<TValue, TError> extends Omit<BaseFieldProps<TValue, TError>, 'components' | 'componentsProps'> {
|
|
8
13
|
components?: {
|
|
9
14
|
Root?: React.ElementType<StackProps>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FieldSection } from '@mui/x-date-pickers/internals';
|
|
2
1
|
export type DateRange<TDate> = [TDate | null, TDate | null];
|
|
3
2
|
export type NonEmptyDateRange<TDate> = [TDate, TDate];
|
|
4
3
|
export type RangePosition = 'start' | 'end';
|
|
@@ -6,6 +5,3 @@ export interface RangePositionProps {
|
|
|
6
5
|
rangePosition: RangePosition;
|
|
7
6
|
onRangePositionChange: (newPosition: RangePosition) => void;
|
|
8
7
|
}
|
|
9
|
-
export interface DateRangeFieldSection extends FieldSection {
|
|
10
|
-
dateName: 'start' | 'end';
|
|
11
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const splitDateRangeSections: (sections:
|
|
3
|
-
startDate:
|
|
4
|
-
endDate:
|
|
1
|
+
import { RangeFieldSection } from '../models/fields';
|
|
2
|
+
export declare const splitDateRangeSections: (sections: RangeFieldSection[]) => {
|
|
3
|
+
startDate: RangeFieldSection[];
|
|
4
|
+
endDate: RangeFieldSection[];
|
|
5
5
|
};
|
|
6
|
-
export declare const removeLastSeparator: (dateSections:
|
|
6
|
+
export declare const removeLastSeparator: (dateSections: RangeFieldSection[]) => RangeFieldSection[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTY3MTE0NTIwMDAwMA==";
|
|
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,8 +1,9 @@
|
|
|
1
1
|
import { PickerStateValueManager, FieldValueManager } from '@mui/x-date-pickers/internals';
|
|
2
|
-
import { DateRange
|
|
2
|
+
import { DateRange } from '../models/range';
|
|
3
3
|
import type { DateRangeValidationError } from '../hooks/validation/useDateRangeValidation';
|
|
4
4
|
import type { TimeRangeValidationError } from '../hooks/validation/useTimeRangeValidation';
|
|
5
5
|
import type { DateTimeRangeValidationError } from '../hooks/validation/useDateTimeRangeValidation';
|
|
6
|
+
import { RangeFieldSection } from '../models/fields';
|
|
6
7
|
export type RangePickerStateValueManager<TValue = [any, any], TDate = any, TError extends DateRangeValidationError | TimeRangeValidationError | DateTimeRangeValidationError = any> = PickerStateValueManager<TValue, TDate, TError>;
|
|
7
8
|
export declare const rangeValueManager: RangePickerStateValueManager;
|
|
8
|
-
export declare const rangeFieldValueManager: FieldValueManager<DateRange<any>, any,
|
|
9
|
+
export declare const rangeFieldValueManager: FieldValueManager<DateRange<any>, any, RangeFieldSection, DateRangeValidationError | TimeRangeValidationError | DateTimeRangeValidationError>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrFromSections } from '@mui/x-date-pickers/internals';
|
|
2
|
+
import { replaceInvalidDateByNull, splitFormatIntoSections, addPositionPropertiesToSections, createDateStrFromSections, getSectionOrder } from '@mui/x-date-pickers/internals';
|
|
3
3
|
import { splitDateRangeSections, removeLastSeparator } from './date-fields-utils';
|
|
4
4
|
export const rangeValueManager = {
|
|
5
5
|
emptyValue: [null, null],
|
|
@@ -42,7 +42,8 @@ export const rangeFieldValueManager = {
|
|
|
42
42
|
if (sectionIndex === rawSectionsOfStartDate.length - 1) {
|
|
43
43
|
return _extends({}, section, {
|
|
44
44
|
dateName: 'start',
|
|
45
|
-
separator:
|
|
45
|
+
separator: `\u2069 – \u2066`,
|
|
46
|
+
parsingSeparator: ' – '
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
return _extends({}, section, {
|
|
@@ -56,9 +57,7 @@ export const rangeFieldValueManager = {
|
|
|
56
57
|
},
|
|
57
58
|
getValueStrFromSections: sections => {
|
|
58
59
|
const dateRangeSections = splitDateRangeSections(sections);
|
|
59
|
-
|
|
60
|
-
const endDateStr = createDateStrFromSections(dateRangeSections.endDate, true);
|
|
61
|
-
return `${startDateStr}${endDateStr}`;
|
|
60
|
+
return createDateStrFromSections([...dateRangeSections.startDate, ...dateRangeSections.endDate], true);
|
|
62
61
|
},
|
|
63
62
|
getActiveDateSections: (sections, activeSection) => {
|
|
64
63
|
const index = activeSection.dateName === 'start' ? 0 : 1;
|
|
@@ -87,5 +86,11 @@ export const rangeFieldValueManager = {
|
|
|
87
86
|
})
|
|
88
87
|
};
|
|
89
88
|
},
|
|
90
|
-
hasError: error => error[0] != null || error[1] != null
|
|
89
|
+
hasError: error => error[0] != null || error[1] != null,
|
|
90
|
+
getSectionOrder: (utils, localeText, format, isRTL) => {
|
|
91
|
+
const splitedFormat = splitFormatIntoSections(utils, localeText, format, null);
|
|
92
|
+
return getSectionOrder([...splitedFormat.slice(0, splitedFormat.length - 1), _extends({}, splitedFormat[splitedFormat.length - 1], {
|
|
93
|
+
separator: ' – '
|
|
94
|
+
}), ...splitedFormat], isRTL);
|
|
95
|
+
}
|
|
91
96
|
};
|
|
@@ -13,7 +13,7 @@ import { resolveComponentProps } from '@mui/base/utils';
|
|
|
13
13
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
14
14
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
15
15
|
import { Watermark } from '@mui/x-license-pro';
|
|
16
|
-
import { applyDefaultDate, DAY_MARGIN, DayCalendar, defaultReduceAnimations, PickersArrowSwitcher, PickersCalendarHeader, useCalendarState, useDefaultDates, useLocaleText, useNextMonthDisabled, usePreviousMonthDisabled, useUtils, WrapperVariantContext } from '@mui/x-date-pickers/internals';
|
|
16
|
+
import { applyDefaultDate, DAY_MARGIN, DayCalendar, defaultReduceAnimations, PickersArrowSwitcher, PickersCalendarHeader, useCalendarState, useDefaultDates, useLocaleText, useNextMonthDisabled, usePreviousMonthDisabled, useUtils, WrapperVariantContext, useNow } from '@mui/x-date-pickers/internals';
|
|
17
17
|
import { getReleaseInfo } from '../internal/utils/releaseInfo';
|
|
18
18
|
import { dateRangeCalendarClasses, getDateRangeCalendarUtilityClass } from './dateRangeCalendarClasses';
|
|
19
19
|
import { isEndOfRange, isRangeValid, isStartOfRange, isWithinRange } from '../internal/utils/date-utils';
|
|
@@ -112,6 +112,7 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
112
112
|
var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar(inProps, ref) {
|
|
113
113
|
var utils = useUtils();
|
|
114
114
|
var localeText = useLocaleText();
|
|
115
|
+
var now = useNow();
|
|
115
116
|
var props = useDateRangeCalendarDefaultizedProps(inProps, 'MuiDateRangeCalendar');
|
|
116
117
|
var isMobile = React.useContext(WrapperVariantContext) === 'mobile';
|
|
117
118
|
var valueProp = props.value,
|
|
@@ -368,6 +369,32 @@ var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar
|
|
|
368
369
|
return utils.setMonth(calendarState.currentMonth, utils.getMonth(calendarState.currentMonth) + index);
|
|
369
370
|
});
|
|
370
371
|
}, [utils, calendarState.currentMonth, calendars]);
|
|
372
|
+
var focusedMonth = React.useMemo(function () {
|
|
373
|
+
var _visibleMonths$find;
|
|
374
|
+
if (!autoFocus) {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// The focus priority of the "day" view is as follows:
|
|
379
|
+
// 1. Month of the `start` date
|
|
380
|
+
// 2. Month of the `end` date
|
|
381
|
+
// 3. Month of the current date
|
|
382
|
+
// 4. First visible month
|
|
383
|
+
|
|
384
|
+
if (value[0] != null) {
|
|
385
|
+
return visibleMonths.find(function (month) {
|
|
386
|
+
return utils.isSameMonth(month, value[0]);
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
if (value[1] != null) {
|
|
390
|
+
return visibleMonths.find(function (month) {
|
|
391
|
+
return utils.isSameMonth(month, value[1]);
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
return (_visibleMonths$find = visibleMonths.find(function (month) {
|
|
395
|
+
return utils.isSameMonth(month, now);
|
|
396
|
+
})) != null ? _visibleMonths$find : visibleMonths[0];
|
|
397
|
+
}, [utils, value, visibleMonths, autoFocus, now]);
|
|
371
398
|
return /*#__PURE__*/_jsxs(DateRangeCalendarRoot, _extends({
|
|
372
399
|
ref: ref,
|
|
373
400
|
className: clsx(className, classes.root),
|
|
@@ -426,7 +453,7 @@ var DateRangeCalendar = /*#__PURE__*/React.forwardRef(function DateRangeCalendar
|
|
|
426
453
|
renderLoading: renderLoading,
|
|
427
454
|
components: componentsForDayCalendar,
|
|
428
455
|
componentsProps: componentsPropsForDayCalendar,
|
|
429
|
-
autoFocus:
|
|
456
|
+
autoFocus: month === focusedMonth,
|
|
430
457
|
fixedWeekNumber: fixedWeekNumber,
|
|
431
458
|
displayWeekNumber: displayWeekNumber
|
|
432
459
|
}), index)]
|
|
@@ -26,7 +26,6 @@ var DesktopNextDateRangePicker = /*#__PURE__*/React.forwardRef(function DesktopN
|
|
|
26
26
|
views: ['day'],
|
|
27
27
|
openTo: 'day',
|
|
28
28
|
showToolbar: (_defaultizedProps$sho = defaultizedProps.showToolbar) != null ? _defaultizedProps$sho : false,
|
|
29
|
-
autoFocus: true,
|
|
30
29
|
components: _extends({
|
|
31
30
|
Field: MultiInputDateRangeField
|
|
32
31
|
}, defaultizedProps.components),
|