@haiilo/catalyst-angular 10.19.1 → 10.19.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.
@@ -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,288 @@ 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
+ if (!this.el.nativeElement.range) {
91
+ return super.handleChangeEvent(this.toDate(value));
92
+ }
93
+ else if (typeof value === 'string') {
94
+ const data = JSON.parse(value).map(this.toDate);
95
+ data[1]?.setHours(23, 59, 59, 999);
96
+ return super.handleChangeEvent(data);
97
+ }
98
+ super.handleChangeEvent(null);
99
+ }
100
+ toISO(value) {
101
+ if (value instanceof Date) {
102
+ const year = value.getFullYear();
103
+ const month = (value.getMonth() + 1).toString().padStart(2, '0');
104
+ const day = value.getDate().toString().padStart(2, '0');
105
+ return `${year}-${month}-${day}`;
106
+ }
107
+ return undefined;
108
+ }
109
+ toDate(value) {
110
+ const [match, year, month, day] = value?.match(/^(\d{4})-(\d{2})-(\d{2})/) ?? [];
111
+ return match ? new Date(Number(year), Number(month) - 1, Number(day)) : null;
112
+ }
113
+ }
114
+ DateValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
115
+ 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: [
116
+ {
117
+ provide: NG_VALUE_ACCESSOR,
118
+ useExisting: DateValueAccessor,
119
+ multi: true
120
+ }
121
+ ], usesInheritance: true, ngImport: i0 });
122
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateValueAccessor, decorators: [{
123
+ type: Directive,
124
+ args: [{
125
+ /* tslint:disable-next-line:directive-selector */
126
+ selector: 'cat-date, cat-date-inline',
127
+ host: {
128
+ '(catChange)': 'handleChangeEvent($event.target.value)'
129
+ },
130
+ providers: [
131
+ {
132
+ provide: NG_VALUE_ACCESSOR,
133
+ useExisting: DateValueAccessor,
134
+ multi: true
135
+ }
136
+ ]
137
+ }]
138
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
139
+
140
+ class TimeValueAccessor extends ValueAccessor {
141
+ constructor(el) {
142
+ super(el);
143
+ }
144
+ get nativeElement() {
145
+ return this.el.nativeElement;
146
+ }
147
+ writeValue(value) {
148
+ if (value && value instanceof Date) {
149
+ const hours = value.getHours().toString().padStart(2, '0');
150
+ const mins = value.getMinutes().toString().padStart(2, '0');
151
+ return super.writeValue(`${hours}:${mins}`);
152
+ }
153
+ return super.writeValue(undefined);
154
+ }
155
+ handleChangeEvent(value) {
156
+ const [match, hours, mins] = value?.match(/^(\d{2}):(\d{2})/) ?? [];
157
+ if (match) {
158
+ const date = new Date();
159
+ date.setHours(Number(hours), Number(mins), 0, 0);
160
+ return super.handleChangeEvent(date);
161
+ }
162
+ return super.handleChangeEvent(null);
163
+ }
164
+ }
165
+ TimeValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
166
+ 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: [
167
+ {
168
+ provide: NG_VALUE_ACCESSOR,
169
+ useExisting: TimeValueAccessor,
170
+ multi: true
171
+ }
172
+ ], usesInheritance: true, ngImport: i0 });
173
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeValueAccessor, decorators: [{
174
+ type: Directive,
175
+ args: [{
176
+ /* tslint:disable-next-line:directive-selector */
177
+ selector: 'cat-time',
178
+ host: {
179
+ '(catChange)': 'handleChangeEvent($event.target.value)'
180
+ },
181
+ providers: [
182
+ {
183
+ provide: NG_VALUE_ACCESSOR,
184
+ useExisting: TimeValueAccessor,
185
+ multi: true
186
+ }
187
+ ]
188
+ }]
189
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
190
+
191
+ class DatetimeComponent {
192
+ get min() {
193
+ return this._min ?? null;
194
+ }
195
+ set min(value) {
196
+ this._min = value;
197
+ setTimeout(() => {
198
+ const min = value ? this.toLocalISODate(value) : undefined;
199
+ this.dateInput?.nativeElement.setAttribute('min', min);
200
+ this.limitTime('min');
201
+ });
202
+ }
203
+ get max() {
204
+ return this._max ?? null;
205
+ }
206
+ set max(value) {
207
+ this._max = value;
208
+ setTimeout(() => {
209
+ const max = value ? this.toLocalISODate(value) : undefined;
210
+ this.dateInput?.nativeElement.setAttribute('max', max);
211
+ this.limitTime('max');
212
+ });
213
+ }
214
+ ngAfterContentInit() {
215
+ if (!this.dateInput) {
216
+ throw new Error('Missing child element <cat-date></cat-date>');
217
+ }
218
+ if (!this.timeInput) {
219
+ throw new Error('Missing child element <cat-time></cat-time>');
220
+ }
221
+ }
222
+ writeValue(value) {
223
+ this.lastValue = this.lastDateValue = this.lastTimeValue = value;
224
+ setTimeout(() => {
225
+ this.dateInput?.writeValue(value);
226
+ this.timeInput?.writeValue(value);
227
+ });
228
+ }
229
+ registerOnChange(fn) {
230
+ setTimeout(() => {
231
+ this.dateInput?.registerOnChange((value) => {
232
+ this.lastDateValue = value;
233
+ this.limitTime('min');
234
+ this.limitTime('max');
235
+ fn(this.value);
236
+ });
237
+ this.timeInput?.registerOnChange((value) => {
238
+ this.lastTimeValue = value;
239
+ fn(this.value);
240
+ });
241
+ });
242
+ }
243
+ registerOnTouched(fn) {
244
+ setTimeout(() => {
245
+ this.dateInput?.registerOnTouched(fn);
246
+ this.timeInput?.registerOnTouched(fn);
247
+ });
248
+ }
249
+ setDisabledState(isDisabled) {
250
+ setTimeout(() => {
251
+ this.dateInput?.setDisabledState(isDisabled);
252
+ this.timeInput?.setDisabledState(isDisabled);
253
+ });
254
+ }
255
+ get value() {
256
+ if (this.lastDateValue && this.lastTimeValue) {
257
+ const result = new Date(this.lastDateValue);
258
+ result.setHours(this.lastTimeValue.getHours(), this.lastTimeValue.getMinutes(), this.lastTimeValue.getSeconds(), this.lastTimeValue.getMilliseconds());
259
+ return result;
260
+ }
261
+ return null;
262
+ }
263
+ limitTime(mode) {
264
+ const limit = mode === 'min' ? this.min : this.max;
265
+ const limitIso = limit ? this.toLocalISODate(limit) : undefined;
266
+ const dateIso = this.lastDateValue ? this.toLocalISODate(this.lastDateValue) : undefined;
267
+ const attr = limit && limitIso === dateIso ? this.toLocalISOTime(limit) : undefined;
268
+ if (attr) {
269
+ this.timeInput?.nativeElement.setAttribute(mode, attr);
270
+ }
271
+ else {
272
+ this.timeInput?.nativeElement.removeAttribute(mode);
273
+ }
274
+ }
275
+ toLocalISODate(value) {
276
+ const year = value.getFullYear();
277
+ const month = (value.getMonth() + 1).toString().padStart(2, '0');
278
+ const day = value.getDate().toString().padStart(2, '0');
279
+ return `${year}-${month}-${day}`;
280
+ }
281
+ toLocalISOTime(value) {
282
+ const hours = value.getHours().toString().padStart(2, '0');
283
+ const mins = value.getMinutes().toString().padStart(2, '0');
284
+ return `${hours}:${mins}`;
285
+ }
286
+ }
287
+ DatetimeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DatetimeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
288
+ DatetimeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DatetimeComponent, selector: "cat-datetime", inputs: { min: "min", max: "max" }, providers: [
289
+ {
290
+ provide: NG_VALUE_ACCESSOR,
291
+ useExisting: DatetimeComponent,
292
+ multi: true
293
+ }
294
+ ], 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 });
295
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DatetimeComponent, decorators: [{
296
+ type: Component,
297
+ args: [{ selector: 'cat-datetime', template: '<ng-content></ng-content>', encapsulation: ViewEncapsulation.None, providers: [
298
+ {
299
+ provide: NG_VALUE_ACCESSOR,
300
+ useExisting: DatetimeComponent,
301
+ multi: true
302
+ }
303
+ ], styles: ["cat-datetime{display:contents}\n"] }]
304
+ }], propDecorators: { dateInput: [{
305
+ type: ContentChild,
306
+ args: [DateValueAccessor]
307
+ }], timeInput: [{
308
+ type: ContentChild,
309
+ args: [TimeValueAccessor]
310
+ }], min: [{
311
+ type: Input
312
+ }], max: [{
313
+ type: Input
314
+ }] } });
315
+
34
316
  /**
35
317
  * The bottom actions of a dialog.
36
318
  */
