@mui/x-date-pickers 7.22.2 → 7.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AdapterMoment/AdapterMoment.js +10 -0
- package/CHANGELOG.md +169 -0
- package/DateCalendar/DateCalendar.js +1 -0
- package/DigitalClock/DigitalClock.js +1 -0
- package/MonthCalendar/MonthCalendar.js +2 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/README.md +3 -3
- package/TimeClock/TimeClock.js +1 -0
- package/YearCalendar/YearCalendar.js +2 -1
- package/index.js +1 -1
- package/internals/components/PickersToolbar.js +2 -4
- package/internals/hooks/useField/useField.utils.js +2 -1
- package/internals/hooks/useField/useFieldState.js +1 -0
- package/internals/hooks/usePicker/usePicker.types.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +16 -4
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +4 -3
- package/internals/hooks/useValueWithTimezone.d.ts +18 -14
- package/internals/hooks/useValueWithTimezone.js +13 -1
- package/locales/nlNL.js +7 -7
- package/modern/AdapterMoment/AdapterMoment.js +10 -0
- package/modern/DateCalendar/DateCalendar.js +1 -0
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/MonthCalendar/MonthCalendar.js +2 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/modern/TimeClock/TimeClock.js +1 -0
- package/modern/YearCalendar/YearCalendar.js +2 -1
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersToolbar.js +2 -4
- package/modern/internals/hooks/useField/useField.utils.js +2 -1
- package/modern/internals/hooks/useField/useFieldState.js +1 -0
- package/modern/internals/hooks/usePicker/usePickerValue.js +16 -4
- package/modern/internals/hooks/useValueWithTimezone.js +13 -1
- package/modern/locales/nlNL.js +7 -7
- package/node/AdapterMoment/AdapterMoment.js +10 -0
- package/node/DateCalendar/DateCalendar.js +1 -0
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/MonthCalendar/MonthCalendar.js +2 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/YearCalendar/YearCalendar.js +2 -1
- package/node/index.js +1 -1
- package/node/internals/components/PickersToolbar.js +2 -4
- package/node/internals/hooks/useField/useField.utils.js +2 -1
- package/node/internals/hooks/useField/useFieldState.js +1 -0
- package/node/internals/hooks/usePicker/usePickerValue.js +16 -4
- package/node/internals/hooks/useValueWithTimezone.js +13 -1
- package/node/locales/nlNL.js +7 -7
- package/package.json +4 -4
|
@@ -430,12 +430,22 @@ export class AdapterMoment {
|
|
|
430
430
|
const end = this.endOfWeek(this.endOfMonth(value));
|
|
431
431
|
let count = 0;
|
|
432
432
|
let current = start;
|
|
433
|
+
let currentDayOfYear = current.get('dayOfYear');
|
|
433
434
|
const nestedWeeks = [];
|
|
434
435
|
while (current.isBefore(end)) {
|
|
435
436
|
const weekNumber = Math.floor(count / 7);
|
|
436
437
|
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
437
438
|
nestedWeeks[weekNumber].push(current);
|
|
439
|
+
const prevDayOfYear = currentDayOfYear;
|
|
438
440
|
current = this.addDays(current, 1);
|
|
441
|
+
currentDayOfYear = current.get('dayOfYear');
|
|
442
|
+
|
|
443
|
+
// If there is a TZ change at midnight, adding 1 day may only increase the date by 23 hours to 11pm
|
|
444
|
+
// To fix, bump the date into the next day (add 12 hours) and then revert to the start of the day
|
|
445
|
+
// See https://github.com/moment/moment/issues/4743#issuecomment-811306874 for context.
|
|
446
|
+
if (prevDayOfYear === currentDayOfYear) {
|
|
447
|
+
current = current.add(12, 'h').startOf('day');
|
|
448
|
+
}
|
|
439
449
|
count += 1;
|
|
440
450
|
}
|
|
441
451
|
return nestedWeeks;
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,175 @@
|
|
|
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
|
+
## 7.23.0
|
|
7
|
+
|
|
8
|
+
_Nov 29, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- ✨ Support for a new display mode on the Data Grid with the [List View feature](https://mui.com/x/react-data-grid/list-view/), offering an extremely flexible way to render datasets and enabling developers to adapt how data is displayed across different screen sizes.
|
|
13
|
+
|
|
14
|
+
https://github.com/user-attachments/assets/61286adc-03fc-4323-9739-8ca726fcc16c
|
|
15
|
+
|
|
16
|
+
- ⚛️ React 19 support
|
|
17
|
+
- 📚 Documentation improvements
|
|
18
|
+
- 🌍 Improve Spanish, Portuguese, Chinese locales on the Data Grid component.
|
|
19
|
+
- 🌍 Improve Dutch locale on the Date and Time Picker components.
|
|
20
|
+
- 🐞 Bugfixes
|
|
21
|
+
|
|
22
|
+
Special thanks go out to the community contributors who have helped make this release possible:
|
|
23
|
+
@dloeda, @headironc, @mathzdev, @nphmuller, @lhilgert9, @lauri865.
|
|
24
|
+
Following are all team members who have contributed to this release:
|
|
25
|
+
@oliviertassinari, @arminmeh, @KenanYusuf, @flaviendelangle, @MBilalShafi.
|
|
26
|
+
|
|
27
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
28
|
+
|
|
29
|
+
### Data Grid
|
|
30
|
+
|
|
31
|
+
#### `@mui/x-data-grid@v7.23.0`
|
|
32
|
+
|
|
33
|
+
- [DataGrid] React 19 support (#15557) @arminmeh
|
|
34
|
+
- [DataGrid] Change test dom check from `/jsdom/` to `/jsdom|HappyDOM/`. (#15642) @jedesroches
|
|
35
|
+
- [DataGrid] Fix last separator not being hidden when grid is scrollable (#15551) @KenanYusuf
|
|
36
|
+
- [DataGrid] Fix order of spread props on toolbar items (#15556) @KenanYusuf
|
|
37
|
+
- [DataGrid] Fix row-spanning in combination with column-pinning (#15460) @lhilgert9
|
|
38
|
+
- [DataGrid] Improve resize performance (#15592) @lauri865
|
|
39
|
+
- [DataGrid] Support column virtualization with dynamic row height (#15567) @cherniavskii
|
|
40
|
+
- [DataGrid] Improve `GridCell` performance (#15621) @lauri865
|
|
41
|
+
- [l10n] Improve Chinese (zh-CN) locale (#15570) @headironc
|
|
42
|
+
- [l10n] Improve Portuguese (pt-PT) locale (#15561) @mathzdev
|
|
43
|
+
|
|
44
|
+
#### `@mui/x-data-grid-pro@v7.23.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
45
|
+
|
|
46
|
+
Same changes as in `@mui/x-data-grid@v7.23.0`, plus:
|
|
47
|
+
|
|
48
|
+
- [DataGridPro] Fix header filtering with `boolean` column type (#15640) @k-rajat19
|
|
49
|
+
- [DataGridPro] Fix pagination state not updating if the data source response has no rows (#15643) @zinoroman
|
|
50
|
+
- [DataGridPro] Fix selection propagation issue on initialization (#15593) @MBilalShafi
|
|
51
|
+
|
|
52
|
+
#### `@mui/x-data-grid-premium@v7.23.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
53
|
+
|
|
54
|
+
Same changes as in `@mui/x-data-grid-pro@v7.23.0`.
|
|
55
|
+
|
|
56
|
+
### Date and Time Pickers
|
|
57
|
+
|
|
58
|
+
#### `@mui/x-date-pickers@v7.23.0`
|
|
59
|
+
|
|
60
|
+
- [pickers] React 19 support (#15557) @arminmeh
|
|
61
|
+
- [pickers] Fix DST issue with `America/Asuncion` timezone and `AdapterMoment` (#15653) @flaviendelangle
|
|
62
|
+
- [pickers] Use `props.referenceDate` timezone when `props.value` and `props.defaultValue` are not defined (#15544) @flaviendelangle
|
|
63
|
+
- [l10n] Improve Dutch (nl-NL) locale (#15564) @nphmuller
|
|
64
|
+
|
|
65
|
+
#### `@mui/x-date-pickers-pro@v7.23.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
66
|
+
|
|
67
|
+
Same changes as in `@mui/x-date-pickers@v7.23.0`.
|
|
68
|
+
|
|
69
|
+
### Charts
|
|
70
|
+
|
|
71
|
+
#### `@mui/x-charts@v7.23.0`
|
|
72
|
+
|
|
73
|
+
- [charts] React 19 support (#15557) @arminmeh
|
|
74
|
+
- [charts] Prevent invalid `releasePointerCapture` (#15609) @alexfauquette
|
|
75
|
+
|
|
76
|
+
#### `@mui/x-charts-pro@v7.23.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
77
|
+
|
|
78
|
+
Same changes as in `@mui/x-charts@v7.23.0`.
|
|
79
|
+
|
|
80
|
+
### Tree View
|
|
81
|
+
|
|
82
|
+
#### `@mui/x-tree-view@v7.23.0`
|
|
83
|
+
|
|
84
|
+
- [TreeView] React 19 support (#15557) @arminmeh
|
|
85
|
+
|
|
86
|
+
#### `@mui/x-tree-view-pro@7.23.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
87
|
+
|
|
88
|
+
Same changes as in `@mui/x-tree-view@7.23.0`.
|
|
89
|
+
|
|
90
|
+
### Docs
|
|
91
|
+
|
|
92
|
+
- [docs] Add data caching to lazy loaded detail panel demo (#15555) @cherniavskii
|
|
93
|
+
- [docs] Remove selectors section from list view docs (#15639) @KenanYusuf
|
|
94
|
+
- [docs] Add documentation for the list view feature (#15344) @KenanYusuf
|
|
95
|
+
|
|
96
|
+
### Core
|
|
97
|
+
|
|
98
|
+
- [core] Update @mui/monorepo (#15574) @oliviertassinari
|
|
99
|
+
|
|
100
|
+
## 7.22.3
|
|
101
|
+
|
|
102
|
+
_Nov 21, 2024_
|
|
103
|
+
|
|
104
|
+
We'd like to offer a big thanks to the 10 contributors who made this release possible. Here are some highlights ✨:
|
|
105
|
+
|
|
106
|
+
- 📊 Charts Pro get stable. The [zoom](https://mui.com/x/react-charts/zoom-and-pan/) and [Heatmap](https://mui.com/x/react-charts/heatmap/) are now stable.
|
|
107
|
+
- 🌍 Improve Chinese, Spanish, Swedish, and Turkish locales on the Data Grid
|
|
108
|
+
- 🐞 Bugfixes
|
|
109
|
+
|
|
110
|
+
Special thanks go out to the community contributors who have helped make this release possible:
|
|
111
|
+
@CarlosLopezLg, @headironc, @viktormelin, @qerkules, @DungTiger, @hendrikpeilke, @k-rajat19.
|
|
112
|
+
Following are all team members who have contributed to this release:
|
|
113
|
+
@alexfauquette, @LukasTy, @MBilalShafi, @flaviendelangle.
|
|
114
|
+
|
|
115
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
116
|
+
|
|
117
|
+
### Data Grid
|
|
118
|
+
|
|
119
|
+
#### `@mui/x-data-grid@7.22.3`
|
|
120
|
+
|
|
121
|
+
- [DataGrid] Add prop to override search input props in `GridColumnsManagement` (#15476) @k-rajat19
|
|
122
|
+
- [DataGrid] Add test coverage for issues fixed in #15184 @MBilalShafi
|
|
123
|
+
- [DataGrid] Fix memoized selectors with arguments (#15336) @MBilalShafi
|
|
124
|
+
- [DataGrid] Fix right column group header border with virtualization (#15503) @hendrikpeilke
|
|
125
|
+
- [DataGrid] Pass reason to `onPaginationModelChange` (#15402) @DungTiger
|
|
126
|
+
- [DataGrid] Set default overlay height in flex parent layout (#15535) @cherniavskii
|
|
127
|
+
- [l10n] Improve Chinese (zh-CN) locale (#15365) @headironc
|
|
128
|
+
- [l10n] Improve Spanish (es-ES) locale (#15369) @CarlosLopezLg
|
|
129
|
+
- [l10n] Improve Swedish (sv-SE) locale (#15371) @viktormelin
|
|
130
|
+
- [l10n] Improve Turkish (tr-TR) locale (#15414) @qerkules
|
|
131
|
+
|
|
132
|
+
#### `@mui/x-data-grid-pro@7.22.3` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
133
|
+
|
|
134
|
+
Same changes as in `@mui/x-data-grid@7.22.3`.
|
|
135
|
+
|
|
136
|
+
#### `@mui/x-data-grid-premium@7.22.3` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
137
|
+
|
|
138
|
+
Same changes as in `@mui/x-data-grid-pro@7.22.3`.
|
|
139
|
+
|
|
140
|
+
### Date and Time Pickers
|
|
141
|
+
|
|
142
|
+
#### `@mui/x-date-pickers@7.22.3`
|
|
143
|
+
|
|
144
|
+
- [pickers] Always use `props.value` when it changes (#15500) @flaviendelangle
|
|
145
|
+
- [pickers] Ensure internal value timezone is updated (#15491) @LukasTy
|
|
146
|
+
- [pickers] Fix `DateTimeRangePicker` error when using format without time (#15341) @fxnoob
|
|
147
|
+
- [pickers] Fix unused code in `PickersToolbar` component (#15525) @LukasTy
|
|
148
|
+
|
|
149
|
+
#### `@mui/x-date-pickers-pro@7.22.3` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
150
|
+
|
|
151
|
+
Same changes as in `@mui/x-date-pickers@7.22.3`, plus:
|
|
152
|
+
|
|
153
|
+
- [DateTimeRangePicker] Use time in `referenceDate` when selecting date (#15431) @LukasTy
|
|
154
|
+
|
|
155
|
+
### Charts
|
|
156
|
+
|
|
157
|
+
#### `@mui/x-charts@7.22.3`
|
|
158
|
+
|
|
159
|
+
No changes since `@mui/x-charts@7.22.2`.
|
|
160
|
+
|
|
161
|
+
#### `@mui/x-charts-pro@7.22.3` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
162
|
+
|
|
163
|
+
- [charts-pro] Fix missing typeOverload (#15400) @alexfauquette
|
|
164
|
+
|
|
165
|
+
### Docs
|
|
166
|
+
|
|
167
|
+
- [docs] Add `PickersPopper` component to customization playground (#15397) @LukasTy
|
|
168
|
+
- [docs] Add `next` version links (#15423) @LukasTy
|
|
169
|
+
- [docs] Use the `loading` state in the demos (#15538) @cherniavskii
|
|
170
|
+
|
|
171
|
+
- [code-infra] Tentative fix for Argos flaky screenshot tests (#15399) @JCQuintas
|
|
172
|
+
- [docs-infra] Transpile `.ts` demo files (#15421) @KenanYusuf
|
|
173
|
+
- [core] Clarify release version bump strategy (#15536) @cherniavskii
|
|
174
|
+
|
|
6
175
|
## 7.22.2
|
|
7
176
|
|
|
8
177
|
_Nov 8, 2024_
|
|
@@ -99,7 +99,8 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
99
99
|
timezone: timezoneProp,
|
|
100
100
|
value: valueProp,
|
|
101
101
|
defaultValue,
|
|
102
|
-
|
|
102
|
+
referenceDate: referenceDateProp,
|
|
103
|
+
onChange,
|
|
103
104
|
valueManager: singleItemValueManager
|
|
104
105
|
});
|
|
105
106
|
const now = useNow(timezone);
|
package/README.md
CHANGED
|
@@ -34,9 +34,9 @@ This component has the following peer dependencies that you will need to install
|
|
|
34
34
|
|
|
35
35
|
```json
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@mui/material": "^5.15.14",
|
|
38
|
-
"react": "^17.0.0 || ^18.0.0",
|
|
39
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
37
|
+
"@mui/material": "^5.15.14 || ^6.0.0",
|
|
38
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
39
|
+
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
40
40
|
},
|
|
41
41
|
```
|
|
42
42
|
|
package/TimeClock/TimeClock.js
CHANGED
|
@@ -105,7 +105,8 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
105
105
|
timezone: timezoneProp,
|
|
106
106
|
value: valueProp,
|
|
107
107
|
defaultValue,
|
|
108
|
-
|
|
108
|
+
referenceDate: referenceDateProp,
|
|
109
|
+
onChange,
|
|
109
110
|
valueManager: singleItemValueManager
|
|
110
111
|
});
|
|
111
112
|
const now = useNow(timezone);
|
package/index.js
CHANGED
|
@@ -10,13 +10,11 @@ import { getPickersToolbarUtilityClass } from "./pickersToolbarClasses.js";
|
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
const useUtilityClasses = ownerState => {
|
|
12
12
|
const {
|
|
13
|
-
classes
|
|
14
|
-
isLandscape
|
|
13
|
+
classes
|
|
15
14
|
} = ownerState;
|
|
16
15
|
const slots = {
|
|
17
16
|
root: ['root'],
|
|
18
|
-
content: ['content']
|
|
19
|
-
penIconButton: ['penIconButton', isLandscape && 'penIconButtonLandscape']
|
|
17
|
+
content: ['content']
|
|
20
18
|
};
|
|
21
19
|
return composeClasses(slots, getPickersToolbarUtilityClass, classes);
|
|
22
20
|
};
|
|
@@ -571,7 +571,8 @@ export const parseSelectedSections = (selectedSections, sections) => {
|
|
|
571
571
|
return 'all';
|
|
572
572
|
}
|
|
573
573
|
if (typeof selectedSections === 'string') {
|
|
574
|
-
|
|
574
|
+
const index = sections.findIndex(section => section.type === selectedSections);
|
|
575
|
+
return index === -1 ? null : index;
|
|
575
576
|
}
|
|
576
577
|
return selectedSections;
|
|
577
578
|
};
|
|
@@ -8,7 +8,7 @@ import { DateOrTimeViewWithMeridiem } from '../../models';
|
|
|
8
8
|
*/
|
|
9
9
|
export interface UsePickerBaseProps<TValue, TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TDate, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueBaseProps<TValue, TError>, UsePickerViewsBaseProps<TValue, TDate, TView, TExternalProps, TAdditionalProps>, UsePickerLayoutProps {
|
|
10
10
|
}
|
|
11
|
-
export interface UsePickerProps<TValue, TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TDate, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueProps<TValue, TError>, UsePickerViewsProps<TValue, TDate, TView, TExternalProps, TAdditionalProps>, UsePickerLayoutProps {
|
|
11
|
+
export interface UsePickerProps<TValue, TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TError, TExternalProps extends UsePickerViewsProps<TValue, TDate, TView, any, any>, TAdditionalProps extends {}> extends UsePickerValueProps<TValue, TDate, TError>, UsePickerViewsProps<TValue, TDate, TView, TExternalProps, TAdditionalProps>, UsePickerLayoutProps {
|
|
12
12
|
}
|
|
13
13
|
export interface UsePickerParams<TValue, TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem, TSection extends FieldSection, TExternalProps extends UsePickerProps<TValue, TDate, TView, any, any, any>, TAdditionalProps extends {}> extends Pick<UsePickerValueParams<TValue, TDate, TExternalProps>, 'valueManager' | 'valueType' | 'wrapperVariant' | 'validator'>, Pick<UsePickerViewParams<TValue, TDate, TView, TSection, TExternalProps, TAdditionalProps>, 'additionalViewProps' | 'autoFocusView' | 'rendererInterceptor' | 'fieldRef'> {
|
|
14
14
|
props: TExternalProps;
|
|
@@ -3,4 +3,4 @@ import { UsePickerValueProps, UsePickerValueParams, UsePickerValueResponse } fro
|
|
|
3
3
|
/**
|
|
4
4
|
* Manage the value lifecycle of all the pickers.
|
|
5
5
|
*/
|
|
6
|
-
export declare const usePickerValue: <TValue, TDate extends PickerValidDate, TSection extends FieldSection, TExternalProps extends UsePickerValueProps<TValue, any>>({ props, valueManager, valueType, wrapperVariant, validator, }: UsePickerValueParams<TValue, TDate, TExternalProps>) => UsePickerValueResponse<TValue, TSection, InferError<TExternalProps>>;
|
|
6
|
+
export declare const usePickerValue: <TValue, TDate extends PickerValidDate, TSection extends FieldSection, TExternalProps extends UsePickerValueProps<TValue, TDate, any>>({ props, valueManager, valueType, wrapperVariant, validator, }: UsePickerValueParams<TValue, TDate, TExternalProps>) => UsePickerValueResponse<TValue, TSection, InferError<TExternalProps>>;
|
|
@@ -121,7 +121,8 @@ export const usePickerValue = ({
|
|
|
121
121
|
value: inValueWithoutRenderTimezone,
|
|
122
122
|
defaultValue: inDefaultValue,
|
|
123
123
|
closeOnSelect = wrapperVariant === 'desktop',
|
|
124
|
-
timezone: timezoneProp
|
|
124
|
+
timezone: timezoneProp,
|
|
125
|
+
referenceDate
|
|
125
126
|
} = props;
|
|
126
127
|
const {
|
|
127
128
|
current: defaultValue
|
|
@@ -129,6 +130,7 @@ export const usePickerValue = ({
|
|
|
129
130
|
const {
|
|
130
131
|
current: isControlled
|
|
131
132
|
} = React.useRef(inValueWithoutRenderTimezone !== undefined);
|
|
133
|
+
const [previousTimezoneProp, setPreviousTimezoneProp] = React.useState(timezoneProp);
|
|
132
134
|
|
|
133
135
|
/* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
|
|
134
136
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -159,6 +161,7 @@ export const usePickerValue = ({
|
|
|
159
161
|
timezone: timezoneProp,
|
|
160
162
|
value: inValueWithoutRenderTimezone,
|
|
161
163
|
defaultValue,
|
|
164
|
+
referenceDate,
|
|
162
165
|
onChange,
|
|
163
166
|
valueManager
|
|
164
167
|
});
|
|
@@ -175,10 +178,19 @@ export const usePickerValue = ({
|
|
|
175
178
|
draft: initialValue,
|
|
176
179
|
lastPublishedValue: initialValue,
|
|
177
180
|
lastCommittedValue: initialValue,
|
|
178
|
-
lastControlledValue:
|
|
181
|
+
lastControlledValue: inValueWithoutRenderTimezone,
|
|
179
182
|
hasBeenModifiedSinceMount: false
|
|
180
183
|
};
|
|
181
184
|
});
|
|
185
|
+
const timezoneFromDraftValue = valueManager.getTimezone(utils, dateState.draft);
|
|
186
|
+
if (previousTimezoneProp !== timezoneProp) {
|
|
187
|
+
setPreviousTimezoneProp(timezoneProp);
|
|
188
|
+
if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
|
|
189
|
+
setDateState(prev => _extends({}, prev, {
|
|
190
|
+
draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
182
194
|
const {
|
|
183
195
|
getValidationErrorForNewValue
|
|
184
196
|
} = useValidation({
|
|
@@ -228,10 +240,10 @@ export const usePickerValue = ({
|
|
|
228
240
|
setIsOpen(false);
|
|
229
241
|
}
|
|
230
242
|
});
|
|
231
|
-
if (
|
|
243
|
+
if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) {
|
|
232
244
|
const isUpdateComingFromPicker = valueManager.areValuesEqual(utils, dateState.draft, inValueWithTimezoneToRender);
|
|
233
245
|
setDateState(prev => _extends({}, prev, {
|
|
234
|
-
lastControlledValue:
|
|
246
|
+
lastControlledValue: inValueWithoutRenderTimezone
|
|
235
247
|
}, isUpdateComingFromPicker ? {} : {
|
|
236
248
|
lastCommittedValue: inValueWithTimezoneToRender,
|
|
237
249
|
lastPublishedValue: inValueWithTimezoneToRender,
|
|
@@ -123,7 +123,7 @@ export interface UsePickerValueState<TValue> {
|
|
|
123
123
|
*/
|
|
124
124
|
lastCommittedValue: TValue;
|
|
125
125
|
/**
|
|
126
|
-
* Last value passed
|
|
126
|
+
* Last value passed to `props.value`.
|
|
127
127
|
* Used to update the `draft` value whenever the `value` prop changes.
|
|
128
128
|
*/
|
|
129
129
|
lastControlledValue: TValue | undefined;
|
|
@@ -226,9 +226,10 @@ export interface UsePickerValueNonStaticProps {
|
|
|
226
226
|
/**
|
|
227
227
|
* Props used to handle the value of the pickers.
|
|
228
228
|
*/
|
|
229
|
-
export interface UsePickerValueProps<TValue, TError> extends UsePickerValueBaseProps<TValue, TError>, UsePickerValueNonStaticProps, TimezoneProps {
|
|
229
|
+
export interface UsePickerValueProps<TValue, TDate extends PickerValidDate, TError> extends UsePickerValueBaseProps<TValue, TError>, UsePickerValueNonStaticProps, TimezoneProps {
|
|
230
|
+
referenceDate?: TDate;
|
|
230
231
|
}
|
|
231
|
-
export interface UsePickerValueParams<TValue, TDate extends PickerValidDate, TExternalProps extends UsePickerValueProps<TValue, any>> {
|
|
232
|
+
export interface UsePickerValueParams<TValue, TDate extends PickerValidDate, TExternalProps extends UsePickerValueProps<TValue, TDate, any>> {
|
|
232
233
|
props: TExternalProps;
|
|
233
234
|
valueManager: PickerValueManager<TValue, TDate, InferError<TExternalProps>>;
|
|
234
235
|
valueType: FieldValueType;
|
|
@@ -5,13 +5,7 @@ import { PickersTimezone, PickerValidDate } from '../../models';
|
|
|
5
5
|
* - The value returned by `onChange` always have the timezone of `props.value` or `props.defaultValue` if defined
|
|
6
6
|
* - The value rendered is always the one from `props.timezone` if defined
|
|
7
7
|
*/
|
|
8
|
-
export declare const useValueWithTimezone: <TDate extends PickerValidDate,
|
|
9
|
-
timezone: PickersTimezone | undefined;
|
|
10
|
-
value: TValue | undefined;
|
|
11
|
-
defaultValue: TValue | undefined;
|
|
12
|
-
onChange: TChange | undefined;
|
|
13
|
-
valueManager: PickerValueManager<TValue, TDate, any>;
|
|
14
|
-
}) => {
|
|
8
|
+
export declare const useValueWithTimezone: <TValue, TDate extends PickerValidDate, TChange extends (...params: any[]) => void>({ timezone: timezoneProp, value: valueProp, defaultValue, referenceDate, onChange, valueManager, }: UseValueWithTimezoneParameters<TValue, TDate, TChange>) => {
|
|
15
9
|
value: TValue;
|
|
16
10
|
handleValueChange: TChange;
|
|
17
11
|
timezone: string;
|
|
@@ -19,15 +13,25 @@ export declare const useValueWithTimezone: <TDate extends PickerValidDate, TValu
|
|
|
19
13
|
/**
|
|
20
14
|
* Wrapper around `useControlled` and `useValueWithTimezone`
|
|
21
15
|
*/
|
|
22
|
-
export declare const useControlledValueWithTimezone: <TDate extends PickerValidDate,
|
|
23
|
-
|
|
16
|
+
export declare const useControlledValueWithTimezone: <TValue, TDate extends PickerValidDate, TChange extends (...params: any[]) => void>({ name, timezone: timezoneProp, value: valueProp, defaultValue, referenceDate, onChange: onChangeProp, valueManager, }: UseControlledValueWithTimezoneParameters<TValue, TDate, TChange>) => {
|
|
17
|
+
value: TValue;
|
|
18
|
+
handleValueChange: TChange;
|
|
19
|
+
timezone: string;
|
|
20
|
+
};
|
|
21
|
+
interface UseValueWithTimezoneParameters<TValue, TDate extends PickerValidDate, TChange extends (...params: any[]) => void> {
|
|
24
22
|
timezone: PickersTimezone | undefined;
|
|
25
23
|
value: TValue | undefined;
|
|
26
24
|
defaultValue: TValue | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The reference date as passed to `props.referenceDate`.
|
|
27
|
+
* It does not need to have its default value.
|
|
28
|
+
* This is only used to determine the timezone to use when `props.value` and `props.defaultValue` are not defined.
|
|
29
|
+
*/
|
|
30
|
+
referenceDate: TDate | undefined;
|
|
27
31
|
onChange: TChange | undefined;
|
|
28
32
|
valueManager: PickerValueManager<TValue, TDate, any>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
33
|
+
}
|
|
34
|
+
interface UseControlledValueWithTimezoneParameters<TValue, TDate extends PickerValidDate, TChange extends (...params: any[]) => void> extends UseValueWithTimezoneParameters<TValue, TDate, TChange> {
|
|
35
|
+
name: string;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -11,6 +11,7 @@ export const useValueWithTimezone = ({
|
|
|
11
11
|
timezone: timezoneProp,
|
|
12
12
|
value: valueProp,
|
|
13
13
|
defaultValue,
|
|
14
|
+
referenceDate,
|
|
14
15
|
onChange,
|
|
15
16
|
valueManager
|
|
16
17
|
}) => {
|
|
@@ -24,7 +25,16 @@ export const useValueWithTimezone = ({
|
|
|
24
25
|
}
|
|
25
26
|
return valueManager.setTimezone(utils, inputTimezone, newValue);
|
|
26
27
|
});
|
|
27
|
-
|
|
28
|
+
let timezoneToRender;
|
|
29
|
+
if (timezoneProp) {
|
|
30
|
+
timezoneToRender = timezoneProp;
|
|
31
|
+
} else if (inputTimezone) {
|
|
32
|
+
timezoneToRender = inputTimezone;
|
|
33
|
+
} else if (referenceDate) {
|
|
34
|
+
timezoneToRender = utils.getTimezone(referenceDate);
|
|
35
|
+
} else {
|
|
36
|
+
timezoneToRender = 'default';
|
|
37
|
+
}
|
|
28
38
|
const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [valueManager, utils, timezoneToRender, inputValue]);
|
|
29
39
|
const handleValueChange = useEventCallback((newValue, ...otherParams) => {
|
|
30
40
|
const newValueWithInputTimezone = setInputTimezone(newValue);
|
|
@@ -45,6 +55,7 @@ export const useControlledValueWithTimezone = ({
|
|
|
45
55
|
timezone: timezoneProp,
|
|
46
56
|
value: valueProp,
|
|
47
57
|
defaultValue,
|
|
58
|
+
referenceDate,
|
|
48
59
|
onChange: onChangeProp,
|
|
49
60
|
valueManager
|
|
50
61
|
}) => {
|
|
@@ -62,6 +73,7 @@ export const useControlledValueWithTimezone = ({
|
|
|
62
73
|
timezone: timezoneProp,
|
|
63
74
|
value: valueWithInputTimezone,
|
|
64
75
|
defaultValue: undefined,
|
|
76
|
+
referenceDate,
|
|
65
77
|
onChange,
|
|
66
78
|
valueManager
|
|
67
79
|
});
|
package/locales/nlNL.js
CHANGED
|
@@ -16,10 +16,10 @@ const nlNLPickers = {
|
|
|
16
16
|
// DateRange labels
|
|
17
17
|
start: 'Start',
|
|
18
18
|
end: 'Einde',
|
|
19
|
-
startDate: '
|
|
20
|
-
startTime: '
|
|
21
|
-
endDate: '
|
|
22
|
-
endTime: '
|
|
19
|
+
startDate: 'Startdatum',
|
|
20
|
+
startTime: 'Starttijd',
|
|
21
|
+
endDate: 'Einddatum',
|
|
22
|
+
endTime: 'Eindtijd',
|
|
23
23
|
// Action bar
|
|
24
24
|
cancelButtonLabel: 'Annuleren',
|
|
25
25
|
clearButtonLabel: 'Resetten',
|
|
@@ -50,11 +50,11 @@ const nlNLPickers = {
|
|
|
50
50
|
timeTableLabel: 'kies tijd',
|
|
51
51
|
dateTableLabel: 'kies datum',
|
|
52
52
|
// Field section placeholders
|
|
53
|
-
fieldYearPlaceholder: params => '
|
|
53
|
+
fieldYearPlaceholder: params => 'J'.repeat(params.digitAmount),
|
|
54
54
|
fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
|
|
55
55
|
fieldDayPlaceholder: () => 'DD',
|
|
56
56
|
fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
|
|
57
|
-
fieldHoursPlaceholder: () => '
|
|
57
|
+
fieldHoursPlaceholder: () => 'uu',
|
|
58
58
|
fieldMinutesPlaceholder: () => 'mm',
|
|
59
59
|
fieldSecondsPlaceholder: () => 'ss',
|
|
60
60
|
fieldMeridiemPlaceholder: () => 'aa',
|
|
@@ -68,6 +68,6 @@ const nlNLPickers = {
|
|
|
68
68
|
seconds: 'Seconden',
|
|
69
69
|
meridiem: 'Middag',
|
|
70
70
|
// Common
|
|
71
|
-
empty: '
|
|
71
|
+
empty: 'Leeg'
|
|
72
72
|
};
|
|
73
73
|
export const nlNL = getPickersLocalization(nlNLPickers);
|
|
@@ -430,12 +430,22 @@ export class AdapterMoment {
|
|
|
430
430
|
const end = this.endOfWeek(this.endOfMonth(value));
|
|
431
431
|
let count = 0;
|
|
432
432
|
let current = start;
|
|
433
|
+
let currentDayOfYear = current.get('dayOfYear');
|
|
433
434
|
const nestedWeeks = [];
|
|
434
435
|
while (current.isBefore(end)) {
|
|
435
436
|
const weekNumber = Math.floor(count / 7);
|
|
436
437
|
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
437
438
|
nestedWeeks[weekNumber].push(current);
|
|
439
|
+
const prevDayOfYear = currentDayOfYear;
|
|
438
440
|
current = this.addDays(current, 1);
|
|
441
|
+
currentDayOfYear = current.get('dayOfYear');
|
|
442
|
+
|
|
443
|
+
// If there is a TZ change at midnight, adding 1 day may only increase the date by 23 hours to 11pm
|
|
444
|
+
// To fix, bump the date into the next day (add 12 hours) and then revert to the start of the day
|
|
445
|
+
// See https://github.com/moment/moment/issues/4743#issuecomment-811306874 for context.
|
|
446
|
+
if (prevDayOfYear === currentDayOfYear) {
|
|
447
|
+
current = current.add(12, 'h').startOf('day');
|
|
448
|
+
}
|
|
439
449
|
count += 1;
|
|
440
450
|
}
|
|
441
451
|
return nestedWeeks;
|
|
@@ -99,7 +99,8 @@ export const MonthCalendar = /*#__PURE__*/React.forwardRef(function MonthCalenda
|
|
|
99
99
|
timezone: timezoneProp,
|
|
100
100
|
value: valueProp,
|
|
101
101
|
defaultValue,
|
|
102
|
-
|
|
102
|
+
referenceDate: referenceDateProp,
|
|
103
|
+
onChange,
|
|
103
104
|
valueManager: singleItemValueManager
|
|
104
105
|
});
|
|
105
106
|
const now = useNow(timezone);
|
|
@@ -105,7 +105,8 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
105
105
|
timezone: timezoneProp,
|
|
106
106
|
value: valueProp,
|
|
107
107
|
defaultValue,
|
|
108
|
-
|
|
108
|
+
referenceDate: referenceDateProp,
|
|
109
|
+
onChange,
|
|
109
110
|
valueManager: singleItemValueManager
|
|
110
111
|
});
|
|
111
112
|
const now = useNow(timezone);
|
package/modern/index.js
CHANGED
|
@@ -10,13 +10,11 @@ import { getPickersToolbarUtilityClass } from "./pickersToolbarClasses.js";
|
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
const useUtilityClasses = ownerState => {
|
|
12
12
|
const {
|
|
13
|
-
classes
|
|
14
|
-
isLandscape
|
|
13
|
+
classes
|
|
15
14
|
} = ownerState;
|
|
16
15
|
const slots = {
|
|
17
16
|
root: ['root'],
|
|
18
|
-
content: ['content']
|
|
19
|
-
penIconButton: ['penIconButton', isLandscape && 'penIconButtonLandscape']
|
|
17
|
+
content: ['content']
|
|
20
18
|
};
|
|
21
19
|
return composeClasses(slots, getPickersToolbarUtilityClass, classes);
|
|
22
20
|
};
|
|
@@ -571,7 +571,8 @@ export const parseSelectedSections = (selectedSections, sections) => {
|
|
|
571
571
|
return 'all';
|
|
572
572
|
}
|
|
573
573
|
if (typeof selectedSections === 'string') {
|
|
574
|
-
|
|
574
|
+
const index = sections.findIndex(section => section.type === selectedSections);
|
|
575
|
+
return index === -1 ? null : index;
|
|
575
576
|
}
|
|
576
577
|
return selectedSections;
|
|
577
578
|
};
|
|
@@ -121,7 +121,8 @@ export const usePickerValue = ({
|
|
|
121
121
|
value: inValueWithoutRenderTimezone,
|
|
122
122
|
defaultValue: inDefaultValue,
|
|
123
123
|
closeOnSelect = wrapperVariant === 'desktop',
|
|
124
|
-
timezone: timezoneProp
|
|
124
|
+
timezone: timezoneProp,
|
|
125
|
+
referenceDate
|
|
125
126
|
} = props;
|
|
126
127
|
const {
|
|
127
128
|
current: defaultValue
|
|
@@ -129,6 +130,7 @@ export const usePickerValue = ({
|
|
|
129
130
|
const {
|
|
130
131
|
current: isControlled
|
|
131
132
|
} = React.useRef(inValueWithoutRenderTimezone !== undefined);
|
|
133
|
+
const [previousTimezoneProp, setPreviousTimezoneProp] = React.useState(timezoneProp);
|
|
132
134
|
|
|
133
135
|
/* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
|
|
134
136
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -159,6 +161,7 @@ export const usePickerValue = ({
|
|
|
159
161
|
timezone: timezoneProp,
|
|
160
162
|
value: inValueWithoutRenderTimezone,
|
|
161
163
|
defaultValue,
|
|
164
|
+
referenceDate,
|
|
162
165
|
onChange,
|
|
163
166
|
valueManager
|
|
164
167
|
});
|
|
@@ -175,10 +178,19 @@ export const usePickerValue = ({
|
|
|
175
178
|
draft: initialValue,
|
|
176
179
|
lastPublishedValue: initialValue,
|
|
177
180
|
lastCommittedValue: initialValue,
|
|
178
|
-
lastControlledValue:
|
|
181
|
+
lastControlledValue: inValueWithoutRenderTimezone,
|
|
179
182
|
hasBeenModifiedSinceMount: false
|
|
180
183
|
};
|
|
181
184
|
});
|
|
185
|
+
const timezoneFromDraftValue = valueManager.getTimezone(utils, dateState.draft);
|
|
186
|
+
if (previousTimezoneProp !== timezoneProp) {
|
|
187
|
+
setPreviousTimezoneProp(timezoneProp);
|
|
188
|
+
if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
|
|
189
|
+
setDateState(prev => _extends({}, prev, {
|
|
190
|
+
draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
182
194
|
const {
|
|
183
195
|
getValidationErrorForNewValue
|
|
184
196
|
} = useValidation({
|
|
@@ -228,10 +240,10 @@ export const usePickerValue = ({
|
|
|
228
240
|
setIsOpen(false);
|
|
229
241
|
}
|
|
230
242
|
});
|
|
231
|
-
if (
|
|
243
|
+
if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) {
|
|
232
244
|
const isUpdateComingFromPicker = valueManager.areValuesEqual(utils, dateState.draft, inValueWithTimezoneToRender);
|
|
233
245
|
setDateState(prev => _extends({}, prev, {
|
|
234
|
-
lastControlledValue:
|
|
246
|
+
lastControlledValue: inValueWithoutRenderTimezone
|
|
235
247
|
}, isUpdateComingFromPicker ? {} : {
|
|
236
248
|
lastCommittedValue: inValueWithTimezoneToRender,
|
|
237
249
|
lastPublishedValue: inValueWithTimezoneToRender,
|
|
@@ -11,6 +11,7 @@ export const useValueWithTimezone = ({
|
|
|
11
11
|
timezone: timezoneProp,
|
|
12
12
|
value: valueProp,
|
|
13
13
|
defaultValue,
|
|
14
|
+
referenceDate,
|
|
14
15
|
onChange,
|
|
15
16
|
valueManager
|
|
16
17
|
}) => {
|
|
@@ -24,7 +25,16 @@ export const useValueWithTimezone = ({
|
|
|
24
25
|
}
|
|
25
26
|
return valueManager.setTimezone(utils, inputTimezone, newValue);
|
|
26
27
|
});
|
|
27
|
-
|
|
28
|
+
let timezoneToRender;
|
|
29
|
+
if (timezoneProp) {
|
|
30
|
+
timezoneToRender = timezoneProp;
|
|
31
|
+
} else if (inputTimezone) {
|
|
32
|
+
timezoneToRender = inputTimezone;
|
|
33
|
+
} else if (referenceDate) {
|
|
34
|
+
timezoneToRender = utils.getTimezone(referenceDate);
|
|
35
|
+
} else {
|
|
36
|
+
timezoneToRender = 'default';
|
|
37
|
+
}
|
|
28
38
|
const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [valueManager, utils, timezoneToRender, inputValue]);
|
|
29
39
|
const handleValueChange = useEventCallback((newValue, ...otherParams) => {
|
|
30
40
|
const newValueWithInputTimezone = setInputTimezone(newValue);
|
|
@@ -45,6 +55,7 @@ export const useControlledValueWithTimezone = ({
|
|
|
45
55
|
timezone: timezoneProp,
|
|
46
56
|
value: valueProp,
|
|
47
57
|
defaultValue,
|
|
58
|
+
referenceDate,
|
|
48
59
|
onChange: onChangeProp,
|
|
49
60
|
valueManager
|
|
50
61
|
}) => {
|
|
@@ -62,6 +73,7 @@ export const useControlledValueWithTimezone = ({
|
|
|
62
73
|
timezone: timezoneProp,
|
|
63
74
|
value: valueWithInputTimezone,
|
|
64
75
|
defaultValue: undefined,
|
|
76
|
+
referenceDate,
|
|
65
77
|
onChange,
|
|
66
78
|
valueManager
|
|
67
79
|
});
|
package/modern/locales/nlNL.js
CHANGED
|
@@ -16,10 +16,10 @@ const nlNLPickers = {
|
|
|
16
16
|
// DateRange labels
|
|
17
17
|
start: 'Start',
|
|
18
18
|
end: 'Einde',
|
|
19
|
-
startDate: '
|
|
20
|
-
startTime: '
|
|
21
|
-
endDate: '
|
|
22
|
-
endTime: '
|
|
19
|
+
startDate: 'Startdatum',
|
|
20
|
+
startTime: 'Starttijd',
|
|
21
|
+
endDate: 'Einddatum',
|
|
22
|
+
endTime: 'Eindtijd',
|
|
23
23
|
// Action bar
|
|
24
24
|
cancelButtonLabel: 'Annuleren',
|
|
25
25
|
clearButtonLabel: 'Resetten',
|
|
@@ -50,11 +50,11 @@ const nlNLPickers = {
|
|
|
50
50
|
timeTableLabel: 'kies tijd',
|
|
51
51
|
dateTableLabel: 'kies datum',
|
|
52
52
|
// Field section placeholders
|
|
53
|
-
fieldYearPlaceholder: params => '
|
|
53
|
+
fieldYearPlaceholder: params => 'J'.repeat(params.digitAmount),
|
|
54
54
|
fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
|
|
55
55
|
fieldDayPlaceholder: () => 'DD',
|
|
56
56
|
fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
|
|
57
|
-
fieldHoursPlaceholder: () => '
|
|
57
|
+
fieldHoursPlaceholder: () => 'uu',
|
|
58
58
|
fieldMinutesPlaceholder: () => 'mm',
|
|
59
59
|
fieldSecondsPlaceholder: () => 'ss',
|
|
60
60
|
fieldMeridiemPlaceholder: () => 'aa',
|
|
@@ -68,6 +68,6 @@ const nlNLPickers = {
|
|
|
68
68
|
seconds: 'Seconden',
|
|
69
69
|
meridiem: 'Middag',
|
|
70
70
|
// Common
|
|
71
|
-
empty: '
|
|
71
|
+
empty: 'Leeg'
|
|
72
72
|
};
|
|
73
73
|
export const nlNL = getPickersLocalization(nlNLPickers);
|
|
@@ -438,12 +438,22 @@ class AdapterMoment {
|
|
|
438
438
|
const end = this.endOfWeek(this.endOfMonth(value));
|
|
439
439
|
let count = 0;
|
|
440
440
|
let current = start;
|
|
441
|
+
let currentDayOfYear = current.get('dayOfYear');
|
|
441
442
|
const nestedWeeks = [];
|
|
442
443
|
while (current.isBefore(end)) {
|
|
443
444
|
const weekNumber = Math.floor(count / 7);
|
|
444
445
|
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
445
446
|
nestedWeeks[weekNumber].push(current);
|
|
447
|
+
const prevDayOfYear = currentDayOfYear;
|
|
446
448
|
current = this.addDays(current, 1);
|
|
449
|
+
currentDayOfYear = current.get('dayOfYear');
|
|
450
|
+
|
|
451
|
+
// If there is a TZ change at midnight, adding 1 day may only increase the date by 23 hours to 11pm
|
|
452
|
+
// To fix, bump the date into the next day (add 12 hours) and then revert to the start of the day
|
|
453
|
+
// See https://github.com/moment/moment/issues/4743#issuecomment-811306874 for context.
|
|
454
|
+
if (prevDayOfYear === currentDayOfYear) {
|
|
455
|
+
current = current.add(12, 'h').startOf('day');
|
|
456
|
+
}
|
|
447
457
|
count += 1;
|
|
448
458
|
}
|
|
449
459
|
return nestedWeeks;
|
|
@@ -142,6 +142,7 @@ const DateCalendar = exports.DateCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
142
142
|
timezone: timezoneProp,
|
|
143
143
|
value: valueProp,
|
|
144
144
|
defaultValue,
|
|
145
|
+
referenceDate: referenceDateProp,
|
|
145
146
|
onChange,
|
|
146
147
|
valueManager: _valueManagers.singleItemValueManager
|
|
147
148
|
});
|
|
@@ -156,6 +156,7 @@ const DigitalClock = exports.DigitalClock = /*#__PURE__*/React.forwardRef(functi
|
|
|
156
156
|
timezone: timezoneProp,
|
|
157
157
|
value: valueProp,
|
|
158
158
|
defaultValue,
|
|
159
|
+
referenceDate: referenceDateProp,
|
|
159
160
|
onChange,
|
|
160
161
|
valueManager: _valueManagers.singleItemValueManager
|
|
161
162
|
});
|
|
@@ -107,7 +107,8 @@ const MonthCalendar = exports.MonthCalendar = /*#__PURE__*/React.forwardRef(func
|
|
|
107
107
|
timezone: timezoneProp,
|
|
108
108
|
value: valueProp,
|
|
109
109
|
defaultValue,
|
|
110
|
-
|
|
110
|
+
referenceDate: referenceDateProp,
|
|
111
|
+
onChange,
|
|
111
112
|
valueManager: _valueManagers.singleItemValueManager
|
|
112
113
|
});
|
|
113
114
|
const now = (0, _useUtils.useNow)(timezone);
|
|
@@ -108,6 +108,7 @@ const MultiSectionDigitalClock = exports.MultiSectionDigitalClock = /*#__PURE__*
|
|
|
108
108
|
timezone: timezoneProp,
|
|
109
109
|
value: valueProp,
|
|
110
110
|
defaultValue,
|
|
111
|
+
referenceDate: referenceDateProp,
|
|
111
112
|
onChange,
|
|
112
113
|
valueManager: _valueManagers.singleItemValueManager
|
|
113
114
|
});
|
|
@@ -114,6 +114,7 @@ const TimeClock = exports.TimeClock = /*#__PURE__*/React.forwardRef(function Tim
|
|
|
114
114
|
timezone: timezoneProp,
|
|
115
115
|
value: valueProp,
|
|
116
116
|
defaultValue,
|
|
117
|
+
referenceDate: referenceDateProp,
|
|
117
118
|
onChange,
|
|
118
119
|
valueManager: _valueManagers.singleItemValueManager
|
|
119
120
|
});
|
|
@@ -112,7 +112,8 @@ const YearCalendar = exports.YearCalendar = /*#__PURE__*/React.forwardRef(functi
|
|
|
112
112
|
timezone: timezoneProp,
|
|
113
113
|
value: valueProp,
|
|
114
114
|
defaultValue,
|
|
115
|
-
|
|
115
|
+
referenceDate: referenceDateProp,
|
|
116
|
+
onChange,
|
|
116
117
|
valueManager: _valueManagers.singleItemValueManager
|
|
117
118
|
});
|
|
118
119
|
const now = (0, _useUtils.useNow)(timezone);
|
package/node/index.js
CHANGED
|
@@ -18,13 +18,11 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
18
|
const _excluded = ["children", "className", "toolbarTitle", "hidden", "titleId", "isLandscape", "classes", "landscapeDirection"];
|
|
19
19
|
const useUtilityClasses = ownerState => {
|
|
20
20
|
const {
|
|
21
|
-
classes
|
|
22
|
-
isLandscape
|
|
21
|
+
classes
|
|
23
22
|
} = ownerState;
|
|
24
23
|
const slots = {
|
|
25
24
|
root: ['root'],
|
|
26
|
-
content: ['content']
|
|
27
|
-
penIconButton: ['penIconButton', isLandscape && 'penIconButtonLandscape']
|
|
25
|
+
content: ['content']
|
|
28
26
|
};
|
|
29
27
|
return (0, _composeClasses.default)(slots, _pickersToolbarClasses.getPickersToolbarUtilityClass, classes);
|
|
30
28
|
};
|
|
@@ -598,7 +598,8 @@ const parseSelectedSections = (selectedSections, sections) => {
|
|
|
598
598
|
return 'all';
|
|
599
599
|
}
|
|
600
600
|
if (typeof selectedSections === 'string') {
|
|
601
|
-
|
|
601
|
+
const index = sections.findIndex(section => section.type === selectedSections);
|
|
602
|
+
return index === -1 ? null : index;
|
|
602
603
|
}
|
|
603
604
|
return selectedSections;
|
|
604
605
|
};
|
|
@@ -129,7 +129,8 @@ const usePickerValue = ({
|
|
|
129
129
|
value: inValueWithoutRenderTimezone,
|
|
130
130
|
defaultValue: inDefaultValue,
|
|
131
131
|
closeOnSelect = wrapperVariant === 'desktop',
|
|
132
|
-
timezone: timezoneProp
|
|
132
|
+
timezone: timezoneProp,
|
|
133
|
+
referenceDate
|
|
133
134
|
} = props;
|
|
134
135
|
const {
|
|
135
136
|
current: defaultValue
|
|
@@ -137,6 +138,7 @@ const usePickerValue = ({
|
|
|
137
138
|
const {
|
|
138
139
|
current: isControlled
|
|
139
140
|
} = React.useRef(inValueWithoutRenderTimezone !== undefined);
|
|
141
|
+
const [previousTimezoneProp, setPreviousTimezoneProp] = React.useState(timezoneProp);
|
|
140
142
|
|
|
141
143
|
/* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
|
|
142
144
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -167,6 +169,7 @@ const usePickerValue = ({
|
|
|
167
169
|
timezone: timezoneProp,
|
|
168
170
|
value: inValueWithoutRenderTimezone,
|
|
169
171
|
defaultValue,
|
|
172
|
+
referenceDate,
|
|
170
173
|
onChange,
|
|
171
174
|
valueManager
|
|
172
175
|
});
|
|
@@ -183,10 +186,19 @@ const usePickerValue = ({
|
|
|
183
186
|
draft: initialValue,
|
|
184
187
|
lastPublishedValue: initialValue,
|
|
185
188
|
lastCommittedValue: initialValue,
|
|
186
|
-
lastControlledValue:
|
|
189
|
+
lastControlledValue: inValueWithoutRenderTimezone,
|
|
187
190
|
hasBeenModifiedSinceMount: false
|
|
188
191
|
};
|
|
189
192
|
});
|
|
193
|
+
const timezoneFromDraftValue = valueManager.getTimezone(utils, dateState.draft);
|
|
194
|
+
if (previousTimezoneProp !== timezoneProp) {
|
|
195
|
+
setPreviousTimezoneProp(timezoneProp);
|
|
196
|
+
if (timezoneProp && timezoneFromDraftValue && timezoneProp !== timezoneFromDraftValue) {
|
|
197
|
+
setDateState(prev => (0, _extends2.default)({}, prev, {
|
|
198
|
+
draft: valueManager.setTimezone(utils, timezoneProp, prev.draft)
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
190
202
|
const {
|
|
191
203
|
getValidationErrorForNewValue
|
|
192
204
|
} = (0, _validation.useValidation)({
|
|
@@ -236,10 +248,10 @@ const usePickerValue = ({
|
|
|
236
248
|
setIsOpen(false);
|
|
237
249
|
}
|
|
238
250
|
});
|
|
239
|
-
if (
|
|
251
|
+
if (dateState.lastControlledValue !== inValueWithoutRenderTimezone) {
|
|
240
252
|
const isUpdateComingFromPicker = valueManager.areValuesEqual(utils, dateState.draft, inValueWithTimezoneToRender);
|
|
241
253
|
setDateState(prev => (0, _extends2.default)({}, prev, {
|
|
242
|
-
lastControlledValue:
|
|
254
|
+
lastControlledValue: inValueWithoutRenderTimezone
|
|
243
255
|
}, isUpdateComingFromPicker ? {} : {
|
|
244
256
|
lastCommittedValue: inValueWithTimezoneToRender,
|
|
245
257
|
lastPublishedValue: inValueWithTimezoneToRender,
|
|
@@ -19,6 +19,7 @@ const useValueWithTimezone = ({
|
|
|
19
19
|
timezone: timezoneProp,
|
|
20
20
|
value: valueProp,
|
|
21
21
|
defaultValue,
|
|
22
|
+
referenceDate,
|
|
22
23
|
onChange,
|
|
23
24
|
valueManager
|
|
24
25
|
}) => {
|
|
@@ -32,7 +33,16 @@ const useValueWithTimezone = ({
|
|
|
32
33
|
}
|
|
33
34
|
return valueManager.setTimezone(utils, inputTimezone, newValue);
|
|
34
35
|
});
|
|
35
|
-
|
|
36
|
+
let timezoneToRender;
|
|
37
|
+
if (timezoneProp) {
|
|
38
|
+
timezoneToRender = timezoneProp;
|
|
39
|
+
} else if (inputTimezone) {
|
|
40
|
+
timezoneToRender = inputTimezone;
|
|
41
|
+
} else if (referenceDate) {
|
|
42
|
+
timezoneToRender = utils.getTimezone(referenceDate);
|
|
43
|
+
} else {
|
|
44
|
+
timezoneToRender = 'default';
|
|
45
|
+
}
|
|
36
46
|
const valueWithTimezoneToRender = React.useMemo(() => valueManager.setTimezone(utils, timezoneToRender, inputValue), [valueManager, utils, timezoneToRender, inputValue]);
|
|
37
47
|
const handleValueChange = (0, _useEventCallback.default)((newValue, ...otherParams) => {
|
|
38
48
|
const newValueWithInputTimezone = setInputTimezone(newValue);
|
|
@@ -54,6 +64,7 @@ const useControlledValueWithTimezone = ({
|
|
|
54
64
|
timezone: timezoneProp,
|
|
55
65
|
value: valueProp,
|
|
56
66
|
defaultValue,
|
|
67
|
+
referenceDate,
|
|
57
68
|
onChange: onChangeProp,
|
|
58
69
|
valueManager
|
|
59
70
|
}) => {
|
|
@@ -71,6 +82,7 @@ const useControlledValueWithTimezone = ({
|
|
|
71
82
|
timezone: timezoneProp,
|
|
72
83
|
value: valueWithInputTimezone,
|
|
73
84
|
defaultValue: undefined,
|
|
85
|
+
referenceDate,
|
|
74
86
|
onChange,
|
|
75
87
|
valueManager
|
|
76
88
|
});
|
package/node/locales/nlNL.js
CHANGED
|
@@ -22,10 +22,10 @@ const nlNLPickers = {
|
|
|
22
22
|
// DateRange labels
|
|
23
23
|
start: 'Start',
|
|
24
24
|
end: 'Einde',
|
|
25
|
-
startDate: '
|
|
26
|
-
startTime: '
|
|
27
|
-
endDate: '
|
|
28
|
-
endTime: '
|
|
25
|
+
startDate: 'Startdatum',
|
|
26
|
+
startTime: 'Starttijd',
|
|
27
|
+
endDate: 'Einddatum',
|
|
28
|
+
endTime: 'Eindtijd',
|
|
29
29
|
// Action bar
|
|
30
30
|
cancelButtonLabel: 'Annuleren',
|
|
31
31
|
clearButtonLabel: 'Resetten',
|
|
@@ -56,11 +56,11 @@ const nlNLPickers = {
|
|
|
56
56
|
timeTableLabel: 'kies tijd',
|
|
57
57
|
dateTableLabel: 'kies datum',
|
|
58
58
|
// Field section placeholders
|
|
59
|
-
fieldYearPlaceholder: params => '
|
|
59
|
+
fieldYearPlaceholder: params => 'J'.repeat(params.digitAmount),
|
|
60
60
|
fieldMonthPlaceholder: params => params.contentType === 'letter' ? 'MMMM' : 'MM',
|
|
61
61
|
fieldDayPlaceholder: () => 'DD',
|
|
62
62
|
fieldWeekDayPlaceholder: params => params.contentType === 'letter' ? 'EEEE' : 'EE',
|
|
63
|
-
fieldHoursPlaceholder: () => '
|
|
63
|
+
fieldHoursPlaceholder: () => 'uu',
|
|
64
64
|
fieldMinutesPlaceholder: () => 'mm',
|
|
65
65
|
fieldSecondsPlaceholder: () => 'ss',
|
|
66
66
|
fieldMeridiemPlaceholder: () => 'aa',
|
|
@@ -74,6 +74,6 @@ const nlNLPickers = {
|
|
|
74
74
|
seconds: 'Seconden',
|
|
75
75
|
meridiem: 'Middag',
|
|
76
76
|
// Common
|
|
77
|
-
empty: '
|
|
77
|
+
empty: 'Leeg'
|
|
78
78
|
};
|
|
79
79
|
const nlNL = exports.nlNL = (0, _getPickersLocalization.getPickersLocalization)(nlNLPickers);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-date-pickers",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.23.0",
|
|
4
4
|
"description": "The community edition of the Date and Time Picker components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"clsx": "^2.1.1",
|
|
42
42
|
"prop-types": "^15.8.1",
|
|
43
43
|
"react-transition-group": "^4.4.5",
|
|
44
|
-
"@mui/x-internals": "7.
|
|
44
|
+
"@mui/x-internals": "7.23.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@emotion/react": "^11.9.0",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"moment": "^2.29.4",
|
|
56
56
|
"moment-hijri": "^2.1.2 || ^3.0.0",
|
|
57
57
|
"moment-jalaali": "^0.7.4 || ^0.8.0 || ^0.9.0 || ^0.10.0",
|
|
58
|
-
"react": "^17.0.0 || ^18.0.0",
|
|
59
|
-
"react-dom": "^17.0.0 || ^18.0.0"
|
|
58
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
59
|
+
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|
|
62
62
|
"@emotion/react": {
|