ngxsmk-datepicker 2.3.1 → 2.4.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.
@@ -1,228 +1,228 @@
1
- # Ionic Framework Integration Guide
2
-
3
- **Last updated:** June 3, 2026 - **Current stable:** v2.3.1
4
-
5
- This guide provides step-by-step instructions for integrating ngxsmk-datepicker with Ionic Angular applications.
6
-
7
- ## Quick Start
8
-
9
- ### 1. Install Dependencies
10
-
11
- ```bash
12
- npm install ngxsmk-datepicker @ionic/angular
13
- ```
14
-
15
- ### 2. Import Ionic Integration Styles
16
-
17
- Add to your `global.scss` or main stylesheet:
18
-
19
- ```scss
20
- @import 'ngxsmk-datepicker/styles/ionic-integration.css';
21
- ```
22
-
23
- Or import directly in your component:
24
-
25
- ```typescript
26
- import 'ngxsmk-datepicker/styles/ionic-integration.css';
27
- ```
28
-
29
- ### 3. Use Inline Mode (Recommended)
30
-
31
- ```typescript
32
- import { Component } from '@angular/core';
33
- import { NgxsmkDatepickerComponent } from 'ngxsmk-datepicker';
34
- import { IonContent, IonItem, IonLabel } from '@ionic/angular/standalone';
35
-
36
- @Component({
37
- selector: 'app-datepicker',
38
- standalone: true,
39
- imports: [NgxsmkDatepickerComponent, IonContent, IonItem, IonLabel],
40
- template: `
41
- <ion-content>
42
- <ion-item>
43
- <ion-label>Select Date</ion-label>
44
- <ngxsmk-datepicker
45
- [inline]="true"
46
- mode="single"
47
- [locale]="'en-US'">
48
- </ngxsmk-datepicker>
49
- </ion-item>
50
- </ion-content>
51
- `
52
- })
53
- export class DatepickerPage {}
54
- ```
55
-
56
- ## Configuration Options
57
-
58
- ### Disable Focus Trap (for Ionic Modals)
59
-
60
- When using datepicker inside `ion-modal`, disable focus trapping to avoid conflicts:
61
-
62
- ```typescript
63
- <ngxsmk-datepicker
64
- [inline]="true"
65
- [disableFocusTrap]="true"
66
- mode="single">
67
- </ngxsmk-datepicker>
68
- ```
69
-
70
- ### Ionic Theme Integration
71
-
72
- The integration styles automatically map Ionic theme variables:
73
-
74
- - `--ion-color-primary` → `--datepicker-primary-color`
75
- - `--ion-background-color` → `--datepicker-background`
76
- - `--ion-text-color` → `--datepicker-text-color`
77
- - `--ion-border-color` → `--datepicker-border-color`
78
-
79
- ## Usage Patterns
80
-
81
- ### Pattern 1: Inline in ion-content (Recommended)
82
-
83
- ```typescript
84
- <ion-content>
85
- <ion-item>
86
- <ion-label>Date</ion-label>
87
- <ngxsmk-datepicker [inline]="true" mode="single"></ngxsmk-datepicker>
88
- </ion-item>
89
- </ion-content>
90
- ```
91
-
92
- **Pros**: No z-index conflicts, no scroll locking issues, works perfectly with Ionic gestures
93
-
94
- ### Pattern 2: Inside ion-modal
95
-
96
- ```typescript
97
- async openDatepickerModal() {
98
- const modal = await this.modalController.create({
99
- component: DatepickerModalPage,
100
- cssClass: 'datepicker-modal'
101
- });
102
- return await modal.present();
103
- }
104
- ```
105
-
106
- ```typescript
107
- // DatepickerModalPage
108
- <ion-header>
109
- <ion-toolbar>
110
- <ion-title>Select Date</ion-title>
111
- </ion-toolbar>
112
- </ion-header>
113
- <ion-content>
114
- <ngxsmk-datepicker
115
- [inline]="true"
116
- [disableFocusTrap]="true"
117
- mode="single">
118
- </ngxsmk-datepicker>
119
- </ion-content>
120
- ```
121
-
122
- **Pros**: Native Ionic modal behavior, handles safe areas automatically
123
-
124
- ### Pattern 3: Inside ion-popover
125
-
126
- ```typescript
127
- async openDatepickerPopover(event: Event) {
128
- const popover = await this.popoverController.create({
129
- component: DatepickerPopoverPage,
130
- event: event,
131
- cssClass: 'datepicker-popover'
132
- });
133
- return await popover.present();
134
- }
135
- ```
136
-
137
- **Note**: Use `[inline]="true"` and `[disableFocusTrap]="true"` inside popovers.
138
-
139
- ## Testing Checklist
140
-
141
- ### iOS Safari
142
- - [ ] Datepicker opens correctly in `ion-content`
143
- - [ ] Datepicker opens correctly in `ion-modal`
144
- - [ ] Safe area insets are respected (notch, home indicator)
145
- - [ ] Keyboard doesn't cover datepicker
146
- - [ ] Swipe gestures work (swipe-to-go-back)
147
- - [ ] Pull-to-refresh works
148
- - [ ] Focus management works correctly
149
- - [ ] No layout shifts when keyboard opens/closes
150
-
151
- ### Android Chrome
152
- - [ ] Datepicker opens correctly in `ion-content`
153
- - [ ] Datepicker opens correctly in `ion-modal`
154
- - [ ] Keyboard doesn't cause layout issues
155
- - [ ] Swipe gestures work
156
- - [ ] Focus management works correctly
157
- - [ ] No double scroll behavior
158
-
159
- ### Ionic Web
160
- - [ ] Datepicker works in browser
161
- - [ ] Z-index conflicts resolved
162
- - [ ] Positioning correct in all scenarios
163
- - [ ] SSR works correctly
164
-
165
- ## Troubleshooting
166
-
167
- ### Issue: Datepicker appears behind ion-modal backdrop
168
-
169
- **Solution**: Use `[inline]="true"` or import `ionic-integration.css`
170
-
171
- ### Issue: Body scroll is locked when datepicker opens
172
-
173
- **Solution**: Import `ionic-integration.css` which disables body scroll lock in Ionic apps
174
-
175
- ### Issue: Touch gestures don't work (swipe-to-go-back)
176
-
177
- **Solution**: Use `[inline]="true"` mode to avoid touch event conflicts
178
-
179
- ### Issue: Datepicker doesn't respect safe areas on iOS
180
-
181
- **Solution**: Safe area insets are automatically added in `ionic-integration.css`
182
-
183
- ### Issue: Focus jumps unexpectedly
184
-
185
- **Solution**: Set `[disableFocusTrap]="true"` when inside Ionic overlays
186
-
187
- ## Capacitor Integration
188
-
189
- For Capacitor apps, handle keyboard events:
190
-
191
- ```typescript
192
- import { Capacitor } from '@capacitor/core';
193
- import { Keyboard } from '@capacitor/keyboard';
194
-
195
- @Component({
196
- // ...
197
- })
198
- export class DatepickerPage {
199
- ngOnInit() {
200
- if (Capacitor.isNativePlatform()) {
201
- Keyboard.addListener('keyboardWillShow', () => {
202
- // Adjust datepicker position if needed
203
- });
204
-
205
- Keyboard.addListener('keyboardWillHide', () => {
206
- // Restore datepicker position
207
- });
208
- }
209
- }
210
- }
211
- ```
212
-
213
- ## Best Practices
214
-
215
- 1. **Always use `[inline]="true"`** in Ionic apps to avoid most compatibility issues
216
- 2. **Import `ionic-integration.css`** for automatic fixes
217
- 3. **Use `[disableFocusTrap]="true"`** inside `ion-modal` and `ion-popover`
218
- 4. **Test on real devices** - iOS and Android behavior differs from browsers
219
- 5. **Use `ion-modal`** for popover-style datepickers instead of native popover mode
220
-
221
- ## Additional Resources
222
-
223
- - [Ionic Overlay System](https://ionicframework.com/docs/utilities/overlays)
224
- - [Ionic Theming](https://ionicframework.com/docs/theming/basics)
225
- - [Capacitor Keyboard Plugin](https://capacitorjs.com/docs/apis/keyboard)
226
-
227
-
228
-
1
+ # Ionic Framework Integration Guide
2
+
3
+ **Last updated:** July 2, 2026 - **Current stable:** v2.4.0
4
+
5
+ This guide provides step-by-step instructions for integrating ngxsmk-datepicker with Ionic Angular applications.
6
+
7
+ ## Quick Start
8
+
9
+ ### 1. Install Dependencies
10
+
11
+ ```bash
12
+ npm install ngxsmk-datepicker @ionic/angular
13
+ ```
14
+
15
+ ### 2. Import Ionic Integration Styles
16
+
17
+ Add to your `global.scss` or main stylesheet:
18
+
19
+ ```scss
20
+ @import 'ngxsmk-datepicker/styles/ionic-integration.css';
21
+ ```
22
+
23
+ Or import directly in your component:
24
+
25
+ ```typescript
26
+ import 'ngxsmk-datepicker/styles/ionic-integration.css';
27
+ ```
28
+
29
+ ### 3. Use Inline Mode (Recommended)
30
+
31
+ ```typescript
32
+ import { Component } from '@angular/core';
33
+ import { NgxsmkDatepickerComponent } from 'ngxsmk-datepicker';
34
+ import { IonContent, IonItem, IonLabel } from '@ionic/angular/standalone';
35
+
36
+ @Component({
37
+ selector: 'app-datepicker',
38
+ standalone: true,
39
+ imports: [NgxsmkDatepickerComponent, IonContent, IonItem, IonLabel],
40
+ template: `
41
+ <ion-content>
42
+ <ion-item>
43
+ <ion-label>Select Date</ion-label>
44
+ <ngxsmk-datepicker
45
+ [inline]="true"
46
+ mode="single"
47
+ [locale]="'en-US'">
48
+ </ngxsmk-datepicker>
49
+ </ion-item>
50
+ </ion-content>
51
+ `
52
+ })
53
+ export class DatepickerPage {}
54
+ ```
55
+
56
+ ## Configuration Options
57
+
58
+ ### Disable Focus Trap (for Ionic Modals)
59
+
60
+ When using datepicker inside `ion-modal`, disable focus trapping to avoid conflicts:
61
+
62
+ ```typescript
63
+ <ngxsmk-datepicker
64
+ [inline]="true"
65
+ [disableFocusTrap]="true"
66
+ mode="single">
67
+ </ngxsmk-datepicker>
68
+ ```
69
+
70
+ ### Ionic Theme Integration
71
+
72
+ The integration styles automatically map Ionic theme variables:
73
+
74
+ - `--ion-color-primary` → `--datepicker-primary-color`
75
+ - `--ion-background-color` → `--datepicker-background`
76
+ - `--ion-text-color` → `--datepicker-text-color`
77
+ - `--ion-border-color` → `--datepicker-border-color`
78
+
79
+ ## Usage Patterns
80
+
81
+ ### Pattern 1: Inline in ion-content (Recommended)
82
+
83
+ ```typescript
84
+ <ion-content>
85
+ <ion-item>
86
+ <ion-label>Date</ion-label>
87
+ <ngxsmk-datepicker [inline]="true" mode="single"></ngxsmk-datepicker>
88
+ </ion-item>
89
+ </ion-content>
90
+ ```
91
+
92
+ **Pros**: No z-index conflicts, no scroll locking issues, works perfectly with Ionic gestures
93
+
94
+ ### Pattern 2: Inside ion-modal
95
+
96
+ ```typescript
97
+ async openDatepickerModal() {
98
+ const modal = await this.modalController.create({
99
+ component: DatepickerModalPage,
100
+ cssClass: 'datepicker-modal'
101
+ });
102
+ return await modal.present();
103
+ }
104
+ ```
105
+
106
+ ```typescript
107
+ // DatepickerModalPage
108
+ <ion-header>
109
+ <ion-toolbar>
110
+ <ion-title>Select Date</ion-title>
111
+ </ion-toolbar>
112
+ </ion-header>
113
+ <ion-content>
114
+ <ngxsmk-datepicker
115
+ [inline]="true"
116
+ [disableFocusTrap]="true"
117
+ mode="single">
118
+ </ngxsmk-datepicker>
119
+ </ion-content>
120
+ ```
121
+
122
+ **Pros**: Native Ionic modal behavior, handles safe areas automatically
123
+
124
+ ### Pattern 3: Inside ion-popover
125
+
126
+ ```typescript
127
+ async openDatepickerPopover(event: Event) {
128
+ const popover = await this.popoverController.create({
129
+ component: DatepickerPopoverPage,
130
+ event: event,
131
+ cssClass: 'datepicker-popover'
132
+ });
133
+ return await popover.present();
134
+ }
135
+ ```
136
+
137
+ **Note**: Use `[inline]="true"` and `[disableFocusTrap]="true"` inside popovers.
138
+
139
+ ## Testing Checklist
140
+
141
+ ### iOS Safari
142
+ - [ ] Datepicker opens correctly in `ion-content`
143
+ - [ ] Datepicker opens correctly in `ion-modal`
144
+ - [ ] Safe area insets are respected (notch, home indicator)
145
+ - [ ] Keyboard doesn't cover datepicker
146
+ - [ ] Swipe gestures work (swipe-to-go-back)
147
+ - [ ] Pull-to-refresh works
148
+ - [ ] Focus management works correctly
149
+ - [ ] No layout shifts when keyboard opens/closes
150
+
151
+ ### Android Chrome
152
+ - [ ] Datepicker opens correctly in `ion-content`
153
+ - [ ] Datepicker opens correctly in `ion-modal`
154
+ - [ ] Keyboard doesn't cause layout issues
155
+ - [ ] Swipe gestures work
156
+ - [ ] Focus management works correctly
157
+ - [ ] No double scroll behavior
158
+
159
+ ### Ionic Web
160
+ - [ ] Datepicker works in browser
161
+ - [ ] Z-index conflicts resolved
162
+ - [ ] Positioning correct in all scenarios
163
+ - [ ] SSR works correctly
164
+
165
+ ## Troubleshooting
166
+
167
+ ### Issue: Datepicker appears behind ion-modal backdrop
168
+
169
+ **Solution**: Use `[inline]="true"` or import `ionic-integration.css`
170
+
171
+ ### Issue: Body scroll is locked when datepicker opens
172
+
173
+ **Solution**: Import `ionic-integration.css` which disables body scroll lock in Ionic apps
174
+
175
+ ### Issue: Touch gestures don't work (swipe-to-go-back)
176
+
177
+ **Solution**: Use `[inline]="true"` mode to avoid touch event conflicts
178
+
179
+ ### Issue: Datepicker doesn't respect safe areas on iOS
180
+
181
+ **Solution**: Safe area insets are automatically added in `ionic-integration.css`
182
+
183
+ ### Issue: Focus jumps unexpectedly
184
+
185
+ **Solution**: Set `[disableFocusTrap]="true"` when inside Ionic overlays
186
+
187
+ ## Capacitor Integration
188
+
189
+ For Capacitor apps, handle keyboard events:
190
+
191
+ ```typescript
192
+ import { Capacitor } from '@capacitor/core';
193
+ import { Keyboard } from '@capacitor/keyboard';
194
+
195
+ @Component({
196
+ // ...
197
+ })
198
+ export class DatepickerPage {
199
+ ngOnInit() {
200
+ if (Capacitor.isNativePlatform()) {
201
+ Keyboard.addListener('keyboardWillShow', () => {
202
+ // Adjust datepicker position if needed
203
+ });
204
+
205
+ Keyboard.addListener('keyboardWillHide', () => {
206
+ // Restore datepicker position
207
+ });
208
+ }
209
+ }
210
+ }
211
+ ```
212
+
213
+ ## Best Practices
214
+
215
+ 1. **Always use `[inline]="true"`** in Ionic apps to avoid most compatibility issues
216
+ 2. **Import `ionic-integration.css`** for automatic fixes
217
+ 3. **Use `[disableFocusTrap]="true"`** inside `ion-modal` and `ion-popover`
218
+ 4. **Test on real devices** - iOS and Android behavior differs from browsers
219
+ 5. **Use `ion-modal`** for popover-style datepickers instead of native popover mode
220
+
221
+ ## Additional Resources
222
+
223
+ - [Ionic Overlay System](https://ionicframework.com/docs/utilities/overlays)
224
+ - [Ionic Theming](https://ionicframework.com/docs/theming/basics)
225
+ - [Capacitor Keyboard Plugin](https://capacitorjs.com/docs/apis/keyboard)
226
+
227
+
228
+