@@ -908,56 +1190,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
908
1190
  type: Component,
909
1191
  args: [{ selector: 'cat-dialog', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
910
1192
  class: 'cat-dialog'
911
- }, template: "<ng-content select=\"cat-dialog-header\"></ng-content>\n<cat-scrollable\n [noOverscroll]=\"noOverscroll\"\n [noScrolledInit]=\"noScrolledInit\"\n [scrolledBuffer]=\"scrolledBuffer\"\n (scrolledBottom)=\"scrolledBottom.emit()\"\n>\n <div class=\"cat-dialog-content\">\n <ng-content></ng-content>\n </div>\n</cat-scrollable>\n<ng-content select=\"cat-dialog-actions\"></ng-content>\n", styles: [".cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}.cdk-overlay-container{position:fixed;z-index:1000}.cdk-overlay-container:empty{display:none}.cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;z-index:1000;display:flex;max-width:100%;max-height:100%}.cdk-overlay-backdrop{position:absolute;inset:0;z-index:1000;pointer-events:auto;-webkit-tap-highlight-color:transparent;transition:opacity .4s cubic-bezier(.25,.8,.25,1);opacity:0}.cdk-overlay-backdrop.cdk-overlay-backdrop-showing{opacity:1}.cdk-high-contrast-active .cdk-overlay-backdrop.cdk-overlay-backdrop-showing{opacity:.6}.cdk-overlay-dark-backdrop{background:rgba(0,0,0,.32)}.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing{opacity:0;visibility:visible}.cdk-overlay-backdrop-noop-animation{transition:none}.cdk-overlay-connected-position-bounding-box{position:absolute;z-index:1000;display:flex;flex-direction:column;min-width:1px;min-height:1px}.cdk-global-scrollblock{position:fixed;width:100%;overflow-y:scroll}.cat-backdrop{transition-duration:.5s}.cat-dialog-pane .cdk-dialog-container>*:only-child{display:block;width:100%;height:100%;min-height:inherit;max-height:inherit}.cat-dialog{width:100%;height:100%;min-height:inherit;max-height:inherit;animation:cat-dialog-enter .25s ease}@keyframes cat-dialog-enter{0%{opacity:0;transform:translateY(24px)}to{opacity:1;transform:none}}\n"] }]
912
- }], ctorParameters: function () { return [{ type: i1$1.DialogRef }]; }, propDecorators: { noOverscroll: [{
913
- type: Input
914
- }], noScrolledInit: [{
915
- type: Input
916
- }], scrolledBuffer: [{
917
- type: Input
918
- }], scrolledBottom: [{
919
- type: Output
920
- }], header: [{
921
- type: ContentChild,
922
- args: [CatDialogHeaderComponent]
923
- }] } });
924
-
925
- class ValueAccessor {
926
- constructor(el) {
927
- this.el = el;
928
- this.onChange = () => { };
929
- this.onTouched = () => { };
930
- }
931
- writeValue(value) {
932
- this.el.nativeElement.value = this.lastValue = value == null ? '' : value;
933
- }
934
- handleChangeEvent(value) {
935
- if (value !== this.lastValue) {
936
- this.lastValue = value;
937
- this.onChange(value);
938
- }
939
- }
940
- _handleBlurEvent() {
941
- this.onTouched();
942
- }
943
- registerOnChange(fn) {
944
- this.onChange = fn;
945
- }
946
- registerOnTouched(fn) {
947
- this.onTouched = fn;
948
- }
949
- setDisabledState(isDisabled) {
950
- this.el.nativeElement.disabled = isDisabled;
951
- }
952
- }
953
- ValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
954
- ValueAccessor.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: ValueAccessor, host: { listeners: { "focusout": "_handleBlurEvent()" } }, ngImport: i0 });
955
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: ValueAccessor, decorators: [{
956
- type: Directive,
957
- args: [{}]
958
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { _handleBlurEvent: [{
959
- type: HostListener,
960
- args: ['focusout']
1193
+ }, template: "<ng-content select=\"cat-dialog-header\"></ng-content>\n<cat-scrollable\n [noOverscroll]=\"noOverscroll\"\n [noScrolledInit]=\"noScrolledInit\"\n [scrolledBuffer]=\"scrolledBuffer\"\n (scrolledBottom)=\"scrolledBottom.emit()\"\n>\n <div class=\"cat-dialog-content\">\n <ng-content></ng-content>\n </div>\n</cat-scrollable>\n<ng-content select=\"cat-dialog-actions\"></ng-content>\n", styles: [".cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}.cdk-overlay-container{position:fixed;z-index:1000}.cdk-overlay-container:empty{display:none}.cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;z-index:1000;display:flex;max-width:100%;max-height:100%}.cdk-overlay-backdrop{position:absolute;inset:0;z-index:1000;pointer-events:auto;-webkit-tap-highlight-color:transparent;transition:opacity .4s cubic-bezier(.25,.8,.25,1);opacity:0}.cdk-overlay-backdrop.cdk-overlay-backdrop-showing{opacity:1}.cdk-high-contrast-active .cdk-overlay-backdrop.cdk-overlay-backdrop-showing{opacity:.6}.cdk-overlay-dark-backdrop{background:rgba(0,0,0,.32)}.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing{opacity:0;visibility:visible}.cdk-overlay-backdrop-noop-animation{transition:none}.cdk-overlay-connected-position-bounding-box{position:absolute;z-index:1000;display:flex;flex-direction:column;min-width:1px;min-height:1px}.cdk-global-scrollblock{position:fixed;width:100%;overflow-y:scroll}.cat-backdrop{transition-duration:.5s}.cat-dialog-pane .cdk-dialog-container>*:only-child{display:block;width:100%;height:100%;min-height:inherit;max-height:inherit}.cat-dialog{width:100%;height:100%;min-height:inherit;max-height:inherit;animation:cat-dialog-enter .25s ease}@keyframes cat-dialog-enter{0%{opacity:0;transform:translateY(24px)}to{opacity:1;transform:none}}\n"] }]
1194
+ }], ctorParameters: function () { return [{ type: i1$1.DialogRef }]; }, propDecorators: { noOverscroll: [{
1195
+ type: Input
1196
+ }], noScrolledInit: [{
1197
+ type: Input
1198
+ }], scrolledBuffer: [{
1199
+ type: Input
1200
+ }], scrolledBottom: [{
1201
+ type: Output
1202
+ }], header: [{
1203
+ type: ContentChild,
1204
+ args: [CatDialogHeaderComponent]
961
1205
  }] } });
