@mui/x-date-pickers 7.3.2 → 7.5.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/AdapterDateFns/AdapterDateFns.d.ts +5 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +1 -5
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -2
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +3 -20
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +14 -224
- package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.d.ts +87 -0
- package/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +332 -0
- package/AdapterDateFnsJalaliV3/index.d.ts +1 -0
- package/AdapterDateFnsJalaliV3/index.js +1 -0
- package/AdapterDateFnsJalaliV3/package.json +6 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +5 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -1
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +2 -6
- package/CHANGELOG.md +160 -2
- package/DateCalendar/DateCalendar.js +5 -4
- package/PickersLayout/usePickerLayout.js +6 -7
- package/PickersShortcuts/PickersShortcuts.d.ts +5 -0
- package/PickersShortcuts/PickersShortcuts.js +4 -3
- package/index.js +1 -1
- package/internals/components/PickersModalDialog.d.ts +2 -2
- package/internals/demo/DemoContainer.js +1 -1
- package/internals/hooks/useField/useField.js +0 -5
- package/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/internals/hooks/useField/useFieldV7TextField.js +5 -0
- package/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -2
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +14 -224
- package/modern/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +332 -0
- package/modern/AdapterDateFnsJalaliV3/index.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +0 -1
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +2 -6
- package/modern/DateCalendar/DateCalendar.js +5 -4
- package/modern/PickersLayout/usePickerLayout.js +6 -7
- package/modern/PickersShortcuts/PickersShortcuts.js +4 -3
- package/modern/index.js +1 -1
- package/modern/internals/demo/DemoContainer.js +1 -1
- package/modern/internals/hooks/useField/useField.js +0 -5
- package/modern/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/modern/internals/hooks/useField/useFieldV7TextField.js +5 -0
- package/modern/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +4 -2
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +14 -224
- package/node/AdapterDateFnsJalaliV3/AdapterDateFnsJalaliV3.js +341 -0
- package/node/AdapterDateFnsJalaliV3/index.js +12 -0
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +2 -6
- package/node/DateCalendar/DateCalendar.js +5 -4
- package/node/PickersLayout/usePickerLayout.js +6 -7
- package/node/PickersShortcuts/PickersShortcuts.js +4 -3
- package/node/index.js +1 -1
- package/node/internals/demo/DemoContainer.js +1 -1
- package/node/internals/hooks/useField/useField.js +0 -5
- package/node/internals/hooks/useField/useFieldV6TextField.js +1 -1
- package/node/internals/hooks/useField/useFieldV7TextField.js +5 -0
- package/node/internals/hooks/usePicker/usePickerViews.js +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
/* eslint-disable class-methods-use-this */
|
|
3
|
+
// TODO remove when date-fns-jalali-v3 is the default
|
|
4
|
+
// @ts-nocheck
|
|
5
|
+
import { addSeconds } from 'date-fns-jalali/addSeconds';
|
|
6
|
+
import { addMinutes } from 'date-fns-jalali/addMinutes';
|
|
7
|
+
import { addHours } from 'date-fns-jalali/addHours';
|
|
8
|
+
import { addDays } from 'date-fns-jalali/addDays';
|
|
9
|
+
import { addWeeks } from 'date-fns-jalali/addWeeks';
|
|
10
|
+
import { addMonths } from 'date-fns-jalali/addMonths';
|
|
11
|
+
import { addYears } from 'date-fns-jalali/addYears';
|
|
12
|
+
import { endOfDay } from 'date-fns-jalali/endOfDay';
|
|
13
|
+
import { endOfWeek } from 'date-fns-jalali/endOfWeek';
|
|
14
|
+
import { endOfYear } from 'date-fns-jalali/endOfYear';
|
|
15
|
+
import { format as dateFnsFormat, longFormatters } from 'date-fns-jalali/format';
|
|
16
|
+
import { getHours } from 'date-fns-jalali/getHours';
|
|
17
|
+
import { getSeconds } from 'date-fns-jalali/getSeconds';
|
|
18
|
+
import { getMilliseconds } from 'date-fns-jalali/getMilliseconds';
|
|
19
|
+
import { getWeek } from 'date-fns-jalali/getWeek';
|
|
20
|
+
import { getYear } from 'date-fns-jalali/getYear';
|
|
21
|
+
import { getMonth } from 'date-fns-jalali/getMonth';
|
|
22
|
+
import { getDate } from 'date-fns-jalali/getDate';
|
|
23
|
+
import { getDaysInMonth } from 'date-fns-jalali/getDaysInMonth';
|
|
24
|
+
import { getMinutes } from 'date-fns-jalali/getMinutes';
|
|
25
|
+
import { isAfter } from 'date-fns-jalali/isAfter';
|
|
26
|
+
import { isBefore } from 'date-fns-jalali/isBefore';
|
|
27
|
+
import { isEqual } from 'date-fns-jalali/isEqual';
|
|
28
|
+
import { isSameDay } from 'date-fns-jalali/isSameDay';
|
|
29
|
+
import { isSameYear } from 'date-fns-jalali/isSameYear';
|
|
30
|
+
import { isSameMonth } from 'date-fns-jalali/isSameMonth';
|
|
31
|
+
import { isSameHour } from 'date-fns-jalali/isSameHour';
|
|
32
|
+
import { isValid } from 'date-fns-jalali/isValid';
|
|
33
|
+
import { parse as dateFnsParse } from 'date-fns-jalali/parse';
|
|
34
|
+
import { setDate } from 'date-fns-jalali/setDate';
|
|
35
|
+
import { setHours } from 'date-fns-jalali/setHours';
|
|
36
|
+
import { setMinutes } from 'date-fns-jalali/setMinutes';
|
|
37
|
+
import { setMonth } from 'date-fns-jalali/setMonth';
|
|
38
|
+
import { setSeconds } from 'date-fns-jalali/setSeconds';
|
|
39
|
+
import { setMilliseconds } from 'date-fns-jalali/setMilliseconds';
|
|
40
|
+
import { setYear } from 'date-fns-jalali/setYear';
|
|
41
|
+
import { startOfDay } from 'date-fns-jalali/startOfDay';
|
|
42
|
+
import { startOfMonth } from 'date-fns-jalali/startOfMonth';
|
|
43
|
+
import { endOfMonth } from 'date-fns-jalali/endOfMonth';
|
|
44
|
+
import { startOfWeek } from 'date-fns-jalali/startOfWeek';
|
|
45
|
+
import { startOfYear } from 'date-fns-jalali/startOfYear';
|
|
46
|
+
import { isWithinInterval } from 'date-fns-jalali/isWithinInterval';
|
|
47
|
+
import { faIR as defaultLocale } from 'date-fns-jalali/locale/fa-IR';
|
|
48
|
+
// date-fns-jalali v2 does not export types
|
|
49
|
+
// @ts-ignore TODO remove when date-fns-jalali-v3 is the default
|
|
50
|
+
|
|
51
|
+
import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
|
|
52
|
+
const defaultFormats = {
|
|
53
|
+
year: 'yyyy',
|
|
54
|
+
month: 'LLLL',
|
|
55
|
+
monthShort: 'MMM',
|
|
56
|
+
dayOfMonth: 'd',
|
|
57
|
+
dayOfMonthFull: 'do',
|
|
58
|
+
weekday: 'EEEE',
|
|
59
|
+
weekdayShort: 'EEEEEE',
|
|
60
|
+
hours24h: 'HH',
|
|
61
|
+
hours12h: 'hh',
|
|
62
|
+
meridiem: 'aa',
|
|
63
|
+
minutes: 'mm',
|
|
64
|
+
seconds: 'ss',
|
|
65
|
+
fullDate: 'PPP',
|
|
66
|
+
keyboardDate: 'P',
|
|
67
|
+
shortDate: 'd MMM',
|
|
68
|
+
normalDate: 'd MMMM',
|
|
69
|
+
normalDateWithWeekday: 'EEE, d MMMM',
|
|
70
|
+
fullTime: 'p',
|
|
71
|
+
fullTime12h: 'hh:mm aaa',
|
|
72
|
+
fullTime24h: 'HH:mm',
|
|
73
|
+
keyboardDateTime: 'P p',
|
|
74
|
+
keyboardDateTime12h: 'P hh:mm aa',
|
|
75
|
+
keyboardDateTime24h: 'P HH:mm'
|
|
76
|
+
};
|
|
77
|
+
const NUMBER_SYMBOL_MAP = {
|
|
78
|
+
'1': '۱',
|
|
79
|
+
'2': '۲',
|
|
80
|
+
'3': '۳',
|
|
81
|
+
'4': '۴',
|
|
82
|
+
'5': '۵',
|
|
83
|
+
'6': '۶',
|
|
84
|
+
'7': '۷',
|
|
85
|
+
'8': '۸',
|
|
86
|
+
'9': '۹',
|
|
87
|
+
'0': '۰'
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Based on `@date-io/date-fns-jalali`
|
|
91
|
+
*
|
|
92
|
+
* MIT License
|
|
93
|
+
*
|
|
94
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
95
|
+
*
|
|
96
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
97
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
98
|
+
* in the Software without restriction, including without limitation the rights
|
|
99
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
100
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
101
|
+
* furnished to do so, subject to the following conditions:
|
|
102
|
+
*
|
|
103
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
104
|
+
* copies or substantial portions of the Software.
|
|
105
|
+
*
|
|
106
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
107
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
108
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
109
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
110
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
111
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
112
|
+
* SOFTWARE.
|
|
113
|
+
*/
|
|
114
|
+
export class AdapterDateFnsJalali extends AdapterDateFnsBase {
|
|
115
|
+
constructor({
|
|
116
|
+
locale,
|
|
117
|
+
formats
|
|
118
|
+
} = {}) {
|
|
119
|
+
if (typeof addDays !== 'function') {
|
|
120
|
+
throw new Error([`MUI: The \`date-fns-jalali\` package v2.x is not compatible with this adapter.`, 'Please, install v3.x of the package or use the `AdapterDateFnsJalali` instead.'].join('\n'));
|
|
121
|
+
}
|
|
122
|
+
if (!longFormatters) {
|
|
123
|
+
throw new Error('MUI: The minimum supported `date-fns-jalali` package version compatible with this adapter is `3.2.x`.');
|
|
124
|
+
}
|
|
125
|
+
super({
|
|
126
|
+
locale: locale ?? defaultLocale,
|
|
127
|
+
// some formats are different in jalali adapter,
|
|
128
|
+
// this ensures that `AdapterDateFnsBase` formats are overridden
|
|
129
|
+
formats: _extends({}, defaultFormats, formats),
|
|
130
|
+
longFormatters,
|
|
131
|
+
lib: 'date-fns-jalali'
|
|
132
|
+
});
|
|
133
|
+
this.parse = (value, format) => {
|
|
134
|
+
if (value === '') {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
return dateFnsParse(value, format, new Date(), {
|
|
138
|
+
locale: this.locale
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
this.getCurrentLocaleCode = () => {
|
|
142
|
+
return this.locale?.code || 'fa-IR';
|
|
143
|
+
};
|
|
144
|
+
this.isValid = value => {
|
|
145
|
+
if (value == null) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
return isValid(value);
|
|
149
|
+
};
|
|
150
|
+
this.format = (value, formatKey) => {
|
|
151
|
+
return this.formatByString(value, this.formats[formatKey]);
|
|
152
|
+
};
|
|
153
|
+
this.formatByString = (value, formatString) => {
|
|
154
|
+
return dateFnsFormat(value, formatString, {
|
|
155
|
+
locale: this.locale
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
this.formatNumber = numberToFormat => {
|
|
159
|
+
return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
|
|
160
|
+
};
|
|
161
|
+
this.isEqual = (value, comparing) => {
|
|
162
|
+
if (value === null && comparing === null) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
if (value === null || comparing === null) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
return isEqual(value, comparing);
|
|
169
|
+
};
|
|
170
|
+
this.isSameYear = (value, comparing) => {
|
|
171
|
+
return isSameYear(value, comparing);
|
|
172
|
+
};
|
|
173
|
+
this.isSameMonth = (value, comparing) => {
|
|
174
|
+
return isSameMonth(value, comparing);
|
|
175
|
+
};
|
|
176
|
+
this.isSameDay = (value, comparing) => {
|
|
177
|
+
return isSameDay(value, comparing);
|
|
178
|
+
};
|
|
179
|
+
this.isSameHour = (value, comparing) => {
|
|
180
|
+
return isSameHour(value, comparing);
|
|
181
|
+
};
|
|
182
|
+
this.isAfter = (value, comparing) => {
|
|
183
|
+
return isAfter(value, comparing);
|
|
184
|
+
};
|
|
185
|
+
this.isAfterYear = (value, comparing) => {
|
|
186
|
+
return isAfter(value, this.endOfYear(comparing));
|
|
187
|
+
};
|
|
188
|
+
this.isAfterDay = (value, comparing) => {
|
|
189
|
+
return isAfter(value, this.endOfDay(comparing));
|
|
190
|
+
};
|
|
191
|
+
this.isBefore = (value, comparing) => {
|
|
192
|
+
return isBefore(value, comparing);
|
|
193
|
+
};
|
|
194
|
+
this.isBeforeYear = (value, comparing) => {
|
|
195
|
+
return isBefore(value, this.startOfYear(comparing));
|
|
196
|
+
};
|
|
197
|
+
this.isBeforeDay = (value, comparing) => {
|
|
198
|
+
return isBefore(value, this.startOfDay(comparing));
|
|
199
|
+
};
|
|
200
|
+
this.isWithinRange = (value, [start, end]) => {
|
|
201
|
+
return isWithinInterval(value, {
|
|
202
|
+
start,
|
|
203
|
+
end
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
this.startOfYear = value => {
|
|
207
|
+
return startOfYear(value);
|
|
208
|
+
};
|
|
209
|
+
this.startOfMonth = value => {
|
|
210
|
+
return startOfMonth(value);
|
|
211
|
+
};
|
|
212
|
+
this.startOfWeek = value => {
|
|
213
|
+
return startOfWeek(value, {
|
|
214
|
+
locale: this.locale
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
this.startOfDay = value => {
|
|
218
|
+
return startOfDay(value);
|
|
219
|
+
};
|
|
220
|
+
this.endOfYear = value => {
|
|
221
|
+
return endOfYear(value);
|
|
222
|
+
};
|
|
223
|
+
this.endOfMonth = value => {
|
|
224
|
+
return endOfMonth(value);
|
|
225
|
+
};
|
|
226
|
+
this.endOfWeek = value => {
|
|
227
|
+
return endOfWeek(value, {
|
|
228
|
+
locale: this.locale
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
this.endOfDay = value => {
|
|
232
|
+
return endOfDay(value);
|
|
233
|
+
};
|
|
234
|
+
this.addYears = (value, amount) => {
|
|
235
|
+
return addYears(value, amount);
|
|
236
|
+
};
|
|
237
|
+
this.addMonths = (value, amount) => {
|
|
238
|
+
return addMonths(value, amount);
|
|
239
|
+
};
|
|
240
|
+
this.addWeeks = (value, amount) => {
|
|
241
|
+
return addWeeks(value, amount);
|
|
242
|
+
};
|
|
243
|
+
this.addDays = (value, amount) => {
|
|
244
|
+
return addDays(value, amount);
|
|
245
|
+
};
|
|
246
|
+
this.addHours = (value, amount) => {
|
|
247
|
+
return addHours(value, amount);
|
|
248
|
+
};
|
|
249
|
+
this.addMinutes = (value, amount) => {
|
|
250
|
+
return addMinutes(value, amount);
|
|
251
|
+
};
|
|
252
|
+
this.addSeconds = (value, amount) => {
|
|
253
|
+
return addSeconds(value, amount);
|
|
254
|
+
};
|
|
255
|
+
this.getYear = value => {
|
|
256
|
+
return getYear(value);
|
|
257
|
+
};
|
|
258
|
+
this.getMonth = value => {
|
|
259
|
+
return getMonth(value);
|
|
260
|
+
};
|
|
261
|
+
this.getDate = value => {
|
|
262
|
+
return getDate(value);
|
|
263
|
+
};
|
|
264
|
+
this.getHours = value => {
|
|
265
|
+
return getHours(value);
|
|
266
|
+
};
|
|
267
|
+
this.getMinutes = value => {
|
|
268
|
+
return getMinutes(value);
|
|
269
|
+
};
|
|
270
|
+
this.getSeconds = value => {
|
|
271
|
+
return getSeconds(value);
|
|
272
|
+
};
|
|
273
|
+
this.getMilliseconds = value => {
|
|
274
|
+
return getMilliseconds(value);
|
|
275
|
+
};
|
|
276
|
+
this.setYear = (value, year) => {
|
|
277
|
+
return setYear(value, year);
|
|
278
|
+
};
|
|
279
|
+
this.setMonth = (value, month) => {
|
|
280
|
+
return setMonth(value, month);
|
|
281
|
+
};
|
|
282
|
+
this.setDate = (value, date) => {
|
|
283
|
+
return setDate(value, date);
|
|
284
|
+
};
|
|
285
|
+
this.setHours = (value, hours) => {
|
|
286
|
+
return setHours(value, hours);
|
|
287
|
+
};
|
|
288
|
+
this.setMinutes = (value, minutes) => {
|
|
289
|
+
return setMinutes(value, minutes);
|
|
290
|
+
};
|
|
291
|
+
this.setSeconds = (value, seconds) => {
|
|
292
|
+
return setSeconds(value, seconds);
|
|
293
|
+
};
|
|
294
|
+
this.setMilliseconds = (value, milliseconds) => {
|
|
295
|
+
return setMilliseconds(value, milliseconds);
|
|
296
|
+
};
|
|
297
|
+
this.getDaysInMonth = value => {
|
|
298
|
+
return getDaysInMonth(value);
|
|
299
|
+
};
|
|
300
|
+
this.getWeekArray = value => {
|
|
301
|
+
const start = this.startOfWeek(this.startOfMonth(value));
|
|
302
|
+
const end = this.endOfWeek(this.endOfMonth(value));
|
|
303
|
+
let count = 0;
|
|
304
|
+
let current = start;
|
|
305
|
+
const nestedWeeks = [];
|
|
306
|
+
while (this.isBefore(current, end)) {
|
|
307
|
+
const weekNumber = Math.floor(count / 7);
|
|
308
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
309
|
+
nestedWeeks[weekNumber].push(current);
|
|
310
|
+
current = this.addDays(current, 1);
|
|
311
|
+
count += 1;
|
|
312
|
+
}
|
|
313
|
+
return nestedWeeks;
|
|
314
|
+
};
|
|
315
|
+
this.getWeekNumber = date => {
|
|
316
|
+
return getWeek(date, {
|
|
317
|
+
locale: this.locale
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
this.getYearRange = ([start, end]) => {
|
|
321
|
+
const startDate = this.startOfYear(start);
|
|
322
|
+
const endDate = this.endOfYear(end);
|
|
323
|
+
const years = [];
|
|
324
|
+
let current = startDate;
|
|
325
|
+
while (this.isBefore(current, endDate)) {
|
|
326
|
+
years.push(current);
|
|
327
|
+
current = this.addYears(current, 1);
|
|
328
|
+
}
|
|
329
|
+
return years;
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AdapterDateFnsJalali } from './AdapterDateFnsJalaliV3';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AdapterDateFnsJalali } from './AdapterDateFnsJalaliV3';
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Locale as DateFnsLocale } from 'date-fns/locale/types';
|
|
2
2
|
import { AdapterFormats, AdapterOptions, MuiPickersAdapter } from '../models';
|
|
3
3
|
import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
|
|
4
|
+
declare module '@mui/x-date-pickers/models' {
|
|
5
|
+
interface PickerValidDateLookup {
|
|
6
|
+
'date-fns': Date;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
10
|
* Based on `@date-io/date-fns`
|
|
6
11
|
*
|
|
@@ -163,14 +163,10 @@ export class AdapterMomentJalaali extends AdapterMoment {
|
|
|
163
163
|
return numberToFormat.replace(/\d/g, match => NUMBER_SYMBOL_MAP[match]).replace(/,/g, '،');
|
|
164
164
|
};
|
|
165
165
|
this.isSameYear = (value, comparing) => {
|
|
166
|
-
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
return value.clone().isSame(comparing, 'jYear');
|
|
166
|
+
return value.jYear() === comparing.jYear();
|
|
169
167
|
};
|
|
170
168
|
this.isSameMonth = (value, comparing) => {
|
|
171
|
-
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
return value.clone().isSame(comparing, 'jMonth');
|
|
169
|
+
return value.jYear() === comparing.jYear() && value.jMonth() === comparing.jMonth();
|
|
174
170
|
};
|
|
175
171
|
this.isAfterYear = (value, comparing) => {
|
|
176
172
|
return value.jYear() > comparing.jYear();
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,144 @@
|
|
|
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
|
+
## v7.5.0
|
|
7
|
+
|
|
8
|
+
_May 17, 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
|
+
- 🎁 Add support for checkbox selection on the Tree View components
|
|
13
|
+
- 🌍 Improve Norwegian (nb-NO) and Spanish (es-ES) locales on the Data Grid
|
|
14
|
+
- 🐞 Bugfixes
|
|
15
|
+
- 📚 Documentation improvements
|
|
16
|
+
|
|
17
|
+
### Data Grid
|
|
18
|
+
|
|
19
|
+
#### `@mui/x-data-grid@7.5.0`
|
|
20
|
+
|
|
21
|
+
- [DataGrid] Fix `rowModesModel` controlled prop (#13056) @Janpot
|
|
22
|
+
- [DataGrid] Reduce bundle size with error messages (#12992) @oliviertassinari
|
|
23
|
+
- [l10n] Improve Norwegian (nb-NO) locale (#13106) @oliverlaidma
|
|
24
|
+
- [l10n] Improve Spanish (es-ES) locale (#13133) @Jucabel
|
|
25
|
+
|
|
26
|
+
#### `@mui/x-data-grid-pro@7.5.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
27
|
+
|
|
28
|
+
Same changes as in `@mui/x-data-grid@7.5.0`.
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid-premium@7.5.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
31
|
+
|
|
32
|
+
Same changes as in `@mui/x-data-grid-pro@7.5.0`.
|
|
33
|
+
|
|
34
|
+
### Date and Time Pickers
|
|
35
|
+
|
|
36
|
+
#### `@mui/x-date-pickers@7.5.0`
|
|
37
|
+
|
|
38
|
+
- [fields] Allow empty `textField` slot placeholder value (#13148) @arthurbalduini
|
|
39
|
+
- [pickers] Fix `AdapterMomentJalaali` regression (#13144) @LukasTy
|
|
40
|
+
- [pickers] Fix field focusing when switching to view without a renderer (#13112) @LukasTy
|
|
41
|
+
- [pickers] Reuse `AdapterDateFnsBase` in Jalali adapters (#13075) @LukasTy
|
|
42
|
+
|
|
43
|
+
#### `@mui/x-date-pickers-pro@7.5.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
44
|
+
|
|
45
|
+
Same changes as in `@mui/x-date-pickers@7.5.0`.
|
|
46
|
+
|
|
47
|
+
### Charts
|
|
48
|
+
|
|
49
|
+
#### `@mui/x-charts@7.5.0`
|
|
50
|
+
|
|
51
|
+
- [charts] Tooltip with `trigger=axis` now follow touch on mobile (#13043) @wzdorowa
|
|
52
|
+
- [charts] Allow `series.label` property to receive a function with the "location" it is going to be displayed on (#12830) @JCQuintas
|
|
53
|
+
- [charts] Improve TypeScript performance (#13137) @alexfauquette
|
|
54
|
+
- [charts] Fix area order when overlapping (#13121) @alexfauquette
|
|
55
|
+
- [charts] Improve `useSlotProps` types (#13141) @alexfauquette
|
|
56
|
+
- [charts] Fix using the theme's font in the Overlay (#13107) @alexfauquette
|
|
57
|
+
|
|
58
|
+
### Tree View
|
|
59
|
+
|
|
60
|
+
#### `@mui/x-tree-view@7.5.0`
|
|
61
|
+
|
|
62
|
+
- [TreeView] Add support for checkbox selection (#11452) @flaviendelangle
|
|
63
|
+
- [TreeView] Remove unused code (#12917) @flaviendelangle
|
|
64
|
+
|
|
65
|
+
### Docs
|
|
66
|
+
|
|
67
|
+
- [docs] Document missing Charts API's (#12875) @alexfauquette
|
|
68
|
+
|
|
69
|
+
### Core
|
|
70
|
+
|
|
71
|
+
- [core] Avoid root level `@mui/x-date-pickers` imports (#13120) @LukasTy
|
|
72
|
+
- [core] Refactor ESLint config to disallow root level imports (#13130) @LukasTy
|
|
73
|
+
- [core] Simplify Danger's config (#13062) @oliviertassinari
|
|
74
|
+
- [core] Shift aliasing from babel to webpack (#13051) @Janpot
|
|
75
|
+
- [core] Reuse the `SectionTitle` component in the doc (#13139) @alexfauquette
|
|
76
|
+
|
|
77
|
+
## 7.4.0
|
|
78
|
+
|
|
79
|
+
_May 10, 2024_
|
|
80
|
+
|
|
81
|
+
We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
|
|
82
|
+
|
|
83
|
+
- ✨ Add optional `id` attribute on shortcut items of the Date and Time Pickers
|
|
84
|
+
- 🎁 Add support for `date-fns-jalali` v3 in the Date and Time Pickers
|
|
85
|
+
- 🚀 Support rounded corners on `BarChart`
|
|
86
|
+
- 🌍 Add accessibility page to TreeView docs
|
|
87
|
+
- 🐞 Bugfixes
|
|
88
|
+
- 📚 Documentation improvements
|
|
89
|
+
|
|
90
|
+
### Data Grid
|
|
91
|
+
|
|
92
|
+
#### `@mui/x-data-grid@7.4.0`
|
|
93
|
+
|
|
94
|
+
- [DataGrid] Fix error when focus moves from column header to `svg` element (#13028) @oukunan
|
|
95
|
+
- [DataGrid] Fix error on column groups change (#12965) @romgrk
|
|
96
|
+
|
|
97
|
+
#### `@mui/x-data-grid-pro@7.4.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
98
|
+
|
|
99
|
+
Same changes as in `@mui/x-data-grid@7.4.0`.
|
|
100
|
+
|
|
101
|
+
#### `@mui/x-data-grid-premium@7.4.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
102
|
+
|
|
103
|
+
Same changes as in `@mui/x-data-grid-pro@7.4.0`.
|
|
104
|
+
|
|
105
|
+
### Date and Time Pickers
|
|
106
|
+
|
|
107
|
+
#### `@mui/x-date-pickers@7.4.0`
|
|
108
|
+
|
|
109
|
+
- [fields] Fix regression preventing form submit on "Enter" click (#13065) @LukasTy
|
|
110
|
+
- [pickers] Add `AdapterDateFnsJalaliV3` adapter (#12891) @smmoosavi
|
|
111
|
+
- [pickers] Add optional `id` attribute on shortcut items (#12976) @noraleonte
|
|
112
|
+
|
|
113
|
+
#### `@mui/x-date-pickers-pro@7.4.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
114
|
+
|
|
115
|
+
Same changes as in `@mui/x-date-pickers@7.4.0`.
|
|
116
|
+
|
|
117
|
+
### Charts
|
|
118
|
+
|
|
119
|
+
#### `@mui/x-charts@7.4.0`
|
|
120
|
+
|
|
121
|
+
- [charts] Add `ChartsGrid` to `themeAugmentation` (#13026) @noraleonte
|
|
122
|
+
- [charts] Support rounded corners on `BarChart` (#12834) @JCQuintas
|
|
123
|
+
|
|
124
|
+
### Tree View
|
|
125
|
+
|
|
126
|
+
#### `@mui/x-tree-view@7.4.0`
|
|
127
|
+
|
|
128
|
+
- [TreeView] Fix props propagation and theme entry in `TreeItem2` (#12889) @flaviendelangle
|
|
129
|
+
|
|
130
|
+
### Docs
|
|
131
|
+
|
|
132
|
+
- [docs] Add accessibility page to TreeView docs (#12845) @noraleonte
|
|
133
|
+
- [docs] Fix Charts styling typos (#13061) @oliviertassinari
|
|
134
|
+
- [docs] Fix legal link to EULA free trial (#13013) @oliviertassinari
|
|
135
|
+
- [docs] Update interface name in pinned columns docs (#13070) @cherniavskii
|
|
136
|
+
|
|
137
|
+
### Core
|
|
138
|
+
|
|
139
|
+
- [core] Improve release process docs (#12977) @JCQuintas
|
|
140
|
+
- [core] Prepare React 19 (#12991) @oliviertassinari
|
|
141
|
+
- [docs-infra] Fix Netlify PR preview path (#12993) @oliviertassinari
|
|
142
|
+
- [infra] Automation: Add release PR reviewers (#12982) @michelengelen
|
|
143
|
+
|
|
6
144
|
## 7.3.2
|
|
7
145
|
|
|
8
146
|
_May 2, 2024_
|
|
@@ -17,8 +155,6 @@ We'd like to offer a big thanks to the 11 contributors who made this release pos
|
|
|
17
155
|
- 🐞 Bugfixes
|
|
18
156
|
- 📚 Documentation improvements
|
|
19
157
|
|
|
20
|
-
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
21
|
-
|
|
22
158
|
### Data Grid
|
|
23
159
|
|
|
24
160
|
#### `@mui/x-data-grid@7.3.2`
|
|
@@ -3281,6 +3417,28 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
|
|
|
3281
3417
|
- [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
|
|
3282
3418
|
- [license] Correctly throw errors (#10924) @oliviertassinari
|
|
3283
3419
|
|
|
3420
|
+
## 6.19.12
|
|
3421
|
+
|
|
3422
|
+
_May 17, 2024_
|
|
3423
|
+
|
|
3424
|
+
We'd like to offer a big thanks to the 2 contributors who made this release possible. Here are some highlights ✨:
|
|
3425
|
+
|
|
3426
|
+
- 🐞 Bugfixes
|
|
3427
|
+
|
|
3428
|
+
### Date Pickers
|
|
3429
|
+
|
|
3430
|
+
#### `@mui/x-date-pickers@6.19.12`
|
|
3431
|
+
|
|
3432
|
+
- [pickers] Fix `AdapterMomentJalaali` regression (#13150) @LukasTy
|
|
3433
|
+
|
|
3434
|
+
#### `@mui/x-date-pickers-pro@6.19.12` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
3435
|
+
|
|
3436
|
+
Same changes as in `@mui/x-date-pickers@6.19.12`.
|
|
3437
|
+
|
|
3438
|
+
### Docs
|
|
3439
|
+
|
|
3440
|
+
- [docs] Use MUI X v6 in Codesandbox and Stackblitz demos (#12838) @cherniavskii
|
|
3441
|
+
|
|
3284
3442
|
## 6.19.11
|
|
3285
3443
|
|
|
3286
3444
|
_Apr 18, 2024_
|
|
@@ -198,9 +198,7 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
198
198
|
disableFuture,
|
|
199
199
|
reduceAnimations,
|
|
200
200
|
timezone,
|
|
201
|
-
labelId: gridLabelId
|
|
202
|
-
slots,
|
|
203
|
-
slotProps
|
|
201
|
+
labelId: gridLabelId
|
|
204
202
|
},
|
|
205
203
|
ownerState: props
|
|
206
204
|
});
|
|
@@ -294,7 +292,10 @@ export const DateCalendar = /*#__PURE__*/React.forwardRef(function DateCalendar(
|
|
|
294
292
|
className: clsx(classes.root, className),
|
|
295
293
|
ownerState: ownerState
|
|
296
294
|
}, other, {
|
|
297
|
-
children: [/*#__PURE__*/_jsx(CalendarHeader, _extends({}, calendarHeaderProps
|
|
295
|
+
children: [/*#__PURE__*/_jsx(CalendarHeader, _extends({}, calendarHeaderProps, {
|
|
296
|
+
slots: slots,
|
|
297
|
+
slotProps: slotProps
|
|
298
|
+
})), /*#__PURE__*/_jsx(DateCalendarViewTransitionContainer, {
|
|
298
299
|
reduceAnimations: reduceAnimations,
|
|
299
300
|
className: classes.viewTransitionContainer,
|
|
300
301
|
transKey: view,
|
|
@@ -63,9 +63,9 @@ const usePickerLayout = props => {
|
|
|
63
63
|
onClear,
|
|
64
64
|
onCancel,
|
|
65
65
|
onSetToday,
|
|
66
|
-
actions: wrapperVariant === 'desktop' ? [] : ['cancel', 'accept']
|
|
67
|
-
className: classes.actionBar
|
|
66
|
+
actions: wrapperVariant === 'desktop' ? [] : ['cancel', 'accept']
|
|
68
67
|
},
|
|
68
|
+
className: classes.actionBar,
|
|
69
69
|
ownerState: _extends({}, props, {
|
|
70
70
|
wrapperVariant
|
|
71
71
|
})
|
|
@@ -86,9 +86,9 @@ const usePickerLayout = props => {
|
|
|
86
86
|
onViewChange,
|
|
87
87
|
views,
|
|
88
88
|
disabled,
|
|
89
|
-
readOnly
|
|
90
|
-
className: classes.toolbar
|
|
89
|
+
readOnly
|
|
91
90
|
},
|
|
91
|
+
className: classes.toolbar,
|
|
92
92
|
ownerState: _extends({}, props, {
|
|
93
93
|
wrapperVariant
|
|
94
94
|
})
|
|
@@ -117,14 +117,13 @@ const usePickerLayout = props => {
|
|
|
117
117
|
additionalProps: {
|
|
118
118
|
isValid,
|
|
119
119
|
isLandscape,
|
|
120
|
-
onChange: onSelectShortcut
|
|
121
|
-
className: classes.shortcuts
|
|
120
|
+
onChange: onSelectShortcut
|
|
122
121
|
},
|
|
122
|
+
className: classes.shortcuts,
|
|
123
123
|
ownerState: {
|
|
124
124
|
isValid,
|
|
125
125
|
isLandscape,
|
|
126
126
|
onChange: onSelectShortcut,
|
|
127
|
-
className: classes.shortcuts,
|
|
128
127
|
wrapperVariant
|
|
129
128
|
}
|
|
130
129
|
});
|
|
@@ -6,6 +6,11 @@ interface PickersShortcutsItemGetValueParams<TValue> {
|
|
|
6
6
|
export interface PickersShortcutsItem<TValue> {
|
|
7
7
|
label: string;
|
|
8
8
|
getValue: (params: PickersShortcutsItemGetValueParams<TValue>) => TValue;
|
|
9
|
+
/**
|
|
10
|
+
* Identifier of the shortcut.
|
|
11
|
+
* If provided, it will be used as the key of the shortcut.
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
9
14
|
}
|
|
10
15
|
export type PickersShortcutsItemContext = Omit<PickersShortcutsItem<unknown>, 'getValue'>;
|
|
11
16
|
export type PickerShortcutChangeImportance = 'set' | 'accept';
|
|
@@ -37,13 +37,13 @@ function PickersShortcuts(props) {
|
|
|
37
37
|
const newValue = getValue({
|
|
38
38
|
isValid
|
|
39
39
|
});
|
|
40
|
-
return {
|
|
40
|
+
return _extends({}, item, {
|
|
41
41
|
label: item.label,
|
|
42
42
|
onClick: () => {
|
|
43
43
|
onChange(newValue, changeImportance, item);
|
|
44
44
|
},
|
|
45
45
|
disabled: !isValid(newValue)
|
|
46
|
-
};
|
|
46
|
+
});
|
|
47
47
|
});
|
|
48
48
|
return /*#__PURE__*/_jsx(List, _extends({
|
|
49
49
|
dense: true,
|
|
@@ -56,7 +56,7 @@ function PickersShortcuts(props) {
|
|
|
56
56
|
children: resolvedItems.map(item => {
|
|
57
57
|
return /*#__PURE__*/_jsx(ListItem, {
|
|
58
58
|
children: /*#__PURE__*/_jsx(Chip, _extends({}, item))
|
|
59
|
-
}, item.label);
|
|
59
|
+
}, item.id ?? item.label);
|
|
60
60
|
})
|
|
61
61
|
}));
|
|
62
62
|
}
|
|
@@ -95,6 +95,7 @@ process.env.NODE_ENV !== "production" ? PickersShortcuts.propTypes = {
|
|
|
95
95
|
*/
|
|
96
96
|
items: PropTypes.arrayOf(PropTypes.shape({
|
|
97
97
|
getValue: PropTypes.func.isRequired,
|
|
98
|
+
id: PropTypes.string,
|
|
98
99
|
label: PropTypes.string.isRequired
|
|
99
100
|
})),
|
|
100
101
|
onChange: PropTypes.func.isRequired,
|
package/index.js
CHANGED