@imihai/angular-datetime-picker 22.0.0 → 22.0.6
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/assets/style/picker.min.css +1 -0
- package/fesm2022/imihai-angular-datetime-picker.mjs +5843 -0
- package/fesm2022/imihai-angular-datetime-picker.mjs.map +1 -0
- package/imihai-angular-datetime-picker-22.0.6.tgz +0 -0
- package/package.json +34 -77
- package/types/imihai-angular-datetime-picker.d.ts +2193 -0
- package/.browserslistrc +0 -9
- package/.editorconfig +0 -13
- package/.eslintrc.js +0 -208
- package/.github/workflows/ci_test.yml +0 -35
- package/.prettierrc +0 -2
- package/.travis.yml +0 -16
- package/angular.json +0 -221
- package/e2e/protractor.conf.js +0 -28
- package/e2e/src/app.e2e-spec.ts +0 -14
- package/e2e/src/app.po.ts +0 -11
- package/e2e/tsconfig.e2e.json +0 -13
- package/projects/picker/karma.conf.js +0 -62
- package/projects/picker/ng-package.json +0 -7
- package/projects/picker/package.json +0 -23
- package/projects/picker/src/lib/date-time/adapter/date-time-adapter.class.ts +0 -313
- package/projects/picker/src/lib/date-time/adapter/date-time-format.class.ts +0 -18
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-adapter.class.ts +0 -307
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-format.class.ts +0 -11
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time.module.ts +0 -31
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-adapter.class.ts +0 -356
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-format.class.ts +0 -14
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time.module.ts +0 -26
- package/projects/picker/src/lib/date-time/calendar-body.component.html +0 -38
- package/projects/picker/src/lib/date-time/calendar-body.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.spec.ts +0 -120
- package/projects/picker/src/lib/date-time/calendar-body.component.ts +0 -190
- package/projects/picker/src/lib/date-time/calendar-month-view.component.html +0 -47
- package/projects/picker/src/lib/date-time/calendar-month-view.component.scss +0 -16
- package/projects/picker/src/lib/date-time/calendar-month-view.component.spec.ts +0 -394
- package/projects/picker/src/lib/date-time/calendar-month-view.component.ts +0 -705
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.html +0 -44
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.spec.ts +0 -343
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.ts +0 -465
- package/projects/picker/src/lib/date-time/calendar-year-view.component.html +0 -16
- package/projects/picker/src/lib/date-time/calendar-year-view.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.spec.ts +0 -381
- package/projects/picker/src/lib/date-time/calendar-year-view.component.ts +0 -549
- package/projects/picker/src/lib/date-time/calendar.component.html +0 -169
- package/projects/picker/src/lib/date-time/calendar.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar.component.spec.ts +0 -592
- package/projects/picker/src/lib/date-time/calendar.component.ts +0 -496
- package/projects/picker/src/lib/date-time/date-time-inline.component.html +0 -1
- package/projects/picker/src/lib/date-time/date-time-inline.component.scss +0 -4
- package/projects/picker/src/lib/date-time/date-time-inline.component.ts +0 -365
- package/projects/picker/src/lib/date-time/date-time-picker-animation-event.ts +0 -4
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.html +0 -126
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.scss +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.ts +0 -631
- package/projects/picker/src/lib/date-time/date-time-picker-input.directive.ts +0 -851
- package/projects/picker/src/lib/date-time/date-time-picker-intl.service.ts +0 -76
- package/projects/picker/src/lib/date-time/date-time-picker-trigger.directive.ts +0 -88
- package/projects/picker/src/lib/date-time/date-time-picker.component.html +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.scss +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.spec.ts +0 -2648
- package/projects/picker/src/lib/date-time/date-time-picker.component.ts +0 -731
- package/projects/picker/src/lib/date-time/date-time.class.ts +0 -256
- package/projects/picker/src/lib/date-time/date-time.module.ts +0 -61
- package/projects/picker/src/lib/date-time/numberedFixLen.pipe.ts +0 -28
- package/projects/picker/src/lib/date-time/options-provider.ts +0 -44
- package/projects/picker/src/lib/date-time/timer-box.component.html +0 -79
- package/projects/picker/src/lib/date-time/timer-box.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer-box.component.ts +0 -175
- package/projects/picker/src/lib/date-time/timer.component.html +0 -58
- package/projects/picker/src/lib/date-time/timer.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer.component.spec.ts +0 -399
- package/projects/picker/src/lib/date-time/timer.component.ts +0 -371
- package/projects/picker/src/lib/dialog/dialog-config.class.ts +0 -220
- package/projects/picker/src/lib/dialog/dialog-container.component.html +0 -1
- package/projects/picker/src/lib/dialog/dialog-container.component.scss +0 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.ts +0 -231
- package/projects/picker/src/lib/dialog/dialog-ref.class.ts +0 -178
- package/projects/picker/src/lib/dialog/dialog.module.ts +0 -25
- package/projects/picker/src/lib/dialog/dialog.service.ts +0 -353
- package/projects/picker/src/lib/utils/array.utils.ts +0 -12
- package/projects/picker/src/lib/utils/constants.ts +0 -59
- package/projects/picker/src/lib/utils/date.utils.ts +0 -97
- package/projects/picker/src/lib/utils/index.ts +0 -5
- package/projects/picker/src/lib/utils/object.utils.ts +0 -29
- package/projects/picker/src/public_api.ts +0 -56
- package/projects/picker/src/sass/picker.scss +0 -743
- package/projects/picker/src/test-helpers.ts +0 -125
- package/projects/picker/src/test.ts +0 -52
- package/projects/picker/tsconfig.lib.json +0 -19
- package/projects/picker/tsconfig.lib.prod.json +0 -7
- package/projects/picker/tsconfig.spec.json +0 -17
- package/projects/picker/tslint.json +0 -8
- package/src/app/app.component.html +0 -77
- package/src/app/app.component.scss +0 -32
- package/src/app/app.component.spec.ts +0 -16
- package/src/app/app.component.ts +0 -35
- package/src/assets/.gitkeep +0 -0
- package/src/environments/environment.prod.ts +0 -3
- package/src/environments/environment.ts +0 -16
- package/src/favicon.ico +0 -0
- package/src/index.html +0 -14
- package/src/karma.conf.js +0 -31
- package/src/main.ts +0 -16
- package/src/polyfills.ts +0 -53
- package/src/styles.scss +0 -7
- package/src/test.ts +0 -50
- package/src/tsconfig.app.json +0 -16
- package/src/tsconfig.spec.json +0 -18
- package/src/tslint.json +0 -17
- package/tsconfig.base.json +0 -31
- package/tsconfig.json +0 -30
- package/tslint.json +0 -130
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* unix-timestamp-date-time-adapter.class
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Inject, Injectable, Optional } from '@angular/core';
|
|
6
|
-
import { DateTime, Info, Settings } from 'luxon';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
DateTimeAdapter,
|
|
10
|
-
OWL_DATE_TIME_LOCALE,
|
|
11
|
-
} from '../date-time-adapter.class';
|
|
12
|
-
|
|
13
|
-
@Injectable()
|
|
14
|
-
export class UnixTimestampDateTimeAdapter extends DateTimeAdapter<number> {
|
|
15
|
-
public firstMonthOfTheYear = 0;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Picker expects:
|
|
19
|
-
* 0 - Sunday
|
|
20
|
-
* 1 - Monday
|
|
21
|
-
* ...
|
|
22
|
-
* 6 - Saturday
|
|
23
|
-
*/
|
|
24
|
-
public firstDayOfTheWeek = 0;
|
|
25
|
-
|
|
26
|
-
public constructor(
|
|
27
|
-
@Optional()
|
|
28
|
-
@Inject(OWL_DATE_TIME_LOCALE)
|
|
29
|
-
private owlDateTimeLocale: string,
|
|
30
|
-
) {
|
|
31
|
-
super();
|
|
32
|
-
|
|
33
|
-
this.setLocale(owlDateTimeLocale || Settings.defaultLocale || 'ru');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public getYear(date: number): number {
|
|
37
|
-
return this.fromTimestamp(date).year;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Picker expects:
|
|
42
|
-
* 0 - January
|
|
43
|
-
* 11 - December
|
|
44
|
-
*
|
|
45
|
-
* Luxon uses:
|
|
46
|
-
* 1 - January
|
|
47
|
-
* 12 - December
|
|
48
|
-
*/
|
|
49
|
-
public getMonth(date: number): number {
|
|
50
|
-
return this.fromTimestamp(date).month - 1;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Picker expects:
|
|
55
|
-
* 0 - Sunday
|
|
56
|
-
* 6 - Saturday
|
|
57
|
-
*
|
|
58
|
-
* Luxon weekday:
|
|
59
|
-
* 1 - Monday
|
|
60
|
-
* 7 - Sunday
|
|
61
|
-
*/
|
|
62
|
-
public getDay(date: number): number {
|
|
63
|
-
return this.fromTimestamp(date).weekday % 7;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public getDate(date: number): number {
|
|
67
|
-
return this.fromTimestamp(date).day;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public getHours(date: number): number {
|
|
71
|
-
return this.fromTimestamp(date).hour;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public getMinutes(date: number): number {
|
|
75
|
-
return this.fromTimestamp(date).minute;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public getSeconds(date: number): number {
|
|
79
|
-
return this.fromTimestamp(date).second;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
public getTime(date: number): number {
|
|
83
|
-
return date;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public getNumDaysInMonth(date: number): number {
|
|
87
|
-
return this.fromTimestamp(date).daysInMonth ?? 0;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public differenceInCalendarDays(dateLeft: number, dateRight: number): number {
|
|
91
|
-
if (!this.isValid(dateLeft) || !this.isValid(dateRight)) {
|
|
92
|
-
return Number.NaN;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return Math.round(
|
|
96
|
-
this.fromTimestamp(dateLeft)
|
|
97
|
-
.startOf('day')
|
|
98
|
-
.diff(this.fromTimestamp(dateRight).startOf('day'), 'days').days,
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public getYearName(date: number): string {
|
|
103
|
-
return this.fromTimestamp(date).toFormat('yyyy');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public getMonthNames(style: 'long' | 'short' | 'narrow'): string[] {
|
|
107
|
-
return Info.months(style, { locale: this.locale });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] {
|
|
111
|
-
const weekdays = Info.weekdays(style, { locale: this.locale });
|
|
112
|
-
|
|
113
|
-
// Luxon returns Monday..Sunday.
|
|
114
|
-
// Existing picker expects Sunday..Saturday.
|
|
115
|
-
return [
|
|
116
|
-
weekdays[6],
|
|
117
|
-
...weekdays.slice(0, 6),
|
|
118
|
-
];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public getDateNames(): string[] {
|
|
122
|
-
return Array.from({ length: 31 }, (_, index) => `${index + 1}`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
public toIso8601(date: number): string {
|
|
126
|
-
return this.fromTimestamp(date).toISO() ?? '';
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
public isEqual(dateLeft: number, dateRight: number): boolean {
|
|
130
|
-
if (!this.isValid(dateLeft) || !this.isValid(dateRight)) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return dateLeft === dateRight;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
public isSameDay(dateLeft: number, dateRight: number): boolean {
|
|
138
|
-
if (!this.isValid(dateLeft) || !this.isValid(dateRight)) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return this.fromTimestamp(dateLeft).hasSame(
|
|
143
|
-
this.fromTimestamp(dateRight),
|
|
144
|
-
'day',
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public isValid(date: number): boolean {
|
|
149
|
-
return typeof date === 'number' && !Number.isNaN(date);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public invalid(): number {
|
|
153
|
-
return NaN;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
public isDateInstance(obj: unknown): boolean {
|
|
157
|
-
return typeof obj === 'number';
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
public addCalendarYears(date: number, amount: number): number {
|
|
161
|
-
return this.fromTimestamp(date)
|
|
162
|
-
.plus({ years: Number(amount) })
|
|
163
|
-
.toMillis();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
public addCalendarMonths(date: number, amount: number): number {
|
|
167
|
-
return this.fromTimestamp(date)
|
|
168
|
-
.plus({ months: Number(amount) })
|
|
169
|
-
.toMillis();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
public addCalendarDays(date: number, amount: number): number {
|
|
173
|
-
return this.fromTimestamp(date)
|
|
174
|
-
.plus({ days: Number(amount) })
|
|
175
|
-
.toMillis();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
public setHours(date: number, amount: number): number {
|
|
179
|
-
return this.fromTimestamp(date)
|
|
180
|
-
.set({ hour: amount })
|
|
181
|
-
.toMillis();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
public setMinutes(date: number, amount: number): number {
|
|
185
|
-
return this.fromTimestamp(date)
|
|
186
|
-
.set({ minute: amount })
|
|
187
|
-
.toMillis();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
public setSeconds(date: number, amount: number): number {
|
|
191
|
-
return this.fromTimestamp(date)
|
|
192
|
-
.set({ second: amount })
|
|
193
|
-
.toMillis();
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
public createDate(
|
|
197
|
-
year: number,
|
|
198
|
-
month: number,
|
|
199
|
-
date: number,
|
|
200
|
-
hours = 0,
|
|
201
|
-
minutes = 0,
|
|
202
|
-
seconds = 0,
|
|
203
|
-
): number {
|
|
204
|
-
const result = DateTime.local(
|
|
205
|
-
year,
|
|
206
|
-
month + 1,
|
|
207
|
-
date,
|
|
208
|
-
hours,
|
|
209
|
-
minutes,
|
|
210
|
-
seconds,
|
|
211
|
-
0,
|
|
212
|
-
).setLocale(this.locale);
|
|
213
|
-
|
|
214
|
-
if (!result.isValid) {
|
|
215
|
-
throw Error(
|
|
216
|
-
`UnixTimestampDateTimeAdapter: Invalid date "${date}" for month with index "${month}".`,
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return result.toMillis();
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
public clone(date: number): number {
|
|
224
|
-
return date;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
public now(): number {
|
|
228
|
-
return DateTime.local()
|
|
229
|
-
.setLocale(this.locale)
|
|
230
|
-
.toMillis();
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Hybrid formatter:
|
|
235
|
-
* - string => Luxon format, e.g. 'dd.MM.yyyy HH:mm'
|
|
236
|
-
* - Intl.DateTimeFormatOptions => old adapter-compatible formatting
|
|
237
|
-
*/
|
|
238
|
-
public format(
|
|
239
|
-
date: number,
|
|
240
|
-
displayFormat: string | Intl.DateTimeFormatOptions,
|
|
241
|
-
): string {
|
|
242
|
-
if (!this.isValid(date)) {
|
|
243
|
-
throw Error('UnixTimestampDateTimeAdapter: Cannot format invalid date.');
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const dt = this.fromTimestamp(date);
|
|
247
|
-
|
|
248
|
-
if (typeof displayFormat === 'string') {
|
|
249
|
-
return dt.toFormat(displayFormat);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
return this.stripDirectionalityCharacters(
|
|
253
|
-
dt.toJSDate().toLocaleDateString(this.locale, displayFormat),
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
public parse(value: unknown, parseFormat: string | string[] | null): number | null {
|
|
258
|
-
if (value == null || value === '') {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (typeof value === 'number') {
|
|
263
|
-
return this.isValid(value) ? value : this.invalid();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (value instanceof Date) {
|
|
267
|
-
const date = DateTime.fromJSDate(value).setLocale(this.locale);
|
|
268
|
-
|
|
269
|
-
return date.isValid ? date.toMillis() : this.invalid();
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (DateTime.isDateTime(value)) {
|
|
273
|
-
return value.isValid
|
|
274
|
-
? value.setLocale(this.locale).toMillis()
|
|
275
|
-
: this.invalid();
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (typeof value !== 'string') {
|
|
279
|
-
return this.invalid();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (parseFormat) {
|
|
283
|
-
const formats = Array.isArray(parseFormat) ? parseFormat : [parseFormat];
|
|
284
|
-
|
|
285
|
-
for (const format of formats) {
|
|
286
|
-
if (typeof format !== 'string') {
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const parsed = DateTime.fromFormat(value, format, {
|
|
291
|
-
locale: this.locale,
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
if (parsed.isValid) {
|
|
295
|
-
return parsed.toMillis();
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const iso = DateTime.fromISO(value, {
|
|
301
|
-
locale: this.locale,
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
if (iso.isValid) {
|
|
305
|
-
return iso.toMillis();
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const jsDate = DateTime.fromJSDate(new Date(value)).setLocale(this.locale);
|
|
309
|
-
|
|
310
|
-
return jsDate.isValid ? jsDate.toMillis() : this.invalid();
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
public override deserialize(value: unknown): number | null {
|
|
314
|
-
if (value == null || value === '') {
|
|
315
|
-
return null;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
if (typeof value === 'number') {
|
|
319
|
-
return this.isValid(value) ? value : this.invalid();
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (value instanceof Date) {
|
|
323
|
-
const date = DateTime.fromJSDate(value).setLocale(this.locale);
|
|
324
|
-
|
|
325
|
-
return date.isValid ? date.toMillis() : this.invalid();
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (DateTime.isDateTime(value)) {
|
|
329
|
-
return value.isValid
|
|
330
|
-
? value.setLocale(this.locale).toMillis()
|
|
331
|
-
: this.invalid();
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
if (typeof value === 'string') {
|
|
335
|
-
const date = DateTime.fromISO(value, {
|
|
336
|
-
locale: this.locale,
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
return date.isValid ? date.toMillis() : this.invalid();
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
return this.invalid();
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
public override setLocale(locale: string): void {
|
|
346
|
-
super.setLocale(locale || 'ru');
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
private fromTimestamp(timestamp: number): DateTime {
|
|
350
|
-
return DateTime.fromMillis(timestamp).setLocale(this.locale);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
private stripDirectionalityCharacters(value: string): string {
|
|
354
|
-
return value.replace(/[\u200e\u200f]/g, '');
|
|
355
|
-
}
|
|
356
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* unix-timestamp-date-time-format.class
|
|
3
|
-
*/
|
|
4
|
-
import {OwlDateTimeFormats} from '../date-time-format.class';
|
|
5
|
-
|
|
6
|
-
export const OWL_UNIX_TIMESTAMP_DATE_TIME_FORMATS: OwlDateTimeFormats = {
|
|
7
|
-
parseInput: null,
|
|
8
|
-
fullPickerInput: {year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric'},
|
|
9
|
-
datePickerInput: {year: 'numeric', month: 'numeric', day: 'numeric'},
|
|
10
|
-
timePickerInput: {hour: 'numeric', minute: 'numeric'},
|
|
11
|
-
monthYearLabel: {year: 'numeric', month: 'short'},
|
|
12
|
-
dateA11yLabel: {year: 'numeric', month: 'long', day: 'numeric'},
|
|
13
|
-
monthYearA11yLabel: {year: 'numeric', month: 'long'},
|
|
14
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* unix-timestamp-date-time.module
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {NgModule} from '@angular/core';
|
|
6
|
-
import {PlatformModule} from '@angular/cdk/platform';
|
|
7
|
-
import {DateTimeAdapter} from '../date-time-adapter.class';
|
|
8
|
-
import {OWL_DATE_TIME_FORMATS} from '../date-time-format.class';
|
|
9
|
-
import {UnixTimestampDateTimeAdapter} from './unix-timestamp-date-time-adapter.class';
|
|
10
|
-
import {OWL_UNIX_TIMESTAMP_DATE_TIME_FORMATS} from './unix-timestamp-date-time-format.class';
|
|
11
|
-
|
|
12
|
-
@NgModule({
|
|
13
|
-
imports: [PlatformModule],
|
|
14
|
-
providers: [
|
|
15
|
-
{provide: DateTimeAdapter, useClass: UnixTimestampDateTimeAdapter},
|
|
16
|
-
],
|
|
17
|
-
})
|
|
18
|
-
export class UnixTimestampDateTimeModule {
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@NgModule({
|
|
22
|
-
imports: [UnixTimestampDateTimeModule],
|
|
23
|
-
providers: [{provide: OWL_DATE_TIME_FORMATS, useValue: OWL_UNIX_TIMESTAMP_DATE_TIME_FORMATS}],
|
|
24
|
-
})
|
|
25
|
-
export class OwlUnixTimestampDateTimeModule {
|
|
26
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
@for (row of rows; track $index; let rowIndex = $index) {
|
|
2
|
-
<tr role="row">
|
|
3
|
-
@for (item of row; track $index; let colIndex = $index) {
|
|
4
|
-
<td
|
|
5
|
-
class="owl-dt-calendar-cell {{ item.cellClass }}"
|
|
6
|
-
[tabindex]="isActiveCell(rowIndex, colIndex) ? 0 : -1"
|
|
7
|
-
[class.owl-dt-calendar-cell-active]="
|
|
8
|
-
isActiveCell(rowIndex, colIndex)
|
|
9
|
-
"
|
|
10
|
-
[class.owl-dt-calendar-cell-disabled]="!item.enabled"
|
|
11
|
-
[class.owl-dt-calendar-cell-in-range]="isInRange(item.value)"
|
|
12
|
-
[class.owl-dt-calendar-cell-range-from]="
|
|
13
|
-
isRangeFrom(item.value)
|
|
14
|
-
"
|
|
15
|
-
[class.owl-dt-calendar-cell-range-to]="isRangeTo(item.value)"
|
|
16
|
-
[attr.aria-label]="item.ariaLabel"
|
|
17
|
-
[attr.aria-disabled]="!item.enabled || null"
|
|
18
|
-
[attr.aria-current]="item.value === todayValue ? 'date' : null"
|
|
19
|
-
[attr.aria-selected]="isSelected(item.value)"
|
|
20
|
-
[style.width.%]="100 / numCols"
|
|
21
|
-
[style.paddingTop.%]="(50 * cellRatio) / numCols"
|
|
22
|
-
[style.paddingBottom.%]="(50 * cellRatio) / numCols"
|
|
23
|
-
(click)="selectCell(item)"
|
|
24
|
-
>
|
|
25
|
-
<span
|
|
26
|
-
class="owl-dt-calendar-cell-content"
|
|
27
|
-
[ngClass]="{
|
|
28
|
-
'owl-dt-calendar-cell-out': item.out,
|
|
29
|
-
'owl-dt-calendar-cell-today': item.value === todayValue,
|
|
30
|
-
'owl-dt-calendar-cell-selected': isSelected(item.value),
|
|
31
|
-
}"
|
|
32
|
-
>
|
|
33
|
-
{{ item.displayValue }}
|
|
34
|
-
</span>
|
|
35
|
-
</td>
|
|
36
|
-
}
|
|
37
|
-
</tr>
|
|
38
|
-
}
|
|
File without changes
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* calendar-body.component.spec
|
|
3
|
-
*/
|
|
4
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
5
|
-
import { CalendarCell, OwlCalendarBodyComponent } from './calendar-body.component';
|
|
6
|
-
import { Component } from '@angular/core';
|
|
7
|
-
import { By } from '@angular/platform-browser';
|
|
8
|
-
|
|
9
|
-
describe('OwlCalendarBodyComponent', () => {
|
|
10
|
-
beforeEach((() => {
|
|
11
|
-
TestBed.configureTestingModule({
|
|
12
|
-
declarations: [
|
|
13
|
-
OwlCalendarBodyComponent,
|
|
14
|
-
|
|
15
|
-
// Test components
|
|
16
|
-
StandardCalendarBodyComponent,
|
|
17
|
-
],
|
|
18
|
-
}).compileComponents();
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
describe('standard CalendarBodyComponent', () => {
|
|
22
|
-
let fixture: ComponentFixture<StandardCalendarBodyComponent>;
|
|
23
|
-
let testComponent: StandardCalendarBodyComponent;
|
|
24
|
-
let calendarBodyNativeElement: Element;
|
|
25
|
-
let rowEls: NodeListOf<Element>;
|
|
26
|
-
let cellEls: NodeListOf<Element>;
|
|
27
|
-
|
|
28
|
-
const refreshElementLists = () => {
|
|
29
|
-
rowEls = calendarBodyNativeElement.querySelectorAll('tr');
|
|
30
|
-
cellEls = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell');
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
fixture = TestBed.createComponent(StandardCalendarBodyComponent);
|
|
35
|
-
fixture.detectChanges();
|
|
36
|
-
|
|
37
|
-
const calendarBodyDebugElement = fixture.debugElement.query(By.directive(OwlCalendarBodyComponent));
|
|
38
|
-
calendarBodyNativeElement = calendarBodyDebugElement.nativeElement;
|
|
39
|
-
testComponent = fixture.componentInstance;
|
|
40
|
-
|
|
41
|
-
refreshElementLists();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should create body', () => {
|
|
45
|
-
expect(rowEls.length).toBe(2);
|
|
46
|
-
expect(cellEls.length).toBe(14);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should highlight today', () => {
|
|
50
|
-
const todayCell = calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-today');
|
|
51
|
-
expect(todayCell).not.toBeNull();
|
|
52
|
-
expect(todayCell.innerHTML.trim()).toBe('3');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should highlight selected', () => {
|
|
56
|
-
const selectedCell = calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-selected');
|
|
57
|
-
expect(selectedCell).not.toBeNull();
|
|
58
|
-
expect(selectedCell.innerHTML.trim()).toBe('4');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('cell should be selected on click', () => {
|
|
62
|
-
spyOn(testComponent, 'handleSelect');
|
|
63
|
-
expect(testComponent.handleSelect).not.toHaveBeenCalled();
|
|
64
|
-
const todayElement =
|
|
65
|
-
calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-today') as HTMLElement;
|
|
66
|
-
todayElement.click();
|
|
67
|
-
fixture.detectChanges();
|
|
68
|
-
|
|
69
|
-
expect(testComponent.handleSelect).toHaveBeenCalled();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should mark active date', () => {
|
|
73
|
-
expect((cellEls[10] as HTMLElement).innerText.trim()).toBe('11');
|
|
74
|
-
expect(cellEls[10].classList).toContain('owl-dt-calendar-cell-active');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should have aria-current set for today', () => {
|
|
78
|
-
const currentCells = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell[aria-current]');
|
|
79
|
-
expect(currentCells.length).toBe(1);
|
|
80
|
-
const todayCell = calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-today');
|
|
81
|
-
expect(currentCells[0].getAttribute('aria-current')).toBe('date');
|
|
82
|
-
expect(currentCells[0].firstChild).toBe(todayCell);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should have aria-selected set on selected cells', () => {
|
|
86
|
-
const calendarCells = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell');
|
|
87
|
-
const selectedCells = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell[aria-selected=true]');
|
|
88
|
-
const nonSelectedCells = calendarBodyNativeElement.querySelectorAll('.owl-dt-calendar-cell[aria-selected=false]');
|
|
89
|
-
expect(nonSelectedCells.length).toBe(calendarCells.length - selectedCells.length);
|
|
90
|
-
const selectedCell = calendarBodyNativeElement.querySelector('.owl-dt-calendar-cell-selected');
|
|
91
|
-
expect(selectedCells[0].firstChild).toBe(selectedCell);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
@Component({
|
|
97
|
-
standalone: false,
|
|
98
|
-
template: `
|
|
99
|
-
<table owl-date-time-calendar-body
|
|
100
|
-
[rows]="rows"
|
|
101
|
-
[todayValue]="todayValue"
|
|
102
|
-
[selectedValues]="selectedValues"
|
|
103
|
-
[selectMode]="'single'"
|
|
104
|
-
[activeCell]="activeCell"
|
|
105
|
-
(select)="handleSelect()">
|
|
106
|
-
</table>`,
|
|
107
|
-
})
|
|
108
|
-
class StandardCalendarBodyComponent {
|
|
109
|
-
rows = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14]].map(r => r.map(createCell));
|
|
110
|
-
todayValue = 3;
|
|
111
|
-
selectedValues = [4];
|
|
112
|
-
activeCell = 10;
|
|
113
|
-
|
|
114
|
-
handleSelect() {
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function createCell( value: number ) {
|
|
119
|
-
return new CalendarCell(value, `${value}`, `${value}-label`, true);
|
|
120
|
-
}
|