@oneluiz/dual-datepicker 1.0.3 → 2.0.1
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/package.json +18 -23
- package/dist/dual-datepicker.component.d.ts +0 -56
- package/dist/dual-datepicker.component.d.ts.map +0 -1
- package/dist/dual-datepicker.component.html +0 -111
- package/dist/dual-datepicker.component.js +0 -292
- package/dist/dual-datepicker.component.scss +0 -256
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.esm.js +0 -5
- package/dist/index.js +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneluiz/dual-datepicker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A customizable dual-calendar date range picker component for Angular 17+",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -28,32 +28,27 @@
|
|
|
28
28
|
"@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
|
|
29
29
|
"@angular/forms": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0"
|
|
30
30
|
},
|
|
31
|
-
"main": "./dist/index.js",
|
|
32
|
-
"module": "./dist/index.esm.js",
|
|
33
|
-
"types": "./dist/index.d.ts",
|
|
34
|
-
"exports": {
|
|
35
|
-
".": {
|
|
36
|
-
"import": "./dist/index.esm.js",
|
|
37
|
-
"require": "./dist/index.js",
|
|
38
|
-
"types": "./dist/index.d.ts"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
31
|
"files": [
|
|
42
32
|
"dist",
|
|
43
33
|
"README.md",
|
|
44
34
|
"LICENSE"
|
|
45
35
|
],
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
"packageManager": "pnpm@10.13.1+sha512.37ebf1a5c7a30d5fabe0c5df44ee8da4c965ca0c5af3dbab28c3a1681b70a256218d05c81c9c0dcf767ef6b8551eb5b960042b9ed4300c59242336377e01cfad",
|
|
37
|
+
"module": "fesm2022/oneluiz-dual-datepicker.mjs",
|
|
38
|
+
"typings": "index.d.ts",
|
|
39
|
+
"exports": {
|
|
40
|
+
"./package.json": {
|
|
41
|
+
"default": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./index.d.ts",
|
|
45
|
+
"esm2022": "./esm2022/oneluiz-dual-datepicker.mjs",
|
|
46
|
+
"esm": "./esm2022/oneluiz-dual-datepicker.mjs",
|
|
47
|
+
"default": "./fesm2022/oneluiz-dual-datepicker.mjs"
|
|
48
|
+
}
|
|
50
49
|
},
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
"@angular/forms": "^17.3.12",
|
|
55
|
-
"rxjs": "^7.8.2",
|
|
56
|
-
"typescript": "5.2",
|
|
57
|
-
"zone.js": "^0.14.10"
|
|
50
|
+
"sideEffects": false,
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"tslib": "^2.3.0"
|
|
58
53
|
}
|
|
59
|
-
}
|
|
54
|
+
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { EventEmitter, OnInit, OnChanges, SimpleChanges, ElementRef } from '@angular/core';
|
|
2
|
-
export interface DateRange {
|
|
3
|
-
fechaInicio: string;
|
|
4
|
-
fechaFin: string;
|
|
5
|
-
rangoTexto: string;
|
|
6
|
-
}
|
|
7
|
-
export interface PresetConfig {
|
|
8
|
-
label: string;
|
|
9
|
-
daysAgo: number;
|
|
10
|
-
}
|
|
11
|
-
export declare class DualDatepickerComponent implements OnInit, OnChanges {
|
|
12
|
-
private elementRef;
|
|
13
|
-
placeholder: string;
|
|
14
|
-
fechaInicio: string;
|
|
15
|
-
fechaFin: string;
|
|
16
|
-
showPresets: boolean;
|
|
17
|
-
closeOnSelection: boolean;
|
|
18
|
-
closeOnPresetSelection: boolean;
|
|
19
|
-
closeOnClickOutside: boolean;
|
|
20
|
-
presets: PresetConfig[];
|
|
21
|
-
inputBackgroundColor: string;
|
|
22
|
-
inputTextColor: string;
|
|
23
|
-
inputBorderColor: string;
|
|
24
|
-
inputBorderColorHover: string;
|
|
25
|
-
inputBorderColorFocus: string;
|
|
26
|
-
inputPadding: string;
|
|
27
|
-
dateRangeChange: EventEmitter<DateRange>;
|
|
28
|
-
dateRangeSelected: EventEmitter<DateRange>;
|
|
29
|
-
mostrarDatePicker: boolean;
|
|
30
|
-
rangoFechas: string;
|
|
31
|
-
fechaSeleccionandoInicio: boolean;
|
|
32
|
-
mesActual: Date;
|
|
33
|
-
mesAnterior: Date;
|
|
34
|
-
diasMesActual: any[];
|
|
35
|
-
diasMesAnterior: any[];
|
|
36
|
-
constructor(elementRef: ElementRef);
|
|
37
|
-
onClickOutside(event: MouseEvent): void;
|
|
38
|
-
ngOnInit(): void;
|
|
39
|
-
ngOnChanges(changes: SimpleChanges): void;
|
|
40
|
-
formatearFecha(fecha: Date): string;
|
|
41
|
-
formatearFechaDisplay(fechaStr: string): string;
|
|
42
|
-
actualizarRangoFechasTexto(): void;
|
|
43
|
-
toggleDatePicker(): void;
|
|
44
|
-
cerrarDatePicker(): void;
|
|
45
|
-
generarCalendarios(): void;
|
|
46
|
-
generarCalendarioMes(fecha: Date): any[];
|
|
47
|
-
estaEnRango(fechaStr: string): boolean;
|
|
48
|
-
seleccionarDia(diaObj: any): void;
|
|
49
|
-
cambiarMes(direccion: number): void;
|
|
50
|
-
getNombreMes(fecha: Date): string;
|
|
51
|
-
seleccionarRangoPredefinido(preset: PresetConfig): void;
|
|
52
|
-
limpiar(): void;
|
|
53
|
-
private emitirCambio;
|
|
54
|
-
private emitirSeleccion;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=dual-datepicker.component.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dual-datepicker.component.d.ts","sourceRoot":"","sources":["../src/dual-datepicker.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAgB,UAAU,EAAE,MAAM,eAAe,CAAC;AAInI,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAOa,uBAAwB,YAAW,MAAM,EAAE,SAAS;IA+BnD,OAAO,CAAC,UAAU;IA9BrB,WAAW,EAAE,MAAM,CAAuB;IAC1C,WAAW,EAAE,MAAM,CAAM;IACzB,QAAQ,EAAE,MAAM,CAAM;IACtB,WAAW,EAAE,OAAO,CAAQ;IAC5B,gBAAgB,EAAE,OAAO,CAAQ;IACjC,sBAAsB,EAAE,OAAO,CAAQ;IACvC,mBAAmB,EAAE,OAAO,CAAQ;IACpC,OAAO,EAAE,YAAY,EAAE,CAI9B;IACO,oBAAoB,EAAE,MAAM,CAAU;IACtC,cAAc,EAAE,MAAM,CAAa;IACnC,gBAAgB,EAAE,MAAM,CAAa;IACrC,qBAAqB,EAAE,MAAM,CAAa;IAC1C,qBAAqB,EAAE,MAAM,CAAa;IAC1C,YAAY,EAAE,MAAM,CAAsB;IAEzC,eAAe,0BAAiC;IAChD,iBAAiB,0BAAiC;IAE5D,iBAAiB,UAAS;IAC1B,WAAW,SAAM;IACjB,wBAAwB,UAAQ;IAChC,SAAS,OAAc;IACvB,WAAW,OAAc;IACzB,aAAa,EAAE,GAAG,EAAE,CAAM;IAC1B,eAAe,EAAE,GAAG,EAAE,CAAM;gBAER,UAAU,EAAE,UAAU;IAG1C,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IASvC,QAAQ,IAAI,IAAI;IAOhB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAWzC,cAAc,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM;IAOnC,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAO/C,0BAA0B,IAAI,IAAI;IAUlC,gBAAgB,IAAI,IAAI;IASxB,gBAAgB,IAAI,IAAI;IAIxB,kBAAkB,IAAI,IAAI;IAK1B,oBAAoB,CAAC,KAAK,EAAE,IAAI,GAAG,GAAG,EAAE;IA8BxC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAKtC,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAyBjC,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAMnC,YAAY,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM;IAKjC,2BAA2B,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAevD,OAAO,IAAI,IAAI;IASf,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,eAAe;CAOxB"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
<div class="datepicker-wrapper"
|
|
2
|
-
[style.--input-border-hover]="inputBorderColorHover"
|
|
3
|
-
[style.--input-border-focus]="inputBorderColorFocus">
|
|
4
|
-
<input
|
|
5
|
-
type="text"
|
|
6
|
-
class="datepicker-input"
|
|
7
|
-
[value]="rangoFechas"
|
|
8
|
-
(click)="toggleDatePicker()"
|
|
9
|
-
[placeholder]="placeholder"
|
|
10
|
-
[ngStyle]="{
|
|
11
|
-
'background-color': inputBackgroundColor,
|
|
12
|
-
'color': inputTextColor,
|
|
13
|
-
'border-color': inputBorderColor,
|
|
14
|
-
'padding': inputPadding
|
|
15
|
-
}"
|
|
16
|
-
readonly>
|
|
17
|
-
|
|
18
|
-
@if (mostrarDatePicker) {
|
|
19
|
-
<div class="date-picker-dropdown">
|
|
20
|
-
@if (showPresets) {
|
|
21
|
-
<div class="date-picker-presets">
|
|
22
|
-
@for (preset of presets; track preset.label) {
|
|
23
|
-
<button type="button" (click)="seleccionarRangoPredefinido(preset)">{{ preset.label }}</button>
|
|
24
|
-
}
|
|
25
|
-
<button type="button" class="btn-close-calendar" (click)="cerrarDatePicker()" title="Close">
|
|
26
|
-
×
|
|
27
|
-
</button>
|
|
28
|
-
</div>
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@if (!showPresets) {
|
|
32
|
-
<div class="date-picker-header-only-close">
|
|
33
|
-
<button type="button" class="btn-close-calendar" (click)="cerrarDatePicker()" title="Close">
|
|
34
|
-
×
|
|
35
|
-
</button>
|
|
36
|
-
</div>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
<!-- Calendars -->
|
|
40
|
-
<div class="date-picker-calendars">
|
|
41
|
-
<!-- Previous month calendar -->
|
|
42
|
-
<div class="date-picker-calendar">
|
|
43
|
-
<div class="date-picker-header">
|
|
44
|
-
<button type="button" (click)="cambiarMes(-1)">
|
|
45
|
-
<svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
|
46
|
-
<path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/>
|
|
47
|
-
</svg>
|
|
48
|
-
</button>
|
|
49
|
-
<span>{{ getNombreMes(mesAnterior) }}</span>
|
|
50
|
-
<button type="button" style="visibility: hidden;">
|
|
51
|
-
<svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
|
52
|
-
<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
|
|
53
|
-
</svg>
|
|
54
|
-
</button>
|
|
55
|
-
</div>
|
|
56
|
-
<div class="date-picker-weekdays">
|
|
57
|
-
<span>S</span><span>M</span><span>T</span><span>W</span><span>T</span><span>F</span><span>S</span>
|
|
58
|
-
</div>
|
|
59
|
-
<div class="date-picker-days">
|
|
60
|
-
@for (diaObj of diasMesAnterior; track diaObj.fecha || $index) {
|
|
61
|
-
<button
|
|
62
|
-
type="button"
|
|
63
|
-
class="date-picker-day"
|
|
64
|
-
[class.empty]="!diaObj.esMesActual"
|
|
65
|
-
[class.selected]="diaObj.esInicio || diaObj.esFin"
|
|
66
|
-
[class.in-range]="diaObj.enRango && !diaObj.esInicio && !diaObj.esFin"
|
|
67
|
-
(click)="seleccionarDia(diaObj)"
|
|
68
|
-
[disabled]="!diaObj.esMesActual">
|
|
69
|
-
{{ diaObj.dia }}
|
|
70
|
-
</button>
|
|
71
|
-
}
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
<!-- Current month calendar -->
|
|
76
|
-
<div class="date-picker-calendar">
|
|
77
|
-
<div class="date-picker-header">
|
|
78
|
-
<button type="button" style="visibility: hidden;">
|
|
79
|
-
<svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
|
80
|
-
<path fill-rule="evenodd" d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z"/>
|
|
81
|
-
</svg>
|
|
82
|
-
</button>
|
|
83
|
-
<span>{{ getNombreMes(mesActual) }}</span>
|
|
84
|
-
<button type="button" (click)="cambiarMes(1)">
|
|
85
|
-
<svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
|
86
|
-
<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
|
|
87
|
-
</svg>
|
|
88
|
-
</button>
|
|
89
|
-
</div>
|
|
90
|
-
<div class="date-picker-weekdays">
|
|
91
|
-
<span>S</span><span>M</span><span>T</span><span>W</span><span>T</span><span>F</span><span>S</span>
|
|
92
|
-
</div>
|
|
93
|
-
<div class="date-picker-days">
|
|
94
|
-
@for (diaObj of diasMesActual; track diaObj.fecha || $index) {
|
|
95
|
-
<button
|
|
96
|
-
type="button"
|
|
97
|
-
class="date-picker-day"
|
|
98
|
-
[class.empty]="!diaObj.esMesActual"
|
|
99
|
-
[class.selected]="diaObj.esInicio || diaObj.esFin"
|
|
100
|
-
[class.in-range]="diaObj.enRango && !diaObj.esInicio && !diaObj.esFin"
|
|
101
|
-
(click)="seleccionarDia(diaObj)"
|
|
102
|
-
[disabled]="!diaObj.esMesActual">
|
|
103
|
-
{{ diaObj.dia }}
|
|
104
|
-
</button>
|
|
105
|
-
}
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
}
|
|
111
|
-
</div>
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DualDatepickerComponent = void 0;
|
|
13
|
-
const core_1 = require("@angular/core");
|
|
14
|
-
const common_1 = require("@angular/common");
|
|
15
|
-
const forms_1 = require("@angular/forms");
|
|
16
|
-
let DualDatepickerComponent = class DualDatepickerComponent {
|
|
17
|
-
elementRef;
|
|
18
|
-
placeholder = 'Select date range';
|
|
19
|
-
fechaInicio = '';
|
|
20
|
-
fechaFin = '';
|
|
21
|
-
showPresets = true;
|
|
22
|
-
closeOnSelection = true;
|
|
23
|
-
closeOnPresetSelection = true;
|
|
24
|
-
closeOnClickOutside = true;
|
|
25
|
-
presets = [
|
|
26
|
-
{ label: 'Last month', daysAgo: 30 },
|
|
27
|
-
{ label: 'Last 6 months', daysAgo: 180 },
|
|
28
|
-
{ label: 'Last year', daysAgo: 365 }
|
|
29
|
-
];
|
|
30
|
-
inputBackgroundColor = '#fff';
|
|
31
|
-
inputTextColor = '#495057';
|
|
32
|
-
inputBorderColor = '#ced4da';
|
|
33
|
-
inputBorderColorHover = '#ced4da';
|
|
34
|
-
inputBorderColorFocus = '#80bdff';
|
|
35
|
-
inputPadding = '0.375rem 0.75rem';
|
|
36
|
-
dateRangeChange = new core_1.EventEmitter();
|
|
37
|
-
dateRangeSelected = new core_1.EventEmitter();
|
|
38
|
-
mostrarDatePicker = false;
|
|
39
|
-
rangoFechas = '';
|
|
40
|
-
fechaSeleccionandoInicio = true;
|
|
41
|
-
mesActual = new Date();
|
|
42
|
-
mesAnterior = new Date();
|
|
43
|
-
diasMesActual = [];
|
|
44
|
-
diasMesAnterior = [];
|
|
45
|
-
constructor(elementRef) {
|
|
46
|
-
this.elementRef = elementRef;
|
|
47
|
-
}
|
|
48
|
-
onClickOutside(event) {
|
|
49
|
-
if (this.mostrarDatePicker && this.closeOnClickOutside) {
|
|
50
|
-
const clickedInside = this.elementRef.nativeElement.contains(event.target);
|
|
51
|
-
if (!clickedInside) {
|
|
52
|
-
this.cerrarDatePicker();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
ngOnInit() {
|
|
57
|
-
if (this.fechaInicio && this.fechaFin) {
|
|
58
|
-
this.actualizarRangoFechasTexto();
|
|
59
|
-
this.generarCalendarios();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
ngOnChanges(changes) {
|
|
63
|
-
if (changes['fechaInicio'] || changes['fechaFin']) {
|
|
64
|
-
if (this.fechaInicio && this.fechaFin) {
|
|
65
|
-
this.actualizarRangoFechasTexto();
|
|
66
|
-
this.generarCalendarios();
|
|
67
|
-
}
|
|
68
|
-
else if (!this.fechaInicio && !this.fechaFin) {
|
|
69
|
-
this.rangoFechas = '';
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
formatearFecha(fecha) {
|
|
74
|
-
const year = fecha.getFullYear();
|
|
75
|
-
const month = String(fecha.getMonth() + 1).padStart(2, '0');
|
|
76
|
-
const day = String(fecha.getDate()).padStart(2, '0');
|
|
77
|
-
return `${year}-${month}-${day}`;
|
|
78
|
-
}
|
|
79
|
-
formatearFechaDisplay(fechaStr) {
|
|
80
|
-
if (!fechaStr)
|
|
81
|
-
return '';
|
|
82
|
-
const fecha = new Date(fechaStr + 'T00:00:00');
|
|
83
|
-
const meses = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
84
|
-
return `${fecha.getDate()} ${meses[fecha.getMonth()]}`;
|
|
85
|
-
}
|
|
86
|
-
actualizarRangoFechasTexto() {
|
|
87
|
-
if (this.fechaInicio && this.fechaFin) {
|
|
88
|
-
const inicio = this.formatearFechaDisplay(this.fechaInicio);
|
|
89
|
-
const fin = this.formatearFechaDisplay(this.fechaFin);
|
|
90
|
-
this.rangoFechas = `${inicio} - ${fin}`;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
this.rangoFechas = '';
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
toggleDatePicker() {
|
|
97
|
-
this.mostrarDatePicker = !this.mostrarDatePicker;
|
|
98
|
-
if (this.mostrarDatePicker) {
|
|
99
|
-
this.fechaSeleccionandoInicio = true;
|
|
100
|
-
this.mesAnterior = new Date(this.mesActual.getFullYear(), this.mesActual.getMonth() - 1, 1);
|
|
101
|
-
this.generarCalendarios();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
cerrarDatePicker() {
|
|
105
|
-
this.mostrarDatePicker = false;
|
|
106
|
-
}
|
|
107
|
-
generarCalendarios() {
|
|
108
|
-
this.diasMesAnterior = this.generarCalendarioMes(this.mesAnterior);
|
|
109
|
-
this.diasMesActual = this.generarCalendarioMes(this.mesActual);
|
|
110
|
-
}
|
|
111
|
-
generarCalendarioMes(fecha) {
|
|
112
|
-
const año = fecha.getFullYear();
|
|
113
|
-
const mes = fecha.getMonth();
|
|
114
|
-
const primerDia = new Date(año, mes, 1);
|
|
115
|
-
const ultimoDia = new Date(año, mes + 1, 0);
|
|
116
|
-
const diasEnMes = ultimoDia.getDate();
|
|
117
|
-
const primerDiaSemana = primerDia.getDay();
|
|
118
|
-
const diasMes = [];
|
|
119
|
-
for (let i = 0; i < primerDiaSemana; i++) {
|
|
120
|
-
diasMes.push({ dia: null, esMesActual: false });
|
|
121
|
-
}
|
|
122
|
-
for (let dia = 1; dia <= diasEnMes; dia++) {
|
|
123
|
-
const fechaDia = new Date(año, mes, dia);
|
|
124
|
-
const fechaStr = this.formatearFecha(fechaDia);
|
|
125
|
-
diasMes.push({
|
|
126
|
-
dia: dia,
|
|
127
|
-
fecha: fechaStr,
|
|
128
|
-
esMesActual: true,
|
|
129
|
-
esInicio: this.fechaInicio === fechaStr,
|
|
130
|
-
esFin: this.fechaFin === fechaStr,
|
|
131
|
-
enRango: this.estaEnRango(fechaStr)
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
return diasMes;
|
|
135
|
-
}
|
|
136
|
-
estaEnRango(fechaStr) {
|
|
137
|
-
if (!this.fechaInicio || !this.fechaFin)
|
|
138
|
-
return false;
|
|
139
|
-
return fechaStr >= this.fechaInicio && fechaStr <= this.fechaFin;
|
|
140
|
-
}
|
|
141
|
-
seleccionarDia(diaObj) {
|
|
142
|
-
if (!diaObj.esMesActual)
|
|
143
|
-
return;
|
|
144
|
-
if (this.fechaSeleccionandoInicio) {
|
|
145
|
-
this.fechaInicio = diaObj.fecha;
|
|
146
|
-
this.fechaFin = '';
|
|
147
|
-
this.fechaSeleccionandoInicio = false;
|
|
148
|
-
this.emitirCambio();
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
if (diaObj.fecha < this.fechaInicio) {
|
|
152
|
-
this.fechaFin = this.fechaInicio;
|
|
153
|
-
this.fechaInicio = diaObj.fecha;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
this.fechaFin = diaObj.fecha;
|
|
157
|
-
}
|
|
158
|
-
this.actualizarRangoFechasTexto();
|
|
159
|
-
if (this.closeOnSelection) {
|
|
160
|
-
this.mostrarDatePicker = false;
|
|
161
|
-
}
|
|
162
|
-
this.fechaSeleccionandoInicio = true;
|
|
163
|
-
this.emitirSeleccion();
|
|
164
|
-
}
|
|
165
|
-
this.generarCalendarios();
|
|
166
|
-
}
|
|
167
|
-
cambiarMes(direccion) {
|
|
168
|
-
this.mesActual = new Date(this.mesActual.getFullYear(), this.mesActual.getMonth() + direccion, 1);
|
|
169
|
-
this.mesAnterior = new Date(this.mesActual.getFullYear(), this.mesActual.getMonth() - 1, 1);
|
|
170
|
-
this.generarCalendarios();
|
|
171
|
-
}
|
|
172
|
-
getNombreMes(fecha) {
|
|
173
|
-
const meses = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
174
|
-
return `${meses[fecha.getMonth()]} ${fecha.getFullYear()}`;
|
|
175
|
-
}
|
|
176
|
-
seleccionarRangoPredefinido(preset) {
|
|
177
|
-
const hoy = new Date();
|
|
178
|
-
const fechaInicio = new Date(hoy);
|
|
179
|
-
fechaInicio.setDate(hoy.getDate() - preset.daysAgo);
|
|
180
|
-
this.fechaInicio = this.formatearFecha(fechaInicio);
|
|
181
|
-
this.fechaFin = this.formatearFecha(hoy);
|
|
182
|
-
this.actualizarRangoFechasTexto();
|
|
183
|
-
this.generarCalendarios();
|
|
184
|
-
if (this.closeOnPresetSelection) {
|
|
185
|
-
this.mostrarDatePicker = false;
|
|
186
|
-
}
|
|
187
|
-
this.emitirSeleccion();
|
|
188
|
-
}
|
|
189
|
-
limpiar() {
|
|
190
|
-
this.fechaInicio = '';
|
|
191
|
-
this.fechaFin = '';
|
|
192
|
-
this.rangoFechas = '';
|
|
193
|
-
this.mostrarDatePicker = false;
|
|
194
|
-
this.fechaSeleccionandoInicio = true;
|
|
195
|
-
this.emitirCambio();
|
|
196
|
-
}
|
|
197
|
-
emitirCambio() {
|
|
198
|
-
this.dateRangeChange.emit({
|
|
199
|
-
fechaInicio: this.fechaInicio,
|
|
200
|
-
fechaFin: this.fechaFin,
|
|
201
|
-
rangoTexto: this.rangoFechas
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
emitirSeleccion() {
|
|
205
|
-
this.dateRangeSelected.emit({
|
|
206
|
-
fechaInicio: this.fechaInicio,
|
|
207
|
-
fechaFin: this.fechaFin,
|
|
208
|
-
rangoTexto: this.rangoFechas
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
exports.DualDatepickerComponent = DualDatepickerComponent;
|
|
213
|
-
__decorate([
|
|
214
|
-
(0, core_1.Input)(),
|
|
215
|
-
__metadata("design:type", String)
|
|
216
|
-
], DualDatepickerComponent.prototype, "placeholder", void 0);
|
|
217
|
-
__decorate([
|
|
218
|
-
(0, core_1.Input)(),
|
|
219
|
-
__metadata("design:type", String)
|
|
220
|
-
], DualDatepickerComponent.prototype, "fechaInicio", void 0);
|
|
221
|
-
__decorate([
|
|
222
|
-
(0, core_1.Input)(),
|
|
223
|
-
__metadata("design:type", String)
|
|
224
|
-
], DualDatepickerComponent.prototype, "fechaFin", void 0);
|
|
225
|
-
__decorate([
|
|
226
|
-
(0, core_1.Input)(),
|
|
227
|
-
__metadata("design:type", Boolean)
|
|
228
|
-
], DualDatepickerComponent.prototype, "showPresets", void 0);
|
|
229
|
-
__decorate([
|
|
230
|
-
(0, core_1.Input)(),
|
|
231
|
-
__metadata("design:type", Boolean)
|
|
232
|
-
], DualDatepickerComponent.prototype, "closeOnSelection", void 0);
|
|
233
|
-
__decorate([
|
|
234
|
-
(0, core_1.Input)(),
|
|
235
|
-
__metadata("design:type", Boolean)
|
|
236
|
-
], DualDatepickerComponent.prototype, "closeOnPresetSelection", void 0);
|
|
237
|
-
__decorate([
|
|
238
|
-
(0, core_1.Input)(),
|
|
239
|
-
__metadata("design:type", Boolean)
|
|
240
|
-
], DualDatepickerComponent.prototype, "closeOnClickOutside", void 0);
|
|
241
|
-
__decorate([
|
|
242
|
-
(0, core_1.Input)(),
|
|
243
|
-
__metadata("design:type", Array)
|
|
244
|
-
], DualDatepickerComponent.prototype, "presets", void 0);
|
|
245
|
-
__decorate([
|
|
246
|
-
(0, core_1.Input)(),
|
|
247
|
-
__metadata("design:type", String)
|
|
248
|
-
], DualDatepickerComponent.prototype, "inputBackgroundColor", void 0);
|
|
249
|
-
__decorate([
|
|
250
|
-
(0, core_1.Input)(),
|
|
251
|
-
__metadata("design:type", String)
|
|
252
|
-
], DualDatepickerComponent.prototype, "inputTextColor", void 0);
|
|
253
|
-
__decorate([
|
|
254
|
-
(0, core_1.Input)(),
|
|
255
|
-
__metadata("design:type", String)
|
|
256
|
-
], DualDatepickerComponent.prototype, "inputBorderColor", void 0);
|
|
257
|
-
__decorate([
|
|
258
|
-
(0, core_1.Input)(),
|
|
259
|
-
__metadata("design:type", String)
|
|
260
|
-
], DualDatepickerComponent.prototype, "inputBorderColorHover", void 0);
|
|
261
|
-
__decorate([
|
|
262
|
-
(0, core_1.Input)(),
|
|
263
|
-
__metadata("design:type", String)
|
|
264
|
-
], DualDatepickerComponent.prototype, "inputBorderColorFocus", void 0);
|
|
265
|
-
__decorate([
|
|
266
|
-
(0, core_1.Input)(),
|
|
267
|
-
__metadata("design:type", String)
|
|
268
|
-
], DualDatepickerComponent.prototype, "inputPadding", void 0);
|
|
269
|
-
__decorate([
|
|
270
|
-
(0, core_1.Output)(),
|
|
271
|
-
__metadata("design:type", Object)
|
|
272
|
-
], DualDatepickerComponent.prototype, "dateRangeChange", void 0);
|
|
273
|
-
__decorate([
|
|
274
|
-
(0, core_1.Output)(),
|
|
275
|
-
__metadata("design:type", Object)
|
|
276
|
-
], DualDatepickerComponent.prototype, "dateRangeSelected", void 0);
|
|
277
|
-
__decorate([
|
|
278
|
-
(0, core_1.HostListener)('document:click', ['$event']),
|
|
279
|
-
__metadata("design:type", Function),
|
|
280
|
-
__metadata("design:paramtypes", [MouseEvent]),
|
|
281
|
-
__metadata("design:returntype", void 0)
|
|
282
|
-
], DualDatepickerComponent.prototype, "onClickOutside", null);
|
|
283
|
-
exports.DualDatepickerComponent = DualDatepickerComponent = __decorate([
|
|
284
|
-
(0, core_1.Component)({
|
|
285
|
-
selector: 'ngx-dual-datepicker',
|
|
286
|
-
standalone: true,
|
|
287
|
-
imports: [common_1.CommonModule, forms_1.FormsModule],
|
|
288
|
-
templateUrl: './dual-datepicker.component.html',
|
|
289
|
-
styleUrl: './dual-datepicker.component.scss'
|
|
290
|
-
}),
|
|
291
|
-
__metadata("design:paramtypes", [core_1.ElementRef])
|
|
292
|
-
], DualDatepickerComponent);
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
// Dual Datepicker Component Styles
|
|
2
|
-
.datepicker-wrapper {
|
|
3
|
-
position: relative;
|
|
4
|
-
width: 100%;
|
|
5
|
-
|
|
6
|
-
.datepicker-input {
|
|
7
|
-
display: block;
|
|
8
|
-
width: 100%;
|
|
9
|
-
padding: 0.375rem 0.75rem;
|
|
10
|
-
font-size: 1rem;
|
|
11
|
-
font-weight: 400;
|
|
12
|
-
line-height: 1.5;
|
|
13
|
-
color: #495057;
|
|
14
|
-
background-color: #fff;
|
|
15
|
-
background-clip: padding-box;
|
|
16
|
-
border: 1px solid #ced4da;
|
|
17
|
-
border-radius: 0.25rem;
|
|
18
|
-
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
|
|
21
|
-
&:hover {
|
|
22
|
-
border-color: var(--input-border-hover, #ced4da);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&:focus {
|
|
26
|
-
border-color: var(--input-border-focus, #80bdff);
|
|
27
|
-
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
|
28
|
-
outline: 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&::placeholder {
|
|
32
|
-
color: #6c757d;
|
|
33
|
-
opacity: 1;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&:disabled,
|
|
37
|
-
&[readonly] {
|
|
38
|
-
background-color: #e9ecef;
|
|
39
|
-
opacity: 1;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.date-picker-dropdown {
|
|
45
|
-
position: absolute;
|
|
46
|
-
top: 100%;
|
|
47
|
-
left: 0;
|
|
48
|
-
margin-top: 4px;
|
|
49
|
-
background: white;
|
|
50
|
-
border: 1px solid #e1e4e8;
|
|
51
|
-
border-radius: 8px;
|
|
52
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.08);
|
|
53
|
-
padding: 16px;
|
|
54
|
-
z-index: 1060;
|
|
55
|
-
min-width: 680px;
|
|
56
|
-
|
|
57
|
-
@media (max-width: 768px) {
|
|
58
|
-
min-width: 100%;
|
|
59
|
-
left: 0;
|
|
60
|
-
right: 0;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.date-picker-header-only-close {
|
|
65
|
-
display: flex;
|
|
66
|
-
justify-content: flex-end;
|
|
67
|
-
margin-bottom: 12px;
|
|
68
|
-
|
|
69
|
-
.btn-close-calendar {
|
|
70
|
-
background-color: transparent;
|
|
71
|
-
border: 1px solid transparent;
|
|
72
|
-
color: #6b7280;
|
|
73
|
-
padding: 6px 10px;
|
|
74
|
-
border-radius: 6px;
|
|
75
|
-
cursor: pointer;
|
|
76
|
-
transition: all 0.15s ease;
|
|
77
|
-
font-size: 1.5rem;
|
|
78
|
-
line-height: 1;
|
|
79
|
-
|
|
80
|
-
&:hover {
|
|
81
|
-
background-color: #fee;
|
|
82
|
-
border-color: #fcc;
|
|
83
|
-
color: #dc2626;
|
|
84
|
-
transform: translateY(-1px);
|
|
85
|
-
box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
&:active {
|
|
89
|
-
transform: translateY(0);
|
|
90
|
-
box-shadow: none;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.date-picker-presets {
|
|
96
|
-
display: flex;
|
|
97
|
-
gap: 6px;
|
|
98
|
-
margin-bottom: 16px;
|
|
99
|
-
padding-bottom: 12px;
|
|
100
|
-
border-bottom: 1px solid #e5e7eb;
|
|
101
|
-
align-items: center;
|
|
102
|
-
|
|
103
|
-
@media (max-width: 768px) {
|
|
104
|
-
flex-wrap: wrap;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
button {
|
|
108
|
-
font-size: 0.75rem;
|
|
109
|
-
padding: 6px 14px;
|
|
110
|
-
border: none;
|
|
111
|
-
background-color: #f9fafb;
|
|
112
|
-
color: #374151;
|
|
113
|
-
border-radius: 6px;
|
|
114
|
-
transition: all 0.15s ease;
|
|
115
|
-
font-weight: 500;
|
|
116
|
-
cursor: pointer;
|
|
117
|
-
border: 1px solid #e5e7eb;
|
|
118
|
-
|
|
119
|
-
&:hover {
|
|
120
|
-
background-color: #f3f4f6;
|
|
121
|
-
border-color: #d1d5db;
|
|
122
|
-
transform: translateY(-1px);
|
|
123
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
&:active {
|
|
127
|
-
transform: translateY(0);
|
|
128
|
-
box-shadow: none;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.btn-close-calendar {
|
|
133
|
-
margin-left: auto;
|
|
134
|
-
background-color: transparent;
|
|
135
|
-
border: 1px solid transparent;
|
|
136
|
-
color: #6b7280;
|
|
137
|
-
padding: 6px 10px;
|
|
138
|
-
font-size: 1.5rem;
|
|
139
|
-
line-height: 1;
|
|
140
|
-
|
|
141
|
-
&:hover {
|
|
142
|
-
background-color: #fee;
|
|
143
|
-
border-color: #fcc;
|
|
144
|
-
color: #dc2626;
|
|
145
|
-
transform: translateY(-1px);
|
|
146
|
-
box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
&:active {
|
|
150
|
-
transform: translateY(0);
|
|
151
|
-
box-shadow: none;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.date-picker-calendars {
|
|
157
|
-
display: flex;
|
|
158
|
-
gap: 32px;
|
|
159
|
-
|
|
160
|
-
@media (max-width: 768px) {
|
|
161
|
-
flex-direction: column;
|
|
162
|
-
gap: 16px;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.date-picker-calendar {
|
|
167
|
-
flex: 1;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.date-picker-header {
|
|
171
|
-
display: flex;
|
|
172
|
-
justify-content: space-between;
|
|
173
|
-
align-items: center;
|
|
174
|
-
margin-bottom: 12px;
|
|
175
|
-
padding: 0 4px;
|
|
176
|
-
|
|
177
|
-
span {
|
|
178
|
-
font-size: 0.813rem;
|
|
179
|
-
font-weight: 600;
|
|
180
|
-
color: #111827;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
button {
|
|
184
|
-
padding: 4px;
|
|
185
|
-
color: #6b7280;
|
|
186
|
-
text-decoration: none;
|
|
187
|
-
border-radius: 6px;
|
|
188
|
-
transition: all 0.15s ease;
|
|
189
|
-
border: none;
|
|
190
|
-
background: transparent;
|
|
191
|
-
cursor: pointer;
|
|
192
|
-
|
|
193
|
-
&:hover {
|
|
194
|
-
background-color: #f3f4f6;
|
|
195
|
-
color: #111827;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.date-picker-weekdays {
|
|
201
|
-
display: grid;
|
|
202
|
-
grid-template-columns: repeat(7, 1fr);
|
|
203
|
-
gap: 2px;
|
|
204
|
-
margin-bottom: 4px;
|
|
205
|
-
|
|
206
|
-
span {
|
|
207
|
-
text-align: center;
|
|
208
|
-
font-size: 0.625rem;
|
|
209
|
-
font-weight: 600;
|
|
210
|
-
color: #6b7280;
|
|
211
|
-
padding: 6px;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.date-picker-days {
|
|
216
|
-
display: grid;
|
|
217
|
-
grid-template-columns: repeat(7, 1fr);
|
|
218
|
-
gap: 2px;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.date-picker-day {
|
|
222
|
-
aspect-ratio: 1;
|
|
223
|
-
border: none;
|
|
224
|
-
background: transparent;
|
|
225
|
-
border-radius: 50%;
|
|
226
|
-
font-size: 0.75rem;
|
|
227
|
-
cursor: pointer;
|
|
228
|
-
transition: all 0.15s ease;
|
|
229
|
-
color: #374151;
|
|
230
|
-
font-weight: 400;
|
|
231
|
-
|
|
232
|
-
&:hover:not(:disabled):not(.selected) {
|
|
233
|
-
background-color: #f3f4f6;
|
|
234
|
-
color: #111827;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
&.empty {
|
|
238
|
-
visibility: hidden;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
&.selected {
|
|
242
|
-
background-color: #222;
|
|
243
|
-
color: white;
|
|
244
|
-
font-weight: 600;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
&.in-range {
|
|
248
|
-
background-color: #f9fafb;
|
|
249
|
-
border-radius: 0;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
&:disabled {
|
|
253
|
-
cursor: not-allowed;
|
|
254
|
-
opacity: 0.3;
|
|
255
|
-
}
|
|
256
|
-
}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/index.esm.js
DELETED
package/dist/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Public API Surface of @oneluiz/dual-datepicker
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DualDatepickerComponent = void 0;
|
|
7
|
-
var dual_datepicker_component_1 = require("./dual-datepicker.component");
|
|
8
|
-
Object.defineProperty(exports, "DualDatepickerComponent", { enumerable: true, get: function () { return dual_datepicker_component_1.DualDatepickerComponent; } });
|