@imihai/angular-datetime-picker 21.0.0 → 21.0.2

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.
Files changed (115) hide show
  1. package/assets/style/picker.min.css +1 -0
  2. package/fesm2022/imihai-angular-datetime-picker.mjs +5845 -0
  3. package/fesm2022/imihai-angular-datetime-picker.mjs.map +1 -0
  4. package/imihai-angular-datetime-picker-21.0.2.tgz +0 -0
  5. package/package.json +33 -77
  6. package/types/imihai-angular-datetime-picker.d.ts +2193 -0
  7. package/.browserslistrc +0 -9
  8. package/.editorconfig +0 -13
  9. package/.eslintrc.js +0 -208
  10. package/.github/workflows/ci_test.yml +0 -35
  11. package/.prettierrc +0 -2
  12. package/.travis.yml +0 -16
  13. package/LICENSE +0 -22
  14. package/README.md +0 -194
  15. package/angular.json +0 -221
  16. package/e2e/protractor.conf.js +0 -28
  17. package/e2e/src/app.e2e-spec.ts +0 -14
  18. package/e2e/src/app.po.ts +0 -11
  19. package/e2e/tsconfig.e2e.json +0 -13
  20. package/projects/picker/karma.conf.js +0 -62
  21. package/projects/picker/ng-package.json +0 -7
  22. package/projects/picker/package.json +0 -28
  23. package/projects/picker/src/lib/date-time/adapter/date-time-adapter.class.ts +0 -313
  24. package/projects/picker/src/lib/date-time/adapter/date-time-format.class.ts +0 -18
  25. package/projects/picker/src/lib/date-time/adapter/luxon-date-time-adapter.class.ts +0 -307
  26. package/projects/picker/src/lib/date-time/adapter/luxon-date-time-format.class.ts +0 -11
  27. package/projects/picker/src/lib/date-time/adapter/luxon-date-time.module.ts +0 -31
  28. package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-adapter.class.ts +0 -356
  29. package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-format.class.ts +0 -14
  30. package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time.module.ts +0 -26
  31. package/projects/picker/src/lib/date-time/calendar-body.component.html +0 -38
  32. package/projects/picker/src/lib/date-time/calendar-body.component.scss +0 -0
  33. package/projects/picker/src/lib/date-time/calendar-body.component.spec.ts +0 -120
  34. package/projects/picker/src/lib/date-time/calendar-body.component.ts +0 -190
  35. package/projects/picker/src/lib/date-time/calendar-month-view.component.html +0 -47
  36. package/projects/picker/src/lib/date-time/calendar-month-view.component.scss +0 -16
  37. package/projects/picker/src/lib/date-time/calendar-month-view.component.spec.ts +0 -394
  38. package/projects/picker/src/lib/date-time/calendar-month-view.component.ts +0 -705
  39. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.html +0 -44
  40. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.scss +0 -0
  41. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.spec.ts +0 -343
  42. package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.ts +0 -465
  43. package/projects/picker/src/lib/date-time/calendar-year-view.component.html +0 -16
  44. package/projects/picker/src/lib/date-time/calendar-year-view.component.scss +0 -0
  45. package/projects/picker/src/lib/date-time/calendar-year-view.component.spec.ts +0 -381
  46. package/projects/picker/src/lib/date-time/calendar-year-view.component.ts +0 -549
  47. package/projects/picker/src/lib/date-time/calendar.component.html +0 -169
  48. package/projects/picker/src/lib/date-time/calendar.component.scss +0 -0
  49. package/projects/picker/src/lib/date-time/calendar.component.spec.ts +0 -592
  50. package/projects/picker/src/lib/date-time/calendar.component.ts +0 -496
  51. package/projects/picker/src/lib/date-time/date-time-inline.component.html +0 -1
  52. package/projects/picker/src/lib/date-time/date-time-inline.component.scss +0 -4
  53. package/projects/picker/src/lib/date-time/date-time-inline.component.ts +0 -365
  54. package/projects/picker/src/lib/date-time/date-time-picker-animation-event.ts +0 -4
  55. package/projects/picker/src/lib/date-time/date-time-picker-container.component.html +0 -126
  56. package/projects/picker/src/lib/date-time/date-time-picker-container.component.scss +0 -0
  57. package/projects/picker/src/lib/date-time/date-time-picker-container.component.ts +0 -631
  58. package/projects/picker/src/lib/date-time/date-time-picker-input.directive.ts +0 -851
  59. package/projects/picker/src/lib/date-time/date-time-picker-intl.service.ts +0 -76
  60. package/projects/picker/src/lib/date-time/date-time-picker-trigger.directive.ts +0 -88
  61. package/projects/picker/src/lib/date-time/date-time-picker.component.html +0 -0
  62. package/projects/picker/src/lib/date-time/date-time-picker.component.scss +0 -0
  63. package/projects/picker/src/lib/date-time/date-time-picker.component.spec.ts +0 -2648
  64. package/projects/picker/src/lib/date-time/date-time-picker.component.ts +0 -731
  65. package/projects/picker/src/lib/date-time/date-time.class.ts +0 -256
  66. package/projects/picker/src/lib/date-time/date-time.module.ts +0 -61
  67. package/projects/picker/src/lib/date-time/numberedFixLen.pipe.ts +0 -28
  68. package/projects/picker/src/lib/date-time/options-provider.ts +0 -44
  69. package/projects/picker/src/lib/date-time/timer-box.component.html +0 -79
  70. package/projects/picker/src/lib/date-time/timer-box.component.scss +0 -0
  71. package/projects/picker/src/lib/date-time/timer-box.component.ts +0 -175
  72. package/projects/picker/src/lib/date-time/timer.component.html +0 -58
  73. package/projects/picker/src/lib/date-time/timer.component.scss +0 -0
  74. package/projects/picker/src/lib/date-time/timer.component.spec.ts +0 -399
  75. package/projects/picker/src/lib/date-time/timer.component.ts +0 -371
  76. package/projects/picker/src/lib/dialog/dialog-config.class.ts +0 -220
  77. package/projects/picker/src/lib/dialog/dialog-container.component.html +0 -1
  78. package/projects/picker/src/lib/dialog/dialog-container.component.scss +0 -0
  79. package/projects/picker/src/lib/dialog/dialog-container.component.ts +0 -231
  80. package/projects/picker/src/lib/dialog/dialog-ref.class.ts +0 -178
  81. package/projects/picker/src/lib/dialog/dialog.module.ts +0 -25
  82. package/projects/picker/src/lib/dialog/dialog.service.ts +0 -353
  83. package/projects/picker/src/lib/utils/array.utils.ts +0 -12
  84. package/projects/picker/src/lib/utils/constants.ts +0 -59
  85. package/projects/picker/src/lib/utils/date.utils.ts +0 -97
  86. package/projects/picker/src/lib/utils/index.ts +0 -5
  87. package/projects/picker/src/lib/utils/object.utils.ts +0 -29
  88. package/projects/picker/src/public_api.ts +0 -56
  89. package/projects/picker/src/sass/picker.scss +0 -743
  90. package/projects/picker/src/test-helpers.ts +0 -125
  91. package/projects/picker/src/test.ts +0 -52
  92. package/projects/picker/tsconfig.lib.json +0 -18
  93. package/projects/picker/tsconfig.lib.prod.json +0 -7
  94. package/projects/picker/tsconfig.spec.json +0 -17
  95. package/projects/picker/tslint.json +0 -8
  96. package/src/app/app.component.html +0 -77
  97. package/src/app/app.component.scss +0 -32
  98. package/src/app/app.component.spec.ts +0 -16
  99. package/src/app/app.component.ts +0 -35
  100. package/src/assets/.gitkeep +0 -0
  101. package/src/environments/environment.prod.ts +0 -3
  102. package/src/environments/environment.ts +0 -16
  103. package/src/favicon.ico +0 -0
  104. package/src/index.html +0 -14
  105. package/src/karma.conf.js +0 -31
  106. package/src/main.ts +0 -16
  107. package/src/polyfills.ts +0 -53
  108. package/src/styles.scss +0 -7
  109. package/src/test.ts +0 -50
  110. package/src/tsconfig.app.json +0 -16
  111. package/src/tsconfig.spec.json +0 -18
  112. package/src/tslint.json +0 -17
  113. package/tsconfig.base.json +0 -29
  114. package/tsconfig.json +0 -30
  115. package/tslint.json +0 -130