962
1206
 
963
1207
  class BooleanValueAccessor extends ValueAccessor {
@@ -994,74 +1238,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
994
1238
  }]
995
1239
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
996
1240
 
997
- class DateValueAccessor extends ValueAccessor {
998
- constructor(el) {
999
- super(el);
1000
- }
1001
- get nativeElement() {
1002
- return this.el.nativeElement;
1003
- }
1004
- writeValue(value) {
1005
- if (!this.el.nativeElement.range) {
1006
- return super.writeValue(this.toISO(value));
1007
- }
1008
- else if (value instanceof Array) {
1009
- const data = [this.toISO(value[0]), this.toISO(value[1])];
1010
- return super.writeValue(JSON.stringify(data));
1011
- }
1012
- return super.writeValue(undefined);
1013
- }
1014
- handleChangeEvent(value) {
1015
- if (!this.el.nativeElement.range) {
1016
- return super.handleChangeEvent(this.toDate(value));
1017
- }
1018
- else if (typeof value === 'string') {
1019
- const data = JSON.parse(value).map(this.toDate);
1020
- data[1]?.setHours(23, 59, 59, 999);
1021
- return super.handleChangeEvent(data);
1022
- }
1023
- super.handleChangeEvent(null);
1024
- }
1025
- toISO(value) {
1026
- if (value instanceof Date) {
1027
- const year = value.getFullYear();
1028
- const month = (value.getMonth() + 1).toString().padStart(2, '0');
1029
- const day = value.getDate().toString().padStart(2, '0');
1030
- return `${year}-${month}-${day}`;
1031
- }
1032
- return undefined;
1033
- }
1034
- toDate(value) {
1035
- const [match, year, month, day] = value?.match(/^(\d{4})-(\d{2})-(\d{2})/) ?? [];
1036
- return match ? new Date(Number(year), Number(month) - 1, Number(day)) : null;
1037
- }
1038
- }
1039
- DateValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1040
- 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: [
1041
- {
1042
- provide: NG_VALUE_ACCESSOR,
1043
- useExisting: DateValueAccessor,
1044
- multi: true
1045
- }
1046
- ], usesInheritance: true, ngImport: i0 });
1047
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DateValueAccessor, decorators: [{
1048
- type: Directive,
1049
- args: [{
1050
- /* tslint:disable-next-line:directive-selector */
1051
- selector: 'cat-date, cat-date-inline',
1052
- host: {
1053
- '(catChange)': 'handleChangeEvent($event.target.value)'
1054
- },
1055
- providers: [
1056
- {
1057
- provide: NG_VALUE_ACCESSOR,
1058
- useExisting: DateValueAccessor,
1059
- multi: true
1060
- }
1061
- ]
1062
- }]
1063
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
1064
-
1065
1241
  class RadioValueAccessor extends ValueAccessor {
1066
1242
  constructor(el) {
1067
1243
  super(el);
@@ -1177,57 +1353,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
1177
1353
  }]
1178
1354
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
1179
1355
 
1180
- class TimeValueAccessor extends ValueAccessor {
1181
- constructor(el) {
1182
- super(el);
1183
- }
1184
- get nativeElement() {
1185
- return this.el.nativeElement;
1186
- }
1187
- writeValue(value) {
1188
- if (value && value instanceof Date) {
1189
- const hours = value.getHours().toString().padStart(2, '0');
1190
- const mins = value.getMinutes().toString().padStart(2, '0');
1191
- return super.writeValue(`${hours}:${mins}`);
1192
- }
1193
- return super.writeValue(undefined);
1194
- }
1195
- handleChangeEvent(value) {
1196
- const [match, hours, mins] = value?.match(/^(\d{2}):(\d{2})/) ?? [];
1197
- if (match) {
1198
- const date = new Date();
1199
- date.setHours(Number(hours), Number(mins), 0, 0);
1200
- return super.handleChangeEvent(date);
1201
- }
1202
- return super.handleChangeEvent(null);
1203
- }
1204
- }
1205
- TimeValueAccessor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1206
- 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: [
1207
- {
1208
- provide: NG_VALUE_ACCESSOR,
1209
- useExisting: TimeValueAccessor,
1210
- multi: true
1211
- }
1212
- ], usesInheritance: true, ngImport: i0 });
1213
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: TimeValueAccessor, decorators: [{
1214
- type: Directive,
1215
- args: [{
1216
- /* tslint:disable-next-line:directive-selector */
1217
- selector: 'cat-time',
1218
- host: {
1219
- '(catChange)': 'handleChangeEvent($event.target.value)'
1220
- },
1221
- providers: [
1222
- {
1223
- provide: NG_VALUE_ACCESSOR,
1224
- useExisting: TimeValueAccessor,
1225
- multi: true
1226
- }
1227
- ]
1228
- }]
1229
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
1230
-
1231
1356
  class ValueAccessorDecorator {
1232
1357
  constructor(el, controlDirective, controlContainer) {
1233
1358
  this.el = el;
@@ -1279,131 +1404,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
1279
1404
  type: Input
1280
1405
  }] } });
