@anglr/datetime 5.0.0-beta.20221019112435 → 5.0.0-beta.20221020044622

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 (63) hide show
  1. package/changelog.md +16 -13
  2. package/es2015/src/modules/dateTime/directives/dateTime/dateTime.directive.js +221 -0
  3. package/es2015/src/modules/dateTime/directives/dateTime/dateTime.directive.js.map +1 -0
  4. package/es2015/src/modules/dateTime/directives/dateTimeBase.js +25 -41
  5. package/es2015/src/modules/dateTime/directives/dateTimeBase.js.map +1 -1
  6. package/es2015/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js +16 -17
  7. package/es2015/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js.map +1 -1
  8. package/es2015/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js +10 -13
  9. package/es2015/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js.map +1 -1
  10. package/es2015/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js +9 -11
  11. package/es2015/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js.map +1 -1
  12. package/es2015/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js +6 -8
  13. package/es2015/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js.map +1 -1
  14. package/es2015/src/modules/dateTime/directives/index.js +1 -1
  15. package/es2015/src/modules/dateTime/directives/index.js.map +1 -1
  16. package/es2015/src/modules/dateTime/modules/dateTime.module.js +7 -3
  17. package/es2015/src/modules/dateTime/modules/dateTime.module.js.map +1 -1
  18. package/es2015/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js +5 -22
  19. package/es2015/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js.map +1 -1
  20. package/es2020/src/modules/dateTime/directives/dateTime/dateTime.directive.js +218 -0
  21. package/es2020/src/modules/dateTime/directives/dateTime/dateTime.directive.js.map +1 -0
  22. package/es2020/src/modules/dateTime/directives/dateTimeBase.js +25 -41
  23. package/es2020/src/modules/dateTime/directives/dateTimeBase.js.map +1 -1
  24. package/es2020/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js +16 -17
  25. package/es2020/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js.map +1 -1
  26. package/es2020/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js +10 -13
  27. package/es2020/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js.map +1 -1
  28. package/es2020/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js +9 -11
  29. package/es2020/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js.map +1 -1
  30. package/es2020/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js +6 -8
  31. package/es2020/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js.map +1 -1
  32. package/es2020/src/modules/dateTime/directives/index.js +1 -1
  33. package/es2020/src/modules/dateTime/directives/index.js.map +1 -1
  34. package/es2020/src/modules/dateTime/modules/dateTime.module.js +7 -3
  35. package/es2020/src/modules/dateTime/modules/dateTime.module.js.map +1 -1
  36. package/es2020/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js +5 -22
  37. package/es2020/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.js.map +1 -1
  38. package/package.json +1 -1
  39. package/src/modules/dateTime/directives/dateTime/dateTime.directive.d.ts +120 -0
  40. package/src/modules/dateTime/directives/dateTime/dateTime.directive.d.ts.map +1 -0
  41. package/src/modules/dateTime/directives/dateTimeBase.d.ts +19 -27
  42. package/src/modules/dateTime/directives/dateTimeBase.d.ts.map +1 -1
  43. package/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.d.ts +3 -2
  44. package/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.d.ts.map +1 -1
  45. package/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.d.ts +4 -4
  46. package/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.d.ts.map +1 -1
  47. package/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.d.ts +4 -4
  48. package/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.d.ts.map +1 -1
  49. package/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.d.ts +2 -2
  50. package/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.d.ts.map +1 -1
  51. package/src/modules/dateTime/directives/index.d.ts +1 -1
  52. package/src/modules/dateTime/directives/index.d.ts.map +1 -1
  53. package/src/modules/dateTime/modules/dateTime.module.d.ts +7 -6
  54. package/src/modules/dateTime/modules/dateTime.module.d.ts.map +1 -1
  55. package/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.d.ts +6 -8
  56. package/src/modules/dateTimePicker/components/dateTimePicker/dateTimePicker.component.d.ts.map +1 -1
  57. package/version.bak +1 -1
  58. package/es2015/src/modules/dateTime/directives/dateTimeRestrictedBase.js +0 -152
  59. package/es2015/src/modules/dateTime/directives/dateTimeRestrictedBase.js.map +0 -1
  60. package/es2020/src/modules/dateTime/directives/dateTimeRestrictedBase.js +0 -149
  61. package/es2020/src/modules/dateTime/directives/dateTimeRestrictedBase.js.map +0 -1
  62. package/src/modules/dateTime/directives/dateTimeRestrictedBase.d.ts +0 -74
  63. package/src/modules/dateTime/directives/dateTimeRestrictedBase.d.ts.map +0 -1
