ngx-datex 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 +320 -0
- package/fesm2022/ngx-datex.mjs +3562 -0
- package/package.json +81 -0
- package/types/ngx-datex.d.ts +2161 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Senguana Wisuma Emilio
|
|
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,320 @@
|
|
|
1
|
+
# NgxDatex - Advanced Angular Date Range Picker
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/ngx-datex)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A feature-rich, accessible date picker component for Angular applications. Built with modern Angular patterns including signals, standalone components, and CDK overlays.
|
|
7
|
+
|
|
8
|
+
## β¨ Features
|
|
9
|
+
|
|
10
|
+
- π
**Single Date & Date Range Selection** - Support for both single dates and date ranges
|
|
11
|
+
- β° **Time Picker Integration** - Optional time selection with 12/24 hour formats
|
|
12
|
+
- π¨ **Customizable Themes** - Built-in themes with full customization support
|
|
13
|
+
- π **Internationalization** - Complete i18n support with multiple locales
|
|
14
|
+
- οΏ½ **Mobile Responsive** - Optimized for mobile devices with touch support
|
|
15
|
+
- βΏ **Accessibility** - WCAG compliant with full keyboard navigation
|
|
16
|
+
- π§ **Extensive Configuration** - Highly configurable with sensible defaults
|
|
17
|
+
- οΏ½ **Forms Integration** - Full Angular Forms support with ControlValueAccessor
|
|
18
|
+
- π **Performance Optimized** - Built with Angular signals for optimal performance
|
|
19
|
+
- π― **TypeScript First** - Written in TypeScript with comprehensive type definitions
|
|
20
|
+
|
|
21
|
+
## π Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install ngx-datex
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## οΏ½ Quick Start
|
|
28
|
+
|
|
29
|
+
### 1. Import the Component
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { NgxDatex } from 'ngx-datex';
|
|
33
|
+
|
|
34
|
+
@Component({
|
|
35
|
+
selector: 'app-example',
|
|
36
|
+
imports: [NgxDatex], // For standalone components
|
|
37
|
+
template: ` <ngx-datex [(ngModel)]="selectedRange" [ranges]="predefinedRanges"> </ngx-datex> `,
|
|
38
|
+
})
|
|
39
|
+
export class ExampleComponent {
|
|
40
|
+
selectedRange: NgxDatexValue | null = null;
|
|
41
|
+
|
|
42
|
+
predefinedRanges = {
|
|
43
|
+
Today: [startOfDay(new Date()), endOfDay(new Date())],
|
|
44
|
+
'Last 7 Days': [startOfDay(subDays(new Date(), 6)), endOfDay(new Date())],
|
|
45
|
+
'Last 30 Days': [startOfDay(subDays(new Date(), 29)), endOfDay(new Date())],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Basic Usage
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<!-- Simple date range picker -->
|
|
54
|
+
<ngx-datex [(ngModel)]="dateRange" placeholder="Select date range"> </ngx-datex>
|
|
55
|
+
|
|
56
|
+
<!-- Single date picker -->
|
|
57
|
+
<ngx-datex [(ngModel)]="singleDate" [singleDatePicker]="true" placeholder="Select date">
|
|
58
|
+
</ngx-datex>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## ποΈ Configuration Options
|
|
62
|
+
|
|
63
|
+
### Input Properties
|
|
64
|
+
|
|
65
|
+
| Property | Type | Default | Description |
|
|
66
|
+
| ------------------ | ------------------------------ | ---------------------- | ------------------------------------------- |
|
|
67
|
+
| `singleDatePicker` | `boolean` | `false` | Enable single date selection mode |
|
|
68
|
+
| `timePicker` | `boolean` | `false` | Enable time selection |
|
|
69
|
+
| `timePicker24Hour` | `boolean` | `true` | Use 24-hour format for time picker |
|
|
70
|
+
| `autoApply` | `boolean` | `false` | Auto-apply selection without confirm button |
|
|
71
|
+
| `showDropdowns` | `boolean` | `false` | Show month/year dropdowns in header |
|
|
72
|
+
| `linkedCalendars` | `boolean` | `true` | Link left and right calendar navigation |
|
|
73
|
+
| `ranges` | `Record<string, [Date, Date]>` | `DEFAULT_RANGES` | Predefined date ranges |
|
|
74
|
+
| `minDate` | `Date \| null` | `null` | Minimum selectable date |
|
|
75
|
+
| `maxDate` | `Date \| null` | `null` | Maximum selectable date |
|
|
76
|
+
| `locale` | `NgxDatexLocale` | `SPANISH_LOCALE` | Localization settings |
|
|
77
|
+
| `theme` | `NgxDatexTheme` | `MATERIAL_LIGHT_THEME` | Theme configuration |
|
|
78
|
+
|
|
79
|
+
### Output Events
|
|
80
|
+
|
|
81
|
+
| Event | Type | Description |
|
|
82
|
+
| ------------- | ------------------------------------------ | ----------------------------------- |
|
|
83
|
+
| `dateChange` | `NgxDatexValue \| null` | Emitted when date selection changes |
|
|
84
|
+
| `rangeChange` | `{startDate: Date, endDate: Date \| null}` | Emitted when range changes |
|
|
85
|
+
| `openEvent` | `void` | Emitted when picker opens |
|
|
86
|
+
| `closeEvent` | `void` | Emitted when picker closes |
|
|
87
|
+
|
|
88
|
+
## π¨ Theming
|
|
89
|
+
|
|
90
|
+
### Using Built-in Themes
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { MATERIAL_LIGHT_THEME } from 'ngx-datex';
|
|
94
|
+
|
|
95
|
+
@Component({
|
|
96
|
+
template: ` <ngx-datex [theme]="materialTheme"></ngx-datex> `,
|
|
97
|
+
})
|
|
98
|
+
export class ThemedComponent {
|
|
99
|
+
materialTheme = MATERIAL_LIGHT_THEME;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Creating Custom Themes
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { NgxDatexTheme } from 'ngx-datex';
|
|
107
|
+
|
|
108
|
+
const customTheme: NgxDatexTheme = {
|
|
109
|
+
name: 'custom-dark',
|
|
110
|
+
colors: {
|
|
111
|
+
primary: '#bb86fc',
|
|
112
|
+
secondary: '#03dac6',
|
|
113
|
+
background: '#121212',
|
|
114
|
+
surface: '#1e1e1e',
|
|
115
|
+
text: '#ffffff',
|
|
116
|
+
// ... other colors
|
|
117
|
+
},
|
|
118
|
+
typography: {
|
|
119
|
+
fontFamily: 'Roboto, sans-serif',
|
|
120
|
+
fontSize: '14px',
|
|
121
|
+
fontWeight: '400',
|
|
122
|
+
lineHeight: '1.5',
|
|
123
|
+
},
|
|
124
|
+
// ... other theme properties
|
|
125
|
+
};
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## π Internationalization
|
|
129
|
+
|
|
130
|
+
### Using Built-in Locales
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { SPANISH_LOCALE } from 'ngx-datex';
|
|
134
|
+
|
|
135
|
+
@Component({
|
|
136
|
+
template: ` <ngx-datex [locale]="spanishLocale"></ngx-datex> `,
|
|
137
|
+
})
|
|
138
|
+
export class LocalizedComponent {
|
|
139
|
+
spanishLocale = SPANISH_LOCALE;
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Creating Custom Locales
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { NgxDatexLocale } from 'ngx-datex';
|
|
147
|
+
|
|
148
|
+
const frenchLocale: NgxDatexLocale = {
|
|
149
|
+
direction: 'ltr',
|
|
150
|
+
format: 'DD/MM/YYYY',
|
|
151
|
+
separator: ' - ',
|
|
152
|
+
applyLabel: 'Appliquer',
|
|
153
|
+
cancelLabel: 'Annuler',
|
|
154
|
+
daysOfWeek: ['Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa', 'Di'],
|
|
155
|
+
monthNames: [
|
|
156
|
+
'Janvier',
|
|
157
|
+
'FΓ©vrier',
|
|
158
|
+
'Mars',
|
|
159
|
+
'Avril',
|
|
160
|
+
'Mai',
|
|
161
|
+
'Juin',
|
|
162
|
+
'Juillet',
|
|
163
|
+
'AoΓ»t',
|
|
164
|
+
'Septembre',
|
|
165
|
+
'Octobre',
|
|
166
|
+
'Novembre',
|
|
167
|
+
'DΓ©cembre',
|
|
168
|
+
],
|
|
169
|
+
firstDay: 1,
|
|
170
|
+
};
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## π± Mobile Support
|
|
174
|
+
|
|
175
|
+
The component automatically adapts to mobile devices with:
|
|
176
|
+
|
|
177
|
+
- Touch-friendly interface
|
|
178
|
+
- Optimized layout for small screens
|
|
179
|
+
- Native-like date selection experience
|
|
180
|
+
- Responsive design patterns
|
|
181
|
+
|
|
182
|
+
## βΏ Accessibility
|
|
183
|
+
|
|
184
|
+
NgxDatex is built with accessibility in mind:
|
|
185
|
+
|
|
186
|
+
- Full keyboard navigation support
|
|
187
|
+
- ARIA labels and descriptions
|
|
188
|
+
- Screen reader compatibility
|
|
189
|
+
- High contrast support
|
|
190
|
+
- Focus management
|
|
191
|
+
|
|
192
|
+
## π§ Advanced Usage
|
|
193
|
+
|
|
194
|
+
### With Reactive Forms
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
|
198
|
+
|
|
199
|
+
@Component({
|
|
200
|
+
imports: [ReactiveFormsModule, NgxDatex],
|
|
201
|
+
template: `
|
|
202
|
+
<form [formGroup]="form">
|
|
203
|
+
<ngx-datex formControlName="dateRange"></ngx-datex>
|
|
204
|
+
</form>
|
|
205
|
+
`,
|
|
206
|
+
})
|
|
207
|
+
export class ReactiveFormComponent {
|
|
208
|
+
form = this.fb.group({
|
|
209
|
+
dateRange: new FormControl<NgxDatexValue | null>(null),
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Custom Date Validation
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
@Component({
|
|
218
|
+
template: `
|
|
219
|
+
<ngx-datex [isInvalidDate]="isWeekend" [minDate]="minDate" [maxDate]="maxDate"> </ngx-datex>
|
|
220
|
+
`,
|
|
221
|
+
})
|
|
222
|
+
export class ValidatedComponent {
|
|
223
|
+
minDate = new Date();
|
|
224
|
+
maxDate = addMonths(new Date(), 6);
|
|
225
|
+
|
|
226
|
+
isWeekend = (date: Date): boolean => {
|
|
227
|
+
const day = date.getDay();
|
|
228
|
+
return day === 0 || day === 6; // Disable weekends
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Time Picker Configuration
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
@Component({
|
|
237
|
+
template: `
|
|
238
|
+
<ngx-datex
|
|
239
|
+
[timePicker]="true"
|
|
240
|
+
[timePicker24Hour]="false"
|
|
241
|
+
[timePickerIncrement]="15"
|
|
242
|
+
[timePickerSeconds]="false"
|
|
243
|
+
>
|
|
244
|
+
</ngx-datex>
|
|
245
|
+
`,
|
|
246
|
+
})
|
|
247
|
+
export class TimePickerComponent {}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## π API Reference
|
|
251
|
+
|
|
252
|
+
### Types
|
|
253
|
+
|
|
254
|
+
#### `NgxDatexValue`
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
interface NgxDatexValue {
|
|
258
|
+
startDate: Date;
|
|
259
|
+
endDate: Date | null;
|
|
260
|
+
label?: string;
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### `NgxDatexLocale`
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
interface NgxDatexLocale {
|
|
268
|
+
direction?: 'ltr' | 'rtl';
|
|
269
|
+
format?: string;
|
|
270
|
+
separator?: string;
|
|
271
|
+
applyLabel?: string;
|
|
272
|
+
cancelLabel?: string;
|
|
273
|
+
daysOfWeek?: string[];
|
|
274
|
+
monthNames?: string[];
|
|
275
|
+
firstDay?: number;
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
#### `NgxDatexTheme`
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
interface NgxDatexTheme {
|
|
283
|
+
name: string;
|
|
284
|
+
colors: {
|
|
285
|
+
/* color definitions */
|
|
286
|
+
};
|
|
287
|
+
typography: {
|
|
288
|
+
/* typography settings */
|
|
289
|
+
};
|
|
290
|
+
spacing: {
|
|
291
|
+
/* spacing scale */
|
|
292
|
+
};
|
|
293
|
+
borderRadius: {
|
|
294
|
+
/* border radius values */
|
|
295
|
+
};
|
|
296
|
+
shadows: {
|
|
297
|
+
/* shadow definitions */
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## π€ Contributing
|
|
303
|
+
|
|
304
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
|
|
305
|
+
|
|
306
|
+
## π License
|
|
307
|
+
|
|
308
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
309
|
+
|
|
310
|
+
## π Acknowledgments
|
|
311
|
+
|
|
312
|
+
- Inspired by the popular [daterangepicker](https://github.com/dangrossman/daterangepicker) library
|
|
313
|
+
- Built with [Angular CDK](https://material.angular.io/cdk) for overlay management
|
|
314
|
+
- Uses [@formkit/tempo](https://github.com/formkit/tempo) for reliable date operations
|
|
315
|
+
|
|
316
|
+
## π Support
|
|
317
|
+
|
|
318
|
+
- π [Documentation](https://ngx-datex.dev)
|
|
319
|
+
- π [Issue Tracker](https://github.com/senguanasoft/ngx-datex/issues)
|
|
320
|
+
- π¬ [Discussions](https://github.com/senguanasoft/ngx-datex/discussions)
|