nxt-pick-datetime 22.0.0 → 22.1.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,245 +1,212 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, LOCALE_ID, Injectable } from '@angular/core';
3
- import moment from 'moment';
4
- import { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from 'nxt-pick-datetime';
5
-
6
- /** InjectionToken for moment date adapter to configure options */
7
- const NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS = new InjectionToken('NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS', {
8
- providedIn: 'root',
9
- factory: NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS_FACTORY
1
+ import * as i0 from "@angular/core";
2
+ import { Injectable, InjectionToken, LOCALE_ID, inject } from "@angular/core";
3
+ import moment from "moment";
4
+ import { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from "nxt-pick-datetime";
5
+ const NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS = new InjectionToken("NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS", {
6
+ providedIn: "root",
7
+ factory: NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS_FACTORY
10
8
  });
11
- /** @internal */
12
9
  function NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS_FACTORY() {
13
- return {
14
- useUtc: false
15
- };
10
+ return { useUtc: false };
16
11
  }
17
- /**
18
- * Creates an array and fills it with values.
19
- *
20
- * @internal
21
- */
22
12
  function range(length, valueFunction) {
23
- const valuesArray = Array(length);
24
- for (let i = 0; i < length; i++) {
25
- valuesArray[i] = valueFunction(i);
26
- }
27
- return valuesArray;
28
- }
29
- class MomentDateTimeAdapter extends DateTimeAdapter {
30
- constructor() {
31
- const dateTimeLocale = inject(LOCALE_ID, { optional: true });
32
- super();
33
- this.options = inject(NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS, { optional: true });
34
- this._localeData = {};
35
- this.setLocale(dateTimeLocale || moment.locale());
36
- }
37
- setLocale(locale) {
38
- super.setLocale(locale);
39
- const momentLocaleData = moment.localeData(locale);
40
- this._localeData = {
41
- longMonths: momentLocaleData.months(),
42
- shortMonths: momentLocaleData.monthsShort(),
43
- longDaysOfWeek: momentLocaleData.weekdays(),
44
- shortDaysOfWeek: momentLocaleData.weekdaysShort(),
45
- narrowDaysOfWeek: momentLocaleData.weekdaysMin(),
46
- dates: range(31, (i) => this.createDate(2017, 0, i + 1).format('D'))
47
- };
48
- }
49
- getYear(date) {
50
- return this.clone(date).year();
51
- }
52
- getMonth(date) {
53
- return this.clone(date).month();
54
- }
55
- getDay(date) {
56
- return this.clone(date).day();
57
- }
58
- getDate(date) {
59
- return this.clone(date).date();
60
- }
61
- getHours(date) {
62
- return this.clone(date).hours();
63
- }
64
- getMinutes(date) {
65
- return this.clone(date).minutes();
66
- }
67
- getSeconds(date) {
68
- return this.clone(date).seconds();
69
- }
70
- getTime(date) {
71
- return this.clone(date).valueOf();
72
- }
73
- getNumDaysInMonth(date) {
74
- return this.clone(date).daysInMonth();
75
- }
76
- differenceInCalendarDays(dateLeft, dateRight) {
77
- return this.clone(dateLeft).diff(dateRight, 'days');
78
- }
79
- getYearName(date) {
80
- return this.clone(date).format('YYYY');
81
- }
82
- getMonthNames(style) {
83
- return style === 'long' ? this._localeData.longMonths : this._localeData.shortMonths;
84
- }
85
- getDayOfWeekNames(style) {
86
- if (style === 'long') {
87
- return this._localeData.longDaysOfWeek;
88
- }
89
- if (style === 'short') {
90
- return this._localeData.shortDaysOfWeek;
91
- }
92
- return this._localeData.narrowDaysOfWeek;
93
- }
94
- getDateNames() {
95
- return this._localeData.dates;
96
- }
97
- toIso8601(date) {
98
- return this.clone(date).format();
99
- }
100
- isEqual(dateLeft, dateRight) {
101
- if (dateLeft && dateRight) {
102
- return this.clone(dateLeft).isSame(this.clone(dateRight));
103
- }
104
- return dateLeft === dateRight;
105
- }
106
- isSameDay(dateLeft, dateRight) {
107
- if (dateLeft && dateRight) {
108
- return this.clone(dateLeft).isSame(this.clone(dateRight), 'day');
109
- }
110
- return dateLeft === dateRight;
111
- }
112
- isValid(date) {
113
- return this.clone(date).isValid();
114
- }
115
- invalid() {
116
- return moment.invalid();
117
- }
118
- isDateInstance(obj) {
119
- return moment.isMoment(obj);
120
- }
121
- addCalendarYears(date, amount) {
122
- return this.clone(date).add({ years: amount });
123
- }
124
- addCalendarMonths(date, amount) {
125
- return this.clone(date).add({ months: amount });
126
- }
127
- addCalendarDays(date, amount) {
128
- return this.clone(date).add({ days: amount });
129
- }
130
- setHours(date, amount) {
131
- return this.clone(date).hours(amount);
132
- }
133
- setMinutes(date, amount) {
134
- return this.clone(date).minutes(amount);
135
- }
136
- setSeconds(date, amount) {
137
- return this.clone(date).seconds(amount);
138
- }
139
- createDate(year, month, date, hours = 0, minutes = 0, seconds = 0) {
140
- if (month < 0 || month > 11) {
141
- throw Error(`Invalid month index "${month}". Month index has to be between 0 and 11.`);
142
- }
143
- if (date < 1) {
144
- throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
145
- }
146
- if (hours < 0 || hours > 23) {
147
- throw Error(`Invalid hours "${hours}". Hours has to be between 0 and 23.`);
148
- }
149
- if (minutes < 0 || minutes > 59) {
150
- throw Error(`Invalid minutes "${minutes}". Minutes has to between 0 and 59.`);
151
- }
152
- if (seconds < 0 || seconds > 59) {
153
- throw Error(`Invalid seconds "${seconds}". Seconds has to be between 0 and 59.`);
154
- }
155
- const result = this.createMoment({ year, month, date, hours, minutes, seconds }).locale(this.locale());
156
- // If the result isn't valid, the date must have been out of bounds for this month.
157
- if (!result.isValid()) {
158
- throw Error(`Invalid date "${date}" for month with index "${month}".`);
159
- }
160
- return result;
161
- }
162
- clone(date) {
163
- return this.createMoment(date).clone().locale(this.locale());
164
- }
165
- now() {
166
- return this.createMoment().locale(this.locale());
167
- }
168
- format(date, displayFormat) {
169
- date = this.clone(date);
170
- if (!this.isValid(date)) {
171
- throw Error('MomentDateTimeAdapter: Cannot format invalid date.');
172
- }
173
- return date.format(displayFormat);
174
- }
175
- parse(value, parseFormat) {
176
- if (value && typeof value === 'string') {
177
- return this.createMoment(value, parseFormat, this.locale());
178
- }
179
- return value ? this.createMoment(value).locale(this.locale()) : undefined;
180
- }
181
- /**
182
- * Returns the given value if given a valid Moment or undefined. Deserializes valid ISO 8601 strings
183
- * (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid Moments and empty
184
- * string into undefined. Returns an invalid date for all other values.
185
- */
186
- deserialize(value) {
187
- let date;
188
- if (value instanceof Date) {
189
- date = this.createMoment(value);
190
- }
191
- if (typeof value === 'string') {
192
- if (!value) {
193
- return undefined;
194
- }
195
- date = this.createMoment(value, moment.ISO_8601).locale(this.locale());
196
- }
197
- if (date && this.isValid(date)) {
198
- return date;
199
- }
200
- return super.deserialize(value);
201
- }
202
- /** Creates a Moment instance while respecting the current UTC settings */
203
- createMoment(...args) {
204
- return (this.options && this.options.useUtc) ? moment.utc(...args) : moment(...args);
205
- }
206
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MomentDateTimeAdapter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
207
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MomentDateTimeAdapter }); }
13
+ const valuesArray = Array(length);
14
+ for (let i = 0; i < length; i++) valuesArray[i] = valueFunction(i);
15
+ return valuesArray;
208
16
  }
209
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: MomentDateTimeAdapter, decorators: [{
210
- type: Injectable
211
- }], ctorParameters: () => [] });
212
-
213
- /**
214
- * @internal
215
- */
17
+ var MomentDateTimeAdapter = class MomentDateTimeAdapter extends DateTimeAdapter {
18
+ constructor() {
19
+ const dateTimeLocale = inject(LOCALE_ID, { optional: true });
20
+ super();
21
+ this.options = inject(NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS, { optional: true });
22
+ this._localeData = {};
23
+ this.setLocale(dateTimeLocale || moment.locale());
24
+ }
25
+ setLocale(locale) {
26
+ super.setLocale(locale);
27
+ const momentLocaleData = moment.localeData(locale);
28
+ this._localeData = {
29
+ longMonths: momentLocaleData.months(),
30
+ shortMonths: momentLocaleData.monthsShort(),
31
+ longDaysOfWeek: momentLocaleData.weekdays(),
32
+ shortDaysOfWeek: momentLocaleData.weekdaysShort(),
33
+ narrowDaysOfWeek: momentLocaleData.weekdaysMin(),
34
+ dates: range(31, (i) => this.createDate(2017, 0, i + 1).format("D"))
35
+ };
36
+ }
37
+ getYear(date) {
38
+ return this.clone(date).year();
39
+ }
40
+ getMonth(date) {
41
+ return this.clone(date).month();
42
+ }
43
+ getDay(date) {
44
+ return this.clone(date).day();
45
+ }
46
+ getDate(date) {
47
+ return this.clone(date).date();
48
+ }
49
+ getHours(date) {
50
+ return this.clone(date).hours();
51
+ }
52
+ getMinutes(date) {
53
+ return this.clone(date).minutes();
54
+ }
55
+ getSeconds(date) {
56
+ return this.clone(date).seconds();
57
+ }
58
+ getTime(date) {
59
+ return this.clone(date).valueOf();
60
+ }
61
+ getNumDaysInMonth(date) {
62
+ return this.clone(date).daysInMonth();
63
+ }
64
+ differenceInCalendarDays(dateLeft, dateRight) {
65
+ return this.clone(dateLeft).diff(dateRight, "days");
66
+ }
67
+ getYearName(date) {
68
+ return this.clone(date).format("YYYY");
69
+ }
70
+ getMonthNames(style) {
71
+ return style === "long" ? this._localeData.longMonths : this._localeData.shortMonths;
72
+ }
73
+ getDayOfWeekNames(style) {
74
+ if (style === "long") return this._localeData.longDaysOfWeek;
75
+ if (style === "short") return this._localeData.shortDaysOfWeek;
76
+ return this._localeData.narrowDaysOfWeek;
77
+ }
78
+ getDateNames() {
79
+ return this._localeData.dates;
80
+ }
81
+ toIso8601(date) {
82
+ return this.clone(date).format();
83
+ }
84
+ isEqual(dateLeft, dateRight) {
85
+ if (dateLeft && dateRight) return this.clone(dateLeft).isSame(this.clone(dateRight));
86
+ return dateLeft === dateRight;
87
+ }
88
+ isSameDay(dateLeft, dateRight) {
89
+ if (dateLeft && dateRight) return this.clone(dateLeft).isSame(this.clone(dateRight), "day");
90
+ return dateLeft === dateRight;
91
+ }
92
+ isValid(date) {
93
+ return this.clone(date).isValid();
94
+ }
95
+ invalid() {
96
+ return moment.invalid();
97
+ }
98
+ isDateInstance(obj) {
99
+ return moment.isMoment(obj);
100
+ }
101
+ addCalendarYears(date, amount) {
102
+ return this.clone(date).add({ years: amount });
103
+ }
104
+ addCalendarMonths(date, amount) {
105
+ return this.clone(date).add({ months: amount });
106
+ }
107
+ addCalendarDays(date, amount) {
108
+ return this.clone(date).add({ days: amount });
109
+ }
110
+ setHours(date, amount) {
111
+ return this.clone(date).hours(amount);
112
+ }
113
+ setMinutes(date, amount) {
114
+ return this.clone(date).minutes(amount);
115
+ }
116
+ setSeconds(date, amount) {
117
+ return this.clone(date).seconds(amount);
118
+ }
119
+ createDate(year, month, date, hours = 0, minutes = 0, seconds = 0) {
120
+ if (month < 0 || month > 11) throw Error(`Invalid month index "${month}". Month index has to be between 0 and 11.`);
121
+ if (date < 1) throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
122
+ if (hours < 0 || hours > 23) throw Error(`Invalid hours "${hours}". Hours has to be between 0 and 23.`);
123
+ if (minutes < 0 || minutes > 59) throw Error(`Invalid minutes "${minutes}". Minutes has to between 0 and 59.`);
124
+ if (seconds < 0 || seconds > 59) throw Error(`Invalid seconds "${seconds}". Seconds has to be between 0 and 59.`);
125
+ const result = this.createMoment({
126
+ year,
127
+ month,
128
+ date,
129
+ hours,
130
+ minutes,
131
+ seconds
132
+ }).locale(this.locale());
133
+ if (!result.isValid()) throw Error(`Invalid date "${date}" for month with index "${month}".`);
134
+ return result;
135
+ }
136
+ clone(date) {
137
+ return this.createMoment(date).clone().locale(this.locale());
138
+ }
139
+ now() {
140
+ return this.createMoment().locale(this.locale());
141
+ }
142
+ format(date, displayFormat) {
143
+ date = this.clone(date);
144
+ if (!this.isValid(date)) throw Error("MomentDateTimeAdapter: Cannot format invalid date.");
145
+ return date.format(displayFormat);
146
+ }
147
+ parse(value, parseFormat) {
148
+ if (value && typeof value === "string") return this.createMoment(value, parseFormat, this.locale());
149
+ return value ? this.createMoment(value).locale(this.locale()) : void 0;
150
+ }
151
+ deserialize(value) {
152
+ let date;
153
+ if (value instanceof Date) date = this.createMoment(value);
154
+ if (typeof value === "string") {
155
+ if (!value) return;
156
+ date = this.createMoment(value, moment.ISO_8601).locale(this.locale());
157
+ }
158
+ if (date && this.isValid(date)) return date;
159
+ return super.deserialize(value);
160
+ }
161
+ createMoment(...args) {
162
+ return this.options && this.options.useUtc ? moment.utc(...args) : moment(...args);
163
+ }
164
+ static {
165
+ this.ɵfac = i0.ɵɵngDeclareFactory({
166
+ minVersion: "12.0.0",
167
+ version: "22.2.5",
168
+ ngImport: i0,
169
+ type: MomentDateTimeAdapter,
170
+ deps: [],
171
+ target: i0.ɵɵFactoryTarget.Injectable
172
+ });
173
+ }
174
+ static {
175
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
176
+ minVersion: "12.0.0",
177
+ version: "22.2.5",
178
+ ngImport: i0,
179
+ type: MomentDateTimeAdapter
180
+ });
181
+ }
182
+ };
183
+ i0.ɵɵngDeclareClassMetadata({
184
+ minVersion: "12.0.0",
185
+ version: "22.2.5",
186
+ ngImport: i0,
187
+ type: MomentDateTimeAdapter,
188
+ decorators: [{ type: Injectable }],
189
+ ctorParameters: () => []
190
+ });
216
191
  const NXT_MOMENT_DATE_TIME_FORMATS = {
217
- parseInput: 'l LT',
218
- fullPickerInput: 'l LT',
219
- datePickerInput: 'l',
220
- timePickerInput: 'LT',
221
- monthYearLabel: 'MMM YYYY',
222
- dateA11yLabel: 'LL',
223
- monthYearA11yLabel: 'MMMM YYYY'
192
+ parseInput: "l LT",
193
+ fullPickerInput: "l LT",
194
+ datePickerInput: "l",
195
+ timePickerInput: "LT",
196
+ monthYearLabel: "MMM YYYY",
197
+ dateA11yLabel: "LL",
198
+ monthYearA11yLabel: "MMMM YYYY"
224
199
  };