@@ -0,0 +1,218 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Directive, inject, Input } from '@angular/core';
3
+ import { BindThis, isBlank, isString } from '@jscrpt/common';
4
+ import { Subject } from 'rxjs';
5
+ import { DateTimeValueFormat } from '../../../../misc/enums';
6
+ import { DATE_API, FORMAT_PROVIDER } from '../../../../misc/tokens';
7
+ import { getSingleDateTimeValue } from '../../../../misc/utils';
8
+ import { DateTimeBase } from '../dateTimeBase';
9
+ import * as i0 from "@angular/core";
10
+ /**
11
+ * Directive that holds shared data for date time, like formats, restrictions
12
+ */
13
+ export class DateTimeDirective {
14
+ constructor() {
15
+ //######################### protected properties #########################
16
+ /**
17
+ * Subject used for emitting changes in max date time value
18
+ */
19
+ this.maxDateTimeChangesSubject = new Subject();
20
+ /**
21
+ * Subject used for emitting changes in min date time value
22
+ */
23
+ this.minDateTimeChangesSubject = new Subject();
24
+ /**
25
+ * Date time value format which is being worked with in this date time
26
+ */
27
+ this.ɵValueFormat = DateTimeValueFormat.DateInstance;
28
+ /**
29
+ * Format of string representation of date
30
+ */
31
+ this.ɵFormat = 'date';
32
+ /**
33
+ * Date api instance, used for date time manipulation
34
+ */
35
+ this.dateApi = inject(DATE_API);
36
+ /**
37
+ * Provider for available formats
38
+ */
39
+ this.formatProvider = inject(FORMAT_PROVIDER);
40
+ /**
41
+ * Custom format string representation of date
42
+ */
43
+ this.customFormat = this.dateApi.getFormat(this.formatProvider[this.ɵFormat]);
44
+ }
45
+ //######################### public properties #########################
46
+ /**
47
+ * Occurs when there are changes in max date time value
48
+ */
49
+ get maxDateTimeChanges() {
50
+ return this.maxDateTimeChangesSubject.asObservable();
51
+ }
52
+ /**
53
+ * Occurs when there are changes in min date time value
54
+ */
55
+ get minDateTimeChanges() {
56
+ return this.minDateTimeChangesSubject.asObservable();
57
+ }
58
+ //######################### public properties - inputs #########################
59
+ /**
60
+ * Gets or sets date time value format which is being worked with in this date time
61
+ */
62
+ get valueFormat() {
63
+ return this.ɵValueFormat;
64
+ }
65
+ set valueFormat(value) {
66
+ if (isString(value)) {
67
+ this.ɵValueFormat = DateTimeValueFormat[value];
68
+ return;
69
+ }
70
+ this.ɵValueFormat = value;
71
+ }
72
+ /**
73
+ * Gets or sets format of string representation of date
74
+ */
75
+ get format() {
76
+ return this.ɵFormat;
77
+ }
78
+ set format(value) {
79
+ this.ɵFormat = value;
80
+ this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);
81
+ }
82
+ /**
83
+ * Gets or sets max allowed date for date time
84
+ */
85
+ get maxDateTime() {
86
+ return this.ɵMaxDateTime;
87
+ }
88
+ set maxDateTime(value) {
89
+ this.maxDateInstanceChange?.unsubscribe();
90
+ this.maxDateInstanceChange = null;
91
+ if (isBlank(value)) {
92
+ this.maxDateSet(value);
93
+ return;
94
+ }
95
+ let val = value;
96
+ if (value instanceof (DateTimeBase)) {
97
+ this.maxDateInstanceChange = value.valueChange.subscribe(() => {
98
+ const val = getSingleDateTimeValue(value.value);
99
+ if (isBlank(val)) {
100
+ this.maxDateSet(null);
101
+ return;
102
+ }
103
+ this.setMinMaxValue(val, this.maxDateSet);
104
+ });
105
+ const v = getSingleDateTimeValue(value.value);
106
+ if (isBlank(v)) {
107
+ this.maxDateSet(null);
108
+ return;
109
+ }
110
+ val = v;
111
+ }
112
+ this.setMinMaxValue(val, this.maxDateSet);
113
+ }
114
+ /**
115
+ * Gets or sets min allowed date for date time
116
+ */
117
+ get minDateTime() {
118
+ return this.ɵMinDateTime;
119
+ }
120
+ set minDateTime(value) {
121
+ this.minDateInstanceChange?.unsubscribe();
122
+ this.minDateInstanceChange = null;
123
+ if (isBlank(value)) {
124
+ this.minDateSet(value);
125
+ return;
126
+ }
127
+ let val = value;
128
+ if (value instanceof (DateTimeBase)) {
129
+ this.minDateInstanceChange = value.valueChange.subscribe(() => {
130
+ const val = getSingleDateTimeValue(value.value);
131
+ if (isBlank(val)) {
132
+ this.minDateSet(null);
133
+ return;
134
+ }
135
+ this.setMinMaxValue(val, this.minDateSet);
136
+ });
137
+ const v = getSingleDateTimeValue(value.value);
138
+ if (isBlank(v)) {
139
+ this.minDateSet(null);
140
+ return;
141
+ }
142
+ val = v;
143
+ }
144
+ this.setMinMaxValue(val, this.minDateSet);
145
+ }
146
+ //######################### public methods - implementation of OnDestroy #########################
147
+ /**
148
+ * Called when component is destroyed
149
+ */
150
+ ngOnDestroy() {
151
+ this.maxDateInstanceChange?.unsubscribe();
152
+ this.maxDateInstanceChange = null;
153
+ this.minDateInstanceChange?.unsubscribe();
154
+ this.minDateInstanceChange = null;
155
+ }
156
+ //######################### protected methods #########################
157
+ /**
158
+ * Sets min date time and notifies about changes
159
+ * @param value - Value to be set
160
+ */
161
+ minDateSet(value) {
162
+ this.ɵMinDateTime = value;
163
+ this.minDateTimeChangesSubject.next();
164
+ }
165
+ /**
166
+ * Sets max date time and notifies about changes
167
+ * @param value - Value to be set
168
+ */
169
+ maxDateSet(value) {
170
+ this.ɵMaxDateTime = value;
171
+ this.maxDateTimeChangesSubject.next();
172
+ }
173
+ /**
174
+ * Sets min or max date time value
175
+ * @param value - Value to be set
176
+ * @param setter - Action used for setting value
177
+ */
178
+ setMinMaxValue(value, setter) {
179
+ const val = this.dateApi.getValue(value, this.customFormat);
180
+ if (val.isValid()) {
181
+ setter(val.value);
182
+ }
183
+ else {
184
+ setter(null);
185
+ }
186
+ }
187
+ }
188
+ DateTimeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
189
+ DateTimeDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeDirective, selector: "[dateTime]", inputs: { valueFormat: "valueFormat", format: "format", customFormat: "customFormat", maxDateTime: "maxDateTime", minDateTime: "minDateTime" }, ngImport: i0 });
190
+ __decorate([
191
+ BindThis,
192
+ __metadata("design:type", Function),
193
+ __metadata("design:paramtypes", [Object]),
194
+ __metadata("design:returntype", void 0)
195
+ ], DateTimeDirective.prototype, "minDateSet", null);
196
+ __decorate([
197
+ BindThis,
198
+ __metadata("design:type", Function),
199
+ __metadata("design:paramtypes", [Object]),
200
+ __metadata("design:returntype", void 0)
201
+ ], DateTimeDirective.prototype, "maxDateSet", null);
202
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeDirective, decorators: [{
203
+ type: Directive,
204
+ args: [{
205
+ selector: '[dateTime]'
206
+ }]
207
+ }], propDecorators: { valueFormat: [{
208
+ type: Input
209
+ }], format: [{
210
+ type: Input
211
+ }], customFormat: [{
212
+ type: Input
213
+ }], maxDateTime: [{
214
+ type: Input
215
+ }], minDateTime: [{
216
+ type: Input
217
+ }], minDateSet: [], maxDateSet: [] } });
218
+ //# sourceMappingURL=dateTime.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateTime.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTime/dateTime.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAY,MAAM,eAAe,CAAC;AAClE,OAAO,EAAU,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAa,OAAO,EAAe,MAAM,MAAM,CAAC;AAGvD,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAC,sBAAsB,EAAC,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;;AAE7C;;GAEG;AAKH,MAAM,OAAO,iBAAiB;IAJ9B;QAMI,0EAA0E;QAE1E;;WAEG;QACO,8BAAyB,GAAkB,IAAI,OAAO,EAAQ,CAAC;QAEzE;;WAEG;QACO,8BAAyB,GAAkB,IAAI,OAAO,EAAQ,CAAC;QAsBzE;;WAEG;QACO,iBAAY,GAAwB,mBAAmB,CAAC,YAAY,CAAC;QAE/E;;WAEG;QACO,YAAO,GAAyB,MAAM,CAAC;QAEjD;;WAEG;QACO,YAAO,GAAmB,MAAM,CAAC,QAAQ,CAAC,CAAC;QAErD;;WAEG;QACO,mBAAc,GAAmB,MA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AI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAE5D,IAAG,GAAG,CAAC,OAAO,EAAE,EAChB;YACI,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SACrB;aAED;YACI,MAAM,CAAC,IAAI,CAAC,CAAC;SAChB;IACL,CAAC;;8GAnRQ,iBAAiB;kGAAjB,iBAAiB;;IAgPzB,QAAQ;;;;mDAKR;;IAMA,QAAQ;;;;mDAKR;2FAhQQ,iBAAiB;kBAJ7B,SAAS;mBACV;oBACI,QAAQ,EAAE,YAAY;iBACzB;8BA+Ec,WAAW;sBADrB,KAAK;gBAqBK,MAAM;sBADhB,KAAK;gBAeC,YAAY;sBADlB,KAAK;gBAOK,WAAW;sBADrB,KAAK;gBAsDK,WAAW;sBADrB,KAAK;gBAuEI,UAAU,MAWV,UAAU","sourcesContent":["import {Directive, inject, Input, OnDestroy} from '@angular/core';\nimport {Action1, BindThis, isBlank, isString} from '@jscrpt/common';\nimport {Observable, Subject, Subscription} from 'rxjs';\n\nimport {FormatProvider} from '../../../../interfaces';\nimport {DateTimeValueFormat} from '../../../../misc/enums';\nimport {DATE_API, FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue} from '../../../../misc/types';\nimport {getSingleDateTimeValue} from '../../../../misc/utils';\nimport {DateApi, DateValue} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\n\n/**\n * Directive that holds shared data for date time, like formats, restrictions\n */\n@Directive(\n{\n selector: '[dateTime]'\n})\nexport class DateTimeDirective<TDate = unknown> implements OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Subject used for emitting changes in max date time value\n */\n protected maxDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subject used for emitting changes in min date time value\n */\n protected minDateTimeChangesSubject: Subject<void> = new Subject<void>();\n\n /**\n * Subscription for max date instance value changes\n */\n protected maxDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Subscription for min date instance value changes\n */\n protected minDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Max allowed value of date time\n */\n protected ɵMaxDateTime: TDate|undefined|null;\n\n /**\n * Min allowed value of date time\n */\n protected ɵMinDateTime: TDate|undefined|null;\n\n /**\n * Date time value format which is being worked with in this date time\n */\n protected ɵValueFormat: DateTimeValueFormat = DateTimeValueFormat.DateInstance;\n\n /**\n * Format of string representation of date\n */\n protected ɵFormat: keyof FormatProvider = 'date';\n\n /**\n * Date api instance, used for date time manipulation\n */\n protected dateApi: DateApi<TDate> = inject(DATE_API);\n\n /**\n * Provider for available formats\n */\n protected formatProvider: FormatProvider = inject(FORMAT_PROVIDER);\n\n //######################### public properties #########################\n\n /**\n * Occurs when there are changes in max date time value\n */\n public get maxDateTimeChanges(): Observable<void>\n {\n return this.maxDateTimeChangesSubject.asObservable();\n }\n\n /**\n * Occurs when there are changes in min date time value\n */\n public get minDateTimeChanges(): Observable<void>\n {\n return this.minDateTimeChangesSubject.asObservable();\n }\n\n //######################### public properties - inputs #########################\n\n /**\n * Gets or sets date time value format which is being worked with in this date time\n */\n @Input()\n public get valueFormat(): DateTimeValueFormat\n {\n return this.ɵValueFormat;\n }\n public set valueFormat(value: DateTimeValueFormat)\n {\n if(isString(value))\n {\n this.ɵValueFormat = DateTimeValueFormat[value] as unknown as DateTimeValueFormat;\n\n return;\n }\n\n this.ɵValueFormat = value;\n }\n\n /**\n * Gets or sets format of string representation of date\n */\n @Input()\n public get format(): keyof FormatProvider\n {\n return this.ɵFormat;\n }\n public set format(value: keyof FormatProvider)\n {\n this.ɵFormat = value;\n this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);\n }\n\n /**\n * Custom format string representation of date\n */\n @Input()\n public customFormat: string = this.dateApi.getFormat(this.formatProvider[this.ɵFormat]);\n\n /**\n * Gets or sets max allowed date for date time\n */\n @Input()\n public get maxDateTime(): TDate|undefined|null\n {\n return this.ɵMaxDateTime;\n }\n public set maxDateTime(value: TDate|undefined|null)\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.maxDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase<TDate>)\n {\n this.maxDateInstanceChange = value.valueChange.subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.maxDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.maxDateSet(null);\n\n return;\n }\n\n val = v;\n }\n \n this.setMinMaxValue(val, this.maxDateSet);\n }\n\n /**\n * Gets or sets min allowed date for date time\n */\n @Input()\n public get minDateTime(): TDate|undefined|null\n {\n return this.ɵMinDateTime;\n }\n public set minDateTime(value: TDate|undefined|null)\n {\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n\n if(isBlank(value))\n {\n this.minDateSet(value);\n\n return;\n }\n\n let val: DateTimeInputOutputValue<TDate> = value;\n\n if(value instanceof DateTimeBase<TDate>)\n {\n this.minDateInstanceChange = value.valueChange.subscribe(() =>\n {\n const val = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(val))\n {\n this.minDateSet(null);\n\n return;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n });\n\n const v = getSingleDateTimeValue<TDate>(value.value);\n\n if(isBlank(v))\n {\n this.minDateSet(null);\n\n return;\n }\n\n val = v;\n }\n\n this.setMinMaxValue(val, this.minDateSet);\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.maxDateInstanceChange?.unsubscribe();\n this.maxDateInstanceChange = null;\n\n this.minDateInstanceChange?.unsubscribe();\n this.minDateInstanceChange = null;\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets min date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected minDateSet(value: TDate|undefined|null): void\n {\n this.ɵMinDateTime = value;\n this.minDateTimeChangesSubject.next();\n }\n\n /**\n * Sets max date time and notifies about changes\n * @param value - Value to be set\n */\n @BindThis\n protected maxDateSet(value: TDate|undefined|null): void\n {\n this.ɵMaxDateTime = value;\n this.maxDateTimeChangesSubject.next();\n }\n\n /**\n * Sets min or max date time value\n * @param value - Value to be set\n * @param setter - Action used for setting value\n */\n protected setMinMaxValue(value: string|number|TDate|Date, setter: Action1<TDate|undefined|null>): void\n {\n const val = this.dateApi.getValue(value, this.customFormat);\n\n if(val.isValid())\n {\n setter(val.value);\n }\n else\n {\n setter(null);\n }\n }\n\n //######################### ng language server #########################\n \n /**\n * Custom input type for `valueFormat` input\n */\n public static ngAcceptInputType_valueFormat: keyof typeof DateTimeValueFormat|DateTimeValueFormat;\n\n /**\n * Custom input type for `maxDateTime` input\n */\n public static ngAcceptInputType_maxDateTime: DateValue|DateTimeBase;\n\n /**\n * Custom input type for `minDateTime` input\n */\n public static ngAcceptInputType_minDateTime: DateValue|DateTimeBase;\n}"]}
@@ -1,32 +1,28 @@
1
- import { Directive, EventEmitter, Input } from '@angular/core';
2
- import { isString } from '@jscrpt/common';
3
- import { DateTimeValueFormat } from '../../../misc/enums';
1
+ import { Directive, EventEmitter, inject } from '@angular/core';
2
+ import { Subscription } from 'rxjs';
3
+ import { DateTimeDirective } from './dateTime/dateTime.directive';
4
4
  import * as i0 from "@angular/core";
