@mui/x-date-pickers 8.10.0 → 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.
@@ -95,199 +95,200 @@ class AdapterDateFns extends _AdapterDateFnsBase.AdapterDateFnsBase {
95
95
  formats,
96
96
  longFormatters: _format.longFormatters
97
97
  });
98
- // TODO: explicit return types can be removed once there is only one date-fns version supported
99
- this.parse = (value, format) => {
100
- if (value === '') {
101
- return null;
102
- }
103
- return (0, _parse.parse)(value, format, new Date(), {
104
- locale: this.locale
105
- });
106
- };
107
- this.isValid = value => {
108
- if (value == null) {
109
- return false;
110
- }
111
- return (0, _isValid.isValid)(value);
112
- };
113
- this.format = (value, formatKey) => {
114
- return this.formatByString(value, this.formats[formatKey]);
115
- };
116
- this.formatByString = (value, formatString) => {
117
- return (0, _format.format)(value, formatString, {
118
- locale: this.locale
119
- });
120
- };
121
- this.isEqual = (value, comparing) => {
122
- if (value === null && comparing === null) {
123
- return true;
124
- }
125
- if (value === null || comparing === null) {
126
- return false;
127
- }
128
- return (0, _isEqual.isEqual)(value, comparing);
129
- };
130
- this.isSameYear = (value, comparing) => {
131
- return (0, _isSameYear.isSameYear)(value, comparing);
132
- };
133
- this.isSameMonth = (value, comparing) => {
134
- return (0, _isSameMonth.isSameMonth)(value, comparing);
135
- };
136
- this.isSameDay = (value, comparing) => {
137
- return (0, _isSameDay.isSameDay)(value, comparing);
138
- };
139
- this.isSameHour = (value, comparing) => {
140
- return (0, _isSameHour.isSameHour)(value, comparing);
141
- };
142
- this.isAfter = (value, comparing) => {
143
- return (0, _isAfter.isAfter)(value, comparing);
144
- };
145
- this.isAfterYear = (value, comparing) => {
146
- return (0, _isAfter.isAfter)(value, (0, _endOfYear.endOfYear)(comparing));
147
- };
148
- this.isAfterDay = (value, comparing) => {
149
- return (0, _isAfter.isAfter)(value, (0, _endOfDay.endOfDay)(comparing));
150
- };
151
- this.isBefore = (value, comparing) => {
152
- return (0, _isBefore.isBefore)(value, comparing);
153
- };
154
- this.isBeforeYear = (value, comparing) => {
155
- return (0, _isBefore.isBefore)(value, this.startOfYear(comparing));
156
- };
157
- this.isBeforeDay = (value, comparing) => {
158
- return (0, _isBefore.isBefore)(value, this.startOfDay(comparing));
159
- };
160
- this.isWithinRange = (value, [start, end]) => {
161
- return (0, _isWithinInterval.isWithinInterval)(value, {
162
- start,
163
- end
164
- });
165
- };
166
- this.startOfYear = value => {
167
- return (0, _startOfYear.startOfYear)(value);
168
- };
169
- this.startOfMonth = value => {
170
- return (0, _startOfMonth.startOfMonth)(value);
171
- };
172
- this.startOfWeek = value => {
173
- return (0, _startOfWeek.startOfWeek)(value, {
174
- locale: this.locale
175
- });
176
- };
177
- this.startOfDay = value => {
178
- return (0, _startOfDay.startOfDay)(value);
179
- };
180
- this.endOfYear = value => {
181
- return (0, _endOfYear.endOfYear)(value);
182
- };
183
- this.endOfMonth = value => {
184
- return (0, _endOfMonth.endOfMonth)(value);
185
- };
186
- this.endOfWeek = value => {
187
- return (0, _endOfWeek.endOfWeek)(value, {
188
- locale: this.locale
189
- });
190
- };
191
- this.endOfDay = value => {
192
- return (0, _endOfDay.endOfDay)(value);
193
- };
194
- this.addYears = (value, amount) => {
195
- return (0, _addYears.addYears)(value, amount);
196
- };
197
- this.addMonths = (value, amount) => {
198
- return (0, _addMonths.addMonths)(value, amount);
199
- };
200
- this.addWeeks = (value, amount) => {
201
- return (0, _addWeeks.addWeeks)(value, amount);
202
- };
203
- this.addDays = (value, amount) => {
204
- return (0, _addDays.addDays)(value, amount);
205
- };
206
- this.addHours = (value, amount) => {
207
- return (0, _addHours.addHours)(value, amount);
208
- };
209
- this.addMinutes = (value, amount) => {
210
- return (0, _addMinutes.addMinutes)(value, amount);
211
- };
212
- this.addSeconds = (value, amount) => {
213
- return (0, _addSeconds.addSeconds)(value, amount);
214
- };
215
- this.getYear = value => {
216
- return (0, _getYear.getYear)(value);
217
- };
218
- this.getMonth = value => {
219
- return (0, _getMonth.getMonth)(value);
220
- };
221
- this.getDate = value => {
222
- return (0, _getDate.getDate)(value);
223
- };
224
- this.getHours = value => {
225
- return (0, _getHours.getHours)(value);
226
- };
227
- this.getMinutes = value => {
228
- return (0, _getMinutes.getMinutes)(value);
229
- };
230
- this.getSeconds = value => {
231
- return (0, _getSeconds.getSeconds)(value);
232
- };
233
- this.getMilliseconds = value => {
234
- return (0, _getMilliseconds.getMilliseconds)(value);
235
- };
236
- this.setYear = (value, year) => {
237
- return (0, _setYear.setYear)(value, year);
238
- };
239
- this.setMonth = (value, month) => {
240
- return (0, _setMonth.setMonth)(value, month);
241
- };
242
- this.setDate = (value, date) => {
243
- return (0, _setDate.setDate)(value, date);
244
- };
245
- this.setHours = (value, hours) => {
246
- return (0, _setHours.setHours)(value, hours);
247
- };
248
- this.setMinutes = (value, minutes) => {
249
- return (0, _setMinutes.setMinutes)(value, minutes);
250
- };
251
- this.setSeconds = (value, seconds) => {
252
- return (0, _setSeconds.setSeconds)(value, seconds);
253
- };
254
- this.setMilliseconds = (value, milliseconds) => {
255
- return (0, _setMilliseconds.setMilliseconds)(value, milliseconds);
256
- };
257
- this.getDaysInMonth = value => {
258
- return (0, _getDaysInMonth.getDaysInMonth)(value);
259
- };
260
- this.getWeekArray = value => {
261
- const start = this.startOfWeek(this.startOfMonth(value));
262
- const end = this.endOfWeek(this.endOfMonth(value));
263
- let count = 0;
264
- let current = start;
265
- const nestedWeeks = [];
266
- while (this.isBefore(current, end)) {
267
- const weekNumber = Math.floor(count / 7);
268
- nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
269
- nestedWeeks[weekNumber].push(current);
270
- current = this.addDays(current, 1);
271
- count += 1;
272
- }
273
- return nestedWeeks;
274
- };
275
- this.getWeekNumber = value => {
276
- return (0, _getWeek.getWeek)(value, {
277
- locale: this.locale
278
- });
279
- };
280
- this.getYearRange = ([start, end]) => {
281
- const startDate = this.startOfYear(start);
282
- const endDate = this.endOfYear(end);
283
- const years = [];
284
- let current = startDate;
285
- while (this.isBefore(current, endDate)) {
286
- years.push(current);
287
- current = this.addYears(current, 1);
288
- }
289
- return years;
290
- };
291
98
  }
