@acontplus/ng-components 2.1.2 → 2.1.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.
|
@@ -3512,7 +3512,7 @@ class DateRangePicker {
|
|
|
3512
3512
|
timePicker24Hour: true,
|
|
3513
3513
|
timePickerIncrement: 1,
|
|
3514
3514
|
timePickerSeconds: false,
|
|
3515
|
-
ranges:
|
|
3515
|
+
ranges: this.getDefaultRanges(),
|
|
3516
3516
|
opens: 'center',
|
|
3517
3517
|
drops: 'auto',
|
|
3518
3518
|
locale: SPANISH_LOCALE,
|
|
@@ -3524,13 +3524,53 @@ class DateRangePicker {
|
|
|
3524
3524
|
// Merge user options with defaults, excluding presetTheme
|
|
3525
3525
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3526
3526
|
const { presetTheme, ...userOptions } = opts;
|
|
3527
|
+
// Merge ranges: user ranges override defaults
|
|
3528
|
+
const mergedRanges = {
|
|
3529
|
+
...defaultOptions.ranges,
|
|
3530
|
+
...(userOptions.ranges || {}),
|
|
3531
|
+
};
|
|
3527
3532
|
return {
|
|
3528
3533
|
...defaultOptions,
|
|
3529
3534
|
...userOptions,
|
|
3535
|
+
ranges: mergedRanges,
|
|
3530
3536
|
// Always use getTheme() to handle presetTheme properly
|
|
3531
3537
|
theme: this.getTheme(),
|
|
3532
3538
|
};
|
|
3533
3539
|
}
|
|
3540
|
+
getDefaultRanges() {
|
|
3541
|
+
const today = new Date();
|
|
3542
|
+
const yesterday = new Date(today);
|
|
3543
|
+
yesterday.setDate(today.getDate() - 1);
|
|
3544
|
+
const last5Days = new Date(today);
|
|
3545
|
+
last5Days.setDate(today.getDate() - 4);
|
|
3546
|
+
const last10Days = new Date(today);
|
|
3547
|
+
last10Days.setDate(today.getDate() - 9);
|
|
3548
|
+
const last15Days = new Date(today);
|
|
3549
|
+
last15Days.setDate(today.getDate() - 14);
|
|
3550
|
+
const last30Days = new Date(today);
|
|
3551
|
+
last30Days.setDate(today.getDate() - 29);
|
|
3552
|
+
// Esta semana (lunes a domingo)
|
|
3553
|
+
const startOfWeek = new Date(today);
|
|
3554
|
+
const dayOfWeek = today.getDay();
|
|
3555
|
+
const daysToMonday = dayOfWeek === 0 ? 6 : dayOfWeek - 1; // Domingo = 0, necesitamos ir 6 días atrás
|
|
3556
|
+
startOfWeek.setDate(today.getDate() - daysToMonday);
|
|
3557
|
+
// Este mes
|
|
3558
|
+
const startOfMonth = new Date(today.getFullYear(), today.getMonth(), 1);
|
|
3559
|
+
// El mes pasado
|
|
3560
|
+
const startOfLastMonth = new Date(today.getFullYear(), today.getMonth() - 1, 1);
|
|
3561
|
+
const endOfLastMonth = new Date(today.getFullYear(), today.getMonth(), 0);
|
|
3562
|
+
return {
|
|
3563
|
+
Hoy: [today, today],
|
|
3564
|
+
Ayer: [yesterday, yesterday],
|
|
3565
|
+
'Últimos 5 días': [last5Days, today],
|
|
3566
|
+
'Últimos 10 días': [last10Days, today],
|
|
3567
|
+
'Últimos 15 días': [last15Days, today],
|
|
3568
|
+
'Últimos 30 días': [last30Days, today],
|
|
3569
|
+
'Esta semana': [startOfWeek, today],
|
|
3570
|
+
'Este mes': [startOfMonth, today],
|
|
3571
|
+
'El mes pasado': [startOfLastMonth, endOfLastMonth],
|
|
3572
|
+
};
|
|
3573
|
+
}
|
|
3534
3574
|
getTheme() {
|
|
3535
3575
|
const opts = this.options();
|
|
3536
3576
|
const baseTheme = opts.theme ?? DEFAULT_THEME;
|