@kdcloudjs/kdesign 1.8.73 → 1.8.74
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/dist/kdesign.css +1 -1
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +349 -150
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +1 -1
- package/dist/kdesign.min.js +10 -10
- package/dist/kdesign.min.js.map +1 -1
- package/es/date-picker/date-picker.js +28 -4
- package/es/date-picker/hooks/use-hover-value.d.ts +1 -1
- package/es/date-picker/hooks/use-hover-value.js +4 -2
- package/es/date-picker/hooks/use-value-texts.d.ts +3 -2
- package/es/date-picker/hooks/use-value-texts.js +3 -2
- package/es/date-picker/interface.d.ts +4 -0
- package/es/date-picker/locale/zh_CN.js +2 -0
- package/es/date-picker/range-picker.js +12 -8
- package/es/date-picker/utils/date-fns.d.ts +3 -3
- package/es/date-picker/utils/date-fns.js +73 -12
- package/es/locale/en-US.d.ts +2 -0
- package/es/locale/en-US.js +2 -0
- package/es/locale/locale.d.ts +2 -0
- package/es/locale/zh-CN.d.ts +2 -0
- package/lib/date-picker/date-picker.js +28 -4
- package/lib/date-picker/hooks/use-hover-value.d.ts +1 -1
- package/lib/date-picker/hooks/use-hover-value.js +4 -2
- package/lib/date-picker/hooks/use-value-texts.d.ts +3 -2
- package/lib/date-picker/hooks/use-value-texts.js +3 -2
- package/lib/date-picker/interface.d.ts +4 -0
- package/lib/date-picker/locale/zh_CN.js +2 -0
- package/lib/date-picker/range-picker.js +12 -8
- package/lib/date-picker/utils/date-fns.d.ts +3 -3
- package/lib/date-picker/utils/date-fns.js +73 -12
- package/lib/locale/en-US.d.ts +2 -0
- package/lib/locale/en-US.js +2 -0
- package/lib/locale/locale.d.ts +2 -0
- package/lib/locale/zh-CN.d.ts +2 -0
- package/package.json +1 -1
|
@@ -207,7 +207,12 @@ Object.defineProperty(exports, "subYears", {
|
|
|
207
207
|
return _subYears.default;
|
|
208
208
|
}
|
|
209
209
|
});
|
|
210
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
210
211
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
212
|
+
var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/sort"));
|
|
213
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
214
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
215
|
+
var _padStart = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/pad-start"));
|
|
211
216
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
212
217
|
var _isDate = _interopRequireDefault(require("date-fns/isDate"));
|
|
213
218
|
var _isValid = _interopRequireDefault(require("date-fns/isValid"));
|
|
@@ -294,19 +299,63 @@ function newDate(value) {
|
|
|
294
299
|
var d = value ? typeof value === 'string' || value instanceof String ? (0, _parseISO.default)(value) : (0, _toDate.default)(value) : new Date();
|
|
295
300
|
return isValid(d) ? d : null;
|
|
296
301
|
}
|
|
297
|
-
function parseDate(value, dateFormat) {
|
|
302
|
+
function parseDate(value, dateFormat, locale) {
|
|
298
303
|
var parsedDate = null;
|
|
299
304
|
var strictParsingValueMatch = true;
|
|
300
305
|
if ((0, _includes.default)(dateFormat).call(dateFormat, 'wo')) {
|
|
301
306
|
return parseWeek(value);
|
|
302
307
|
}
|
|
303
|
-
|
|
308
|
+
var normalizedValue = value;
|
|
309
|
+
var normalizedFormat = dateFormat;
|
|
310
|
+
if (locale) {
|
|
311
|
+
if ((0, _includes.default)(dateFormat).call(dateFormat, 'MMMM') && locale.months) {
|
|
312
|
+
var _context, _context2;
|
|
313
|
+
var sortedIndices = (0, _sort.default)(_context = (0, _map.default)(_context2 = locale.months).call(_context2, function (m, i) {
|
|
314
|
+
return {
|
|
315
|
+
name: m,
|
|
316
|
+
index: i
|
|
317
|
+
};
|
|
318
|
+
})).call(_context, function (a, b) {
|
|
319
|
+
return b.name.length - a.name.length;
|
|
320
|
+
});
|
|
321
|
+
var matched = (0, _find.default)(sortedIndices).call(sortedIndices, function (_ref) {
|
|
322
|
+
var name = _ref.name;
|
|
323
|
+
return (0, _includes.default)(value).call(value, name);
|
|
324
|
+
});
|
|
325
|
+
if (matched) {
|
|
326
|
+
var _context3;
|
|
327
|
+
normalizedValue = normalizedValue.replace(matched.name, (0, _padStart.default)(_context3 = String(matched.index + 1)).call(_context3, 2, '0'));
|
|
328
|
+
normalizedFormat = normalizedFormat.replace('MMMM', 'MM');
|
|
329
|
+
}
|
|
330
|
+
} else if ((0, _includes.default)(dateFormat).call(dateFormat, 'MMM') && locale.monthsShort) {
|
|
331
|
+
var _context4, _context5;
|
|
332
|
+
var _sortedIndices = (0, _sort.default)(_context4 = (0, _map.default)(_context5 = locale.monthsShort).call(_context5, function (m, i) {
|
|
333
|
+
return {
|
|
334
|
+
name: m,
|
|
335
|
+
index: i
|
|
336
|
+
};
|
|
337
|
+
})).call(_context4, function (a, b) {
|
|
338
|
+
return b.name.length - a.name.length;
|
|
339
|
+
});
|
|
340
|
+
var _matched = (0, _find.default)(_sortedIndices).call(_sortedIndices, function (_ref2) {
|
|
341
|
+
var name = _ref2.name;
|
|
342
|
+
return (0, _includes.default)(value).call(value, name);
|
|
343
|
+
});
|
|
344
|
+
if (_matched) {
|
|
345
|
+
var _context6;
|
|
346
|
+
normalizedValue = normalizedValue.replace(_matched.name, (0, _padStart.default)(_context6 = String(_matched.index + 1)).call(_context6, 2, '0'));
|
|
347
|
+
normalizedFormat = normalizedFormat.replace('MMM', 'MM');
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
parsedDate = (0, _parse.default)(normalizedValue, localeParse(normalizedFormat), new Date());
|
|
304
352
|
if (!isValid(parsedDate)) {
|
|
305
|
-
if (
|
|
306
|
-
|
|
353
|
+
if (normalizedValue.length > 0) {
|
|
354
|
+
var _context7;
|
|
355
|
+
parsedDate = (0, _parse.default)(normalizedValue, (0, _slice.default)(_context7 = localeParse(normalizedFormat)).call(_context7, 0, normalizedValue.length), new Date());
|
|
307
356
|
}
|
|
308
357
|
if (!isValid(parsedDate)) {
|
|
309
|
-
parsedDate = new Date(
|
|
358
|
+
parsedDate = new Date(normalizedValue);
|
|
310
359
|
}
|
|
311
360
|
}
|
|
312
361
|
return isValid(parsedDate) && strictParsingValueMatch ? parsedDate : null;
|
|
@@ -318,15 +367,27 @@ function formatDate(date, _format, _locale) {
|
|
|
318
367
|
if (!isValid(date)) {
|
|
319
368
|
return null;
|
|
320
369
|
}
|
|
370
|
+
if (_locale && (0, _typeof2.default)(_locale) === 'object') {
|
|
371
|
+
var monthIndex = (0, _getMonth.default)(date);
|
|
372
|
+
var result = localeParse(_format);
|
|
373
|
+
if ((0, _includes.default)(result).call(result, 'MMMM') && _locale.months) {
|
|
374
|
+
var escaped = _locale.months[monthIndex].replace(/'/g, "''");
|
|
375
|
+
result = result.replace(/MMMM/g, "'".concat(escaped, "'"));
|
|
376
|
+
} else if ((0, _includes.default)(result).call(result, 'MMM') && _locale.monthsShort) {
|
|
377
|
+
var _escaped = _locale.monthsShort[monthIndex].replace(/'/g, "''");
|
|
378
|
+
result = result.replace(/MMM/g, "'".concat(_escaped, "'"));
|
|
379
|
+
}
|
|
380
|
+
return (0, _format2.default)(date, result);
|
|
381
|
+
}
|
|
321
382
|
return (0, _format2.default)(date, localeParse(_format));
|
|
322
383
|
}
|
|
323
|
-
function setTime(date,
|
|
324
|
-
var
|
|
325
|
-
hour =
|
|
326
|
-
|
|
327
|
-
minute =
|
|
328
|
-
|
|
329
|
-
second =
|
|
384
|
+
function setTime(date, _ref3) {
|
|
385
|
+
var _ref3$hour = _ref3.hour,
|
|
386
|
+
hour = _ref3$hour === void 0 ? 0 : _ref3$hour,
|
|
387
|
+
_ref3$minute = _ref3.minute,
|
|
388
|
+
minute = _ref3$minute === void 0 ? 0 : _ref3$minute,
|
|
389
|
+
_ref3$second = _ref3.second,
|
|
390
|
+
second = _ref3$second === void 0 ? 0 : _ref3$second;
|
|
330
391
|
return (0, _setHours.default)((0, _setMinutes.default)((0, _setSeconds.default)(date, second), minute), hour);
|
|
331
392
|
}
|
|
332
393
|
function getWeek(date) {
|
package/lib/locale/en-US.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ declare const locale: {
|
|
|
13
13
|
'DatePicker.year': string;
|
|
14
14
|
'DatePicker.weekTitle': string[];
|
|
15
15
|
'DatePicker.monthTitle': string[];
|
|
16
|
+
'DatePicker.months': string[];
|
|
17
|
+
'DatePicker.monthsShort': string[];
|
|
16
18
|
'DatePicker.rangePlaceholder': string[];
|
|
17
19
|
'DatePicker.rangeYearPlaceholder': string[];
|
|
18
20
|
'DatePicker.rangeMonthPlaceholder': string[];
|
package/lib/locale/en-US.js
CHANGED
|
@@ -19,6 +19,8 @@ var locale = {
|
|
|
19
19
|
'DatePicker.year': '',
|
|
20
20
|
'DatePicker.weekTitle': ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
21
21
|
'DatePicker.monthTitle': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
22
|
+
'DatePicker.months': ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
23
|
+
'DatePicker.monthsShort': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
22
24
|
'DatePicker.rangePlaceholder': ['Start date', 'End date'],
|
|
23
25
|
'DatePicker.rangeYearPlaceholder': ['Start year', 'End year'],
|
|
24
26
|
'DatePicker.rangeMonthPlaceholder': ['Start month', 'End month'],
|
package/lib/locale/locale.d.ts
CHANGED
|
@@ -146,6 +146,8 @@ declare class LocaleCache {
|
|
|
146
146
|
'DatePicker.month': string;
|
|
147
147
|
'DatePicker.weekTitle': import("../date-picker/interface").WeekTitleType;
|
|
148
148
|
'DatePicker.monthTitle': import("../date-picker/interface").MonthTitleType;
|
|
149
|
+
'DatePicker.months'?: import("../date-picker/interface").MonthTitleType | undefined;
|
|
150
|
+
'DatePicker.monthsShort'?: import("../date-picker/interface").MonthTitleType | undefined;
|
|
149
151
|
'DatePicker.rangePlaceholder': [string, string];
|
|
150
152
|
'DatePicker.rangeYearPlaceholder': [string, string];
|
|
151
153
|
'DatePicker.rangeMonthPlaceholder': [string, string];
|
package/lib/locale/zh-CN.d.ts
CHANGED
|
@@ -118,6 +118,8 @@ declare const locale: {
|
|
|
118
118
|
'DatePicker.month': string;
|
|
119
119
|
'DatePicker.weekTitle': import("../date-picker/interface").WeekTitleType;
|
|
120
120
|
'DatePicker.monthTitle': import("../date-picker/interface").MonthTitleType;
|
|
121
|
+
'DatePicker.months'?: import("../date-picker/interface").MonthTitleType | undefined;
|
|
122
|
+
'DatePicker.monthsShort'?: import("../date-picker/interface").MonthTitleType | undefined;
|
|
121
123
|
'DatePicker.rangePlaceholder': [string, string];
|
|
122
124
|
'DatePicker.rangeYearPlaceholder': [string, string];
|
|
123
125
|
'DatePicker.rangeMonthPlaceholder': [string, string];
|