@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
package/changelog.md CHANGED
@@ -19,6 +19,7 @@
19
19
  - `element` html element that represents input itself
20
20
  - new `DateTimeModule` module for basic date time directives, components, pipes
21
21
  - **exports**
22
+ - `DateTimeDirective,`
22
23
  - `DateTimeControlValueAccessorDirective`
23
24
  - `DateTimeInputDirective`
24
25
  - `DateTimeMaxValidatorDirective`
@@ -28,17 +29,7 @@
28
29
  - new `DateTimeBase` class, that is base class for date time directives, contains basic shared data
29
30
  - **implements**
30
31
  - `DateTimeInputValue`
31
- - **inputs**
32
- - `valueFormat` gets or sets date time value format which is being worked with in this date time
33
- - `format` gets or sets format of string representation of date
34
- - `customFormat` custom format string representation of date
35
- - new `DateTimeRestrictedBase` class, that is base class for date time directives with value restrictions
36
- - **extends** `DateTimeBase`
37
- - **implements**
38
32
  - `OnDestroy`
39
- - **inputs**
40
- - `maxDateTime` gets or sets max allowed date for date time
41
- - `minDateTime` gets or sets min allowed date for date time
42
33
  - new `DateTimeInputDirective` directive, that is used for setting up date time input
43
34
  - **extends** `DateTimeBase`
44
35
  - **implements**
@@ -60,14 +51,14 @@
60
51
  - **provides**
61
52
  - `NG_VALIDATORS` providing self
62
53
  - new `DateTimeMaxValidatorDirective` directive, that applies validator for date time max value
63
- - **extends** `DateTimeRestrictedBase`
54
+ - **extends** `DateTimeBase`
64
55
  - **implements**
65
56
  - `Validator`
66
57
  - `OnInit`
67
58
  - **provides**
68
59
  - `NG_VALIDATORS` providing self
69
60
  - new `DateTimeMinValidatorDirective` directive, that applies validator for date time min value
70
- - **extends** `DateTimeRestrictedBase`
61
+ - **extends** `DateTimeBase`
71
62
  - **implements**
72
63
  - `Validator`
73
64
  - `OnInit`
@@ -109,7 +100,7 @@
109
100
  - `showPicker` hides date time picker
110
101
  - `hidePicker` shows date time picker
111
102
  - new `DateTimePickerComponent` directive, which is component used for displaying date time picker
112
- - **extends** `DateTimeRestrictedBase`
103
+ - **extends** `DateTimeDirective`
113
104
  - **implements**
114
105
  - `DateTimeInputValue`
115
106
  - `OnChanges`
@@ -148,6 +139,18 @@
148
139
  - **properties**
149
140
  - `periodsDefinition` definition of types for each period type for picker
150
141
  - `defaultPeriod` name of default period for picker that is displayed after opening
142
+ - new `DateTimeDirective` directive, that holds shared data for date time, like formats, restrictions
143
+ - **implements**
144
+ - `OnDestroy`
145
+ - **properties**
146
+ - `maxDateTimeChanges` occurs when there are changes in max date time value
147
+ - `minDateTimeChanges` occurs when there are changes in min date time value
148
+ - **inputs**
149
+ - `valueFormat` gets or sets date time value format which is being worked with in this date time
150
+ - `format` gets or sets format of string representation of date
151
+ - `customFormat` custom format string representation of date
152
+ - `maxDateTime` gets or sets max allowed date for date time
153
+ - `minDateTime` gets or sets min allowed date for date time
151
154
  - updated `DateApiObject` interface
152
155
  - new `unixTimestamp` method, that gets value of date time as unix timestamp
153
156
  - updated `DateFormatPipe`
