@mui/x-date-pickers 8.9.2 → 8.10.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.
Files changed (30) hide show
  1. package/AdapterDateFns/AdapterDateFns.js +194 -193
  2. package/AdapterDateFnsBase/AdapterDateFnsBase.js +57 -60
  3. package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +197 -196
  4. package/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +195 -195
  5. package/AdapterDateFnsV2/AdapterDateFnsV2.js +192 -192
  6. package/AdapterDayjs/AdapterDayjs.js +378 -378
  7. package/AdapterLuxon/AdapterLuxon.js +324 -324
  8. package/AdapterMoment/AdapterMoment.js +297 -300
  9. package/AdapterMomentHijri/AdapterMomentHijri.js +78 -77
  10. package/AdapterMomentJalaali/AdapterMomentJalaali.js +78 -79
  11. package/CHANGELOG.md +303 -6
  12. package/PickersLayout/PickersLayout.js +12 -9
  13. package/PickersLayout/PickersLayout.types.d.ts +5 -0
  14. package/PickersLayout/usePickerLayout.js +6 -2
  15. package/esm/AdapterDateFns/AdapterDateFns.js +194 -193
  16. package/esm/AdapterDateFnsBase/AdapterDateFnsBase.js +57 -60
  17. package/esm/AdapterDateFnsJalali/AdapterDateFnsJalali.js +197 -196
  18. package/esm/AdapterDateFnsJalaliV2/AdapterDateFnsJalaliV2.js +195 -195
  19. package/esm/AdapterDateFnsV2/AdapterDateFnsV2.js +192 -192
  20. package/esm/AdapterDayjs/AdapterDayjs.js +378 -378
  21. package/esm/AdapterLuxon/AdapterLuxon.js +324 -324
  22. package/esm/AdapterMoment/AdapterMoment.js +297 -300
  23. package/esm/AdapterMomentHijri/AdapterMomentHijri.js +78 -77
  24. package/esm/AdapterMomentJalaali/AdapterMomentJalaali.js +78 -79
  25. package/esm/PickersLayout/PickersLayout.js +12 -9
  26. package/esm/PickersLayout/PickersLayout.types.d.ts +5 -0
  27. package/esm/PickersLayout/usePickerLayout.js +6 -2
  28. package/esm/index.js +1 -1
  29. package/index.js +1 -1
  30. package/package.json +7 -9