1281
1406
 
1282
- class DatetimeComponent {
1283
- get min() {
1284
- return this._min ?? null;
1285
- }
1286
- set min(value) {
1287
- this._min = value;
1288
- setTimeout(() => {
1289
- const min = value ? this.toLocalISODate(value) : undefined;
1290
- this.dateInput?.nativeElement.setAttribute('min', min);
1291
- this.limitTime('min');
1292
- });
1293
- }
1294
- get max() {
1295
- return this._max ?? null;
1296
- }
1297
- set max(value) {
1298
- this._max = value;
1299
- setTimeout(() => {
1300
- const max = value ? this.toLocalISODate(value) : undefined;
1301
- this.dateInput?.nativeElement.setAttribute('max', max);
1302
- this.limitTime('max');
1303
- });
1304
- }
1305
- ngAfterContentInit() {
1306
- if (!this.dateInput) {
1307
- throw new Error('Missing child element <cat-date></cat-date>');
1308
- }
1309
- if (!this.timeInput) {
1310
- throw new Error('Missing child element <cat-time></cat-time>');
1311
- }
1312
- }
1313
- writeValue(value) {
1314
- this.lastValue = this.lastDateValue = this.lastTimeValue = value;
1315
- setTimeout(() => {
1316
- this.dateInput?.writeValue(value);
1317
- this.timeInput?.writeValue(value);
1318
- });
1319
- }
1320
- registerOnChange(fn) {
1321
- setTimeout(() => {
1322
- this.dateInput?.registerOnChange((value) => {
1323
- this.lastDateValue = value;
1324
- this.limitTime('min');
1325
- this.limitTime('max');
1326
- fn(this.value);
1327
- });
1328
- this.timeInput?.registerOnChange((value) => {
1329
- this.lastTimeValue = value;
1330
- fn(this.value);
1331
- });
1332
- });
1333
- }
1334
- registerOnTouched(fn) {
1335
- setTimeout(() => {
1336
- this.dateInput?.registerOnTouched(fn);
1337
- this.timeInput?.registerOnTouched(fn);
1338
- });
1339
- }
1340
- setDisabledState(isDisabled) {
1341
- setTimeout(() => {
1342
- this.dateInput?.setDisabledState(isDisabled);
1343
- this.timeInput?.setDisabledState(isDisabled);
1344
- });
1345
- }
1346
- get value() {
1347
- if (this.lastDateValue && this.lastTimeValue) {
1348
- const result = new Date(this.lastDateValue);
1349
- result.setHours(this.lastTimeValue.getHours(), this.lastTimeValue.getMinutes(), this.lastTimeValue.getSeconds(), this.lastTimeValue.getMilliseconds());
1350
- return result;
1351
- }
1352
- return null;
1353
- }
1354
- limitTime(mode) {
1355
- const limit = mode === 'min' ? this.min : this.max;
1356
- const limitIso = limit ? this.toLocalISODate(limit) : undefined;
1357
- const dateIso = this.lastDateValue ? this.toLocalISODate(this.lastDateValue) : undefined;
1358
- const attr = limit && limitIso === dateIso ? this.toLocalISOTime(limit) : undefined;
1359
- if (attr) {
1360
- this.timeInput?.nativeElement.setAttribute(mode, attr);
1361
- }
1362
- else {
1363
- this.timeInput?.nativeElement.removeAttribute(mode);
1364
- }
1365
- }
1366
- toLocalISODate(value) {
1367
- const year = value.getFullYear();
1368
- const month = (value.getMonth() + 1).toString().padStart(2, '0');
1369
- const day = value.getDate().toString().padStart(2, '0');
1370
- return `${year}-${month}-${day}`;
1371
- }
1372
- toLocalISOTime(value) {
1373
- const hours = value.getHours().toString().padStart(2, '0');
1374
- const mins = value.getMinutes().toString().padStart(2, '0');
1375
- return `${hours}:${mins}`;
1376
- }
1377
- }
1378
- DatetimeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DatetimeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1379
- DatetimeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: DatetimeComponent, selector: "cat-datetime", inputs: { min: "min", max: "max" }, providers: [
1380
- {
1381
- provide: NG_VALUE_ACCESSOR,
1382
- useExisting: DatetimeComponent,
1383
- multi: true
1384
- }
1385
- ], 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 });
1386
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: DatetimeComponent, decorators: [{
1387
- type: Component,
1388
- args: [{ selector: 'cat-datetime', template: '<ng-content></ng-content>', encapsulation: ViewEncapsulation.None, providers: [
1389
- {
1390
- provide: NG_VALUE_ACCESSOR,
1391
- useExisting: DatetimeComponent,
1392
- multi: true
1393
- }
1394
- ], styles: ["cat-datetime{display:contents}\n"] }]
1395
- }], propDecorators: { dateInput: [{
1396
- type: ContentChild,
1397
- args: [DateValueAccessor]
1398
- }], timeInput: [{
1399
- type: ContentChild,
1400
- args: [TimeValueAccessor]
1401
- }], min: [{
1402
- type: Input
1403
- }], max: [{
1404
- type: Input
1405
- }] } });
1406
-
1407
1407
  const CatComponents = [
1408
1408
  CatAlert,
1409
1409
  CatAvatar,
@@ -1429,6 +1429,7 @@ const CatComponents = [
1429
1429
  CatTab,
1430
1430
  CatTabs,
1431
1431
  CatTextarea,
1432
+ CatTime,
1432
1433
  CatToggle,
1433
1434
  CatTooltip
1434
1435
  ];
@@ -1452,7 +1453,7 @@ class CatalystModule {
1452
1453
  }
1453
1454
  }
1454
1455
  CatalystModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: CatalystModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1455
- 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,
1456
+ 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,
1456
1457
  DateValueAccessor,
1457
1458
  RadioValueAccessor,
1458
1459
  SelectValueAccessor,
@@ -1462,7 +1463,7 @@ CatalystModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
1462
1463
  ValueAccessorDecorator,
1463
1464
  DatetimeComponent, CatDialogComponent,
1464
1465
  CatDialogHeaderComponent,
1465
- 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,
1466
+ 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,
1466
1467
  DateValueAccessor,
1467
1468
  RadioValueAccessor,
1468
1469
  SelectValueAccessor,