@@ -0,0 +1,221 @@
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
+ var _a;
90
+ (_a = this.maxDateInstanceChange) === null || _a === void 0 ? void 0 : _a.unsubscribe();
91
+ this.maxDateInstanceChange = null;
92
+ if (isBlank(value)) {
93
+ this.maxDateSet(value);
94
+ return;
95
+ }
96
+ let val = value;
97
+ if (value instanceof (DateTimeBase)) {
98
+ this.maxDateInstanceChange = value.valueChange.subscribe(() => {
99
+ const val = getSingleDateTimeValue(value.value);
100
+ if (isBlank(val)) {
101
+ this.maxDateSet(null);
102
+ return;
103
+ }
104
+ this.setMinMaxValue(val, this.maxDateSet);
105
+ });
106
+ const v = getSingleDateTimeValue(value.value);
107
+ if (isBlank(v)) {
108
+ this.maxDateSet(null);
109
+ return;
110
+ }
111
+ val = v;
112
+ }
113
+ this.setMinMaxValue(val, this.maxDateSet);
114
+ }
115
+ /**
116
+ * Gets or sets min allowed date for date time
117
+ */
118
+ get minDateTime() {
119
+ return this.ɵMinDateTime;
120
+ }
121
+ set minDateTime(value) {
122
+ var _a;
123
+ (_a = this.minDateInstanceChange) === null || _a === void 0 ? void 0 : _a.unsubscribe();
124
+ this.minDateInstanceChange = null;
125
+ if (isBlank(value)) {
126
+ this.minDateSet(value);
127
+ return;
128
+ }
129
+ let val = value;
130
+ if (value instanceof (DateTimeBase)) {
131
+ this.minDateInstanceChange = value.valueChange.subscribe(() => {
132
+ const val = getSingleDateTimeValue(value.value);
133
+ if (isBlank(val)) {
134
+ this.minDateSet(null);
135
+ return;
136
+ }
137
+ this.setMinMaxValue(val, this.minDateSet);
138
+ });
139
+ const v = getSingleDateTimeValue(value.value);
140
+ if (isBlank(v)) {
141
+ this.minDateSet(null);
142
+ return;
143
+ }
144
+ val = v;
145
+ }
146
+ this.setMinMaxValue(val, this.minDateSet);
147
+ }
148
+ //######################### public methods - implementation of OnDestroy #########################
149
+ /**
150
+ * Called when component is destroyed
151
+ */
152
+ ngOnDestroy() {
153
+ var _a, _b;
154
+ (_a = this.maxDateInstanceChange) === null || _a === void 0 ? void 0 : _a.unsubscribe();
155
+ this.maxDateInstanceChange = null;
156
+ (_b = this.minDateInstanceChange) === null || _b === void 0 ? void 0 : _b.unsubscribe();
157
+ this.minDateInstanceChange = null;
158
+ }
159
+ //######################### protected methods #########################
160
+ /**
161
+ * Sets min date time and notifies about changes
162
+ * @param value - Value to be set
163
+ */
164
+ minDateSet(value) {
165
+ this.ɵMinDateTime = value;
166
+ this.minDateTimeChangesSubject.next();
167
+ }
168
+ /**
169
+ * Sets max date time and notifies about changes
170
+ * @param value - Value to be set
171
+ */
172
+ maxDateSet(value) {
173
+ this.ɵMaxDateTime = value;
174
+ this.maxDateTimeChangesSubject.next();
175
+ }
176
+ /**
177
+ * Sets min or max date time value
178
+ * @param value - Value to be set
179
+ * @param setter - Action used for setting value
180
+ */
181
+ setMinMaxValue(value, setter) {
182
+ const val = this.dateApi.getValue(value, this.customFormat);
183
+ if (val.isValid()) {
184
+ setter(val.value);
185
+ }
186
+ else {
187
+ setter(null);
188
+ }
189
+ }
190
+ }
191
+ DateTimeDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
192
+ 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 });
193
+ __decorate([
194
+ BindThis,
195
+ __metadata("design:type", Function),
196
+ __metadata("design:paramtypes", [Object]),
197
+ __metadata("design:returntype", void 0)
198
+ ], DateTimeDirective.prototype, "minDateSet", null);
199
+ __decorate([
200
+ BindThis,
201
+ __metadata("design:type", Function),
202
+ __metadata("design:paramtypes", [Object]),
203
+ __metadata("design:returntype", void 0)
204
+ ], DateTimeDirective.prototype, "maxDateSet", null);
205
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeDirective, decorators: [{
206
+ type: Directive,
207
+ args: [{
208
+ selector: '[dateTime]'
209
+ }]
210
+ }], propDecorators: { valueFormat: [{
211
+ type: Input
212
+ }], format: [{
213
+ type: Input
214
+ }], customFormat: [{
215
+ type: Input
216
+ }], maxDateTime: [{
217
+ type: Input
218
+ }], minDateTime: [{
219
+ type: Input
220
+ }], minDateSet: [], maxDateSet: [] } });
221
+ //# 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,CAA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,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
@@ -49,10 +50,10 @@ export class DateTimeInputDirective extends DateTimeBase {
49
50
  var _a;
50
51
  //accepts all available formats
51
52
  this.setInternalValue(value);
52
- this.ɵValue = formatDateTime(this.internalValue, this.valueFormat, this.customFormat);
53
+ this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);
53
54
  //not range value
54
55
  if (!Array.isArray(this.internalValue)) {
55
- this.rawValue = (_a = this.internalValue) === null || _a === void 0 ? void 0 : _a.format(this.customFormat);
56
+ this.rawValue = (_a = this.internalValue) === null || _a === void 0 ? void 0 : _a.format(this.dateTimeData.customFormat);
56
57
  }