@@ -130,6 +130,9 @@ const NUMBER_SYMBOL_MAP = {
130
130
  * SOFTWARE.
131
131
  */
132
132
  export class AdapterMomentHijri extends AdapterMoment {
133
+ lib = 'moment-hijri';
134
+ isTimezoneCompatible = false;
135
+ formatTokenMap = (() => formatTokenMap)();
133
136
  constructor({
134
137
  formats,
135
138
  instance
@@ -138,85 +141,83 @@ export class AdapterMomentHijri extends AdapterMoment {
138
141
  locale: 'ar-SA',
139
142
  instance
140
143
  });
141
- this.lib = 'moment-hijri';
142
- this.moment = void 0;
143
- this.isTimezoneCompatible = false;
144
- this.formatTokenMap = formatTokenMap;
145
- this.date = value => {
146
- if (value === null) {
147
- return null;
148
- }
149
- return this.moment(value).locale('ar-SA');
150
- };
151
- /* v8 ignore next 3 */
152
- this.getTimezone = () => {
153
- return 'default';
154
- };
155
- /* v8 ignore next 3 */
156
- this.setTimezone = value => {
157
- return value;
158
- };
159
- this.parse = (value, format) => {
160
- if (value === '') {
161
- return null;
162
- }
163
- return this.moment(value, format, true).locale('ar-SA');
164
- };
165
- this.formatNumber = numberToFormat => {
166
- return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
167
- };
168
- this.startOfYear = value => {
169
- return value.clone().startOf('iYear');
170
- };
171
- this.startOfMonth = value => {
172
- return value.clone().startOf('iMonth');
173
- };
174
- this.endOfYear = value => {
175
- return value.clone().endOf('iYear');
176
- };
177
- this.endOfMonth = value => {
178
- return value.clone().endOf('iMonth');
179
- };
180
- this.addYears = (value, amount) => {
181
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'iYear') : value.clone().add(amount, 'iYear');
182
- };
183
- this.addMonths = (value, amount) => {
184
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'iMonth') : value.clone().add(amount, 'iMonth');
185
- };
186
- this.getYear = value => {
187
- return value.iYear();
188
- };
189
- this.getMonth = value => {
190
- return value.iMonth();
191
- };
192
- this.getDate = value => {
193
- return value.iDate();
194
- };
195
- this.setYear = (value, year) => {
196
- return value.clone().iYear(year);
197
- };
198
- this.setMonth = (value, month) => {
199
- return value.clone().iMonth(month);
200
- };
201
- this.setDate = (value, date) => {
202
- return value.clone().iDate(date);
203
- };
204
- this.getWeekNumber = value => {
205
- return value.iWeek();
206
- };
207
- this.getYearRange = ([start, end]) => {
208
- // moment-hijri only supports dates between 1356-01-01 H and 1499-12-29 H
209
- // We need to throw if outside min/max bounds, otherwise the while loop below will be infinite.
210
- if (start.isBefore('1937-03-14')) {
211
- throw new Error('min date must be on or after 1356-01-01 H (1937-03-14)');
212
- }
213
- if (end.isAfter('2076-11-26')) {
214
- throw new Error('max date must be on or before 1499-12-29 H (2076-11-26)');
215
- }
216
- return super.getYearRange([start, end]);
217
- };
218
144
  this.moment = instance || defaultHMoment;
219
145
  this.locale = 'ar-SA';
220
146
  this.formats = _extends({}, defaultFormats, formats);
221
147
  }
148
+ date = value => {
149
+ if (value === null) {
150
+ return null;
151
+ }
152
+ return this.moment(value).locale('ar-SA');
153
+ };
154
+
155
+ /* v8 ignore next 3 */
156
+ getTimezone = () => {
157
+ return 'default';
158
+ };
159
+
160
+ /* v8 ignore next 3 */
161
+ setTimezone = value => {
162
+ return value;
163
+ };
164
+ parse = (value, format) => {
165
+ if (value === '') {
166
+ return null;
167
+ }
168
+ return this.moment(value, format, true).locale('ar-SA');
169
+ };
170
+ formatNumber = numberToFormat => {
171
+ return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
172
+ };
173
+ startOfYear = value => {
174
+ return value.clone().startOf('iYear');
175
+ };
176
+ startOfMonth = value => {
177
+ return value.clone().startOf('iMonth');
178
+ };
179
+ endOfYear = value => {
180
+ return value.clone().endOf('iYear');
181
+ };
182
+ endOfMonth = value => {
183
+ return value.clone().endOf('iMonth');
184
+ };
185
+ addYears = (value, amount) => {
186
+ return amount < 0 ? value.clone().subtract(Math.abs(amount), 'iYear') : value.clone().add(amount, 'iYear');
187
+ };
188
+ addMonths = (value, amount) => {
189
+ return amount < 0 ? value.clone().subtract(Math.abs(amount), 'iMonth') : value.clone().add(amount, 'iMonth');
190
+ };
191
+ getYear = value => {
192
+ return value.iYear();
193
+ };
194
+ getMonth = value => {
195
+ return value.iMonth();
196
+ };
197
+ getDate = value => {
198
+ return value.iDate();
199
+ };
200
+ setYear = (value, year) => {
201
+ return value.clone().iYear(year);
202
+ };
203
+ setMonth = (value, month) => {
204
+ return value.clone().iMonth(month);
205
+ };
206
+ setDate = (value, date) => {
207
+ return value.clone().iDate(date);
208
+ };
209
+ getWeekNumber = value => {
210
+ return value.iWeek();
211
+ };
212
+ getYearRange = ([start, end]) => {
213
+ // moment-hijri only supports dates between 1356-01-01 H and 1499-12-29 H
214
+ // We need to throw if outside min/max bounds, otherwise the while loop below will be infinite.
215
+ if (start.isBefore('1937-03-14')) {
216
+ throw new Error('min date must be on or after 1356-01-01 H (1937-03-14)');
217
+ }
218
+ if (end.isAfter('2076-11-26')) {
219
+ throw new Error('max date must be on or before 1499-12-29 H (2076-11-26)');
220
+ }
221
+ return super.getYearRange([start, end]);
222
+ };
222
223
  }
