@haiilo/catalyst-angular 10.19.1 → 10.19.3

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,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, EventEmitter, Inject, Output, ContentChild, Directive, HostListener, Self, Optional, Host, SkipSelf, NgModule, Injectable } from '@angular/core';
2
+ import { InjectionToken, Directive, HostListener, Component, ViewEncapsulation, ContentChild, Input, ChangeDetectionStrategy, EventEmitter, Inject, Output, Self, Optional, Host, SkipSelf, NgModule, Injectable } from '@angular/core';
3
3
  import * as i3 from '@haiilo/catalyst';
4
4
  import { catI18nRegistry, catIconRegistry, catNotificationService } from '@haiilo/catalyst';
5
5
  import log from 'loglevel';
@@ -8,10 +8,10 @@ import { DialogModule } from '@angular/cdk/dialog';
8
8
  import * as i1 from '@angular/common';
9
9
  import { CommonModule } from '@angular/common';
10
10
  import { defineCustomElements } from '@haiilo/catalyst/loader';
11
- import { __decorate } from 'tslib';
12
- import { fromEvent } from 'rxjs';
13
11
  import * as i1$2 from '@angular/forms';
14
12
  import { NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
13
+ import { __decorate } from 'tslib';
14
+ import { fromEvent } from 'rxjs';
15
15
 
16
16
  // It is important to declare the InjectionTokens first
17
17
  const CAT_LOG_TOKEN = new InjectionToken('CAT_LOG', {
@@ -31,6 +31,300 @@ const CAT_NOTIFICATION_SERVICE_TOKEN = new InjectionToken('CAT_NOTIFICATION_SERV
31
31
  factory: () => catNotificationService
32
32
  });
33
33
 
34
+ class ValueAccessor {
35
+ constructor(el) {
36
+ this.el = el;
37
+ this.onChange = () => { };
38
+ this.onTouched = () => { };
39
+ }
40
+ writeValue(value) {
41
+ this.el.nativeElement.value = this.lastValue = value == null ? '' : value;
42
+ }
43
+ handleChangeEvent(value) {
44
+ if (value !== this.lastValue) {
45
+ this.lastValue = value;
46
+ this.onChange(value);
47
+ }
48
+ }
49
+ _handleBlurEvent() {
50
+ this.onTouched();
51
+ }
52
+ registerOnChange(fn) {
53
+ this.onChange = fn;
54
+ }
55
+ registerOnTouched(fn) {
56
+ this.onTouched = fn;
57
+ }
58
+ setDisabledState(isDisabled) {
59
+ this.el.nativeElement.disabled = isDisabled;
60
+ }
61
+ }
62
+ ValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
63
+ ValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: ValueAccessor, host: { listeners: { "focusout": "_handleBlurEvent()" } }, ngImport: i0 });
64
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ValueAccessor, decorators: [{
65
+ type: Directive,
66
+ args: [{}]
67
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { _handleBlurEvent: [{
68
+ type: HostListener,
69
+ args: ['focusout']
70
+ }] } });
71
+
72
+ class DateValueAccessor extends ValueAccessor {
73
+ constructor(el) {
74
+ super(el);
75
+ }
76
+ get nativeElement() {
77
+ return this.el.nativeElement;
78
+ }
79
+ writeValue(value) {
80
+ if (!this.el.nativeElement.range) {
81
+ return super.writeValue(this.toISO(value));
82
+ }
83
+ else if (value instanceof Array) {
84
+ const data = [this.toISO(value[0]), this.toISO(value[1])];
85
+ return super.writeValue(JSON.stringify(data));
86
+ }
87
+ return super.writeValue(undefined);
88
+ }
89
+ handleChangeEvent(value) {
90
+ var _a;
91
+ if (!this.el.nativeElement.range) {
92
+ return super.handleChangeEvent(this.toDate(value));
93
+ }
94
+ else if (typeof value === 'string') {
95
+ const data = JSON.parse(value).map(this.toDate);
96
+ (_a = data[1]) === null || _a === void 0 ? void 0 : _a.setHours(23, 59, 59, 999);
97
+ return super.handleChangeEvent(data);
98
+ }
99
+ super.handleChangeEvent(null);
100
+ }
101
+ toISO(value) {
102
+ if (value instanceof Date) {
103
+ const year = value.getFullYear();
104
+ const month = (value.getMonth() + 1).toString().padStart(2, '0');
105
+ const day = value.getDate().toString().padStart(2, '0');
106
+ return `${year}-${month}-${day}`;
107
+ }
108
+ return undefined;
109
+ }
110
+ toDate(value) {
111
+ var _a;
112
+ const [match, year, month, day] = (_a = value === null || value === void 0 ? void 0 : value.match(/^(\d{4})-(\d{2})-(\d{2})/)) !== null && _a !== void 0 ? _a : [];
113
+ return match ? new Date(Number(year), Number(month) - 1, Number(day)) : null;
114
+ }
115
+ }
116
+ DateValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
117
+ DateValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: DateValueAccessor, selector: "cat-date, cat-date-inline", host: { listeners: { "catChange": "handleChangeEvent($event.target.value)" } }, providers: [
118
+ {
119
+ provide: NG_VALUE_ACCESSOR,
120
+ useExisting: DateValueAccessor,
121
+ multi: true
122
+ }
123
+ ], usesInheritance: true, ngImport: i0 });
124
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateValueAccessor, decorators: [{
125
+ type: Directive,
126
+ args: [{
127
+ /* tslint:disable-next-line:directive-selector */
128
+ selector: 'cat-date, cat-date-inline',
129
+ host: {
130
+ '(catChange)': 'handleChangeEvent($event.target.value)'
131
+ },
132
+ providers: [
133
+ {
134
+ provide: NG_VALUE_ACCESSOR,
135
+ useExisting: DateValueAccessor,
136
+ multi: true
137
+ }
138
+ ]
139
+ }]
140
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
141
+
142
+ class TimeValueAccessor extends ValueAccessor {
143
+ constructor(el) {
144
+ super(el);
145
+ }
146
+ get nativeElement() {
147
+ return this.el.nativeElement;
148
+ }
149
+ writeValue(value) {
150
+ if (value && value instanceof Date) {
151
+ const hours = value.getHours().toString().padStart(2, '0');
152
+ const mins = value.getMinutes().toString().padStart(2, '0');
153
+ return super.writeValue(`${hours}:${mins}`);
154
+ }
155
+ return super.writeValue(undefined);
156
+ }
157
+ handleChangeEvent(value) {
158
+ var _a;
159
+ const [match, hours, mins] = (_a = value === null || value === void 0 ? void 0 : value.match(/^(\d{2}):(\d{2})/)) !== null && _a !== void 0 ? _a : [];
160
+ if (match) {
161
+ const date = new Date();
162
+ date.setHours(Number(hours), Number(mins), 0, 0);
163
+ return super.handleChangeEvent(date);
164
+ }
165
+ return super.handleChangeEvent(null);
166
+ }
167
+ }
168
+ TimeValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
169
+ TimeValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: TimeValueAccessor, selector: "cat-time", host: { listeners: { "catChange": "handleChangeEvent($event.target.value)" } }, providers: [
170
+ {
171
+ provide: NG_VALUE_ACCESSOR,
172
+ useExisting: TimeValueAccessor,
173
+ multi: true
174
+ }
175
+ ], usesInheritance: true, ngImport: i0 });
176
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeValueAccessor, decorators: [{
177
+ type: Directive,
178
+ args: [{
179
+ /* tslint:disable-next-line:directive-selector */
180
+ selector: 'cat-time',
181
+ host: {
182
+ '(catChange)': 'handleChangeEvent($event.target.value)'
183
+ },
184
+ providers: [
185
+ {
186
+ provide: NG_VALUE_ACCESSOR,
187
+ useExisting: TimeValueAccessor,
188
+ multi: true
189
+ }
190
+ ]
191
+ }]
192
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
193
+
194
+ class DatetimeComponent {
195
+ get min() {
196
+ var _a;
197
+ return (_a = this._min) !== null && _a !== void 0 ? _a : null;
198
+ }
199
+ set min(value) {
200
+ this._min = value;
201
+ setTimeout(() => {
202
+ var _a;
203
+ const min = value ? this.toLocalISODate(value) : undefined;
204
+ (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.nativeElement.setAttribute('min', min);
205
+ this.limitTime('min');
206
+ });
207
+ }
208
+ get max() {
209
+ var _a;
210
+ return (_a = this._max) !== null && _a !== void 0 ? _a : null;
211
+ }
212
+ set max(value) {
213
+ this._max = value;
214
+ setTimeout(() => {
215
+ var _a;
216
+ const max = value ? this.toLocalISODate(value) : undefined;
217
+ (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.nativeElement.setAttribute('max', max);
218
+ this.limitTime('max');
219
+ });
220
+ }
221
+ ngAfterContentInit() {
222
+ if (!this.dateInput) {
223
+ throw new Error('Missing child element <cat-date></cat-date>');
224
+ }
225
+ if (!this.timeInput) {
226
+ throw new Error('Missing child element <cat-time></cat-time>');
227
+ }
228
+ }
229
+ writeValue(value) {
230
+ this.lastValue = this.lastDateValue = this.lastTimeValue = value;
231
+ setTimeout(() => {
232
+ var _a, _b;
233
+ (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.writeValue(value);
234
+ (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.writeValue(value);
235
+ });
236
+ }
237
+ registerOnChange(fn) {
238
+ setTimeout(() => {
239
+ var _a, _b;
240
+ (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.registerOnChange((value) => {
241
+ this.lastDateValue = value;
242
+ this.limitTime('min');
243
+ this.limitTime('max');
244
+ fn(this.value);
245
+ });
246
+ (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.registerOnChange((value) => {
247
+ this.lastTimeValue = value;
248
+ fn(this.value);
249
+ });
250
+ });
251
+ }
252
+ registerOnTouched(fn) {
253
+ setTimeout(() => {
254
+ var _a, _b;
255
+ (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.registerOnTouched(fn);
256
+ (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.registerOnTouched(fn);
257
+ });
258
+ }
259
+ setDisabledState(isDisabled) {
260
+ setTimeout(() => {
261
+ var _a, _b;
262
+ (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.setDisabledState(isDisabled);
263
+ (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.setDisabledState(isDisabled);
264
+ });
265
+ }
266
+ get value() {
267
+ if (this.lastDateValue && this.lastTimeValue) {
268
+ const result = new Date(this.lastDateValue);
269
+ result.setHours(this.lastTimeValue.getHours(), this.lastTimeValue.getMinutes(), this.lastTimeValue.getSeconds(), this.lastTimeValue.getMilliseconds());
270
+ return result;
271
+ }
272
+ return null;
273
+ }
274
+ limitTime(mode) {
275
+ var _a, _b;
276
+ const limit = mode === 'min' ? this.min : this.max;
277
+ const limitIso = limit ? this.toLocalISODate(limit) : undefined;
278
+ const dateIso = this.lastDateValue ? this.toLocalISODate(this.lastDateValue) : undefined;
279
+ const attr = limit && limitIso === dateIso ? this.toLocalISOTime(limit) : undefined;
280
+ if (attr) {
281
+ (_a = this.timeInput) === null || _a === void 0 ? void 0 : _a.nativeElement.setAttribute(mode, attr);
282
+ }
283
+ else {
284
+ (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.nativeElement.removeAttribute(mode);
285
+ }
286
+ }
287
+ toLocalISODate(value) {
288
+ const year = value.getFullYear();
289
+ const month = (value.getMonth() + 1).toString().padStart(2, '0');
290
+ const day = value.getDate().toString().padStart(2, '0');
291
+ return `${year}-${month}-${day}`;
292
+ }
293
+ toLocalISOTime(value) {
294
+ const hours = value.getHours().toString().padStart(2, '0');
295
+ const mins = value.getMinutes().toString().padStart(2, '0');
296
+ return `${hours}:${mins}`;
297
+ }
298
+ }
299
+ DatetimeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DatetimeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
300
+ DatetimeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DatetimeComponent, selector: "cat-datetime", inputs: { min: "min", max: "max" }, providers: [
301
+ {
302
+ provide: NG_VALUE_ACCESSOR,
303
+ useExisting: DatetimeComponent,
304
+ multi: true
305
+ }
306
+ ], queries: [{ propertyName: "dateInput", first: true, predicate: DateValueAccessor, descendants: true }, { propertyName: "timeInput", first: true, predicate: TimeValueAccessor, descendants: true }], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["cat-datetime{display:contents}\n"], encapsulation: i0.ViewEncapsulation.None });
307
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DatetimeComponent, decorators: [{
308
+ type: Component,
309
+ args: [{ selector: 'cat-datetime', template: '<ng-content></ng-content>', encapsulation: ViewEncapsulation.None, providers: [
310
+ {
311
+ provide: NG_VALUE_ACCESSOR,
312
+ useExisting: DatetimeComponent,
313
+ multi: true
314
+ }
315
+ ], styles: ["cat-datetime{display:contents}\n"] }]
316
+ }], propDecorators: { dateInput: [{
317
+ type: ContentChild,
318
+ args: [DateValueAccessor]
319
+ }], timeInput: [{
320
+ type: ContentChild,
321
+ args: [TimeValueAccessor]
322
+ }], min: [{
323
+ type: Input
324
+ }], max: [{
325
+ type: Input
326
+ }] } });
327
+
34
328
  /**
35
329
  * The bottom actions of a dialog.
36
330
  */
@@ -925,44 +1219,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
925
1219
  args: [CatDialogHeaderComponent]
926
1220
  }] } });
927
1221
 
928
- class ValueAccessor {
929
- constructor(el) {
930
- this.el = el;
931
- this.onChange = () => { };
932
- this.onTouched = () => { };
933
- }
934
- writeValue(value) {
935
- this.el.nativeElement.value = this.lastValue = value == null ? '' : value;
936
- }
937
- handleChangeEvent(value) {
938
- if (value !== this.lastValue) {
939
- this.lastValue = value;
940
- this.onChange(value);
941
- }
942
- }
943
- _handleBlurEvent() {
944
- this.onTouched();
945
- }
946
- registerOnChange(fn) {
947
- this.onChange = fn;
948
- }
949
- registerOnTouched(fn) {
950
- this.onTouched = fn;
951
- }
952
- setDisabledState(isDisabled) {
953
- this.el.nativeElement.disabled = isDisabled;
954
- }
955
- }
956
- ValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
957
- ValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: ValueAccessor, host: { listeners: { "focusout": "_handleBlurEvent()" } }, ngImport: i0 });
958
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ValueAccessor, decorators: [{
959
- type: Directive,
960
- args: [{}]
961
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { _handleBlurEvent: [{
962
- type: HostListener,
963
- args: ['focusout']
964
- }] } });
965
-
966
1222
  class BooleanValueAccessor extends ValueAccessor {
967
1223
  constructor(el) {
968
1224
  super(el);
@@ -997,76 +1253,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
997
1253
  }]
998
1254
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
999
1255
 
1000
- class DateValueAccessor extends ValueAccessor {
1001
- constructor(el) {
1002
- super(el);
1003
- }
1004
- get nativeElement() {
1005
- return this.el.nativeElement;
1006
- }
1007
- writeValue(value) {
1008
- if (!this.el.nativeElement.range) {
1009
- return super.writeValue(this.toISO(value));
1010
- }
1011
- else if (value instanceof Array) {
1012
- const data = [this.toISO(value[0]), this.toISO(value[1])];
1013
- return super.writeValue(JSON.stringify(data));
1014
- }
1015
- return super.writeValue(undefined);
1016
- }
1017
- handleChangeEvent(value) {
1018
- var _a;
1019
- if (!this.el.nativeElement.range) {
1020
- return super.handleChangeEvent(this.toDate(value));
1021
- }
1022
- else if (typeof value === 'string') {
1023
- const data = JSON.parse(value).map(this.toDate);
1024
- (_a = data[1]) === null || _a === void 0 ? void 0 : _a.setHours(23, 59, 59, 999);
1025
- return super.handleChangeEvent(data);
1026
- }
1027
- super.handleChangeEvent(null);
1028
- }
1029
- toISO(value) {
1030
- if (value instanceof Date) {
1031
- const year = value.getFullYear();
1032
- const month = (value.getMonth() + 1).toString().padStart(2, '0');
1033
- const day = value.getDate().toString().padStart(2, '0');
1034
- return `${year}-${month}-${day}`;
1035
- }
1036
- return undefined;
1037
- }
1038
- toDate(value) {
1039
- var _a;
1040
- const [match, year, month, day] = (_a = value === null || value === void 0 ? void 0 : value.match(/^(\d{4})-(\d{2})-(\d{2})/)) !== null && _a !== void 0 ? _a : [];
1041
- return match ? new Date(Number(year), Number(month) - 1, Number(day)) : null;
1042
- }
1043
- }
1044
- DateValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1045
- DateValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: DateValueAccessor, selector: "cat-date, cat-date-inline", host: { listeners: { "catChange": "handleChangeEvent($event.target.value)" } }, providers: [
1046
- {
1047
- provide: NG_VALUE_ACCESSOR,
1048
- useExisting: DateValueAccessor,
1049
- multi: true
1050
- }
1051
- ], usesInheritance: true, ngImport: i0 });
1052
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateValueAccessor, decorators: [{
1053
- type: Directive,
1054
- args: [{
1055
- /* tslint:disable-next-line:directive-selector */
1056
- selector: 'cat-date, cat-date-inline',
1057
- host: {
1058
- '(catChange)': 'handleChangeEvent($event.target.value)'
1059
- },
1060
- providers: [
1061
- {
1062
- provide: NG_VALUE_ACCESSOR,
1063
- useExisting: DateValueAccessor,
1064
- multi: true
1065
- }
1066
- ]
1067
- }]
1068
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
1069
-
1070
1256
  class RadioValueAccessor extends ValueAccessor {
1071
1257
  constructor(el) {
1072
1258
  super(el);
@@ -1182,58 +1368,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
1182
1368
  }]
1183
1369
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
1184
1370
 
1185
- class TimeValueAccessor extends ValueAccessor {
1186
- constructor(el) {
1187
- super(el);
1188
- }
1189
- get nativeElement() {
1190
- return this.el.nativeElement;
1191
- }
1192
- writeValue(value) {
1193
- if (value && value instanceof Date) {
1194
- const hours = value.getHours().toString().padStart(2, '0');
1195
- const mins = value.getMinutes().toString().padStart(2, '0');
1196
- return super.writeValue(`${hours}:${mins}`);
1197
- }
1198
- return super.writeValue(undefined);
1199
- }
1200
- handleChangeEvent(value) {
1201
- var _a;
1202
- const [match, hours, mins] = (_a = value === null || value === void 0 ? void 0 : value.match(/^(\d{2}):(\d{2})/)) !== null && _a !== void 0 ? _a : [];
1203
- if (match) {
1204
- const date = new Date();
1205
- date.setHours(Number(hours), Number(mins), 0, 0);
1206
- return super.handleChangeEvent(date);
1207
- }
1208
- return super.handleChangeEvent(null);
1209
- }
1210
- }
1211
- TimeValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1212
- TimeValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: TimeValueAccessor, selector: "cat-time", host: { listeners: { "catChange": "handleChangeEvent($event.target.value)" } }, providers: [
1213
- {
1214
- provide: NG_VALUE_ACCESSOR,
1215
- useExisting: TimeValueAccessor,
1216
- multi: true
1217
- }
1218
- ], usesInheritance: true, ngImport: i0 });
1219
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeValueAccessor, decorators: [{
1220
- type: Directive,
1221
- args: [{
1222
- /* tslint:disable-next-line:directive-selector */
1223
- selector: 'cat-time',
1224
- host: {
1225
- '(catChange)': 'handleChangeEvent($event.target.value)'
1226
- },
1227
- providers: [
1228
- {
1229
- provide: NG_VALUE_ACCESSOR,
1230
- useExisting: TimeValueAccessor,
1231
- multi: true
1232
- }
1233
- ]
1234
- }]
1235
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
1236
-
1237
1371
  class ValueAccessorDecorator {
1238
1372
  constructor(el, controlDirective, controlContainer) {
1239
1373
  this.el = el;
@@ -1289,140 +1423,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
1289
1423
  type: Input
1290
1424
  }] } });
