@mui/x-date-pickers 8.11.0 → 8.11.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 +169 -0
- package/DateCalendar/DateCalendar.js +1 -0
- package/MonthCalendar/MonthCalendar.js +10 -6
- package/MonthCalendar/MonthCalendar.types.d.ts +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +14 -8
- package/esm/DateCalendar/DateCalendar.js +1 -0
- package/esm/MonthCalendar/MonthCalendar.js +10 -6
- package/esm/MonthCalendar/MonthCalendar.types.d.ts +1 -0
- package/esm/MultiSectionDigitalClock/MultiSectionDigitalClockSection.js +14 -8
- package/esm/index.js +1 -1
- package/esm/internals/components/PickerFieldUI.js +45 -12
- package/esm/internals/hooks/useField/useFieldSectionContentProps.js +9 -8
- package/index.js +1 -1
- package/internals/components/PickerFieldUI.js +45 -12
- package/internals/hooks/useField/useFieldSectionContentProps.js +9 -8
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,175 @@
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## 8.11.2
|
|
9
|
+
|
|
10
|
+
_Sep 10, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to extend a big thank you to the 13 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
- 📚 Documentation improvements
|
|
16
|
+
|
|
17
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
18
|
+
@ludvigeriksson, @sai6855
|
|
19
|
+
|
|
20
|
+
The following are all team members who have contributed to this release:
|
|
21
|
+
@alexfauquette, @bernardobelchior, @brijeshb42, @flaviendelangle, @Janpot, @LukasTy, @MBilalShafi, @noraleonte, @rita-codes, @romgrk, @siriwatknp
|
|
22
|
+
|
|
23
|
+
### Data Grid
|
|
24
|
+
|
|
25
|
+
#### `@mui/x-data-grid@8.11.2`
|
|
26
|
+
|
|
27
|
+
- [DataGrid] Allow opting out of the exclude row selection model (#19423) @MBilalShafi
|
|
28
|
+
- [DataGrid] Fix column dropdown menu text alignment for the "Unpin" menu item (#19462) @MBilalShafi
|
|
29
|
+
- [DataGrid] Fix indeterminate state for "Select all" checkbox with exclude model (#19466) @MBilalShafi
|
|
30
|
+
- [DataGrid] Fix styled API arguments error (#19460) @MBilalShafi
|
|
31
|
+
- [DataGrid] Fix `stringify()` for theme objects (#19427) @romgrk
|
|
32
|
+
|
|
33
|
+
#### `@mui/x-data-grid-pro@8.11.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
34
|
+
|
|
35
|
+
Same changes as in `@mui/x-data-grid@8.11.2`.
|
|
36
|
+
|
|
37
|
+
#### `@mui/x-data-grid-premium@8.11.2` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
38
|
+
|
|
39
|
+
Same changes as in `@mui/x-data-grid-pro@8.11.2`, plus:
|
|
40
|
+
|
|
41
|
+
- [DataGridPremium] Fallback to the regular reorder method for plain data (#19467) @MBilalShafi
|
|
42
|
+
- [DataGridPremium] Fix showing `0` as total aggregation value when aggregation position is set to `null` for row groups (#19515) @cherniavskii
|
|
43
|
+
|
|
44
|
+
### Date and Time Pickers
|
|
45
|
+
|
|
46
|
+
#### `@mui/x-date-pickers@8.11.2`
|
|
47
|
+
|
|
48
|
+
- [pickers] Gracefully handle `textField.slotProps` (#18980) @LukasTy
|
|
49
|
+
- [pickers] Improve hour and minute placement in Date Time Picker (#19227) @MBilalShafi
|
|
50
|
+
- [pickers] Use `calendarState.currentMonth` in Month Calendar when available (#19073) @LukasTy
|
|
51
|
+
- [pickers] Improve invalid value pasting into a section (#19357) @sai6855
|
|
52
|
+
- [fields] Remove redundant `id` and `aria-labelledby` attributes from spinbuttons (#19523) @LukasTy
|
|
53
|
+
|
|
54
|
+
#### `@mui/x-date-pickers-pro@8.11.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
55
|
+
|
|
56
|
+
Same changes as in `@mui/x-date-pickers@8.11.2`.
|
|
57
|
+
|
|
58
|
+
### Charts
|
|
59
|
+
|
|
60
|
+
#### `@mui/x-charts@8.11.2`
|
|
61
|
+
|
|
62
|
+
- [charts] Fix highlight regression (#19486) @alexfauquette
|
|
63
|
+
- [charts] Improve code reuse in `ChartsXAxis` and `ChartsYAxis` (#19198) @bernardobelchior
|
|
64
|
+
- [charts] Simplify params in `getRange` and `createDateFormatter` (#19517) @bernardobelchior
|
|
65
|
+
- [charts] Handle domain edge cases with `filterMode: 'discard'` (#19199) @bernardobelchior
|
|
66
|
+
- [l10n] Add Swedish (sv-SE) locale (#19489) @ludvigeriksson
|
|
67
|
+
|
|
68
|
+
#### `@mui/x-charts-pro@8.11.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
69
|
+
|
|
70
|
+
Same changes as in `@mui/x-charts@8.11.2`.
|
|
71
|
+
|
|
72
|
+
### Tree View
|
|
73
|
+
|
|
74
|
+
#### `@mui/x-tree-view@8.11.2`
|
|
75
|
+
|
|
76
|
+
- [TreeView] Do not mutate `props.items` in the `getItemTree()` method (#19483) @flaviendelangle
|
|
77
|
+
- [TreeView] Expose a new hook to apply selection propagation on the selected items (#19402) @flaviendelangle
|
|
78
|
+
|
|
79
|
+
#### `@mui/x-tree-view-pro@8.11.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
80
|
+
|
|
81
|
+
Same changes as in `@mui/x-tree-view@8.11.2`.
|
|
82
|
+
|
|
83
|
+
### Codemod
|
|
84
|
+
|
|
85
|
+
#### `@mui/x-codemod@8.11.2`
|
|
86
|
+
|
|
87
|
+
Internal changes.
|
|
88
|
+
|
|
89
|
+
### Docs
|
|
90
|
+
|
|
91
|
+
- [docs] Add recipe for save and manage filters from the panel (#19361) @siriwatknp
|
|
92
|
+
|
|
93
|
+
### Core
|
|
94
|
+
|
|
95
|
+
- [code-infra] Remove log when restarting dev server (#19490) @bernardobelchior
|
|
96
|
+
- [code-infra] Store test results in CI (#19507) @Janpot
|
|
97
|
+
|
|
98
|
+
### Miscellaneous
|
|
99
|
+
|
|
100
|
+
- [infra] Set nodejs versions of various CIs to 22.18 (#19503) @brijeshb42
|
|
101
|
+
- [test] Split infinitive @romgrk
|
|
102
|
+
|
|
103
|
+
## 8.11.1
|
|
104
|
+
|
|
105
|
+
_Sep 4, 2025_
|
|
106
|
+
|
|
107
|
+
We'd like to extend a big thank you to the 6 contributors who made this release possible. Here are some highlights ✨:
|
|
108
|
+
|
|
109
|
+
Special thanks go out to the community members for their valuable contributions:
|
|
110
|
+
@sai6855
|
|
111
|
+
|
|
112
|
+
The following are all team members who have contributed to this release:
|
|
113
|
+
@brijeshb42, @flaviendelangle, @JCQuintas, @mapache-salvaje, @oliviertassinari
|
|
114
|
+
|
|
115
|
+
### Data Grid
|
|
116
|
+
|
|
117
|
+
#### `@mui/x-data-grid@8.11.1`
|
|
118
|
+
|
|
119
|
+
- [DataGrid] Refine types in `GridCell` component (#19384) @sai6855
|
|
120
|
+
|
|
121
|
+
#### `@mui/x-data-grid-pro@8.11.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
122
|
+
|
|
123
|
+
Same changes as in `@mui/x-data-grid@8.11.1`.
|
|
124
|
+
|
|
125
|
+
#### `@mui/x-data-grid-premium@8.11.1` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
126
|
+
|
|
127
|
+
Same changes as in `@mui/x-data-grid-pro@8.11.1`.
|
|
128
|
+
|
|
129
|
+
### Date and Time Pickers
|
|
130
|
+
|
|
131
|
+
#### `@mui/x-date-pickers@8.11.1`
|
|
132
|
+
|
|
133
|
+
- [pickers] Merge `slotProps` for input adornment in `PickerFieldUI` component (#19399) @sai6855
|
|
134
|
+
|
|
135
|
+
#### `@mui/x-date-pickers-pro@8.11.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
136
|
+
|
|
137
|
+
Same changes as in `@mui/x-date-pickers@8.11.1`.
|
|
138
|
+
|
|
139
|
+
### Charts
|
|
140
|
+
|
|
141
|
+
#### `@mui/x-charts@8.11.1`
|
|
142
|
+
|
|
143
|
+
- [charts] Prevent crash and warn user on incorrect `axisId` when composing (#19397) @JCQuintas
|
|
144
|
+
|
|
145
|
+
#### `@mui/x-charts-pro@8.11.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
146
|
+
|
|
147
|
+
Same changes as in `@mui/x-charts@8.11.1`.
|
|
148
|
+
|
|
149
|
+
### Tree View
|
|
150
|
+
|
|
151
|
+
#### `@mui/x-tree-view@8.11.1`
|
|
152
|
+
|
|
153
|
+
- [tree view] Expose the methods to manually refetch the children of an item (#19248) @flaviendelangle
|
|
154
|
+
- [tree view] Use the shared store implementation instead of the custom one (#19261) @flaviendelangle
|
|
155
|
+
|
|
156
|
+
#### `@mui/x-tree-view-pro@8.11.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
157
|
+
|
|
158
|
+
Same changes as in `@mui/x-tree-view@8.11.1`.
|
|
159
|
+
|
|
160
|
+
### Codemod
|
|
161
|
+
|
|
162
|
+
#### `@mui/x-codemod@8.11.1`
|
|
163
|
+
|
|
164
|
+
Internal changes.
|
|
165
|
+
|
|
166
|
+
### Docs
|
|
167
|
+
|
|
168
|
+
- [docs] Fix grammar and spelling mistakes on the Date and Time Pickers pages (#19300) @mapache-salvaje
|
|
169
|
+
- [docs] Remove wrong legend info (#19383) @JCQuintas
|
|
170
|
+
|
|
171
|
+
### Core
|
|
172
|
+
|
|
173
|
+
- [internal] Fix action alert (#19388) @oliviertassinari
|
|
174
|
+
- [internal] Fix pnpm valelint to have 0 errors @oliviertassinari
|
|
175
|
+
- [infra] Remove "main" fields from publishable packages (#19407) @brijeshb42
|
|
176
|
+
|
|
8
177
|
## 8.11.0
|
|
9
178
|
|
|
10
179
|
_Aug 29, 2025_
|
|
@@ -337,6 +337,7 @@ const DateCalendar = exports.DateCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
337
337
|
yearsPerRow: yearsPerRow,
|
|
338
338
|
referenceDate: referenceDate
|
|
339
339
|
})), view === 'month' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_MonthCalendar.MonthCalendar, (0, _extends2.default)({}, baseDateValidationProps, commonViewProps, {
|
|
340
|
+
currentMonth: calendarState.currentMonth,
|
|
340
341
|
hasFocus: hasFocus,
|
|
341
342
|
className: className,
|
|
342
343
|
value: value,
|
|
@@ -31,7 +31,7 @@ var _usePickerPrivateContext = require("../internals/hooks/usePickerPrivateConte
|
|
|
31
31
|
var _useDateManager = require("../managers/useDateManager");
|
|
32
32
|
var _usePickerAdapter = require("../hooks/usePickerAdapter");
|
|
33
33
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
34
|
-
const _excluded = ["autoFocus", "className", "classes", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
|
|
34
|
+
const _excluded = ["autoFocus", "className", "currentMonth", "classes", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
|
|
35
35
|
const useUtilityClasses = classes => {
|
|
36
36
|
const slots = {
|
|
37
37
|
root: ['root']
|
|
@@ -48,6 +48,7 @@ function useMonthCalendarDefaultizedProps(props, name) {
|
|
|
48
48
|
monthsPerRow: themeProps.monthsPerRow ?? 3
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
const isSameMonth = (monthA, monthB, yearA, yearB, adapter) => Boolean(monthA === monthB && yearB && adapter.isSameYear(yearA, yearB));
|
|
51
52
|
const MonthCalendarRoot = (0, _styles.styled)('div', {
|
|
52
53
|
name: 'MuiMonthCalendar',
|
|
53
54
|
slot: 'Root',
|
|
@@ -91,6 +92,7 @@ const MonthCalendar = exports.MonthCalendar = /*#__PURE__*/React.forwardRef(func
|
|
|
91
92
|
const {
|
|
92
93
|
autoFocus,
|
|
93
94
|
className,
|
|
95
|
+
currentMonth,
|
|
94
96
|
classes: classesProp,
|
|
95
97
|
value: valueProp,
|
|
96
98
|
defaultValue,
|
|
@@ -181,11 +183,12 @@ const MonthCalendar = exports.MonthCalendar = /*#__PURE__*/React.forwardRef(func
|
|
|
181
183
|
if (readOnly) {
|
|
182
184
|
return;
|
|
183
185
|
}
|
|
184
|
-
const
|
|
186
|
+
const currentValue = value && currentMonth && !adapter.isSameYear(value, currentMonth) ? adapter.setYear(value, adapter.getYear(currentMonth)) : value;
|
|
187
|
+
const newDate = adapter.setMonth(currentValue ?? referenceDate, month);
|
|
185
188
|
handleValueChange(newDate);
|
|
186
189
|
});
|
|
187
190
|
const focusMonth = (0, _useEventCallback.default)(month => {
|
|
188
|
-
if (!isMonthDisabled(adapter.setMonth(value ?? referenceDate, month))) {
|
|
191
|
+
if (!isMonthDisabled(adapter.setMonth(value ?? currentMonth ?? referenceDate, month))) {
|
|
189
192
|
setFocusedMonth(month);
|
|
190
193
|
changeHasFocus(true);
|
|
191
194
|
if (onMonthFocus) {
|
|
@@ -236,11 +239,11 @@ const MonthCalendar = exports.MonthCalendar = /*#__PURE__*/React.forwardRef(func
|
|
|
236
239
|
"aria-labelledby": gridLabelId,
|
|
237
240
|
monthsPerRow: monthsPerRow
|
|
238
241
|
}, other, {
|
|
239
|
-
children: (0, _dateUtils.getMonthsInYear)(adapter, value ?? referenceDate).map(month => {
|
|
242
|
+
children: (0, _dateUtils.getMonthsInYear)(adapter, currentMonth ?? value ?? referenceDate).map(month => {
|
|
240
243
|
const monthNumber = adapter.getMonth(month);
|
|
241
244
|
const monthText = adapter.format(month, 'monthShort');
|
|
242
245
|
const monthLabel = adapter.format(month, 'month');
|
|
243
|
-
const isSelected = monthNumber
|
|
246
|
+
const isSelected = isSameMonth(monthNumber, selectedMonth, month, value, adapter);
|
|
244
247
|
const isDisabled = disabled || isMonthDisabled(month);
|
|
245
248
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MonthCalendarButton.MonthCalendarButton, {
|
|
246
249
|
selected: isSelected,
|
|
@@ -252,7 +255,7 @@ const MonthCalendar = exports.MonthCalendar = /*#__PURE__*/React.forwardRef(func
|
|
|
252
255
|
tabIndex: monthNumber === focusedMonth && !isDisabled ? 0 : -1,
|
|
253
256
|
onFocus: handleMonthFocus,
|
|
254
257
|
onBlur: handleMonthBlur,
|
|
255
|
-
"aria-current": todayMonth
|
|
258
|
+
"aria-current": isSameMonth(monthNumber, todayMonth, month, now, adapter) ? 'date' : undefined,
|
|
256
259
|
"aria-label": monthLabel,
|
|
257
260
|
slots: slots,
|
|
258
261
|
slotProps: slotProps,
|
|
@@ -274,6 +277,7 @@ process.env.NODE_ENV !== "production" ? MonthCalendar.propTypes = {
|
|
|
274
277
|
*/
|
|
275
278
|
classes: _propTypes.default.object,
|
|
276
279
|
className: _propTypes.default.string,
|
|
280
|
+
currentMonth: _propTypes.default.object,
|
|
277
281
|
/**
|
|
278
282
|
* The default selected value.
|
|
279
283
|
* Used when the component is not controlled.
|
|
@@ -32,6 +32,7 @@ export interface ExportedMonthCalendarProps {
|
|
|
32
32
|
export interface MonthCalendarProps extends ExportedMonthCalendarProps, MonthValidationProps, BaseDateValidationProps, TimezoneProps, FormProps {
|
|
33
33
|
autoFocus?: boolean;
|
|
34
34
|
className?: string;
|
|
35
|
+
currentMonth?: PickerValidDate;
|
|
35
36
|
/**
|
|
36
37
|
* Override or extend the styles applied to the component.
|
|
37
38
|
*/
|
|
@@ -55,12 +55,6 @@ const MultiSectionDigitalClockSectionRoot = (0, _styles.styled)(_MenuList.defaul
|
|
|
55
55
|
'&:not(:first-of-type)': {
|
|
56
56
|
borderLeft: `1px solid ${(theme.vars || theme).palette.divider}`
|
|
57
57
|
},
|
|
58
|
-
'&::after': {
|
|
59
|
-
display: 'block',
|
|
60
|
-
content: '""',
|
|
61
|
-
// subtracting the height of one item, extra margin and borders to make sure the max height is correct
|
|
62
|
-
height: 'calc(100% - 40px - 6px)'
|
|
63
|
-
},
|
|
64
58
|
variants: [{
|
|
65
59
|
props: {
|
|
66
60
|
hasDigitalClockAlreadyBeenRendered: true
|
|
@@ -145,9 +139,21 @@ const MultiSectionDigitalClockSection = exports.MultiSectionDigitalClockSection
|
|
|
145
139
|
}
|
|
146
140
|
previousActive.current = activeItem;
|
|
147
141
|
const offsetTop = activeItem.offsetTop;
|
|
142
|
+
const itemHeight = activeItem.offsetHeight;
|
|
143
|
+
const containerHeight = containerRef.current.clientHeight;
|
|
144
|
+
const scrollableHeight = containerRef.current.scrollHeight;
|
|
145
|
+
|
|
146
|
+
// Calculate the ideal centered position
|
|
147
|
+
const centeredPosition = offsetTop - containerHeight / 2 + itemHeight / 2;
|
|
148
|
+
|
|
149
|
+
// Calculate the maximum scroll position that would show content at the bottom
|
|
150
|
+
const maxScrollTop = scrollableHeight - containerHeight;
|
|
151
|
+
|
|
152
|
+
// If centering would create empty space at the bottom, align the last items to the bottom instead
|
|
153
|
+
const scrollPosition = Math.min(centeredPosition, maxScrollTop);
|
|
148
154
|
|
|
149
|
-
//
|
|
150
|
-
containerRef.current.scrollTop =
|
|
155
|
+
// Ensure we don't scroll past the top
|
|
156
|
+
containerRef.current.scrollTop = Math.max(0, scrollPosition);
|
|
151
157
|
});
|
|
152
158
|
const focusedOptionIndex = items.findIndex(item => item.isFocused(item.value));
|
|
153
159
|
const handleKeyDown = event => {
|
|
@@ -330,6 +330,7 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
330
330
|
yearsPerRow: yearsPerRow,
|
|
331
331
|
referenceDate: referenceDate
|
|
332
332
|
})), view === 'month' && /*#__PURE__*/_jsx(MonthCalendar, _extends({}, baseDateValidationProps, commonViewProps, {
|
|
333
|
+
currentMonth: calendarState.currentMonth,
|
|
333
334
|
hasFocus: hasFocus,
|
|
334
335
|
className: className,
|
|
335
336
|
value: value,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
const _excluded = ["autoFocus", "className", "classes", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
|
|
5
|
+
const _excluded = ["autoFocus", "className", "currentMonth", "classes", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "shouldDisableMonth", "readOnly", "disableHighlightToday", "onMonthFocus", "hasFocus", "onFocusedViewChange", "monthsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import clsx from 'clsx';
|
|
@@ -40,6 +40,7 @@ export function useMonthCalendarDefaultizedProps(props, name) {
|
|
|
40
40
|
monthsPerRow: themeProps.monthsPerRow ?? 3
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
+
const isSameMonth = (monthA, monthB, yearA, yearB, adapter) => Boolean(monthA === monthB && yearB && adapter.isSameYear(yearA, yearB));
|
|
43
44
|
const MonthCalendarRoot = styled('div', {
|
|
44
45
|
name: 'MuiMonthCalendar',
|
|
45
46
|
slot: 'Root',
|
|
@@ -83,6 +84,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
83
84
|
const {
|
|
84
85
|
autoFocus,
|
|
85
86
|
className,
|
|
87
|
+
currentMonth,
|
|
86
88
|
classes: classesProp,
|
|
87
89
|
value: valueProp,
|
|
88
90
|
defaultValue,
|
|
@@ -173,11 +175,12 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
173
175
|
if (readOnly) {
|
|
174
176
|
return;
|
|
175
177
|
}
|
|
176
|
-
const
|
|
178
|
+
const currentValue = value && currentMonth && !adapter.isSameYear(value, currentMonth) ? adapter.setYear(value, adapter.getYear(currentMonth)) : value;
|
|
179
|
+
const newDate = adapter.setMonth(currentValue ?? referenceDate, month);
|
|
177
180
|
handleValueChange(newDate);
|
|
178
181
|
});
|
|
179
182
|
const focusMonth = useEventCallback(month => {
|
|
180
|
-
if (!isMonthDisabled(adapter.setMonth(value ?? referenceDate, month))) {
|
|
183
|
+
if (!isMonthDisabled(adapter.setMonth(value ?? currentMonth ?? referenceDate, month))) {
|
|
181
184
|
setFocusedMonth(month);
|
|
182
185
|
changeHasFocus(true);
|
|
183
186
|
if (onMonthFocus) {
|
|
@@ -228,11 +231,11 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
228
231
|
"aria-labelledby": gridLabelId,
|
|
229
232
|
monthsPerRow: monthsPerRow
|
|
230
233
|
}, other, {
|
|
231
|
-
children: getMonthsInYear(adapter, value ?? referenceDate).map(month => {
|
|
234
|
+
children: getMonthsInYear(adapter, currentMonth ?? value ?? referenceDate).map(month => {
|
|
232
235
|
const monthNumber = adapter.getMonth(month);
|
|
233
236
|
const monthText = adapter.format(month, 'monthShort');
|
|
234
237
|
const monthLabel = adapter.format(month, 'month');
|
|
235
|
-
const isSelected = monthNumber
|
|
238
|
+
const isSelected = isSameMonth(monthNumber, selectedMonth, month, value, adapter);
|
|
236
239
|
const isDisabled = disabled || isMonthDisabled(month);
|
|
237
240
|
return /*#__PURE__*/_jsx(MonthCalendarButton, {
|
|
238
241
|
selected: isSelected,
|
|
@@ -244,7 +247,7 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
244
247
|
tabIndex: monthNumber === focusedMonth && !isDisabled ? 0 : -1,
|
|
245
248
|
onFocus: handleMonthFocus,
|
|
246
249
|
onBlur: handleMonthBlur,
|
|
247
|
-
"aria-current": todayMonth
|
|
250
|
+
"aria-current": isSameMonth(monthNumber, todayMonth, month, now, adapter) ? 'date' : undefined,
|
|
248
251
|
"aria-label": monthLabel,
|
|
249
252
|
slots: slots,
|
|
250
253
|
slotProps: slotProps,
|
|
@@ -266,6 +269,7 @@ process.env.NODE_ENV !== "production" ? MonthCalendar.propTypes = {
|
|
|
266
269
|
*/
|
|
267
270
|
classes: PropTypes.object,
|
|
268
271
|
className: PropTypes.string,
|
|
272
|
+
currentMonth: PropTypes.object,
|
|
269
273
|
/**
|
|
270
274
|
* The default selected value.
|
|
271
275
|
* Used when the component is not controlled.
|
|
@@ -32,6 +32,7 @@ export interface ExportedMonthCalendarProps {
|
|
|
32
32
|
export interface MonthCalendarProps extends ExportedMonthCalendarProps, MonthValidationProps, BaseDateValidationProps, TimezoneProps, FormProps {
|
|
33
33
|
autoFocus?: boolean;
|
|
34
34
|
className?: string;
|
|
35
|
+
currentMonth?: PickerValidDate;
|
|
35
36
|
/**
|
|
36
37
|
* Override or extend the styles applied to the component.
|
|
37
38
|
*/
|
|
@@ -48,12 +48,6 @@ const MultiSectionDigitalClockSectionRoot = styled(MenuList, {
|
|
|
48
48
|
'&:not(:first-of-type)': {
|
|
49
49
|
borderLeft: `1px solid ${(theme.vars || theme).palette.divider}`
|
|
50
50
|
},
|
|
51
|
-
'&::after': {
|
|
52
|
-
display: 'block',
|
|
53
|
-
content: '""',
|
|
54
|
-
// subtracting the height of one item, extra margin and borders to make sure the max height is correct
|
|
55
|
-
height: 'calc(100% - 40px - 6px)'
|
|
56
|
-
},
|
|
57
51
|
variants: [{
|
|
58
52
|
props: {
|
|
59
53
|
hasDigitalClockAlreadyBeenRendered: true
|
|
@@ -138,9 +132,21 @@ export const MultiSectionDigitalClockSection = /*#__PURE__*/React.forwardRef(fun
|
|
|
138
132
|
}
|
|
139
133
|
previousActive.current = activeItem;
|
|
140
134
|
const offsetTop = activeItem.offsetTop;
|
|
135
|
+
const itemHeight = activeItem.offsetHeight;
|
|
136
|
+
const containerHeight = containerRef.current.clientHeight;
|
|
137
|
+
const scrollableHeight = containerRef.current.scrollHeight;
|
|
138
|
+
|
|
139
|
+
// Calculate the ideal centered position
|
|
140
|
+
const centeredPosition = offsetTop - containerHeight / 2 + itemHeight / 2;
|
|
141
|
+
|
|
142
|
+
// Calculate the maximum scroll position that would show content at the bottom
|
|
143
|
+
const maxScrollTop = scrollableHeight - containerHeight;
|
|
144
|
+
|
|
145
|
+
// If centering would create empty space at the bottom, align the last items to the bottom instead
|
|
146
|
+
const scrollPosition = Math.min(centeredPosition, maxScrollTop);
|
|
141
147
|
|
|
142
|
-
//
|
|
143
|
-
containerRef.current.scrollTop =
|
|
148
|
+
// Ensure we don't scroll past the top
|
|
149
|
+
containerRef.current.scrollTop = Math.max(0, scrollPosition);
|
|
144
150
|
});
|
|
145
151
|
const focusedOptionIndex = items.findIndex(item => item.isFocused(item.value));
|
|
146
152
|
const handleKeyDown = event => {
|
package/esm/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import resolveComponentProps from '@mui/utils/resolveComponentProps';
|
|
|
17
17
|
import MuiTextField from '@mui/material/TextField';
|
|
18
18
|
import MuiIconButton from '@mui/material/IconButton';
|
|
19
19
|
import MuiInputAdornment from '@mui/material/InputAdornment';
|
|
20
|
+
import { major as materialMajor } from '@mui/material/version';
|
|
20
21
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
21
22
|
import { useFieldOwnerState } from "../hooks/useFieldOwnerState.js";
|
|
22
23
|
import { usePickerTranslations } from "../../hooks/index.js";
|
|
@@ -24,6 +25,7 @@ import { ClearIcon as MuiClearIcon } from "../../icons/index.js";
|
|
|
24
25
|
import { useNullablePickerContext } from "../hooks/useNullablePickerContext.js";
|
|
25
26
|
import { PickersTextField } from "../../PickersTextField/index.js";
|
|
26
27
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
const noop = () => {};
|
|
27
29
|
export const cleanFieldResponse = _ref => {
|
|
28
30
|
let {
|
|
29
31
|
enableAccessibleFieldDOMStructure
|
|
@@ -40,13 +42,20 @@ export const cleanFieldResponse = _ref => {
|
|
|
40
42
|
openPickerAriaLabel
|
|
41
43
|
} = fieldResponse,
|
|
42
44
|
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded2);
|
|
45
|
+
const mergedInputProps = materialMajor >= 6 && other?.slotProps?.input ? mergeSlotProps(other?.slotProps?.input, InputProps) : noop;
|
|
43
46
|
return {
|
|
44
47
|
clearable,
|
|
45
48
|
onClear,
|
|
46
49
|
clearButtonPosition,
|
|
47
50
|
openPickerButtonPosition,
|
|
48
51
|
openPickerAriaLabel,
|
|
49
|
-
textFieldProps: _extends({}, other, {
|
|
52
|
+
textFieldProps: _extends({}, other, materialMajor >= 6 && other?.slotProps?.input ? {
|
|
53
|
+
slotProps: _extends({}, other?.slotProps, {
|
|
54
|
+
input: ownerState => _extends({}, resolveComponentProps(mergedInputProps, ownerState), {
|
|
55
|
+
readOnly
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
} : {
|
|
50
59
|
InputProps: _extends({}, InputProps ?? {}, {
|
|
51
60
|
readOnly
|
|
52
61
|
})
|
|
@@ -68,13 +77,27 @@ export const cleanFieldResponse = _ref => {
|
|
|
68
77
|
openPickerAriaLabel
|
|
69
78
|
} = fieldResponse,
|
|
70
79
|
other = _objectWithoutPropertiesLoose(fieldResponse, _excluded3);
|
|
80
|
+
const mergedInputProps = materialMajor >= 6 && other?.slotProps?.input ? mergeSlotProps(other?.slotProps?.input, InputProps) : noop;
|
|
81
|
+
const mergedHtmlInputProps = materialMajor >= 6 && other?.slotProps?.htmlInput ? mergeSlotProps(other?.slotProps?.htmlInput, inputProps) : noop;
|
|
71
82
|
return {
|
|
72
83
|
clearable,
|
|
73
84
|
onClear,
|
|
74
85
|
clearButtonPosition,
|
|
75
86
|
openPickerButtonPosition,
|
|
76
87
|
openPickerAriaLabel,
|
|
77
|
-
textFieldProps: _extends({}, other, {
|
|
88
|
+
textFieldProps: _extends({}, other, materialMajor >= 6 && (other?.slotProps?.input || other?.slotProps?.htmlInput) ? {
|
|
89
|
+
slotProps: _extends({}, other?.slotProps, {
|
|
90
|
+
input: ownerState => _extends({}, resolveComponentProps(mergedInputProps, ownerState), {
|
|
91
|
+
readOnly
|
|
92
|
+
}),
|
|
93
|
+
htmlInput: ownerState => _extends({}, resolveComponentProps(mergedHtmlInputProps, ownerState), {
|
|
94
|
+
inputMode,
|
|
95
|
+
onPaste,
|
|
96
|
+
onKeyDown,
|
|
97
|
+
ref: inputRef
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
} : {
|
|
78
101
|
InputProps: _extends({}, InputProps ?? {}, {
|
|
79
102
|
readOnly
|
|
80
103
|
}),
|
|
@@ -139,7 +162,7 @@ export function PickerFieldUI(props) {
|
|
|
139
162
|
startInputAdornmentProps = _objectWithoutPropertiesLoose(_useSlotProps, _excluded4);
|
|
140
163
|
const _useSlotProps2 = useSlotProps({
|
|
141
164
|
elementType: InputAdornment,
|
|
142
|
-
externalSlotProps: slotProps?.inputAdornment,
|
|
165
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.inputAdornment, slotProps?.inputAdornment),
|
|
143
166
|
additionalProps: {
|
|
144
167
|
position: 'end'
|
|
145
168
|
},
|
|
@@ -198,14 +221,13 @@ export function PickerFieldUI(props) {
|
|
|
198
221
|
ownerState
|
|
199
222
|
});
|
|
200
223
|
textFieldProps.ref = useForkRef(textFieldProps.ref, pickerContext?.rootRef);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
224
|
+
const additionalTextFieldInputProps = {};
|
|
225
|
+
const textFieldInputProps = resolveComponentProps((materialMajor >= 6 && textFieldProps?.slotProps?.input) ?? textFieldProps.InputProps, ownerState);
|
|
204
226
|
if (pickerContext) {
|
|
205
|
-
|
|
227
|
+
additionalTextFieldInputProps.ref = pickerContext.triggerRef;
|
|
206
228
|
}
|
|
207
|
-
if (!
|
|
208
|
-
|
|
229
|
+
if (!textFieldInputProps?.startAdornment && (clearButtonPosition === 'start' || openPickerButtonPosition === 'start')) {
|
|
230
|
+
additionalTextFieldInputProps.startAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, startInputAdornmentProps, {
|
|
209
231
|
children: [openPickerButtonPosition === 'start' && /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
210
232
|
children: /*#__PURE__*/_jsx(OpenPickerIcon, _extends({}, openPickerIconProps))
|
|
211
233
|
})), clearButtonPosition === 'start' && /*#__PURE__*/_jsx(ClearButton, _extends({}, clearButtonProps, {
|
|
@@ -213,8 +235,8 @@ export function PickerFieldUI(props) {
|
|
|
213
235
|
}))]
|
|
214
236
|
}));
|
|
215
237
|
}
|
|
216
|
-
if (!
|
|
217
|
-
|
|
238
|
+
if (!textFieldInputProps?.endAdornment && (clearButtonPosition === 'end' || openPickerButtonPosition === 'end')) {
|
|
239
|
+
additionalTextFieldInputProps.endAdornment = /*#__PURE__*/_jsxs(InputAdornment, _extends({}, endInputAdornmentProps, {
|
|
218
240
|
children: [clearButtonPosition === 'end' && /*#__PURE__*/_jsx(ClearButton, _extends({}, clearButtonProps, {
|
|
219
241
|
children: /*#__PURE__*/_jsx(ClearIcon, _extends({}, clearIconProps))
|
|
220
242
|
})), openPickerButtonPosition === 'end' && /*#__PURE__*/_jsx(OpenPickerButton, _extends({}, openPickerButtonProps, {
|
|
@@ -239,7 +261,18 @@ export function PickerFieldUI(props) {
|
|
|
239
261
|
}
|
|
240
262
|
}, ...(Array.isArray(textFieldProps.sx) ? textFieldProps.sx : [textFieldProps.sx])];
|
|
241
263
|
}
|
|
242
|
-
|
|
264
|
+
const resolvedTextFieldInputProps = materialMajor >= 6 && textFieldProps?.slotProps?.input ? resolveComponentProps(mergeSlotProps(textFieldInputProps, additionalTextFieldInputProps), ownerState) : _extends({}, textFieldInputProps, additionalTextFieldInputProps);
|
|
265
|
+
|
|
266
|
+
// Remove the `input` slotProps to avoid them overriding the manually resolved `InputProps`.
|
|
267
|
+
// Relevant on `materialMajor >= 6` since `slotProps` would take precedence.
|
|
268
|
+
delete textFieldProps?.slotProps?.input;
|
|
269
|
+
if (fieldResponse.enableAccessibleFieldDOMStructure) {
|
|
270
|
+
// Remove the `slotProps` on `PickersTextField` as they are not supported.
|
|
271
|
+
delete textFieldProps?.slotProps;
|
|
272
|
+
}
|
|
273
|
+
return /*#__PURE__*/_jsx(TextField, _extends({}, textFieldProps, {
|
|
274
|
+
InputProps: resolvedTextFieldInputProps
|
|
275
|
+
}));
|
|
243
276
|
}
|
|
244
277
|
export function mergeSlotProps(slotPropsA, slotPropsB) {
|
|
245
278
|
if (!slotPropsA) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
3
|
-
import useId from '@mui/utils/useId';
|
|
4
3
|
import { usePickerAdapter, usePickerTranslations } from "../../../hooks/index.js";
|
|
5
4
|
import { syncSelectionToDOM } from "./syncSelectionToDOM.js";
|
|
6
5
|
/**
|
|
@@ -13,7 +12,6 @@ import { syncSelectionToDOM } from "./syncSelectionToDOM.js";
|
|
|
13
12
|
export function useFieldSectionContentProps(parameters) {
|
|
14
13
|
const adapter = usePickerAdapter();
|
|
15
14
|
const translations = usePickerTranslations();
|
|
16
|
-
const id = useId();
|
|
17
15
|
const {
|
|
18
16
|
focused,
|
|
19
17
|
domGetters,
|
|
@@ -147,7 +145,6 @@ export function useFieldSectionContentProps(parameters) {
|
|
|
147
145
|
onDragOver: handleDragOver,
|
|
148
146
|
onFocus: createFocusHandler(sectionIndex),
|
|
149
147
|
// Aria attributes
|
|
150
|
-
'aria-labelledby': `${id}-${section.type}`,
|
|
151
148
|
'aria-readonly': readOnly,
|
|
152
149
|
'aria-valuenow': getSectionValueNow(section, adapter),
|
|
153
150
|
'aria-valuemin': sectionBoundaries.minimum,
|
|
@@ -159,7 +156,6 @@ export function useFieldSectionContentProps(parameters) {
|
|
|
159
156
|
tabIndex: isContainerEditable || sectionIndex > 0 ? -1 : 0,
|
|
160
157
|
contentEditable: !isContainerEditable && !disabled && !readOnly,
|
|
161
158
|
role: 'spinbutton',
|
|
162
|
-
id: `${id}-${section.type}`,
|
|
163
159
|
'data-range-position': section.dateName || undefined,
|
|
164
160
|
spellCheck: isEditable ? false : undefined,
|
|
165
161
|
autoCapitalize: isEditable ? 'off' : undefined,
|
|
@@ -167,7 +163,7 @@ export function useFieldSectionContentProps(parameters) {
|
|
|
167
163
|
children: section.value || section.placeholder,
|
|
168
164
|
inputMode: section.contentType === 'letter' ? 'text' : 'numeric'
|
|
169
165
|
};
|
|
170
|
-
}, [sectionsValueBoundaries,
|
|
166
|
+
}, [sectionsValueBoundaries, isContainerEditable, disabled, readOnly, isEditable, translations, adapter, handleInput, handlePaste, handleMouseUp, handleDragOver, createFocusHandler, fieldValueManager, value]);
|
|
171
167
|
}
|
|
172
168
|
function getSectionValueText(section, adapter) {
|
|
173
169
|
if (!section.value) {
|
|
@@ -177,13 +173,18 @@ function getSectionValueText(section, adapter) {
|
|
|
177
173
|
case 'month':
|
|
178
174
|
{
|
|
179
175
|
if (section.contentType === 'digit') {
|
|
180
|
-
|
|
176
|
+
const dateWithMonth = adapter.setMonth(adapter.date(), Number(section.value) - 1);
|
|
177
|
+
return adapter.isValid(dateWithMonth) ? adapter.format(dateWithMonth, 'month') : '';
|
|
181
178
|
}
|
|
182
179
|
const parsedDate = adapter.parse(section.value, section.format);
|
|
183
|
-
return parsedDate ? adapter.format(parsedDate, 'month') : undefined;
|
|
180
|
+
return parsedDate && adapter.isValid(parsedDate) ? adapter.format(parsedDate, 'month') : undefined;
|
|
184
181
|
}
|
|
185
182
|
case 'day':
|
|
186
|
-
|
|
183
|
+
if (section.contentType === 'digit') {
|
|
184
|
+
const dateWithDay = adapter.setDate(adapter.startOfYear(adapter.date()), Number(section.value));
|
|
185
|
+
return adapter.isValid(dateWithDay) ? adapter.format(dateWithDay, 'dayOfMonthFull') : '';
|
|
186
|
+
}
|
|
187
|
+
return section.value;
|
|
187
188
|
case 'weekDay':
|
|
188
189
|
// TODO: improve by providing the label of the week day
|
|
189
190
|
return undefined;
|
package/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var _resolveComponentProps = _interopRequireDefault(require("@mui/utils/resolveC
|
|
|
21
21
|
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
22
22
|
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
23
23
|
var _InputAdornment = _interopRequireDefault(require("@mui/material/InputAdornment"));
|
|
24
|
+
var _version = require("@mui/material/version");
|
|
24
25
|
var _useSlotProps5 = _interopRequireDefault(require("@mui/utils/useSlotProps"));
|
|
25
26
|
var _useFieldOwnerState = require("../hooks/useFieldOwnerState");
|
|
26
27
|
var _hooks = require("../../hooks");
|
|
@@ -36,6 +37,7 @@ const _excluded = ["enableAccessibleFieldDOMStructure"],
|
|
|
36
37
|
_excluded6 = ["ownerState"],
|
|
37
38
|
_excluded7 = ["ownerState"],
|
|
38
39
|
_excluded8 = ["InputProps", "inputProps"];
|
|
40
|
+
const noop = () => {};
|
|
39
41
|
const cleanFieldResponse = _ref => {
|
|
40
42
|
let {
|
|
41
43
|
enableAccessibleFieldDOMStructure
|
|
@@ -52,13 +54,20 @@ const cleanFieldResponse = _ref => {
|
|
|
52
54
|
openPickerAriaLabel
|
|
53
55
|
} = fieldResponse,
|
|
54
56
|
other = (0, _objectWithoutPropertiesLoose2.default)(fieldResponse, _excluded2);
|
|
57
|
+
const mergedInputProps = _version.major >= 6 && other?.slotProps?.input ? mergeSlotProps(other?.slotProps?.input, InputProps) : noop;
|
|
55
58
|
return {
|
|
56
59
|
clearable,
|
|
57
60
|
onClear,
|
|
58
61
|
clearButtonPosition,
|
|
59
62
|
openPickerButtonPosition,
|
|
60
63
|
openPickerAriaLabel,
|
|
61
|
-
textFieldProps: (0, _extends2.default)({}, other, {
|
|
64
|
+
textFieldProps: (0, _extends2.default)({}, other, _version.major >= 6 && other?.slotProps?.input ? {
|
|
65
|
+
slotProps: (0, _extends2.default)({}, other?.slotProps, {
|
|
66
|
+
input: ownerState => (0, _extends2.default)({}, (0, _resolveComponentProps.default)(mergedInputProps, ownerState), {
|
|
67
|
+
readOnly
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
} : {
|
|
62
71
|
InputProps: (0, _extends2.default)({}, InputProps ?? {}, {
|
|
63
72
|
readOnly
|
|
64
73
|
})
|
|
@@ -80,13 +89,27 @@ const cleanFieldResponse = _ref => {
|
|
|
80
89
|
openPickerAriaLabel
|
|
81
90
|
} = fieldResponse,
|
|
82
91
|
other = (0, _objectWithoutPropertiesLoose2.default)(fieldResponse, _excluded3);
|
|
92
|
+
const mergedInputProps = _version.major >= 6 && other?.slotProps?.input ? mergeSlotProps(other?.slotProps?.input, InputProps) : noop;
|
|
93
|
+
const mergedHtmlInputProps = _version.major >= 6 && other?.slotProps?.htmlInput ? mergeSlotProps(other?.slotProps?.htmlInput, inputProps) : noop;
|
|
83
94
|
return {
|
|
84
95
|
clearable,
|
|
85
96
|
onClear,
|
|
86
97
|
clearButtonPosition,
|
|
87
98
|
openPickerButtonPosition,
|
|
88
99
|
openPickerAriaLabel,
|
|
89
|
-
textFieldProps: (0, _extends2.default)({}, other, {
|
|
100
|
+
textFieldProps: (0, _extends2.default)({}, other, _version.major >= 6 && (other?.slotProps?.input || other?.slotProps?.htmlInput) ? {
|
|
101
|
+
slotProps: (0, _extends2.default)({}, other?.slotProps, {
|
|
102
|
+
input: ownerState => (0, _extends2.default)({}, (0, _resolveComponentProps.default)(mergedInputProps, ownerState), {
|
|
103
|
+
readOnly
|
|
104
|
+
}),
|
|
105
|
+
htmlInput: ownerState => (0, _extends2.default)({}, (0, _resolveComponentProps.default)(mergedHtmlInputProps, ownerState), {
|
|
106
|
+
inputMode,
|
|
107
|
+
onPaste,
|
|
108
|
+
onKeyDown,
|
|
109
|
+
ref: inputRef
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
} : {
|
|
90
113
|
InputProps: (0, _extends2.default)({}, InputProps ?? {}, {
|
|
91
114
|
readOnly
|
|
92
115
|
}),
|
|
@@ -152,7 +175,7 @@ function PickerFieldUI(props) {
|
|
|
152
175
|
startInputAdornmentProps = (0, _objectWithoutPropertiesLoose2.default)(_useSlotProps, _excluded4);
|
|
153
176
|
const _useSlotProps2 = (0, _useSlotProps5.default)({
|
|
154
177
|
elementType: InputAdornment,
|
|
155
|
-
externalSlotProps: slotProps?.inputAdornment,
|
|
178
|
+
externalSlotProps: mergeSlotProps(pickerFieldUIContext.slotProps.inputAdornment, slotProps?.inputAdornment),
|
|
156
179
|
additionalProps: {
|
|
157
180
|
position: 'end'
|
|
158
181
|
},
|
|
@@ -211,14 +234,13 @@ function PickerFieldUI(props) {
|
|
|
211
234
|
ownerState
|
|
212
235
|
});
|
|
213
236
|
textFieldProps.ref = (0, _useForkRef.default)(textFieldProps.ref, pickerContext?.rootRef);
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
237
|
+
const additionalTextFieldInputProps = {};
|
|
238
|
+
const textFieldInputProps = (0, _resolveComponentProps.default)((_version.major >= 6 && textFieldProps?.slotProps?.input) ?? textFieldProps.InputProps, ownerState);
|
|
217
239
|
if (pickerContext) {
|
|
218
|
-
|
|
240
|
+
additionalTextFieldInputProps.ref = pickerContext.triggerRef;
|
|
219
241
|
}
|
|
220
|
-
if (!
|
|
221
|
-
|
|
242
|
+
if (!textFieldInputProps?.startAdornment && (clearButtonPosition === 'start' || openPickerButtonPosition === 'start')) {
|
|
243
|
+
additionalTextFieldInputProps.startAdornment = /*#__PURE__*/(0, _jsxRuntime.jsxs)(InputAdornment, (0, _extends2.default)({}, startInputAdornmentProps, {
|
|
222
244
|
children: [openPickerButtonPosition === 'start' && /*#__PURE__*/(0, _jsxRuntime.jsx)(OpenPickerButton, (0, _extends2.default)({}, openPickerButtonProps, {
|
|
223
245
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(OpenPickerIcon, (0, _extends2.default)({}, openPickerIconProps))
|
|
224
246
|
})), clearButtonPosition === 'start' && /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearButton, (0, _extends2.default)({}, clearButtonProps, {
|
|
@@ -226,8 +248,8 @@ function PickerFieldUI(props) {
|
|
|
226
248
|
}))]
|
|
227
249
|
}));
|
|
228
250
|
}
|
|
229
|
-
if (!
|
|
230
|
-
|
|
251
|
+
if (!textFieldInputProps?.endAdornment && (clearButtonPosition === 'end' || openPickerButtonPosition === 'end')) {
|
|
252
|
+
additionalTextFieldInputProps.endAdornment = /*#__PURE__*/(0, _jsxRuntime.jsxs)(InputAdornment, (0, _extends2.default)({}, endInputAdornmentProps, {
|
|
231
253
|
children: [clearButtonPosition === 'end' && /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearButton, (0, _extends2.default)({}, clearButtonProps, {
|
|
232
254
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ClearIcon, (0, _extends2.default)({}, clearIconProps))
|
|
233
255
|
})), openPickerButtonPosition === 'end' && /*#__PURE__*/(0, _jsxRuntime.jsx)(OpenPickerButton, (0, _extends2.default)({}, openPickerButtonProps, {
|
|
@@ -252,7 +274,18 @@ function PickerFieldUI(props) {
|
|
|
252
274
|
}
|
|
253
275
|
}, ...(Array.isArray(textFieldProps.sx) ? textFieldProps.sx : [textFieldProps.sx])];
|
|
254
276
|
}
|
|
255
|
-
|
|
277
|
+
const resolvedTextFieldInputProps = _version.major >= 6 && textFieldProps?.slotProps?.input ? (0, _resolveComponentProps.default)(mergeSlotProps(textFieldInputProps, additionalTextFieldInputProps), ownerState) : (0, _extends2.default)({}, textFieldInputProps, additionalTextFieldInputProps);
|
|
278
|
+
|
|
279
|
+
// Remove the `input` slotProps to avoid them overriding the manually resolved `InputProps`.
|
|
280
|
+
// Relevant on `materialMajor >= 6` since `slotProps` would take precedence.
|
|
281
|
+
delete textFieldProps?.slotProps?.input;
|
|
282
|
+
if (fieldResponse.enableAccessibleFieldDOMStructure) {
|
|
283
|
+
// Remove the `slotProps` on `PickersTextField` as they are not supported.
|
|
284
|
+
delete textFieldProps?.slotProps;
|
|
285
|
+
}
|
|
286
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TextField, (0, _extends2.default)({}, textFieldProps, {
|
|
287
|
+
InputProps: resolvedTextFieldInputProps
|
|
288
|
+
}));
|
|
256
289
|
}
|
|
257
290
|
function mergeSlotProps(slotPropsA, slotPropsB) {
|
|
258
291
|
if (!slotPropsA) {
|
|
@@ -8,7 +8,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.useFieldSectionContentProps = useFieldSectionContentProps;
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
11
|
-
var _useId = _interopRequireDefault(require("@mui/utils/useId"));
|
|
12
11
|
var _hooks = require("../../../hooks");
|
|
13
12
|
var _syncSelectionToDOM = require("./syncSelectionToDOM");
|
|
14
13
|
/**
|
|
@@ -21,7 +20,6 @@ var _syncSelectionToDOM = require("./syncSelectionToDOM");
|
|
|
21
20
|
function useFieldSectionContentProps(parameters) {
|
|
22
21
|
const adapter = (0, _hooks.usePickerAdapter)();
|
|
23
22
|
const translations = (0, _hooks.usePickerTranslations)();
|
|
24
|
-
const id = (0, _useId.default)();
|
|
25
23
|
const {
|
|
26
24
|
focused,
|
|
27
25
|
domGetters,
|
|
@@ -155,7 +153,6 @@ function useFieldSectionContentProps(parameters) {
|
|
|
155
153
|
onDragOver: handleDragOver,
|
|
156
154
|
onFocus: createFocusHandler(sectionIndex),
|
|
157
155
|
// Aria attributes
|
|
158
|
-
'aria-labelledby': `${id}-${section.type}`,
|
|
159
156
|
'aria-readonly': readOnly,
|
|
160
157
|
'aria-valuenow': getSectionValueNow(section, adapter),
|
|
161
158
|
'aria-valuemin': sectionBoundaries.minimum,
|
|
@@ -167,7 +164,6 @@ function useFieldSectionContentProps(parameters) {
|
|
|
167
164
|
tabIndex: isContainerEditable || sectionIndex > 0 ? -1 : 0,
|
|
168
165
|
contentEditable: !isContainerEditable && !disabled && !readOnly,
|
|
169
166
|
role: 'spinbutton',
|
|
170
|
-
id: `${id}-${section.type}`,
|
|
171
167
|
'data-range-position': section.dateName || undefined,
|
|
172
168
|
spellCheck: isEditable ? false : undefined,
|
|
173
169
|
autoCapitalize: isEditable ? 'off' : undefined,
|
|
@@ -175,7 +171,7 @@ function useFieldSectionContentProps(parameters) {
|
|
|
175
171
|
children: section.value || section.placeholder,
|
|
176
172
|
inputMode: section.contentType === 'letter' ? 'text' : 'numeric'
|
|
177
173
|
};
|
|
178
|
-
}, [sectionsValueBoundaries,
|
|
174
|
+
}, [sectionsValueBoundaries, isContainerEditable, disabled, readOnly, isEditable, translations, adapter, handleInput, handlePaste, handleMouseUp, handleDragOver, createFocusHandler, fieldValueManager, value]);
|
|
179
175
|
}
|
|
180
176
|
function getSectionValueText(section, adapter) {
|
|
181
177
|
if (!section.value) {
|
|
@@ -185,13 +181,18 @@ function getSectionValueText(section, adapter) {
|
|
|
185
181
|
case 'month':
|
|
186
182
|
{
|
|
187
183
|
if (section.contentType === 'digit') {
|
|
188
|
-
|
|
184
|
+
const dateWithMonth = adapter.setMonth(adapter.date(), Number(section.value) - 1);
|
|
185
|
+
return adapter.isValid(dateWithMonth) ? adapter.format(dateWithMonth, 'month') : '';
|
|
189
186
|
}
|
|
190
187
|
const parsedDate = adapter.parse(section.value, section.format);
|
|
191
|
-
return parsedDate ? adapter.format(parsedDate, 'month') : undefined;
|
|
188
|
+
return parsedDate && adapter.isValid(parsedDate) ? adapter.format(parsedDate, 'month') : undefined;
|
|
192
189
|
}
|
|
193
190
|
case 'day':
|
|
194
|
-
|
|
191
|
+
if (section.contentType === 'digit') {
|
|
192
|
+
const dateWithDay = adapter.setDate(adapter.startOfYear(adapter.date()), Number(section.value));
|
|
193
|
+
return adapter.isValid(dateWithDay) ? adapter.format(dateWithDay, 'dayOfMonthFull') : '';
|
|
194
|
+
}
|
|
195
|
+
return section.value;
|
|
195
196
|
case 'weekDay':
|
|
196
197
|
// TODO: improve by providing the label of the week day
|
|
197
198
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-date-pickers",
|
|
3
|
-
"version": "8.11.
|
|
3
|
+
"version": "8.11.2",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "The community edition of the MUI X Date and Time Picker components.",
|
|
6
|
-
"main": "./index.js",
|
|
7
6
|
"license": "MIT",
|
|
8
7
|
"bugs": {
|
|
9
8
|
"url": "https://github.com/mui/mui-x/issues"
|
|
@@ -35,12 +34,12 @@
|
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
36
|
"@babel/runtime": "^7.28.2",
|
|
38
|
-
"@mui/utils": "^7.3.
|
|
37
|
+
"@mui/utils": "^7.3.2",
|
|
39
38
|
"@types/react-transition-group": "^4.4.12",
|
|
40
39
|
"clsx": "^2.1.1",
|
|
41
40
|
"prop-types": "^15.8.1",
|
|
42
41
|
"react-transition-group": "^4.4.5",
|
|
43
|
-
"@mui/x-internals": "8.11.
|
|
42
|
+
"@mui/x-internals": "8.11.2"
|
|
44
43
|
},
|
|
45
44
|
"peerDependencies": {
|
|
46
45
|
"@emotion/react": "^11.9.0",
|
|
@@ -90,27 +89,28 @@
|
|
|
90
89
|
"node": ">=14.0.0"
|
|
91
90
|
},
|
|
92
91
|
"type": "commonjs",
|
|
92
|
+
"main": "./index.js",
|
|
93
93
|
"types": "./index.d.ts",
|
|
94
94
|
"exports": {
|
|
95
95
|
"./package.json": "./package.json",
|
|
96
96
|
".": {
|
|
97
|
-
"import": {
|
|
98
|
-
"types": "./esm/index.d.ts",
|
|
99
|
-
"default": "./esm/index.js"
|
|
100
|
-
},
|
|
101
97
|
"require": {
|
|
102
98
|
"types": "./index.d.ts",
|
|
103
99
|
"default": "./index.js"
|
|
100
|
+
},
|
|
101
|
+
"default": {
|
|
102
|
+
"types": "./esm/index.d.ts",
|
|
103
|
+
"default": "./esm/index.js"
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
"./*": {
|
|
107
|
-
"import": {
|
|
108
|
-
"types": "./esm/*/index.d.ts",
|
|
109
|
-
"default": "./esm/*/index.js"
|
|
110
|
-
},
|
|
111
107
|
"require": {
|
|
112
108
|
"types": "./*/index.d.ts",
|
|
113
109
|
"default": "./*/index.js"
|
|
110
|
+
},
|
|
111
|
+
"default": {
|
|
112
|
+
"types": "./esm/*/index.d.ts",
|
|
113
|
+
"default": "./esm/*/index.js"
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
"./esm": null
|