@oneluiz/dual-datepicker 1.0.0
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/LICENSE +21 -0
- package/README.md +277 -0
- package/dist/dual-datepicker.component.d.ts +56 -0
- package/dist/dual-datepicker.component.d.ts.map +1 -0
- package/dist/dual-datepicker.component.html +111 -0
- package/dist/dual-datepicker.component.js +292 -0
- package/dist/dual-datepicker.component.scss +233 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +5 -0
- package/dist/index.js +8 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Luis Cortes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# @oneluiz/dual-datepicker
|
|
2
|
+
|
|
3
|
+
A beautiful, customizable dual-calendar date range picker for Angular 17+. Built as a standalone component with full TypeScript support.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## ✨ Features
|
|
10
|
+
|
|
11
|
+
- 📅 **Dual Calendar Display** - Side-by-side month view for easy range selection
|
|
12
|
+
- 🎨 **Fully Customizable** - Color scheme, padding, and styling
|
|
13
|
+
- ⚡ **Preset Ranges** - Configurable quick-select options
|
|
14
|
+
- 🎯 **Standalone Component** - No module imports required
|
|
15
|
+
- 📱 **Responsive Design** - Works on desktop and mobile
|
|
16
|
+
- 🌐 **TypeScript** - Full type safety
|
|
17
|
+
- ♿ **Accessible** - Keyboard navigation and ARIA labels
|
|
18
|
+
- 🎭 **Flexible Behavior** - Control when the picker closes
|
|
19
|
+
|
|
20
|
+
## 📦 Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @oneluiz/dual-datepicker
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 🚀 Quick Start
|
|
27
|
+
|
|
28
|
+
### 1. Import the Component
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { Component } from '@angular/core';
|
|
32
|
+
import { DualDatepickerComponent, DateRange } from '@oneluiz/dual-datepicker';
|
|
33
|
+
|
|
34
|
+
@Component({
|
|
35
|
+
selector: 'app-root',
|
|
36
|
+
standalone: true,
|
|
37
|
+
imports: [DualDatepickerComponent],
|
|
38
|
+
template: `
|
|
39
|
+
<ngx-dual-datepicker
|
|
40
|
+
[(ngModel)]="dateRange"
|
|
41
|
+
placeholder="Select date range">
|
|
42
|
+
</ngx-dual-datepicker>
|
|
43
|
+
`
|
|
44
|
+
})
|
|
45
|
+
export class AppComponent {
|
|
46
|
+
dateRange: DateRange = { start: null, end: null };
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Use with Forms
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { Component } from '@angular/core';
|
|
54
|
+
import { FormsModule } from '@angular/forms';
|
|
55
|
+
import { DualDatepickerComponent } from '@oneluiz/dual-datepicker';
|
|
56
|
+
|
|
57
|
+
@Component({
|
|
58
|
+
selector: 'app-example',
|
|
59
|
+
standalone: true,
|
|
60
|
+
imports: [FormsModule, DualDatepickerComponent],
|
|
61
|
+
template: `
|
|
62
|
+
<ngx-dual-datepicker
|
|
63
|
+
[(ngModel)]="selectedRange"
|
|
64
|
+
[presets]="customPresets"
|
|
65
|
+
(ngModelChange)="onDateChange($event)">
|
|
66
|
+
</ngx-dual-datepicker>
|
|
67
|
+
`
|
|
68
|
+
})
|
|
69
|
+
export class ExampleComponent {
|
|
70
|
+
selectedRange = { start: null, end: null };
|
|
71
|
+
|
|
72
|
+
customPresets = [
|
|
73
|
+
{ label: 'Last 7 days', daysAgo: 7 },
|
|
74
|
+
{ label: 'Last 30 days', daysAgo: 30 },
|
|
75
|
+
{ label: 'Last 90 days', daysAgo: 90 }
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
onDateChange(range: any) {
|
|
79
|
+
console.log('Date range selected:', range);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 🎨 Customization
|
|
85
|
+
|
|
86
|
+
### Custom Colors (Bootstrap Style)
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
<ngx-dual-datepicker
|
|
90
|
+
[(ngModel)]="dateRange"
|
|
91
|
+
inputBackgroundColor="#ffffff"
|
|
92
|
+
inputTextColor="#495057"
|
|
93
|
+
inputBorderColor="#ced4da"
|
|
94
|
+
inputBorderColorHover="#80bdff"
|
|
95
|
+
inputBorderColorFocus="#80bdff"
|
|
96
|
+
inputPadding="0.375rem 0.75rem">
|
|
97
|
+
</ngx-dual-datepicker>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Custom Colors (GitHub Style)
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
<ngx-dual-datepicker
|
|
104
|
+
[(ngModel)]="dateRange"
|
|
105
|
+
inputBackgroundColor="#f3f4f6"
|
|
106
|
+
inputTextColor="#24292e"
|
|
107
|
+
inputBorderColor="transparent"
|
|
108
|
+
inputBorderColorHover="#d1d5db"
|
|
109
|
+
inputBorderColorFocus="#80bdff"
|
|
110
|
+
inputPadding="6px 10px">
|
|
111
|
+
</ngx-dual-datepicker>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Custom Presets
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
customPresets: PresetConfig[] = [
|
|
118
|
+
{ label: 'Last 15 days', daysAgo: 15 },
|
|
119
|
+
{ label: 'Last 3 months', daysAgo: 90 },
|
|
120
|
+
{ label: 'Last 6 months', daysAgo: 180 },
|
|
121
|
+
{ label: 'Last year', daysAgo: 365 }
|
|
122
|
+
];
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<ngx-dual-datepicker
|
|
127
|
+
[(ngModel)]="dateRange"
|
|
128
|
+
[presets]="customPresets">
|
|
129
|
+
</ngx-dual-datepicker>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## 📖 API Reference
|
|
133
|
+
|
|
134
|
+
### Inputs
|
|
135
|
+
|
|
136
|
+
| Property | Type | Default | Description |
|
|
137
|
+
|----------|------|---------|-------------|
|
|
138
|
+
| `ngModel` | `DateRange` | `{ start: null, end: null }` | Two-way binding for selected date range |
|
|
139
|
+
| `placeholder` | `string` | `'Select date range'` | Input placeholder text |
|
|
140
|
+
| `presets` | `PresetConfig[]` | Default presets | Array of preset configurations |
|
|
141
|
+
| `closeOnSelection` | `boolean` | `false` | Close picker when both dates selected |
|
|
142
|
+
| `closeOnPresetSelection` | `boolean` | `false` | Close picker when preset is clicked |
|
|
143
|
+
| `closeOnClickOutside` | `boolean` | `true` | Close picker when clicking outside |
|
|
144
|
+
| `inputBackgroundColor` | `string` | `'#fff'` | Input background color |
|
|
145
|
+
| `inputTextColor` | `string` | `'#495057'` | Input text color |
|
|
146
|
+
| `inputBorderColor` | `string` | `'#ced4da'` | Input border color |
|
|
147
|
+
| `inputBorderColorHover` | `string` | `'#9ca3af'` | Input border color on hover |
|
|
148
|
+
| `inputBorderColorFocus` | `string` | `'#80bdff'` | Input border color on focus |
|
|
149
|
+
| `inputPadding` | `string` | `'0.375rem 0.75rem'` | Input padding |
|
|
150
|
+
|
|
151
|
+
### Outputs
|
|
152
|
+
|
|
153
|
+
| Event | Type | Description |
|
|
154
|
+
|-------|------|-------------|
|
|
155
|
+
| `ngModelChange` | `EventEmitter<DateRange>` | Emitted when date range changes |
|
|
156
|
+
|
|
157
|
+
### Types
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
interface DateRange {
|
|
161
|
+
start: Date | null;
|
|
162
|
+
end: Date | null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface PresetConfig {
|
|
166
|
+
label: string;
|
|
167
|
+
daysAgo: number;
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Default Presets
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
[
|
|
175
|
+
{ label: 'Last month', daysAgo: 30 },
|
|
176
|
+
{ label: 'Last 6 months', daysAgo: 180 },
|
|
177
|
+
{ label: 'Last year', daysAgo: 365 }
|
|
178
|
+
]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## 🎯 Examples
|
|
182
|
+
|
|
183
|
+
### Minimal Usage
|
|
184
|
+
|
|
185
|
+
```html
|
|
186
|
+
<ngx-dual-datepicker [(ngModel)]="dateRange"></ngx-dual-datepicker>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### With Auto-close
|
|
190
|
+
|
|
191
|
+
```html
|
|
192
|
+
<ngx-dual-datepicker
|
|
193
|
+
[(ngModel)]="dateRange"
|
|
194
|
+
[closeOnSelection]="true"
|
|
195
|
+
[closeOnPresetSelection]="true">
|
|
196
|
+
</ngx-dual-datepicker>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Custom Styling
|
|
200
|
+
|
|
201
|
+
```html
|
|
202
|
+
<ngx-dual-datepicker
|
|
203
|
+
[(ngModel)]="dateRange"
|
|
204
|
+
placeholder="Pick your dates"
|
|
205
|
+
inputBackgroundColor="#fef3c7"
|
|
206
|
+
inputTextColor="#92400e"
|
|
207
|
+
inputBorderColor="#fbbf24"
|
|
208
|
+
inputBorderColorHover="#f59e0b"
|
|
209
|
+
inputBorderColorFocus="#d97706"
|
|
210
|
+
inputPadding="8px 12px">
|
|
211
|
+
</ngx-dual-datepicker>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### With Event Handler
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
@Component({
|
|
218
|
+
selector: 'app-example',
|
|
219
|
+
template: `
|
|
220
|
+
<ngx-dual-datepicker
|
|
221
|
+
[(ngModel)]="dateRange"
|
|
222
|
+
(ngModelChange)="onDateRangeChange($event)">
|
|
223
|
+
</ngx-dual-datepicker>
|
|
224
|
+
|
|
225
|
+
<div *ngIf="dateRange.start && dateRange.end">
|
|
226
|
+
Selected: {{ formatDateRange() }}
|
|
227
|
+
</div>
|
|
228
|
+
`
|
|
229
|
+
})
|
|
230
|
+
export class ExampleComponent {
|
|
231
|
+
dateRange: DateRange = { start: null, end: null };
|
|
232
|
+
|
|
233
|
+
onDateRangeChange(range: DateRange) {
|
|
234
|
+
console.log('Start:', range.start);
|
|
235
|
+
console.log('End:', range.end);
|
|
236
|
+
|
|
237
|
+
if (range.start && range.end) {
|
|
238
|
+
// Both dates selected - do something
|
|
239
|
+
this.fetchData(range.start, range.end);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
formatDateRange(): string {
|
|
244
|
+
if (!this.dateRange.start || !this.dateRange.end) return '';
|
|
245
|
+
return `${this.dateRange.start.toLocaleDateString()} - ${this.dateRange.end.toLocaleDateString()}`;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
fetchData(start: Date, end: Date) {
|
|
249
|
+
// Your API call here
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## 🛠️ Requirements
|
|
255
|
+
|
|
256
|
+
- Angular 17.0.0 or higher
|
|
257
|
+
- Angular 18.0.0 or higher
|
|
258
|
+
|
|
259
|
+
## 📄 License
|
|
260
|
+
|
|
261
|
+
MIT © Luis Cortes
|
|
262
|
+
|
|
263
|
+
## 🤝 Contributing
|
|
264
|
+
|
|
265
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
266
|
+
|
|
267
|
+
## 🐛 Issues
|
|
268
|
+
|
|
269
|
+
Found a bug? Please [open an issue](https://github.com/oneluiz/ng-dual-datepicker/issues).
|
|
270
|
+
|
|
271
|
+
## ⭐ Support
|
|
272
|
+
|
|
273
|
+
If you find this package useful, please give it a star on [GitHub](https://github.com/oneluiz/ng-dual-datepicker)!
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
Made with ❤️ by [Luis Cortes](https://github.com/oneluiz)
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<div class="datepicker-wrapper"
|
|
2
|
+
[style.--input-border-hover]="inputBorderColorHover"
|
|
3
|
+
[style.--input-border-focus]="inputBorderColorFocus">
|
|
4
|
+
<input
|
|
5
|
+
type="text"
|
|
6
|
+
class="form-control 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>
|
|
@@ -0,0 +1,292 @@
|
|
|
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);
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Dual Datepicker Component Styles
|
|
2
|
+
.datepicker-wrapper {
|
|
3
|
+
position: relative;
|
|
4
|
+
width: 100%;
|
|
5
|
+
|
|
6
|
+
.datepicker-input {
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
|
|
9
|
+
&:hover {
|
|
10
|
+
border-color: var(--input-border-hover, #ced4da);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&:focus {
|
|
14
|
+
border-color: var(--input-border-focus, #80bdff);
|
|
15
|
+
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
|
|
16
|
+
outline: 0;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.date-picker-dropdown {
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 100%;
|
|
24
|
+
left: 0;
|
|
25
|
+
margin-top: 4px;
|
|
26
|
+
background: white;
|
|
27
|
+
border: 1px solid #e1e4e8;
|
|
28
|
+
border-radius: 8px;
|
|
29
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.08);
|
|
30
|
+
padding: 16px;
|
|
31
|
+
z-index: 1060;
|
|
32
|
+
min-width: 680px;
|
|
33
|
+
|
|
34
|
+
@media (max-width: 768px) {
|
|
35
|
+
min-width: 100%;
|
|
36
|
+
left: 0;
|
|
37
|
+
right: 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.date-picker-header-only-close {
|
|
42
|
+
display: flex;
|
|
43
|
+
justify-content: flex-end;
|
|
44
|
+
margin-bottom: 12px;
|
|
45
|
+
|
|
46
|
+
.btn-close-calendar {
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
border: 1px solid transparent;
|
|
49
|
+
color: #6b7280;
|
|
50
|
+
padding: 6px 10px;
|
|
51
|
+
border-radius: 6px;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
transition: all 0.15s ease;
|
|
54
|
+
font-size: 1.5rem;
|
|
55
|
+
line-height: 1;
|
|
56
|
+
|
|
57
|
+
&:hover {
|
|
58
|
+
background-color: #fee;
|
|
59
|
+
border-color: #fcc;
|
|
60
|
+
color: #dc2626;
|
|
61
|
+
transform: translateY(-1px);
|
|
62
|
+
box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&:active {
|
|
66
|
+
transform: translateY(0);
|
|
67
|
+
box-shadow: none;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.date-picker-presets {
|
|
73
|
+
display: flex;
|
|
74
|
+
gap: 6px;
|
|
75
|
+
margin-bottom: 16px;
|
|
76
|
+
padding-bottom: 12px;
|
|
77
|
+
border-bottom: 1px solid #e5e7eb;
|
|
78
|
+
align-items: center;
|
|
79
|
+
|
|
80
|
+
@media (max-width: 768px) {
|
|
81
|
+
flex-wrap: wrap;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
button {
|
|
85
|
+
font-size: 0.75rem;
|
|
86
|
+
padding: 6px 14px;
|
|
87
|
+
border: none;
|
|
88
|
+
background-color: #f9fafb;
|
|
89
|
+
color: #374151;
|
|
90
|
+
border-radius: 6px;
|
|
91
|
+
transition: all 0.15s ease;
|
|
92
|
+
font-weight: 500;
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
border: 1px solid #e5e7eb;
|
|
95
|
+
|
|
96
|
+
&:hover {
|
|
97
|
+
background-color: #f3f4f6;
|
|
98
|
+
border-color: #d1d5db;
|
|
99
|
+
transform: translateY(-1px);
|
|
100
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&:active {
|
|
104
|
+
transform: translateY(0);
|
|
105
|
+
box-shadow: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.btn-close-calendar {
|
|
110
|
+
margin-left: auto;
|
|
111
|
+
background-color: transparent;
|
|
112
|
+
border: 1px solid transparent;
|
|
113
|
+
color: #6b7280;
|
|
114
|
+
padding: 6px 10px;
|
|
115
|
+
font-size: 1.5rem;
|
|
116
|
+
line-height: 1;
|
|
117
|
+
|
|
118
|
+
&:hover {
|
|
119
|
+
background-color: #fee;
|
|
120
|
+
border-color: #fcc;
|
|
121
|
+
color: #dc2626;
|
|
122
|
+
transform: translateY(-1px);
|
|
123
|
+
box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&:active {
|
|
127
|
+
transform: translateY(0);
|
|
128
|
+
box-shadow: none;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.date-picker-calendars {
|
|
134
|
+
display: flex;
|
|
135
|
+
gap: 32px;
|
|
136
|
+
|
|
137
|
+
@media (max-width: 768px) {
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
gap: 16px;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.date-picker-calendar {
|
|
144
|
+
flex: 1;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.date-picker-header {
|
|
148
|
+
display: flex;
|
|
149
|
+
justify-content: space-between;
|
|
150
|
+
align-items: center;
|
|
151
|
+
margin-bottom: 12px;
|
|
152
|
+
padding: 0 4px;
|
|
153
|
+
|
|
154
|
+
span {
|
|
155
|
+
font-size: 0.813rem;
|
|
156
|
+
font-weight: 600;
|
|
157
|
+
color: #111827;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
button {
|
|
161
|
+
padding: 4px;
|
|
162
|
+
color: #6b7280;
|
|
163
|
+
text-decoration: none;
|
|
164
|
+
border-radius: 6px;
|
|
165
|
+
transition: all 0.15s ease;
|
|
166
|
+
border: none;
|
|
167
|
+
background: transparent;
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
|
|
170
|
+
&:hover {
|
|
171
|
+
background-color: #f3f4f6;
|
|
172
|
+
color: #111827;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.date-picker-weekdays {
|
|
178
|
+
display: grid;
|
|
179
|
+
grid-template-columns: repeat(7, 1fr);
|
|
180
|
+
gap: 2px;
|
|
181
|
+
margin-bottom: 4px;
|
|
182
|
+
|
|
183
|
+
span {
|
|
184
|
+
text-align: center;
|
|
185
|
+
font-size: 0.625rem;
|
|
186
|
+
font-weight: 600;
|
|
187
|
+
color: #6b7280;
|
|
188
|
+
padding: 6px;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.date-picker-days {
|
|
193
|
+
display: grid;
|
|
194
|
+
grid-template-columns: repeat(7, 1fr);
|
|
195
|
+
gap: 2px;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.date-picker-day {
|
|
199
|
+
aspect-ratio: 1;
|
|
200
|
+
border: none;
|
|
201
|
+
background: transparent;
|
|
202
|
+
border-radius: 50%;
|
|
203
|
+
font-size: 0.75rem;
|
|
204
|
+
cursor: pointer;
|
|
205
|
+
transition: all 0.15s ease;
|
|
206
|
+
color: #374151;
|
|
207
|
+
font-weight: 400;
|
|
208
|
+
|
|
209
|
+
&:hover:not(:disabled):not(.selected) {
|
|
210
|
+
background-color: #f3f4f6;
|
|
211
|
+
color: #111827;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&.empty {
|
|
215
|
+
visibility: hidden;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&.selected {
|
|
219
|
+
background-color: #222;
|
|
220
|
+
color: white;
|
|
221
|
+
font-weight: 600;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
&.in-range {
|
|
225
|
+
background-color: #f9fafb;
|
|
226
|
+
border-radius: 0;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&:disabled {
|
|
230
|
+
cursor: not-allowed;
|
|
231
|
+
opacity: 0.3;
|
|
232
|
+
}
|
|
233
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
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.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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; } });
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oneluiz/dual-datepicker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A customizable dual-calendar date range picker component for Angular 17+",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"datepicker",
|
|
8
|
+
"date-range",
|
|
9
|
+
"calendar",
|
|
10
|
+
"dual-calendar",
|
|
11
|
+
"date-picker",
|
|
12
|
+
"angular-component",
|
|
13
|
+
"standalone",
|
|
14
|
+
"typescript"
|
|
15
|
+
],
|
|
16
|
+
"author": "Luis Cortes",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/oneluiz/ng-dual-datepicker.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/oneluiz/ng-dual-datepicker/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/oneluiz/ng-dual-datepicker#readme",
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@angular/common": "^17.0.0 || ^18.0.0",
|
|
28
|
+
"@angular/core": "^17.0.0 || ^18.0.0",
|
|
29
|
+
"@angular/forms": "^17.0.0 || ^18.0.0"
|
|
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
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"clean": "rm -rf dist",
|
|
48
|
+
"build": "npm run clean && tsc && node create-esm.js",
|
|
49
|
+
"prepare": "npm run build"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@angular/common": "^17.3.12",
|
|
53
|
+
"@angular/core": "^17.3.12",
|
|
54
|
+
"@angular/forms": "^17.3.12",
|
|
55
|
+
"rxjs": "^7.8.2",
|
|
56
|
+
"typescript": "5.2",
|
|
57
|
+
"zone.js": "^0.14.10"
|
|
58
|
+
}
|
|
59
|
+
}
|