nxt-pick-datetime 19.0.4 → 21.0.0-alpha.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/README.md +11 -14
- package/assets/picker.scss +23 -23
- package/fesm2022/nxt-pick-datetime-moment-adapter.mjs +19 -27
- package/fesm2022/nxt-pick-datetime-moment-adapter.mjs.map +1 -1
- package/fesm2022/nxt-pick-datetime-native-adapter.mjs +19 -22
- package/fesm2022/nxt-pick-datetime-native-adapter.mjs.map +1 -1
- package/fesm2022/nxt-pick-datetime.mjs +1862 -2637
- package/fesm2022/nxt-pick-datetime.mjs.map +1 -1
- package/package.json +16 -13
- package/types/nxt-pick-datetime-moment-adapter.d.ts +25 -0
- package/types/nxt-pick-datetime-native-adapter.d.ts +13 -0
- package/types/nxt-pick-datetime.d.ts +1200 -0
- package/index.d.ts +0 -5
- package/lib/class/date-time-adapter.class.d.ts +0 -176
- package/lib/class/date-time-format.class.d.ts +0 -12
- package/lib/class/date-time.class.d.ts +0 -76
- package/lib/class/dialog-config.class.d.ts +0 -90
- package/lib/class/dialog-ref.class.d.ts +0 -50
- package/lib/date-time/calendar/calendar.component.d.ts +0 -147
- package/lib/date-time/calendar-body/calendar-body.component.d.ts +0 -79
- package/lib/date-time/calendar-month-view/calendar-month-view.component.d.ts +0 -139
- package/lib/date-time/calendar-multi-year-view/calendar-multi-year-view.component.d.ts +0 -115
- package/lib/date-time/calendar-year-view/calendar-year-view.component.d.ts +0 -123
- package/lib/date-time/date-time-inline/date-time-inline.component.d.ts +0 -106
- package/lib/date-time/date-time-picker/date-time-picker.component.d.ts +0 -172
- package/lib/date-time/date-time-picker-container/date-time-picker-container.animations.d.ts +0 -6
- package/lib/date-time/date-time-picker-container/date-time-picker-container.component.d.ts +0 -129
- package/lib/date-time/date-time-picker-input.directive.d.ts +0 -167
- package/lib/date-time/date-time-picker-intl.service.d.ts +0 -51
- package/lib/date-time/date-time-picker-trigger.directive.d.ts +0 -22
- package/lib/date-time/date-time.module.d.ts +0 -23
- package/lib/date-time/number-fixed-len.pipe.d.ts +0 -8
- package/lib/date-time/timer/timer.component.d.ts +0 -131
- package/lib/date-time/timer-box/timer-box.component.d.ts +0 -37
- package/lib/dialog/dialog-container/dialog-container.component.d.ts +0 -69
- package/lib/dialog/dialog.module.d.ts +0 -12
- package/lib/dialog/dialog.service.d.ts +0 -78
- package/lib/utils/object.d.ts +0 -9
- package/moment-adapter/date-time-adapter.class.d.ts +0 -64
- package/moment-adapter/date-time-format.class.d.ts +0 -5
- package/moment-adapter/index.d.ts +0 -5
- package/moment-adapter/moment-adapter.module.d.ts +0 -8
- package/moment-adapter/public-api.d.ts +0 -2
- package/native-adapter/date-time-adapter.class.d.ts +0 -72
- package/native-adapter/date-time-format.class.d.ts +0 -5
- package/native-adapter/index.d.ts +0 -5
- package/native-adapter/native-adapter.module.d.ts +0 -9
- package/native-adapter/public-api.d.ts +0 -1
- package/public-api.d.ts +0 -14
package/README.md
CHANGED
|
@@ -22,25 +22,22 @@ npm install --save nxt-pick-datetime
|
|
|
22
22
|
npm install --save moment # if you want to use MomentDateTimeModule
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
###
|
|
25
|
+
### Configure DateTime adapter provider
|
|
26
26
|
|
|
27
|
-
The date & time picker was built to be date implementation agnostic. It comes with two
|
|
27
|
+
The date & time picker was built to be date implementation agnostic. It comes with two date adapter implementations, or you can provide your own adapter by implementing `DateTimeAdapter` (see [documentation](https://liquid-js.github.io/nxt-components/demo/pick-datetime/custom-adapter)).
|
|
28
28
|
|
|
29
|
-
- `
|
|
30
|
-
- `
|
|
29
|
+
- `provideNativeDateTimeAdapter` - support for native JavaScript Date object
|
|
30
|
+
- `provideNativeDateTimeAdapter` - support for MomentJs
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
...
|
|
40
|
-
DateTimeModule,
|
|
41
|
-
NativeDateTimeModule
|
|
33
|
+
import { ApplicationConfig } from '@angular/core'
|
|
34
|
+
import { provideNativeDateTimeAdapter } from 'nxt-pick-datetime/native-adapter'
|
|
35
|
+
|
|
36
|
+
export const appConfig: ApplicationConfig = {
|
|
37
|
+
providers: [
|
|
38
|
+
provideNativeDateTimeAdapter()
|
|
42
39
|
]
|
|
43
|
-
}
|
|
40
|
+
}
|
|
44
41
|
```
|
|
45
42
|
|
|
46
43
|
### Use it in a template
|
package/assets/picker.scss
CHANGED
|
@@ -6,7 +6,7 @@ $cdk-z-index-overlay: 1000;
|
|
|
6
6
|
$cdk-z-index-overlay-backdrop: 1000;
|
|
7
7
|
|
|
8
8
|
// Background color for all of the backdrops
|
|
9
|
-
$cdk-overlay-dark-backdrop-background:
|
|
9
|
+
$cdk-overlay-dark-backdrop-background: rgb(0, 0, 0, 0.288);
|
|
10
10
|
|
|
11
11
|
// Default backdrop animation is based on the Material Design swift-ease-out.
|
|
12
12
|
$backdrop-animation-duration: 400ms !default;
|
|
@@ -143,11 +143,11 @@ $backdrop-animation-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1) !default;
|
|
|
143
143
|
box-sizing: border-box;
|
|
144
144
|
display: block;
|
|
145
145
|
padding: 1.5em;
|
|
146
|
-
box-shadow: 0 11px 15px -7px
|
|
146
|
+
box-shadow: 0 11px 15px -7px rgb(0, 0, 0, 0.2), 0 24px 38px 3px rgb(0, 0, 0, 0.14), 0 9px 46px 8px rgb(0, 0, 0, 0.12);
|
|
147
147
|
border-radius: 2px;
|
|
148
148
|
overflow: auto;
|
|
149
149
|
background: #fff;
|
|
150
|
-
color:
|
|
150
|
+
color: rgb(0, 0, 0, 0.87);
|
|
151
151
|
width: 100%;
|
|
152
152
|
height: 100%;
|
|
153
153
|
outline: none;
|
|
@@ -169,7 +169,7 @@ $theme-color: #3f51b5;
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
.nxt-dt-container-row {
|
|
172
|
-
border-bottom: 1px solid
|
|
172
|
+
border-bottom: 1px solid rgb(0, 0, 0, 0.12);
|
|
173
173
|
|
|
174
174
|
&:last-child {
|
|
175
175
|
border-bottom: none;
|
|
@@ -200,7 +200,7 @@ $theme-color: #3f51b5;
|
|
|
200
200
|
padding: 0 0.8em;
|
|
201
201
|
|
|
202
202
|
&:hover {
|
|
203
|
-
background-color:
|
|
203
|
+
background-color: rgb(0, 0, 0, 0.12);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -238,7 +238,7 @@ $theme-color: #3f51b5;
|
|
|
238
238
|
border-spacing: 0;
|
|
239
239
|
|
|
240
240
|
.nxt-dt-calendar-header {
|
|
241
|
-
color:
|
|
241
|
+
color: rgb(0, 0, 0, 0.4);
|
|
242
242
|
|
|
243
243
|
.nxt-dt-weekdays {
|
|
244
244
|
th {
|
|
@@ -261,7 +261,7 @@ $theme-color: #3f51b5;
|
|
|
261
261
|
left: -0.5em;
|
|
262
262
|
right: -0.5em;
|
|
263
263
|
height: 1px;
|
|
264
|
-
background:
|
|
264
|
+
background: rgb(0, 0, 0, 0.12);
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
}
|
|
@@ -272,7 +272,7 @@ $theme-color: #3f51b5;
|
|
|
272
272
|
line-height: 0;
|
|
273
273
|
text-align: center;
|
|
274
274
|
outline: 0;
|
|
275
|
-
color:
|
|
275
|
+
color: rgb(0, 0, 0, 0.85);
|
|
276
276
|
appearance: none;
|
|
277
277
|
}
|
|
278
278
|
|
|
@@ -299,15 +299,15 @@ $theme-color: #3f51b5;
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
.nxt-dt-calendar-cell-today:not(.nxt-dt-calendar-cell-selected) {
|
|
302
|
-
border-color:
|
|
302
|
+
border-color: rgb(0, 0, 0, 0.4);
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
.nxt-dt-calendar-cell-selected {
|
|
306
|
-
color:
|
|
306
|
+
color: hsl(0, 0%, 100%, 0.85);
|
|
307
307
|
background-color: $theme-color;
|
|
308
308
|
|
|
309
309
|
&.nxt-dt-calendar-cell-today {
|
|
310
|
-
box-shadow: inset 0 0 0 1px
|
|
310
|
+
box-shadow: inset 0 0 0 1px hsl(0, 0%, 100%, 0.85);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
|
|
@@ -315,7 +315,7 @@ $theme-color: #3f51b5;
|
|
|
315
315
|
cursor: default;
|
|
316
316
|
|
|
317
317
|
& > .nxt-dt-calendar-cell-content:not(.nxt-dt-calendar-cell-selected) {
|
|
318
|
-
color:
|
|
318
|
+
color: rgb(0, 0, 0, 0.4);
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
& > .nxt-dt-calendar-cell-content.nxt-dt-calendar-cell-selected {
|
|
@@ -323,13 +323,13 @@ $theme-color: #3f51b5;
|
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
& > .nxt-dt-calendar-cell-today:not(.nxt-dt-calendar-cell-selected) {
|
|
326
|
-
border-color:
|
|
326
|
+
border-color: rgb(0, 0, 0, 0.2);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
.nxt-dt-calendar-cell-active:focus > .nxt-dt-calendar-cell-content:not(.nxt-dt-calendar-cell-selected),
|
|
331
331
|
:not(.nxt-dt-calendar-cell-disabled):hover > .nxt-dt-calendar-cell-content:not(.nxt-dt-calendar-cell-selected) {
|
|
332
|
-
background-color:
|
|
332
|
+
background-color: rgb(0, 0, 0, 0.04);
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
.nxt-dt-calendar-cell-in-range {
|
|
@@ -384,7 +384,7 @@ $theme-color: #3f51b5;
|
|
|
384
384
|
display: block;
|
|
385
385
|
width: 2em;
|
|
386
386
|
text-align: center;
|
|
387
|
-
border: 1px solid
|
|
387
|
+
border: 1px solid rgb(0, 0, 0, 0.5);
|
|
388
388
|
border-radius: 3px;
|
|
389
389
|
outline: medium none;
|
|
390
390
|
font-size: 1.2em;
|
|
@@ -455,7 +455,7 @@ $theme-color: #3f51b5;
|
|
|
455
455
|
}
|
|
456
456
|
|
|
457
457
|
&:hover > .nxt-dt-control-button-content {
|
|
458
|
-
background-color:
|
|
458
|
+
background-color: rgb(0, 0, 0, 0.12);
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
.nxt-dt-control-button-arrow {
|
|
@@ -478,7 +478,7 @@ $theme-color: #3f51b5;
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
&[disabled] {
|
|
481
|
-
color:
|
|
481
|
+
color: rgb(0, 0, 0, 0.4);
|
|
482
482
|
cursor: default;
|
|
483
483
|
}
|
|
484
484
|
|
|
@@ -493,7 +493,7 @@ $theme-color: #3f51b5;
|
|
|
493
493
|
.nxt-dt-popup-container {
|
|
494
494
|
position: relative;
|
|
495
495
|
width: 18.5em;
|
|
496
|
-
box-shadow: 0 5px 5px -3px
|
|
496
|
+
box-shadow: 0 5px 5px -3px rgb(0, 0, 0, 0.2), 0 8px 10px 1px rgb(0, 0, 0, 0.14), 0 3px 14px 2px rgb(0, 0, 0, 0.12);
|
|
497
497
|
|
|
498
498
|
.nxt-dt-calendar,
|
|
499
499
|
.nxt-dt-timer {
|
|
@@ -569,7 +569,7 @@ $theme-color: #3f51b5;
|
|
|
569
569
|
|
|
570
570
|
&:hover {
|
|
571
571
|
.nxt-dt-control-button-content {
|
|
572
|
-
background-color:
|
|
572
|
+
background-color: rgb(0, 0, 0, 0.1);
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
575
|
}
|
|
@@ -589,7 +589,7 @@ $theme-color: #3f51b5;
|
|
|
589
589
|
}
|
|
590
590
|
|
|
591
591
|
&:last-child {
|
|
592
|
-
border-top: 1px solid
|
|
592
|
+
border-top: 1px solid rgb(0, 0, 0, 0.12);
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
|
|
@@ -601,7 +601,7 @@ $theme-color: #3f51b5;
|
|
|
601
601
|
.nxt-dt-container-disabled,
|
|
602
602
|
.nxt-dt-trigger-disabled {
|
|
603
603
|
opacity: 0.35;
|
|
604
|
-
filter: Alpha(opacity
|
|
604
|
+
filter: Alpha(opacity=35);
|
|
605
605
|
background-image: none;
|
|
606
606
|
cursor: default !important;
|
|
607
607
|
}
|
|
@@ -653,7 +653,7 @@ $theme-color: #3f51b5;
|
|
|
653
653
|
}
|
|
654
654
|
|
|
655
655
|
&:focus > .nxt-dt-control-content {
|
|
656
|
-
background-color:
|
|
656
|
+
background-color: rgb(0, 0, 0, 0.12);
|
|
657
657
|
}
|
|
658
658
|
|
|
659
659
|
&:not(:-moz-focusring):focus > .nxt-dt-control-content {
|
|
@@ -663,7 +663,7 @@ $theme-color: #3f51b5;
|
|
|
663
663
|
|
|
664
664
|
.nxt-hidden-accessible {
|
|
665
665
|
border: 0;
|
|
666
|
-
clip: rect(0 0 0 0);
|
|
666
|
+
clip-path: rect(0 0 0 0);
|
|
667
667
|
height: 1px;
|
|
668
668
|
margin: -1px;
|
|
669
669
|
overflow: hidden;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, LOCALE_ID, Injectable,
|
|
2
|
+
import { InjectionToken, inject, LOCALE_ID, Injectable, NgModule } from '@angular/core';
|
|
3
3
|
import moment from 'moment';
|
|
4
4
|
import { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from 'nxt-pick-datetime';
|
|
5
5
|
|
|
@@ -27,9 +27,10 @@ function range(length, valueFunction) {
|
|
|
27
27
|
return valuesArray;
|
|
28
28
|
}
|
|
29
29
|
class MomentDateTimeAdapter extends DateTimeAdapter {
|
|
30
|
-
constructor(
|
|
30
|
+
constructor() {
|
|
31
|
+
const dateTimeLocale = inject(LOCALE_ID, { optional: true });
|
|
31
32
|
super();
|
|
32
|
-
this.options =
|
|
33
|
+
this.options = inject(NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS, { optional: true });
|
|
33
34
|
this._localeData = {};
|
|
34
35
|
this.setLocale(dateTimeLocale || moment.locale());
|
|
35
36
|
}
|
|
@@ -151,7 +152,7 @@ class MomentDateTimeAdapter extends DateTimeAdapter {
|
|
|
151
152
|
if (seconds < 0 || seconds > 59) {
|
|
152
153
|
throw Error(`Invalid seconds "${seconds}". Seconds has to be between 0 and 59.`);
|
|
153
154
|
}
|
|
154
|
-
const result = this.createMoment({ year, month, date, hours, minutes, seconds }).locale(this.locale);
|
|
155
|
+
const result = this.createMoment({ year, month, date, hours, minutes, seconds }).locale(this.locale());
|
|
155
156
|
// If the result isn't valid, the date must have been out of bounds for this month.
|
|
156
157
|
if (!result.isValid()) {
|
|
157
158
|
throw Error(`Invalid date "${date}" for month with index "${month}".`);
|
|
@@ -159,10 +160,10 @@ class MomentDateTimeAdapter extends DateTimeAdapter {
|
|
|
159
160
|
return result;
|
|
160
161
|
}
|
|
161
162
|
clone(date) {
|
|
162
|
-
return this.createMoment(date).clone().locale(this.locale);
|
|
163
|
+
return this.createMoment(date).clone().locale(this.locale());
|
|
163
164
|
}
|
|
164
165
|
now() {
|
|
165
|
-
return this.createMoment().locale(this.locale);
|
|
166
|
+
return this.createMoment().locale(this.locale());
|
|
166
167
|
}
|
|
167
168
|
format(date, displayFormat) {
|
|
168
169
|
date = this.clone(date);
|
|
@@ -173,9 +174,9 @@ class MomentDateTimeAdapter extends DateTimeAdapter {
|
|
|
173
174
|
}
|
|
174
175
|
parse(value, parseFormat) {
|
|
175
176
|
if (value && typeof value === 'string') {
|
|
176
|
-
return this.createMoment(value, parseFormat, this.locale);
|
|
177
|
+
return this.createMoment(value, parseFormat, this.locale());
|
|
177
178
|
}
|
|
178
|
-
return value ? this.createMoment(value).locale(this.locale) : undefined;
|
|
179
|
+
return value ? this.createMoment(value).locale(this.locale()) : undefined;
|
|
179
180
|
}
|
|
180
181
|
/**
|
|
181
182
|
* Returns the given value if given a valid Moment or undefined. Deserializes valid ISO 8601 strings
|
|
@@ -191,7 +192,7 @@ class MomentDateTimeAdapter extends DateTimeAdapter {
|
|
|
191
192
|
if (!value) {
|
|
192
193
|
return undefined;
|
|
193
194
|
}
|
|
194
|
-
date = this.createMoment(value, moment.ISO_8601).locale(this.locale);
|
|
195
|
+
date = this.createMoment(value, moment.ISO_8601).locale(this.locale());
|
|
195
196
|
}
|
|
196
197
|
if (date && this.isValid(date)) {
|
|
197
198
|
return date;
|
|
@@ -202,22 +203,12 @@ class MomentDateTimeAdapter extends DateTimeAdapter {
|
|
|
202
203
|
createMoment(...args) {
|
|
203
204
|
return (this.options && this.options.useUtc) ? moment.utc(...args) : moment(...args);
|
|
204
205
|
}
|
|
205
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
206
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
206
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: MomentDateTimeAdapter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
207
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: MomentDateTimeAdapter }); }
|
|
207
208
|
}
|
|
208
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
209
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: MomentDateTimeAdapter, decorators: [{
|
|
209
210
|
type: Injectable
|
|
210
|
-
}], ctorParameters: () => [
|
|
211
|
-
type: Optional
|
|
212
|
-
}, {
|
|
213
|
-
type: Inject,
|
|
214
|
-
args: [LOCALE_ID]
|
|
215
|
-
}] }, { type: undefined, decorators: [{
|
|
216
|
-
type: Optional
|
|
217
|
-
}, {
|
|
218
|
-
type: Inject,
|
|
219
|
-
args: [NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS]
|
|
220
|
-
}] }] });
|
|
211
|
+
}], ctorParameters: () => [] });
|
|
221
212
|
|
|
222
213
|
/**
|
|
223
214
|
* @internal
|
|
@@ -245,14 +236,15 @@ function provideMomentDateTimeAdapter() {
|
|
|
245
236
|
}
|
|
246
237
|
];
|
|
247
238
|
}
|
|
239
|
+
/** @deprecated use provideMomentDateTimeAdapter */
|
|
248
240
|
class MomentDateTimeModule {
|
|
249
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
250
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
251
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
241
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: MomentDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
242
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.8", ngImport: i0, type: MomentDateTimeModule }); }
|
|
243
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: MomentDateTimeModule, providers: [
|
|
252
244
|
provideMomentDateTimeAdapter()
|
|
253
245
|
] }); }
|
|
254
246
|
}
|
|
255
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
247
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: MomentDateTimeModule, decorators: [{
|
|
256
248
|
type: NgModule,
|
|
257
249
|
args: [{
|
|
258
250
|
providers: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nxt-pick-datetime-moment-adapter.mjs","sources":["../../../packages/pick-datetime/moment-adapter/src/date-time-adapter.class.ts","../../../packages/pick-datetime/moment-adapter/src/date-time-format.class.ts","../../../packages/pick-datetime/moment-adapter/src/moment-adapter.module.ts","../../../packages/pick-datetime/moment-adapter/src/nxt-pick-datetime-moment-adapter.ts"],"sourcesContent":["import { Inject, Injectable, InjectionToken, LOCALE_ID, Optional } from '@angular/core'\r\nimport moment, { Moment } from 'moment'\r\nimport { DateTimeAdapter } from 'nxt-pick-datetime'\r\n\r\n/** Configurable options for {@see MomentDateAdapter} */\r\nexport interface MomentDateTimeAdapterOptions {\r\n /**\r\n * Turns the use of utc dates on or off.\r\n * Changing this will change how the DateTimePicker output value.\r\n * {@default false}\r\n */\r\n useUtc: boolean\r\n}\r\n\r\n/** InjectionToken for moment date adapter to configure options */\r\nexport const NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS = new InjectionToken<MomentDateTimeAdapterOptions>(\r\n 'NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS', {\r\n providedIn: 'root',\r\n factory: NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS_FACTORY\r\n })\r\n\r\n/** @internal */\r\nexport function NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS_FACTORY(): MomentDateTimeAdapterOptions {\r\n return {\r\n useUtc: false\r\n }\r\n}\r\n\r\n/**\r\n * Creates an array and fills it with values.\r\n *\r\n * @internal\r\n */\r\nfunction range<T>(length: number, valueFunction: (index: number) => T): T[] {\r\n const valuesArray = Array(length)\r\n for (let i = 0; i < length; i++) {\r\n valuesArray[i] = valueFunction(i)\r\n }\r\n return valuesArray\r\n}\r\n\r\n@Injectable()\r\nexport class MomentDateTimeAdapter extends DateTimeAdapter<Moment> {\r\n\r\n private _localeData: {\r\n longMonths: string[]\r\n shortMonths: string[]\r\n longDaysOfWeek: string[]\r\n shortDaysOfWeek: string[]\r\n narrowDaysOfWeek: string[]\r\n dates: string[]\r\n } = {} as any\r\n\r\n constructor(\r\n @Optional()\r\n @Inject(LOCALE_ID)\r\n dateTimeLocale?: string,\r\n @Optional()\r\n @Inject(NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS)\r\n private readonly options?: MomentDateTimeAdapterOptions\r\n ) {\r\n super()\r\n this.setLocale(dateTimeLocale || moment.locale())\r\n }\r\n\r\n override setLocale(locale: string) {\r\n super.setLocale(locale)\r\n\r\n const momentLocaleData = moment.localeData(locale)\r\n this._localeData = {\r\n longMonths: momentLocaleData.months(),\r\n shortMonths: momentLocaleData.monthsShort(),\r\n longDaysOfWeek: momentLocaleData.weekdays(),\r\n shortDaysOfWeek: momentLocaleData.weekdaysShort(),\r\n narrowDaysOfWeek: momentLocaleData.weekdaysMin(),\r\n dates: range(31, (i) => this.createDate(2017, 0, i + 1).format('D'))\r\n }\r\n }\r\n\r\n getYear(date: Moment): number {\r\n return this.clone(date).year()\r\n }\r\n\r\n getMonth(date: Moment): number {\r\n return this.clone(date).month()\r\n }\r\n\r\n getDay(date: Moment): number {\r\n return this.clone(date).day()\r\n }\r\n\r\n getDate(date: Moment): number {\r\n return this.clone(date).date()\r\n }\r\n\r\n getHours(date: Moment): number {\r\n return this.clone(date).hours()\r\n }\r\n\r\n getMinutes(date: Moment): number {\r\n return this.clone(date).minutes()\r\n }\r\n\r\n getSeconds(date: Moment): number {\r\n return this.clone(date).seconds()\r\n }\r\n\r\n getTime(date: Moment): number {\r\n return this.clone(date).valueOf()\r\n }\r\n\r\n getNumDaysInMonth(date: Moment): number {\r\n return this.clone(date).daysInMonth()\r\n }\r\n\r\n differenceInCalendarDays(dateLeft: Moment, dateRight: Moment): number {\r\n return this.clone(dateLeft).diff(dateRight, 'days')\r\n }\r\n\r\n getYearName(date: Moment): string {\r\n return this.clone(date).format('YYYY')\r\n }\r\n\r\n getMonthNames(style: 'long' | 'short' | 'narrow'): string[] {\r\n return style === 'long' ? this._localeData.longMonths : this._localeData.shortMonths\r\n }\r\n\r\n getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] {\r\n if (style === 'long') {\r\n return this._localeData.longDaysOfWeek\r\n }\r\n if (style === 'short') {\r\n return this._localeData.shortDaysOfWeek\r\n }\r\n return this._localeData.narrowDaysOfWeek\r\n }\r\n\r\n getDateNames(): string[] {\r\n return this._localeData.dates\r\n }\r\n\r\n toIso8601(date: Moment): string {\r\n return this.clone(date).format()\r\n }\r\n\r\n isEqual(dateLeft: Moment, dateRight: Moment): boolean {\r\n\r\n if (dateLeft && dateRight) {\r\n return this.clone(dateLeft).isSame(this.clone(dateRight))\r\n }\r\n\r\n return dateLeft === dateRight\r\n }\r\n\r\n isSameDay(dateLeft: Moment, dateRight: Moment): boolean {\r\n\r\n if (dateLeft && dateRight) {\r\n return this.clone(dateLeft).isSame(this.clone(dateRight), 'day')\r\n }\r\n\r\n return dateLeft === dateRight\r\n }\r\n\r\n isValid(date: Moment): boolean {\r\n return this.clone(date).isValid()\r\n }\r\n\r\n invalid(): Moment {\r\n return moment.invalid()\r\n }\r\n\r\n isDateInstance(obj: any): boolean {\r\n return moment.isMoment(obj)\r\n }\r\n\r\n addCalendarYears(date: Moment, amount: number): Moment {\r\n return this.clone(date).add({ years: amount })\r\n }\r\n\r\n addCalendarMonths(date: Moment, amount: number): Moment {\r\n return this.clone(date).add({ months: amount })\r\n }\r\n\r\n addCalendarDays(date: Moment, amount: number): Moment {\r\n return this.clone(date).add({ days: amount })\r\n }\r\n\r\n setHours(date: Moment, amount: number): Moment {\r\n return this.clone(date).hours(amount)\r\n }\r\n\r\n setMinutes(date: Moment, amount: number): Moment {\r\n return this.clone(date).minutes(amount)\r\n }\r\n\r\n setSeconds(date: Moment, amount: number): Moment {\r\n return this.clone(date).seconds(amount)\r\n }\r\n\r\n createDate(year: number, month: number, date: number): Moment\r\n createDate(year: number, month: number, date: number, hours: number = 0, minutes: number = 0, seconds: number = 0): Moment {\r\n if (month < 0 || month > 11) {\r\n throw Error(`Invalid month index \"${month}\". Month index has to be between 0 and 11.`)\r\n }\r\n\r\n if (date < 1) {\r\n throw Error(`Invalid date \"${date}\". Date has to be greater than 0.`)\r\n }\r\n\r\n if (hours < 0 || hours > 23) {\r\n throw Error(`Invalid hours \"${hours}\". Hours has to be between 0 and 23.`)\r\n }\r\n\r\n if (minutes < 0 || minutes > 59) {\r\n throw Error(`Invalid minutes \"${minutes}\". Minutes has to between 0 and 59.`)\r\n }\r\n\r\n if (seconds < 0 || seconds > 59) {\r\n throw Error(`Invalid seconds \"${seconds}\". Seconds has to be between 0 and 59.`)\r\n }\r\n\r\n const result = this.createMoment({ year, month, date, hours, minutes, seconds }).locale(this.locale)\r\n\r\n // If the result isn't valid, the date must have been out of bounds for this month.\r\n if (!result.isValid()) {\r\n throw Error(`Invalid date \"${date}\" for month with index \"${month}\".`)\r\n }\r\n\r\n return result\r\n }\r\n\r\n clone(date: Moment): Moment {\r\n return this.createMoment(date).clone().locale(this.locale)\r\n }\r\n\r\n now(): Moment {\r\n return this.createMoment().locale(this.locale)\r\n }\r\n\r\n format(date: Moment, displayFormat: any): string {\r\n date = this.clone(date)\r\n if (!this.isValid(date)) {\r\n throw Error('MomentDateTimeAdapter: Cannot format invalid date.')\r\n }\r\n return date.format(displayFormat)\r\n }\r\n\r\n parse(value: any, parseFormat: any): Moment | undefined {\r\n if (value && typeof value === 'string') {\r\n return this.createMoment(value, parseFormat, this.locale)\r\n }\r\n return value ? this.createMoment(value).locale(this.locale) : undefined\r\n }\r\n\r\n /**\r\n * Returns the given value if given a valid Moment or undefined. Deserializes valid ISO 8601 strings\r\n * (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid Moments and empty\r\n * string into undefined. Returns an invalid date for all other values.\r\n */\r\n override deserialize(value: any): Moment | undefined {\r\n let date\r\n if (value instanceof Date) {\r\n date = this.createMoment(value)\r\n }\r\n if (typeof value === 'string') {\r\n if (!value) {\r\n return undefined\r\n }\r\n date = this.createMoment(value, moment.ISO_8601).locale(this.locale)\r\n }\r\n if (date && this.isValid(date)) {\r\n return date\r\n }\r\n return super.deserialize(value)\r\n }\r\n\r\n /** Creates a Moment instance while respecting the current UTC settings */\r\n private createMoment(...args: any[]): Moment {\r\n return (this.options && this.options.useUtc) ? moment.utc(...args) : moment(...args)\r\n }\r\n}\r\n","import { DateTimeFormats } from 'nxt-pick-datetime'\r\n\r\n/**\r\n * @internal\r\n */\r\nexport const NXT_MOMENT_DATE_TIME_FORMATS: DateTimeFormats = {\r\n parseInput: 'l LT',\r\n fullPickerInput: 'l LT',\r\n datePickerInput: 'l',\r\n timePickerInput: 'LT',\r\n monthYearLabel: 'MMM YYYY',\r\n dateA11yLabel: 'LL',\r\n monthYearA11yLabel: 'MMMM YYYY'\r\n}\r\n","import { LOCALE_ID, NgModule, Provider } from '@angular/core'\r\nimport { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from 'nxt-pick-datetime'\r\nimport { MomentDateTimeAdapter, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS } from './date-time-adapter.class'\r\nimport { NXT_MOMENT_DATE_TIME_FORMATS } from './date-time-format.class'\r\n\r\nexport function provideMomentDateTimeAdapter(): Provider[] {\r\n return [\r\n {\r\n provide: DateTimeAdapter,\r\n useClass: MomentDateTimeAdapter,\r\n deps: [LOCALE_ID, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS]\r\n },\r\n {\r\n provide: NXT_DATE_TIME_FORMATS,\r\n useValue: NXT_MOMENT_DATE_TIME_FORMATS\r\n }\r\n ]\r\n}\r\n\r\n@NgModule({\r\n providers: [\r\n provideMomentDateTimeAdapter()\r\n ]\r\n})\r\nexport class MomentDateTimeModule { }\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAcA;MACa,oCAAoC,GAAG,IAAI,cAAc,CAClE,sCAAsC,EAAE;AACpC,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE;AACZ,CAAA;AAEL;SACgB,4CAA4C,GAAA;IACxD,OAAO;AACH,QAAA,MAAM,EAAE;KACX;AACL;AAEA;;;;AAIG;AACH,SAAS,KAAK,CAAI,MAAc,EAAE,aAAmC,EAAA;AACjE,IAAA,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;AACjC,IAAA,KA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E;AACP,wBAAA,4BAA4B;AAC/B;AACJ,iBAAA;;;ACvBD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"nxt-pick-datetime-moment-adapter.mjs","sources":["../../../packages/pick-datetime/moment-adapter/src/date-time-adapter.class.ts","../../../packages/pick-datetime/moment-adapter/src/date-time-format.class.ts","../../../packages/pick-datetime/moment-adapter/src/moment-adapter.module.ts","../../../packages/pick-datetime/moment-adapter/src/nxt-pick-datetime-moment-adapter.ts"],"sourcesContent":["import { inject, Injectable, InjectionToken, LOCALE_ID } from '@angular/core'\r\nimport moment, { Moment } from 'moment'\r\nimport { DateTimeAdapter } from 'nxt-pick-datetime'\r\n\r\n/** Configurable options for {@see MomentDateAdapter} */\r\nexport interface MomentDateTimeAdapterOptions {\r\n /**\r\n * Turns the use of utc dates on or off.\r\n * Changing this will change how the DateTimePicker output value.\r\n * {@default false}\r\n */\r\n useUtc: boolean\r\n}\r\n\r\n/** InjectionToken for moment date adapter to configure options */\r\nexport const NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS = new InjectionToken<MomentDateTimeAdapterOptions>('NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS', {\r\n providedIn: 'root',\r\n factory: NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS_FACTORY\r\n})\r\n\r\n/** @internal */\r\nexport function NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS_FACTORY(): MomentDateTimeAdapterOptions {\r\n return {\r\n useUtc: false\r\n }\r\n}\r\n\r\n/**\r\n * Creates an array and fills it with values.\r\n *\r\n * @internal\r\n */\r\nfunction range<T>(length: number, valueFunction: (index: number) => T): T[] {\r\n const valuesArray = Array(length)\r\n for (let i = 0; i < length; i++) {\r\n valuesArray[i] = valueFunction(i)\r\n }\r\n return valuesArray\r\n}\r\n\r\n@Injectable()\r\nexport class MomentDateTimeAdapter extends DateTimeAdapter<Moment> {\r\n private readonly options = inject(NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS, { optional: true })\r\n\r\n private _localeData: {\r\n longMonths: string[]\r\n shortMonths: string[]\r\n longDaysOfWeek: string[]\r\n shortDaysOfWeek: string[]\r\n narrowDaysOfWeek: string[]\r\n dates: string[]\r\n } = {} as any\r\n\r\n constructor() {\r\n const dateTimeLocale = inject(LOCALE_ID, { optional: true })\r\n\r\n super()\r\n this.setLocale(dateTimeLocale || moment.locale())\r\n }\r\n\r\n override setLocale(locale: string) {\r\n super.setLocale(locale)\r\n\r\n const momentLocaleData = moment.localeData(locale)\r\n this._localeData = {\r\n longMonths: momentLocaleData.months(),\r\n shortMonths: momentLocaleData.monthsShort(),\r\n longDaysOfWeek: momentLocaleData.weekdays(),\r\n shortDaysOfWeek: momentLocaleData.weekdaysShort(),\r\n narrowDaysOfWeek: momentLocaleData.weekdaysMin(),\r\n dates: range(31, (i) => this.createDate(2017, 0, i + 1).format('D'))\r\n }\r\n }\r\n\r\n getYear(date: Moment): number {\r\n return this.clone(date).year()\r\n }\r\n\r\n getMonth(date: Moment): number {\r\n return this.clone(date).month()\r\n }\r\n\r\n getDay(date: Moment): number {\r\n return this.clone(date).day()\r\n }\r\n\r\n getDate(date: Moment): number {\r\n return this.clone(date).date()\r\n }\r\n\r\n getHours(date: Moment): number {\r\n return this.clone(date).hours()\r\n }\r\n\r\n getMinutes(date: Moment): number {\r\n return this.clone(date).minutes()\r\n }\r\n\r\n getSeconds(date: Moment): number {\r\n return this.clone(date).seconds()\r\n }\r\n\r\n getTime(date: Moment): number {\r\n return this.clone(date).valueOf()\r\n }\r\n\r\n getNumDaysInMonth(date: Moment): number {\r\n return this.clone(date).daysInMonth()\r\n }\r\n\r\n differenceInCalendarDays(dateLeft: Moment, dateRight: Moment): number {\r\n return this.clone(dateLeft).diff(dateRight, 'days')\r\n }\r\n\r\n getYearName(date: Moment): string {\r\n return this.clone(date).format('YYYY')\r\n }\r\n\r\n getMonthNames(style: 'long' | 'short' | 'narrow'): string[] {\r\n return style === 'long' ? this._localeData.longMonths : this._localeData.shortMonths\r\n }\r\n\r\n getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] {\r\n if (style === 'long') {\r\n return this._localeData.longDaysOfWeek\r\n }\r\n if (style === 'short') {\r\n return this._localeData.shortDaysOfWeek\r\n }\r\n return this._localeData.narrowDaysOfWeek\r\n }\r\n\r\n getDateNames(): string[] {\r\n return this._localeData.dates\r\n }\r\n\r\n toIso8601(date: Moment): string {\r\n return this.clone(date).format()\r\n }\r\n\r\n isEqual(dateLeft: Moment, dateRight: Moment): boolean {\r\n\r\n if (dateLeft && dateRight) {\r\n return this.clone(dateLeft).isSame(this.clone(dateRight))\r\n }\r\n\r\n return dateLeft === dateRight\r\n }\r\n\r\n isSameDay(dateLeft: Moment, dateRight: Moment): boolean {\r\n\r\n if (dateLeft && dateRight) {\r\n return this.clone(dateLeft).isSame(this.clone(dateRight), 'day')\r\n }\r\n\r\n return dateLeft === dateRight\r\n }\r\n\r\n isValid(date: Moment): boolean {\r\n return this.clone(date).isValid()\r\n }\r\n\r\n invalid(): Moment {\r\n return moment.invalid()\r\n }\r\n\r\n isDateInstance(obj: any): boolean {\r\n return moment.isMoment(obj)\r\n }\r\n\r\n addCalendarYears(date: Moment, amount: number): Moment {\r\n return this.clone(date).add({ years: amount })\r\n }\r\n\r\n addCalendarMonths(date: Moment, amount: number): Moment {\r\n return this.clone(date).add({ months: amount })\r\n }\r\n\r\n addCalendarDays(date: Moment, amount: number): Moment {\r\n return this.clone(date).add({ days: amount })\r\n }\r\n\r\n setHours(date: Moment, amount: number): Moment {\r\n return this.clone(date).hours(amount)\r\n }\r\n\r\n setMinutes(date: Moment, amount: number): Moment {\r\n return this.clone(date).minutes(amount)\r\n }\r\n\r\n setSeconds(date: Moment, amount: number): Moment {\r\n return this.clone(date).seconds(amount)\r\n }\r\n\r\n createDate(year: number, month: number, date: number): Moment\r\n createDate(year: number, month: number, date: number, hours: number = 0, minutes: number = 0, seconds: number = 0): Moment {\r\n if (month < 0 || month > 11) {\r\n throw Error(`Invalid month index \"${month}\". Month index has to be between 0 and 11.`)\r\n }\r\n\r\n if (date < 1) {\r\n throw Error(`Invalid date \"${date}\". Date has to be greater than 0.`)\r\n }\r\n\r\n if (hours < 0 || hours > 23) {\r\n throw Error(`Invalid hours \"${hours}\". Hours has to be between 0 and 23.`)\r\n }\r\n\r\n if (minutes < 0 || minutes > 59) {\r\n throw Error(`Invalid minutes \"${minutes}\". Minutes has to between 0 and 59.`)\r\n }\r\n\r\n if (seconds < 0 || seconds > 59) {\r\n throw Error(`Invalid seconds \"${seconds}\". Seconds has to be between 0 and 59.`)\r\n }\r\n\r\n const result = this.createMoment({ year, month, date, hours, minutes, seconds }).locale(this.locale())\r\n\r\n // If the result isn't valid, the date must have been out of bounds for this month.\r\n if (!result.isValid()) {\r\n throw Error(`Invalid date \"${date}\" for month with index \"${month}\".`)\r\n }\r\n\r\n return result\r\n }\r\n\r\n clone(date: Moment): Moment {\r\n return this.createMoment(date).clone().locale(this.locale())\r\n }\r\n\r\n now(): Moment {\r\n return this.createMoment().locale(this.locale())\r\n }\r\n\r\n format(date: Moment, displayFormat: any): string {\r\n date = this.clone(date)\r\n if (!this.isValid(date)) {\r\n throw Error('MomentDateTimeAdapter: Cannot format invalid date.')\r\n }\r\n return date.format(displayFormat)\r\n }\r\n\r\n parse(value: any, parseFormat: any): Moment | undefined {\r\n if (value && typeof value === 'string') {\r\n return this.createMoment(value, parseFormat, this.locale())\r\n }\r\n return value ? this.createMoment(value).locale(this.locale()) : undefined\r\n }\r\n\r\n /**\r\n * Returns the given value if given a valid Moment or undefined. Deserializes valid ISO 8601 strings\r\n * (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid Moments and empty\r\n * string into undefined. Returns an invalid date for all other values.\r\n */\r\n override deserialize(value: any): Moment | undefined {\r\n let date\r\n if (value instanceof Date) {\r\n date = this.createMoment(value)\r\n }\r\n if (typeof value === 'string') {\r\n if (!value) {\r\n return undefined\r\n }\r\n date = this.createMoment(value, moment.ISO_8601).locale(this.locale())\r\n }\r\n if (date && this.isValid(date)) {\r\n return date\r\n }\r\n return super.deserialize(value)\r\n }\r\n\r\n /** Creates a Moment instance while respecting the current UTC settings */\r\n private createMoment(...args: any[]): Moment {\r\n return (this.options && this.options.useUtc) ? moment.utc(...args) : moment(...args)\r\n }\r\n}\r\n","import { DateTimeFormats } from 'nxt-pick-datetime'\r\n\r\n/**\r\n * @internal\r\n */\r\nexport const NXT_MOMENT_DATE_TIME_FORMATS: DateTimeFormats = {\r\n parseInput: 'l LT',\r\n fullPickerInput: 'l LT',\r\n datePickerInput: 'l',\r\n timePickerInput: 'LT',\r\n monthYearLabel: 'MMM YYYY',\r\n dateA11yLabel: 'LL',\r\n monthYearA11yLabel: 'MMMM YYYY'\r\n}\r\n","import { LOCALE_ID, NgModule, Provider } from '@angular/core'\r\nimport { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from 'nxt-pick-datetime'\r\nimport { MomentDateTimeAdapter, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS } from './date-time-adapter.class'\r\nimport { NXT_MOMENT_DATE_TIME_FORMATS } from './date-time-format.class'\r\n\r\nexport function provideMomentDateTimeAdapter(): Provider[] {\r\n return [\r\n {\r\n provide: DateTimeAdapter,\r\n useClass: MomentDateTimeAdapter,\r\n deps: [LOCALE_ID, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS]\r\n },\r\n {\r\n provide: NXT_DATE_TIME_FORMATS,\r\n useValue: NXT_MOMENT_DATE_TIME_FORMATS\r\n }\r\n ]\r\n}\r\n\r\n/** @deprecated use provideMomentDateTimeAdapter */\r\n@NgModule({\r\n providers: [\r\n provideMomentDateTimeAdapter()\r\n ]\r\n})\r\nexport class MomentDateTimeModule { }\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAcA;MACa,oCAAoC,GAAG,IAAI,cAAc,CAA+B,sCAAsC,EAAE;AACzI,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,O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A,QAAA,EAAA,CAAA,CAAA;+GAApB,oBAAoB,EAAA,CAAA,CAAA;AAApB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,EAAA,SAAA,EAJlB;AACP,YAAA,4BAA4B;AAC/B,SAAA,EAAA,CAAA,CAAA;;2FAEQ,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBALhC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,SAAS,EAAE;AACP,wBAAA,4BAA4B;AAC/B;AACJ,iBAAA;;;ACxBD;;AAEG;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PlatformModule } from '@angular/cdk/platform';
|
|
1
|
+
import { Platform, PlatformModule } from '@angular/cdk/platform';
|
|
3
2
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { LOCALE_ID, Injectable,
|
|
3
|
+
import { inject, LOCALE_ID, Injectable, NgModule } from '@angular/core';
|
|
5
4
|
import { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from 'nxt-pick-datetime';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -91,7 +90,9 @@ function range(length, valueFunction) {
|
|
|
91
90
|
return valuesArray;
|
|
92
91
|
}
|
|
93
92
|
class NativeDateTimeAdapter extends DateTimeAdapter {
|
|
94
|
-
constructor(
|
|
93
|
+
constructor() {
|
|
94
|
+
const platform = inject(Platform);
|
|
95
|
+
const dateTimeLocale = inject(LOCALE_ID, { optional: true });
|
|
95
96
|
super();
|
|
96
97
|
super.setLocale(dateTimeLocale);
|
|
97
98
|
// IE does its own time zone correction, so we disable this on IE.
|
|
@@ -144,7 +145,7 @@ class NativeDateTimeAdapter extends DateTimeAdapter {
|
|
|
144
145
|
}
|
|
145
146
|
getYearName(date) {
|
|
146
147
|
if (SUPPORTS_INTL_API) {
|
|
147
|
-
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
148
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
148
149
|
year: 'numeric',
|
|
149
150
|
timeZone: 'utc'
|
|
150
151
|
});
|
|
@@ -154,7 +155,7 @@ class NativeDateTimeAdapter extends DateTimeAdapter {
|
|
|
154
155
|
}
|
|
155
156
|
getMonthNames(style) {
|
|
156
157
|
if (SUPPORTS_INTL_API) {
|
|
157
|
-
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
158
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
158
159
|
month: style,
|
|
159
160
|
timeZone: 'utc'
|
|
160
161
|
});
|
|
@@ -164,7 +165,7 @@ class NativeDateTimeAdapter extends DateTimeAdapter {
|
|
|
164
165
|
}
|
|
165
166
|
getDayOfWeekNames(style) {
|
|
166
167
|
if (SUPPORTS_INTL_API) {
|
|
167
|
-
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
168
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
168
169
|
weekday: style,
|
|
169
170
|
timeZone: 'utc'
|
|
170
171
|
});
|
|
@@ -174,7 +175,7 @@ class NativeDateTimeAdapter extends DateTimeAdapter {
|
|
|
174
175
|
}
|
|
175
176
|
getDateNames() {
|
|
176
177
|
if (SUPPORTS_INTL_API) {
|
|
177
|
-
const dtf = new Intl.DateTimeFormat(this.locale, {
|
|
178
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), {
|
|
178
179
|
day: 'numeric',
|
|
179
180
|
timeZone: 'utc'
|
|
180
181
|
});
|
|
@@ -292,7 +293,7 @@ class NativeDateTimeAdapter extends DateTimeAdapter {
|
|
|
292
293
|
date.setFullYear(Math.max(1, Math.min(9999, date.getFullYear())));
|
|
293
294
|
}
|
|
294
295
|
displayFormat = { ...displayFormat, timeZone: 'utc' };
|
|
295
|
-
const dtf = new Intl.DateTimeFormat(this.locale, displayFormat);
|
|
296
|
+
const dtf = new Intl.DateTimeFormat(this.locale(), displayFormat);
|
|
296
297
|
return this.stripDirectionalityCharacters(this._format(dtf, date));
|
|
297
298
|
}
|
|
298
299
|
return this.stripDirectionalityCharacters(date.toDateString());
|
|
@@ -354,17 +355,12 @@ class NativeDateTimeAdapter extends DateTimeAdapter {
|
|
|
354
355
|
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
|
|
355
356
|
return dtf.format(d);
|
|
356
357
|
}
|
|
357
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
358
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
358
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: NativeDateTimeAdapter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
359
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: NativeDateTimeAdapter }); }
|
|
359
360
|
}
|
|
360
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
361
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: NativeDateTimeAdapter, decorators: [{
|
|
361
362
|
type: Injectable
|
|
362
|
-
}], ctorParameters: () => [
|
|
363
|
-
type: Optional
|
|
364
|
-
}, {
|
|
365
|
-
type: Inject,
|
|
366
|
-
args: [LOCALE_ID]
|
|
367
|
-
}] }] });
|
|
363
|
+
}], ctorParameters: () => [] });
|
|
368
364
|
|
|
369
365
|
/**
|
|
370
366
|
* @internal
|
|
@@ -391,14 +387,15 @@ function provideNativeDateTimeAdapter() {
|
|
|
391
387
|
}
|
|
392
388
|
];
|
|
393
389
|
}
|
|
390
|
+
/** @deprecated use provideNativeDateTimeAdapter */
|
|
394
391
|
class NativeDateTimeModule {
|
|
395
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
396
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
397
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
392
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: NativeDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
393
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.8", ngImport: i0, type: NativeDateTimeModule, imports: [PlatformModule] }); }
|
|
394
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: NativeDateTimeModule, providers: [
|
|
398
395
|
provideNativeDateTimeAdapter()
|
|
399
396
|
], imports: [PlatformModule] }); }
|
|
400
397
|
}
|
|
401
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
398
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: NativeDateTimeModule, decorators: [{
|
|
402
399
|
type: NgModule,
|
|
403
400
|
args: [{
|
|
404
401
|
imports: [PlatformModule],
|