funda-ui 3.8.757 → 3.8.810
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/Date/index.js +547 -138
- package/lib/cjs/Date/index.js +547 -138
- package/lib/esm/Date/Calendar.tsx +8 -25
- package/lib/esm/Date/index.tsx +123 -101
- package/lib/esm/Date/utils/date.js +481 -0
- package/package.json +1 -1
package/Date/index.js
CHANGED
|
@@ -45,6 +45,441 @@ module.exports = config;
|
|
|
45
45
|
|
|
46
46
|
/***/ }),
|
|
47
47
|
|
|
48
|
+
/***/ 593:
|
|
49
|
+
/***/ ((module) => {
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get now
|
|
53
|
+
* @returns {Date} // Wed Apr 17 2024 14:31:36 GMT+0800 (China Standard Time)
|
|
54
|
+
*/
|
|
55
|
+
var getNow = function getNow() {
|
|
56
|
+
return new Date(Date.now());
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Zero Padding
|
|
61
|
+
* @param {Number} num
|
|
62
|
+
* @param {Boolean} padZeroEnabled
|
|
63
|
+
* @returns {String} '01', '05', '12'
|
|
64
|
+
*/
|
|
65
|
+
var padZero = function padZero(num) {
|
|
66
|
+
var padZeroEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
67
|
+
if (padZeroEnabled) {
|
|
68
|
+
return num < 10 ? '0' + num : num.toString();
|
|
69
|
+
} else {
|
|
70
|
+
return num.toString();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Number validation
|
|
76
|
+
* @param {*} v
|
|
77
|
+
* @returns {Boolean}
|
|
78
|
+
*/
|
|
79
|
+
var isNumeric = function isNumeric(v) {
|
|
80
|
+
return !isNaN(parseFloat(v)) && isFinite(v);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Hours validation
|
|
85
|
+
* @param {*} v
|
|
86
|
+
* @returns {Boolean}
|
|
87
|
+
*/
|
|
88
|
+
var isValidHours = function isValidHours(v) {
|
|
89
|
+
return /^([01]?[0-9]|2[0-3])$/.test(v); // 0~23, 00~23
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Minutes and Seconds validation
|
|
94
|
+
* @param {*} v
|
|
95
|
+
* @returns {Boolean}
|
|
96
|
+
*/
|
|
97
|
+
var isValidMinutesAndSeconds = function isValidMinutesAndSeconds(v) {
|
|
98
|
+
return /^([01]?[0-9]|[0-5][0-9])$/.test(v); // 0~59, 00~59
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Year validation
|
|
103
|
+
* @param {*} v
|
|
104
|
+
* @returns {Boolean}
|
|
105
|
+
*/
|
|
106
|
+
var isValidYear = function isValidYear(v) {
|
|
107
|
+
return /^([1-9][0-9])\d{2}$/.test(v); // 1000 ~ 9999
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Month validation
|
|
112
|
+
* @param {*} v
|
|
113
|
+
* @returns {Boolean}
|
|
114
|
+
*/
|
|
115
|
+
var isValidMonth = function isValidMonth(v) {
|
|
116
|
+
return /^(0?[1-9]|1[0-2])$/.test(v); // 01~12, 1~12
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Day validation
|
|
121
|
+
* @param {*} v
|
|
122
|
+
* @returns {Boolean}
|
|
123
|
+
*/
|
|
124
|
+
var isValidDay = function isValidDay(v) {
|
|
125
|
+
return /^(0?[1-9]|[1-2][0-9]|3[0-1])$/.test(v); // 01~31, 1~31
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Check if the string is legitimate
|
|
130
|
+
* @param {String} v
|
|
131
|
+
* @returns {Boolean}
|
|
132
|
+
*/
|
|
133
|
+
var isValidDate = function isValidDate(v) {
|
|
134
|
+
return !(String(new Date(v)).toLowerCase() === 'invalid date');
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get calendar date
|
|
139
|
+
* @param {Date | String} v
|
|
140
|
+
* @returns {String} yyyy-MM-dd
|
|
141
|
+
*/
|
|
142
|
+
function dateFormat(v) {
|
|
143
|
+
var date = typeof v === 'string' ? new Date(v.replace(/-/g, "/")) : v; // fix "Invalid date in safari"
|
|
144
|
+
return date;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Get calendar date
|
|
149
|
+
* @param {Date | String} v
|
|
150
|
+
* @param {Boolean} padZeroEnabled
|
|
151
|
+
* @returns {String} yyyy-MM-dd
|
|
152
|
+
*/
|
|
153
|
+
function getCalendarDate(v) {
|
|
154
|
+
var padZeroEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
155
|
+
var date = dateFormat(v);
|
|
156
|
+
var year = date.getFullYear();
|
|
157
|
+
var month = padZero(date.getMonth() + 1, padZeroEnabled);
|
|
158
|
+
var day = padZero(date.getDate(), padZeroEnabled);
|
|
159
|
+
var hours = padZero(date.getHours(), padZeroEnabled);
|
|
160
|
+
var minutes = padZero(date.getMinutes(), padZeroEnabled);
|
|
161
|
+
var seconds = padZero(date.getSeconds(), padZeroEnabled);
|
|
162
|
+
var res = "".concat(year, "-").concat(month, "-").concat(day);
|
|
163
|
+
return res;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Get today date
|
|
168
|
+
* @returns {String} yyyy-MM-dd
|
|
169
|
+
*/
|
|
170
|
+
function getTodayDate() {
|
|
171
|
+
return getCalendarDate(new Date());
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Get tomorrow date
|
|
176
|
+
* @param {Date | String} v
|
|
177
|
+
* @returns {String} yyyy-MM-dd
|
|
178
|
+
*/
|
|
179
|
+
function getTomorrowDate(v) {
|
|
180
|
+
var today = dateFormat(v);
|
|
181
|
+
var _tomorrow = today;
|
|
182
|
+
_tomorrow.setDate(_tomorrow.getDate() + 1);
|
|
183
|
+
var tomorrow = getCalendarDate(_tomorrow);
|
|
184
|
+
return tomorrow;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Get yesterday date
|
|
189
|
+
* @param {Date | String} v
|
|
190
|
+
* @returns {String} yyyy-MM-dd
|
|
191
|
+
*/
|
|
192
|
+
function getYesterdayDate(v) {
|
|
193
|
+
var today = dateFormat(v);
|
|
194
|
+
var _yesterday = today;
|
|
195
|
+
_yesterday.setDate(_yesterday.getDate() - 1);
|
|
196
|
+
var yesterday = getCalendarDate(_yesterday);
|
|
197
|
+
return yesterday;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Get specified date
|
|
202
|
+
* @param {Date | String} v
|
|
203
|
+
* @param {Number} days The number of days forward or backward, which can be a negative number
|
|
204
|
+
* @returns {String} yyyy-MM-dd
|
|
205
|
+
*/
|
|
206
|
+
/* console.log(getSpecifiedDate(getTodayDate(), -180)); // 2023-08-27 (180 days before February 23, 202) */
|
|
207
|
+
function getSpecifiedDate(v, days) {
|
|
208
|
+
var today = dateFormat(v);
|
|
209
|
+
var _specifiedDay = today;
|
|
210
|
+
_specifiedDay.setDate(_specifiedDay.getDate() + days);
|
|
211
|
+
var specifiedDay = getCalendarDate(_specifiedDay);
|
|
212
|
+
return specifiedDay;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Get next month date
|
|
217
|
+
* @param {Date | String} v
|
|
218
|
+
* @returns {String} yyyy-MM-dd
|
|
219
|
+
*/
|
|
220
|
+
function getNextMonthDate(v) {
|
|
221
|
+
var today = dateFormat(v);
|
|
222
|
+
today.setMonth(today.getMonth() + 1);
|
|
223
|
+
return getCalendarDate(today);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Get previous month date
|
|
228
|
+
* @param {Date | String} v
|
|
229
|
+
* @returns {String} yyyy-MM-dd
|
|
230
|
+
*/
|
|
231
|
+
function getPrevMonthDate(v) {
|
|
232
|
+
var today = dateFormat(v);
|
|
233
|
+
today.setMonth(today.getMonth() - 1);
|
|
234
|
+
return getCalendarDate(today);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Get next year date
|
|
239
|
+
* @param {Date | String} v
|
|
240
|
+
* @returns {String} yyyy-MM-dd
|
|
241
|
+
*/
|
|
242
|
+
function getNextYearDate(v) {
|
|
243
|
+
var today = dateFormat(v);
|
|
244
|
+
var current = new Date(today);
|
|
245
|
+
current.setFullYear(current.getFullYear() + 1);
|
|
246
|
+
return getCalendarDate(current);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Get previous year date
|
|
251
|
+
* @param {Date | String} v
|
|
252
|
+
* @returns {String} yyyy-MM-dd
|
|
253
|
+
*/
|
|
254
|
+
function getPrevYearDate(v) {
|
|
255
|
+
var today = dateFormat(v);
|
|
256
|
+
var current = new Date(today);
|
|
257
|
+
current.setFullYear(current.getFullYear() - 1);
|
|
258
|
+
return getCalendarDate(current);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Get last day in month
|
|
263
|
+
* @param {Date | String} v
|
|
264
|
+
* @param {?Number} targetMonth
|
|
265
|
+
* @returns {String} yyyy-MM-dd
|
|
266
|
+
*/
|
|
267
|
+
/*
|
|
268
|
+
Example: Get last day in next month
|
|
269
|
+
|
|
270
|
+
const _day = '2024-01-01';
|
|
271
|
+
const y = new Date(getNextMonthDate(_day)).getFullYear();
|
|
272
|
+
const m = String(new Date(getNextMonthDate(_day)).getMonth() + 1).padStart(2, '0');
|
|
273
|
+
const d = getLastDayInMonth(getNextMonthDate(_day), new Date(getNextMonthDate(_day)).getMonth() + 1);
|
|
274
|
+
|
|
275
|
+
const lastDayOfNextMonth = `${y}-${m}-${d}`; // 2024-02-29
|
|
276
|
+
|
|
277
|
+
*/
|
|
278
|
+
function getLastDayInMonth(v) {
|
|
279
|
+
var targetMonth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
280
|
+
var date = dateFormat(v);
|
|
281
|
+
return new Date(date.getFullYear(), typeof targetMonth !== 'undefined' ? targetMonth : date.getMonth() - 1, 0).getDate();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Get current year
|
|
286
|
+
* @returns {Number}
|
|
287
|
+
*/
|
|
288
|
+
function getCurrentYear() {
|
|
289
|
+
return new Date().getFullYear();
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Get current month
|
|
294
|
+
* @param {Boolean} padZeroEnabled
|
|
295
|
+
* @returns {Number}
|
|
296
|
+
*/
|
|
297
|
+
function getCurrentMonth() {
|
|
298
|
+
var padZeroEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
299
|
+
var m = new Date().getMonth() + 1;
|
|
300
|
+
return padZeroEnabled ? String(m).padStart(2, '0') : m;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Get current day
|
|
305
|
+
* @param {Boolean} padZeroEnabled
|
|
306
|
+
* @returns {Number}
|
|
307
|
+
*/
|
|
308
|
+
function getCurrentDay() {
|
|
309
|
+
var padZeroEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
310
|
+
var d = new Date().getDate();
|
|
311
|
+
return padZeroEnabled ? String(d).padStart(2, '0') : d;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Get first and last month day
|
|
316
|
+
* @param {Number} v
|
|
317
|
+
* @param {Boolean} padZeroEnabled
|
|
318
|
+
* @returns {Array}
|
|
319
|
+
*/
|
|
320
|
+
function getFirstAndLastMonthDay(year) {
|
|
321
|
+
var padZeroEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
322
|
+
var theFirst = new Date(year, 0, 1).getDate();
|
|
323
|
+
var theLast = new Date(year, 11, 31).getDate();
|
|
324
|
+
var padZero = function padZero(num) {
|
|
325
|
+
if (padZeroEnabled) {
|
|
326
|
+
return num < 10 ? '0' + num : num.toString();
|
|
327
|
+
} else {
|
|
328
|
+
return num.toString();
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
return [padZero(theFirst), padZero(theLast)];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Get current date
|
|
336
|
+
* @param {Boolean} padZeroEnabled
|
|
337
|
+
* @typedef {String} JSON
|
|
338
|
+
*/
|
|
339
|
+
function getCurrentDate() {
|
|
340
|
+
var padZeroEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
341
|
+
var date = new Date();
|
|
342
|
+
var padZero = function padZero(num) {
|
|
343
|
+
if (padZeroEnabled) {
|
|
344
|
+
return num < 10 ? '0' + num : num.toString();
|
|
345
|
+
} else {
|
|
346
|
+
return num.toString();
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
var year = date.getFullYear();
|
|
350
|
+
var month = padZero(date.getMonth() + 1);
|
|
351
|
+
var day = padZero(date.getDate());
|
|
352
|
+
var hours = padZero(date.getHours());
|
|
353
|
+
var minutes = padZero(date.getMinutes());
|
|
354
|
+
return {
|
|
355
|
+
today: "".concat(year, "-").concat(month, "-").concat(day),
|
|
356
|
+
yearStart: "".concat(year, "-01-01"),
|
|
357
|
+
yearEnd: "".concat(year, "-12-").concat(getLastDayInMonth(date, 12))
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Get full time
|
|
363
|
+
* @param {Date | String} v
|
|
364
|
+
* @param {Boolean} padZeroEnabled
|
|
365
|
+
* @param {Boolean} hasSeconds
|
|
366
|
+
* @returns {String} yyyy-MM-dd HH:mm:ss
|
|
367
|
+
*/
|
|
368
|
+
function getFullTime(v) {
|
|
369
|
+
var padZeroEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
370
|
+
var hasSeconds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
371
|
+
var date = dateFormat(v);
|
|
372
|
+
var padZero = function padZero(num) {
|
|
373
|
+
if (padZeroEnabled) {
|
|
374
|
+
return num < 10 ? '0' + num : num.toString();
|
|
375
|
+
} else {
|
|
376
|
+
return num.toString();
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
var year = date.getFullYear();
|
|
380
|
+
var month = padZero(date.getMonth() + 1);
|
|
381
|
+
var day = padZero(date.getDate());
|
|
382
|
+
var hours = padZero(date.getHours());
|
|
383
|
+
var minutes = padZero(date.getMinutes());
|
|
384
|
+
var seconds = padZero(date.getSeconds());
|
|
385
|
+
var res = "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
386
|
+
var res2 = "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes);
|
|
387
|
+
return hasSeconds ? res : res2;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Add hours
|
|
392
|
+
* @param {Date | String} v
|
|
393
|
+
* @param {Number} offset
|
|
394
|
+
* @param {Boolean} padZeroEnabled
|
|
395
|
+
* @returns {String} yyyy-MM-dd HH:mm:ss
|
|
396
|
+
*/
|
|
397
|
+
function setDateHours(v, offset) {
|
|
398
|
+
var padZeroEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
399
|
+
var date = dateFormat(v);
|
|
400
|
+
var _cur = new Date(date).setTime(new Date(date).getTime() + offset * 60 * 60 * 1000);
|
|
401
|
+
return getFullTime(new Date(_cur), padZeroEnabled);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Add minutes
|
|
406
|
+
* @param {Date | String} v
|
|
407
|
+
* @param {Number} offset
|
|
408
|
+
* @param {Boolean} padZeroEnabled
|
|
409
|
+
* @returns {String} yyyy-MM-dd HH:mm:ss
|
|
410
|
+
*/
|
|
411
|
+
function setDateMinutes(v, offset) {
|
|
412
|
+
var padZeroEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
413
|
+
var date = dateFormat(v);
|
|
414
|
+
var _cur = new Date(date).setTime(new Date(date).getTime() + offset * 60 * 1000);
|
|
415
|
+
return getFullTime(new Date(_cur), padZeroEnabled);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Add days
|
|
419
|
+
* @param {Date | String} v
|
|
420
|
+
* @param {Number} offset
|
|
421
|
+
* @param {Boolean} padZeroEnabled
|
|
422
|
+
* @returns {String} yyyy-MM-dd HH:mm:ss
|
|
423
|
+
*/
|
|
424
|
+
function setDateDays(v, offset) {
|
|
425
|
+
var padZeroEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
426
|
+
var date = dateFormat(v);
|
|
427
|
+
var _cur = new Date(date).setTime(new Date(date).getTime() + offset * 24 * 60 * 60 * 1000);
|
|
428
|
+
return getFullTime(new Date(_cur), padZeroEnabled);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Convert timestamp to date
|
|
433
|
+
* @param {Number} v
|
|
434
|
+
* @param {Boolean} padZeroEnabled
|
|
435
|
+
* @returns {String} yyyy-MM-dd HH:mm:ss
|
|
436
|
+
*/
|
|
437
|
+
function timestampToDate(v) {
|
|
438
|
+
var padZeroEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
439
|
+
return getFullTime(new Date(v), padZeroEnabled);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// node & browser
|
|
443
|
+
module.exports = {
|
|
444
|
+
getNow: getNow,
|
|
445
|
+
padZero: padZero,
|
|
446
|
+
dateFormat: dateFormat,
|
|
447
|
+
//
|
|
448
|
+
isValidDate: isValidDate,
|
|
449
|
+
isNumeric: isNumeric,
|
|
450
|
+
isValidHours: isValidHours,
|
|
451
|
+
isValidMinutesAndSeconds: isValidMinutesAndSeconds,
|
|
452
|
+
isValidYear: isValidYear,
|
|
453
|
+
isValidMonth: isValidMonth,
|
|
454
|
+
isValidDay: isValidDay,
|
|
455
|
+
//
|
|
456
|
+
getLastDayInMonth: getLastDayInMonth,
|
|
457
|
+
getFirstAndLastMonthDay: getFirstAndLastMonthDay,
|
|
458
|
+
getCalendarDate: getCalendarDate,
|
|
459
|
+
getFullTime: getFullTime,
|
|
460
|
+
// current
|
|
461
|
+
getTodayDate: getTodayDate,
|
|
462
|
+
getCurrentMonth: getCurrentMonth,
|
|
463
|
+
getCurrentYear: getCurrentYear,
|
|
464
|
+
getCurrentDay: getCurrentDay,
|
|
465
|
+
getCurrentDate: getCurrentDate,
|
|
466
|
+
// next & previous
|
|
467
|
+
getTomorrowDate: getTomorrowDate,
|
|
468
|
+
getYesterdayDate: getYesterdayDate,
|
|
469
|
+
getNextMonthDate: getNextMonthDate,
|
|
470
|
+
getPrevMonthDate: getPrevMonthDate,
|
|
471
|
+
getNextYearDate: getNextYearDate,
|
|
472
|
+
getPrevYearDate: getPrevYearDate,
|
|
473
|
+
getSpecifiedDate: getSpecifiedDate,
|
|
474
|
+
// convert
|
|
475
|
+
setDateHours: setDateHours,
|
|
476
|
+
setDateMinutes: setDateMinutes,
|
|
477
|
+
setDateDays: setDateDays,
|
|
478
|
+
timestampToDate: timestampToDate
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
/***/ }),
|
|
482
|
+
|
|
48
483
|
/***/ 378:
|
|
49
484
|
/***/ ((module) => {
|
|
50
485
|
|
|
@@ -1048,6 +1483,8 @@ var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
|
|
|
1048
1483
|
// EXTERNAL MODULE: ../RootPortal/dist/cjs/index.js
|
|
1049
1484
|
var dist_cjs = __webpack_require__(909);
|
|
1050
1485
|
var dist_cjs_default = /*#__PURE__*/__webpack_require__.n(dist_cjs);
|
|
1486
|
+
// EXTERNAL MODULE: ./src/utils/date.js
|
|
1487
|
+
var utils_date = __webpack_require__(593);
|
|
1051
1488
|
;// CONCATENATED MODULE: ./src/Calendar.tsx
|
|
1052
1489
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
1053
1490
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -1060,6 +1497,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
1060
1497
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
1061
1498
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1062
1499
|
|
|
1500
|
+
|
|
1063
1501
|
var Calendar = function Calendar(props) {
|
|
1064
1502
|
var min = props.min,
|
|
1065
1503
|
max = props.max,
|
|
@@ -1132,27 +1570,9 @@ var Calendar = function Calendar(props) {
|
|
|
1132
1570
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
1133
1571
|
winMonth = _useState22[0],
|
|
1134
1572
|
setWinMonth = _useState22[1];
|
|
1135
|
-
var padZero = function padZero(num) {
|
|
1136
|
-
var padZeroEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1137
|
-
if (padZeroEnabled) {
|
|
1138
|
-
return num < 10 ? '0' + num : num.toString();
|
|
1139
|
-
} else {
|
|
1140
|
-
return num.toString();
|
|
1141
|
-
}
|
|
1142
|
-
};
|
|
1143
|
-
var isValidDate = function isValidDate(v) {
|
|
1144
|
-
return !(String(new window.Date(v)).toLowerCase() === 'invalid date');
|
|
1145
|
-
};
|
|
1146
|
-
var dateFormat = function dateFormat(v) {
|
|
1147
|
-
var date = typeof v === 'string' ? new window.Date(v.replace(/-/g, "/")) : v; // fix "Invalid date in safari"
|
|
1148
|
-
return date;
|
|
1149
|
-
};
|
|
1150
|
-
var getTodayDate = function getTodayDate() {
|
|
1151
|
-
return getCalendarDate(new Date());
|
|
1152
|
-
};
|
|
1153
1573
|
var getFullTimeData = function getFullTimeData(v) {
|
|
1154
1574
|
var padZeroEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1155
|
-
if (typeof v === 'string' && !isValidDate(v)) {
|
|
1575
|
+
if (typeof v === 'string' && !(0,utils_date.isValidDate)(v)) {
|
|
1156
1576
|
return {
|
|
1157
1577
|
res: '0000-00-00 00:00:00',
|
|
1158
1578
|
resNoSeconds: '0000-00-00 00:00',
|
|
@@ -1165,13 +1585,13 @@ var Calendar = function Calendar(props) {
|
|
|
1165
1585
|
seconds: "00"
|
|
1166
1586
|
};
|
|
1167
1587
|
}
|
|
1168
|
-
var date = dateFormat(v);
|
|
1588
|
+
var date = (0,utils_date.dateFormat)(v);
|
|
1169
1589
|
var year = date.getFullYear();
|
|
1170
|
-
var month = padZero(date.getMonth() + 1, padZeroEnabled);
|
|
1171
|
-
var day = padZero(date.getDate(), padZeroEnabled);
|
|
1172
|
-
var hours = padZero(date.getHours(), padZeroEnabled);
|
|
1173
|
-
var minutes = padZero(date.getMinutes(), padZeroEnabled);
|
|
1174
|
-
var seconds = padZero(date.getSeconds(), padZeroEnabled);
|
|
1590
|
+
var month = (0,utils_date.padZero)(date.getMonth() + 1, padZeroEnabled);
|
|
1591
|
+
var day = (0,utils_date.padZero)(date.getDate(), padZeroEnabled);
|
|
1592
|
+
var hours = (0,utils_date.padZero)(date.getHours(), padZeroEnabled);
|
|
1593
|
+
var minutes = (0,utils_date.padZero)(date.getMinutes(), padZeroEnabled);
|
|
1594
|
+
var seconds = (0,utils_date.padZero)(date.getSeconds(), padZeroEnabled);
|
|
1175
1595
|
var res = "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
1176
1596
|
var res2 = "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes);
|
|
1177
1597
|
return {
|
|
@@ -1188,8 +1608,8 @@ var Calendar = function Calendar(props) {
|
|
|
1188
1608
|
};
|
|
1189
1609
|
|
|
1190
1610
|
//
|
|
1191
|
-
var MIN = typeof min !== 'undefined' && min !== '' && min !== null && isValidDate(min) ? getFullTimeData(min) : '';
|
|
1192
|
-
var MAX = typeof max !== 'undefined' && max !== '' && max !== null && isValidDate(max) ? getFullTimeData(max) : '';
|
|
1611
|
+
var MIN = typeof min !== 'undefined' && min !== '' && min !== null && (0,utils_date.isValidDate)(min) ? getFullTimeData(min) : '';
|
|
1612
|
+
var MAX = typeof max !== 'undefined' && max !== '' && max !== null && (0,utils_date.isValidDate)(max) ? getFullTimeData(max) : '';
|
|
1193
1613
|
var currentMinDateDisabled = MIN !== '' ? Number(new window.Date().getTime()) < Number(new window.Date(MIN.res).getTime()) ? true : false : false;
|
|
1194
1614
|
var currentMaxDateDisabled = MAX !== '' ? Number(new window.Date().getTime()) > Number(new window.Date(MAX.res).getTime()) ? true : false : false;
|
|
1195
1615
|
|
|
@@ -1319,8 +1739,8 @@ var Calendar = function Calendar(props) {
|
|
|
1319
1739
|
|
|
1320
1740
|
//
|
|
1321
1741
|
onChangeMonth === null || onChangeMonth === void 0 ? void 0 : onChangeMonth({
|
|
1322
|
-
day: padZero(day),
|
|
1323
|
-
month: padZero(_date.getMonth() + 1),
|
|
1742
|
+
day: (0,utils_date.padZero)(day),
|
|
1743
|
+
month: (0,utils_date.padZero)(_date.getMonth() + 1),
|
|
1324
1744
|
year: _date.getFullYear().toString()
|
|
1325
1745
|
});
|
|
1326
1746
|
return _date;
|
|
@@ -1336,8 +1756,8 @@ var Calendar = function Calendar(props) {
|
|
|
1336
1756
|
|
|
1337
1757
|
//
|
|
1338
1758
|
onChangeMonth === null || onChangeMonth === void 0 ? void 0 : onChangeMonth({
|
|
1339
|
-
day: padZero(day),
|
|
1340
|
-
month: padZero(_date.getMonth() + 1),
|
|
1759
|
+
day: (0,utils_date.padZero)(day),
|
|
1760
|
+
month: (0,utils_date.padZero)(_date.getMonth() + 1),
|
|
1341
1761
|
year: _date.getFullYear().toString()
|
|
1342
1762
|
});
|
|
1343
1763
|
return _date;
|
|
@@ -1356,8 +1776,8 @@ var Calendar = function Calendar(props) {
|
|
|
1356
1776
|
|
|
1357
1777
|
//
|
|
1358
1778
|
onChangeYear === null || onChangeYear === void 0 ? void 0 : onChangeYear({
|
|
1359
|
-
day: padZero(day),
|
|
1360
|
-
month: padZero(month + 1),
|
|
1779
|
+
day: (0,utils_date.padZero)(day),
|
|
1780
|
+
month: (0,utils_date.padZero)(month + 1),
|
|
1361
1781
|
year: currentValue.toString()
|
|
1362
1782
|
});
|
|
1363
1783
|
}
|
|
@@ -1371,8 +1791,8 @@ var Calendar = function Calendar(props) {
|
|
|
1371
1791
|
|
|
1372
1792
|
//
|
|
1373
1793
|
onChangeMonth === null || onChangeMonth === void 0 ? void 0 : onChangeMonth({
|
|
1374
|
-
day: padZero(day),
|
|
1375
|
-
month: padZero(currentIndex + 1),
|
|
1794
|
+
day: (0,utils_date.padZero)(day),
|
|
1795
|
+
month: (0,utils_date.padZero)(currentIndex + 1),
|
|
1376
1796
|
year: year.toString()
|
|
1377
1797
|
});
|
|
1378
1798
|
}
|
|
@@ -1382,7 +1802,7 @@ var Calendar = function Calendar(props) {
|
|
|
1382
1802
|
setTodayDate(now);
|
|
1383
1803
|
|
|
1384
1804
|
//
|
|
1385
|
-
var _now = getTodayDate().split('-');
|
|
1805
|
+
var _now = (0,utils_date.getTodayDate)().split('-');
|
|
1386
1806
|
onChangeToday === null || onChangeToday === void 0 ? void 0 : onChangeToday({
|
|
1387
1807
|
day: _now[2],
|
|
1388
1808
|
month: _now[1],
|
|
@@ -1485,7 +1905,7 @@ var Calendar = function Calendar(props) {
|
|
|
1485
1905
|
}, [date]);
|
|
1486
1906
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
1487
1907
|
// update current today
|
|
1488
|
-
if (typeof customTodayDate === 'string' && customTodayDate !== '' && isValidDate(customTodayDate)) {
|
|
1908
|
+
if (typeof customTodayDate === 'string' && customTodayDate !== '' && (0,utils_date.isValidDate)(customTodayDate)) {
|
|
1489
1909
|
var _customNow = new Date(customTodayDate);
|
|
1490
1910
|
setTodayDate(_customNow);
|
|
1491
1911
|
} else {
|
|
@@ -1605,7 +2025,7 @@ var Calendar = function Calendar(props) {
|
|
|
1605
2025
|
className: "date2d-cal__cell date2d-cal__day ".concat(d > 0 ? '' : 'empty', " ").concat(d === now.getDate() ? 'today' : '', " ").concat(d === day ? 'selected' : '', " ").concat(isLastCol ? 'last-cell' : '', " ").concat(isLastRow ? 'last-row' : '', " ").concat(checkDisabledDay(year, month, d) ? 'disabled' : ''),
|
|
1606
2026
|
key: "col" + i,
|
|
1607
2027
|
"data-date": getCalendarDate(_dateShow),
|
|
1608
|
-
"data-day": padZero(d),
|
|
2028
|
+
"data-day": (0,utils_date.padZero)(d),
|
|
1609
2029
|
"data-week": i,
|
|
1610
2030
|
onClick: function onClick(e) {
|
|
1611
2031
|
if (d > 0) {
|
|
@@ -1628,7 +2048,7 @@ var Calendar = function Calendar(props) {
|
|
|
1628
2048
|
className: "date2d-cal__month-container"
|
|
1629
2049
|
}, MONTHS_FULL.map(function (month, index) {
|
|
1630
2050
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
1631
|
-
"data-month": padZero(index + 1),
|
|
2051
|
+
"data-month": (0,utils_date.padZero)(index + 1),
|
|
1632
2052
|
className: "date2d-cal__month ".concat(selectedMonth === index ? ' selected' : '', " ").concat(checkDisabledMonth(year, index) ? 'disabled' : ''),
|
|
1633
2053
|
key: month + index,
|
|
1634
2054
|
onClick: function onClick() {
|
|
@@ -1689,6 +2109,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
1689
2109
|
|
|
1690
2110
|
|
|
1691
2111
|
|
|
2112
|
+
|
|
1692
2113
|
var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.forwardRef)(function (props, _ref) {
|
|
1693
2114
|
var popupRef = props.popupRef,
|
|
1694
2115
|
triggerClassName = props.triggerClassName,
|
|
@@ -1745,6 +2166,7 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
1745
2166
|
langMonthsFull = props.langMonthsFull,
|
|
1746
2167
|
langToday = props.langToday,
|
|
1747
2168
|
attributes = _objectWithoutProperties(props, _excluded);
|
|
2169
|
+
var defaultValueIsEmpty = typeof value === 'undefined' || value === null || value === 'null' || value === '';
|
|
1748
2170
|
|
|
1749
2171
|
// Localization
|
|
1750
2172
|
var _langHoursTitle = langHoursTitle || 'Hours';
|
|
@@ -1845,9 +2267,6 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
1845
2267
|
};
|
|
1846
2268
|
}, [popupRef]);
|
|
1847
2269
|
var windowScrollUpdate = (0,performance.debounce)(handleScrollEvent, 50);
|
|
1848
|
-
var isValidDate = function isValidDate(v) {
|
|
1849
|
-
return !(String(new window.Date(v)).toLowerCase() === 'invalid date');
|
|
1850
|
-
};
|
|
1851
2270
|
var eventFire = function eventFire(el, etype) {
|
|
1852
2271
|
if (el.fireEvent) {
|
|
1853
2272
|
el.fireEvent('on' + etype);
|
|
@@ -1857,24 +2276,9 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
1857
2276
|
el.dispatchEvent(evObj);
|
|
1858
2277
|
}
|
|
1859
2278
|
};
|
|
1860
|
-
var dateFormat = function dateFormat(v) {
|
|
1861
|
-
var date = typeof v === 'string' ? new window.Date(v.replace(/-/g, "/")) : v; // fix "Invalid date in safari"
|
|
1862
|
-
return date;
|
|
1863
|
-
};
|
|
1864
|
-
var getNow = function getNow() {
|
|
1865
|
-
return new window.Date(window.Date.now());
|
|
1866
|
-
};
|
|
1867
|
-
var padZero = function padZero(num) {
|
|
1868
|
-
var padZeroEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1869
|
-
if (padZeroEnabled) {
|
|
1870
|
-
return num < 10 ? '0' + num : num.toString();
|
|
1871
|
-
} else {
|
|
1872
|
-
return num.toString();
|
|
1873
|
-
}
|
|
1874
|
-
};
|
|
1875
2279
|
var getFullTimeData = function getFullTimeData(v) {
|
|
1876
2280
|
var padZeroEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1877
|
-
if (typeof v === 'string' && !isValidDate(v)) {
|
|
2281
|
+
if (typeof v === 'string' && !(0,utils_date.isValidDate)(v)) {
|
|
1878
2282
|
return {
|
|
1879
2283
|
res: '0000-00-00 00:00:00',
|
|
1880
2284
|
resNoSeconds: '0000-00-00 00:00',
|
|
@@ -1887,13 +2291,13 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
1887
2291
|
seconds: "00"
|
|
1888
2292
|
};
|
|
1889
2293
|
}
|
|
1890
|
-
var date = dateFormat(v);
|
|
2294
|
+
var date = (0,utils_date.dateFormat)(v);
|
|
1891
2295
|
var year = date.getFullYear();
|
|
1892
|
-
var month = padZero(date.getMonth() + 1, padZeroEnabled);
|
|
1893
|
-
var day = padZero(date.getDate(), padZeroEnabled);
|
|
1894
|
-
var hours = padZero(date.getHours(), padZeroEnabled);
|
|
1895
|
-
var minutes = padZero(date.getMinutes(), padZeroEnabled);
|
|
1896
|
-
var seconds = padZero(date.getSeconds(), padZeroEnabled);
|
|
2296
|
+
var month = (0,utils_date.padZero)(date.getMonth() + 1, padZeroEnabled);
|
|
2297
|
+
var day = (0,utils_date.padZero)(date.getDate(), padZeroEnabled);
|
|
2298
|
+
var hours = (0,utils_date.padZero)(date.getHours(), padZeroEnabled);
|
|
2299
|
+
var minutes = (0,utils_date.padZero)(date.getMinutes(), padZeroEnabled);
|
|
2300
|
+
var seconds = (0,utils_date.padZero)(date.getSeconds(), padZeroEnabled);
|
|
1897
2301
|
var res = "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes, ":").concat(seconds);
|
|
1898
2302
|
var res2 = "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes);
|
|
1899
2303
|
return {
|
|
@@ -1910,10 +2314,37 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
1910
2314
|
};
|
|
1911
2315
|
|
|
1912
2316
|
//
|
|
1913
|
-
var MIN = typeof min !== 'undefined' && min !== '' && min !== null && isValidDate(min) ? getFullTimeData(min) : '';
|
|
1914
|
-
var MAX = typeof max !== 'undefined' && max !== '' && max !== null && isValidDate(max) ? getFullTimeData(max) : '';
|
|
2317
|
+
var MIN = typeof min !== 'undefined' && min !== '' && min !== null && (0,utils_date.isValidDate)(min) ? getFullTimeData(min) : '';
|
|
2318
|
+
var MAX = typeof max !== 'undefined' && max !== '' && max !== null && (0,utils_date.isValidDate)(max) ? getFullTimeData(max) : '';
|
|
1915
2319
|
var currentMinDateDisabled = MIN !== '' ? Number(new window.Date().getTime()) < Number(new window.Date(MIN.res).getTime()) ? true : false : false;
|
|
1916
2320
|
var currentMaxDateDisabled = MAX !== '' ? Number(new window.Date().getTime()) > Number(new window.Date(MAX.res).getTime()) ? true : false : false;
|
|
2321
|
+
var getActualDefaultValue = function getActualDefaultValue(v) {
|
|
2322
|
+
var init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2323
|
+
var _v = getFullTimeData((0,utils_date.getNow)());
|
|
2324
|
+
var _nowVal = "".concat(_v.date, " ").concat(_v.hours, ":").concat(_v.minutes, ":").concat(_v.seconds);
|
|
2325
|
+
if (!init) setInitSplitClickEvOk(true);
|
|
2326
|
+
if (!initSplitClickEvOk) {
|
|
2327
|
+
var noTargetVal = typeof clickInitValue === 'undefined' || clickInitValue === null || clickInitValue === 'null' || clickInitValue === '';
|
|
2328
|
+
if (!defaultValueIsEmpty) {
|
|
2329
|
+
noTargetVal = true;
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
//
|
|
2333
|
+
var targetVal = noTargetVal ? defaultValueIsEmpty ? _nowVal : v : clickInitValue;
|
|
2334
|
+
if (typeof v === 'undefined') {
|
|
2335
|
+
targetVal = noTargetVal ? _nowVal : clickInitValue;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
//
|
|
2339
|
+
return [false, noTargetVal, targetVal];
|
|
2340
|
+
} else {
|
|
2341
|
+
var _targetVal = defaultValueIsEmpty ? _nowVal : v;
|
|
2342
|
+
if (typeof v === 'undefined') {
|
|
2343
|
+
_targetVal = _nowVal;
|
|
2344
|
+
}
|
|
2345
|
+
return [true, true, _targetVal];
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
1917
2348
|
function handleScrollEvent() {
|
|
1918
2349
|
popwinPosHide();
|
|
1919
2350
|
}
|
|
@@ -2021,7 +2452,7 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2021
2452
|
var val = event.target.value;
|
|
2022
2453
|
|
|
2023
2454
|
//
|
|
2024
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, val, isValidDate(val));
|
|
2455
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, val, (0,utils_date.isValidDate)(val));
|
|
2025
2456
|
}
|
|
2026
2457
|
function handleBlur(event) {
|
|
2027
2458
|
//remove focus style
|
|
@@ -2036,44 +2467,19 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2036
2467
|
|
|
2037
2468
|
e.target.select();
|
|
2038
2469
|
resetDefauleValueExist();
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
var _targetVal = noTargetVal ? getNow() : clickInitValue;
|
|
2043
|
-
if (noTargetVal) {
|
|
2044
|
-
if (!dateDefaultValueExist) {
|
|
2045
|
-
var _initValue = initValue(_targetVal),
|
|
2046
|
-
_initValue2 = src_slicedToArray(_initValue, 2),
|
|
2047
|
-
a = _initValue2[0],
|
|
2048
|
-
b = _initValue2[1];
|
|
2049
|
-
var _full = getFullTimeData(b).res;
|
|
2050
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), isValidDate(_full));
|
|
2051
|
-
setChangedVal(_full);
|
|
2052
|
-
}
|
|
2053
|
-
} else {
|
|
2054
|
-
if (!initSplitClickEvOk) {
|
|
2055
|
-
var _initValue3 = initValue(_targetVal),
|
|
2056
|
-
_initValue4 = src_slicedToArray(_initValue3, 2),
|
|
2057
|
-
_a = _initValue4[0],
|
|
2058
|
-
_b = _initValue4[1];
|
|
2059
|
-
var _full2 = getFullTimeData(_b).res;
|
|
2060
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full2), isValidDate(_full2));
|
|
2061
|
-
|
|
2062
|
-
//
|
|
2063
|
-
setInitSplitClickEvOk(true);
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2470
|
+
var _date = "".concat(splitVals[0], "-").concat(splitVals[1], "-").concat(splitVals[2]);
|
|
2471
|
+
var _full = "".concat(_date, " ").concat(splitVals[3], ":").concat(splitVals[4], ":").concat(splitVals[5]);
|
|
2472
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), (0,utils_date.isValidDate)(_full));
|
|
2066
2473
|
}
|
|
2067
2474
|
function clearAll() {
|
|
2068
2475
|
setDateDefaultValueExist(false);
|
|
2069
|
-
setChangedVal('');
|
|
2070
2476
|
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, '', false);
|
|
2071
2477
|
}
|
|
2072
2478
|
function resetDefauleValueExist() {
|
|
2073
2479
|
if (!dateDefaultValueExist) setDateDefaultValueExist(true);
|
|
2074
2480
|
}
|
|
2075
2481
|
function valueResConverter(inputData) {
|
|
2076
|
-
var v = isValidDate(inputData) ? inputData : "".concat(getFullTimeData(getNow()).date, " ").concat(inputData);
|
|
2482
|
+
var v = (0,utils_date.isValidDate)(inputData) ? inputData : "".concat(getFullTimeData((0,utils_date.getNow)()).date, " ").concat(inputData);
|
|
2077
2483
|
var _onlyTime = "".concat(getFullTimeData(v).hours, ":").concat(getFullTimeData(v).minutes).concat(truncateSeconds ? "" : ":".concat(getFullTimeData(v).seconds));
|
|
2078
2484
|
var _date = "".concat(getFullTimeData(v).year).concat(valueUseSlash ? "/" : '-').concat(getFullTimeData(v).month).concat(valueUseSlash ? "/" : '-').concat(getFullTimeData(v).day);
|
|
2079
2485
|
var _time = type === 'datetime-local' || type === 'time' ? " ".concat(getFullTimeData(v).hours, ":").concat(getFullTimeData(v).minutes).concat(truncateSeconds ? "" : ":".concat(getFullTimeData(v).seconds)) : '';
|
|
@@ -2206,11 +2612,10 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2206
2612
|
return res;
|
|
2207
2613
|
}
|
|
2208
2614
|
function initValue(v) {
|
|
2209
|
-
var
|
|
2210
|
-
var _res = valueResConverter(_dVal);
|
|
2615
|
+
var _res = valueResConverter(v);
|
|
2211
2616
|
setChangedVal(_res);
|
|
2212
|
-
if (isValidDate(
|
|
2213
|
-
var _getFullTimeData = getFullTimeData(
|
|
2617
|
+
if ((0,utils_date.isValidDate)(v)) {
|
|
2618
|
+
var _getFullTimeData = getFullTimeData(v),
|
|
2214
2619
|
date = _getFullTimeData.date,
|
|
2215
2620
|
year = _getFullTimeData.year,
|
|
2216
2621
|
month = _getFullTimeData.month,
|
|
@@ -2222,21 +2627,22 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2222
2627
|
setTimeVal([hours, minutes, seconds]);
|
|
2223
2628
|
setSplitVals([year, month, day, hours, minutes, seconds]);
|
|
2224
2629
|
}
|
|
2225
|
-
return [_res,
|
|
2630
|
+
return [_res, v];
|
|
2226
2631
|
}
|
|
2227
2632
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
2228
2633
|
// update default value
|
|
2229
2634
|
//--------------
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2635
|
+
var _getActualDefaultValu = getActualDefaultValue(value, true),
|
|
2636
|
+
_getActualDefaultValu2 = src_slicedToArray(_getActualDefaultValu, 3),
|
|
2637
|
+
curInitSplitClickEvOk = _getActualDefaultValu2[0],
|
|
2638
|
+
curNoTargetVal = _getActualDefaultValu2[1],
|
|
2639
|
+
curTargetVal = _getActualDefaultValu2[2];
|
|
2640
|
+
setDateDefaultValueExist(defaultValueIsEmpty ? false : true);
|
|
2641
|
+
var _initValue = initValue(curTargetVal),
|
|
2642
|
+
_initValue2 = src_slicedToArray(_initValue, 2),
|
|
2643
|
+
a = _initValue2[0],
|
|
2644
|
+
b = _initValue2[1];
|
|
2645
|
+
onLoad === null || onLoad === void 0 ? void 0 : onLoad(a, getFullTimeData(b));
|
|
2240
2646
|
|
|
2241
2647
|
//--------------
|
|
2242
2648
|
document.removeEventListener('pointerdown', handleClickOutside);
|
|
@@ -2304,7 +2710,7 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2304
2710
|
inputMode: "numeric",
|
|
2305
2711
|
tabIndex: tabIndex || 0,
|
|
2306
2712
|
className: "date2d__control__inputplaceholder--year",
|
|
2307
|
-
value: !dateDefaultValueExist ? "" : splitVals[0]
|
|
2713
|
+
value: !dateDefaultValueExist ? "" : splitVals[0],
|
|
2308
2714
|
maxLength: 4,
|
|
2309
2715
|
autoComplete: "off",
|
|
2310
2716
|
disabled: disabled || null,
|
|
@@ -2312,12 +2718,11 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2312
2718
|
onClick: handleInitSplitClickEv,
|
|
2313
2719
|
onChange: function onChange(e) {
|
|
2314
2720
|
var _val = e.target.value;
|
|
2721
|
+
if (_val !== '' && !(0,utils_date.isValidYear)(_val) && (0,utils_date.isNumeric)(_val) && Number(_val) > 9999) _val = '9999';
|
|
2722
|
+
if (_val !== '' && !(0,utils_date.isValidYear)(_val) && !(0,utils_date.isNumeric)(_val)) _val = "".concat((0,utils_date.getCurrentYear)());
|
|
2315
2723
|
var _date = "".concat(_val, "-").concat(splitVals[1], "-").concat(splitVals[2]);
|
|
2316
2724
|
var _full = "".concat(_date, " ").concat(splitVals[3], ":").concat(splitVals[4], ":").concat(splitVals[5]);
|
|
2317
|
-
|
|
2318
|
-
// console.log(/^([1-9][0-9])\d{2}$/.test(_val));// 1000 ~ 9999
|
|
2319
|
-
}
|
|
2320
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), isValidDate(_full));
|
|
2725
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), (0,utils_date.isValidDate)(_full));
|
|
2321
2726
|
setSplitVals(function (prevState) {
|
|
2322
2727
|
return [_val, prevState[1], prevState[2], prevState[3], prevState[4], prevState[5]];
|
|
2323
2728
|
});
|
|
@@ -2340,12 +2745,14 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2340
2745
|
onClick: handleInitSplitClickEv,
|
|
2341
2746
|
onChange: function onChange(e) {
|
|
2342
2747
|
var _val = e.target.value;
|
|
2748
|
+
if (_val !== '' && !(0,utils_date.isValidMonth)(_val) && (0,utils_date.isNumeric)(_val)) {
|
|
2749
|
+
if (Number(_val) > 12) _val = '12';
|
|
2750
|
+
if (Number(_val) < 1 && Number(_val) > 0) _val = '01';
|
|
2751
|
+
}
|
|
2752
|
+
if (_val !== '' && !(0,utils_date.isValidMonth)(_val) && !(0,utils_date.isNumeric)(_val)) _val = "".concat((0,utils_date.getCurrentMonth)());
|
|
2343
2753
|
var _date = "".concat(splitVals[0], "-").concat(_val, "-").concat(splitVals[2]);
|
|
2344
2754
|
var _full = "".concat(_date, " ").concat(splitVals[3], ":").concat(splitVals[4], ":").concat(splitVals[5]);
|
|
2345
|
-
|
|
2346
|
-
// console.log(/^(0?[1-9]|1[0-2])$/.test(_val));// 01~12, 1~12
|
|
2347
|
-
}
|
|
2348
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), isValidDate(_full));
|
|
2755
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), (0,utils_date.isValidDate)(_full));
|
|
2349
2756
|
setSplitVals(function (prevState) {
|
|
2350
2757
|
return [prevState[0], _val, prevState[2], prevState[3], prevState[4], prevState[5]];
|
|
2351
2758
|
});
|
|
@@ -2368,12 +2775,19 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2368
2775
|
onClick: handleInitSplitClickEv,
|
|
2369
2776
|
onChange: function onChange(e) {
|
|
2370
2777
|
var _val = e.target.value;
|
|
2778
|
+
var _day = "".concat(splitVals[0], "-").concat(splitVals[1], "-01");
|
|
2779
|
+
var d = (0,utils_date.getLastDayInMonth)(_day, new window.Date(_day).getMonth() + 1);
|
|
2780
|
+
if (_val !== '' && (0,utils_date.isValidDay)(_val) && (0,utils_date.isNumeric)(_val)) {
|
|
2781
|
+
if (Number(_val) > Number(d)) _val = "".concat(d);
|
|
2782
|
+
}
|
|
2783
|
+
if (_val !== '' && !(0,utils_date.isValidDay)(_val) && (0,utils_date.isNumeric)(_val)) {
|
|
2784
|
+
if (Number(_val) > Number(d)) _val = "".concat(d);
|
|
2785
|
+
if (Number(_val) < 1 && Number(_val) > 0) _val = '01';
|
|
2786
|
+
}
|
|
2787
|
+
if (_val !== '' && !(0,utils_date.isValidDay)(_val) && !(0,utils_date.isNumeric)(_val)) _val = "".concat((0,utils_date.getCurrentDay)());
|
|
2371
2788
|
var _date = "".concat(splitVals[0], "-").concat(splitVals[1], "-").concat(_val);
|
|
2372
2789
|
var _full = "".concat(_date, " ").concat(splitVals[3], ":").concat(splitVals[4], ":").concat(splitVals[5]);
|
|
2373
|
-
|
|
2374
|
-
// console.log(/^(0?[1-9]|[1-2][0-9]|3[0-1])$/.test(_val));// 01~31, 1~31
|
|
2375
|
-
}
|
|
2376
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), isValidDate(_full));
|
|
2790
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), (0,utils_date.isValidDate)(_full));
|
|
2377
2791
|
setSplitVals(function (prevState) {
|
|
2378
2792
|
return [prevState[0], prevState[1], _val, prevState[3], prevState[4], prevState[5]];
|
|
2379
2793
|
});
|
|
@@ -2396,12 +2810,11 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2396
2810
|
onClick: handleInitSplitClickEv,
|
|
2397
2811
|
onChange: function onChange(e) {
|
|
2398
2812
|
var _val = e.target.value;
|
|
2813
|
+
if (_val !== '' && !(0,utils_date.isValidHours)(_val) && (0,utils_date.isNumeric)(_val) && Number(_val) > 23) _val = '23';
|
|
2814
|
+
if (_val !== '' && !(0,utils_date.isValidHours)(_val) && !(0,utils_date.isNumeric)(_val)) _val = '00';
|
|
2399
2815
|
var _date = "".concat(splitVals[0], "-").concat(splitVals[1], "-").concat(splitVals[2]);
|
|
2400
2816
|
var _full = "".concat(_date, " ").concat(_val, ":").concat(splitVals[4], ":").concat(splitVals[5]);
|
|
2401
|
-
|
|
2402
|
-
// console.log(/^([01]?[0-9]|2[0-3])$/.test(_val));// 0~23, 00~23
|
|
2403
|
-
}
|
|
2404
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), isValidDate(_full));
|
|
2817
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), (0,utils_date.isValidDate)(_full));
|
|
2405
2818
|
setSplitVals(function (prevState) {
|
|
2406
2819
|
return [prevState[0], prevState[1], prevState[2], _val, prevState[4], prevState[5]];
|
|
2407
2820
|
});
|
|
@@ -2424,12 +2837,11 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2424
2837
|
onClick: handleInitSplitClickEv,
|
|
2425
2838
|
onChange: function onChange(e) {
|
|
2426
2839
|
var _val = e.target.value;
|
|
2840
|
+
if (_val !== '' && !(0,utils_date.isValidMinutesAndSeconds)(_val) && (0,utils_date.isNumeric)(_val) && Number(_val) > 59) _val = '59';
|
|
2841
|
+
if (_val !== '' && !(0,utils_date.isValidMinutesAndSeconds)(_val) && !(0,utils_date.isNumeric)(_val)) _val = '00';
|
|
2427
2842
|
var _date = "".concat(splitVals[0], "-").concat(splitVals[1], "-").concat(splitVals[2]);
|
|
2428
2843
|
var _full = "".concat(_date, " ").concat(splitVals[3], ":").concat(_val, ":").concat(splitVals[5]);
|
|
2429
|
-
|
|
2430
|
-
// console.log(/^([01]?[0-9]|[0-5][0-9])$/.test(_val));// 0~59, 00~59
|
|
2431
|
-
}
|
|
2432
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), isValidDate(_full));
|
|
2844
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), (0,utils_date.isValidDate)(_full));
|
|
2433
2845
|
setSplitVals(function (prevState) {
|
|
2434
2846
|
return [prevState[0], prevState[1], prevState[2], prevState[3], _val, prevState[5]];
|
|
2435
2847
|
});
|
|
@@ -2452,12 +2864,11 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2452
2864
|
onClick: handleInitSplitClickEv,
|
|
2453
2865
|
onChange: function onChange(e) {
|
|
2454
2866
|
var _val = e.target.value;
|
|
2867
|
+
if (_val !== '' && !(0,utils_date.isValidMinutesAndSeconds)(_val) && (0,utils_date.isNumeric)(_val) && Number(_val) > 59) _val = '59';
|
|
2868
|
+
if (_val !== '' && !(0,utils_date.isValidMinutesAndSeconds)(_val) && !(0,utils_date.isNumeric)(_val)) _val = '00';
|
|
2455
2869
|
var _date = "".concat(splitVals[0], "-").concat(splitVals[1], "-").concat(splitVals[2]);
|
|
2456
2870
|
var _full = "".concat(_date, " ").concat(splitVals[3], ":").concat(splitVals[4], ":").concat(_val);
|
|
2457
|
-
|
|
2458
|
-
// console.log(/^([01]?[0-9]|[0-5][0-9])$/.test(_val));// 0~59, 00~59
|
|
2459
|
-
}
|
|
2460
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), isValidDate(_full));
|
|
2871
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(inputRef.current, valueResConverter(_full), (0,utils_date.isValidDate)(_full));
|
|
2461
2872
|
setSplitVals(function (prevState) {
|
|
2462
2873
|
return [prevState[0], prevState[1], prevState[2], prevState[3], prevState[4], _val];
|
|
2463
2874
|
});
|
|
@@ -2602,7 +3013,6 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2602
3013
|
//
|
|
2603
3014
|
var _val = e.currentTarget.dataset.value;
|
|
2604
3015
|
var _v = getFullTimeData("".concat(dateVal, " ").concat(_val, ":").concat(timeVal[1], ":").concat(timeVal[2]));
|
|
2605
|
-
console.log('^^^^^^^funda-ui test: ', e.currentTarget.dataset.value, "".concat(dateVal, " ").concat(_val, ":").concat(timeVal[1], ":").concat(timeVal[2]), getFullTimeData("".concat(dateVal, " ").concat(_val, ":").concat(timeVal[1], ":").concat(timeVal[2])));
|
|
2606
3016
|
setChangedVal("".concat(dateVal, " ").concat(_val, ":").concat(timeVal[1], ":").concat(timeVal[2]));
|
|
2607
3017
|
setTimeVal(function (prevState) {
|
|
2608
3018
|
return [_val, prevState[1], prevState[2]];
|
|
@@ -2634,7 +3044,6 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
|
|
|
2634
3044
|
//
|
|
2635
3045
|
var _val = e.currentTarget.dataset.value;
|
|
2636
3046
|
var _v = getFullTimeData("".concat(dateVal, " ").concat(timeVal[0], ":").concat(_val, ":").concat(timeVal[2]));
|
|
2637
|
-
console.log('^^^^^^^funda-ui test: ', e.currentTarget.dataset.value, "".concat(dateVal, " ").concat(timeVal[0], ":").concat(_val, ":").concat(timeVal[2]), getFullTimeData("".concat(dateVal, " ").concat(timeVal[0], ":").concat(_val, ":").concat(timeVal[2])));
|
|
2638
3047
|
setChangedVal("".concat(dateVal, " ").concat(timeVal[0], ":").concat(_val, ":").concat(timeVal[2]));
|
|
2639
3048
|
setTimeVal(function (prevState) {
|
|
2640
3049
|
return [prevState[0], _val, prevState[2]];
|