@mui/x-date-pickers 7.0.0-alpha.2 → 7.0.0-alpha.3
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.js +10 -14
- package/AdapterDateFnsJalali/AdapterDateFnsJalali.js +12 -16
- package/AdapterDayjs/AdapterDayjs.js +11 -8
- package/AdapterLuxon/AdapterLuxon.d.ts +1 -1
- package/AdapterLuxon/AdapterLuxon.js +29 -16
- package/AdapterMoment/AdapterMoment.d.ts +1 -1
- package/AdapterMoment/AdapterMoment.js +14 -14
- package/AdapterMomentHijri/AdapterMomentHijri.d.ts +0 -1
- package/AdapterMomentHijri/AdapterMomentHijri.js +1 -24
- package/AdapterMomentJalaali/AdapterMomentJalaali.d.ts +0 -2
- package/AdapterMomentJalaali/AdapterMomentJalaali.js +0 -26
- package/CHANGELOG.md +241 -0
- package/DateCalendar/DateCalendar.js +2 -2
- package/DateCalendar/DayCalendar.d.ts +3 -3
- package/DatePicker/DatePicker.js +2 -2
- package/DateTimePicker/DateTimePicker.js +2 -2
- package/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
- package/MobileDatePicker/MobileDatePicker.js +2 -2
- package/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.d.ts +3 -2
- package/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +2 -1
- package/PickersShortcuts/PickersShortcuts.d.ts +1 -1
- package/PickersShortcuts/PickersShortcuts.js +1 -1
- package/README.md +0 -1
- package/StaticDatePicker/StaticDatePicker.js +2 -2
- package/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/index.js +1 -1
- package/internals/components/PickersTextField/Outline.d.ts +2 -0
- package/internals/components/PickersTextField/Outline.js +99 -0
- package/internals/components/PickersTextField/PickersInput.d.ts +4 -0
- package/internals/components/PickersTextField/PickersInput.js +264 -0
- package/internals/components/PickersTextField/PickersInput.types.d.ts +30 -0
- package/internals/components/PickersTextField/PickersInput.types.js +1 -0
- package/internals/components/PickersTextField/PickersTextField.d.ts +3 -0
- package/internals/components/PickersTextField/PickersTextField.js +120 -0
- package/internals/components/PickersTextField/PickersTextField.types.d.ts +18 -0
- package/internals/components/PickersTextField/PickersTextField.types.js +1 -0
- package/internals/components/PickersTextField/index.d.ts +1 -0
- package/internals/components/PickersTextField/index.js +1 -0
- package/internals/components/PickersTextField/pickersTextFieldClasses.d.ts +42 -0
- package/internals/components/PickersTextField/pickersTextFieldClasses.js +9 -0
- package/internals/hooks/useField/useField.utils.js +23 -10
- package/internals/hooks/usePicker/usePickerValue.js +2 -6
- package/internals/hooks/usePicker/usePickerValue.types.d.ts +2 -2
- package/legacy/AdapterDateFns/AdapterDateFns.js +10 -14
- package/legacy/AdapterDateFnsJalali/AdapterDateFnsJalali.js +12 -16
- package/legacy/AdapterDayjs/AdapterDayjs.js +11 -8
- package/legacy/AdapterLuxon/AdapterLuxon.js +30 -17
- package/legacy/AdapterMoment/AdapterMoment.js +326 -320
- package/legacy/AdapterMomentHijri/AdapterMomentHijri.js +4 -25
- package/legacy/AdapterMomentJalaali/AdapterMomentJalaali.js +0 -30
- package/legacy/DateCalendar/DateCalendar.js +2 -2
- package/legacy/DatePicker/DatePicker.js +2 -2
- package/legacy/DateTimePicker/DateTimePicker.js +2 -2
- package/legacy/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/legacy/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
- package/legacy/MobileDatePicker/MobileDatePicker.js +2 -2
- package/legacy/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
- package/legacy/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +2 -1
- package/legacy/PickersShortcuts/PickersShortcuts.js +2 -1
- package/legacy/StaticDatePicker/StaticDatePicker.js +2 -2
- package/legacy/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/legacy/index.js +1 -1
- package/legacy/internals/components/PickersTextField/Outline.js +100 -0
- package/legacy/internals/components/PickersTextField/PickersInput.js +273 -0
- package/legacy/internals/components/PickersTextField/PickersInput.types.js +1 -0
- package/legacy/internals/components/PickersTextField/PickersTextField.js +129 -0
- package/legacy/internals/components/PickersTextField/PickersTextField.types.js +1 -0
- package/legacy/internals/components/PickersTextField/index.js +1 -0
- package/legacy/internals/components/PickersTextField/pickersTextFieldClasses.js +9 -0
- package/legacy/internals/hooks/useField/useField.utils.js +23 -10
- package/legacy/internals/hooks/usePicker/usePickerValue.js +2 -6
- package/locales/beBY.d.ts +18 -5
- package/locales/caES.d.ts +18 -5
- package/locales/csCZ.d.ts +18 -5
- package/locales/daDK.d.ts +18 -5
- package/locales/deDE.d.ts +18 -5
- package/locales/elGR.d.ts +18 -5
- package/locales/enUS.d.ts +18 -5
- package/locales/esES.d.ts +18 -5
- package/locales/eu.d.ts +18 -5
- package/locales/faIR.d.ts +18 -5
- package/locales/fiFI.d.ts +18 -5
- package/locales/frFR.d.ts +18 -5
- package/locales/heIL.d.ts +18 -5
- package/locales/huHU.d.ts +18 -5
- package/locales/isIS.d.ts +18 -5
- package/locales/itIT.d.ts +18 -5
- package/locales/jaJP.d.ts +18 -5
- package/locales/koKR.d.ts +18 -5
- package/locales/kzKZ.d.ts +18 -5
- package/locales/mk.d.ts +18 -5
- package/locales/nbNO.d.ts +18 -5
- package/locales/nlNL.d.ts +18 -5
- package/locales/plPL.d.ts +18 -5
- package/locales/ptBR.d.ts +18 -5
- package/locales/roRO.d.ts +18 -5
- package/locales/ruRU.d.ts +18 -5
- package/locales/skSK.d.ts +18 -5
- package/locales/svSE.d.ts +18 -5
- package/locales/trTR.d.ts +18 -5
- package/locales/ukUA.d.ts +18 -5
- package/locales/urPK.d.ts +18 -5
- package/locales/utils/getPickersLocalization.d.ts +18 -5
- package/locales/utils/pickersLocaleTextApi.d.ts +18 -5
- package/locales/viVN.d.ts +18 -5
- package/locales/zhCN.d.ts +18 -5
- package/locales/zhHK.d.ts +18 -5
- package/modern/AdapterDateFns/AdapterDateFns.js +10 -14
- package/modern/AdapterDateFnsJalali/AdapterDateFnsJalali.js +12 -16
- package/modern/AdapterDayjs/AdapterDayjs.js +11 -8
- package/modern/AdapterLuxon/AdapterLuxon.js +28 -16
- package/modern/AdapterMoment/AdapterMoment.js +14 -14
- package/modern/AdapterMomentHijri/AdapterMomentHijri.js +1 -24
- package/modern/AdapterMomentJalaali/AdapterMomentJalaali.js +0 -26
- package/modern/DateCalendar/DateCalendar.js +2 -2
- package/modern/DatePicker/DatePicker.js +2 -2
- package/modern/DateTimePicker/DateTimePicker.js +2 -2
- package/modern/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/modern/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
- package/modern/MobileDatePicker/MobileDatePicker.js +2 -2
- package/modern/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
- package/modern/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +2 -1
- package/modern/PickersShortcuts/PickersShortcuts.js +1 -1
- package/modern/StaticDatePicker/StaticDatePicker.js +2 -2
- package/modern/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersTextField/Outline.js +99 -0
- package/modern/internals/components/PickersTextField/PickersInput.js +264 -0
- package/modern/internals/components/PickersTextField/PickersInput.types.js +1 -0
- package/modern/internals/components/PickersTextField/PickersTextField.js +119 -0
- package/modern/internals/components/PickersTextField/PickersTextField.types.js +1 -0
- package/modern/internals/components/PickersTextField/index.js +1 -0
- package/modern/internals/components/PickersTextField/pickersTextFieldClasses.js +9 -0
- package/modern/internals/hooks/useField/useField.utils.js +23 -10
- package/modern/internals/hooks/usePicker/usePickerValue.js +2 -6
- package/node/AdapterDateFns/AdapterDateFns.js +10 -14
- package/node/AdapterDateFnsJalali/AdapterDateFnsJalali.js +12 -16
- package/node/AdapterDayjs/AdapterDayjs.js +10 -7
- package/node/AdapterLuxon/AdapterLuxon.js +28 -16
- package/node/AdapterMoment/AdapterMoment.js +14 -14
- package/node/AdapterMomentHijri/AdapterMomentHijri.js +1 -24
- package/node/AdapterMomentJalaali/AdapterMomentJalaali.js +0 -26
- package/node/DateCalendar/DateCalendar.js +2 -2
- package/node/DatePicker/DatePicker.js +2 -2
- package/node/DateTimePicker/DateTimePicker.js +2 -2
- package/node/DesktopDatePicker/DesktopDatePicker.js +2 -2
- package/node/DesktopDateTimePicker/DesktopDateTimePicker.js +2 -2
- package/node/MobileDatePicker/MobileDatePicker.js +2 -2
- package/node/MobileDateTimePicker/MobileDateTimePicker.js +2 -2
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.js +2 -0
- package/node/MultiSectionDigitalClock/MultiSectionDigitalClock.utils.js +2 -1
- package/node/PickersShortcuts/PickersShortcuts.js +1 -1
- package/node/StaticDatePicker/StaticDatePicker.js +2 -2
- package/node/StaticDateTimePicker/StaticDateTimePicker.js +2 -2
- package/node/index.js +1 -1
- package/node/internals/components/PickersTextField/Outline.js +108 -0
- package/node/internals/components/PickersTextField/PickersInput.js +272 -0
- package/node/internals/components/PickersTextField/PickersInput.types.js +5 -0
- package/node/internals/components/PickersTextField/PickersTextField.js +127 -0
- package/node/internals/components/PickersTextField/PickersTextField.types.js +5 -0
- package/node/internals/components/PickersTextField/index.js +12 -0
- package/node/internals/components/PickersTextField/pickersTextFieldClasses.js +17 -0
- package/node/internals/hooks/useField/useField.utils.js +23 -10
- package/node/internals/hooks/usePicker/usePickerValue.js +2 -6
- package/package.json +2 -2
- package/internals/components/FakeTextField/FakeTextField.d.ts +0 -22
- package/internals/components/FakeTextField/FakeTextField.js +0 -44
- package/internals/components/FakeTextField/index.d.ts +0 -1
- package/internals/components/FakeTextField/index.js +0 -1
- package/legacy/internals/components/FakeTextField/FakeTextField.js +0 -49
- package/legacy/internals/components/FakeTextField/index.js +0 -1
- package/modern/internals/components/FakeTextField/FakeTextField.js +0 -44
- package/modern/internals/components/FakeTextField/index.js +0 -1
- package/node/internals/components/FakeTextField/FakeTextField.js +0 -52
- package/node/internals/components/FakeTextField/index.js +0 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
5
|
/* eslint-disable class-methods-use-this */
|
|
6
6
|
import defaultMoment from 'moment';
|
|
7
7
|
// From https://momentjs.com/docs/#/displaying/format/
|
|
@@ -150,327 +150,333 @@ var MISSING_TIMEZONE_PLUGIN = ['Missing timezone plugin', 'To be able to use tim
|
|
|
150
150
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
151
151
|
* SOFTWARE.
|
|
152
152
|
*/
|
|
153
|
-
export var AdapterMoment = /*#__PURE__*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (!_this.hasTimezonePlugin()) {
|
|
198
|
-
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
199
|
-
}
|
|
200
|
-
var parsedValue = timezone === 'default' ? _this.moment(value) : _this.moment.tz(value, timezone);
|
|
201
|
-
if (_this.locale === undefined) {
|
|
202
|
-
return parsedValue;
|
|
203
|
-
}
|
|
204
|
-
return parsedValue.locale(_this.locale);
|
|
205
|
-
};
|
|
206
|
-
this.date = function (value) {
|
|
207
|
-
var timezone = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
|
|
208
|
-
if (value === null) {
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
if (timezone === 'UTC') {
|
|
212
|
-
return _this.createUTCDate(value);
|
|
213
|
-
}
|
|
214
|
-
if (timezone === 'system' || timezone === 'default' && !_this.hasTimezonePlugin()) {
|
|
215
|
-
return _this.createSystemDate(value);
|
|
216
|
-
}
|
|
217
|
-
return _this.createTZDate(value, timezone);
|
|
218
|
-
};
|
|
219
|
-
this.getInvalidDate = function () {
|
|
220
|
-
return _this.moment(new Date('Invalid Date'));
|
|
221
|
-
};
|
|
222
|
-
this.getTimezone = function (value) {
|
|
223
|
-
var _value$_z, _ref2, _this$moment$defaultZ;
|
|
224
|
-
// @ts-ignore
|
|
225
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
226
|
-
var zone = (_value$_z = value._z) == null ? void 0 : _value$_z.name;
|
|
227
|
-
var defaultZone = value.isUTC() ? 'UTC' : 'system';
|
|
228
|
-
|
|
229
|
-
// @ts-ignore
|
|
230
|
-
return (_ref2 = zone != null ? zone : (_this$moment$defaultZ = _this.moment.defaultZone) == null ? void 0 : _this$moment$defaultZ.name) != null ? _ref2 : defaultZone;
|
|
231
|
-
};
|
|
232
|
-
this.setTimezone = function (value, timezone) {
|
|
233
|
-
var _this$moment$defaultZ2, _this$moment$defaultZ3;
|
|
234
|
-
if (_this.getTimezone(value) === timezone) {
|
|
235
|
-
return value;
|
|
236
|
-
}
|
|
237
|
-
if (timezone === 'UTC') {
|
|
238
|
-
return value.clone().utc();
|
|
239
|
-
}
|
|
240
|
-
if (timezone === 'system') {
|
|
241
|
-
return value.clone().local();
|
|
242
|
-
}
|
|
243
|
-
if (!_this.hasTimezonePlugin()) {
|
|
153
|
+
export var AdapterMoment = /*#__PURE__*/function () {
|
|
154
|
+
function AdapterMoment() {
|
|
155
|
+
var _this = this;
|
|
156
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
157
|
+
locale = _ref.locale,
|
|
158
|
+
formats = _ref.formats,
|
|
159
|
+
instance = _ref.instance;
|
|
160
|
+
_classCallCheck(this, AdapterMoment);
|
|
161
|
+
this.isMUIAdapter = true;
|
|
162
|
+
this.isTimezoneCompatible = true;
|
|
163
|
+
this.lib = 'moment';
|
|
164
|
+
this.moment = void 0;
|
|
165
|
+
this.locale = void 0;
|
|
166
|
+
this.formats = void 0;
|
|
167
|
+
this.escapedCharacters = {
|
|
168
|
+
start: '[',
|
|
169
|
+
end: ']'
|
|
170
|
+
};
|
|
171
|
+
this.formatTokenMap = formatTokenMap;
|
|
172
|
+
this.setLocaleToValue = function (value) {
|
|
173
|
+
var expectedLocale = _this.getCurrentLocaleCode();
|
|
174
|
+
if (expectedLocale === value.locale()) {
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
return value.locale(expectedLocale);
|
|
178
|
+
};
|
|
179
|
+
this.hasTimezonePlugin = function () {
|
|
180
|
+
return typeof _this.moment.tz !== 'undefined';
|
|
181
|
+
};
|
|
182
|
+
this.createSystemDate = function (value) {
|
|
183
|
+
var parsedValue = _this.moment(value).local();
|
|
184
|
+
if (_this.locale === undefined) {
|
|
185
|
+
return parsedValue;
|
|
186
|
+
}
|
|
187
|
+
return parsedValue.locale(_this.locale);
|
|
188
|
+
};
|
|
189
|
+
this.createUTCDate = function (value) {
|
|
190
|
+
var parsedValue = _this.moment.utc(value);
|
|
191
|
+
if (_this.locale === undefined) {
|
|
192
|
+
return parsedValue;
|
|
193
|
+
}
|
|
194
|
+
return parsedValue.locale(_this.locale);
|
|
195
|
+
};
|
|
196
|
+
this.createTZDate = function (value, timezone) {
|
|
244
197
|
/* istanbul ignore next */
|
|
245
|
-
if (
|
|
198
|
+
if (!_this.hasTimezonePlugin()) {
|
|
246
199
|
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
247
200
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
(_this$moment$defaultZ2 = (_this$moment$defaultZ3 = _this.moment.defaultZone) == null ? void 0 : _this$moment$defaultZ3.name) != null ? _this$moment$defaultZ2 : 'system' : timezone;
|
|
252
|
-
if (cleanZone === 'system') {
|
|
253
|
-
return value.clone().local();
|
|
254
|
-
}
|
|
255
|
-
var newValue = value.clone();
|
|
256
|
-
newValue.tz(cleanZone);
|
|
257
|
-
return newValue;
|
|
258
|
-
};
|
|
259
|
-
this.toJsDate = function (value) {
|
|
260
|
-
return value.toDate();
|
|
261
|
-
};
|
|
262
|
-
this.parse = function (value, format) {
|
|
263
|
-
if (value === '') {
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
if (_this.locale) {
|
|
267
|
-
return _this.moment(value, format, _this.locale, true);
|
|
268
|
-
}
|
|
269
|
-
return _this.moment(value, format, true);
|
|
270
|
-
};
|
|
271
|
-
this.getCurrentLocaleCode = function () {
|
|
272
|
-
return _this.locale || defaultMoment.locale();
|
|
273
|
-
};
|
|
274
|
-
this.is12HourCycleInCurrentLocale = function () {
|
|
275
|
-
return /A|a/.test(defaultMoment.localeData(_this.getCurrentLocaleCode()).longDateFormat('LT'));
|
|
276
|
-
};
|
|
277
|
-
this.expandFormat = function (format) {
|
|
278
|
-
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
279
|
-
var localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
280
|
-
return format.match(localFormattingTokens).map(function (token) {
|
|
281
|
-
var firstCharacter = token[0];
|
|
282
|
-
if (firstCharacter === 'L' || firstCharacter === ';') {
|
|
283
|
-
return defaultMoment.localeData(_this.getCurrentLocaleCode()).longDateFormat(token);
|
|
201
|
+
var parsedValue = timezone === 'default' ? _this.moment(value) : _this.moment.tz(value, timezone);
|
|
202
|
+
if (_this.locale === undefined) {
|
|
203
|
+
return parsedValue;
|
|
284
204
|
}
|
|
285
|
-
return
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
205
|
+
return parsedValue.locale(_this.locale);
|
|
206
|
+
};
|
|
207
|
+
this.date = function (value) {
|
|
208
|
+
var timezone = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
|
|
209
|
+
if (value === null) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
if (timezone === 'UTC') {
|
|
213
|
+
return _this.createUTCDate(value);
|
|
214
|
+
}
|
|
215
|
+
if (timezone === 'system' || timezone === 'default' && !_this.hasTimezonePlugin()) {
|
|
216
|
+
return _this.createSystemDate(value);
|
|
217
|
+
}
|
|
218
|
+
return _this.createTZDate(value, timezone);
|
|
219
|
+
};
|
|
220
|
+
this.getInvalidDate = function () {
|
|
221
|
+
return _this.moment(new Date('Invalid Date'));
|
|
222
|
+
};
|
|
223
|
+
this.getTimezone = function (value) {
|
|
224
|
+
var _value$_z, _ref2, _this$moment$defaultZ;
|
|
225
|
+
// @ts-ignore
|
|
226
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
227
|
+
var zone = (_value$_z = value._z) == null ? void 0 : _value$_z.name;
|
|
228
|
+
var defaultZone = value.isUTC() ? 'UTC' : 'system';
|
|
229
|
+
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
return (_ref2 = zone != null ? zone : (_this$moment$defaultZ = _this.moment.defaultZone) == null ? void 0 : _this$moment$defaultZ.name) != null ? _ref2 : defaultZone;
|
|
232
|
+
};
|
|
233
|
+
this.setTimezone = function (value, timezone) {
|
|
234
|
+
var _this$moment$defaultZ2, _this$moment$defaultZ3;
|
|
235
|
+
if (_this.getTimezone(value) === timezone) {
|
|
236
|
+
return value;
|
|
237
|
+
}
|
|
238
|
+
if (timezone === 'UTC') {
|
|
239
|
+
return value.clone().utc();
|
|
240
|
+
}
|
|
241
|
+
if (timezone === 'system') {
|
|
242
|
+
return value.clone().local();
|
|
243
|
+
}
|
|
244
|
+
if (!_this.hasTimezonePlugin()) {
|
|
245
|
+
/* istanbul ignore next */
|
|
246
|
+
if (timezone !== 'default') {
|
|
247
|
+
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
248
|
+
}
|
|
249
|
+
return value;
|
|
250
|
+
}
|
|
251
|
+
var cleanZone = timezone === 'default' ? // @ts-ignore
|
|
252
|
+
(_this$moment$defaultZ2 = (_this$moment$defaultZ3 = _this.moment.defaultZone) == null ? void 0 : _this$moment$defaultZ3.name) != null ? _this$moment$defaultZ2 : 'system' : timezone;
|
|
253
|
+
if (cleanZone === 'system') {
|
|
254
|
+
return value.clone().local();
|
|
255
|
+
}
|
|
256
|
+
var newValue = value.clone();
|
|
257
|
+
newValue.tz(cleanZone);
|
|
258
|
+
return newValue;
|
|
259
|
+
};
|
|
260
|
+
this.toJsDate = function (value) {
|
|
261
|
+
return value.toDate();
|
|
262
|
+
};
|
|
263
|
+
this.parse = function (value, format) {
|
|
264
|
+
if (value === '') {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
if (_this.locale) {
|
|
268
|
+
return _this.moment(value, format, _this.locale, true);
|
|
269
|
+
}
|
|
270
|
+
return _this.moment(value, format, true);
|
|
271
|
+
};
|
|
272
|
+
this.getCurrentLocaleCode = function () {
|
|
273
|
+
return _this.locale || defaultMoment.locale();
|
|
274
|
+
};
|
|
275
|
+
this.is12HourCycleInCurrentLocale = function () {
|
|
276
|
+
return /A|a/.test(defaultMoment.localeData(_this.getCurrentLocaleCode()).longDateFormat('LT'));
|
|
277
|
+
};
|
|
278
|
+
this.expandFormat = function (format) {
|
|
279
|
+
// @see https://github.com/moment/moment/blob/develop/src/lib/format/format.js#L6
|
|
280
|
+
var localFormattingTokens = /(\[[^[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})|./g;
|
|
281
|
+
return format.match(localFormattingTokens).map(function (token) {
|
|
282
|
+
var firstCharacter = token[0];
|
|
283
|
+
if (firstCharacter === 'L' || firstCharacter === ';') {
|
|
284
|
+
return defaultMoment.localeData(_this.getCurrentLocaleCode()).longDateFormat(token);
|
|
285
|
+
}
|
|
286
|
+
return token;
|
|
287
|
+
}).join('');
|
|
288
|
+
};
|
|
289
|
+
this.isValid = function (value) {
|
|
290
|
+
if (value == null) {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
return value.isValid();
|
|
294
|
+
};
|
|
295
|
+
this.format = function (value, formatKey) {
|
|
296
|
+
return _this.formatByString(value, _this.formats[formatKey]);
|
|
297
|
+
};
|
|
298
|
+
this.formatByString = function (value, formatString) {
|
|
299
|
+
var clonedDate = value.clone();
|
|
300
|
+
clonedDate.locale(_this.getCurrentLocaleCode());
|
|
301
|
+
return clonedDate.format(formatString);
|
|
302
|
+
};
|
|
303
|
+
this.formatNumber = function (numberToFormat) {
|
|
304
|
+
return numberToFormat;
|
|
305
|
+
};
|
|
306
|
+
this.isEqual = function (value, comparing) {
|
|
307
|
+
if (value === null && comparing === null) {
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
if (value === null || comparing === null) {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
return value.isSame(comparing);
|
|
314
|
+
};
|
|
315
|
+
this.isSameYear = function (value, comparing) {
|
|
316
|
+
return value.isSame(comparing, 'year');
|
|
317
|
+
};
|
|
318
|
+
this.isSameMonth = function (value, comparing) {
|
|
319
|
+
return value.isSame(comparing, 'month');
|
|
320
|
+
};
|
|
321
|
+
this.isSameDay = function (value, comparing) {
|
|
322
|
+
return value.isSame(comparing, 'day');
|
|
323
|
+
};
|
|
324
|
+
this.isSameHour = function (value, comparing) {
|
|
325
|
+
return value.isSame(comparing, 'hour');
|
|
326
|
+
};
|
|
327
|
+
this.isAfter = function (value, comparing) {
|
|
328
|
+
return value.isAfter(comparing);
|
|
329
|
+
};
|
|
330
|
+
this.isAfterYear = function (value, comparing) {
|
|
331
|
+
return value.isAfter(comparing, 'year');
|
|
332
|
+
};
|
|
333
|
+
this.isAfterDay = function (value, comparing) {
|
|
334
|
+
return value.isAfter(comparing, 'day');
|
|
335
|
+
};
|
|
336
|
+
this.isBefore = function (value, comparing) {
|
|
337
|
+
return value.isBefore(comparing);
|
|
338
|
+
};
|
|
339
|
+
this.isBeforeYear = function (value, comparing) {
|
|
340
|
+
return value.isBefore(comparing, 'year');
|
|
341
|
+
};
|
|
342
|
+
this.isBeforeDay = function (value, comparing) {
|
|
343
|
+
return value.isBefore(comparing, 'day');
|
|
344
|
+
};
|
|
345
|
+
this.isWithinRange = function (value, _ref3) {
|
|
346
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
347
|
+
start = _ref4[0],
|
|
348
|
+
end = _ref4[1];
|
|
349
|
+
return value.isBetween(start, end, null, '[]');
|
|
350
|
+
};
|
|
351
|
+
this.startOfYear = function (value) {
|
|
352
|
+
return value.clone().startOf('year');
|
|
353
|
+
};
|
|
354
|
+
this.startOfMonth = function (value) {
|
|
355
|
+
return value.clone().startOf('month');
|
|
356
|
+
};
|
|
357
|
+
this.startOfWeek = function (value) {
|
|
358
|
+
return value.clone().startOf('week');
|
|
359
|
+
};
|
|
360
|
+
this.startOfDay = function (value) {
|
|
361
|
+
return value.clone().startOf('day');
|
|
362
|
+
};
|
|
363
|
+
this.endOfYear = function (value) {
|
|
364
|
+
return value.clone().endOf('year');
|
|
365
|
+
};
|
|
366
|
+
this.endOfMonth = function (value) {
|
|
367
|
+
return value.clone().endOf('month');
|
|
368
|
+
};
|
|
369
|
+
this.endOfWeek = function (value) {
|
|
370
|
+
return value.clone().endOf('week');
|
|
371
|
+
};
|
|
372
|
+
this.endOfDay = function (value) {
|
|
373
|
+
return value.clone().endOf('day');
|
|
374
|
+
};
|
|
375
|
+
this.addYears = function (value, amount) {
|
|
376
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'years') : value.clone().add(amount, 'years');
|
|
377
|
+
};
|
|
378
|
+
this.addMonths = function (value, amount) {
|
|
379
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'months') : value.clone().add(amount, 'months');
|
|
380
|
+
};
|
|
381
|
+
this.addWeeks = function (value, amount) {
|
|
382
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'weeks') : value.clone().add(amount, 'weeks');
|
|
383
|
+
};
|
|
384
|
+
this.addDays = function (value, amount) {
|
|
385
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'days') : value.clone().add(amount, 'days');
|
|
386
|
+
};
|
|
387
|
+
this.addHours = function (value, amount) {
|
|
388
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'hours') : value.clone().add(amount, 'hours');
|
|
389
|
+
};
|
|
390
|
+
this.addMinutes = function (value, amount) {
|
|
391
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'minutes') : value.clone().add(amount, 'minutes');
|
|
392
|
+
};
|
|
393
|
+
this.addSeconds = function (value, amount) {
|
|
394
|
+
return amount < 0 ? value.clone().subtract(Math.abs(amount), 'seconds') : value.clone().add(amount, 'seconds');
|
|
395
|
+
};
|
|
396
|
+
this.getYear = function (value) {
|
|
397
|
+
return value.get('year');
|
|
398
|
+
};
|
|
399
|
+
this.getMonth = function (value) {
|
|
400
|
+
return value.get('month');
|
|
401
|
+
};
|
|
402
|
+
this.getDate = function (value) {
|
|
403
|
+
return value.get('date');
|
|
404
|
+
};
|
|
405
|
+
this.getHours = function (value) {
|
|
406
|
+
return value.get('hours');
|
|
407
|
+
};
|
|
408
|
+
this.getMinutes = function (value) {
|
|
409
|
+
return value.get('minutes');
|
|
410
|
+
};
|
|
411
|
+
this.getSeconds = function (value) {
|
|
412
|
+
return value.get('seconds');
|
|
413
|
+
};
|
|
414
|
+
this.getMilliseconds = function (value) {
|
|
415
|
+
return value.get('milliseconds');
|
|
416
|
+
};
|
|
417
|
+
this.setYear = function (value, year) {
|
|
418
|
+
return value.clone().year(year);
|
|
419
|
+
};
|
|
420
|
+
this.setMonth = function (value, month) {
|
|
421
|
+
return value.clone().month(month);
|
|
422
|
+
};
|
|
423
|
+
this.setDate = function (value, date) {
|
|
424
|
+
return value.clone().date(date);
|
|
425
|
+
};
|
|
426
|
+
this.setHours = function (value, hours) {
|
|
427
|
+
return value.clone().hours(hours);
|
|
428
|
+
};
|
|
429
|
+
this.setMinutes = function (value, minutes) {
|
|
430
|
+
return value.clone().minutes(minutes);
|
|
431
|
+
};
|
|
432
|
+
this.setSeconds = function (value, seconds) {
|
|
433
|
+
return value.clone().seconds(seconds);
|
|
434
|
+
};
|
|
435
|
+
this.setMilliseconds = function (value, milliseconds) {
|
|
436
|
+
return value.clone().milliseconds(milliseconds);
|
|
437
|
+
};
|
|
438
|
+
this.getDaysInMonth = function (value) {
|
|
439
|
+
return value.daysInMonth();
|
|
440
|
+
};
|
|
441
|
+
this.getWeekArray = function (value) {
|
|
442
|
+
var cleanValue = _this.setLocaleToValue(value);
|
|
443
|
+
var start = _this.startOfWeek(_this.startOfMonth(cleanValue));
|
|
444
|
+
var end = _this.endOfWeek(_this.endOfMonth(cleanValue));
|
|
445
|
+
var count = 0;
|
|
446
|
+
var current = start;
|
|
447
|
+
var nestedWeeks = [];
|
|
448
|
+
while (current.isBefore(end)) {
|
|
449
|
+
var weekNumber = Math.floor(count / 7);
|
|
450
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
451
|
+
nestedWeeks[weekNumber].push(current);
|
|
452
|
+
current = _this.addDays(current, 1);
|
|
453
|
+
count += 1;
|
|
454
|
+
}
|
|
455
|
+
return nestedWeeks;
|
|
456
|
+
};
|
|
457
|
+
this.getWeekNumber = function (value) {
|
|
458
|
+
return value.week();
|
|
459
|
+
};
|
|
460
|
+
this.moment = instance || defaultMoment;
|
|
461
|
+
this.locale = locale;
|
|
462
|
+
this.formats = _extends({}, defaultFormats, formats);
|
|
463
|
+
}
|
|
464
|
+
_createClass(AdapterMoment, [{
|
|
465
|
+
key: "getYearRange",
|
|
466
|
+
value: function getYearRange(_ref5) {
|
|
467
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
468
|
+
start = _ref6[0],
|
|
469
|
+
end = _ref6[1];
|
|
470
|
+
var startDate = this.startOfYear(start);
|
|
471
|
+
var endDate = this.endOfYear(end);
|
|
472
|
+
var years = [];
|
|
473
|
+
var current = startDate;
|
|
474
|
+
while (this.isBefore(current, endDate)) {
|
|
475
|
+
years.push(current);
|
|
476
|
+
current = this.addYears(current, 1);
|
|
477
|
+
}
|
|
478
|
+
return years;
|
|
470
479
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
this.locale = locale;
|
|
475
|
-
this.formats = _extends({}, defaultFormats, formats);
|
|
476
|
-
});
|
|
480
|
+
}]);
|
|
481
|
+
return AdapterMoment;
|
|
482
|
+
}();
|