99
+
100
+ // TODO: explicit return types can be removed once there is only one date-fns version supported
101
+ parse = (value, format) => {
102
+ if (value === '') {
103
+ return null;
104
+ }
105
+ return (0, _parse.parse)(value, format, new Date(), {
106
+ locale: this.locale
107
+ });
108
+ };
109
+ isValid = value => {
110
+ if (value == null) {
111
+ return false;
112
+ }
113
+ return (0, _isValid.isValid)(value);
114
+ };
115
+ format = (value, formatKey) => {
116
+ return this.formatByString(value, this.formats[formatKey]);
117
+ };
118
+ formatByString = (value, formatString) => {
119
+ return (0, _format.format)(value, formatString, {
120
+ locale: this.locale
121
+ });
122
+ };
123
+ isEqual = (value, comparing) => {
124
+ if (value === null && comparing === null) {
125
+ return true;
126
+ }
127
+ if (value === null || comparing === null) {
128
+ return false;
129
+ }
130
+ return (0, _isEqual.isEqual)(value, comparing);
131
+ };
132
+ isSameYear = (value, comparing) => {
133
+ return (0, _isSameYear.isSameYear)(value, comparing);
134
+ };
135
+ isSameMonth = (value, comparing) => {
136
+ return (0, _isSameMonth.isSameMonth)(value, comparing);
137
+ };
138
+ isSameDay = (value, comparing) => {
139
+ return (0, _isSameDay.isSameDay)(value, comparing);
140
+ };
141
+ isSameHour = (value, comparing) => {
142
+ return (0, _isSameHour.isSameHour)(value, comparing);
143
+ };
144
+ isAfter = (value, comparing) => {
145
+ return (0, _isAfter.isAfter)(value, comparing);
146
+ };
147
+ isAfterYear = (value, comparing) => {
148
+ return (0, _isAfter.isAfter)(value, (0, _endOfYear.endOfYear)(comparing));
149
+ };
150
+ isAfterDay = (value, comparing) => {
151
+ return (0, _isAfter.isAfter)(value, (0, _endOfDay.endOfDay)(comparing));
152
+ };
153
+ isBefore = (value, comparing) => {
154
+ return (0, _isBefore.isBefore)(value, comparing);
155
+ };
156
+ isBeforeYear = (value, comparing) => {
157
+ return (0, _isBefore.isBefore)(value, this.startOfYear(comparing));
158
+ };
159
+ isBeforeDay = (value, comparing) => {
160
+ return (0, _isBefore.isBefore)(value, this.startOfDay(comparing));
161
+ };
162
+ isWithinRange = (value, [start, end]) => {
163
+ return (0, _isWithinInterval.isWithinInterval)(value, {
164
+ start,
165
+ end
166
+ });
167
+ };
168
+ startOfYear = value => {
169
+ return (0, _startOfYear.startOfYear)(value);
170
+ };
171
+ startOfMonth = value => {
172
+ return (0, _startOfMonth.startOfMonth)(value);
173
+ };
174
+ startOfWeek = value => {
175
+ return (0, _startOfWeek.startOfWeek)(value, {
176
+ locale: this.locale
177
+ });
178
+ };
179
+ startOfDay = value => {
180
+ return (0, _startOfDay.startOfDay)(value);
181
+ };
182
+ endOfYear = value => {
183
+ return (0, _endOfYear.endOfYear)(value);
184
+ };
185
+ endOfMonth = value => {
186
+ return (0, _endOfMonth.endOfMonth)(value);
187
+ };
188
+ endOfWeek = value => {
189
+ return (0, _endOfWeek.endOfWeek)(value, {
190
+ locale: this.locale
191
+ });
192
+ };
193
+ endOfDay = value => {
194
+ return (0, _endOfDay.endOfDay)(value);
195
+ };
196
+ addYears = (value, amount) => {
197
+ return (0, _addYears.addYears)(value, amount);
198
+ };
199
+ addMonths = (value, amount) => {
200
+ return (0, _addMonths.addMonths)(value, amount);
201
+ };
202
+ addWeeks = (value, amount) => {
203
+ return (0, _addWeeks.addWeeks)(value, amount);
204
+ };
205
+ addDays = (value, amount) => {
206
+ return (0, _addDays.addDays)(value, amount);
207
+ };
208
+ addHours = (value, amount) => {
209
+ return (0, _addHours.addHours)(value, amount);
210
+ };
211
+ addMinutes = (value, amount) => {
212
+ return (0, _addMinutes.addMinutes)(value, amount);
213
+ };
214
+ addSeconds = (value, amount) => {
215
+ return (0, _addSeconds.addSeconds)(value, amount);
216
+ };
217
+ getYear = value => {
218
+ return (0, _getYear.getYear)(value);
219
+ };
220
+ getMonth = value => {
221
+ return (0, _getMonth.getMonth)(value);
222
+ };
223
+ getDate = value => {
224
+ return (0, _getDate.getDate)(value);
225
+ };
226
+ getHours = value => {
227
+ return (0, _getHours.getHours)(value);
228
+ };
229
+ getMinutes = value => {
230
+ return (0, _getMinutes.getMinutes)(value);
231
+ };
232
+ getSeconds = value => {
233
+ return (0, _getSeconds.getSeconds)(value);
234
+ };
235
+ getMilliseconds = value => {
236
+ return (0, _getMilliseconds.getMilliseconds)(value);
237
+ };
238
+ setYear = (value, year) => {
239
+ return (0, _setYear.setYear)(value, year);
240
+ };
241
+ setMonth = (value, month) => {
242
+ return (0, _setMonth.setMonth)(value, month);
243
+ };
244
+ setDate = (value, date) => {
245
+ return (0, _setDate.setDate)(value, date);
246
+ };
247
+ setHours = (value, hours) => {
248
+ return (0, _setHours.setHours)(value, hours);
249
+ };
250
+ setMinutes = (value, minutes) => {
251
+ return (0, _setMinutes.setMinutes)(value, minutes);
252
+ };
253
+ setSeconds = (value, seconds) => {
254
+ return (0, _setSeconds.setSeconds)(value, seconds);
255
+ };
256
+ setMilliseconds = (value, milliseconds) => {
257
+ return (0, _setMilliseconds.setMilliseconds)(value, milliseconds);
258
+ };
259
+ getDaysInMonth = value => {
260
+ return (0, _getDaysInMonth.getDaysInMonth)(value);
261
+ };
262
+ getWeekArray = value => {
263
+ const start = this.startOfWeek(this.startOfMonth(value));
264
+ const end = this.endOfWeek(this.endOfMonth(value));
265
+ let count = 0;
266
+ let current = start;
267
+ const nestedWeeks = [];
268
+ while (this.isBefore(current, end)) {
269
+ const weekNumber = Math.floor(count / 7);
270
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
271
+ nestedWeeks[weekNumber].push(current);
272
+ current = this.addDays(current, 1);
273
+ count += 1;
274
+ }
275
+ return nestedWeeks;
276
+ };
277
+ getWeekNumber = value => {
278
+ return (0, _getWeek.getWeek)(value, {
279
+ locale: this.locale
280
+ });
281
+ };
282
+ getYearRange = ([start, end]) => {
283
+ const startDate = this.startOfYear(start);
284
+ const endDate = this.endOfYear(end);
285
+ const years = [];
286
+ let current = startDate;
287
+ while (this.isBefore(current, endDate)) {
288
+ years.push(current);
289
+ current = this.addYears(current, 1);
290
+ }
291
+ return years;
292
+ };
292
293
  }