@@ -128,6 +128,9 @@ const NUMBER_SYMBOL_MAP = {
128
128
  * SOFTWARE.
129
129
  */
130
130
  export class AdapterMomentJalaali extends AdapterMoment {
131
+ isTimezoneCompatible = false;
132
+ lib = 'moment-jalaali';
133
+ formatTokenMap = (() => formatTokenMap)();
131
134
  constructor({
132
135
  formats,
133
136
  instance
@@ -136,87 +139,83 @@ export class AdapterMomentJalaali extends AdapterMoment {
136
139
  locale: 'fa',
137
140
  instance
138
141
  });
139
- this.isTimezoneCompatible = false;
140
- this.lib = 'moment-jalaali';
141
- this.moment = void 0;
142
- this.formatTokenMap = formatTokenMap;
143
- this.date = value => {
144
- if (value === null) {
145
- return null;
146
- }
147
- return this.moment(value).locale('fa');
148
- };
149
- this.getTimezone = () => {
150
- return 'default';
151
- };
152
- this.setTimezone = value => {
153
- return value;
154
- };
155
- this.parse = (value, format) => {
156
- if (value === '') {
157
- return null;
158
- }
159
- return this.moment(value, format, true).locale('fa');
160
- };
161
- this.formatNumber = numberToFormat => {
162
- return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
163
- };
164
- this.isSameYear = (value, comparing) => {
165
- return value.jYear() === comparing.jYear();
166
- };
167
- this.isSameMonth = (value, comparing) => {
168
- return value.jYear() === comparing.jYear() && value.jMonth() === comparing.jMonth();
169
- };
170
- this.isAfterYear = (value, comparing) => {
171
- return value.jYear() > comparing.jYear();
172
- };
173
- this.isBeforeYear = (value, comparing) => {
174
- return value.jYear() < comparing.jYear();
175
- };
176
- this.startOfYear = value => {
177
- return value.clone().startOf('jYear');
178
- };
179
- this.startOfMonth = value => {
180
- return value.clone().startOf('jMonth');
181
- };
182
- this.endOfYear = value => {
183
- return value.clone().endOf('jYear');
184
- };
185
- this.endOfMonth = value => {
186
- return value.clone().endOf('jMonth');
187
- };
188
- this.addYears = (value, amount) => {
189
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'jYear') : value.clone().add(amount, 'jYear');
190
- };
191
- this.addMonths = (value, amount) => {
192
- return amount < 0 ? value.clone().subtract(Math.abs(amount), 'jMonth') : value.clone().add(amount, 'jMonth');
193
- };
194
- this.getYear = value => {
195
- return value.jYear();
196
- };
197
- this.getMonth = value => {
198
- return value.jMonth();
199
- };
200
- this.getDate = value => {
201
- return value.jDate();
202
- };
203
- this.getDaysInMonth = value => {
204
- return this.moment.jDaysInMonth(value.jYear(), value.jMonth());
205
- };
206
- this.setYear = (value, year) => {
207
- return value.clone().jYear(year);
208
- };
209
- this.setMonth = (value, month) => {
210
- return value.clone().jMonth(month);
211
- };
212
- this.setDate = (value, date) => {
213
- return value.clone().jDate(date);
214
- };
215
- this.getWeekNumber = value => {
216
- return value.jWeek();
217
- };
218
142
  this.moment = instance || defaultJMoment;
219
143
  this.locale = 'fa';
220
144
  this.formats = _extends({}, defaultFormats, formats);
221
145
  }
146
+ date = value => {
147
+ if (value === null) {
148
+ return null;
149
+ }
150
+ return this.moment(value).locale('fa');
151
+ };
152
+ getTimezone = () => {
153
+ return 'default';
154
+ };
155
+ setTimezone = value => {
156
+ return value;
157
+ };
158
+ parse = (value, format) => {
159
+ if (value === '') {
160
+ return null;
161
+ }
162
+ return this.moment(value, format, true).locale('fa');
163
+ };
164
+ formatNumber = numberToFormat => {
165
+ return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
166
+ };
167
+ isSameYear = (value, comparing) => {
168
+ return value.jYear() === comparing.jYear();
169
+ };
170
+ isSameMonth = (value, comparing) => {
171
+ return value.jYear() === comparing.jYear() && value.jMonth() === comparing.jMonth();
172
+ };
173
+ isAfterYear = (value, comparing) => {
174
+ return value.jYear() > comparing.jYear();
175
+ };
176
+ isBeforeYear = (value, comparing) => {
177
+ return value.jYear() < comparing.jYear();
178
+ };
179
+ startOfYear = value => {
180
+ return value.clone().startOf('jYear');
181
+ };
182
+ startOfMonth = value => {
183
+ return value.clone().startOf('jMonth');
184
+ };
185
+ endOfYear = value => {
186
+ return value.clone().endOf('jYear');
187
+ };
188
+ endOfMonth = value => {
189
+ return value.clone().endOf('jMonth');
190
+ };
191
+ addYears = (value, amount) => {
192
+ return amount < 0 ? value.clone().subtract(Math.abs(amount), 'jYear') : value.clone().add(amount, 'jYear');
193
+ };
194
+ addMonths = (value, amount) => {
195
+ return amount < 0 ? value.clone().subtract(Math.abs(amount), 'jMonth') : value.clone().add(amount, 'jMonth');
196
+ };
197
+ getYear = value => {
198
+ return value.jYear();
199
+ };
200
+ getMonth = value => {
201
+ return value.jMonth();
202
+ };
203
+ getDate = value => {
204
+ return value.jDate();
205
+ };
206
+ getDaysInMonth = value => {
207
+ return this.moment.jDaysInMonth(value.jYear(), value.jMonth());
208
+ };
209
+ setYear = (value, year) => {
210
+ return value.clone().jYear(year);
211
+ };
212
+ setMonth = (value, month) => {
213
+ return value.clone().jMonth(month);
214
+ };
215
+ setDate = (value, date) => {
216
+ return value.clone().jDate(date);
217
+ };
218
+ getWeekNumber = value => {
219
+ return value.jWeek();
220
+ };
222
221
  }
