@mui/x-date-pickers 6.9.0 → 6.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +136 -8
- package/DateField/DateField.js +3 -1
- package/DateTimeField/DateTimeField.js +3 -1
- package/DigitalClock/DigitalClock.js +28 -8
- package/MonthCalendar/MonthCalendar.js +1 -1
- package/MonthCalendar/MonthCalendar.types.d.ts +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +31 -18
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +7 -1
- package/README.md +2 -2
- package/TimeClock/TimeClock.js +35 -20
- package/TimeField/TimeField.js +3 -1
- package/YearCalendar/YearCalendar.js +1 -1
- package/YearCalendar/YearCalendar.types.d.ts +1 -1
- package/index.js +1 -1
- package/internals/hooks/useClockReferenceDate.d.ts +8 -0
- package/internals/hooks/useClockReferenceDate.js +26 -0
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +2 -0
- package/internals/models/props/clock.d.ts +6 -1
- package/internals/utils/getDefaultReferenceDate.d.ts +5 -2
- package/internals/utils/getDefaultReferenceDate.js +7 -2
- package/legacy/DateField/DateField.js +3 -1
- package/legacy/DateTimeField/DateTimeField.js +3 -1
- package/legacy/DigitalClock/DigitalClock.js +28 -10
- package/legacy/MonthCalendar/MonthCalendar.js +1 -1
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +31 -20
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +7 -1
- package/legacy/TimeClock/TimeClock.js +35 -22
- package/legacy/TimeField/TimeField.js +3 -1
- package/legacy/YearCalendar/YearCalendar.js +1 -1
- package/legacy/index.js +1 -1
- package/legacy/internals/hooks/useClockReferenceDate.js +29 -0
- package/legacy/internals/utils/getDefaultReferenceDate.js +9 -2
- package/legacy/locales/index.js +1 -0
- package/legacy/locales/roRO.js +22 -10
- package/legacy/locales/zhHK.js +93 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/roRO.js +8 -10
- package/locales/zhHK.d.ts +53 -0
- package/locales/zhHK.js +57 -0
- package/modern/DateField/DateField.js +3 -1
- package/modern/DateTimeField/DateTimeField.js +3 -1
- package/modern/DigitalClock/DigitalClock.js +28 -8
- package/modern/MonthCalendar/MonthCalendar.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +31 -18
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +7 -1
- package/modern/TimeClock/TimeClock.js +35 -20
- package/modern/TimeField/TimeField.js +3 -1
- package/modern/YearCalendar/YearCalendar.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/hooks/useClockReferenceDate.js +26 -0
- package/modern/internals/utils/getDefaultReferenceDate.js +4 -2
- package/modern/locales/index.js +1 -0
- package/modern/locales/roRO.js +8 -10
- package/modern/locales/zhHK.js +57 -0
- package/node/DateField/DateField.js +3 -1
- package/node/DateTimeField/DateTimeField.js +3 -1
- package/node/DigitalClock/DigitalClock.js +28 -8
- package/node/MonthCalendar/MonthCalendar.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +31 -18
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +7 -1
- package/node/TimeClock/TimeClock.js +35 -20
- package/node/TimeField/TimeField.js +3 -1
- package/node/YearCalendar/YearCalendar.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/hooks/useClockReferenceDate.js +35 -0
- package/node/internals/utils/getDefaultReferenceDate.js +6 -3
- package/node/locales/index.js +11 -0
- package/node/locales/roRO.js +8 -10
- package/node/locales/zhHK.js +64 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,23 +3,151 @@
|
|
|
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.9.2
|
|
7
|
+
|
|
8
|
+
_Jul 6, 2023_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🚀 Auto-scroll when making range selection (#8661) @m4theushw
|
|
13
|
+
|
|
14
|
+
- 📚 New page: Components lifecycle (#8372) @flaviendelangle
|
|
15
|
+
|
|
16
|
+
Clarify pickers events and value updates in a [single docs page](https://mui.com/x/react-date-pickers/lifecycle/).
|
|
17
|
+
|
|
18
|
+
- 🥧 Add pie chart component
|
|
19
|
+
|
|
20
|
+
They are fresh from the code editor. You can visit [pie charts docs](https://mui.com/x/react-charts/pie/) or their [demo page](https://mui.com/x/react-charts/pie-demo/).
|
|
21
|
+
|
|
22
|
+
<img width="380" alt="pie-charts" src="https://github.com/mui/mui-x/assets/13808724/fe908c45-803c-4316-b913-dbd2f9f0551e">
|
|
23
|
+
|
|
24
|
+
- 🐞 Bugfixes
|
|
25
|
+
|
|
26
|
+
- 📚 Documentation improvements
|
|
27
|
+
|
|
28
|
+
### `@mui/x-data-grid@v6.9.2` / `@mui/x-data-grid-pro@v6.9.2` / `@mui/x-data-grid-premium@v6.9.2`
|
|
29
|
+
|
|
30
|
+
#### Changes
|
|
31
|
+
|
|
32
|
+
- [DataGrid] Fix `RangeError` when using flex columns (#9554) @cherniavskii
|
|
33
|
+
- [DataGrid] Fix React 17 editing bug (#9530) @romgrk
|
|
34
|
+
- [DataGrid] Use `getRowId` in filtering (#9564) @romgrk
|
|
35
|
+
- [DataGrid] Correctly reflect `TablePagination`'s `rowsPerPageOptions` shape to `pageSizeOptions` (#9438) @burakkgunduzz
|
|
36
|
+
- [DataGridPremium] Auto-scroll when making range selection (#8661) @m4theushw
|
|
37
|
+
- [l10n] Improve Spanish (es-ES) locale (#9500) @fufex
|
|
38
|
+
|
|
39
|
+
### `@mui/x-date-pickers@v6.9.2` / `@mui/x-date-pickers-pro@v6.9.2`
|
|
40
|
+
|
|
41
|
+
#### Changes
|
|
42
|
+
|
|
43
|
+
- [pickers] Forward digital clock classes (#9555) @YoonjiJang
|
|
44
|
+
- [pickers] Rename `internal` folder to `internals` on `@mui/x-date-picker-pro` (#9571) @flaviendelangle
|
|
45
|
+
|
|
46
|
+
### `@mui/x-charts@6.0.0-alpha.2`
|
|
47
|
+
|
|
48
|
+
#### Changes
|
|
49
|
+
|
|
50
|
+
- [charts] Add pie chart component (#9395) @alexfauquette
|
|
51
|
+
|
|
52
|
+
### Docs
|
|
53
|
+
|
|
54
|
+
- [docs] Add pickers playground (#9164) @LukasTy
|
|
55
|
+
- [docs] Fix API links for pickers (#9573) @alexfauquette
|
|
56
|
+
- [docs] Fix demos with `ToggleButtonGroup` (#9548) @flaviendelangle
|
|
57
|
+
- [docs] Fix typos in pagination documentation page (#9332) @RatherBeLunar
|
|
58
|
+
- [docs] Hide ads on paid content @oliviertassinari
|
|
59
|
+
- [docs] Move the charts in the sidebar (#9437) @flaviendelangle
|
|
60
|
+
- [docs] New page: Components lifecycle (#8372) @flaviendelangle
|
|
61
|
+
- [docs] Remove outdated header tag @oliviertassinari
|
|
62
|
+
|
|
63
|
+
### Core
|
|
64
|
+
|
|
65
|
+
- [core] Fix typo in priority support @oliviertassinari
|
|
66
|
+
- [core] Remove mention of Crowdin @oliviertassinari
|
|
67
|
+
|
|
68
|
+
## 6.9.1
|
|
69
|
+
|
|
70
|
+
_Jun 30, 2023_
|
|
71
|
+
|
|
72
|
+
We'd like to offer a big thanks to the 13 contributors who made this release possible. Here are some highlights ✨:
|
|
73
|
+
|
|
74
|
+
- 🔎 Add experimental API for faster filtering performance
|
|
75
|
+
- 🌍 Add Chinese (Hong Kong) (zh-HK) locale on the pickers
|
|
76
|
+
- 🌍 Improve Romanian (ro-RO) and Hungarian (hu-HU) translations on the pickers and the data grid
|
|
77
|
+
- 🐞 Bugfixes
|
|
78
|
+
- 📚 Documentation improvements
|
|
79
|
+
|
|
80
|
+
### `@mui/x-data-grid@v6.9.1` / `@mui/x-data-grid-pro@v6.9.1` / `@mui/x-data-grid-premium@v6.9.1`
|
|
81
|
+
|
|
82
|
+
#### Changes
|
|
83
|
+
|
|
84
|
+
- [DataGrid] Add Joy UI `tooltip` and `loadingOverlay` slots (#9028) @cherniavskii
|
|
85
|
+
- [DataGrid] Add section about enabling pagination on Pro and Premium (#8759) @joserodolfofreitas
|
|
86
|
+
- [DataGrid] Don't forward `editCellState` prop to DOM element (#9501) @m4theushw
|
|
87
|
+
- [DataGrid] Add experimental API for faster filtering performance (#9254) @romgrk
|
|
88
|
+
- [DataGrid] Fix `nextFieldToFocus` to always be a visible column field when <kbd>Tab</kbd> key is pressed (#8314) @yaredtsy
|
|
89
|
+
- [DataGrid] Fix `Maximum call stack size exceeded` error when using fractional width (#9516) @cherniavskii
|
|
90
|
+
- [DataGridPro] Don't throw error in column pinning (#9507) @romgrk
|
|
91
|
+
- [DataGridPro] Fix bug with `checkboxSelection` and treeData/grouping (#9418) @romgrk
|
|
92
|
+
- [l10n] Improve Romanian (ro-RO) and Hungarian (hu-HU) translations (#9436) @noraleonte
|
|
93
|
+
|
|
94
|
+
### `@mui/x-date-pickers@v6.9.1` / `@mui/x-date-pickers-pro@v6.9.1`
|
|
95
|
+
|
|
96
|
+
#### Changes
|
|
97
|
+
|
|
98
|
+
- [DateTimePicker] Scroll to Digital Clock section only when selection changes (#9434) @LukasTy
|
|
99
|
+
- [pickers] Handle `keyDown` only when input is focused (#9481) @LukasTy
|
|
100
|
+
- [pickers] Add `referenceDate` prop on `TimeClock`, `DigitalClock` and `MultiSectionDigitalClock` (#9356) @flaviendelangle
|
|
101
|
+
- [l10n] Add Chinese (Hong Kong) (zh-HK) locale (#9468) @samchiu90
|
|
102
|
+
- [l10n] Improve Romanian (ro-RO) translations (#9436) @noraleonte
|
|
103
|
+
|
|
104
|
+
### `@mui/x-charts@6.0.0-alpha.1`
|
|
105
|
+
|
|
106
|
+
#### Changes
|
|
107
|
+
|
|
108
|
+
- [charts] Take responsive container from data grid (#9497) @alexfauquette
|
|
109
|
+
- [charts] Update README.md (#9426) @alexfauquette
|
|
110
|
+
- [charts] Fix typo and small refactor (#9526) @flaviendelangle
|
|
111
|
+
|
|
112
|
+
### Docs
|
|
113
|
+
|
|
114
|
+
- [docs] Add a recipe limiting to one expanded detail panel at a time (#9488) @cherniavskii
|
|
115
|
+
- [docs] Add missing upcoming flag without issue (#9449) @oliviertassinari
|
|
116
|
+
- [docs] Fix 301 when opening the charts @oliviertassinari
|
|
117
|
+
- [docs] Fix 404 link (#9435) @alexfauquette
|
|
118
|
+
- [docs] Fix `productId` logic (#9451) @oliviertassinari
|
|
119
|
+
- [docs] Update charts overview.md (#9429) @brentertz
|
|
120
|
+
- [docs] Avoid systematic usage of `"bg": "inline"` (#9499) @alexfauquette
|
|
121
|
+
- [docs] Display plan icon in ToC (#9490) @cherniavskii
|
|
122
|
+
- [docs] Remove "product" markdown header (#9517) @oliviertassinari
|
|
123
|
+
|
|
124
|
+
### Core
|
|
125
|
+
|
|
126
|
+
- [core] Add `edit-mode` to priority support action (#9483) @DanailH
|
|
127
|
+
- [core] Fix priority support prompt action (#9472) @DanailH
|
|
128
|
+
- [core] Update `uses` for priority support action (#9480) @DanailH
|
|
129
|
+
- [core] Bumb update monorepo (#9476) @alexfauquette
|
|
130
|
+
- [CHANGELOG] Fix media quality (#9439) @oliviertassinari
|
|
131
|
+
- [CHANGELOG] Remove height img attribute @oliviertassinari
|
|
132
|
+
- [test] Skip flaky row pinning tests in JSDOM (#9511) @cherniavskii
|
|
133
|
+
|
|
6
134
|
## 6.9.0
|
|
7
135
|
|
|
8
136
|
_Jun 22, 2023_
|
|
9
137
|
|
|
10
138
|
We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
|
|
11
139
|
|
|
12
|
-
- 🎁 We
|
|
13
|
-
|
|
140
|
+
- 🎁 We released a new open-source package: `@mui/x-charts`. This package aims at simplifying the integration of charts into your dashboards. 📊
|
|
141
|
+
|
|
142
|
+
<img width="512" alt="charts" src="https://github.com/mui/mui-x/assets/3165635/41201d3c-16a4-442d-a230-68356e6b433d">
|
|
143
|
+
|
|
144
|
+
It already contains [line](https://mui.com/x/react-charts/lines/), [bar](https://mui.com/x/react-charts/bars/), and [scatter](https://mui.com/x/react-charts/scatter/) charts, with basic customization features. Check out the [documentation](https://mui.com/x/react-charts/) to see what it can do, and open issues to get the feature you need implemented.
|
|
14
145
|
|
|
15
|
-
|
|
146
|
+
- 🚀 Introducing UTC and timezone support for pickers.
|
|
16
147
|
|
|
17
|
-
|
|
18
|
-
Please, visit the new [documentation](https://mui.com/x/react-charts/) to know what it does, and open issues to get the feature you need to be implemented.
|
|
148
|
+
<img width="774" src="https://github.com/mui/mui-x/assets/3165635/ad95a404-ee67-4aff-b996-ad6cbb322348">
|
|
19
149
|
|
|
20
|
-
|
|
21
|
-

|
|
22
|
-
Please visit the [documentation](https://mui.com/x/react-date-pickers/timezone/) to learn how to use it.
|
|
150
|
+
Visit the [documentation](https://mui.com/x/react-date-pickers/timezone/) to learn how to use it.
|
|
23
151
|
|
|
24
152
|
- 🌍 Improve Brazilian Portuguese (pt-BR) on the data grid
|
|
25
153
|
- 🌍 Improve Czech (cs-CZ) locale on the pickers
|
package/DateField/DateField.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["components", "componentsProps", "slots", "slotProps", "InputProps", "inputProps"],
|
|
4
4
|
_excluded2 = ["inputRef"],
|
|
5
|
-
_excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
|
|
5
|
+
_excluded3 = ["ref", "onPaste", "onKeyDown", "inputMode", "readOnly"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import MuiTextField from '@mui/material/TextField';
|
|
@@ -48,6 +48,7 @@ const DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps, ref)
|
|
|
48
48
|
{
|
|
49
49
|
ref: inputRef,
|
|
50
50
|
onPaste,
|
|
51
|
+
onKeyDown,
|
|
51
52
|
inputMode,
|
|
52
53
|
readOnly
|
|
53
54
|
} = _useDateField,
|
|
@@ -61,6 +62,7 @@ const DateField = /*#__PURE__*/React.forwardRef(function DateField(inProps, ref)
|
|
|
61
62
|
inputProps: _extends({}, fieldProps.inputProps, {
|
|
62
63
|
inputMode,
|
|
63
64
|
onPaste,
|
|
65
|
+
onKeyDown,
|
|
64
66
|
ref: inputRef
|
|
65
67
|
})
|
|
66
68
|
}));
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["components", "componentsProps", "slots", "slotProps", "InputProps", "inputProps"],
|
|
4
4
|
_excluded2 = ["inputRef"],
|
|
5
|
-
_excluded3 = ["ref", "onPaste", "inputMode", "readOnly"];
|
|
5
|
+
_excluded3 = ["ref", "onPaste", "onKeyDown", "inputMode", "readOnly"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import MuiTextField from '@mui/material/TextField';
|
|
@@ -48,6 +48,7 @@ const DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inPro
|
|
|
48
48
|
{
|
|
49
49
|
ref: inputRef,
|
|
50
50
|
onPaste,
|
|
51
|
+
onKeyDown,
|
|
51
52
|
inputMode,
|
|
52
53
|
readOnly
|
|
53
54
|
} = _useDateTimeField,
|
|
@@ -61,6 +62,7 @@ const DateTimeField = /*#__PURE__*/React.forwardRef(function DateTimeField(inPro
|
|
|
61
62
|
inputProps: _extends({}, fieldProps.inputProps, {
|
|
62
63
|
inputMode,
|
|
63
64
|
onPaste,
|
|
65
|
+
onKeyDown,
|
|
64
66
|
ref: inputRef
|
|
65
67
|
})
|
|
66
68
|
}));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["ampm", "timeStep", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "onChange", "
|
|
3
|
+
const _excluded = ["ampm", "timeStep", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "defaultValue", "referenceDate", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "onChange", "view", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly", "views", "skipDisabled", "timezone"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
7
8
|
import { alpha, styled, useThemeProps } from '@mui/material/styles';
|
|
8
9
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
9
10
|
import composeClasses from '@mui/utils/composeClasses';
|
|
@@ -18,6 +19,7 @@ import { useViews } from '../internals/hooks/useViews';
|
|
|
18
19
|
import { DIGITAL_CLOCK_VIEW_HEIGHT } from '../internals/constants/dimensions';
|
|
19
20
|
import { useControlledValueWithTimezone } from '../internals/hooks/useValueWithTimezone';
|
|
20
21
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
22
|
+
import { useClockReferenceDate } from '../internals/hooks/useClockReferenceDate';
|
|
21
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
24
|
const useUtilityClasses = ownerState => {
|
|
23
25
|
const {
|
|
@@ -93,6 +95,8 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
93
95
|
slots,
|
|
94
96
|
slotProps,
|
|
95
97
|
value: valueProp,
|
|
98
|
+
defaultValue,
|
|
99
|
+
referenceDate: referenceDateProp,
|
|
96
100
|
disableIgnoringDatePartForTimeValidation = false,
|
|
97
101
|
maxTime,
|
|
98
102
|
minTime,
|
|
@@ -102,7 +106,6 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
102
106
|
shouldDisableClock,
|
|
103
107
|
shouldDisableTime,
|
|
104
108
|
onChange,
|
|
105
|
-
defaultValue,
|
|
106
109
|
view: inView,
|
|
107
110
|
openTo,
|
|
108
111
|
onViewChange,
|
|
@@ -135,7 +138,19 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
135
138
|
}), [props]);
|
|
136
139
|
const classes = useUtilityClasses(ownerState);
|
|
137
140
|
const ClockItem = (_ref = (_slots$digitalClockIt = slots == null ? void 0 : slots.digitalClockItem) != null ? _slots$digitalClockIt : components == null ? void 0 : components.DigitalClockItem) != null ? _ref : DigitalClockItem;
|
|
138
|
-
const clockItemProps = (
|
|
141
|
+
const clockItemProps = useSlotProps({
|
|
142
|
+
elementType: ClockItem,
|
|
143
|
+
externalSlotProps: (_slotProps$digitalClo = slotProps == null ? void 0 : slotProps.digitalClockItem) != null ? _slotProps$digitalClo : componentsProps == null ? void 0 : componentsProps.digitalClockItem,
|
|
144
|
+
ownerState: {},
|
|
145
|
+
className: classes.item
|
|
146
|
+
});
|
|
147
|
+
const valueOrReferenceDate = useClockReferenceDate({
|
|
148
|
+
value,
|
|
149
|
+
referenceDate: referenceDateProp,
|
|
150
|
+
utils,
|
|
151
|
+
props,
|
|
152
|
+
timezone
|
|
153
|
+
});
|
|
139
154
|
const handleValueChange = useEventCallback(newValue => handleRawValueChange(newValue, 'finish'));
|
|
140
155
|
const {
|
|
141
156
|
setValueAndGoToNextView
|
|
@@ -164,7 +179,6 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
164
179
|
// Subtracting the 4px of extra margin intended for the first visible section item
|
|
165
180
|
containerRef.current.scrollTop = offsetTop - 4;
|
|
166
181
|
});
|
|
167
|
-
const selectedTimeOrMidnight = React.useMemo(() => value || utils.setSeconds(utils.setMinutes(utils.setHours(now, 0), 0), 0), [value, now, utils]);
|
|
168
182
|
const isTimeDisabled = React.useCallback(valueToCheck => {
|
|
169
183
|
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, utils);
|
|
170
184
|
const containsValidTime = () => {
|
|
@@ -197,11 +211,11 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
197
211
|
return !containsValidTime() || !isValidValue();
|
|
198
212
|
}, [disableIgnoringDatePartForTimeValidation, utils, minTime, maxTime, disableFuture, now, disablePast, minutesStep, shouldDisableClock, shouldDisableTime]);
|
|
199
213
|
const timeOptions = React.useMemo(() => {
|
|
200
|
-
const startOfDay = utils.startOfDay(
|
|
214
|
+
const startOfDay = utils.startOfDay(valueOrReferenceDate);
|
|
201
215
|
return [startOfDay, ...Array.from({
|
|
202
216
|
length: Math.ceil(24 * 60 / timeStep) - 1
|
|
203
|
-
}, (_, index) => utils.addMinutes(startOfDay, timeStep * (index + 1))), utils.endOfDay(
|
|
204
|
-
}, [
|
|
217
|
+
}, (_, index) => utils.addMinutes(startOfDay, timeStep * (index + 1))), utils.endOfDay(valueOrReferenceDate)];
|
|
218
|
+
}, [valueOrReferenceDate, timeStep, utils]);
|
|
205
219
|
return /*#__PURE__*/_jsx(DigitalClockRoot, _extends({
|
|
206
220
|
ref: handleRef,
|
|
207
221
|
className: clsx(classes.root, className),
|
|
@@ -211,6 +225,7 @@ export const DigitalClock = /*#__PURE__*/React.forwardRef(function DigitalClock(
|
|
|
211
225
|
autoFocusItem: autoFocus || !!focusedView,
|
|
212
226
|
role: "listbox",
|
|
213
227
|
"aria-label": localeText.timePickerToolbarTitle,
|
|
228
|
+
className: classes.list,
|
|
214
229
|
children: timeOptions.map(option => {
|
|
215
230
|
if (skipDisabled && isTimeDisabled(option)) {
|
|
216
231
|
return null;
|
|
@@ -313,7 +328,7 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
313
328
|
minutesStep: PropTypes.number,
|
|
314
329
|
/**
|
|
315
330
|
* Callback fired when the value changes.
|
|
316
|
-
* @template TDate
|
|
331
|
+
* @template TDate, TView
|
|
317
332
|
* @param {TDate | null} value The new value.
|
|
318
333
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
319
334
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
@@ -343,6 +358,11 @@ process.env.NODE_ENV !== "production" ? DigitalClock.propTypes = {
|
|
|
343
358
|
* @default false
|
|
344
359
|
*/
|
|
345
360
|
readOnly: PropTypes.bool,
|
|
361
|
+
/**
|
|
362
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
363
|
+
* @default The closest valid time using the validation props, except callbacks such as `shouldDisableTime`.
|
|
364
|
+
*/
|
|
365
|
+
referenceDate: PropTypes.any,
|
|
346
366
|
/**
|
|
347
367
|
* Disable specific clock time.
|
|
348
368
|
* @param {number} clockValue The value to check.
|
|
@@ -283,7 +283,7 @@ process.env.NODE_ENV !== "production" ? MonthCalendar.propTypes = {
|
|
|
283
283
|
readOnly: PropTypes.bool,
|
|
284
284
|
/**
|
|
285
285
|
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
286
|
-
* @default The closest valid month using the validation props, except callbacks such as `
|
|
286
|
+
* @default The closest valid month using the validation props, except callbacks such as `shouldDisableMonth`.
|
|
287
287
|
*/
|
|
288
288
|
referenceDate: PropTypes.any,
|
|
289
289
|
/**
|
|
@@ -38,7 +38,7 @@ export interface MonthCalendarProps<TDate> extends ExportedMonthCalendarProps, M
|
|
|
38
38
|
defaultValue?: TDate | null;
|
|
39
39
|
/**
|
|
40
40
|
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
41
|
-
* @default The closest valid month using the validation props, except callbacks such as `
|
|
41
|
+
* @default The closest valid month using the validation props, except callbacks such as `shouldDisableMonth`.
|
|
42
42
|
*/
|
|
43
43
|
referenceDate?: TDate;
|
|
44
44
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["ampm", "timeSteps", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "onChange", "
|
|
3
|
+
const _excluded = ["ampm", "timeSteps", "autoFocus", "components", "componentsProps", "slots", "slotProps", "value", "defaultValue", "referenceDate", "disableIgnoringDatePartForTimeValidation", "maxTime", "minTime", "disableFuture", "disablePast", "minutesStep", "shouldDisableClock", "shouldDisableTime", "onChange", "view", "views", "openTo", "onViewChange", "focusedView", "onFocusedViewChange", "className", "disabled", "readOnly", "skipDisabled", "timezone"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
@@ -17,6 +17,7 @@ import { MultiSectionDigitalClockSection } from './MultiSectionDigitalClockSecti
|
|
|
17
17
|
import { getHourSectionOptions, getTimeSectionOptions } from './MultiSectionDigitalClock.utils';
|
|
18
18
|
import { useControlledValueWithTimezone } from '../internals/hooks/useValueWithTimezone';
|
|
19
19
|
import { singleItemValueManager } from '../internals/utils/valueManagers';
|
|
20
|
+
import { useClockReferenceDate } from '../internals/hooks/useClockReferenceDate';
|
|
20
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
22
|
const useUtilityClasses = ownerState => {
|
|
22
23
|
const {
|
|
@@ -54,6 +55,8 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
54
55
|
slots,
|
|
55
56
|
slotProps,
|
|
56
57
|
value: valueProp,
|
|
58
|
+
defaultValue,
|
|
59
|
+
referenceDate: referenceDateProp,
|
|
57
60
|
disableIgnoringDatePartForTimeValidation = false,
|
|
58
61
|
maxTime,
|
|
59
62
|
minTime,
|
|
@@ -63,7 +66,6 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
63
66
|
shouldDisableClock,
|
|
64
67
|
shouldDisableTime,
|
|
65
68
|
onChange,
|
|
66
|
-
defaultValue,
|
|
67
69
|
view: inView,
|
|
68
70
|
views: inViews = ['hours', 'minutes'],
|
|
69
71
|
openTo,
|
|
@@ -96,6 +98,13 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
96
98
|
minutes: 5,
|
|
97
99
|
seconds: 5
|
|
98
100
|
}, inTimeSteps), [inTimeSteps]);
|
|
101
|
+
const valueOrReferenceDate = useClockReferenceDate({
|
|
102
|
+
value,
|
|
103
|
+
referenceDate: referenceDateProp,
|
|
104
|
+
utils,
|
|
105
|
+
props,
|
|
106
|
+
timezone
|
|
107
|
+
});
|
|
99
108
|
const handleValueChange = useEventCallback((newValue, selectionState, selectedView) => handleRawValueChange(newValue, selectionState, selectedView));
|
|
100
109
|
const views = React.useMemo(() => {
|
|
101
110
|
if (!ampm || !inViews.includes('hours')) {
|
|
@@ -116,14 +125,13 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
116
125
|
focusedView: inFocusedView,
|
|
117
126
|
onFocusedViewChange
|
|
118
127
|
});
|
|
119
|
-
const selectedTimeOrMidnight = React.useMemo(() => value || utils.setSeconds(utils.setMinutes(utils.setHours(now, 0), 0), 0), [value, now, utils]);
|
|
120
128
|
const handleMeridiemValueChange = useEventCallback(newValue => {
|
|
121
129
|
setValueAndGoToView(newValue, null, 'meridiem');
|
|
122
130
|
});
|
|
123
131
|
const {
|
|
124
132
|
meridiemMode,
|
|
125
133
|
handleMeridiemChange
|
|
126
|
-
} = useMeridiemMode(
|
|
134
|
+
} = useMeridiemMode(valueOrReferenceDate, ampm, handleMeridiemValueChange, 'finish');
|
|
127
135
|
const isTimeDisabled = React.useCallback((rawValue, viewType) => {
|
|
128
136
|
const isAfter = createIsAfterIgnoreDatePart(disableIgnoringDatePartForTimeValidation, utils);
|
|
129
137
|
const shouldCheckPastEnd = viewType === 'hours' || viewType === 'minutes' && views.includes('seconds');
|
|
@@ -155,11 +163,11 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
155
163
|
if (shouldDisableTime) {
|
|
156
164
|
switch (viewType) {
|
|
157
165
|
case 'hours':
|
|
158
|
-
return !shouldDisableTime(utils.setHours(
|
|
166
|
+
return !shouldDisableTime(utils.setHours(valueOrReferenceDate, timeValue), 'hours');
|
|
159
167
|
case 'minutes':
|
|
160
|
-
return !shouldDisableTime(utils.setMinutes(
|
|
168
|
+
return !shouldDisableTime(utils.setMinutes(valueOrReferenceDate, timeValue), 'minutes');
|
|
161
169
|
case 'seconds':
|
|
162
|
-
return !shouldDisableTime(utils.setSeconds(
|
|
170
|
+
return !shouldDisableTime(utils.setSeconds(valueOrReferenceDate, timeValue), 'seconds');
|
|
163
171
|
default:
|
|
164
172
|
return false;
|
|
165
173
|
}
|
|
@@ -170,7 +178,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
170
178
|
case 'hours':
|
|
171
179
|
{
|
|
172
180
|
const valueWithMeridiem = convertValueToMeridiem(rawValue, meridiemMode, ampm);
|
|
173
|
-
const dateWithNewHours = utils.setHours(
|
|
181
|
+
const dateWithNewHours = utils.setHours(valueOrReferenceDate, valueWithMeridiem);
|
|
174
182
|
const start = utils.setSeconds(utils.setMinutes(dateWithNewHours, 0), 0);
|
|
175
183
|
const end = utils.setSeconds(utils.setMinutes(dateWithNewHours, 59), 59);
|
|
176
184
|
return !containsValidTime({
|
|
@@ -180,7 +188,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
180
188
|
}
|
|
181
189
|
case 'minutes':
|
|
182
190
|
{
|
|
183
|
-
const dateWithNewMinutes = utils.setMinutes(
|
|
191
|
+
const dateWithNewMinutes = utils.setMinutes(valueOrReferenceDate, rawValue);
|
|
184
192
|
const start = utils.setSeconds(dateWithNewMinutes, 0);
|
|
185
193
|
const end = utils.setSeconds(dateWithNewMinutes, 59);
|
|
186
194
|
return !containsValidTime({
|
|
@@ -190,7 +198,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
190
198
|
}
|
|
191
199
|
case 'seconds':
|
|
192
200
|
{
|
|
193
|
-
const dateWithNewSeconds = utils.setSeconds(
|
|
201
|
+
const dateWithNewSeconds = utils.setSeconds(valueOrReferenceDate, rawValue);
|
|
194
202
|
const start = dateWithNewSeconds;
|
|
195
203
|
const end = dateWithNewSeconds;
|
|
196
204
|
return !containsValidTime({
|
|
@@ -201,7 +209,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
201
209
|
default:
|
|
202
210
|
throw new Error('not supported');
|
|
203
211
|
}
|
|
204
|
-
}, [ampm,
|
|
212
|
+
}, [ampm, valueOrReferenceDate, disableIgnoringDatePartForTimeValidation, maxTime, meridiemMode, minTime, minutesStep, shouldDisableClock, shouldDisableTime, utils, disableFuture, disablePast, now, views]);
|
|
205
213
|
const handleSectionChange = useEventCallback((sectionView, newValue) => {
|
|
206
214
|
const viewIndex = views.indexOf(sectionView);
|
|
207
215
|
const nextView = views[viewIndex + 1];
|
|
@@ -214,7 +222,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
214
222
|
return {
|
|
215
223
|
onChange: hours => {
|
|
216
224
|
const valueWithMeridiem = convertValueToMeridiem(hours, meridiemMode, ampm);
|
|
217
|
-
handleSectionChange('hours', utils.setHours(
|
|
225
|
+
handleSectionChange('hours', utils.setHours(valueOrReferenceDate, valueWithMeridiem));
|
|
218
226
|
},
|
|
219
227
|
items: getHourSectionOptions({
|
|
220
228
|
now,
|
|
@@ -231,10 +239,10 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
231
239
|
{
|
|
232
240
|
return {
|
|
233
241
|
onChange: minutes => {
|
|
234
|
-
handleSectionChange('minutes', utils.setMinutes(
|
|
242
|
+
handleSectionChange('minutes', utils.setMinutes(valueOrReferenceDate, minutes));
|
|
235
243
|
},
|
|
236
244
|
items: getTimeSectionOptions({
|
|
237
|
-
value: utils.getMinutes(
|
|
245
|
+
value: utils.getMinutes(valueOrReferenceDate),
|
|
238
246
|
isDisabled: minutes => disabled || isTimeDisabled(minutes, 'minutes'),
|
|
239
247
|
resolveLabel: minutes => utils.format(utils.setMinutes(now, minutes), 'minutes'),
|
|
240
248
|
timeStep: timeSteps.minutes,
|
|
@@ -247,10 +255,10 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
247
255
|
{
|
|
248
256
|
return {
|
|
249
257
|
onChange: seconds => {
|
|
250
|
-
handleSectionChange('seconds', utils.setSeconds(
|
|
258
|
+
handleSectionChange('seconds', utils.setSeconds(valueOrReferenceDate, seconds));
|
|
251
259
|
},
|
|
252
260
|
items: getTimeSectionOptions({
|
|
253
|
-
value: utils.getSeconds(
|
|
261
|
+
value: utils.getSeconds(valueOrReferenceDate),
|
|
254
262
|
isDisabled: seconds => disabled || isTimeDisabled(seconds, 'seconds'),
|
|
255
263
|
resolveLabel: seconds => utils.format(utils.setSeconds(now, seconds), 'seconds'),
|
|
256
264
|
timeStep: timeSteps.seconds,
|
|
@@ -281,7 +289,7 @@ export const MultiSectionDigitalClock = /*#__PURE__*/React.forwardRef(function M
|
|
|
281
289
|
default:
|
|
282
290
|
throw new Error(`Unknown view: ${viewToBuild} found.`);
|
|
283
291
|
}
|
|
284
|
-
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, handleSectionChange,
|
|
292
|
+
}, [now, value, ampm, utils, timeSteps.hours, timeSteps.minutes, timeSteps.seconds, localeText.hoursClockNumberText, localeText.minutesClockNumberText, localeText.secondsClockNumberText, meridiemMode, handleSectionChange, valueOrReferenceDate, disabled, isTimeDisabled, handleMeridiemChange]);
|
|
285
293
|
const viewTimeOptions = React.useMemo(() => {
|
|
286
294
|
return views.reduce((result, currentView) => {
|
|
287
295
|
return _extends({}, result, {
|
|
@@ -391,7 +399,7 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
391
399
|
minutesStep: PropTypes.number,
|
|
392
400
|
/**
|
|
393
401
|
* Callback fired when the value changes.
|
|
394
|
-
* @template TDate
|
|
402
|
+
* @template TDate, TView
|
|
395
403
|
* @param {TDate | null} value The new value.
|
|
396
404
|
* @param {PickerSelectionState | undefined} selectionState Indicates if the date selection is complete.
|
|
397
405
|
* @param {TView | undefined} selectedView Indicates the view in which the selection has been made.
|
|
@@ -421,6 +429,11 @@ process.env.NODE_ENV !== "production" ? MultiSectionDigitalClock.propTypes = {
|
|
|
421
429
|
* @default false
|
|
422
430
|
*/
|
|
423
431
|
readOnly: PropTypes.bool,
|
|
432
|
+
/**
|
|
433
|
+
* The date used to generate the new value when both `value` and `defaultValue` are empty.
|
|
434
|
+
* @default The closest valid time using the validation props, except callbacks such as `shouldDisableTime`.
|
|
435
|
+
*/
|
|
436
|
+
referenceDate: PropTypes.any,
|
|
424
437
|
/**
|
|
425
438
|
* Disable specific clock time.
|
|
426
439
|
* @param {number} clockValue The value to check.
|
|
@@ -82,6 +82,7 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
82
82
|
var _slots$digitalClockSe;
|
|
83
83
|
const containerRef = React.useRef(null);
|
|
84
84
|
const handleRef = useForkRef(ref, containerRef);
|
|
85
|
+
const previousSelected = React.useRef(null);
|
|
85
86
|
const props = useThemeProps({
|
|
86
87
|
props: inProps,
|
|
87
88
|
name: 'MuiMultiSectionDigitalClockSection'
|
|
@@ -109,9 +110,14 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
111
112
|
const selectedItem = containerRef.current.querySelector('[role="option"][aria-selected="true"]');
|
|
112
|
-
if (!selectedItem) {
|
|
113
|
+
if (!selectedItem || previousSelected.current === selectedItem) {
|
|
114
|
+
// Handle setting the ref to null if the selected item is ever reset via UI
|
|
115
|
+
if (previousSelected.current !== selectedItem) {
|
|
116
|
+
previousSelected.current = selectedItem;
|
|
117
|
+
}
|
|
113
118
|
return;
|
|
114
119
|
}
|
|
120
|
+
previousSelected.current = selectedItem;
|
|
115
121
|
if (active && autoFocus) {
|
|
116
122
|
selectedItem.focus();
|
|
117
123
|
}
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ It's part of MUI X, an open-core extension of MUI, with advanced components.
|
|
|
7
7
|
|
|
8
8
|
Install the package in your project directory with:
|
|
9
9
|
|
|
10
|
-
```
|
|
10
|
+
```bash
|
|
11
11
|
npm install @mui/x-date-pickers
|
|
12
12
|
```
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ We currently support 4 different date libraries:
|
|
|
19
19
|
- [Luxon](https://moment.github.io/luxon/#/)
|
|
20
20
|
- [Moment.js](https://momentjs.com/)
|
|
21
21
|
|
|
22
|
-
```
|
|
22
|
+
```bash
|
|
23
23
|
// date-fns
|
|
24
24
|
npm install date-fns
|
|
25
25
|
// or dayjs
|