@libs-ui/components-datetime-picker 0.2.241 → 0.2.243
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/custom-ranges/calendar/calendar.component.d.ts +3 -3
- package/custom-ranges/custom-ranges.component.d.ts +5 -5
- package/defines/date-options.define.d.ts +2 -2
- package/esm2022/custom-ranges/calendar/calendar.component.mjs +57 -56
- package/esm2022/custom-ranges/custom-ranges.component.mjs +16 -16
- package/esm2022/defines/common-date.define.mjs +2 -2
- package/esm2022/defines/date-options.define.mjs +9 -10
- package/esm2022/picker.component.mjs +6 -7
- package/fesm2022/libs-ui-components-datetime-picker.mjs +85 -84
- package/fesm2022/libs-ui-components-datetime-picker.mjs.map +1 -1
- package/package.json +10 -10
- package/picker.component.d.ts +5 -5
|
@@ -2,13 +2,13 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { signal, computed, input, model, output, inject, viewChild, effect, untracked, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { LibsUiComponentsLabelComponent } from '@libs-ui/components-label';
|
|
4
4
|
import { LibsUiComponentsPopoverComponent } from '@libs-ui/components-popover';
|
|
5
|
-
import { UtilsLanguageConstants, get, UtilsCache,
|
|
5
|
+
import { UtilsLanguageConstants, get, UtilsCache, getDayjs, UtilsHttpParamsRequestInstance, isEmpty, set, ERROR_MESSAGE_EMPTY_VALID } from '@libs-ui/utils';
|
|
6
6
|
import * as i1 from '@ngx-translate/core';
|
|
7
7
|
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
8
|
-
import dayjs from 'dayjs';
|
|
9
8
|
import { LibsUiComponentsButtonsButtonComponent } from '@libs-ui/components-buttons-button';
|
|
10
9
|
import { LibsUiComponentsDropdownComponent } from '@libs-ui/components-dropdown';
|
|
11
10
|
import { LibsUiComponentsInputsInputComponent } from '@libs-ui/components-inputs-input';
|
|
11
|
+
import dayjs from 'dayjs';
|
|
12
12
|
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
13
13
|
import { returnListObject, returnDetailObject } from '@libs-ui/services-http-request';
|
|
14
14
|
|
|
@@ -53,13 +53,13 @@ const defaultLocaleConfig = () => {
|
|
|
53
53
|
};
|
|
54
54
|
const getDateRangeDefault = () => {
|
|
55
55
|
return {
|
|
56
|
-
today: [
|
|
57
|
-
yesterday: [
|
|
58
|
-
_7days_ago: [
|
|
59
|
-
_30days_ago: [
|
|
60
|
-
this_month: [
|
|
61
|
-
last_month: [
|
|
62
|
-
_3months_ago: [
|
|
56
|
+
today: [getDayjs().hour(0).minute(0).second(0).millisecond(0), getDayjs().hour(23).minute(59).second(59)],
|
|
57
|
+
yesterday: [getDayjs().subtract(1, 'days').hour(0).minute(0).second(0).millisecond(0), getDayjs().subtract(1, 'days').hour(23).minute(59).second(59)],
|
|
58
|
+
_7days_ago: [getDayjs().subtract(6, 'days').hour(0).second(0).minute(0).millisecond(0), getDayjs().hour(23).minute(59).second(59)],
|
|
59
|
+
_30days_ago: [getDayjs().subtract(29, 'days').hour(0).second(0).minute(0).millisecond(0), getDayjs().hour(23).minute(59).second(59)],
|
|
60
|
+
this_month: [getDayjs().startOf('month'), getDayjs().endOf('month')],
|
|
61
|
+
last_month: [getDayjs().subtract(1, 'month').startOf('month'), getDayjs().subtract(1, 'month').endOf('month')],
|
|
62
|
+
_3months_ago: [getDayjs().subtract(89, 'days').hour(0).second(0).minute(0).millisecond(0), getDayjs().hour(23).minute(59).second(59)],
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -196,7 +196,7 @@ const getYearsDetailById = (listOfYears = []) => {
|
|
|
196
196
|
};
|
|
197
197
|
|
|
198
198
|
const DEFAULT_MIN_YEAR = 1945;
|
|
199
|
-
const DEFAULT_MAX_YEAR =
|
|
199
|
+
const DEFAULT_MAX_YEAR = getDayjs().year() + 5;
|
|
200
200
|
|
|
201
201
|
var SideEnum;
|
|
202
202
|
(function (SideEnum) {
|
|
@@ -213,7 +213,7 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
213
213
|
calendarVariables = signal({ left: signal({}), right: signal({}) });
|
|
214
214
|
timepickerVariables = signal({ left: signal({ selectedHour: 0, selectedMinute: 0 }), right: signal({ selectedHour: 23, selectedMinute: 59 }) });
|
|
215
215
|
disableMonth = signal({ left: signal([]), right: signal([]) });
|
|
216
|
-
today = signal(
|
|
216
|
+
today = signal(getDayjs());
|
|
217
217
|
listKeyFromSelected = signal({ month: undefined, year: undefined });
|
|
218
218
|
listKeyToSelected = signal({ month: undefined, year: undefined });
|
|
219
219
|
checkShowListDropdown = signal({});
|
|
@@ -259,15 +259,15 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
259
259
|
autoApply = input(false);
|
|
260
260
|
hasSecondPicker = input(false);
|
|
261
261
|
showRangeLabelOnInput = input(undefined);
|
|
262
|
-
startDate = model(
|
|
263
|
-
endDate = model(
|
|
262
|
+
startDate = model(getDayjs().startOf('day'));
|
|
263
|
+
endDate = model(getDayjs().endOf('day'));
|
|
264
264
|
minDate = input(undefined, { transform: this.transformMinMaxDate.bind(this) });
|
|
265
265
|
maxDate = input(undefined, { transform: this.transformMinMaxDate.bind(this) });
|
|
266
266
|
listYearHiddenInputSearch = input(true, { transform: (value) => value ?? true });
|
|
267
267
|
/** OUTPUT */
|
|
268
268
|
outChangStageFlagMouse = output();
|
|
269
|
-
// readonly outStartDateChanged = output<{ startDate:
|
|
270
|
-
// readonly outEndDateChanged = output<{ endDate:
|
|
269
|
+
// readonly outStartDateChanged = output<{ startDate: Dayjs | undefined }>();
|
|
270
|
+
// readonly outEndDateChanged = output<{ endDate: Dayjs | undefined }>();
|
|
271
271
|
outPickerDate = output();
|
|
272
272
|
// readonly outRangeClicked: EventEmitter<IRangesClicked> = new EventEmitter();
|
|
273
273
|
outCancel = output();
|
|
@@ -279,23 +279,23 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
279
279
|
constructor() {
|
|
280
280
|
this.listMonthsConfig.set(getMonthsListConfig(this.translate));
|
|
281
281
|
effect(() => {
|
|
282
|
-
const oldStart = this.startDate()?.clone();
|
|
283
|
-
const oldEnd = this.endDate()?.clone();
|
|
282
|
+
const oldStart = getDayjs({ date: this.startDate()?.clone() });
|
|
283
|
+
const oldEnd = getDayjs({ date: this.endDate()?.clone() });
|
|
284
284
|
untracked(() => {
|
|
285
285
|
this.oldDate.set({ start: oldStart, end: oldEnd });
|
|
286
286
|
});
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
289
|
ngOnInit() {
|
|
290
|
-
const startDate = this.startDate()?.clone();
|
|
291
|
-
const endDate = this.endDate()?.clone();
|
|
290
|
+
const startDate = getDayjs({ date: this.startDate()?.clone() });
|
|
291
|
+
const endDate = getDayjs({ date: this.endDate()?.clone() });
|
|
292
292
|
this.splitPickerDate.update(current => {
|
|
293
293
|
current.start.update(sideCurrent => {
|
|
294
|
-
sideCurrent.day = (startDate ??
|
|
294
|
+
sideCurrent.day = (startDate ?? getDayjs().startOf('day')).date();
|
|
295
295
|
return sideCurrent;
|
|
296
296
|
});
|
|
297
297
|
current.end.update(sideCurrent => {
|
|
298
|
-
sideCurrent.day = (endDate ??
|
|
298
|
+
sideCurrent.day = (endDate ?? getDayjs().endOf('day')).date();
|
|
299
299
|
return sideCurrent;
|
|
300
300
|
});
|
|
301
301
|
return current;
|
|
@@ -337,8 +337,8 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
337
337
|
// this.outFunctionsControl.emit({ buildDefaultRange: this.buildDefaultRange.bind(this), applyToSelect: this.applyToSelect.bind(this) })
|
|
338
338
|
}
|
|
339
339
|
buildConfigYear(side, startYear) {
|
|
340
|
-
const minDate = this.minDate();
|
|
341
|
-
const maxDate = this.maxDate();
|
|
340
|
+
const minDate = getDayjs({ date: this.minDate() });
|
|
341
|
+
const maxDate = getDayjs({ date: this.maxDate() });
|
|
342
342
|
const listLeftYear = [];
|
|
343
343
|
const listRightYear = [];
|
|
344
344
|
if (side === SideEnum.left) {
|
|
@@ -355,7 +355,7 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
357
|
const start = maxDate?.year() ?? DEFAULT_MAX_YEAR;
|
|
358
|
-
const end = startYear ?? minDate?.year() ??
|
|
358
|
+
const end = startYear ?? minDate?.year() ?? getDayjs().year();
|
|
359
359
|
for (let i = start; i >= end; i--) {
|
|
360
360
|
listRightYear.push({
|
|
361
361
|
id: i,
|
|
@@ -369,23 +369,24 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
369
369
|
this.outChangStageFlagMouse.emit(flagMouse);
|
|
370
370
|
}
|
|
371
371
|
updateStartEndDate(date) {
|
|
372
|
-
|
|
372
|
+
date = getDayjs({ date });
|
|
373
|
+
if ((this.endDate() || date.isBefore(getDayjs({ date: this.startDate() }), 'day'))) {
|
|
373
374
|
if (this.hasTimePicker()) {
|
|
374
375
|
date = this.getDateWithTime(date, SideEnum.left);
|
|
375
376
|
}
|
|
376
377
|
this.endDate.set(undefined);
|
|
377
|
-
this.setStartDate(date.clone());
|
|
378
|
+
this.setStartDate(getDayjs({ date: date.clone() }));
|
|
378
379
|
return;
|
|
379
380
|
}
|
|
380
|
-
if (!this.endDate() && this.startDate() && date.isBefore(this.startDate())) {
|
|
381
|
-
this.setEndDate(this.startDate()?.clone());
|
|
381
|
+
if (!this.endDate() && this.startDate() && date.isBefore(getDayjs({ date: this.startDate() }))) {
|
|
382
|
+
this.setEndDate(getDayjs({ date: this.startDate()?.clone() }));
|
|
382
383
|
return;
|
|
383
384
|
}
|
|
384
385
|
if (this.hasTimePicker()) {
|
|
385
|
-
date = this.getDateWithTime(date, SideEnum.right);
|
|
386
|
+
date = getDayjs({ date: this.getDateWithTime(date, SideEnum.right) });
|
|
386
387
|
}
|
|
387
|
-
if (!date.isBefore(this.startDate(), 'day')) {
|
|
388
|
-
this.setEndDate(date.clone());
|
|
388
|
+
if (!date.isBefore(getDayjs({ date: this.startDate() }), 'day')) {
|
|
389
|
+
this.setEndDate(getDayjs({ date: date.clone() }));
|
|
389
390
|
}
|
|
390
391
|
if (this.autoApply()) {
|
|
391
392
|
this.calculateSelectedLabel();
|
|
@@ -418,23 +419,23 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
418
419
|
return;
|
|
419
420
|
}
|
|
420
421
|
if (typeof startDate === 'string') {
|
|
421
|
-
this.startDate.set(dayjs(startDate, this.dateOptions().format));
|
|
422
|
+
this.startDate.set(getDayjs({ date: dayjs(startDate, this.dateOptions().format), returnDayjsIfConfigDateNotExist: true }));
|
|
422
423
|
}
|
|
423
424
|
if (typeof startDate === 'object') {
|
|
424
425
|
this.pickingDate.set(true);
|
|
425
|
-
this.startDate.set(
|
|
426
|
+
this.startDate.set(getDayjs({ date: startDate, returnDayjsIfConfigDateNotExist: true }));
|
|
426
427
|
}
|
|
427
428
|
if (!this.hasTimePicker()) {
|
|
428
429
|
this.pickingDate.set(true);
|
|
429
|
-
this.startDate.set(this.startDate()?.startOf('day'));
|
|
430
|
+
this.startDate.set(getDayjs({ date: this.startDate()?.startOf('day') }));
|
|
430
431
|
}
|
|
431
432
|
this.setStartDateInTimePicker();
|
|
432
433
|
if (this.minDate() && this.startDate()?.isBefore(this.minDate())) {
|
|
433
|
-
this.startDate.set(this.minDate()?.clone());
|
|
434
|
+
this.startDate.set(getDayjs({ date: this.minDate() })?.clone());
|
|
434
435
|
this.setStartDateInTimePicker();
|
|
435
436
|
}
|
|
436
437
|
if (this.maxDate() && this.startDate()?.isAfter(this.maxDate())) {
|
|
437
|
-
this.startDate.set(this.maxDate()
|
|
438
|
+
this.startDate.set(getDayjs({ date: this.maxDate() })?.clone());
|
|
438
439
|
this.setStartDateInTimePicker();
|
|
439
440
|
}
|
|
440
441
|
if (!this.isShown()) {
|
|
@@ -457,11 +458,11 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
457
458
|
}
|
|
458
459
|
setEndDate(endDate) {
|
|
459
460
|
if (typeof endDate === 'string') {
|
|
460
|
-
this.endDate.set(dayjs(endDate, this.dateOptions().format));
|
|
461
|
+
this.endDate.set(getDayjs({ date: dayjs(endDate, this.dateOptions().format), returnDayjsIfConfigDateNotExist: true }));
|
|
461
462
|
}
|
|
462
463
|
if (typeof endDate === 'object') {
|
|
463
464
|
this.pickingDate.set(false);
|
|
464
|
-
this.endDate.set(dayjs(endDate));
|
|
465
|
+
this.endDate.set(getDayjs({ date: dayjs(endDate), returnDayjsIfConfigDateNotExist: true }));
|
|
465
466
|
}
|
|
466
467
|
if (!this.endDate() || !this.startDate()) {
|
|
467
468
|
return this.updateMonthsInView();
|
|
@@ -483,7 +484,7 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
483
484
|
this.endDate.set(this.startDate()?.clone());
|
|
484
485
|
}
|
|
485
486
|
if (this.maxDate() && this.endDate()?.isAfter(this.maxDate())) {
|
|
486
|
-
this.endDate.set(this.maxDate()?.clone());
|
|
487
|
+
this.endDate.set(getDayjs({ date: (this.maxDate()) })?.clone());
|
|
487
488
|
}
|
|
488
489
|
// this.outEndDateChanged.emit({ endDate: this.endDate() });
|
|
489
490
|
this.updateMonthsInView();
|
|
@@ -500,8 +501,8 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
500
501
|
this.renderCalendar(SideEnum.right);
|
|
501
502
|
}
|
|
502
503
|
getDisable(type) {
|
|
503
|
-
const minDate = this.minDate();
|
|
504
|
-
const maxDate = this.maxDate();
|
|
504
|
+
const minDate = getDayjs({ date: this.minDate() });
|
|
505
|
+
const maxDate = getDayjs({ date: this.maxDate() });
|
|
505
506
|
if (type === 'left') {
|
|
506
507
|
this.disableMonth().left.set([]);
|
|
507
508
|
if (minDate?.year() === this.listKeyFromSelected().year) {
|
|
@@ -723,7 +724,7 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
723
724
|
}
|
|
724
725
|
updateMonthSelect(event, type) {
|
|
725
726
|
const side = type.includes(SideEnum.left) ? SideEnum.left : SideEnum.right;
|
|
726
|
-
const year = this.calendarVariables()[side]().dropdowns?.()?.currentYear ||
|
|
727
|
+
const year = this.calendarVariables()[side]().dropdowns?.()?.currentYear || getDayjs().year();
|
|
727
728
|
const month = Number(event.key) - 1;
|
|
728
729
|
if (side === SideEnum.left) {
|
|
729
730
|
if (this.isSelectedData().leftmonth) {
|
|
@@ -840,7 +841,7 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
840
841
|
}
|
|
841
842
|
}
|
|
842
843
|
this.getDisable('right');
|
|
843
|
-
let month =
|
|
844
|
+
let month = getDayjs().month();
|
|
844
845
|
if (side === SideEnum.right && this.listKeyFromSelected().month) {
|
|
845
846
|
month = Number(this.listKeyFromSelected().month) - 1;
|
|
846
847
|
}
|
|
@@ -852,8 +853,8 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
852
853
|
}
|
|
853
854
|
monthOrYearChanged(month, year, side) {
|
|
854
855
|
const isLeft = side === SideEnum.left;
|
|
855
|
-
const minDate = this.minDate();
|
|
856
|
-
const maxDate = this.maxDate();
|
|
856
|
+
const minDate = getDayjs({ date: this.minDate() });
|
|
857
|
+
const maxDate = getDayjs({ date: this.maxDate() });
|
|
857
858
|
if (minDate && (year < minDate?.year() || (year === minDate?.year() && month < minDate?.month()))) {
|
|
858
859
|
month = minDate?.month();
|
|
859
860
|
year = minDate?.year();
|
|
@@ -1150,12 +1151,12 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
1150
1151
|
const hour = mainCalendar.month.hour();
|
|
1151
1152
|
const minute = mainCalendar.month.minute();
|
|
1152
1153
|
const second = mainCalendar.month.second();
|
|
1153
|
-
const daysInMonth =
|
|
1154
|
-
const firstDay =
|
|
1155
|
-
const lastDay =
|
|
1156
|
-
const lastMonth =
|
|
1157
|
-
const lastYear =
|
|
1158
|
-
const daysInLastMonth =
|
|
1154
|
+
const daysInMonth = getDayjs({ date: new Date(year, month) }).daysInMonth();
|
|
1155
|
+
const firstDay = getDayjs({ date: new Date(year, month, 1) });
|
|
1156
|
+
const lastDay = getDayjs({ date: new Date(year, month, daysInMonth) });
|
|
1157
|
+
const lastMonth = getDayjs({ date: firstDay.subtract(1, 'month') }).month();
|
|
1158
|
+
const lastYear = getDayjs({ date: firstDay.subtract(1, 'month') }).year();
|
|
1159
|
+
const daysInLastMonth = getDayjs({ date: new Date(lastYear, lastMonth) }).daysInMonth();
|
|
1159
1160
|
const dayOfWeek = firstDay.day();
|
|
1160
1161
|
const calendar = {};
|
|
1161
1162
|
calendar.firstDay = firstDay;
|
|
@@ -1170,16 +1171,16 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
1170
1171
|
if (dayOfWeek === this.dateOptions().firstDay) {
|
|
1171
1172
|
startDay = daysInLastMonth - 6;
|
|
1172
1173
|
}
|
|
1173
|
-
let curDate =
|
|
1174
|
-
for (let i = 0, col = 0, row = 0; i < 42; i++, col++, curDate =
|
|
1174
|
+
let curDate = getDayjs({ date: new Date(lastYear, lastMonth, startDay, 12, minute, second) });
|
|
1175
|
+
for (let i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = getDayjs({ date: curDate }).add(24, 'hour')) {
|
|
1175
1176
|
if (i > 0 && col % 7 === 0) {
|
|
1176
1177
|
col = 0;
|
|
1177
1178
|
row++;
|
|
1178
1179
|
}
|
|
1179
1180
|
calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
|
|
1180
1181
|
curDate = curDate.hour(12);
|
|
1181
|
-
const minDate = this.minDate();
|
|
1182
|
-
const maxDate = this.maxDate();
|
|
1182
|
+
const minDate = getDayjs({ date: this.minDate() });
|
|
1183
|
+
const maxDate = getDayjs({ date: this.maxDate() });
|
|
1183
1184
|
if (minDate && calendar[row][col].format('YYYY-MM-DD') === minDate?.format('YYYY-MM-DD') && calendar[row][col].isBefore(minDate) && side === 'left') {
|
|
1184
1185
|
calendar[row][col] = minDate?.clone();
|
|
1185
1186
|
}
|
|
@@ -1199,8 +1200,8 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
1199
1200
|
return current;
|
|
1200
1201
|
});
|
|
1201
1202
|
}
|
|
1202
|
-
const minDate = side === 'left' ? this.minDate() : this.startDate();
|
|
1203
|
-
const maxDate = this.maxDate();
|
|
1203
|
+
const minDate = side === 'left' ? getDayjs({ date: this.minDate() }) : getDayjs({ date: this.startDate() });
|
|
1204
|
+
const maxDate = getDayjs({ date: this.maxDate() });
|
|
1204
1205
|
this.calendarVariables()[side].set({
|
|
1205
1206
|
month: month,
|
|
1206
1207
|
year: year,
|
|
@@ -1254,8 +1255,8 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
1254
1255
|
}
|
|
1255
1256
|
for (let col = 0; col < 7; col++) {
|
|
1256
1257
|
const classes = [];
|
|
1257
|
-
const startDate = this.startDate();
|
|
1258
|
-
const endDate = this.endDate();
|
|
1258
|
+
const startDate = getDayjs({ date: this.startDate() });
|
|
1259
|
+
const endDate = getDayjs({ date: this.endDate() });
|
|
1259
1260
|
const nowHoveredDate = this.nowHoveredDate();
|
|
1260
1261
|
if (calendar[row][col].isSame(new Date(), 'day')) {
|
|
1261
1262
|
classes.push('today');
|
|
@@ -1302,10 +1303,10 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
1302
1303
|
}
|
|
1303
1304
|
}
|
|
1304
1305
|
renderTimePicker(side) {
|
|
1305
|
-
let selected =
|
|
1306
|
-
const maxDate = this.maxDate();
|
|
1307
|
-
const startDate = this.startDate();
|
|
1308
|
-
const endDate = this.endDate();
|
|
1306
|
+
let selected = getDayjs(), minDate;
|
|
1307
|
+
const maxDate = getDayjs({ date: this.maxDate() });
|
|
1308
|
+
const startDate = getDayjs({ date: this.startDate() });
|
|
1309
|
+
const endDate = getDayjs({ date: this.endDate() });
|
|
1309
1310
|
if (side === SideEnum.left && startDate) {
|
|
1310
1311
|
selected = startDate.clone();
|
|
1311
1312
|
minDate = this.maxDate();
|
|
@@ -1318,7 +1319,7 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
1318
1319
|
if (!startDate) {
|
|
1319
1320
|
return;
|
|
1320
1321
|
}
|
|
1321
|
-
selected = this.getDateWithTime(startDate, SideEnum.right);
|
|
1322
|
+
selected = getDayjs({ date: this.getDateWithTime(startDate, SideEnum.right) });
|
|
1322
1323
|
if (selected.isBefore(startDate)) {
|
|
1323
1324
|
selected = startDate.clone();
|
|
1324
1325
|
}
|
|
@@ -1423,7 +1424,7 @@ class LibsUiComponentsDatetimePickerCustomRangesCalendarComponent {
|
|
|
1423
1424
|
return value;
|
|
1424
1425
|
}
|
|
1425
1426
|
if (typeof value === 'string') {
|
|
1426
|
-
return
|
|
1427
|
+
return getDayjs({ date: value });
|
|
1427
1428
|
}
|
|
1428
1429
|
return undefined;
|
|
1429
1430
|
}
|
|
@@ -1491,8 +1492,8 @@ class LibsUiComponentsDatetimePickerCustomRangesComponent {
|
|
|
1491
1492
|
flagMouse = input({ isMouseEnter: false, isMouseEnterContent: false });
|
|
1492
1493
|
dateOptions = input({ ...defaultLocaleConfig(), ...getDateOptions() });
|
|
1493
1494
|
alwaysShowCalendars = input(false);
|
|
1494
|
-
startDate = model(
|
|
1495
|
-
endDate = model(
|
|
1495
|
+
startDate = model(getDayjs().startOf('day'));
|
|
1496
|
+
endDate = model(getDayjs().endOf('day'));
|
|
1496
1497
|
showCustomRangeLabel = input(undefined);
|
|
1497
1498
|
keepCalendarOpeningWithRange = input(undefined);
|
|
1498
1499
|
singleDateSelected = input(undefined, {
|
|
@@ -1502,7 +1503,7 @@ class LibsUiComponentsDatetimePickerCustomRangesComponent {
|
|
|
1502
1503
|
}
|
|
1503
1504
|
let date = value.date;
|
|
1504
1505
|
if (typeof date === 'string') {
|
|
1505
|
-
date =
|
|
1506
|
+
date = getDayjs({ date, returnDayjsIfConfigDateNotExist: true });
|
|
1506
1507
|
}
|
|
1507
1508
|
return {
|
|
1508
1509
|
...value,
|
|
@@ -1518,10 +1519,10 @@ class LibsUiComponentsDatetimePickerCustomRangesComponent {
|
|
|
1518
1519
|
let startDate = value.startDate;
|
|
1519
1520
|
let endDate = value.endDate;
|
|
1520
1521
|
if (typeof startDate === 'string') {
|
|
1521
|
-
startDate =
|
|
1522
|
+
startDate = getDayjs({ date: startDate, returnDayjsIfConfigDateNotExist: true });
|
|
1522
1523
|
}
|
|
1523
1524
|
if (typeof endDate === 'string') {
|
|
1524
|
-
endDate =
|
|
1525
|
+
endDate = getDayjs({ date: endDate, returnDayjsIfConfigDateNotExist: true });
|
|
1525
1526
|
}
|
|
1526
1527
|
return {
|
|
1527
1528
|
...value,
|
|
@@ -1542,10 +1543,10 @@ class LibsUiComponentsDatetimePickerCustomRangesComponent {
|
|
|
1542
1543
|
}
|
|
1543
1544
|
onAfterViewInit() {
|
|
1544
1545
|
if (!this.startDate()) {
|
|
1545
|
-
this.startDate.set(
|
|
1546
|
+
this.startDate.set(getDayjs().startOf('day'));
|
|
1546
1547
|
}
|
|
1547
1548
|
if (!this.endDate()) {
|
|
1548
|
-
this.endDate.set(
|
|
1549
|
+
this.endDate.set(getDayjs().endOf('day'));
|
|
1549
1550
|
}
|
|
1550
1551
|
const dateRangeSelected = this.dateRangeSelected();
|
|
1551
1552
|
const singleDateSelected = this.singleDateSelected();
|
|
@@ -1555,7 +1556,7 @@ class LibsUiComponentsDatetimePickerCustomRangesComponent {
|
|
|
1555
1556
|
};
|
|
1556
1557
|
if (this.isSingle()) {
|
|
1557
1558
|
if (this.hasTimePicker()) {
|
|
1558
|
-
const now =
|
|
1559
|
+
const now = getDayjs();
|
|
1559
1560
|
this.startDate.update(current => {
|
|
1560
1561
|
if (current) {
|
|
1561
1562
|
current.set('hour', 10).set('minute', 30);
|
|
@@ -1571,8 +1572,8 @@ class LibsUiComponentsDatetimePickerCustomRangesComponent {
|
|
|
1571
1572
|
});
|
|
1572
1573
|
}
|
|
1573
1574
|
if (singleDateSelected?.date) {
|
|
1574
|
-
this.startDate.set(singleDateSelected.date);
|
|
1575
|
-
this.endDate.set(singleDateSelected.date);
|
|
1575
|
+
this.startDate.set(getDayjs({ date: singleDateSelected.date }));
|
|
1576
|
+
this.endDate.set(getDayjs({ date: singleDateSelected.date }));
|
|
1576
1577
|
}
|
|
1577
1578
|
this.renderRanges();
|
|
1578
1579
|
return;
|
|
@@ -1580,8 +1581,8 @@ class LibsUiComponentsDatetimePickerCustomRangesComponent {
|
|
|
1580
1581
|
if (dateRangeSelected) {
|
|
1581
1582
|
this.selectedQuickRange.set(dateRangeSelected.quickRangeId ? dateRangeSelected.quickRangeId : customRange.id);
|
|
1582
1583
|
this.chosenQuickRange.set(dateRangeSelected.quickRangeId ?? customRange.id);
|
|
1583
|
-
this.startDate.set(dateRangeSelected.startDate);
|
|
1584
|
-
this.endDate.set(dateRangeSelected.endDate);
|
|
1584
|
+
this.startDate.set(getDayjs({ date: dateRangeSelected.startDate }));
|
|
1585
|
+
this.endDate.set(getDayjs({ date: dateRangeSelected.endDate }));
|
|
1585
1586
|
}
|
|
1586
1587
|
if (this.hasTimePicker()) {
|
|
1587
1588
|
this.selectedQuickRange.set(customRange.id);
|
|
@@ -1608,8 +1609,8 @@ class LibsUiComponentsDatetimePickerCustomRangesComponent {
|
|
|
1608
1609
|
this.quickRangesArray.set([]);
|
|
1609
1610
|
for (const key in ranges) {
|
|
1610
1611
|
const rangeValue = rangesDefault[key];
|
|
1611
|
-
const start =
|
|
1612
|
-
const end =
|
|
1612
|
+
const start = getDayjs({ date: rangeValue[0], returnDayjsIfConfigDateNotExist: true });
|
|
1613
|
+
const end = getDayjs({ date: rangeValue[1], returnDayjsIfConfigDateNotExist: true });
|
|
1613
1614
|
this.quickRangesArray.update(current => {
|
|
1614
1615
|
current.push({
|
|
1615
1616
|
id: key,
|
|
@@ -1880,7 +1881,7 @@ class LibsUiComponentsDatetimePickerComponent {
|
|
|
1880
1881
|
this.outSelectSingleDate.emit(data);
|
|
1881
1882
|
this.chosenDateFromRanges.set({ selectedLabel: data.displayLabel });
|
|
1882
1883
|
if (this.hasTimePicker()) {
|
|
1883
|
-
const startTime =
|
|
1884
|
+
const startTime = getDayjs({ date: data.date, returnDayjsIfConfigDateNotExist: true }).format('DD/MM/YYYY HH:mm');
|
|
1884
1885
|
this.chosenDateFromRanges.update(current => {
|
|
1885
1886
|
current.selectedLabel = `${startTime}`;
|
|
1886
1887
|
return current;
|
|
@@ -1896,11 +1897,11 @@ class LibsUiComponentsDatetimePickerComponent {
|
|
|
1896
1897
|
}
|
|
1897
1898
|
// this.selectedKey = data.selectedLabel;
|
|
1898
1899
|
this.chosenDateFromRanges.set({ selectedLabel: data.displayLabel });
|
|
1899
|
-
// this.selected.start =
|
|
1900
|
-
// this.selected.end =
|
|
1900
|
+
// this.selected.start = getDayjs<Dayjs>({date:data.startDate});
|
|
1901
|
+
// this.selected.end = getDayjs<Dayjs>({date:data.endDate});
|
|
1901
1902
|
if (this.hasTimePicker()) {
|
|
1902
|
-
const startTime =
|
|
1903
|
-
const endTime =
|
|
1903
|
+
const startTime = getDayjs({ date: data.startDate, returnDayjsIfConfigDateNotExist: true }).format('DD/MM/YYYY HH:mm');
|
|
1904
|
+
const endTime = getDayjs({ date: data.endDate, returnDayjsIfConfigDateNotExist: true }).format('DD/MM/YYYY HH:mm');
|
|
1904
1905
|
this.chosenDateFromRanges.update(current => {
|
|
1905
1906
|
current.selectedLabel = `${startTime} - ${endTime}`;
|
|
1906
1907
|
return current;
|