5
5
  /**
6
6
  * Base class for date time directives, contains basic shared data
7
7
  */
8
8
  export class DateTimeBase {
9
- //######################### constructors #########################
10
- constructor(dateApi, formatProvider) {
11
- this.dateApi = dateApi;
12
- this.formatProvider = formatProvider;
9
+ //######################### constructor #########################
10
+ constructor() {
13
11
  //######################### protected properties #########################
14
12
  /**
15
- * Date time value format which is being worked with in this date time
13
+ * Subscriptions created during initialization
16
14
  */
17
- this.ɵValueFormat = DateTimeValueFormat.DateInstance;
15
+ this.initSubscriptions = new Subscription();
18
16
  /**
19
- * Format of string representation of date
17
+ * Instance of date time shared data, like formats and restrictions
20
18
  */
21
- this.ɵFormat = 'date';
19
+ this.dateTimeData = inject((DateTimeDirective));
22
20
  /**
23
21
  * @inheritdoc
24
22
  */
25
23
  this.valueChange = new EventEmitter();
26
- /**
27
- * Custom format string representation of date
28
- */
29
- this.customFormat = this.dateApi.getFormat(this.formatProvider[this.ɵFormat]);
24
+ this.initSubscriptions.add(this.dateTimeData.maxDateTimeChanges.subscribe(() => this.onMaxDateTimeChange()));
25
+ this.initSubscriptions.add(this.dateTimeData.minDateTimeChanges.subscribe(() => this.onMinDateTimeChange()));
30
26
  }
31
27
  //######################### public properties - implementation of DateTimeInputValue #########################
32
28
  /**
@@ -38,40 +34,28 @@ export class DateTimeBase {
38
34
  set value(value) {
39
35
  this.ɵValue = value;
40
36
  }
41
- //######################### public properties - inputs #########################
37
+ //######################### public methods - implementation of OnDestroy #########################
42
38
  /**
43
- * Gets or sets date time value format which is being worked with in this date time
39
+ * Called when component is destroyed
44
40
  */
45
- get valueFormat() {
46
- return this.ɵValueFormat;
47
- }
48
- set valueFormat(value) {
49
- if (isString(value)) {
50
- this.ɵValueFormat = DateTimeValueFormat[value];
51
- return;
52
- }
53
- this.ɵValueFormat = value;
41
+ ngOnDestroy() {
42
+ this.initSubscriptions.unsubscribe();
54
43
  }
44
+ //######################### protected methods #########################
55
45
  /**
56
- * Gets or sets format of string representation of date
46
+ * Called whenever max date time restriction changes
57
47
  */
58
- get format() {
59
- return this.ɵFormat;
48
+ onMaxDateTimeChange() {
60
49
  }
61
- set format(value) {
62
- this.ɵFormat = value;
63
- this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);
50
+ /**
51
+ * Called whenever min date time restriction changes
52
+ */
53
+ onMinDateTimeChange() {
64
54
  }
65
55
  }
66
- DateTimeBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeBase, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
67
- DateTimeBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeBase, inputs: { valueFormat: "valueFormat", format: "format", customFormat: "customFormat" }, ngImport: i0 });
56
+ DateTimeBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
57
+ DateTimeBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeBase, ngImport: i0 });
68
58
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeBase, decorators: [{
69
59
  type: Directive
70
- }], ctorParameters: function () { return [{ type: undefined }, { type: undefined }]; }, propDecorators: { valueFormat: [{
71
- type: Input
72
- }], format: [{
73
- type: Input
74
- }], customFormat: [{
75
- type: Input
76
- }] } });
60
+ }], ctorParameters: function () { return []; } });
77
61
  //# sourceMappingURL=dateTimeBase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateTimeBase.js","sourceRoot":"","sources":["../../../../../src/modules/dateTime/directives/dateTimeBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;;AAIxD;;GAEG;AAEH,MAAM,OAAO,YAAY;IAgFrB,kEAAkE;IAClE,YAAsB,OAAuB,EACvB,cAA8B;QAD9B,YAAO,GAAP,OAAO,CAAgB;QACvB,mBAAc,GAAd,cAAc,CAAgB;QAhFpD,0EAA0E;QAE1E;;WAEG;QACO,iBAAY,GAAwB,mBAAmB,CAAC,YAAY,CAAC;QAE/E;;WAEG;QACO,YAAO,GAAyB,MAAM,CAAC;QAqBjD;;WAEG;QACI,gBAAW,GAAuB,IAAI,YAAY,EAAQ,CAAC;QAsClE;;WAEG;QAEI,iBAAY,GAAW,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAMxF,CAAC;IAjED,8GAA8G;IAE9G;;OAEG;IACH,IAAW,KAAK;QAEZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACD,IAAW,KAAK,CAAC,KAAqD;QAElE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAOD,gFAAgF;IAEhF;;OAEG;IACH,IACW,WAAW;QAElB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,IAAW,WAAW,CAAC,KAA0B;QAE7C,IAAG,QAAQ,CAAC,KAAK,CAAC,EAClB;YACI,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC,KAAK,CAAmC,CAAC;YAEjF,OAAO;SACV;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IACW,MAAM;QAEb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IACD,IAAW,MAAM,CAAC,KAA2B;QAEzC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,CAAC;;yGAxEQ,YAAY;6FAAZ,YAAY;2FAAZ,YAAY;kBADxB,SAAS;kHA6CK,WAAW;sBADrB,KAAK;gBAqBK,MAAM;sBADhB,KAAK;gBAeC,YAAY;sBADlB,KAAK","sourcesContent":["import {Directive, EventEmitter, Input} from '@angular/core';\nimport {isString} from '@jscrpt/common';\n\nimport {DateTimeInputValue, FormatProvider} from '../../../interfaces';\nimport {DateTimeValueFormat} from '../../../misc/enums';\nimport {DateTimeInputOutputValue} from '../../../misc/types';\nimport {DateApi} from '../../../services';\n\n/**\n * Base class for date time directives, contains basic shared data\n */\n@Directive()\nexport class DateTimeBase<TDate = unknown> implements DateTimeInputValue<TDate>\n{\n //######################### protected properties #########################\n\n /**\n * Date time value format which is being worked with in this date time\n */\n protected ɵValueFormat: DateTimeValueFormat = DateTimeValueFormat.DateInstance;\n\n /**\n * Format of string representation of date\n */\n protected ɵFormat: keyof FormatProvider = 'date';\n\n /**\n * Current value of date time, could be string, unix timestamp, Date, TDate object, or ranged DateTimeValue\n */\n protected ɵValue: DateTimeInputOutputValue<TDate>|undefined|null;\n\n //######################### public properties - implementation of DateTimeInputValue #########################\n\n /**\n * @inheritdoc\n */\n public get value(): DateTimeInputOutputValue<TDate>|undefined|null\n {\n return this.ɵValue;\n }\n public set value(value: DateTimeInputOutputValue<TDate>|undefined|null)\n {\n this.ɵValue = value;\n }\n\n /**\n * @inheritdoc\n */\n public valueChange: EventEmitter<void> = new EventEmitter<void>();\n\n //######################### public properties - inputs #########################\n\n /**\n * Gets or sets date time value format which is being worked with in this date time\n */\n @Input()\n public get valueFormat(): DateTimeValueFormat\n {\n return this.ɵValueFormat;\n }\n public set valueFormat(value: DateTimeValueFormat)\n {\n if(isString(value))\n {\n this.ɵValueFormat = DateTimeValueFormat[value] as unknown as DateTimeValueFormat;\n\n return;\n }\n\n this.ɵValueFormat = value;\n }\n\n /**\n * Gets or sets format of string representation of date\n */\n @Input()\n public get format(): keyof FormatProvider\n {\n return this.ɵFormat;\n }\n public set format(value: keyof FormatProvider)\n {\n this.ɵFormat = value;\n this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);\n }\n\n /**\n * Custom format string representation of date\n */\n @Input()\n public customFormat: string = this.dateApi.getFormat(this.formatProvider[this.ɵFormat]);\n\n //######################### constructors #########################\n constructor(protected dateApi: DateApi<TDate>,\n protected formatProvider: FormatProvider,)\n {\n }\n\n //######################### ng language server #########################\n \n /**\n * Custom input type for `valueFormat` input\n */\n public static ngAcceptInputType_valueFormat: keyof typeof DateTimeValueFormat|DateTimeValueFormat;\n}\n"]}