1291
1425
 
1292
- class DatetimeComponent {
1293
- get min() {
1294
- var _a;
1295
- return (_a = this._min) !== null && _a !== void 0 ? _a : null;
1296
- }
1297
- set min(value) {
1298
- this._min = value;
1299
- setTimeout(() => {
1300
- var _a;
1301
- const min = value ? this.toLocalISODate(value) : undefined;
1302
- (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.nativeElement.setAttribute('min', min);
1303
- this.limitTime('min');
1304
- });
1305
- }
1306
- get max() {
1307
- var _a;
1308
- return (_a = this._max) !== null && _a !== void 0 ? _a : null;
1309
- }
1310
- set max(value) {
1311
- this._max = value;
1312
- setTimeout(() => {
1313
- var _a;
1314
- const max = value ? this.toLocalISODate(value) : undefined;
1315
- (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.nativeElement.setAttribute('max', max);
1316
- this.limitTime('max');
1317
- });
1318
- }
1319
- ngAfterContentInit() {
1320
- if (!this.dateInput) {
1321
- throw new Error('Missing child element <cat-date></cat-date>');
1322
- }
1323
- if (!this.timeInput) {
1324
- throw new Error('Missing child element <cat-time></cat-time>');
1325
- }
1326
- }
1327
- writeValue(value) {
1328
- this.lastValue = this.lastDateValue = this.lastTimeValue = value;
1329
- setTimeout(() => {
1330
- var _a, _b;
1331
- (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.writeValue(value);
1332
- (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.writeValue(value);
1333
- });
1334
- }
1335
- registerOnChange(fn) {
1336
- setTimeout(() => {
1337
- var _a, _b;
1338
- (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.registerOnChange((value) => {
1339
- this.lastDateValue = value;
1340
- this.limitTime('min');
1341
- this.limitTime('max');
1342
- fn(this.value);
1343
- });
1344
- (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.registerOnChange((value) => {
1345
- this.lastTimeValue = value;
1346
- fn(this.value);
1347
- });
1348
- });
1349
- }
1350
- registerOnTouched(fn) {
1351
- setTimeout(() => {
1352
- var _a, _b;
1353
- (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.registerOnTouched(fn);
1354
- (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.registerOnTouched(fn);
1355
- });
1356
- }
1357
- setDisabledState(isDisabled) {
1358
- setTimeout(() => {
1359
- var _a, _b;
1360
- (_a = this.dateInput) === null || _a === void 0 ? void 0 : _a.setDisabledState(isDisabled);
1361
- (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.setDisabledState(isDisabled);
1362
- });
1363
- }
1364
- get value() {
1365
- if (this.lastDateValue && this.lastTimeValue) {
1366
- const result = new Date(this.lastDateValue);
1367
- result.setHours(this.lastTimeValue.getHours(), this.lastTimeValue.getMinutes(), this.lastTimeValue.getSeconds(), this.lastTimeValue.getMilliseconds());
1368
- return result;
1369
- }
1370
- return null;
1371
- }
1372
- limitTime(mode) {
1373
- var _a, _b;
1374
- const limit = mode === 'min' ? this.min : this.max;
1375
- const limitIso = limit ? this.toLocalISODate(limit) : undefined;
1376
- const dateIso = this.lastDateValue ? this.toLocalISODate(this.lastDateValue) : undefined;
1377
- const attr = limit && limitIso === dateIso ? this.toLocalISOTime(limit) : undefined;
1378
- if (attr) {
1379
- (_a = this.timeInput) === null || _a === void 0 ? void 0 : _a.nativeElement.setAttribute(mode, attr);
1380
- }
1381
- else {
1382
- (_b = this.timeInput) === null || _b === void 0 ? void 0 : _b.nativeElement.removeAttribute(mode);
1383
- }
1384
- }
1385
- toLocalISODate(value) {
1386
- const year = value.getFullYear();
1387
- const month = (value.getMonth() + 1).toString().padStart(2, '0');
1388
- const day = value.getDate().toString().padStart(2, '0');
1389
- return `${year}-${month}-${day}`;
1390
- }
1391
- toLocalISOTime(value) {
1392
- const hours = value.getHours().toString().padStart(2, '0');
1393
- const mins = value.getMinutes().toString().padStart(2, '0');
1394
- return `${hours}:${mins}`;
1395
- }
1396
- }
1397
- DatetimeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DatetimeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1398
- DatetimeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DatetimeComponent, selector: "cat-datetime", inputs: { min: "min", max: "max" }, providers: [
1399
- {
1400
- provide: NG_VALUE_ACCESSOR,
1401
- useExisting: DatetimeComponent,
1402
- multi: true
1403
- }
1404
- ], queries: [{ propertyName: "dateInput", first: true, predicate: DateValueAccessor, descendants: true }, { propertyName: "timeInput", first: true, predicate: TimeValueAccessor, descendants: true }], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["cat-datetime{display:contents}\n"], encapsulation: i0.ViewEncapsulation.None });
1405
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DatetimeComponent, decorators: [{
1406
- type: Component,
1407
- args: [{ selector: 'cat-datetime', template: '<ng-content></ng-content>', encapsulation: ViewEncapsulation.None, providers: [
1408
- {
1409
- provide: NG_VALUE_ACCESSOR,
1410
- useExisting: DatetimeComponent,
1411
- multi: true
1412
- }
1413
- ], styles: ["cat-datetime{display:contents}\n"] }]
1414
- }], propDecorators: { dateInput: [{
1415
- type: ContentChild,
1416
- args: [DateValueAccessor]
1417
- }], timeInput: [{
1418
- type: ContentChild,
1419
- args: [TimeValueAccessor]
1420
- }], min: [{
1421
- type: Input
1422
- }], max: [{
1423
- type: Input
1424
- }] } });
1425
-
1426
1426
  const CatComponents = [
1427
1427
  CatAlert,
1428
1428
  CatAvatar,
@@ -1448,6 +1448,7 @@ const CatComponents = [
1448
1448
  CatTab,
1449
1449
  CatTabs,
1450
1450
  CatTextarea,
1451
+ CatTime,
1451
1452
  CatToggle,
1452
1453
  CatTooltip
1453
1454
  ];
@@ -1471,7 +1472,7 @@ class CatalystModule {
1471
1472
  }
1472
1473
  }
1473
1474
  CatalystModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CatalystModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1474
- CatalystModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: CatalystModule, declarations: [CatAlert, CatAvatar, CatBadge, CatButton, CatButtonGroup, CatCard, CatCheckbox, CatDate, CatDateInline, CatDatepicker, CatDropdown, CatFormGroup, CatIcon, CatInput, CatPagination, CatRadio, CatRadioGroup, CatScrollable, CatSelect, CatSkeleton, CatSpinner, CatTab, CatTabs, CatTextarea, CatToggle, CatTooltip, BooleanValueAccessor,
1475
+ CatalystModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: CatalystModule, declarations: [CatAlert, CatAvatar, CatBadge, CatButton, CatButtonGroup, CatCard, CatCheckbox, CatDate, CatDateInline, CatDatepicker, CatDropdown, CatFormGroup, CatIcon, CatInput, CatPagination, CatRadio, CatRadioGroup, CatScrollable, CatSelect, CatSkeleton, CatSpinner, CatTab, CatTabs, CatTextarea, CatTime, CatToggle, CatTooltip, BooleanValueAccessor,
1475
1476
  DateValueAccessor,
1476
1477
  RadioValueAccessor,
1477
1478
  SelectValueAccessor,
@@ -1481,7 +1482,7 @@ CatalystModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
1481
1482
  ValueAccessorDecorator,
1482
1483
  DatetimeComponent, CatDialogComponent,
1483
1484
  CatDialogHeaderComponent,
1484
- CatDialogActionsComponent], imports: [CommonModule, DialogModule], exports: [CatAlert, CatAvatar, CatBadge, CatButton, CatButtonGroup, CatCard, CatCheckbox, CatDate, CatDateInline, CatDatepicker, CatDropdown, CatFormGroup, CatIcon, CatInput, CatPagination, CatRadio, CatRadioGroup, CatScrollable, CatSelect, CatSkeleton, CatSpinner, CatTab, CatTabs, CatTextarea, CatToggle, CatTooltip, BooleanValueAccessor,
1485
+ CatDialogActionsComponent], imports: [CommonModule, DialogModule], exports: [CatAlert, CatAvatar, CatBadge, CatButton, CatButtonGroup, CatCard, CatCheckbox, CatDate, CatDateInline, CatDatepicker, CatDropdown, CatFormGroup, CatIcon, CatInput, CatPagination, CatRadio, CatRadioGroup, CatScrollable, CatSelect, CatSkeleton, CatSpinner, CatTab, CatTabs, CatTextarea, CatTime, CatToggle, CatTooltip, BooleanValueAccessor,
1485
1486
  DateValueAccessor,
1486
1487
  RadioValueAccessor,
1487
1488
  SelectValueAccessor,