57
58
  else {
58
59
  //TODO: add support for ranges
@@ -78,6 +79,7 @@ export class DateTimeInputDirective extends DateTimeBase {
78
79
  * Called when component is destroyed
79
80
  */
80
81
  ngOnDestroy() {
82
+ super.ngOnDestroy();
81
83
  this.elementRef.nativeElement.removeEventListener('input', this.handleInput);
82
84
  this.elementRef.nativeElement.removeEventListener('focus', this.handleFocus);
83
85
  this.elementRef.nativeElement.removeEventListener('blur', this.handleBlur);
@@ -88,7 +90,7 @@ export class DateTimeInputDirective extends DateTimeBase {
88
90
  * @param value - Value to be set
89
91
  */
90
92
  setInternalValue(value) {
91
- this.internalValue = parseDateTime(value, this.dateApi, null, this.customFormat);
93
+ this.internalValue = parseDateTime(value, this.dateApi, null, this.dateTimeData.customFormat);
92
94
  if (isBlank(this.internalValue)) {
93
95
  return;
94
96
  }
@@ -96,22 +98,22 @@ export class DateTimeInputDirective extends DateTimeBase {
96
98
  if (Array.isArray(this.internalValue)) {
97
99
  const [from, to] = this.internalValue;
98
100
  if (from) {
99
- const val = this.valueProvider.getValue(from.value, this.customFormat).from;
101
+ const val = this.valueProvider.getValue(from.value, this.dateTimeData.customFormat).from;
100
102
  if (val) {
101
- this.internalValue[0] = this.dateApi.getValue(val, this.customFormat);
103
+ this.internalValue[0] = this.dateApi.getValue(val, this.dateTimeData.customFormat);
102
104
  }
103
105
  }
104
106
  if (to) {
105
- const val = this.valueProvider.getValue(to.value, this.customFormat).to;
107
+ const val = this.valueProvider.getValue(to.value, this.dateTimeData.customFormat).to;
106
108
  if (val) {
107
- this.internalValue[1] = this.dateApi.getValue(val, this.customFormat);
109
+ this.internalValue[1] = this.dateApi.getValue(val, this.dateTimeData.customFormat);
108
110
  }
109
111
  }
110
112
  }
111
113
  else {
112
- const val = this.valueProvider.getValue(this.internalValue.value, this.customFormat).from;
114
+ const val = this.valueProvider.getValue(this.internalValue.value, this.dateTimeData.customFormat).from;
113
115
  if (val) {
114
- this.internalValue = this.dateApi.getValue(val, this.customFormat);
116
+ this.internalValue = this.dateApi.getValue(val, this.dateTimeData.customFormat);
115
117
  }
116
118
  }
117
119
  }
@@ -126,7 +128,7 @@ export class DateTimeInputDirective extends DateTimeBase {
126
128
  return;
127
129
  }
128
130
  this.setInternalValue(this.rawValue);
129
- this.ɵValue = formatDateTime(this.internalValue, this.valueFormat, this.customFormat);
131
+ this.ɵValue = formatDateTime(this.internalValue, this.dateTimeData.valueFormat, this.dateTimeData.customFormat);
130
132
  this.valueChange.next();
131
133
  }
132
134
  /**
@@ -144,7 +146,7 @@ export class DateTimeInputDirective extends DateTimeBase {
144
146
  this.blur.emit(event);
145
147
  }
146
148
  }
147
- 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 });
149
+ 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 });
148
150
  DateTimeInputDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeInputDirective, selector: "input[dateTime][dateTimeInput]", providers: [
149
151
  {
150
152
  provide: DATE_TIME_INPUT,
@@ -184,8 +186,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
184
186
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
185
187
  type: Inject,
186
188
  args: [DATE_API]
187
- }] }, { type: undefined, decorators: [{
188
- type: Inject,
189
- args: [FORMAT_PROVIDER]
190
189
  }] }, { type: i1.DateValueProvider }]; }, propDecorators: { handleInput: [], handleFocus: [], handleBlur: [] } });
191
190
  //# 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,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,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAEnF,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,YAAmB;IA6E5E,kEAAkE;IAClE,YAAsB,UAA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AI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAEtF,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;;mHAjMQ,sBAAsB,4CA+EX,QAAQ,aACR,eAAe;uGAhF1B,sBAAsB,yDAT/B;QAEI;YACI,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;SACxD;KACJ;;IA+JA,QAAQ;;;;yDAiBR;;IAMA,QAAQ;;qCACoB,UAAU;;yDAGtC;;IAMA,QAAQ;;qCACmB,UAAU;;wDAGrC;2FAjMQ,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;;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,YAAmB;IA6E5E,kEAAkE;IAClE,YAAsB,UAAwC,EACtB,OAAuB,EACzC,aAAuC;QAEzD,KAAK,EAAE,CAAC;QAJU,eAAU,GAAV,UAAU,CAA8B;QACtB,YAAO,GAAP,OAAO,CAAgB;QACzC,kBAAa,GAAb,aAAa,CAA0B;QAb7D;;WAEG;QACI,UAAK,GAA6B,IAAI,YAAY,EAAc,CAAC;QAExE;;WAEG;QACI,SAAI,GAA6B,IAAI,YAAY,EAAc,CAAC;QASnE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1E,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,gBAAgB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C;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}"]}