1
+ {"version":3,"file":"dateTimeBase.js","sourceRoot":"","sources":["../../../../../src/modules/dateTime/directives/dateTimeBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAIlC,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;;AAEhE;;GAEG;AAEH,MAAM,OAAO,YAAY;IAsCrB,iEAAiE;IACjE;QArCA,0EAA0E;QAE1E;;WAEG;QACO,sBAAiB,GAAiB,IAAI,YAAY,EAAE,CAAC;QAO/D;;WAEG;QACO,iBAAY,GAA6B,MAAM,CAAC,CAAA,iBAAwB,CAAA,CAAC,CAAC;QAgBpF;;WAEG;QACI,gBAAW,GAAuB,IAAI,YAAY,EAAQ,CAAC;QAK9D,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;QAC7G,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;IACjH,CAAC;IAxBD,8GAA8G;IAE9G;;OAEG;IACH,IAAW,KAAK;QAEZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACD,IAAW,KAAK,CAAC,KAAqD;QAElE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IAcD,kGAAkG;IAElG;;OAEG;IACI,WAAW;QAEd,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IAED,uEAAuE;IAEvE;;OAEG;IACO,mBAAmB;IAE7B,CAAC;IAED;;OAEG;IACO,mBAAmB;IAE7B,CAAC;;yGArEQ,YAAY;6FAAZ,YAAY;2FAAZ,YAAY;kBADxB,SAAS","sourcesContent":["import {Directive, EventEmitter, inject, OnDestroy} from '@angular/core';\nimport {Subscription} from 'rxjs';\n\nimport {DateTimeInputValue} from '../../../interfaces';\nimport {DateTimeInputOutputValue} from '../../../misc/types';\nimport {DateTimeDirective} from './dateTime/dateTime.directive';\n\n/**\n * Base class for date time directives, contains basic shared data\n */\n@Directive()\nexport class DateTimeBase<TDate = unknown> implements DateTimeInputValue<TDate>, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Subscriptions created during initialization\n */\n protected initSubscriptions: Subscription = new Subscription();\n\n /**\n * Current value of date time, could be string, unix timestamp, Date, TDate object, or ranged DateTimeValue\n */\n protected ɵValue: DateTimeInputOutputValue<TDate>|undefined|null;\n\n /**\n * Instance of date time shared data, like formats and restrictions\n */\n protected dateTimeData: DateTimeDirective<TDate> = inject(DateTimeDirective<TDate>);\n\n //######################### public properties - implementation of DateTimeInputValue #########################\n\n /**\n * @inheritdoc\n */\n public get value(): DateTimeInputOutputValue<TDate>|undefined|null\n {\n return this.ɵValue;\n }\n public set value(value: DateTimeInputOutputValue<TDate>|undefined|null)\n {\n this.ɵValue = value;\n }\n\n /**\n * @inheritdoc\n */\n public valueChange: EventEmitter<void> = new EventEmitter<void>();\n\n //######################### constructor #########################\n constructor()\n {\n this.initSubscriptions.add(this.dateTimeData.maxDateTimeChanges.subscribe(() => this.onMaxDateTimeChange()));\n this.initSubscriptions.add(this.dateTimeData.minDateTimeChanges.subscribe(() => this.onMinDateTimeChange()));\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.initSubscriptions.unsubscribe();\n }\n\n //######################### protected methods #########################\n\n /**\n * Called whenever max date time restriction changes\n */\n protected onMaxDateTimeChange(): void\n {\n }\n\n /**\n * Called whenever min date time restriction changes\n */\n protected onMinDateTimeChange(): void\n {\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import { Directive, ElementRef, EventEmitter, forwardRef, Inject } from '@angular/core';
3
3
  import { BindThis, isBlank } from '@jscrpt/common';
4
- import { DATE_API, DATE_TIME_INPUT, FORMAT_PROVIDER } from '../../../../misc/tokens';
4
+ import { DATE_API, DATE_TIME_INPUT } from '../../../../misc/tokens';
5
5
  import { formatDateTime, parseDateTime } from '../../../../misc/utils';
6
6
  import { DateValueProvider } from '../../../../services';
7
7
  import { DateTimeBase } from '../dateTimeBase';
@@ -13,9 +13,10 @@ import * as i1 from "../../../../services";
13
13
  */
14
14
  export class DateTimeInputDirective extends DateTimeBase {
15
15
  //######################### constructors #########################
16
- constructor(elementRef, dateApi, formatProvider, valueProvider) {
17
- super(dateApi, formatProvider);
16
+ constructor(elementRef, dateApi, valueProvider) {
17
+ super();
18
18
  this.elementRef = elementRef;
19
+ this.dateApi = dateApi;
19
20
  this.valueProvider = valueProvider;
20
21
  /**
21
22
  * @inheritdoc
@@ -48,10 +49,10 @@ export class DateTimeInputDirective extends DateTimeBase {
48
49
  set value(value) {
49
50
  //accepts all available formats
50
51
  this.setInternalValue(value);
51
- this.ɵValue = formatDateTime(this.internalValue, this.valueFormat, this.customFormat);
52
+ this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);
52
53
  //not range value
53
54
  if (!Array.isArray(this.internalValue)) {
54
- this.rawValue = this.internalValue?.format(this.customFormat);
55
+ this.rawValue = this.internalValue?.format(this.dateTimeData.customFormat);
55
56
  }
56
57
  else {
57
58
  //TODO: add support for ranges
@@ -77,6 +78,7 @@ export class DateTimeInputDirective extends DateTimeBase {
77
78
  * Called when component is destroyed
78
79
  */
79
80
  ngOnDestroy() {
81
+ super.ngOnDestroy();
80
82
  this.elementRef.nativeElement.removeEventListener('input', this.handleInput);
81
83
  this.elementRef.nativeElement.removeEventListener('focus', this.handleFocus);
82
84
  this.elementRef.nativeElement.removeEventListener('blur', this.handleBlur);
@@ -87,7 +89,7 @@ export class DateTimeInputDirective extends DateTimeBase {
87
89
  * @param value - Value to be set
88
90
  */
89
91
  setInternalValue(value) {
90
- this.internalValue = parseDateTime(value, this.dateApi, null, this.customFormat);
92
+ this.internalValue = parseDateTime(value, this.dateApi, null, this.dateTimeData.customFormat);
91
93
  if (isBlank(this.internalValue)) {
92
94
  return;
93
95
  }
@@ -95,22 +97,22 @@ export class DateTimeInputDirective extends DateTimeBase {
95
97
  if (Array.isArray(this.internalValue)) {
96
98
  const [from, to] = this.internalValue;
97
99
  if (from) {
98
- const val = this.valueProvider.getValue(from.value, this.customFormat).from;
100
+ const val = this.valueProvider.getValue(from.value, this.dateTimeData.customFormat).from;
99
101
  if (val) {
100
- this.internalValue[0] = this.dateApi.getValue(val, this.customFormat);
102
+ this.internalValue[0] = this.dateApi.getValue(val, this.dateTimeData.customFormat);
101
103
  }
102
104
  }
103
105
  if (to) {
104
- const val = this.valueProvider.getValue(to.value, this.customFormat).to;
106
+ const val = this.valueProvider.getValue(to.value, this.dateTimeData.customFormat).to;
105
107
  if (val) {
106
- this.internalValue[1] = this.dateApi.getValue(val, this.customFormat);
108
+ this.internalValue[1] = this.dateApi.getValue(val, this.dateTimeData.customFormat);
107
109
  }
108
110
  }
109
111
  }
110
112
  else {
111
- const val = this.valueProvider.getValue(this.internalValue.value, this.customFormat).from;
113
+ const val = this.valueProvider.getValue(this.internalValue.value, this.dateTimeData.customFormat).from;
112
114
  if (val) {
113
- this.internalValue = this.dateApi.getValue(val, this.customFormat);
115
+ this.internalValue = this.dateApi.getValue(val, this.dateTimeData.customFormat);
114
116
  }
115
117
  }
116
118
  }
@@ -125,7 +127,7 @@ export class DateTimeInputDirective extends DateTimeBase {
125
127
  return;
126
128
  }
127
129
  this.setInternalValue(this.rawValue);
128
- this.ɵValue = formatDateTime(this.internalValue, this.valueFormat, this.customFormat);
130
+ this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);
129
131
  this.valueChange.next();
130
132
  }
131
133
  /**
@@ -143,7 +145,7 @@ export class DateTimeInputDirective extends DateTimeBase {
143
145
  this.blur.emit(event);
144
146
  }
145
147
  }
146
- DateTimeInputDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeInputDirective, deps: [{ token: i0.ElementRef }, { token: DATE_API }, { token: FORMAT_PROVIDER }, { token: i1.DateValueProvider }], target: i0.ɵɵFactoryTarget.Directive });
148
+ DateTimeInputDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeInputDirective, deps: [{ token: i0.ElementRef }, { token: DATE_API }, { token: i1.DateValueProvider }], target: i0.ɵɵFactoryTarget.Directive });
147
149
  DateTimeInputDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeInputDirective, selector: "input[dateTime][dateTimeInput]", providers: [
148
150
  {
149
151
  provide: DATE_TIME_INPUT,
@@ -183,8 +185,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
183
185
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
184
186
  type: Inject,
185
187
  args: [DATE_API]
186
- }] }, { type: undefined, decorators: [{
187
- type: Inject,
188
- args: [FORMAT_PROVIDER]
189
188
  }] }, { type: i1.DateValueProvider }]; }, propDecorators: { handleInput: [], handleFocus: [], handleBlur: [] } });
190
189
  //# sourceMappingURL=dateTimeInput.directive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateTimeInput.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,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U,CAAC,GAAG,EAAE,uBAAuB,CAAC;yBACxD;qBACJ;oBACD,QAAQ,EAAE,UAAU;iBACvB;;0BAgFgB,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,eAAe;4EA6EzB,WAAW,MAuBX,WAAW,MAUX,UAAU","sourcesContent":["import {Directive, ElementRef, EventEmitter, ExistingProvider, forwardRef, Inject, OnDestroy} from '@angular/core';\nimport {BindThis, isBlank} from '@jscrpt/common';\n\nimport {DateTimeInput, FormatProvider} from '../../../../interfaces';\nimport {DATE_API, DATE_TIME_INPUT, FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue, DateTimeObjectValue} from '../../../../misc/types';\nimport {formatDateTime, parseDateTime} from '../../../../misc/utils';\nimport {DateApi, DateValueProvider} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\n\n//TODO: range is unimplemented\n\n/**\n * Directive that is used for setting up date time input\n */\n@Directive(\n{\n selector: 'input[dateTime][dateTimeInput]',\n providers:\n [\n <ExistingProvider>\n {\n provide: DATE_TIME_INPUT,\n useExisting: forwardRef(() => DateTimeInputDirective),\n },\n ],\n exportAs: 'dateTime',\n})\nexport class DateTimeInputDirective<TDate = unknown> extends DateTimeBase<TDate> implements DateTimeInput, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Internal representation of current date time value\n */\n protected internalValue: DateTimeObjectValue<TDate>|undefined|null;\n\n //######################### public properties - implementation of DateTimeInput #########################\n\n /**\n * @inheritdoc\n */\n public get rawValue(): string|undefined|null\n {\n return this.elementRef.nativeElement.value;\n }\n public set rawValue(value: string|undefined|null)\n {\n this.elementRef.nativeElement.value = value ?? '';\n }\n\n /**\n * @inheritdoc\n */\n public override get value(): DateTimeInputOutputValue<TDate>|undefined|null\n {\n return this.ɵValue;\n }\n public override set value(value: DateTimeInputOutputValue<TDate>|undefined|null)\n {\n //accepts all available formats\n this.setInternalValue(value);\n this.ɵValue = formatDateTime(this.internalValue, this.valueFormat, this.customFormat);\n \n //not range value\n if(!Array.isArray(this.internalValue))\n {\n this.rawValue = this.internalValue?.format(this.customFormat);\n }\n else\n {\n //TODO: add support for ranges\n }\n }\n\n /**\n * @inheritdoc\n */\n public get disabled(): boolean\n {\n return this.elementRef.nativeElement.disabled;\n }\n public set disabled(value: boolean)\n {\n this.elementRef.nativeElement.disabled = value;\n }\n\n /**\n * Html element that represents input itself\n */\n public get element(): HTMLElement\n {\n return this.elementRef.nativeElement;\n }\n\n /**\n * @inheritdoc\n */\n public focus: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();\n\n /**\n * @inheritdoc\n */\n public blur: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();\n\n //######################### constructors #########################\n constructor(protected elementRef: ElementRef<HTMLInputElement>,\n @Inject(DATE_API) dateApi: DateApi<TDate>,\n @Inject(FORMAT_PROVIDER) formatProvider: FormatProvider,\n protected valueProvider: DateValueProvider<TDate>,)\n {\n super(dateApi, formatProvider);\n\n this.elementRef.nativeElement.addEventListener('input', this.handleInput);\n this.elementRef.nativeElement.addEventListener('focus', this.handleFocus);\n this.elementRef.nativeElement.addEventListener('blur', this.handleBlur);\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public ngOnDestroy(): void\n {\n this.elementRef.nativeElement.removeEventListener('input', this.handleInput);\n this.elementRef.nativeElement.removeEventListener('focus', this.handleFocus);\n this.elementRef.nativeElement.removeEventListener('blur', this.handleBlur);\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets internal value and fix lowest time difference\n * @param value - Value to be set\n */\n protected setInternalValue(value: DateTimeInputOutputValue<TDate>|undefined|null): void\n {\n this.internalValue = parseDateTime(value, this.dateApi, null, this.customFormat);\n\n if(isBlank(this.internalValue))\n {\n return;\n }\n\n //ranged value\n if(Array.isArray(this.internalValue))\n {\n const [from, to] = this.internalValue;\n\n if(from)\n {\n const val = this.valueProvider.getValue(from.value, this.customFormat).from;\n\n if(val)\n {\n this.internalValue[0] = this.dateApi.getValue(val, this.customFormat);\n }\n }\n\n if(to)\n {\n const val = this.valueProvider.getValue(to.value, this.customFormat).to;\n\n if(val)\n {\n this.internalValue[1] = this.dateApi.getValue(val, this.customFormat);\n }\n }\n }\n else\n {\n const val = this.valueProvider.getValue(this.internalValue.value, this.customFormat).from;\n\n if(val)\n {\n this.internalValue = this.dateApi.getValue(val, this.customFormat);\n }\n }\n }\n\n /**\n * Handles input event on input\n */\n @BindThis\n protected handleInput(): void\n {\n if(!this.rawValue)\n {\n this.internalValue = null;\n this.ɵValue = null;\n\n this.valueChange.next();\n\n return;\n }\n\n this.setInternalValue(this.rawValue);\n this.ɵValue = formatDateTime(this.internalValue, this.valueFormat, this.customFormat);\n\n this.valueChange.next();\n }\n\n /**\n * Handles focus event on input\n * @param event - Event that occured\n */\n @BindThis\n protected handleFocus(event: FocusEvent): void\n {\n this.focus.emit(event);\n }\n\n /**\n * Handles blur event on input\n * @param event - Event that occured\n */\n @BindThis\n protected handleBlur(event: FocusEvent): void\n {\n this.blur.emit(event);\n }\n}"]}
1
+ {"version":3,"file":"dateTimeInput.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,YAAY,EAAoB,UAAU,EAAE,MAAM,EAAY,MAAM,eAAe,CAAC;AACnH,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAU,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;;;AAE7C,8BAA8B;AAE9B;;GAEG;AAcH,MAAM,OAAO,sBAAwC,SAAQ,YA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AC,WAAW,CAAC,IAAI,EAAE,CAAC;YAExB,OAAO;SACV;QAED,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAEhH,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;;OAGG;IAEO,WAAW,CAAC,KAAiB;QAEnC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IAEO,UAAU,CAAC,KAAiB;QAElC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;;mHAlMQ,sBAAsB,4CA+EX,QAAQ;uGA/EnB,sBAAsB,yDAT/B;QAEI;YACI,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;SACxD;KACJ;;IAgKA,QAAQ;;;;yDAiBR;;IAMA,QAAQ;;qCACoB,UAAU;;yDAGtC;;IAMA,QAAQ;;qCACmB,UAAU;;wDAGrC;2FAlMQ,sBAAsB;kBAblC,SAAS;mBACV;oBACI,QAAQ,EAAE,gCAAgC;oBAC1C,SAAS,EACT;wBAEI;4BACI,OAAO,EAAE,eAAe;4BACxB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,uBAAuB,CAAC;yBACxD;qBACJ;oBACD,QAAQ,EAAE,UAAU;iBACvB;;0BAgFgB,MAAM;2BAAC,QAAQ;4EA+ElB,WAAW,MAuBX,WAAW,MAUX,UAAU","sourcesContent":["import {Directive, ElementRef, EventEmitter, ExistingProvider, forwardRef, Inject, OnDestroy} from '@angular/core';\nimport {BindThis, isBlank} from '@jscrpt/common';\n\nimport {DateTimeInput} from '../../../../interfaces';\nimport {DATE_API, DATE_TIME_INPUT} from '../../../../misc/tokens';\nimport {DateTimeInputOutputValue, DateTimeObjectValue} from '../../../../misc/types';\nimport {formatDateTime, parseDateTime} from '../../../../misc/utils';\nimport {DateApi, DateValueProvider} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\n\n//TODO: range is unimplemented\n\n/**\n * Directive that is used for setting up date time input\n */\n@Directive(\n{\n selector: 'input[dateTime][dateTimeInput]',\n providers:\n [\n <ExistingProvider>\n {\n provide: DATE_TIME_INPUT,\n useExisting: forwardRef(() => DateTimeInputDirective),\n },\n ],\n exportAs: 'dateTime',\n})\nexport class DateTimeInputDirective<TDate = unknown> extends DateTimeBase<TDate> implements DateTimeInput, OnDestroy\n{\n //######################### protected properties #########################\n\n /**\n * Internal representation of current date time value\n */\n protected internalValue: DateTimeObjectValue<TDate>|undefined|null;\n\n //######################### public properties - implementation of DateTimeInput #########################\n\n /**\n * @inheritdoc\n */\n public get rawValue(): string|undefined|null\n {\n return this.elementRef.nativeElement.value;\n }\n public set rawValue(value: string|undefined|null)\n {\n this.elementRef.nativeElement.value = value ?? '';\n }\n\n /**\n * @inheritdoc\n */\n public override get value(): DateTimeInputOutputValue<TDate>|undefined|null\n {\n return this.ɵValue;\n }\n public override set value(value: DateTimeInputOutputValue<TDate>|undefined|null)\n {\n //accepts all available formats\n this.setInternalValue(value);\n this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);\n \n //not range value\n if(!Array.isArray(this.internalValue))\n {\n this.rawValue = this.internalValue?.format(this.dateTimeData.customFormat);\n }\n else\n {\n //TODO: add support for ranges\n }\n }\n\n /**\n * @inheritdoc\n */\n public get disabled(): boolean\n {\n return this.elementRef.nativeElement.disabled;\n }\n public set disabled(value: boolean)\n {\n this.elementRef.nativeElement.disabled = value;\n }\n\n /**\n * Html element that represents input itself\n */\n public get element(): HTMLElement\n {\n return this.elementRef.nativeElement;\n }\n\n /**\n * @inheritdoc\n */\n public focus: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();\n\n /**\n * @inheritdoc\n */\n public blur: EventEmitter<FocusEvent> = new EventEmitter<FocusEvent>();\n\n //######################### constructors #########################\n constructor(protected elementRef: ElementRef<HTMLInputElement>,\n @Inject(DATE_API) protected dateApi: DateApi<TDate>,\n protected valueProvider: DateValueProvider<TDate>,)\n {\n super();\n\n this.elementRef.nativeElement.addEventListener('input', this.handleInput);\n this.elementRef.nativeElement.addEventListener('focus', this.handleFocus);\n this.elementRef.nativeElement.addEventListener('blur', this.handleBlur);\n }\n\n //######################### public methods - implementation of OnDestroy #########################\n \n /**\n * Called when component is destroyed\n */\n public override ngOnDestroy(): void\n {\n super.ngOnDestroy();\n\n this.elementRef.nativeElement.removeEventListener('input', this.handleInput);\n this.elementRef.nativeElement.removeEventListener('focus', this.handleFocus);\n this.elementRef.nativeElement.removeEventListener('blur', this.handleBlur);\n }\n\n //######################### protected methods #########################\n\n /**\n * Sets internal value and fix lowest time difference\n * @param value - Value to be set\n */\n protected setInternalValue(value: DateTimeInputOutputValue<TDate>|undefined|null): void\n {\n this.internalValue = parseDateTime(value, this.dateApi, null, this.dateTimeData.customFormat);\n\n if(isBlank(this.internalValue))\n {\n return;\n }\n\n //ranged value\n if(Array.isArray(this.internalValue))\n {\n const [from, to] = this.internalValue;\n\n if(from)\n {\n const val = this.valueProvider.getValue(from.value, this.dateTimeData.customFormat).from;\n\n if(val)\n {\n this.internalValue[0] = this.dateApi.getValue(val, this.dateTimeData.customFormat);\n }\n }\n\n if(to)\n {\n const val = this.valueProvider.getValue(to.value, this.dateTimeData.customFormat).to;\n\n if(val)\n {\n this.internalValue[1] = this.dateApi.getValue(val, this.dateTimeData.customFormat);\n }\n }\n }\n else\n {\n const val = this.valueProvider.getValue(this.internalValue.value, this.dateTimeData.customFormat).from;\n\n if(val)\n {\n this.internalValue = this.dateApi.getValue(val, this.dateTimeData.customFormat);\n }\n }\n }\n\n /**\n * Handles input event on input\n */\n @BindThis\n protected handleInput(): void\n {\n if(!this.rawValue)\n {\n this.internalValue = null;\n this.ɵValue = null;\n\n this.valueChange.next();\n\n return;\n }\n\n this.setInternalValue(this.rawValue);\n this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);\n\n this.valueChange.next();\n }\n\n /**\n * Handles focus event on input\n * @param event - Event that occured\n */\n @BindThis\n protected handleFocus(event: FocusEvent): void\n {\n this.focus.emit(event);\n }\n\n /**\n * Handles blur event on input\n * @param event - Event that occured\n */\n @BindThis\n protected handleBlur(event: FocusEvent): void\n {\n this.blur.emit(event);\n }\n}"]}
@@ -1,29 +1,29 @@
1
1
  import { Directive, forwardRef, Inject } from '@angular/core';
2
2
  import { NG_VALIDATORS } from '@angular/forms';
3
- import { DATE_API, FORMAT_PROVIDER } from '../../../../misc/tokens';
4
- import { datetimeMaxValidator, datetimeValidator } from '../../../../misc/validators';
5
- import { DateTimeRestrictedBase } from '../dateTimeRestrictedBase';
3
+ import { DATE_API } from '../../../../misc/tokens';
4
+ import { datetimeMaxValidator } from '../../../../misc/validators';
5
+ import { DateTimeBase } from '../dateTimeBase';
6
6
  import * as i0 from "@angular/core";
7
7
  /**
8
8
  * Applies validator for date time max value
9
9
  */
10
- export class DateTimeMaxValidatorDirective extends DateTimeRestrictedBase {
10
+ export class DateTimeMaxValidatorDirective extends DateTimeBase {
11
11
  //######################### constructor #########################
12
- constructor(dateApi, formatProvider) {
13
- super(dateApi, formatProvider);
12
+ constructor(dateApi) {
13
+ super();
14
+ this.dateApi = dateApi;
14
15
  //######################### private fields #########################
15
16
  /**
16
17
  * Function used for validations
17
18
  */
18
19
  this._validator = () => null;
19
- this._validator = datetimeValidator(dateApi, null, null);
20
20
  }
21
21
  //######################### public methods - implementation of OnInit #########################
22
22
  /**
23
23
  * Initialize component
24
24
  */
25
25
  ngOnInit() {
26
- this._validator = datetimeMaxValidator(this.dateApi, this.maxDateTime, this.valueFormat, this.customFormat);
26
+ this._validator = datetimeMaxValidator(this.dateApi, this.dateTimeData.maxDateTime, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);
27
27
  }
28
28
  //######################### public methods - implementation of Validator #########################
29
29
  /**
@@ -39,10 +39,10 @@ export class DateTimeMaxValidatorDirective extends DateTimeRestrictedBase {
39
39
  * @inheritdoc
40
40
  */
41
41
  onMaxDateTimeChange() {
42
- this._validator = datetimeMaxValidator(this.dateApi, this.maxDateTime, this.valueFormat, this.customFormat);
42
+ this._validator = datetimeMaxValidator(this.dateApi, this.dateTimeData.maxDateTime, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);
43
43
  }
44
44
  }
45
- DateTimeMaxValidatorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeMaxValidatorDirective, deps: [{ token: DATE_API }, { token: FORMAT_PROVIDER }], target: i0.ɵɵFactoryTarget.Directive });
45
+ DateTimeMaxValidatorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeMaxValidatorDirective, deps: [{ token: DATE_API }], target: i0.ɵɵFactoryTarget.Directive });
46
46
  DateTimeMaxValidatorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeMaxValidatorDirective, selector: "[dateTime][maxDateTime][validate]", providers: [
47
47
  {
48
48
  provide: NG_VALIDATORS,
@@ -65,8 +65,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
65
65
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
66
66
  type: Inject,
67
67
  args: [DATE_API]
68
- }] }, { type: undefined, decorators: [{
69
- type: Inject,
70
- args: [FORMAT_PROVIDER]
71
68
  }] }]; } });
