@ngx-mce/datetime-picker 21.1.0 → 21.2.0-next.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/README.md CHANGED
@@ -1,236 +1,240 @@
1
- # Angular Material DatetimePicker, Timepicker for @angular/material 7.x, 8.x, 9.x, 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x, 18.x, 19.x, 20.x
2
-
3
- [![Build Status](https://travis-ci.com/h2qutc/angular-material-components.svg?branch=master)](https://travis-ci.com/h2qutc/angular-material-components)
4
- [![License](https://img.shields.io/npm/l/angular-material-components.svg)](https://www.npmjs.com/package/angular-material-components)
5
- [![npm version](https://badge.fury.io/js/%40angular-material-components%2Fdatetime-picker.svg)](https://www.npmjs.com/package/@ngx-mce/datetime-picker)
6
- [![Github All Releases](https://img.shields.io/npm/dt/@ngx-mce/datetime-picker.svg)]()
7
-
8
- ## Description
9
-
10
- A DatetimePicker like @angular/material
11
- [Datepicker](https://material.angular.io/components/datepicker/overview) by adding support for
12
- choosing time.
13
-
14
- <a href="https://buymeacoffee.com/fbf.prog64" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
15
-
16
- ## DEMO
17
-
18
- @see [LIVE DEMO AND DOCUMENTATION](https://h2qutc.github.io/angular-material-components/)
19
-
20
- @see [DEMO stackblitz](https://stackblitz.com/edit/demo-ngx-mat-datetime-picker)
21
-
22
- ![Alt Text](demo_datetime_picker.png)
23
-
24
- Choose the version corresponding to your Angular version:
25
-
26
- | Angular | @ngx-mce/datetime-picker |
27
- | ------- | ------------------------------- |
28
- | 20 | 20.x+ |
29
- | 19 | 19.x+ |
30
- | 18 | 18.x+ |
31
- | 16 | 16.x+ |
32
- | 15 | 15.x+ OR 9.x+ for legacy import |
33
- | 14 | 8.x+ |
34
- | 13 | 7.x+ |
35
- | 12 | 6.x+ |
36
- | 11 | 5.x+ |
37
- | 10 | 4.x+ |
38
- | 9 | 2.x+ |
39
- | 8 | 2.x+ |
40
- | 7 | 2.x+ |
41
-
42
- ## Getting started
43
-
44
- ```
45
- npm install --save @ngx-mce/datetime-picker
46
- ```
47
-
48
- ## Setup
49
-
50
- Add the date provider to your app configuration.
51
-
52
- [!IMPORTANT] to prevent the \_ERROR Error: NgxMatDatetimePicker: No provider found for DateAdapter.
53
- You must import one of the following providers at your application root or standalone component:
54
- provideNativeDateAdapter, provideMomentDateAdapter, provideLuxonDateAdapter, provideDateFnsAdapter,
55
- or provide a custom implementation.
56
-
57
- ```typescript
58
- import { provideNativeDateAdapter } from '@angular/material/core';
59
-
60
- export const appConfig: ApplicationConfig = {
61
- providers: [
62
- ...,
63
- provideNativeDateAdapter(),
64
- ...,
65
- ],
66
- };
67
- ```
68
-
69
- On your component, you can use the datepicker as follows:
70
-
71
- ```typescript
72
- import {
73
- NgxMatDatepickerActions,
74
- NgxMatDatepickerApply,
75
- NgxMatDatepickerCancel,
76
- NgxMatDatepickerClear,
77
- NgxMatDatepickerInput,
78
- NgxMatDatetimepicker,
79
- } from '@ngx-mce/datetime-picker';
80
-
81
- @Component({
82
- selector: 'test',
83
- imports: [
84
- NgxMatDatepickerActions,
85
- NgxMatDatepickerActions,
86
- NgxMatDatepickerApply,
87
- NgxMatDatepickerCancel,
88
- NgxMatDatepickerClear,
89
- NgxMatDatepickerInput,
90
- NgxMatDatetimepicker,
91
- ..., // other imports
92
- ],
93
- template: `
94
- <input matInput [ngxMatDatetimePicker]="event" class="hidden" />
95
-
96
- <ngx-mat-datetime-picker #event>
97
- <ngx-mat-datepicker-actions>
98
- <div class="flex w-full justify-between">
99
- <button mat-button ngxMatDatepickerClear>Clear</button>
100
- <div>
101
- <button mat-button ngxMatDatepickerCancel>Cancel</button>
102
- <button mat-raised-button color="primary" ngxMatDatepickerApply>Apply</button>
103
- </div>
104
- </div>
105
- </ngx-mat-datepicker-actions>
106
- </ngx-mat-datetime-picker>
107
- `,
108
- })
109
- export class TestComponent {}
110
- ```
111
-
112
- @see [src/app/demo-datetime/demo-datetime.module.ts](src/app/demo-datetime/demo-datetime.module.ts)
113
-
114
- ## Using the component The same API as @angular/material Datepicker (@see [API
115
-
116
- docs](https://material.angular.io/components/datepicker/api)) ### Datetime Picker
117
- (ngx-mat-datetime-picker)
118
-
119
- ```html
120
- <mat-form-field>
121
- <input
122
- matInput
123
- [ngxMatDatetimePicker]="picker"
124
- placeholder="Choose a date"
125
- [formControl]="dateControl"
126
- [min]="minDate"
127
- [max]="maxDate"
128
- [disabled]="disabled" />
129
- <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
130
- <ngx-mat-datetime-picker
131
- #picker
132
- [showSpinners]="showSpinners"
133
- [showSeconds]="showSeconds"
134
- [stepHour]="stepHour"
135
- [stepMinute]="stepMinute"
136
- [stepSecond]="stepSecond"
137
- [touchUi]="touchUi"
138
- [color]="color"
139
- [enableMeridian]="enableMeridian"
140
- [disableMinute]="disableMinute"
141
- [hideTime]="hideTime">
142
- </ngx-mat-datetime-picker>
143
- </mat-form-field>
144
- ```
145
-
146
- ### Timepicker (ngx-mat-timepicker)
147
-
148
- ```
149
- <ngx-mat-timepicker [(ngModel)]="date"></ngx-mat-timepicker>
150
- <ngx-mat-timepicker [(ngModel)]="date" [disabled]="disabled"></ngx-mat-timepicker>
151
- <ngx-mat-timepicker [(ngModel)]="date" [stepHour]="2" [stepMinute]="5" [stepSecond]="10"></ngx-mat-timepicker>
152
- <ngx-mat-timepicker [(ngModel)]="date" [showSpinners]="showSpinners"></ngx-mat-timepicker>
153
- <ngx-mat-timepicker [(ngModel)]="date" [showSeconds]="showSeconds"></ngx-mat-timepicker>
154
- <ngx-mat-timepicker [(ngModel)]="date" [disableMinute]="disableMinute"></ngx-mat-timepicker>
155
- <ngx-mat-timepicker [(ngModel)]="date" [defaultTime]="defaultTime"></ngx-mat-timepicker>
156
- <ngx-mat-timepicker [formControl]="formControl"></ngx-mat-timepicker>
157
- ```
158
-
159
- #### List of @Input of ngx-mat-timepicker
160
-
161
- _You can use all @Input of ngx-mat-timepicker for ngx-mat-datetime-picker_
162
-
163
- | @Input | Type | Default value | Description |
164
- | ------------------ | ------------ | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
165
- | **disabled** | boolean | null | If true, the picker is readonly and can't be modified |
166
- | **showSpinners** | boolean | true | If true, the spinners above and below input are visible |
167
- | **showSeconds** | boolean | true | If true, it is not possible to select seconds |
168
- | **disableMinute** | boolean | false | If true, the minute (and second) is readonly |
169
- | **defaultTime** | Array | undefined | An array [hour, minute, second] for default time when the date is not yet defined |
170
- | **stepHour** | number | 1 | The number of hours to add/substract when clicking hour spinners |
171
- | **stepMinute** | number | 1 | The number of minutes to add/substract when clicking minute spinners |
172
- | **stepSecond** | number | 1 | The number of seconds to add/substract when clicking second spinners |
173
- | **color** | ThemePalette | undefined | Color palette to use on the datepicker's calendar. |
174
- | **enableMeridian** | boolean | false | Whether to display 12H or 24H mode. |
175
- | **hideTime** | boolean | false | If true, the time is hidden. |
176
- | **touchUi** | boolean | false | Whether the calendar UI is in touch mode. In touch mode the calendar opens in a dialog rather than a popup and elements have more padding to allow for bigger touch targets. |
177
-
178
- ## Choosing a date implementation and date format settings
179
-
180
- [NativeDateAdapter](https://github.com/angular/components/blob/main/src/material/core/datetime/index.ts)
181
- [DateFnsAdapter](https://github.com/angular/components/blob/main/src/material-date-fns-adapter/adapter/index.ts)
182
- [LuxonDateAdapter](https://github.com/angular/components/blob/main/src/material-luxon-adapter/adapter/index.ts)
183
- [MomentDateAdapter](https://github.com/angular/components/blob/main/src/material-moment-adapter/adapter/index.ts)
184
-
185
- For example:
186
-
187
- Creating a custom date adapter:
188
-
189
- ```
190
- @Injectable()
191
- export class CustomDateAdapter extends DateAdapter<D> {...}
192
- // D can be Date, Moment or customized type
193
- ```
194
-
195
- ```
196
- // If using Moment
197
- const CUSTOM_DATE_FORMATS: MatDateFormats = {
198
- parse: {
199
- dateInput: "l, LTS"
200
- },
201
- display: {
202
- dateInput: "l, LTS",
203
- monthYearLabel: "MMM YYYY",
204
- dateA11yLabel: "LL",
205
- monthYearA11yLabel: "MMMM YYYY"
206
- }
207
- };
208
- ```
209
-
210
- Creating a custom date adapter module
211
-
212
- ```
213
- export function provideNgxMatCustomDate() {
214
- return makeEnvironmentProviders([
215
- { provide: DateAdapter, useClass: CustomDateAdapter, deps: [MAT_DATE_LOCALE] },
216
- { provide: MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS },
217
- ]);
218
- }
219
-
220
- ```
221
-
222
- You can also customize the date format by providing your custom MAT_DATE_FORMATS in your module.
223
-
224
- ## Theming
225
-
226
- - @see @angular/material
227
- [Using a pre-built theme](https://material.angular.io/guide/theming#using-a-pre-built-theme)
228
- - Add the Material Design icon font to your index.html
229
-
230
- ```
231
- <link href="https://fonts.googleapis.com/icon?family=Material+Icons&display=block" rel="stylesheet">
232
- ```
233
-
234
- ## License
235
-
236
- MIT
1
+ # Angular Material DatetimePicker and Timepicker
2
+ ## For Angular Material 21.x
3
+
4
+ [![License](https://img.shields.io/npm/l/angular-material-components.svg)](https://www.npmjs.com/package/@ngx-mce/datetime-picker)
5
+ [![npm version](https://badge.fury.io/js/%40angular-material-components%2Fdatetime-picker.svg)](https://www.npmjs.com/package/@ngx-mce/datetime-picker)
6
+ [![Github All Releases](https://img.shields.io/npm/dt/@ngx-mce/datetime-picker.svg)]()
7
+
8
+ ## Description
9
+
10
+ These are Date and Time pickers for Angular Material projects. Specifically, this extends the @angular/material
11
+ [Datepicker](https://material.angular.io/components/datepicker/overview) to support choosing time.
12
+
13
+ <a href="https://buymeacoffee.com/fbf.prog64" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
14
+
15
+ # Version control
16
+
17
+ Choose the version corresponding to your Angular version:
18
+
19
+ | Angular | @ngx-mce/datetime-picker |
20
+ | -------- | -------------------------|
21
+ | 21 | 21.x |
22
+ | 15 -- 20 | Please use [GNURub's version](https://github.com/GNURub/angular-material-components) |
23
+ | 7 -- 14 | Please use [h2qutc's version](https://github.com/h2qutc/angular-material-components) |
24
+
25
+ # Date and Time pickers in action
26
+
27
+ See demo:
28
+
29
+ * Over [StackBlitz](https://stackblitz.com/edit/demo-ngx-mat-datetime-picker).
30
+ * In the [documentation](https://fbf-prog64.github.io/angular-material-components/).
31
+
32
+ ![DateTimePicker in action](demo_datetime_picker.png)
33
+
34
+ # How to use
35
+
36
+ ## Install
37
+
38
+ ```
39
+ npm install --save @ngx-mce/datetime-picker
40
+ ```
41
+
42
+ ## Configure
43
+
44
+ Add the date provider of your choice to your app configuration, either in your application root or in your standalone component.
45
+
46
+ The following providers are available:
47
+
48
+ * `provideNativeDateAdapter`, based on native JS.
49
+ * `provideMomentDateAdapter`, based on Moment.js.
50
+ * `provideLuxonDateAdapter`, based on Luxon.
51
+ * `provideDateFnsAdapter`, based on date.fns.
52
+ * You may also provide a custom implementation.
53
+
54
+ This step is important to prevent the following error:
55
+
56
+ ```
57
+ Error: NgxMatDatetimePicker: No provider found for DateAdapter.
58
+ ```
59
+
60
+ ```typescript
61
+ import { provideNativeDateAdapter } from '@angular/material/core';
62
+
63
+ export const appConfig: ApplicationConfig = {
64
+ providers: [
65
+ ...,
66
+ provideNativeDateAdapter(),
67
+ ...,
68
+ ],
69
+ };
70
+ ```
71
+
72
+ ## Using the component
73
+
74
+ On your component, you can use the datepicker as follows:
75
+
76
+ ```typescript
77
+ import {
78
+ NgxMatDatepickerActions,
79
+ NgxMatDatepickerApply,
80
+ NgxMatDatepickerCancel,
81
+ NgxMatDatepickerClear,
82
+ NgxMatDatepickerInput,
83
+ NgxMatDatetimepicker,
84
+ } from '@ngx-mce/datetime-picker';
85
+
86
+ @Component({
87
+ selector: 'test',
88
+ imports: [
89
+ NgxMatDatepickerActions,
90
+ NgxMatDatepickerActions,
91
+ NgxMatDatepickerApply,
92
+ NgxMatDatepickerCancel,
93
+ NgxMatDatepickerClear,
94
+ NgxMatDatepickerInput,
95
+ NgxMatDatetimepicker,
96
+ ..., // other imports
97
+ ],
98
+ template: `
99
+ <input matInput [ngxMatDatetimePicker]="event" class="hidden" />
100
+
101
+ <ngx-mat-datetime-picker #event>
102
+ <ngx-mat-datepicker-actions>
103
+ <div class="flex w-full justify-between">
104
+ <button mat-button ngxMatDatepickerClear>Clear</button>
105
+ <div>
106
+ <button mat-button ngxMatDatepickerCancel>Cancel</button>
107
+ <button mat-raised-button color="primary" ngxMatDatepickerApply>Apply</button>
108
+ </div>
109
+ </div>
110
+ </ngx-mat-datepicker-actions>
111
+ </ngx-mat-datetime-picker>
112
+ `,
113
+ })
114
+ export class TestComponent {}
115
+ ```
116
+
117
+ Check out the demo source code [here](src/app/demo-datetime/demo-datetime.module.ts).
118
+
119
+ ### Markup
120
+
121
+ The template uses the same API as @angular/material Datepicker (see [API docs](https://material.angular.io/components/datepicker/api))
122
+
123
+ ### Datetime Picker (ngx-mat-datetime-picker)
124
+
125
+ ```html
126
+ <mat-form-field>
127
+ <input
128
+ matInput
129
+ [ngxMatDatetimePicker]="picker"
130
+ placeholder="Choose a date"
131
+ [formControl]="dateControl"
132
+ [min]="minDate"
133
+ [max]="maxDate"
134
+ [disabled]="disabled" />
135
+ <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
136
+ <ngx-mat-datetime-picker
137
+ #picker
138
+ [showSpinners]="showSpinners"
139
+ [showSeconds]="showSeconds"
140
+ [stepHour]="stepHour"
141
+ [stepMinute]="stepMinute"
142
+ [stepSecond]="stepSecond"
143
+ [touchUi]="touchUi"
144
+ [color]="color"
145
+ [enableMeridian]="enableMeridian"
146
+ [disableMinute]="disableMinute"
147
+ [hideTime]="hideTime">
148
+ </ngx-mat-datetime-picker>
149
+ </mat-form-field>
150
+ ```
151
+
152
+ ### Timepicker (ngx-mat-timepicker)
153
+
154
+ ```
155
+ <ngx-mat-timepicker [(ngModel)]="date"></ngx-mat-timepicker>
156
+ <ngx-mat-timepicker [(ngModel)]="date" [disabled]="disabled"></ngx-mat-timepicker>
157
+ <ngx-mat-timepicker [(ngModel)]="date" [stepHour]="2" [stepMinute]="5" [stepSecond]="10"></ngx-mat-timepicker>
158
+ <ngx-mat-timepicker [(ngModel)]="date" [showSpinners]="showSpinners"></ngx-mat-timepicker>
159
+ <ngx-mat-timepicker [(ngModel)]="date" [showSeconds]="showSeconds"></ngx-mat-timepicker>
160
+ <ngx-mat-timepicker [(ngModel)]="date" [disableMinute]="disableMinute"></ngx-mat-timepicker>
161
+ <ngx-mat-timepicker [(ngModel)]="date" [defaultTime]="defaultTime"></ngx-mat-timepicker>
162
+ <ngx-mat-timepicker [formControl]="formControl"></ngx-mat-timepicker>
163
+ ```
164
+
165
+ ## List of @Input of ngx-mat-timepicker
166
+
167
+ _These properties are also available in ngx-mat-datetime-picker._
168
+
169
+ | @Input | Type | Default value | Description |
170
+ | ------------------ | ------------ | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
171
+ | **disabled** | boolean | null | If true, the picker is readonly and can't be modified |
172
+ | **showSpinners** | boolean | true | If true, the spinners above and below input are visible |
173
+ | **showSeconds** | boolean | true | If true, it is not possible to select seconds |
174
+ | **disableMinute** | boolean | false | If true, the minute (and second) is readonly |
175
+ | **defaultTime** | Array | undefined | An array [hour, minute, second] for default time when the date is not yet defined |
176
+ | **stepHour** | number | 1 | The number of hours to add/substract when clicking hour spinners |
177
+ | **stepMinute** | number | 1 | The number of minutes to add/substract when clicking minute spinners |
178
+ | **stepSecond** | number | 1 | The number of seconds to add/substract when clicking second spinners |
179
+ | **color** | ThemePalette | undefined | Color palette to use on the datepicker's calendar. |
180
+ | **enableMeridian** | boolean | false | Whether to display 12H or 24H mode. |
181
+ | **hideTime** | boolean | false | If true, the time is hidden. |
182
+ | **touchUi** | boolean | false | Whether the calendar UI is in touch mode. In touch mode the calendar opens in a dialog rather than a popup and elements have more padding to allow for bigger touch targets. |
183
+
184
+ ## Choosing the best date provider and format settings
185
+
186
+ * [NativeDateAdapter](https://github.com/angular/components/blob/main/src/material/core/datetime/index.ts)
187
+ * [DateFnsAdapter](https://github.com/angular/components/blob/main/src/material-date-fns-adapter/adapter/index.ts)
188
+ * [LuxonDateAdapter](https://github.com/angular/components/blob/main/src/material-luxon-adapter/adapter/index.ts)
189
+ * [MomentDateAdapter](https://github.com/angular/components/blob/main/src/material-moment-adapter/adapter/index.ts)
190
+
191
+ Examples of using a custom adapter are provided below.
192
+
193
+ ```
194
+ @Injectable()
195
+ export class CustomDateAdapter extends DateAdapter<D> {...}
196
+ // D can be Date, Moment or customized type
197
+ ```
198
+
199
+ ```
200
+ // If using Moment
201
+ const CUSTOM_DATE_FORMATS: MatDateFormats = {
202
+ parse: {
203
+ dateInput: "l, LTS"
204
+ },
205
+ display: {
206
+ dateInput: "l, LTS",
207
+ monthYearLabel: "MMM YYYY",
208
+ dateA11yLabel: "LL",
209
+ monthYearA11yLabel: "MMMM YYYY"
210
+ }
211
+ };
212
+ ```
213
+
214
+ Providing the custom adapter in the Module.
215
+
216
+ ```
217
+ export function provideNgxMatCustomDate() {
218
+ return makeEnvironmentProviders([
219
+ { provide: DateAdapter, useClass: CustomDateAdapter, deps: [MAT_DATE_LOCALE] },
220
+ { provide: MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS },
221
+ ]);
222
+ }
223
+
224
+ ```
225
+
226
+ You can also customize the date format by providing your custom `MAT_DATE_FORMATS` in your module.
227
+
228
+ ## Theming
229
+
230
+ - @see @angular/material
231
+ [Using a pre-built theme](https://material.angular.io/guide/theming#using-a-pre-built-theme)
232
+ - Add the Material Design icon font to your index.html
233
+
234
+ ```
235
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons&display=block" rel="stylesheet">
236
+ ```
237
+
238
+ ## License
239
+
240
+ MIT