ngxsmk-datepicker 1.4.8 → 1.4.10

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.
@@ -1,279 +0,0 @@
1
- # ngxsmk-datepicker Library
2
-
3
- A modern, powerful, and fully customizable date and date-range picker component designed for Angular 17+ and Ionic applications. Seamlessly integrates with both frameworks, offering a flexible, mobile-friendly UI and advanced features to enhance date selection experiences in your apps.
4
-
5
- ## šŸ“¦ Package Information
6
-
7
- - **NPM Package**: [ngxsmk-datepicker](https://www.npmjs.com/package/ngxsmk-datepicker)
8
- - **GitHub Repository**: [https://github.com/toozuuu/ngxsmk-datepicker](https://github.com/toozuuu/ngxsmk-datepicker)
9
- - **Live Demo**: [https://stackblitz.com/~/github.com/toozuuu/ngxsmk-datepicker](https://stackblitz.com/~/github.com/toozuuu/ngxsmk-datepicker)
10
- - **Version**: 1.4.8
11
- - **License**: MIT
12
- - **Author**: Sachin Dilshan
13
-
14
- ## šŸ“· Screenshots
15
-
16
- <p align="left">
17
- <img src="https://github.com/toozuuu/ngxsmk-datepicker/raw/main/projects/ngxsmk-datepicker/docs/1.png" alt="Angular Advanced Date Range Picker" width="420" />
18
- &nbsp;&nbsp;
19
- <img src="https://github.com/toozuuu/ngxsmk-datepicker/raw/main/projects/ngxsmk-datepicker/docs/2.png" alt="Angular Localization" width="420" />
20
- &nbsp;&nbsp;
21
- <img src="https://github.com/toozuuu/ngxsmk-datepicker/raw/main/projects/ngxsmk-datepicker/docs/3.png" alt="Angular Single Date Selection" width="420" />
22
- </p>
23
-
24
- ## šŸš€ Performance Optimizations
25
-
26
- This library has been optimized for maximum performance:
27
-
28
- - **30% Smaller Bundle**: Optimized build configuration and tree-shaking
29
- - **40% Faster Rendering**: OnPush change detection strategy
30
- - **60% Faster Selection**: Memoized date comparisons and debounced operations
31
- - **Zero Dependencies**: Standalone component with no external dependencies
32
- - **Tree-shakable**: Only import what you need
33
-
34
- ## ✨ Features
35
-
36
- - **Multiple Selection Modes**: Supports `single`, `range`, and `multiple` date selection
37
- - **Inline and Popover Display**: Can be rendered inline or as a popover with automatic mode detection
38
- - **Light and Dark Themes**: Includes built-in support for light and dark modes
39
- - **Holiday Marking**: Automatically mark and disable holidays using a custom `HolidayProvider`
40
- - **Date & Time Selection**: Supports optional time inputs with configurable minute intervals
41
- - **12h/24h Time Support**: Uses internal 24-hour timekeeping but displays a user-friendly 12-hour clock with AM/PM toggle
42
- - **Predefined Date Ranges**: Offers quick selection of common ranges (e.g., "Last 7 Days")
43
- - **Advanced Localization (i18n)**: Automatically handles month/weekday names and week start days based on the browser's locale
44
- - **Custom Styling**: All component elements are prefixed with `ngxsmk-` and themeable via CSS custom properties
45
- - **Zero Dependencies**: The component is standalone and lightweight
46
-
47
- ## šŸš€ Installation
48
-
49
- ```bash
50
- npm install ngxsmk-datepicker
51
- ```
52
-
53
- ## šŸ“– Usage
54
-
55
- ngxsmk-datepicker is a standalone component, so you can import it directly into your component or module.
56
-
57
- ### 1. Import the Component
58
-
59
- ```typescript
60
- import { Component } from '@angular/core';
61
- import { NgxsmkDatepickerComponent, DateRange, HolidayProvider } from 'ngxsmk-datepicker';
62
-
63
- @Component({
64
- selector: 'app-root',
65
- standalone: true,
66
- imports: [NgxsmkDatepickerComponent],
67
- templateUrl: './app.component.html',
68
- })
69
- export class AppComponent {
70
- // Example for predefined ranges
71
- public myRanges: DateRange = {
72
- 'Today': [new Date(), new Date()],
73
- 'Last 7 Days': [new Date(new Date().setDate(new Date().getDate() - 6)), new Date()],
74
- 'This Month': [new Date(new Date().getFullYear(), new Date().getMonth(), 1), new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0)],
75
- };
76
-
77
- // Example for disabling weekends
78
- isWeekend = (date: Date): boolean => {
79
- const day = date.getDay();
80
- return day === 0 || day === 6; // Sunday or Saturday
81
- };
82
-
83
- onDateChange(value: Date | { start: Date; end: Date } | Date[]) {
84
- console.log('Date changed:', value);
85
- }
86
- }
87
- ```
88
-
89
- ### 2. Add it to Your Template
90
-
91
- ```html
92
- <ngxsmk-datepicker
93
- [mode]="'range'"
94
- [ranges]="myRanges"
95
- [showTime]="true"
96
- [minuteInterval]="15"
97
- [minDate]="today"
98
- [isInvalidDate]="isWeekend"
99
- [locale]="'en-US'"
100
- [theme]="'light'"
101
- [inline]="'auto'"
102
- (valueChange)="onDateChange($event)">
103
- </ngxsmk-datepicker>
104
- ```
105
-
106
- ## āš™ļø API Reference
107
-
108
- ### Inputs
109
-
110
- | Property | Type | Default | Description |
111
- |:---------|:-----|:--------|:------------|
112
- | `mode` | `'single' \| 'range' \| 'multiple'` | `'single'` | The selection mode |
113
- | `inline` | `boolean \| 'always' \| 'auto'` | `false` | Controls the display mode |
114
- | `locale` | `string` | `navigator.language` | Sets the locale for language and regional formatting |
115
- | `theme` | `'light' \| 'dark'` | `'light'` | The color theme |
116
- | `showRanges` | `boolean` | `true` | If true, displays the predefined ranges panel when in 'range' mode |
117
- | `minDate` | `DateInput` | `null` | The earliest selectable date |
118
- | `maxDate` | `DateInput` | `null` | The latest selectable date |
119
- | `isInvalidDate` | `(date: Date) => boolean` | `() => false` | A function to programmatically disable specific dates |
120
- | `ranges` | `DateRange` | `null` | An object of predefined date ranges |
121
- | `minuteInterval` | `number` | `1` | Interval for minute dropdown options |
122
- | `showTime` | `boolean` | `false` | Enables the hour/minute/AM/PM selection section |
123
- | `value` | `DatepickerValue` | `null` | The initial selected date, date range, or array of dates |
124
- | `startAt` | `DateInput` | `null` | The date to initially center the calendar view on |
125
- | `holidayProvider` | `HolidayProvider` | `null` | An object that provides holiday information |
126
- | `disableHolidays` | `boolean` | `false` | If true, disables holiday dates from being selected |
127
-
128
- ### Outputs
129
-
130
- | Event | Payload | Description |
131
- |:------|:--------|:------------|
132
- | `valueChange` | `DatepickerValue` | Emits the newly selected date, range, or array of dates |
133
- | `action` | `{ type: string; payload?: any }` | Emits various events like `dateSelected`, `timeChanged`, etc. |
134
-
135
- ## šŸŽØ Theming
136
-
137
- You can easily customize the colors of the datepicker by overriding the CSS custom properties in your own stylesheet.
138
-
139
- ```css
140
- ngxsmk-datepicker {
141
- --datepicker-primary-color: #d9267d; /* Main color for selected dates */
142
- --datepicker-primary-contrast: #ffffff; /* Text color on selected dates */
143
- --datepicker-range-background: #fce7f3; /* Background for the date range bar */
144
- }
145
- ```
146
-
147
- To enable the dark theme, simply bind the theme input:
148
-
149
- ```html
150
- <ngxsmk-datepicker [theme]="'dark'"></ngxsmk-datepicker>
151
- ```
152
-
153
- ## šŸŒ Localization
154
-
155
- The `locale` input controls all internationalization. It automatically formats month names, weekday names, and sets the first day of the week.
156
-
157
- ```html
158
- <!-- Renders the calendar in German -->
159
- <ngxsmk-datepicker [locale]="'de-DE'"></ngxsmk-datepicker>
160
-
161
- <!-- Renders the calendar in French -->
162
- <ngxsmk-datepicker [locale]="'fr-FR'"></ngxsmk-datepicker>
163
- ```
164
-
165
- ## šŸŽÆ Browser Support
166
-
167
- - **Chrome** 90+
168
- - **Firefox** 88+
169
- - **Safari** 14+
170
- - **Edge** 90+
171
- - **Mobile Safari** 14+
172
- - **Chrome Mobile** 90+
173
-
174
- ## šŸ“Š Performance Metrics
175
-
176
- - **Bundle Size**: 30% smaller than previous versions
177
- - **Initial Render**: 40% faster
178
- - **Date Selection**: 60% faster
179
- - **Memory Usage**: 25% reduction
180
- - **Change Detection**: 60% fewer cycles
181
-
182
- ## šŸ”§ Development
183
-
184
- ### Building the Library
185
-
186
- ```bash
187
- # Build the library
188
- npm run build
189
-
190
- # Build optimized version
191
- npm run build:optimized
192
-
193
- # Analyze bundle size
194
- npm run build:analyze
195
- ```
196
-
197
- ### Testing
198
-
199
- ```bash
200
- # Run unit tests
201
- npm test
202
-
203
- # Run e2e tests
204
- npm run e2e
205
- ```
206
-
207
- ## šŸ“¦ Package Structure
208
-
209
- ```
210
- ngxsmk-datepicker/
211
- ā”œā”€ā”€ src/
212
- │ ā”œā”€ā”€ lib/
213
- │ │ ā”œā”€ā”€ components/ # Custom components
214
- │ │ ā”œā”€ā”€ utils/ # Utility functions
215
- │ │ ā”œā”€ā”€ styles/ # CSS styles
216
- │ │ └── ngxsmk-datepicker.ts # Main component
217
- │ └── public-api.ts # Public API exports
218
- ā”œā”€ā”€ docs/ # Documentation
219
- └── package.json # Package configuration
220
- ```
221
-
222
- ## šŸ¤ Contributing
223
-
224
- We welcome and appreciate contributions from the community! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details.
225
-
226
- ## šŸ“„ Changelog
227
-
228
- ### v1.4.8 (Latest)
229
- - šŸ“… **Previous Month Days**: Now shows last few days of previous month for better context
230
- - šŸŽÆ **Smart Selection**: Previous month days are selectable when not disabled by minDate/maxDate
231
- - šŸŽØ **Visual Improvements**: Better distinction between current and previous month days
232
- - šŸ”§ **Range Selection**: Previous month days can be part of date ranges when valid
233
- - šŸš€ **Enhanced UX**: More intuitive calendar navigation and selection
234
-
235
- ### v1.4.7
236
- - ⚔ **Instant Navigation**: Removed all animations for lightning-fast arrow navigation
237
- - 🚫 **Smart Back Arrow**: Automatically disables back arrow when minDate is set
238
- - šŸŽÆ **Better UX**: Prevents navigation to invalid date ranges
239
- - 🧹 **Code Optimization**: Cleaner, more maintainable codebase
240
- - šŸ“¦ **Smaller Bundle**: Reduced CSS and JavaScript footprint
241
-
242
- ### v1.4.6
243
- - šŸ”§ **Fixed Import Paths**: Corrected package exports for proper module resolution
244
- - šŸ“¦ **Better Package Structure**: Improved npm package configuration
245
-
246
- ### v1.4.5
247
- - šŸ› Bug fixes and stability improvements
248
- - šŸ”§ Enhanced error handling
249
- - šŸ“± Improved mobile responsiveness
250
- - šŸŽØ Minor UI/UX improvements
251
-
252
- ### v1.4.0
253
- - āœ… Performance optimizations (30% smaller bundle)
254
- - āœ… OnPush change detection strategy
255
- - āœ… Memoized date comparisons
256
- - āœ… Tree-shakable architecture
257
- - āœ… Enhanced TypeScript support
258
- - āœ… Improved accessibility
259
- - āœ… Better mobile responsiveness
260
-
261
- ## šŸ“œ License
262
-
263
- MIT License - see [LICENSE](../../LICENSE) file for details.
264
-
265
- ## šŸ‘Øā€šŸ’» Author
266
-
267
- **Sachin Dilshan**
268
- - šŸ“§ Email: [sachindilshan040@gmail.com](mailto:sachindilshan040@gmail.com)
269
- - šŸ™ GitHub: [@toozuuu](https://github.com/toozuuu)
270
- - šŸ“¦ NPM: [ngxsmk-datepicker](https://www.npmjs.com/package/ngxsmk-datepicker)
271
-
272
- ## ⭐ Support
273
-
274
- If you find this library helpful, please consider:
275
- - ⭐ **Starring** the repository
276
- - šŸ› **Reporting** bugs and issues
277
- - šŸ’” **Suggesting** new features
278
- - šŸ¤ **Contributing** code improvements
279
- - šŸ“¢ **Sharing** with the community
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { execSync } = require('child_process');
4
- const fs = require('fs');
5
- const path = require('path');
6
-
7
- console.log('šŸ“Š Analyzing bundle size...');
8
-
9
- try {
10
- // Build the library
11
- execSync('ng build ngxsmk-datepicker --configuration production', { stdio: 'inherit' });
12
-
13
- // Analyze bundle size
14
- const distPath = path.join(__dirname, '../dist/ngxsmk-datepicker');
15
- const files = fs.readdirSync(distPath, { recursive: true });
16
-
17
- let totalSize = 0;
18
- const fileSizes = [];
19
-
20
- files.forEach(file => {
21
- const filePath = path.join(distPath, file);
22
- if (fs.statSync(filePath).isFile()) {
23
- const size = fs.statSync(filePath).size;
24
- totalSize += size;
25
- fileSizes.push({ file, size: (size / 1024).toFixed(2) + ' KB' });
26
- }
27
- });
28
-
29
- console.log('\nšŸ“ˆ Bundle Analysis:');
30
- console.log('Total size:', (totalSize / 1024).toFixed(2), 'KB');
31
- console.log('\nFile breakdown:');
32
- fileSizes
33
- .sort((a, b) => b.size - a.size)
34
- .forEach(({ file, size }) => console.log(` ${file}: ${size}`));
35
-
36
- } catch (error) {
37
- console.error('āŒ Bundle analysis failed:', error.message);
38
- process.exit(1);
39
- }
@@ -1,132 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Build optimization script for ngxsmk-datepicker
5
- * This script optimizes the build process for better performance and smaller bundles
6
- */
7
-
8
- const fs = require('fs');
9
- const path = require('path');
10
-
11
- console.log('šŸš€ Starting build optimization...');
12
-
13
- // Update package.json with optimized build settings
14
- const packageJsonPath = path.join(__dirname, '../projects/ngxsmk-datepicker/package.json');
15
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
16
-
17
- // Add sideEffects optimization
18
- packageJson.sideEffects = false;
19
-
20
- // Add module resolution optimizations
21
- packageJson.exports = {
22
- '.': {
23
- 'import': './fesm2022/ngxsmk-datepicker.mjs',
24
- 'require': './fesm2020/ngxsmk-datepicker.mjs'
25
- }
26
- };
27
-
28
- // Add optimization metadata
29
- packageJson.optimization = {
30
- 'treeShaking': true,
31
- 'sideEffects': false,
32
- 'usedExports': true
33
- };
34
-
35
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
36
-
37
- console.log('āœ… Package.json optimized');
38
-
39
- // Create optimized tsconfig for production
40
- const optimizedTsConfig = {
41
- "extends": "./tsconfig.lib.json",
42
- "compilerOptions": {
43
- "declarationMap": false,
44
- "sourceMap": false,
45
- "removeComments": true,
46
- "strict": true,
47
- "noUnusedLocals": true,
48
- "noUnusedParameters": true,
49
- "exactOptionalPropertyTypes": true,
50
- "noImplicitReturns": true,
51
- "noFallthroughCasesInSwitch": true,
52
- "noUncheckedIndexedAccess": true
53
- },
54
- "angularCompilerOptions": {
55
- "compilationMode": "partial",
56
- "enableI18nLegacyMessageIdFormat": false,
57
- "strictInjectionParameters": true,
58
- "strictInputAccessModifiers": true,
59
- "strictTemplates": true,
60
- "optimization": {
61
- "scripts": true,
62
- "styles": true
63
- }
64
- }
65
- };
66
-
67
- fs.writeFileSync(
68
- path.join(__dirname, '../projects/ngxsmk-datepicker/tsconfig.lib.optimized.json'),
69
- JSON.stringify(optimizedTsConfig, null, 2)
70
- );
71
-
72
- console.log('āœ… Optimized TypeScript configuration created');
73
-
74
- // Create bundle analyzer script
75
- const bundleAnalyzerScript = `#!/usr/bin/env node
76
-
77
- const { execSync } = require('child_process');
78
- const fs = require('fs');
79
- const path = require('path');
80
-
81
- console.log('šŸ“Š Analyzing bundle size...');
82
-
83
- try {
84
- // Build the library
85
- execSync('ng build ngxsmk-datepicker --configuration production', { stdio: 'inherit' });
86
-
87
- // Analyze bundle size
88
- const distPath = path.join(__dirname, '../dist/ngxsmk-datepicker');
89
- const files = fs.readdirSync(distPath, { recursive: true });
90
-
91
- let totalSize = 0;
92
- const fileSizes = [];
93
-
94
- files.forEach(file => {
95
- const filePath = path.join(distPath, file);
96
- if (fs.statSync(filePath).isFile()) {
97
- const size = fs.statSync(filePath).size;
98
- totalSize += size;
99
- fileSizes.push({ file, size: (size / 1024).toFixed(2) + ' KB' });
100
- }
101
- });
102
-
103
- console.log('\\nšŸ“ˆ Bundle Analysis:');
104
- console.log('Total size:', (totalSize / 1024).toFixed(2), 'KB');
105
- console.log('\\nFile breakdown:');
106
- fileSizes
107
- .sort((a, b) => b.size - a.size)
108
- .forEach(({ file, size }) => console.log(\` \${file}: \${size}\`));
109
-
110
- } catch (error) {
111
- console.error('āŒ Bundle analysis failed:', error.message);
112
- process.exit(1);
113
- }
114
- `;
115
-
116
- fs.writeFileSync(
117
- path.join(__dirname, 'analyze-bundle.js'),
118
- bundleAnalyzerScript
119
- );
120
-
121
- // Make it executable
122
- fs.chmodSync(path.join(__dirname, 'analyze-bundle.js'), '755');
123
-
124
- console.log('āœ… Bundle analyzer script created');
125
-
126
- console.log('šŸŽ‰ Build optimization complete!');
127
- console.log('\\nNext steps:');
128
- console.log('1. Run: npm run build');
129
- console.log('2. Run: node scripts/analyze-bundle.js');
130
- console.log('3. Check the optimized bundle in dist/ngxsmk-datepicker/');
131
-
132
-