@acontplus/ng-components 2.1.2 → 2.1.4
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.
|
@@ -48,6 +48,7 @@ import * as i2$3 from '@angular/material/input';
|
|
|
48
48
|
import { MatInputModule } from '@angular/material/input';
|
|
49
49
|
import { Datex, SPANISH_LOCALE, DEFAULT_THEME, MATERIAL_THEME, BOOTSTRAP_THEME } from 'datex-ui';
|
|
50
50
|
export { BOOTSTRAP_THEME, DEFAULT_THEME, Datex, MATERIAL_THEME, SPANISH_LOCALE, SPANISH_LOCALE_WITH_TIME } from 'datex-ui';
|
|
51
|
+
import { addDay, monthStart, monthEnd, weekStart, weekEnd } from '@formkit/tempo';
|
|
51
52
|
import { TranslocoService } from '@jsverse/transloco';
|
|
52
53
|
|
|
53
54
|
/**
|
|
@@ -3367,6 +3368,7 @@ class DateRangePicker {
|
|
|
3367
3368
|
this.stateChanges.next();
|
|
3368
3369
|
}
|
|
3369
3370
|
_errorState = false;
|
|
3371
|
+
currentDate = new Date();
|
|
3370
3372
|
get errorState() {
|
|
3371
3373
|
return this._errorState;
|
|
3372
3374
|
}
|
|
@@ -3512,7 +3514,7 @@ class DateRangePicker {
|
|
|
3512
3514
|
timePicker24Hour: true,
|
|
3513
3515
|
timePickerIncrement: 1,
|
|
3514
3516
|
timePickerSeconds: false,
|
|
3515
|
-
ranges:
|
|
3517
|
+
ranges: this.getDefaultRanges(),
|
|
3516
3518
|
opens: 'center',
|
|
3517
3519
|
drops: 'auto',
|
|
3518
3520
|
locale: SPANISH_LOCALE,
|
|
@@ -3524,13 +3526,38 @@ class DateRangePicker {
|
|
|
3524
3526
|
// Merge user options with defaults, excluding presetTheme
|
|
3525
3527
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3526
3528
|
const { presetTheme, ...userOptions } = opts;
|
|
3529
|
+
// Merge ranges: user ranges override defaults
|
|
3530
|
+
const mergedRanges = {
|
|
3531
|
+
...defaultOptions.ranges,
|
|
3532
|
+
...(userOptions.ranges || {}),
|
|
3533
|
+
};
|
|
3527
3534
|
return {
|
|
3528
3535
|
...defaultOptions,
|
|
3529
3536
|
...userOptions,
|
|
3537
|
+
ranges: mergedRanges,
|
|
3530
3538
|
// Always use getTheme() to handle presetTheme properly
|
|
3531
3539
|
theme: this.getTheme(),
|
|
3532
3540
|
};
|
|
3533
3541
|
}
|
|
3542
|
+
getDateAddDay(day) {
|
|
3543
|
+
return addDay(this.currentDate, day);
|
|
3544
|
+
}
|
|
3545
|
+
getDefaultRanges() {
|
|
3546
|
+
return {
|
|
3547
|
+
Hoy: [this.currentDate, this.currentDate],
|
|
3548
|
+
Ayer: [this.getDateAddDay(-1), this.getDateAddDay(-1)],
|
|
3549
|
+
'Últimos 5 días': [this.getDateAddDay(-4), this.currentDate],
|
|
3550
|
+
'Últimos 10 días': [this.getDateAddDay(-9), this.currentDate],
|
|
3551
|
+
'Últimos 15 días': [this.getDateAddDay(-14), this.currentDate],
|
|
3552
|
+
'Últimos 30 días': [this.getDateAddDay(-29), this.currentDate],
|
|
3553
|
+
'Esta semana': [weekStart(this.currentDate), weekEnd(this.currentDate)],
|
|
3554
|
+
'Este mes': [monthStart(this.currentDate), monthEnd(this.currentDate)],
|
|
3555
|
+
'El mes pasado': [
|
|
3556
|
+
monthStart(addDay(monthStart(this.currentDate), -1)),
|
|
3557
|
+
addDay(monthStart(this.currentDate), -1),
|
|
3558
|
+
],
|
|
3559
|
+
};
|
|
3560
|
+
}
|
|
3534
3561
|
getTheme() {
|
|
3535
3562
|
const opts = this.options();
|
|
3536
3563
|
const baseTheme = opts.theme ?? DEFAULT_THEME;
|