72
69
  //# sourceMappingURL=dateTimeMaxValidator.directive.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateTimeMaxValidator.directive.js","sourceRoot":"","sources":["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AChH,CAAC;;0HA/CQ,6BAA6B,kBAUlB,QAAQ,aACR,eAAe;8GAX1B,6BAA6B,4DATtC;QAEI;YACI,OAAO,EAAE,aAAa;YACtB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,6BAA6B,CAAC;YAC5D,KAAK,EAAE,IAAI;SACd;KACJ;2FAEQ,6BAA6B;kBAbzC,SAAS;mBACV;oBACI,QAAQ,EAAE,mCAAmC;oBAC7C,SAAS,EACT;wBAEI;4BACI,OAAO,EAAE,aAAa;4BACtB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,8BAA8B,CAAC;4BAC5D,KAAK,EAAE,IAAI;yBACd;qBACJ;iBACJ;;0BAWgB,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,eAAe","sourcesContent":["import {Directive, ExistingProvider, forwardRef, Inject, OnInit} from '@angular/core';\nimport {AbstractControl, NG_VALIDATORS, ValidationErrors, Validator, ValidatorFn} from '@angular/forms';\n\nimport {FormatProvider} from '../../../../interfaces';\nimport {DATE_API, FORMAT_PROVIDER} from '../../../../misc/tokens';\nimport {datetimeMaxValidator, datetimeValidator} from '../../../../misc/validators';\nimport {DateApi} from '../../../../services';\nimport {DateTimeRestrictedBase} from '../dateTimeRestrictedBase';\n\n/**\n * Applies validator for date time max value\n */\n@Directive(\n{\n selector: '[dateTime][maxDateTime][validate]',\n providers:\n [\n <ExistingProvider>\n {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => DateTimeMaxValidatorDirective),\n multi: true\n },\n ],\n})\nexport class DateTimeMaxValidatorDirective<TDate = unknown> extends DateTimeRestrictedBase<TDate> implements Validator, OnInit\n{\n //######################### private fields #########################\n\n /**\n * Function used for validations\n */\n private _validator: ValidatorFn = () => null;\n\n //######################### constructor #########################\n constructor(@Inject(DATE_API) dateApi: DateApi<TDate>,\n @Inject(FORMAT_PROVIDER) formatProvider: FormatProvider,)\n {\n super(dateApi, formatProvider);\n this._validator = datetimeValidator(dateApi, null, null);\n }\n\n //######################### public methods - implementation of OnInit #########################\n \n /**\n * Initialize component\n */\n public ngOnInit(): void\n {\n this._validator = datetimeMaxValidator(this.dateApi, this.maxDateTime, this.valueFormat, this.customFormat);\n }\n\n //######################### public methods - implementation of Validator #########################\n\n /**\n * Validates input and returns validation result\n * @param control - Control that is being validated\n * @returns validation results\n */\n public validate(control: AbstractControl): ValidationErrors|null\n {\n return this._validator(control);\n }\n\n //######################### protected methods - overrides #########################\n\n /**\n * @inheritdoc\n */\n protected override onMaxDateTimeChange(): void\n {\n this._validator = datetimeMaxValidator(this.dateApi, this.maxDateTime, this.valueFormat, this.customFormat);\n }\n}"]}