@@ -32,26 +32,29 @@ export const PickersLayoutRoot = styled('div', {
32
32
  },
33
33
  variants: [{
34
34
  props: {
35
- pickerOrientation: 'landscape'
35
+ pickerOrientation: 'landscape',
36
+ hasShortcuts: false
36
37
  },
37
38
  style: {
38
39
  [`& .${pickersLayoutClasses.toolbar}`]: {
39
40
  gridColumn: 1,
40
- gridRow: '2 / 3'
41
- },
42
- [`.${pickersLayoutClasses.shortcuts}`]: {
43
- gridColumn: '2 / 4',
44
- gridRow: 1
41
+ gridRow: '1 / 3'
45
42
  }
46
43
  }
47
44
  }, {
48
45
  props: {
49
46
  pickerOrientation: 'landscape',
50
- layoutDirection: 'rtl'
47
+ hasShortcuts: true
51
48
  },
52
49
  style: {
53
50
  [`& .${pickersLayoutClasses.toolbar}`]: {
54
- gridColumn: 3
51
+ gridColumn: '2 / 4',
52
+ gridRow: 1,
53
+ maxWidth: 'max-content'
54
+ },
55
+ [`& .${pickersLayoutClasses.shortcuts}`]: {
56
+ gridColumn: 1,
57
+ gridRow: 2
55
58
  }
56
59
  }
57
60
  }, {
@@ -70,7 +73,7 @@ export const PickersLayoutRoot = styled('div', {
70
73
  }
71
74
  }, {
72
75
  props: {
73
- pickerOrientation: 'portrait',
76
+ hasShortcuts: true,
74
77
  layoutDirection: 'rtl'
75
78
  },
76
79
  style: {
@@ -33,6 +33,11 @@ export interface PickerLayoutOwnerState extends PickerOwnerState {
33
33
  * Is equal to "rtl" when the layout is in right-to-left direction.
34
34
  */
35
35
  layoutDirection: 'ltr' | 'rtl';
36
+ /**
37
+ * Whether the layout should display the shortcuts panel or not.
38
+ * This flag is used to adjust the layout accordingly.
39
+ */
40
+ hasShortcuts: boolean;
36
41
  }
37
42
  export interface ExportedPickersLayoutSlotProps<TValue extends PickerValidValue> {
38
43
  /**
@@ -47,7 +47,8 @@ const usePickerLayout = props => {
47
47
  classes: classesProp
48
48
  } = props;
49
49
  const ownerState = React.useMemo(() => _extends({}, pickerOwnerState, {
50
- layoutDirection: isRtl ? 'rtl' : 'ltr'
50
+ layoutDirection: isRtl ? 'rtl' : 'ltr',
51
+ hasShortcuts: false
51
52
  }), [pickerOwnerState, isRtl]);
52
53
  const classes = useUtilityClasses(classesProp, ownerState);
53
54
 
@@ -92,6 +93,7 @@ const usePickerLayout = props => {
92
93
  className: classes.shortcuts,
93
94
  ownerState
94
95
  });
96
+ const hasShortcuts = Array.isArray(shortcutsProps?.items) && shortcutsProps.items.length > 0;
95
97
  const shortcuts = view && !!Shortcuts ? /*#__PURE__*/_jsx(Shortcuts, _extends({}, shortcutsProps)) : null;
96
98
  return {
97
99
  toolbar,
@@ -99,7 +101,9 @@ const usePickerLayout = props => {
99
101
  tabs,
100
102
  actionBar,
101
103
  shortcuts,
102
- ownerState
104
+ ownerState: _extends({}, ownerState, {
105
+ hasShortcuts
106
+ })
103
107
  };
104
108
  };
105
109
  export default usePickerLayout;
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v8.9.2
2
+ * @mui/x-date-pickers v8.10.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-date-pickers v8.9.2
2
+ * @mui/x-date-pickers v8.10.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-date-pickers",
3
- "version": "8.9.2",
3
+ "version": "8.10.2",
4
4
  "author": "MUI Team",
5
5
  "description": "The community edition of the MUI X Date and Time Picker components.",
6
6
  "main": "./index.js",
@@ -35,12 +35,12 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@babel/runtime": "^7.28.2",
38
- "@mui/utils": "^7.2.0",
38
+ "@mui/utils": "^7.3.1",
39
39
  "@types/react-transition-group": "^4.4.12",
40
40
  "clsx": "^2.1.1",
41
41
  "prop-types": "^15.8.1",
42
42
  "react-transition-group": "^4.4.5",
43
- "@mui/x-internals": "8.9.2"
43
+ "@mui/x-internals": "8.10.2"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@emotion/react": "^11.9.0",
@@ -89,8 +89,8 @@
89
89
  "engines": {
90
90
  "node": ">=14.0.0"
91
91
  },
92
- "private": false,
93
- "module": "./esm/index.js",
92
+ "type": "commonjs",
93
+ "types": "./index.d.ts",
94
94
  "exports": {
95
95
  "./package.json": "./package.json",
96
96
  ".": {
@@ -113,8 +113,6 @@
113
113
  "default": "./esm/*/index.js"
114
114
  }
115
115
  },
116
- "./esm": null,
117
- "./modern": null
118
- },
119
- "types": "./index.d.ts"
116
+ "./esm": null
117
+ }
120
118
  }