@mui/x-date-pickers 7.0.0-alpha.7 → 7.0.0-alpha.8
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 +4 -21
- package/AdapterDateFns/AdapterDateFns.js +11 -255
- package/AdapterDateFnsBase/AdapterDateFnsBase.d.ts +62 -0
- package/AdapterDateFnsBase/AdapterDateFnsBase.js +291 -0
- package/AdapterDateFnsBase/index.d.ts +1 -0
- package/AdapterDateFnsBase/index.js +1 -0
- package/AdapterDateFnsBase/package.json +6 -0
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.d.ts +1 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.d.ts +80 -0
- package/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
- package/AdapterDateFnsV3/index.d.ts +1 -0
- package/AdapterDateFnsV3/index.js +1 -0
- package/AdapterDateFnsV3/package.json +6 -0
- package/CHANGELOG.md +175 -49
- package/DatePicker/DatePickerToolbar.d.ts +2 -2
- package/DatePicker/DatePickerToolbar.js +2 -7
- package/DigitalClock/DigitalClock.js +1 -0
- package/DigitalClock/DigitalClock.types.d.ts +5 -0
- package/LocalizationProvider/LocalizationProvider.js +1 -1
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.types.d.ts +5 -0
- package/PickersSectionList/PickersSectionList.js +1 -1
- package/TimeClock/TimeClock.js +1 -0
- package/TimeClock/TimeClock.types.d.ts +5 -0
- package/hooks/useClearableField.js +3 -3
- package/index.js +1 -1
- package/internals/components/PickersInput/PickersInput.d.ts +2 -4
- package/internals/components/PickersInput/PickersInput.js +2 -3
- package/internals/hooks/useField/useField.utils.js +5 -5
- package/internals/hooks/usePicker/index.d.ts +1 -1
- package/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/internals/hooks/useUtils.js +2 -2
- package/internals/hooks/useViews.js +2 -2
- package/internals/index.d.ts +9 -3
- package/internals/index.js +6 -2
- package/internals/models/common.d.ts +1 -1
- package/internals/models/helpers.d.ts +1 -0
- package/internals/utils/views.js +1 -1
- package/legacy/AdapterDateFns/AdapterDateFns.js +222 -458
- package/legacy/AdapterDateFnsBase/AdapterDateFnsBase.js +293 -0
- package/legacy/AdapterDateFnsBase/index.js +1 -0
- package/legacy/AdapterDateFnsV3/AdapterDateFnsV3.js +306 -0
- package/legacy/AdapterDateFnsV3/index.js +1 -0
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +5 -6
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +5 -6
- package/legacy/DatePicker/DatePickerToolbar.js +2 -7
- package/legacy/DigitalClock/DigitalClock.js +1 -0
- package/legacy/LocalizationProvider/LocalizationProvider.js +1 -1
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/legacy/PickersSectionList/PickersSectionList.js +1 -1
- package/legacy/TimeClock/TimeClock.js +1 -0
- package/legacy/hooks/useClearableField.js +3 -3
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersInput/PickersInput.js +2 -3
- package/legacy/internals/hooks/useField/useField.utils.js +5 -5
- package/legacy/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/legacy/internals/hooks/useUtils.js +2 -2
- package/legacy/internals/hooks/useViews.js +2 -2
- package/legacy/internals/index.js +6 -2
- package/legacy/internals/utils/views.js +1 -1
- package/legacy/locales/index.js +1 -0
- package/locales/enUS.d.ts +1 -1
- package/locales/index.d.ts +1 -0
- package/locales/index.js +1 -0
- package/locales/mk.d.ts +1 -1
- package/locales/utils/getPickersLocalization.d.ts +1 -1
- package/modern/AdapterDateFns/AdapterDateFns.js +11 -254
- package/modern/AdapterDateFnsBase/AdapterDateFnsBase.js +290 -0
- package/modern/AdapterDateFnsBase/index.js +1 -0
- package/modern/AdapterDateFnsV3/AdapterDateFnsV3.js +287 -0
- package/modern/AdapterDateFnsV3/index.js +1 -0
- package/modern/DatePicker/DatePickerToolbar.js +2 -7
- package/modern/DigitalClock/DigitalClock.js +1 -0
- package/modern/LocalizationProvider/LocalizationProvider.js +1 -1
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/modern/PickersSectionList/PickersSectionList.js +1 -1
- package/modern/TimeClock/TimeClock.js +1 -0
- package/modern/hooks/useClearableField.js +3 -3
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersInput/PickersInput.js +2 -3
- package/modern/internals/hooks/useField/useField.utils.js +5 -5
- package/modern/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/modern/internals/hooks/useUtils.js +2 -2
- package/modern/internals/hooks/useViews.js +2 -2
- package/modern/internals/index.js +6 -2
- package/modern/internals/utils/views.js +1 -1
- package/modern/locales/index.js +1 -0
- package/node/AdapterDateFns/AdapterDateFns.js +11 -254
- package/node/AdapterDateFnsBase/AdapterDateFnsBase.js +298 -0
- package/node/AdapterDateFnsBase/index.js +12 -0
- package/node/AdapterDateFnsV3/AdapterDateFnsV3.js +295 -0
- package/node/AdapterDateFnsV3/index.js +12 -0
- package/node/DatePicker/DatePickerToolbar.js +0 -4
- package/node/DigitalClock/DigitalClock.js +1 -0
- package/node/LocalizationProvider/LocalizationProvider.js +1 -1
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +1 -0
- package/node/PickersSectionList/PickersSectionList.js +1 -1
- package/node/TimeClock/TimeClock.js +1 -0
- package/node/hooks/useClearableField.js +3 -3
- package/node/index.js +1 -1
- package/node/internals/components/PickersInput/PickersInput.js +2 -3
- package/node/internals/hooks/useField/useField.utils.js +5 -5
- package/node/internals/hooks/usePicker/usePickerValue.js +2 -2
- package/node/internals/hooks/useUtils.js +2 -2
- package/node/internals/hooks/useViews.js +2 -2
- package/node/internals/index.js +47 -1
- package/node/internals/utils/views.js +1 -1
- package/node/locales/index.js +11 -0
- package/package.json +2 -2
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Locale as DateFnsLocale } from 'date-fns/locale/types';
|
|
2
|
+
import { AdapterFormats, AdapterOptions, MuiPickersAdapter } from '../models';
|
|
3
|
+
import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
|
|
4
|
+
/**
|
|
5
|
+
* Based on `@date-io/date-fns`
|
|
6
|
+
*
|
|
7
|
+
* MIT License
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
10
|
+
*
|
|
11
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
* in the Software without restriction, including without limitation the rights
|
|
14
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
* furnished to do so, subject to the following conditions:
|
|
17
|
+
*
|
|
18
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
* copies or substantial portions of the Software.
|
|
20
|
+
*
|
|
21
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
* SOFTWARE.
|
|
28
|
+
*/
|
|
29
|
+
export declare class AdapterDateFns extends AdapterDateFnsBase<DateFnsLocale> implements MuiPickersAdapter<Date, DateFnsLocale> {
|
|
30
|
+
constructor({ locale, formats }?: AdapterOptions<DateFnsLocale, never>);
|
|
31
|
+
parse: (value: string, format: string) => any;
|
|
32
|
+
isValid: (value: Date | null) => any;
|
|
33
|
+
format: (value: Date, formatKey: keyof AdapterFormats) => any;
|
|
34
|
+
formatByString: (value: Date, formatString: string) => any;
|
|
35
|
+
isEqual: (value: Date | null, comparing: Date | null) => any;
|
|
36
|
+
isSameYear: (value: Date, comparing: Date) => any;
|
|
37
|
+
isSameMonth: (value: Date, comparing: Date) => any;
|
|
38
|
+
isSameDay: (value: Date, comparing: Date) => any;
|
|
39
|
+
isSameHour: (value: Date, comparing: Date) => any;
|
|
40
|
+
isAfter: (value: Date, comparing: Date) => any;
|
|
41
|
+
isAfterYear: (value: Date, comparing: Date) => any;
|
|
42
|
+
isAfterDay: (value: Date, comparing: Date) => any;
|
|
43
|
+
isBefore: (value: Date, comparing: Date) => any;
|
|
44
|
+
isBeforeYear: (value: Date, comparing: Date) => any;
|
|
45
|
+
isBeforeDay: (value: Date, comparing: Date) => any;
|
|
46
|
+
isWithinRange: (value: Date, [start, end]: [Date, Date]) => any;
|
|
47
|
+
startOfYear: (value: Date) => any;
|
|
48
|
+
startOfMonth: (value: Date) => any;
|
|
49
|
+
startOfWeek: (value: Date) => any;
|
|
50
|
+
startOfDay: (value: Date) => any;
|
|
51
|
+
endOfYear: (value: Date) => any;
|
|
52
|
+
endOfMonth: (value: Date) => any;
|
|
53
|
+
endOfWeek: (value: Date) => any;
|
|
54
|
+
endOfDay: (value: Date) => any;
|
|
55
|
+
addYears: (value: Date, amount: number) => any;
|
|
56
|
+
addMonths: (value: Date, amount: number) => any;
|
|
57
|
+
addWeeks: (value: Date, amount: number) => any;
|
|
58
|
+
addDays: (value: Date, amount: number) => any;
|
|
59
|
+
addHours: (value: Date, amount: number) => any;
|
|
60
|
+
addMinutes: (value: Date, amount: number) => any;
|
|
61
|
+
addSeconds: (value: Date, amount: number) => any;
|
|
62
|
+
getYear: (value: Date) => any;
|
|
63
|
+
getMonth: (value: Date) => any;
|
|
64
|
+
getDate: (value: Date) => any;
|
|
65
|
+
getHours: (value: Date) => any;
|
|
66
|
+
getMinutes: (value: Date) => any;
|
|
67
|
+
getSeconds: (value: Date) => any;
|
|
68
|
+
getMilliseconds: (value: Date) => any;
|
|
69
|
+
setYear: (value: Date, year: number) => any;
|
|
70
|
+
setMonth: (value: Date, month: number) => any;
|
|
71
|
+
setDate: (value: Date, date: number) => any;
|
|
72
|
+
setHours: (value: Date, hours: number) => any;
|
|
73
|
+
setMinutes: (value: Date, minutes: number) => any;
|
|
74
|
+
setSeconds: (value: Date, seconds: number) => any;
|
|
75
|
+
setMilliseconds: (value: Date, milliseconds: number) => any;
|
|
76
|
+
getDaysInMonth: (value: Date) => any;
|
|
77
|
+
getWeekArray: (value: Date) => Date[][];
|
|
78
|
+
getWeekNumber: (value: Date) => any;
|
|
79
|
+
getYearRange: ([start, end]: [Date, Date]) => Date[];
|
|
80
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/* eslint-disable class-methods-use-this */
|
|
2
|
+
// TODO remove when date-fns-v3 is the default
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
import { addDays } from 'date-fns/addDays';
|
|
5
|
+
import { addSeconds } from 'date-fns/addSeconds';
|
|
6
|
+
import { addMinutes } from 'date-fns/addMinutes';
|
|
7
|
+
import { addHours } from 'date-fns/addHours';
|
|
8
|
+
import { addWeeks } from 'date-fns/addWeeks';
|
|
9
|
+
import { addMonths } from 'date-fns/addMonths';
|
|
10
|
+
import { addYears } from 'date-fns/addYears';
|
|
11
|
+
import { endOfDay } from 'date-fns/endOfDay';
|
|
12
|
+
import { endOfWeek } from 'date-fns/endOfWeek';
|
|
13
|
+
import { endOfYear } from 'date-fns/endOfYear';
|
|
14
|
+
// @ts-ignore TODO remove when date-fns-v3 is the default
|
|
15
|
+
import { format as dateFnsFormat, longFormatters } from 'date-fns/format';
|
|
16
|
+
import { getDate } from 'date-fns/getDate';
|
|
17
|
+
import { getDaysInMonth } from 'date-fns/getDaysInMonth';
|
|
18
|
+
import { getHours } from 'date-fns/getHours';
|
|
19
|
+
import { getMinutes } from 'date-fns/getMinutes';
|
|
20
|
+
import { getMonth } from 'date-fns/getMonth';
|
|
21
|
+
import { getSeconds } from 'date-fns/getSeconds';
|
|
22
|
+
import { getMilliseconds } from 'date-fns/getMilliseconds';
|
|
23
|
+
import { getWeek } from 'date-fns/getWeek';
|
|
24
|
+
import { getYear } from 'date-fns/getYear';
|
|
25
|
+
import { isAfter } from 'date-fns/isAfter';
|
|
26
|
+
import { isBefore } from 'date-fns/isBefore';
|
|
27
|
+
import { isEqual } from 'date-fns/isEqual';
|
|
28
|
+
import { isSameDay } from 'date-fns/isSameDay';
|
|
29
|
+
import { isSameYear } from 'date-fns/isSameYear';
|
|
30
|
+
import { isSameMonth } from 'date-fns/isSameMonth';
|
|
31
|
+
import { isSameHour } from 'date-fns/isSameHour';
|
|
32
|
+
import { isValid } from 'date-fns/isValid';
|
|
33
|
+
import { parse as dateFnsParse } from 'date-fns/parse';
|
|
34
|
+
import { setDate } from 'date-fns/setDate';
|
|
35
|
+
import { setHours } from 'date-fns/setHours';
|
|
36
|
+
import { setMinutes } from 'date-fns/setMinutes';
|
|
37
|
+
import { setMonth } from 'date-fns/setMonth';
|
|
38
|
+
import { setSeconds } from 'date-fns/setSeconds';
|
|
39
|
+
import { setMilliseconds } from 'date-fns/setMilliseconds';
|
|
40
|
+
import { setYear } from 'date-fns/setYear';
|
|
41
|
+
import { startOfDay } from 'date-fns/startOfDay';
|
|
42
|
+
import { startOfMonth } from 'date-fns/startOfMonth';
|
|
43
|
+
import { endOfMonth } from 'date-fns/endOfMonth';
|
|
44
|
+
import { startOfWeek } from 'date-fns/startOfWeek';
|
|
45
|
+
import { startOfYear } from 'date-fns/startOfYear';
|
|
46
|
+
import { isWithinInterval } from 'date-fns/isWithinInterval';
|
|
47
|
+
import { enUS } from 'date-fns/locale/en-US';
|
|
48
|
+
// date-fns v2 does not export types
|
|
49
|
+
// @ts-ignore TODO remove when date-fns-v3 is the default
|
|
50
|
+
|
|
51
|
+
import { AdapterDateFnsBase } from '../AdapterDateFnsBase';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Based on `@date-io/date-fns`
|
|
55
|
+
*
|
|
56
|
+
* MIT License
|
|
57
|
+
*
|
|
58
|
+
* Copyright (c) 2017 Dmitriy Kovalenko
|
|
59
|
+
*
|
|
60
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
61
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
62
|
+
* in the Software without restriction, including without limitation the rights
|
|
63
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
64
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
65
|
+
* furnished to do so, subject to the following conditions:
|
|
66
|
+
*
|
|
67
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
68
|
+
* copies or substantial portions of the Software.
|
|
69
|
+
*
|
|
70
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
71
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
72
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
73
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
74
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
75
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
76
|
+
* SOFTWARE.
|
|
77
|
+
*/
|
|
78
|
+
export class AdapterDateFns extends AdapterDateFnsBase {
|
|
79
|
+
constructor({
|
|
80
|
+
locale,
|
|
81
|
+
formats
|
|
82
|
+
} = {}) {
|
|
83
|
+
if (typeof addDays !== 'function') {
|
|
84
|
+
throw new Error([`MUI: The \`date-fns\` package v2.x is not compatible with this adapter.`, 'Please, install v3.x of the package or use the `AdapterDateFns` instead.'].join('\n'));
|
|
85
|
+
}
|
|
86
|
+
if (!longFormatters) {
|
|
87
|
+
throw new Error('MUI: The minimum supported `date-fns` package version compatible with this adapter is `3.2.x`.');
|
|
88
|
+
}
|
|
89
|
+
super({
|
|
90
|
+
locale: locale != null ? locale : enUS,
|
|
91
|
+
formats,
|
|
92
|
+
longFormatters
|
|
93
|
+
});
|
|
94
|
+
this.parse = (value, format) => {
|
|
95
|
+
if (value === '') {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
return dateFnsParse(value, format, new Date(), {
|
|
99
|
+
locale: this.locale
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
this.isValid = value => {
|
|
103
|
+
if (value == null) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return isValid(value);
|
|
107
|
+
};
|
|
108
|
+
this.format = (value, formatKey) => {
|
|
109
|
+
return this.formatByString(value, this.formats[formatKey]);
|
|
110
|
+
};
|
|
111
|
+
this.formatByString = (value, formatString) => {
|
|
112
|
+
return dateFnsFormat(value, formatString, {
|
|
113
|
+
locale: this.locale
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
this.isEqual = (value, comparing) => {
|
|
117
|
+
if (value === null && comparing === null) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
if (value === null || comparing === null) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return isEqual(value, comparing);
|
|
124
|
+
};
|
|
125
|
+
this.isSameYear = (value, comparing) => {
|
|
126
|
+
return isSameYear(value, comparing);
|
|
127
|
+
};
|
|
128
|
+
this.isSameMonth = (value, comparing) => {
|
|
129
|
+
return isSameMonth(value, comparing);
|
|
130
|
+
};
|
|
131
|
+
this.isSameDay = (value, comparing) => {
|
|
132
|
+
return isSameDay(value, comparing);
|
|
133
|
+
};
|
|
134
|
+
this.isSameHour = (value, comparing) => {
|
|
135
|
+
return isSameHour(value, comparing);
|
|
136
|
+
};
|
|
137
|
+
this.isAfter = (value, comparing) => {
|
|
138
|
+
return isAfter(value, comparing);
|
|
139
|
+
};
|
|
140
|
+
this.isAfterYear = (value, comparing) => {
|
|
141
|
+
return isAfter(value, endOfYear(comparing));
|
|
142
|
+
};
|
|
143
|
+
this.isAfterDay = (value, comparing) => {
|
|
144
|
+
return isAfter(value, endOfDay(comparing));
|
|
145
|
+
};
|
|
146
|
+
this.isBefore = (value, comparing) => {
|
|
147
|
+
return isBefore(value, comparing);
|
|
148
|
+
};
|
|
149
|
+
this.isBeforeYear = (value, comparing) => {
|
|
150
|
+
return isBefore(value, this.startOfYear(comparing));
|
|
151
|
+
};
|
|
152
|
+
this.isBeforeDay = (value, comparing) => {
|
|
153
|
+
return isBefore(value, this.startOfDay(comparing));
|
|
154
|
+
};
|
|
155
|
+
this.isWithinRange = (value, [start, end]) => {
|
|
156
|
+
return isWithinInterval(value, {
|
|
157
|
+
start,
|
|
158
|
+
end
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
this.startOfYear = value => {
|
|
162
|
+
return startOfYear(value);
|
|
163
|
+
};
|
|
164
|
+
this.startOfMonth = value => {
|
|
165
|
+
return startOfMonth(value);
|
|
166
|
+
};
|
|
167
|
+
this.startOfWeek = value => {
|
|
168
|
+
return startOfWeek(value, {
|
|
169
|
+
locale: this.locale
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
this.startOfDay = value => {
|
|
173
|
+
return startOfDay(value);
|
|
174
|
+
};
|
|
175
|
+
this.endOfYear = value => {
|
|
176
|
+
return endOfYear(value);
|
|
177
|
+
};
|
|
178
|
+
this.endOfMonth = value => {
|
|
179
|
+
return endOfMonth(value);
|
|
180
|
+
};
|
|
181
|
+
this.endOfWeek = value => {
|
|
182
|
+
return endOfWeek(value, {
|
|
183
|
+
locale: this.locale
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
this.endOfDay = value => {
|
|
187
|
+
return endOfDay(value);
|
|
188
|
+
};
|
|
189
|
+
this.addYears = (value, amount) => {
|
|
190
|
+
return addYears(value, amount);
|
|
191
|
+
};
|
|
192
|
+
this.addMonths = (value, amount) => {
|
|
193
|
+
return addMonths(value, amount);
|
|
194
|
+
};
|
|
195
|
+
this.addWeeks = (value, amount) => {
|
|
196
|
+
return addWeeks(value, amount);
|
|
197
|
+
};
|
|
198
|
+
this.addDays = (value, amount) => {
|
|
199
|
+
return addDays(value, amount);
|
|
200
|
+
};
|
|
201
|
+
this.addHours = (value, amount) => {
|
|
202
|
+
return addHours(value, amount);
|
|
203
|
+
};
|
|
204
|
+
this.addMinutes = (value, amount) => {
|
|
205
|
+
return addMinutes(value, amount);
|
|
206
|
+
};
|
|
207
|
+
this.addSeconds = (value, amount) => {
|
|
208
|
+
return addSeconds(value, amount);
|
|
209
|
+
};
|
|
210
|
+
this.getYear = value => {
|
|
211
|
+
return getYear(value);
|
|
212
|
+
};
|
|
213
|
+
this.getMonth = value => {
|
|
214
|
+
return getMonth(value);
|
|
215
|
+
};
|
|
216
|
+
this.getDate = value => {
|
|
217
|
+
return getDate(value);
|
|
218
|
+
};
|
|
219
|
+
this.getHours = value => {
|
|
220
|
+
return getHours(value);
|
|
221
|
+
};
|
|
222
|
+
this.getMinutes = value => {
|
|
223
|
+
return getMinutes(value);
|
|
224
|
+
};
|
|
225
|
+
this.getSeconds = value => {
|
|
226
|
+
return getSeconds(value);
|
|
227
|
+
};
|
|
228
|
+
this.getMilliseconds = value => {
|
|
229
|
+
return getMilliseconds(value);
|
|
230
|
+
};
|
|
231
|
+
this.setYear = (value, year) => {
|
|
232
|
+
return setYear(value, year);
|
|
233
|
+
};
|
|
234
|
+
this.setMonth = (value, month) => {
|
|
235
|
+
return setMonth(value, month);
|
|
236
|
+
};
|
|
237
|
+
this.setDate = (value, date) => {
|
|
238
|
+
return setDate(value, date);
|
|
239
|
+
};
|
|
240
|
+
this.setHours = (value, hours) => {
|
|
241
|
+
return setHours(value, hours);
|
|
242
|
+
};
|
|
243
|
+
this.setMinutes = (value, minutes) => {
|
|
244
|
+
return setMinutes(value, minutes);
|
|
245
|
+
};
|
|
246
|
+
this.setSeconds = (value, seconds) => {
|
|
247
|
+
return setSeconds(value, seconds);
|
|
248
|
+
};
|
|
249
|
+
this.setMilliseconds = (value, milliseconds) => {
|
|
250
|
+
return setMilliseconds(value, milliseconds);
|
|
251
|
+
};
|
|
252
|
+
this.getDaysInMonth = value => {
|
|
253
|
+
return getDaysInMonth(value);
|
|
254
|
+
};
|
|
255
|
+
this.getWeekArray = value => {
|
|
256
|
+
const start = this.startOfWeek(this.startOfMonth(value));
|
|
257
|
+
const end = this.endOfWeek(this.endOfMonth(value));
|
|
258
|
+
let count = 0;
|
|
259
|
+
let current = start;
|
|
260
|
+
const nestedWeeks = [];
|
|
261
|
+
while (this.isBefore(current, end)) {
|
|
262
|
+
const weekNumber = Math.floor(count / 7);
|
|
263
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
264
|
+
nestedWeeks[weekNumber].push(current);
|
|
265
|
+
current = this.addDays(current, 1);
|
|
266
|
+
count += 1;
|
|
267
|
+
}
|
|
268
|
+
return nestedWeeks;
|
|
269
|
+
};
|
|
270
|
+
this.getWeekNumber = value => {
|
|
271
|
+
return getWeek(value, {
|
|
272
|
+
locale: this.locale
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
this.getYearRange = ([start, end]) => {
|
|
276
|
+
const startDate = this.startOfYear(start);
|
|
277
|
+
const endDate = this.endOfYear(end);
|
|
278
|
+
const years = [];
|
|
279
|
+
let current = startDate;
|
|
280
|
+
while (this.isBefore(current, endDate)) {
|
|
281
|
+
years.push(current);
|
|
282
|
+
current = this.addYears(current, 1);
|
|
283
|
+
}
|
|
284
|
+
return years;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AdapterDateFns } from './AdapterDateFnsV3';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AdapterDateFns } from './AdapterDateFnsV3';
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,90 @@
|
|
|
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.0.0-alpha.8
|
|
7
|
+
|
|
8
|
+
_Jan 11, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- ⏰ Support date-fns v3 (#11659) @LukasTy
|
|
13
|
+
Pickers support both v2 and v3 of date-fns. For v3 use `AdapterDateFnsV3`.
|
|
14
|
+
```js
|
|
15
|
+
// with date-fns v2.x
|
|
16
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
17
|
+
import de from 'date-fns/locale/de';
|
|
18
|
+
```
|
|
19
|
+
```js
|
|
20
|
+
// with date-fns v3.x
|
|
21
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
|
|
22
|
+
import { de } from 'date-fns/locale/de';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Data Grid
|
|
26
|
+
|
|
27
|
+
#### Breaking changes
|
|
28
|
+
|
|
29
|
+
- The import path for locales has been changed:
|
|
30
|
+
|
|
31
|
+
```diff
|
|
32
|
+
-import { enUS } from '@mui/x-data-grid';
|
|
33
|
+
+import { enUS } from '@mui/x-data-grid/locales';
|
|
34
|
+
|
|
35
|
+
-import { enUS } from '@mui/x-data-grid-pro';
|
|
36
|
+
+import { enUS } from '@mui/x-data-grid-pro/locales';
|
|
37
|
+
|
|
38
|
+
-import { enUS } from '@mui/x-data-grid-premium';
|
|
39
|
+
+import { enUS } from '@mui/x-data-grid-premium/locales';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### `@mui/x-data-grid@7.0.0-alpha.8`
|
|
43
|
+
|
|
44
|
+
- [DataGrid] Stop exporting locales from the package root (#11614) @cherniavskii
|
|
45
|
+
|
|
46
|
+
#### `@mui/x-data-grid-pro@7.0.0-alpha.8` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
47
|
+
|
|
48
|
+
Same changes as in `@mui/x-data-grid@7.0.0-alpha.8`.
|
|
49
|
+
|
|
50
|
+
#### `@mui/x-data-grid-premium@7.0.0-alpha.8` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
51
|
+
|
|
52
|
+
Same changes as in `@mui/x-data-grid-pro@7.0.0-alpha.8`.
|
|
53
|
+
|
|
54
|
+
### Date Pickers
|
|
55
|
+
|
|
56
|
+
#### `@mui/x-date-pickers@7.0.0-alpha.8`
|
|
57
|
+
|
|
58
|
+
- [pickers] Add `date-fns@3.x` adapter (#11462) @LukasTy
|
|
59
|
+
- [pickers] Avoid deeper than 2nd level imports (#11588) @LukasTy
|
|
60
|
+
- [pickers] Fix clearable behavior blocking focus return to `OpenPickerButton` (#11642) @noraleonte
|
|
61
|
+
- [pickers] Move `DateRange` to `@mui/x-date-pickers-pro/models` (#11611) @flaviendelangle
|
|
62
|
+
- [l10n] Add missing Danish (da-DK) locale export (#11640) @etlos
|
|
63
|
+
|
|
64
|
+
#### `@mui/x-date-pickers-pro@7.0.0-alpha.8` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
65
|
+
|
|
66
|
+
Same changes as in `@mui/x-date-pickers@7.0.0-alpha.8`.
|
|
67
|
+
|
|
68
|
+
### Tree View / `@mui/x-tree-view@7.0.0-alpha.8`
|
|
69
|
+
|
|
70
|
+
- [tree view] Cleanup `onKeyDown` handler (#11481) @flaviendelangle
|
|
71
|
+
- [tree view] Define the parameters used by each plugin to avoid listing them in each component (#11473) @flaviendelangle
|
|
72
|
+
|
|
73
|
+
### Docs
|
|
74
|
+
|
|
75
|
+
- [docs] Fix parsing of `x-date-pickers-pro` demo adapter imports (#11628) @LukasTy
|
|
76
|
+
- [docs] Improve `git diff` format @oliviertassinari
|
|
77
|
+
- [docs] Push up the MUI X brand (#11533) @oliviertassinari
|
|
78
|
+
- [docs] Remove old data grid translation files (#11646) @cherniavskii
|
|
79
|
+
- [docs] Improve Server-side data grid docs (#11589) @oliviertassinari
|
|
80
|
+
- [docs] Improve charts landing page (#11570) @oliviertassinari
|
|
81
|
+
|
|
82
|
+
### Core
|
|
83
|
+
|
|
84
|
+
- [core] Lock `jsdom` version (#11652) @cherniavskii
|
|
85
|
+
- [core] Remove PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD (#11608) @oliviertassinari
|
|
86
|
+
- [core] Simplify isSsr logic (#11606) @oliviertassinari
|
|
87
|
+
- [core] Sync playwright cache between MUI X and Material UI (#11607) @oliviertassinari
|
|
88
|
+
- [core] Use MUI X official name in errors (#11645) @oliviertassinari
|
|
89
|
+
|
|
6
90
|
## 7.0.0-alpha.7
|
|
7
91
|
|
|
8
92
|
_Jan 5, 2024_
|
|
@@ -28,7 +112,7 @@ We'd like to offer a big thanks to the 7 contributors who made this release poss
|
|
|
28
112
|
label: 'Node 2',
|
|
29
113
|
},
|
|
30
114
|
];
|
|
31
|
-
|
|
115
|
+
|
|
32
116
|
<RichTreeView
|
|
33
117
|
items={MUI_X_PRODUCTS}
|
|
34
118
|
defaultCollapseIcon={<ExpandMoreIcon />}
|
|
@@ -88,10 +172,10 @@ Same changes as in `@mui/x-date-pickers@7.0.0-alpha.7`.
|
|
|
88
172
|
<TreeView
|
|
89
173
|
- onNodeToggle={handleExpansionChange}
|
|
90
174
|
+ onExpandedNodesChange={handleExpansionChange}
|
|
91
|
-
|
|
175
|
+
|
|
92
176
|
- expanded={expandedNodes}
|
|
93
177
|
+ expandedNodes={expandedNodes}
|
|
94
|
-
|
|
178
|
+
|
|
95
179
|
- defaultExpanded={defaultExpandedNodes}
|
|
96
180
|
+ defaultExpandedNodes={defaultExpandedNodes}
|
|
97
181
|
/>
|
|
@@ -274,10 +358,10 @@ Same changes as in `@mui/x-data-grid-pro@7.0.0-alpha.5`.
|
|
|
274
358
|
The `SlotsComponent` suffix has been replaced with `Slots` and `SlotsComponentsProps` with `SlotProps`.
|
|
275
359
|
|
|
276
360
|
```diff
|
|
277
|
-
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
+
|
|
361
|
+
-DateCalendarSlotsComponent
|
|
362
|
+
-DateCalendarSlotsComponentsProps
|
|
363
|
+
+DateCalendarSlots
|
|
364
|
+
+DateCalendarSlotProps
|
|
281
365
|
```
|
|
282
366
|
|
|
283
367
|
- Move `inputRef` inside the props passed to the field hooks
|
|
@@ -285,26 +369,26 @@ The `SlotsComponent` suffix has been replaced with `Slots` and `SlotsComponentsP
|
|
|
285
369
|
The field hooks now only receive the props instead of an object containing both the props and the `inputRef`.
|
|
286
370
|
|
|
287
371
|
```diff
|
|
288
|
-
-
|
|
289
|
-
-
|
|
290
|
-
+
|
|
372
|
+
-const { inputRef, ...otherProps } = props
|
|
373
|
+
-const fieldResponse = useDateField({ props: otherProps, inputRef });
|
|
374
|
+
+const fieldResponse = useDateField(props);
|
|
291
375
|
```
|
|
292
376
|
|
|
293
377
|
If you are using a multi input range field hook, the same applies to `startInputRef` and `endInputRef` params
|
|
294
378
|
|
|
295
379
|
```diff
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
-
|
|
304
|
-
-
|
|
305
|
-
+
|
|
306
|
-
+
|
|
307
|
-
|
|
380
|
+
-const { inputRef: startInputRef, ...otherStartTextFieldProps } = startTextFieldProps
|
|
381
|
+
-const { inputRef: endInputRef, ...otherEndTextFieldProps } = endTextFieldProps
|
|
382
|
+
|
|
383
|
+
const fieldResponse = useMultiInputDateRangeField({
|
|
384
|
+
sharedProps,
|
|
385
|
+
- startTextFieldProps: otherStartTextFieldProps,
|
|
386
|
+
- endTextFieldProps: otherEndTextFieldProps,
|
|
387
|
+
- startInputRef
|
|
388
|
+
- endInputRef,
|
|
389
|
+
+ startTextFieldProps,
|
|
390
|
+
+ endTextFieldProps
|
|
391
|
+
});
|
|
308
392
|
```
|
|
309
393
|
|
|
310
394
|
- Rename the ref returned by the field hooks to `inputRef`
|
|
@@ -313,26 +397,26 @@ The `SlotsComponent` suffix has been replaced with `Slots` and `SlotsComponentsP
|
|
|
313
397
|
This ref was previously named `ref` and has been renamed `inputRef` for extra clarity.
|
|
314
398
|
|
|
315
399
|
```diff
|
|
316
|
-
|
|
400
|
+
const fieldResponse = useDateField(props);
|
|
317
401
|
|
|
318
|
-
-
|
|
319
|
-
+
|
|
402
|
+
-return <input ref={fieldResponse.ref} />
|
|
403
|
+
+return <input ref={fieldResponse.inputRef} />
|
|
320
404
|
```
|
|
321
405
|
|
|
322
406
|
If you are using a multi input range field hook, the same applies to the ref in the `startDate` and `endDate` objects
|
|
323
407
|
|
|
324
408
|
```diff
|
|
325
|
-
|
|
409
|
+
const fieldResponse = useDateField(props);
|
|
326
410
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
-
|
|
330
|
-
+
|
|
331
|
-
|
|
332
|
-
-
|
|
333
|
-
+
|
|
334
|
-
|
|
335
|
-
|
|
411
|
+
return (
|
|
412
|
+
<div>
|
|
413
|
+
- <input ref={fieldResponse.startDate.ref} />
|
|
414
|
+
+ <input ref={fieldResponse.startDate.inputRef} />
|
|
415
|
+
<span>–</span>
|
|
416
|
+
- <input ref={fieldResponse.endDate.ref} />
|
|
417
|
+
+ <input ref={fieldResponse.endDate.inputRef} />
|
|
418
|
+
</div>
|
|
419
|
+
)
|
|
336
420
|
```
|
|
337
421
|
|
|
338
422
|
- Restructure the API of `useClearableField`
|
|
@@ -342,23 +426,23 @@ The `SlotsComponent` suffix has been replaced with `Slots` and `SlotsComponentsP
|
|
|
342
426
|
You should now be able to directly pass the returned value from your field hook (e.g: `useDateField`) to `useClearableField`
|
|
343
427
|
|
|
344
428
|
```diff
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
-
|
|
348
|
-
-
|
|
349
|
-
-
|
|
350
|
-
-
|
|
351
|
-
-
|
|
352
|
-
-
|
|
353
|
-
-
|
|
354
|
-
-
|
|
355
|
-
-
|
|
429
|
+
const fieldResponse = useDateField(props);
|
|
430
|
+
|
|
431
|
+
-const { InputProps, onClear, clearable, slots, slotProps, ...otherFieldProps } = fieldResponse
|
|
432
|
+
-const { InputProps: ProcessedInputProps, fieldProps: processedFieldProps } = useClearableField({
|
|
433
|
+
- fieldProps: otherFieldProps,
|
|
434
|
+
- InputProps,
|
|
435
|
+
- clearable,
|
|
436
|
+
- onClear,
|
|
437
|
+
- slots,
|
|
438
|
+
- slotProps,
|
|
439
|
+
-});
|
|
356
440
|
-
|
|
357
|
-
-
|
|
441
|
+
- return <MyCustomTextField {...processedFieldProps} InputProps={ProcessedInputProps} />
|
|
358
442
|
|
|
359
|
-
+
|
|
443
|
+
+const processedFieldProps = useClearableField(fieldResponse);
|
|
360
444
|
+
|
|
361
|
-
+
|
|
445
|
+
+return <MyCustomTextField {...processedFieldProps} />
|
|
362
446
|
```
|
|
363
447
|
|
|
364
448
|
#### `@mui/x-date-pickers@7.0.0-alpha.5`
|
|
@@ -1340,6 +1424,48 @@ Here is an example of the renaming for the `<ChartsTooltip />` component.
|
|
|
1340
1424
|
- [core] Update release instructions as per v7 configuration (#10962) @MBilalShafi
|
|
1341
1425
|
- [license] Correctly throw errors (#10924) @oliviertassinari
|
|
1342
1426
|
|
|
1427
|
+
## 6.19.0
|
|
1428
|
+
|
|
1429
|
+
_Jan 11, 2024_
|
|
1430
|
+
|
|
1431
|
+
We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
|
|
1432
|
+
|
|
1433
|
+
- ⏰ Support date-fns v3 (#11659) @LukasTy
|
|
1434
|
+
Pickers support both v2 and v3 of date-fns. For v3 use `AdapterDateFnsV3`.
|
|
1435
|
+
```js
|
|
1436
|
+
// with date-fns v2.x
|
|
1437
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
|
1438
|
+
import de from 'date-fns/locale/de';
|
|
1439
|
+
```
|
|
1440
|
+
```js
|
|
1441
|
+
// with date-fns v3.x
|
|
1442
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
|
|
1443
|
+
import { de } from 'date-fns/locale/de';
|
|
1444
|
+
```
|
|
1445
|
+
|
|
1446
|
+
### Date Pickers
|
|
1447
|
+
|
|
1448
|
+
#### `@mui/x-date-pickers@6.19.0`
|
|
1449
|
+
|
|
1450
|
+
- [pickers] Add date-fns@3.x adapter (#11659) @LukasTy
|
|
1451
|
+
- [pickers] Fix clearable behavior blocking focus return to `OpenPickerButton` (#11643) @noraleonte
|
|
1452
|
+
- [l10n] Add missing Danish (da-DK) locale export (#11641) @etlos
|
|
1453
|
+
|
|
1454
|
+
#### `@mui/x-date-pickers-pro@6.19.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
1455
|
+
|
|
1456
|
+
Same changes as in `@mui/x-date-pickers@6.19.0`.
|
|
1457
|
+
|
|
1458
|
+
### Docs
|
|
1459
|
+
|
|
1460
|
+
- [docs] Add missing component @oliviertassinari
|
|
1461
|
+
- [docs] Fix parsing of `x-date-pickers-pro` demo adapter imports (#11637) @LukasTy
|
|
1462
|
+
- [docs] Push up the MUI X brand (#11533) @oliviertassinari
|
|
1463
|
+
- [docs] Improve Server-side data grid docs (#11589) @oliviertassinari
|
|
1464
|
+
- [docs] Add demo to the charts overview page (#11586) @danilo-leal
|
|
1465
|
+
- [docs] Fix 404 links in the docs @oliviertassinari
|
|
1466
|
+
- [docs] Improve landing page (#11570) @oliviertassinari
|
|
1467
|
+
- [docs] Give a general revision to the docs (#11249) @danilo-leal
|
|
1468
|
+
|
|
1343
1469
|
## 6.18.7
|
|
1344
1470
|
|
|
1345
1471
|
_Jan 5, 2024_
|