225
-
226
200
  function provideMomentDateTimeAdapter() {
227
- return [
228
- {
229
- provide: DateTimeAdapter,
230
- useClass: MomentDateTimeAdapter,
231
- deps: [LOCALE_ID, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS]
232
- },
233
- {
234
- provide: NXT_DATE_TIME_FORMATS,
235
- useValue: NXT_MOMENT_DATE_TIME_FORMATS
236
- }
237
- ];
201
+ return [{
202
+ provide: DateTimeAdapter,
203
+ useClass: MomentDateTimeAdapter,
204
+ deps: [LOCALE_ID, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS]
205
+ }, {
206
+ provide: NXT_DATE_TIME_FORMATS,
207
+ useValue: NXT_MOMENT_DATE_TIME_FORMATS
208
+ }];
238
209
  }
239
-
240
- /**
241
- * Generated bundle index. Do not edit.
242
- */
243
-
244
210
  export { NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS, provideMomentDateTimeAdapter };
245
- //# sourceMappingURL=nxt-pick-datetime-moment-adapter.mjs.map
211
+
212
+ //# sourceMappingURL=nxt-pick-datetime-moment-adapter.mjs.map
@@ -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/public-api.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","export { MomentDateTimeAdapterOptions, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS } from './date-time-adapter.class'\nimport { LOCALE_ID, Provider } from '@angular/core'\nimport { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from 'nxt-pick-datetime'\nimport { MomentDateTimeAdapter, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS } from './date-time-adapter.class'\nimport { NXT_MOMENT_DATE_TIME_FORMATS } from './date-time-format.class'\n\nexport function provideMomentDateTimeAdapter(): Provider[] {\n return [\n {\n provide: DateTimeAdapter,\n useClass: MomentDateTimeAdapter,\n deps: [LOCALE_ID, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS]\n },\n {\n provide: NXT_DATE_TIME_FORMATS,\n useValue: NXT_MOMENT_DATE_TIME_FORMATS\n }\n ]\n}\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,OAAO,EAAE;AACZ,CAAA;AAED;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,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC7B,WAAW,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IACrC;AACA,IAAA,OAAO,WAAW;AACtB;AAGM,MAAO,qBAAsB,SAAQ,eAAuB,CAAA;AAY9D,IAAA,WAAA,GAAA;AACI,QAAA,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAE5D,QAAA,KAAK,EAAE;QAdM,IAAA,CAAA,OAAO,GAAG,MAAM,CAAC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CD;;AAEG;AACI,MAAM,4BAA4B,GAAoB;AACzD,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,eAAe,EAAE,MAAM;AACvB,IAAA,eAAe,EAAE,GAAG;AACpB,IAAA,eAAe,EAAE,IAAI;AACrB,IAAA,cAAc,EAAE,UAAU;AAC1B,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,kBAAkB,EAAE;CACvB;;SCPe,4BAA4B,GAAA;IACxC,OAAO;AACH,QAAA;AACI,YAAA,OAAO,EAAE,eAAe;AACxB,YAAA,QAAQ,EAAE,qBAAqB;AAC/B,YAAA,IAAI,EAAE,CAAC,SAAS,EAAE,oCAAoC;AACzD,SAAA;AACD,QAAA;AACI,YAAA,OAAO,EAAE,qBAAqB;AAC9B,YAAA,QAAQ,EAAE;AACb;KACJ;AACL;;AClBA;;AAEG;;;;"}
1
+ {"version":3,"file":"nxt-pick-datetime-moment-adapter.mjs","names":[],"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/public-api.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","export { MomentDateTimeAdapterOptions, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS } from './date-time-adapter.class'\nimport { LOCALE_ID, Provider } from '@angular/core'\nimport { DateTimeAdapter, NXT_DATE_TIME_FORMATS } from 'nxt-pick-datetime'\nimport { MomentDateTimeAdapter, NXT_MOMENT_DATE_TIME_ADAPTER_OPTIONS } from './date-time-adapter.class'\nimport { NXT_MOMENT_DATE_TIME_FORMATS } from './date-time-format.class'\n\nexport function provideMomentDateTimeAdapter(): Provider[] {\n return [\n {\n provide: DateTimeAdapter,\n useClass: MomentDateTimeAd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