293
294
  exports.AdapterDateFns = AdapterDateFns;
@@ -223,67 +223,14 @@ const defaultFormats = {
223
223
  * SOFTWARE.
224
224
  */
225
225
  class AdapterDateFnsBase {
226
+ isMUIAdapter = true;
227
+ isTimezoneCompatible = false;
228
+ formatTokenMap = formatTokenMap;
229
+ escapedCharacters = {
230
+ start: "'",
231
+ end: "'"
232
+ };
226
233
  constructor(props) {
227
- this.isMUIAdapter = true;
228
- this.isTimezoneCompatible = false;
229
- this.lib = void 0;
230
- this.locale = void 0;
231
- this.formats = void 0;
232
- this.formatTokenMap = formatTokenMap;
233
- this.escapedCharacters = {
234
- start: "'",
235
- end: "'"
236
- };
237
- this.longFormatters = void 0;
238
- this.date = value => {
239
- if (typeof value === 'undefined') {
240
- return new Date();
241
- }
242
- if (value === null) {
243
- return null;
244
- }
245
- return new Date(value);
246
- };
247
- this.getInvalidDate = () => new Date('Invalid Date');
248
- this.getTimezone = () => {
249
- return 'default';
250
- };
251
- this.setTimezone = value => {
252
- return value;
253
- };
254
- this.toJsDate = value => {
255
- return value;
256
- };
257
- this.getCurrentLocaleCode = () => {
258
- // `code` is undefined only in `date-fns` types, but all locales have it
259
- return this.locale.code;
260
- };
261
- // Note: date-fns input types are more lenient than this adapter, so we need to expose our more
262
- // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
263
- this.is12HourCycleInCurrentLocale = () => {
264
- return /a/.test(this.locale.formatLong.time({
265
- width: 'short'
266
- }));
267
- };
268
- this.expandFormat = format => {
269
- const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
270
-
271
- // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
272
- return format.match(longFormatRegexp).map(token => {
273
- const firstCharacter = token[0];
274
- if (firstCharacter === 'p' || firstCharacter === 'P') {
275
- const longFormatter = this.longFormatters[firstCharacter];
276
- return longFormatter(token, this.locale.formatLong);
277
- }
278
- return token;
279
- }).join('');
280
- };
281
- this.formatNumber = numberToFormat => {
282
- return numberToFormat;
283
- };
284
- this.getDayOfWeek = value => {
285
- return value.getDay() + 1;
286
- };
287
234
  const {
288
235
  locale,
289
236
  formats,
@@ -295,5 +242,55 @@ class AdapterDateFnsBase {
295
242
  this.longFormatters = longFormatters;
296
243
  this.lib = lib || 'date-fns';
297
244
  }
245
+ date = value => {
246
+ if (typeof value === 'undefined') {
247
+ return new Date();
248
+ }
249
+ if (value === null) {
250
+ return null;
251
+ }
252
+ return new Date(value);
253
+ };
254
+ getInvalidDate = () => new Date('Invalid Date');
255
+ getTimezone = () => {
256
+ return 'default';
257
+ };
258
+ setTimezone = value => {
259
+ return value;
260
+ };
261
+ toJsDate = value => {
262
+ return value;
263
+ };
264
+ getCurrentLocaleCode = () => {
265
+ // `code` is undefined only in `date-fns` types, but all locales have it
266
+ return this.locale.code;
267
+ };
268
+
269
+ // Note: date-fns input types are more lenient than this adapter, so we need to expose our more
270
+ // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
271
+ is12HourCycleInCurrentLocale = () => {
272
+ return /a/.test(this.locale.formatLong.time({
273
+ width: 'short'
274
+ }));
275
+ };
276
+ expandFormat = format => {
277
+ const longFormatRegexp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
278
+
279
+ // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
280
+ return format.match(longFormatRegexp).map(token => {
281
+ const firstCharacter = token[0];
282
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
283
+ const longFormatter = this.longFormatters[firstCharacter];
284
+ return longFormatter(token, this.locale.formatLong);
285
+ }
286
+ return token;
287
+ }).join('');
288
+ };
289
+ formatNumber = numberToFormat => {
290
+ return numberToFormat;
291
+ };
292
+ getDayOfWeek = value => {
293
+ return value.getDay() + 1;
294
+ };
298
295
  }
299
296
  exports.AdapterDateFnsBase = AdapterDateFnsBase;