1
+ {"version":3,"file":"dateTimeMaxValidator.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAoB,UAAU,EAAE,MAAM,EAAS,MAAM,eAAe,CAAC;AACtF,OAAO,EAAkB,aAAa,EAA2C,MAAM,gBAAgB,CAAC;AAExG,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;;AAE7C;;GAEG;AAcH,MAAM,OAAO,6BAA+C,SAAQ,YAAmB;IASnF,iEAAiE;IACjE,YAAwC,OAAuB;QAE3D,KAAK,EAAE,CAAC;QAF4B,YAAO,GAAP,OAAO,CAAgB;QAR/D,oEAAoE;QAEpE;;WAEG;QACK,eAAU,GAAgB,GAAG,EAAE,CAAC,IAAI,CAAC;IAM7C,CAAC;IAED,+FAA+F;IAE/F;;OAEG;IACI,QAAQ;QAEX,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACvJ,CAAC;IAED,kGAAkG;IAElG;;;;OAIG;IACI,QAAQ,CAAC,OAAwB;QAEpC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,mFAAmF;IAEnF;;OAEG;IACgB,mBAAmB;QAElC,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACvJ,CAAC;;0HA7CQ,6BAA6B,kBAUlB,QAAQ;8GAVnB,6BAA6B,4DATtC;QAEI;YACI,OAAO,EAAE,aAAa;YACtB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,6BAA6B,CAAC;YAC5D,KAAK,EAAE,IAAI;SACd;KACJ;2FAEQ,6BAA6B;kBAbzC,SAAS;mBACV;oBACI,QAAQ,EAAE,mCAAmC;oBAC7C,SAAS,EACT;wBAEI;4BACI,OAAO,EAAE,aAAa;4BACtB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,8BAA8B,CAAC;4BAC5D,KAAK,EAAE,IAAI;yBACd;qBACJ;iBACJ;;0BAWgB,MAAM;2BAAC,QAAQ","sourcesContent":["import {Directive, ExistingProvider, forwardRef, Inject, OnInit} from '@angular/core';\nimport {AbstractControl, NG_VALIDATORS, ValidationErrors, Validator, ValidatorFn} from '@angular/forms';\n\nimport {DATE_API} from '../../../../misc/tokens';\nimport {datetimeMaxValidator} from '../../../../misc/validators';\nimport {DateApi} from '../../../../services';\nimport {DateTimeBase} from '../dateTimeBase';\n\n/**\n * Applies validator for date time max value\n */\n@Directive(\n{\n selector: '[dateTime][maxDateTime][validate]',\n providers:\n [\n <ExistingProvider>\n {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => DateTimeMaxValidatorDirective),\n multi: true\n },\n ],\n})\nexport class DateTimeMaxValidatorDirective<TDate = unknown> extends DateTimeBase<TDate> implements Validator, OnInit\n{\n //######################### private fields #########################\n\n /**\n * Function used for validations\n */\n private _validator: ValidatorFn = () => null;\n\n //######################### constructor #########################\n constructor(@Inject(DATE_API) protected dateApi: DateApi<TDate>,)\n {\n super();\n }\n\n //######################### public methods - implementation of OnInit #########################\n \n /**\n * Initialize component\n */\n public ngOnInit(): void\n {\n this._validator = datetimeMaxValidator(this.dateApi, this.dateTimeData.maxDateTime, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);\n }\n\n //######################### public methods - implementation of Validator #########################\n\n /**\n * Validates input and returns validation result\n * @param control - Control that is being validated\n * @returns validation results\n */\n public validate(control: AbstractControl): ValidationErrors|null\n {\n return this._validator(control);\n }\n\n //######################### protected methods - overrides #########################\n\n /**\n * @inheritdoc\n */\n protected override onMaxDateTimeChange(): void\n {\n this._validator = datetimeMaxValidator(this.dateApi, this.dateTimeData.maxDateTime, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);\n }\n}"]}