@@ -1,18 +0,0 @@
1
- /**
2
- * date-time-format.class
3
- */
4
-
5
- import { InjectionToken } from '@angular/core';
6
-
7
- export interface OwlDateTimeFormats {
8
- parseInput: any;
9
- fullPickerInput: any;
10
- datePickerInput: any;
11
- timePickerInput: any;
12
- monthYearLabel: any;
13
- dateA11yLabel: any;
14
- monthYearA11yLabel: any;
15
- }
16
-
17
- /** InjectionToken for date time picker that can be used to override default format. */
18
- export const OWL_DATE_TIME_FORMATS = new InjectionToken<OwlDateTimeFormats>('OWL_DATE_TIME_FORMATS');
@@ -1,307 +0,0 @@
1
- /**
2
- * luxon-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 LuxonDateTimeAdapter extends DateTimeAdapter<DateTime> {
15
- public firstMonthOfTheYear = 0;
16
-
17
- /**
18
- * 0 - Sunday
19
- * 1 - Monday
20
- * ...
21
- * 6 - Saturday
22
- */
23
- public firstDayOfTheWeek = 0;
24
-
25
- public constructor(
26
- @Optional()
27
- @Inject(OWL_DATE_TIME_LOCALE)
28
- private owlDateTimeLocale: string,
29
- ) {
30
- super();
31
-
32
- this.setLocale(owlDateTimeLocale || Settings.defaultLocale || 'ru');
33
- }
34
-
35
- public getYear(date: DateTime): number {
36
- return date.year;
37
- }
38
-
39
- /**
40
- * Picker expects month index:
41
- * 0 - January
42
- * 11 - December
43
- *
44
- * Luxon uses:
45
- * 1 - January
46
- * 12 - December
47
- */
48
- public getMonth(date: DateTime): number {
49
- return date.month - 1;
50
- }
51
-
52
- /**
53
- * Picker expects:
54
- * 0 - Sunday
55
- * 6 - Saturday
56
- *
57
- * Luxon weekday:
58
- * 1 - Monday
59
- * 7 - Sunday
60
- */
61
- public getDay(date: DateTime): number {
62
- return date.weekday % 7;
63
- }
64
-
65
- public getDate(date: DateTime): number {
66
- return date.day;
67
- }
68
-
69
- public getHours(date: DateTime): number {
70
- return date.hour;
71
- }
72
-
73
- public getMinutes(date: DateTime): number {
74
- return date.minute;
75
- }
76
-
77
- public getSeconds(date: DateTime): number {
78
- return date.second;
79
- }
80
-
81
- public getTime(date: DateTime): number {
82
- return date.toMillis();
83
- }
84
-
85
- public getNumDaysInMonth(date: DateTime): number {
86
- return date.daysInMonth ?? 0;
87
- }
88
-
89
- public differenceInCalendarDays(dateLeft: DateTime, dateRight: DateTime): number {
90
- if (this.isValid(dateLeft) && this.isValid(dateRight)) {
91
- return Math.round(
92
- dateLeft.startOf('day').diff(dateRight.startOf('day'), 'days').days,
93
- );
94
- }
95
-
96
- return null;
97
- }
98
-
99
- public getYearName(date: DateTime): string {
100
- return date.setLocale(this.locale).toFormat('yyyy');
101
- }
102
-
103
- public getMonthNames(style: 'long' | 'short' | 'narrow'): string[] {
104
- return Info.months(style, { locale: this.locale });
105
- }
106
-
107
- public getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] {
108
- const weekdays = Info.weekdays(style, { locale: this.locale });
109
-
110
- // Luxon returns Monday..Sunday.
111
- // Existing picker expects Sunday..Saturday.
112
- return [
113
- weekdays[6],
114
- ...weekdays.slice(0, 6),
115
- ];
116
- }
117
-
118
- public getDateNames(): string[] {
119
- return Array.from({ length: 31 }, (_, index) => `${index + 1}`);
120
- }
121
-
122
- public toIso8601(date: DateTime): string {
123
- return date.toISO() ?? '';
124
- }
125
-
126
- public isEqual(dateLeft: DateTime, dateRight: DateTime): boolean {
127
- if (this.isValid(dateLeft) && this.isValid(dateRight)) {
128
- return dateLeft.toMillis() === dateRight.toMillis();
129
- }
130
-
131
- return false;
132
- }
133
-
134
- public isSameDay(dateLeft: DateTime, dateRight: DateTime): boolean {
135
- if (this.isValid(dateLeft) && this.isValid(dateRight)) {
136
- return (
137
- dateLeft.year === dateRight.year &&
138
- dateLeft.month === dateRight.month &&
139
- dateLeft.day === dateRight.day
140
- );
141
- }
142
-
143
- return false;
144
- }
145
-
146
- public isValid(date: DateTime): boolean {
147
- return DateTime.isDateTime(date) && date.isValid;
148
- }
149
-
150
- public invalid(): DateTime {
151
- return DateTime.invalid('Invalid date');
152
- }
153
-
154
- public isDateInstance(obj: unknown): boolean {
155
- return DateTime.isDateTime(obj);
156
- }
157
-
158
- public addCalendarYears(date: DateTime, amount: number): DateTime {
159
- return date.plus({ years: Number(amount) });
160
- }
161
-
162
- public addCalendarMonths(date: DateTime, amount: number): DateTime {
163
- return date.plus({ months: Number(amount) });
164
- }
165
-
166
- public addCalendarDays(date: DateTime, amount: number): DateTime {
167
- return date.plus({ days: Number(amount) });
168
- }
169
-
170
- public setHours(date: DateTime, amount: number): DateTime {
171
- return date.set({ hour: amount });
172
- }
173
-
174
- public setMinutes(date: DateTime, amount: number): DateTime {
175
- return date.set({ minute: amount });
176
- }
177
-
178
- public setSeconds(date: DateTime, amount: number): DateTime {
179
- return date.set({ second: amount });
180
- }
181
-
182
- public createDate(
183
- year: number,
184
- month: number,
185
- date: number,
186
- hours = 0,
187
- minutes = 0,
188
- seconds = 0,
189
- ): DateTime {
190
- const result = DateTime.local(
191
- year,
192
- month + 1,
193
- date,
194
- hours,
195
- minutes,
196
- seconds,
197
- 0,
198
- ).setLocale(this.locale);
199
-
200
- if (!result.isValid) {
201
- throw Error(
202
- `LuxonDateTimeAdapter: Invalid date "${date}" for month with index "${month}".`,
203
- );
204
- }
205
-
206
- return result;
207
- }
208
-
209
- public clone(date: DateTime): DateTime {
210
- return DateTime.fromMillis(date.toMillis(), {
211
- zone: date.zone,
212
- locale: date.locale,
213
- });
214
- }
215
-
216
- public now(): DateTime {
217
- return DateTime.local().setLocale(this.locale);
218
- }
219
-
220
- public format(date: DateTime, displayFormat: string): string {
221
- if (!this.isValid(date)) {
222
- throw Error('LuxonDateTimeAdapter: Cannot format invalid date.');
223
- }
224
-
225
- return date.setLocale(this.locale).toFormat(displayFormat);
226
- }
227
-
228
- public parse(value: unknown, parseFormat: string | string[]): DateTime | null {
229
- if (value == null || value === '') {
230
- return null;
231
- }
232
-
233
- if (DateTime.isDateTime(value)) {
234
- return value.isValid ? value.setLocale(this.locale) : this.invalid();
235
- }
236
-
237
- if (value instanceof Date) {
238
- const date = DateTime.fromJSDate(value).setLocale(this.locale);
239
-
240
- return date.isValid ? date : this.invalid();
241
- }
242
-
243
- if (typeof value === 'number') {
244
- const date = DateTime.fromMillis(value).setLocale(this.locale);
245
-
246
- return date.isValid ? date : this.invalid();
247
- }
248
-
249
- if (typeof value !== 'string') {
250
- return this.invalid();
251
- }
252
-
253
- const formats = Array.isArray(parseFormat) ? parseFormat : [parseFormat];
254
-
255
- for (const format of formats) {
256
- const parsed = DateTime.fromFormat(value, format, {
257
- locale: this.locale,
258
- });
259
-
260
- if (parsed.isValid) {
261
- return parsed;
262
- }
263
- }
264
-
265
- const iso = DateTime.fromISO(value, {
266
- locale: this.locale,
267
- });
268
-
269
- return iso.isValid ? iso : this.invalid();
270
- }
271
-
272
- public deserialize(value: unknown): DateTime | null {
273
- if (value == null || value === '') {
274
- return null;
275
- }
276
-
277
- if (DateTime.isDateTime(value)) {
278
- return value.isValid ? value.setLocale(this.locale) : this.invalid();
279
- }
280
-
281
- if (value instanceof Date) {
282
- const date = DateTime.fromJSDate(value).setLocale(this.locale);
283
-
284
- return date.isValid ? date : this.invalid();
285
- }
286
-
287
- if (typeof value === 'number') {
288
- const date = DateTime.fromMillis(value).setLocale(this.locale);
289
-
290
- return date.isValid ? date : this.invalid();
291
- }
292
-
293
- if (typeof value === 'string') {
294
- const date = DateTime.fromISO(value, {
295
- locale: this.locale,
296
- });
297
-
298
- return date.isValid ? date : this.invalid();
299
- }
300
-
301
- return this.invalid();
302
- }
303
-
304
- public override setLocale(locale: string): void {
305
- super.setLocale(locale || 'ru');
306
- }
307
- }
@@ -1,11 +0,0 @@
1
- import { OwlDateTimeFormats } from './date-time-format.class';
2
-
3
- export const OWL_LUXON_DATE_TIME_FORMATS: OwlDateTimeFormats = {
4
- parseInput: 'dd.MM.yyyy HH:mm',
5
- fullPickerInput: 'dd.MM.yyyy HH:mm',
6
- datePickerInput: 'dd.MM.yyyy',
7
- timePickerInput: 'HH:mm',
8
- monthYearLabel: 'LLL yyyy',
9
- dateA11yLabel: 'dd.MM.yyyy',
10
- monthYearA11yLabel: 'LLLL yyyy',
11
- };
@@ -1,31 +0,0 @@
1
- /**
2
- * luxon-date-time.module
3
- */
4
-
5
- import { NgModule } from '@angular/core';
6
-
7
- import { DateTimeAdapter } from './date-time-adapter.class';
8
- import { OWL_DATE_TIME_FORMATS } from './date-time-format.class';
9
- import { LuxonDateTimeAdapter } from './luxon-date-time-adapter.class';
10
- import { OWL_LUXON_DATE_TIME_FORMATS } from './luxon-date-time-format.class';
11
-
12
- @NgModule({
13
- providers: [
14
- {
15
- provide: DateTimeAdapter,
16
- useClass: LuxonDateTimeAdapter,
17
- },
18
- ],
19
- })
20
- export class LuxonDateTimeModule {}
21
-
22
- @NgModule({
23
- imports: [LuxonDateTimeModule],
24
- providers: [
25
- {
26
- provide: OWL_DATE_TIME_FORMATS,
27
- useValue: OWL_LUXON_DATE_TIME_FORMATS,
28
- },
29
- ],
30
- })
31
- export class OwlLuxonDateTimeModule {}