@anglr/datetime 5.0.0-beta.20221017112052 → 5.0.0-beta.20221018103539

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 (138) hide show
  1. package/changelog.md +46 -8
  2. package/es2015/src/index.js +0 -3
  3. package/es2015/src/index.js.map +1 -1
  4. package/es2015/src/interfaces/dateTimeInput/dateTimeInput.interface.js.map +1 -1
  5. package/es2015/src/legacy/selector/components/inputDateTime/inputDateTime.component.js +4 -6
  6. package/es2015/src/legacy/selector/components/inputDateTime/inputDateTime.component.js.map +1 -1
  7. package/es2015/src/legacy/selector/components/selector/selector.component.js +2 -2
  8. package/es2015/src/legacy/selector/components/selector/selector.component.js.map +1 -1
  9. package/es2015/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +2 -2
  10. package/es2015/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +1 -1
  11. package/es2015/src/misc/enums.js +1 -1
  12. package/es2015/src/misc/enums.js.map +1 -1
  13. package/es2015/src/misc/types.js.map +1 -1
  14. package/es2015/src/misc/utils.js +10 -0
  15. package/es2015/src/misc/utils.js.map +1 -1
  16. package/es2015/src/misc/validators.js +79 -2
  17. package/es2015/src/misc/validators.js.map +1 -1
  18. package/es2015/src/modules/dateTime/directives/dateTimeBase.js +77 -0
  19. package/es2015/src/modules/dateTime/directives/dateTimeBase.js.map +1 -0
  20. package/es2015/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js +18 -59
  21. package/es2015/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js.map +1 -1
  22. package/es2015/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js +72 -0
  23. package/es2015/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js.map +1 -0
  24. package/es2015/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js +71 -0
  25. package/es2015/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js.map +1 -0
  26. package/es2015/src/modules/dateTime/directives/dateTimeRestrictedBase.js +152 -0
  27. package/es2015/src/modules/dateTime/directives/dateTimeRestrictedBase.js.map +1 -0
  28. package/es2015/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js +17 -6
  29. package/es2015/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js.map +1 -1
  30. package/es2015/src/modules/dateTime/directives/index.js +4 -0
  31. package/es2015/src/modules/dateTime/directives/index.js.map +1 -1
  32. package/es2015/src/modules/dateTime/modules/dateTime.module.js +9 -1
  33. package/es2015/src/modules/dateTime/modules/dateTime.module.js.map +1 -1
  34. package/es2015/src/services/{datePositionParser.interface.js → datePositionParser/datePositionParser.interface.js} +0 -0
  35. package/es2015/src/services/datePositionParser/datePositionParser.interface.js.map +1 -0
  36. package/es2015/src/services/{datePositionParser.service.js → datePositionParser/datePositionParser.service.js} +0 -0
  37. package/es2015/src/services/datePositionParser/datePositionParser.service.js.map +1 -0
  38. package/es2015/src/services/{dateTimeRelativeParser.service.js → dateTimeRelativeParser/dateTimeRelativeParser.service.js} +8 -8
  39. package/es2015/src/services/dateTimeRelativeParser/dateTimeRelativeParser.service.js.map +1 -0
  40. package/es2015/src/services/{dateValueProvider.service.js → dateValueProvider/dateValueProvider.service.js} +1 -1
  41. package/es2015/src/services/dateValueProvider/dateValueProvider.service.js.map +1 -0
  42. package/es2015/src/services/index.js +4 -1
  43. package/es2015/src/services/index.js.map +1 -1
  44. package/es2020/src/index.js +0 -3
  45. package/es2020/src/index.js.map +1 -1
  46. package/es2020/src/interfaces/dateTimeInput/dateTimeInput.interface.js.map +1 -1
  47. package/es2020/src/legacy/selector/components/inputDateTime/inputDateTime.component.js +4 -6
  48. package/es2020/src/legacy/selector/components/inputDateTime/inputDateTime.component.js.map +1 -1
  49. package/es2020/src/legacy/selector/components/selector/selector.component.js +2 -2
  50. package/es2020/src/legacy/selector/components/selector/selector.component.js.map +1 -1
  51. package/es2020/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js +2 -2
  52. package/es2020/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.js.map +1 -1
  53. package/es2020/src/misc/enums.js +1 -1
  54. package/es2020/src/misc/enums.js.map +1 -1
  55. package/es2020/src/misc/types.js.map +1 -1
  56. package/es2020/src/misc/utils.js +10 -0
  57. package/es2020/src/misc/utils.js.map +1 -1
  58. package/es2020/src/misc/validators.js +79 -2
  59. package/es2020/src/misc/validators.js.map +1 -1
  60. package/es2020/src/modules/dateTime/directives/dateTimeBase.js +77 -0
  61. package/es2020/src/modules/dateTime/directives/dateTimeBase.js.map +1 -0
  62. package/es2020/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js +18 -59
  63. package/es2020/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.js.map +1 -1
  64. package/es2020/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js +72 -0
  65. package/es2020/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.js.map +1 -0
  66. package/es2020/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js +71 -0
  67. package/es2020/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.js.map +1 -0
  68. package/es2020/src/modules/dateTime/directives/dateTimeRestrictedBase.js +149 -0
  69. package/es2020/src/modules/dateTime/directives/dateTimeRestrictedBase.js.map +1 -0
  70. package/es2020/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js +17 -6
  71. package/es2020/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.js.map +1 -1
  72. package/es2020/src/modules/dateTime/directives/index.js +4 -0
  73. package/es2020/src/modules/dateTime/directives/index.js.map +1 -1
  74. package/es2020/src/modules/dateTime/modules/dateTime.module.js +9 -1
  75. package/es2020/src/modules/dateTime/modules/dateTime.module.js.map +1 -1
  76. package/es2020/src/services/{datePositionParser.interface.js → datePositionParser/datePositionParser.interface.js} +0 -0
  77. package/es2020/src/services/datePositionParser/datePositionParser.interface.js.map +1 -0
  78. package/es2020/src/services/{datePositionParser.service.js → datePositionParser/datePositionParser.service.js} +0 -0
  79. package/es2020/src/services/datePositionParser/datePositionParser.service.js.map +1 -0
  80. package/es2020/src/services/{dateTimeRelativeParser.service.js → dateTimeRelativeParser/dateTimeRelativeParser.service.js} +8 -8
  81. package/es2020/src/services/dateTimeRelativeParser/dateTimeRelativeParser.service.js.map +1 -0
  82. package/es2020/src/services/{dateValueProvider.service.js → dateValueProvider/dateValueProvider.service.js} +1 -1
  83. package/es2020/src/services/dateValueProvider/dateValueProvider.service.js.map +1 -0
  84. package/es2020/src/services/index.js +4 -1
  85. package/es2020/src/services/index.js.map +1 -1
  86. package/package.json +1 -1
  87. package/src/index.d.ts +0 -3
  88. package/src/index.d.ts.map +1 -1
  89. package/src/interfaces/dateTimeInput/dateTimeInput.interface.d.ts +14 -9
  90. package/src/interfaces/dateTimeInput/dateTimeInput.interface.d.ts.map +1 -1
  91. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.d.ts +1 -3
  92. package/src/legacy/selector/components/inputDateTime/inputDateTime.component.d.ts.map +1 -1
  93. package/src/legacy/selector/components/selector/selector.component.d.ts +1 -2
  94. package/src/legacy/selector/components/selector/selector.component.d.ts.map +1 -1
  95. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts +1 -2
  96. package/src/legacy/selector/components/simpleInputDateTime/simpleInputDateTime.component.d.ts.map +1 -1
  97. package/src/misc/enums.d.ts +1 -1
  98. package/src/misc/types.d.ts +1 -1
  99. package/src/misc/types.d.ts.map +1 -1
  100. package/src/misc/utils.d.ts +5 -0
  101. package/src/misc/utils.d.ts.map +1 -1
  102. package/src/misc/validators.d.ts +17 -0
  103. package/src/misc/validators.d.ts.map +1 -1
  104. package/src/modules/dateTime/directives/dateTimeBase.d.ts +56 -0
  105. package/src/modules/dateTime/directives/dateTimeBase.d.ts.map +1 -0
  106. package/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.d.ts +3 -39
  107. package/src/modules/dateTime/directives/dateTimeInput/dateTimeInput.directive.d.ts.map +1 -1
  108. package/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.d.ts +33 -0
  109. package/src/modules/dateTime/directives/dateTimeMaxValidator/dateTimeMaxValidator.directive.d.ts.map +1 -0
  110. package/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.d.ts +33 -0
  111. package/src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.d.ts.map +1 -0
  112. package/src/modules/dateTime/directives/dateTimeRestrictedBase.d.ts +74 -0
  113. package/src/modules/dateTime/directives/dateTimeRestrictedBase.d.ts.map +1 -0
  114. package/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.d.ts +9 -2
  115. package/src/modules/dateTime/directives/dateTimeValidator/dateTimeValidator.directive.d.ts.map +1 -1
  116. package/src/modules/dateTime/directives/index.d.ts +4 -0
  117. package/src/modules/dateTime/directives/index.d.ts.map +1 -1
  118. package/src/modules/dateTime/modules/dateTime.module.d.ts +4 -2
  119. package/src/modules/dateTime/modules/dateTime.module.d.ts.map +1 -1
  120. package/src/services/{datePositionParser.interface.d.ts → datePositionParser/datePositionParser.interface.d.ts} +0 -0
  121. package/src/services/{datePositionParser.interface.d.ts.map → datePositionParser/datePositionParser.interface.d.ts.map} +0 -0
  122. package/src/services/{datePositionParser.service.d.ts → datePositionParser/datePositionParser.service.d.ts} +0 -0
  123. package/src/services/{datePositionParser.service.d.ts.map → datePositionParser/datePositionParser.service.d.ts.map} +0 -0
  124. package/src/services/{dateTimeRelativeParser.service.d.ts → dateTimeRelativeParser/dateTimeRelativeParser.service.d.ts} +3 -3
  125. package/src/services/{dateTimeRelativeParser.service.d.ts.map → dateTimeRelativeParser/dateTimeRelativeParser.service.d.ts.map} +1 -1
  126. package/src/services/{dateValueProvider.service.d.ts → dateValueProvider/dateValueProvider.service.d.ts} +2 -2
  127. package/src/services/{dateValueProvider.service.d.ts.map → dateValueProvider/dateValueProvider.service.d.ts.map} +1 -1
  128. package/src/services/index.d.ts +4 -1
  129. package/src/services/index.d.ts.map +1 -1
  130. package/version.bak +1 -1
  131. package/es2015/src/services/datePositionParser.interface.js.map +0 -1
  132. package/es2015/src/services/datePositionParser.service.js.map +0 -1
  133. package/es2015/src/services/dateTimeRelativeParser.service.js.map +0 -1
  134. package/es2015/src/services/dateValueProvider.service.js.map +0 -1
  135. package/es2020/src/services/datePositionParser.interface.js.map +0 -1
  136. package/es2020/src/services/datePositionParser.service.js.map +0 -1
  137. package/es2020/src/services/dateTimeRelativeParser.service.js.map +0 -1
  138. package/es2020/src/services/dateValueProvider.service.js.map +0 -1
@@ -0,0 +1,77 @@
1
+ import { Directive, EventEmitter, Input } from '@angular/core';
2
+ import { isString } from '@jscrpt/common';
3
+ import { DateTimeValueFormat } from '../../../misc/enums';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Base class for date time directives, contains basic shared data
7
+ */
8
+ export class DateTimeBase {
9
+ //######################### constructors #########################
10
+ constructor(dateApi, formatProvider) {
11
+ this.dateApi = dateApi;
12
+ this.formatProvider = formatProvider;
13
+ //######################### protected properties #########################
14
+ /**
15
+ * Date time value format which is being worked with in this date time
16
+ */
17
+ this.ɵValueFormat = DateTimeValueFormat.DateInstance;
18
+ /**
19
+ * Format of string representation of date
20
+ */
21
+ this.ɵFormat = 'date';
22
+ /**
23
+ * @inheritdoc
24
+ */
25
+ this.valueChange = new EventEmitter();
26
+ /**
27
+ * Custom format string representation of date
28
+ */
29
+ this.customFormat = this.dateApi.getFormat(this.formatProvider[this.ɵFormat]);
30
+ }
31
+ //######################### public properties - implementation of DateTimeInputValue #########################
32
+ /**
33
+ * @inheritdoc
34
+ */
35
+ get value() {
36
+ return this.ɵValue;
37
+ }
38
+ set value(value) {
39
+ this.ɵValue = value;
40
+ }
41
+ //######################### public properties - inputs #########################
42
+ /**
43
+ * Gets or sets date time value format which is being worked with in this date time
44
+ */
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;
54
+ }
55
+ /**
56
+ * Gets or sets format of string representation of date
57
+ */
58
+ get format() {
59
+ return this.ɵFormat;
60
+ }
61
+ set format(value) {
62
+ this.ɵFormat = value;
63
+ this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);
64
+ }
65
+ }
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 });
68
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeBase, decorators: [{
69
+ 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
+ }] } });
77
+ //# sourceMappingURL=dateTimeBase.js.map
@@ -0,0 +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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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,33 +1,19 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
- import { Directive, ElementRef, EventEmitter, forwardRef, Inject, Input } from '@angular/core';
3
- import { BindThis, isString } from '@jscrpt/common';
4
- import { DateTimeValueFormat } from '../../../../misc/enums';
2
+ import { Directive, ElementRef, EventEmitter, forwardRef, Inject } from '@angular/core';
3
+ import { BindThis } from '@jscrpt/common';
5
4
  import { DATE_API, DATE_TIME_INPUT, FORMAT_PROVIDER } from '../../../../misc/tokens';
6
5
  import { formatDateTime, parseDateTime } from '../../../../misc/utils';
6
+ import { DateTimeBase } from '../dateTimeBase';
7
7
  import * as i0 from "@angular/core";
8
8
  //TODO: range is unimplemented
9
9
  /**
10
10
  * Directive that is used for setting up date time input
11
11
  */
12
- export class DateTimeInputDirective {
12
+ export class DateTimeInputDirective extends DateTimeBase {
13
13
  //######################### constructors #########################
14
14
  constructor(element, dateApi, formatProvider) {
15
+ super(dateApi, formatProvider);
15
16
  this.element = element;
16
- this.dateApi = dateApi;
17
- this.formatProvider = formatProvider;
18
- //######################### private fields #########################
19
- /**
20
- * Date time value format which is being worked with in this date time
21
- */
22
- this._valueFormat = DateTimeValueFormat.DateInstance;
23
- /**
24
- * Format of string representation of date
25
- */
26
- this._format = 'date';
27
- /**
28
- * @inheritdoc
29
- */
30
- this.valueChange = new EventEmitter();
31
17
  /**
32
18
  * @inheritdoc
33
19
  */
@@ -36,10 +22,6 @@ export class DateTimeInputDirective {
36
22
  * @inheritdoc
37
23
  */
38
24
  this.blur = new EventEmitter();
39
- /**
40
- * Custom format string representation of date
41
- */
42
- this.customFormat = this.dateApi.getFormat(this.formatProvider[this._format]);
43
25
  this.element.nativeElement.addEventListener('input', this.handleInput);
44
26
  this.element.nativeElement.addEventListener('focus', this.handleFocus);
45
27
  this.element.nativeElement.addEventListener('blur', this.handleBlur);
@@ -58,10 +40,10 @@ export class DateTimeInputDirective {
58
40
  * @inheritdoc
59
41
  */
60
42
  get value() {
61
- return this._value;
43
+ return this.ɵValue;
62
44
  }
63
45
  set value(value) {
64
- this._value = value;
46
+ this.ɵValue = value;
65
47
  //accepts all available formats
66
48
  this.internalValue = parseDateTime(value, this.dateApi, null, this.customFormat);
67
49
  //not range value
@@ -81,30 +63,6 @@ export class DateTimeInputDirective {
81
63
  set disabled(value) {
82
64
  this.element.nativeElement.disabled = value;
83
65
  }
84
- //######################### public properties - inputs #########################
85
- /**
86
- * Gets or sets date time value format which is being worked with in this date time
87
- */
88
- get valueFormat() {
89
- return this._valueFormat;
90
- }
91
- set valueFormat(value) {
92
- if (isString(value)) {
93
- this._valueFormat = DateTimeValueFormat[value];
94
- return;
95
- }
96
- this._valueFormat = value;
97
- }
98
- /**
99
- * Gets or sets format of string representation of date
100
- */
101
- get format() {
102
- return this._format;
103
- }
104
- set format(value) {
105
- this._format = value;
106
- this.customFormat = this.dateApi.getFormat(this.formatProvider[value]);
107
- }
108
66
  //######################### public methods - implementation of OnDestroy #########################
109
67
  /**
110
68
  * Called when component is destroyed
@@ -119,8 +77,14 @@ export class DateTimeInputDirective {
119
77
  * Handles input event on input
120
78
  */
121
79
  handleInput() {
80
+ if (!this.rawValue) {
81
+ this.internalValue = null;
82
+ this.ɵValue = null;
83
+ this.valueChange.next();
84
+ return;
85
+ }
122
86
  this.internalValue = parseDateTime(this.rawValue, this.dateApi, this.valueFormat, this.customFormat);
123
- this._value = formatDateTime(this.internalValue, this.valueFormat, this.customFormat);
87
+ this.ɵValue = formatDateTime(this.internalValue, this.valueFormat, this.customFormat);
124
88
  this.valueChange.next();
125
89
  }
126
90
  /**
@@ -139,12 +103,12 @@ export class DateTimeInputDirective {
139
103
  }
140
104
  }
141
105
  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 }], target: i0.ɵɵFactoryTarget.Directive });
142
- DateTimeInputDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeInputDirective, selector: "input[dateTime][dateTimeInput]", inputs: { valueFormat: "valueFormat", format: "format", customFormat: "customFormat" }, providers: [
106
+ DateTimeInputDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeInputDirective, selector: "input[dateTime][dateTimeInput]", providers: [
143
107
  {
144
108
  provide: DATE_TIME_INPUT,
145
109
  useExisting: forwardRef(() => DateTimeInputDirective),
146
110
  },
147
- ], ngImport: i0 });
111
+ ], exportAs: ["dateTime"], usesInheritance: true, ngImport: i0 });
148
112
  __decorate([
149
113
  BindThis,
150
114
  __metadata("design:type", Function),
@@ -173,6 +137,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
173
137
  useExisting: forwardRef(() => DateTimeInputDirective),
174
138
  },
175
139
  ],
140
+ exportAs: 'dateTime',
176
141
  }]
177
142
  }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
178
143
  type: Inject,
@@ -180,11 +145,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
180
145
  }] }, { type: undefined, decorators: [{
181
146
  type: Inject,
182
147
  args: [FORMAT_PROVIDER]
183
- }] }]; }, propDecorators: { valueFormat: [{
184
- type: Input
185
- }], format: [{
186
- type: Input
187
- }], customFormat: [{
188
- type: Input
189
- }], handleInput: [], handleFocus: [], handleBlur: [] } });
148
+ }] }]; }, propDecorators: { handleInput: [], handleFocus: [], handleBlur: [] } });
190
149
  //# 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,EAAE,KAAK,EAAY,MAAM,eAAe,CAAC;AAC1H,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAEnF,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAC;;AAGrE,8BAA8B;AAE9B;;GAEG;AAaH,MAAM,OAAO,sBAAsB;IAsI/B,kEAAkE;IAClE,YAAsB,OAAqC,EACnB,OAAuB,EAChB,cAA8B;QAFvD,YAAO,GAAP,OAAO,CAA8B;QACnB,YAAO,GAAP,OAAO,CAAgB;QAChB,mBAAc,GAAd,cAAc,CAAgB;QAvI7E,oEAAoE;QAEpE;;WAEG;QACK,iBAAY,GAAwB,mBAAmB,CAAC,YAAY,CAAC;QAO7E;;WAEG;QACK,YAAO,GAAyB,MAAM,CAAC;QA4D/C;;WAEG;QACI,gBAAW,GAAuB,IAAI,YAAY,EAAQ,CAAC;QAElE;;WAEG;QACI,UAAK,GAA6B,IAAI,YAAY,EAAc,CAAC;QAExE;;WAEG;QACI,SAAI,GAA6B,IAAI,YAAY,EAAc,CAAC;QAsCvE;;WAEG;QAEI,iBAAY,GAAW,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI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c,CAAC,IAAI,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;;mHA5LQ,sBAAsB,4CAwIX,QAAQ,aACR,eAAe;uGAzI1B,sBAAsB,iJAR/B;QAEI;YACI,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;SACxD;KACJ;;IAmKA,QAAQ;;;;yDAOR;;IAMA,QAAQ;;qCACoB,UAAU;;yDAGtC;;IAMA,QAAQ;;qCACmB,UAAU;;wDAGrC;2FA5LQ,sBAAsB;kBAZlC,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;iBACJ;;0BAyIgB,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,eAAe;4CAvCxB,WAAW;sBADrB,KAAK;gBAqBK,MAAM;sBADhB,KAAK;gBAeC,YAAY;sBADlB,KAAK;gBA+BI,WAAW,MAaX,WAAW,MAUX,UAAU","sourcesContent":["import {Directive, ElementRef, EventEmitter, ExistingProvider, forwardRef, Inject, Input, OnDestroy} from '@angular/core';\nimport {BindThis, isString} from '@jscrpt/common';\n\nimport {DateTimeInput, FormatProvider} from '../../../../interfaces';\nimport {DateTimeValueFormat} from '../../../../misc/enums';\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} from '../../../../services';\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})\nexport class DateTimeInputDirective<TDate = unknown> implements DateTimeInput, OnDestroy\n{\n //######################### private fields #########################\n\n /**\n * Date time value format which is being worked with in this date time\n */\n private _valueFormat: DateTimeValueFormat = DateTimeValueFormat.DateInstance;\n\n /**\n * Value of date time\n */\n private _value: DateTimeInputOutputValue<TDate>|undefined|null;\n\n /**\n * Format of string representation of date\n */\n private _format: keyof FormatProvider = 'date';\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.element.nativeElement.value;\n }\n public set rawValue(value: string|undefined|null)\n {\n this.element.nativeElement.value = value ?? '';\n }\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 //accepts all available formats\n this.internalValue = parseDateTime(value, this.dateApi, null, 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.element.nativeElement.disabled;\n }\n public set disabled(value: boolean)\n {\n this.element.nativeElement.disabled = value;\n }\n\n /**\n * @inheritdoc\n */\n public valueChange: EventEmitter<void> = new EventEmitter<void>();\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 //######################### 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 element: ElementRef<HTMLInputElement>,\n @Inject(DATE_API) protected dateApi: DateApi<TDate>,\n @Inject(FORMAT_PROVIDER) protected formatProvider: FormatProvider,)\n {\n this.element.nativeElement.addEventListener('input', this.handleInput);\n this.element.nativeElement.addEventListener('focus', this.handleFocus);\n this.element.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.element.nativeElement.removeEventListener('input', this.handleInput);\n this.element.nativeElement.removeEventListener('focus', this.handleFocus);\n this.element.nativeElement.removeEventListener('blur', this.handleBlur);\n }\n\n //######################### protected methods #########################\n\n /**\n * Handles input event on input\n */\n @BindThis\n protected handleInput(): void\n {\n this.internalValue = parseDateTime(this.rawValue, this.dateApi, this.valueFormat, this.customFormat);\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\n //######################### ng language server #########################\n \n /**\n * Custom input type for `valueFormat` input\n */\n public static ngAcceptInputType_valueFormat: keyof typeof DateTimeValueFormat|DateTimeValueFormat;\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,EAAC,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAEnF,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;;AAE7C,8BAA8B;AAE9B;;GAEG;AAcH,MAAM,OAAO,sBAAwC,SAAQ,YAAmB;IAsE5E,kEAAkE;IAClE,YAAsB,OAAqC,EAC7B,OAAuB,EAChB,cAA8B;QAE/D,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAJb,YAAO,GAAP,OAAO,CAA8B;QAX3D;;WAEG;QACI,UAAK,GAA6B,IAAI,YAAY,EAAc,CAAC;QAExE;;WAEG;QACI,SAAI,GAA6B,IAAI,YAAY,EAAc,CAAC;QASnE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACvE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,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BR;;IAMA,QAAQ;;qCACoB,UAAU;;yDAGtC;;IAMA,QAAQ;;qCACmB,UAAU;;wDAGrC;2FAxIQ,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;;0BAyEgB,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,eAAe;4CA2BzB,WAAW,MAuBX,WAAW,MAUX,UAAU","sourcesContent":["import {Directive, ElementRef, EventEmitter, ExistingProvider, forwardRef, Inject, OnDestroy} from '@angular/core';\nimport {BindThis} 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} 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.element.nativeElement.value;\n }\n public set rawValue(value: string|undefined|null)\n {\n this.element.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 this.ɵValue = value;\n\n //accepts all available formats\n this.internalValue = parseDateTime(value, this.dateApi, null, 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.element.nativeElement.disabled;\n }\n public set disabled(value: boolean)\n {\n this.element.nativeElement.disabled = value;\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 element: ElementRef<HTMLInputElement>,\n @Inject(DATE_API) dateApi: DateApi<TDate>,\n @Inject(FORMAT_PROVIDER) formatProvider: FormatProvider,)\n {\n super(dateApi, formatProvider);\n\n this.element.nativeElement.addEventListener('input', this.handleInput);\n this.element.nativeElement.addEventListener('focus', this.handleFocus);\n this.element.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.element.nativeElement.removeEventListener('input', this.handleInput);\n this.element.nativeElement.removeEventListener('focus', this.handleFocus);\n this.element.nativeElement.removeEventListener('blur', this.handleBlur);\n }\n\n //######################### protected methods #########################\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.internalValue = parseDateTime(this.rawValue, this.dateApi, this.valueFormat, this.customFormat);\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}"]}
@@ -0,0 +1,72 @@
1
+ import { Directive, forwardRef, Inject } from '@angular/core';
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';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Applies validator for date time max value
9
+ */
10
+ export class DateTimeMaxValidatorDirective extends DateTimeRestrictedBase {
11
+ //######################### constructor #########################
12
+ constructor(dateApi, formatProvider) {
13
+ super(dateApi, formatProvider);
14
+ //######################### private fields #########################
15
+ /**
16
+ * Function used for validations
17
+ */
18
+ this._validator = () => null;
19
+ this._validator = datetimeValidator(dateApi, null, null);
20
+ }
21
+ //######################### public methods - implementation of OnInit #########################
22
+ /**
23
+ * Initialize component
24
+ */
25
+ ngOnInit() {
26
+ this._validator = datetimeMaxValidator(this.dateApi, this.maxDateTime, this.valueFormat, this.customFormat);
27
+ }
28
+ //######################### public methods - implementation of Validator #########################
29
+ /**
30
+ * Validates input and returns validation result
31
+ * @param control - Control that is being validated
32
+ * @returns validation results
33
+ */
34
+ validate(control) {
35
+ return this._validator(control);
36
+ }
37
+ //######################### protected methods - overrides #########################
38
+ /**
39
+ * @inheritdoc
40
+ */
41
+ onMaxDateTimeChange() {
42
+ this._validator = datetimeMaxValidator(this.dateApi, this.maxDateTime, this.valueFormat, this.customFormat);
43
+ }
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 });
46
+ DateTimeMaxValidatorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeMaxValidatorDirective, selector: "[dateTime][maxDateTime][validate]", providers: [
47
+ {
48
+ provide: NG_VALIDATORS,
49
+ useExisting: forwardRef(() => DateTimeMaxValidatorDirective),
50
+ multi: true
51
+ },
52
+ ], usesInheritance: true, ngImport: i0 });
53
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeMaxValidatorDirective, decorators: [{
54
+ type: Directive,
55
+ args: [{
56
+ selector: '[dateTime][maxDateTime][validate]',
57
+ providers: [
58
+ {
59
+ provide: NG_VALIDATORS,
60
+ useExisting: forwardRef(() => DateTimeMaxValidatorDirective),
61
+ multi: true
62
+ },
63
+ ],
64
+ }]
65
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
66
+ type: Inject,
67
+ args: [DATE_API]
68
+ }] }, { type: undefined, decorators: [{
69
+ type: Inject,
70
+ args: [FORMAT_PROVIDER]
71
+ }] }]; } });
72
+ //# sourceMappingURL=dateTimeMaxValidator.directive.js.map
@@ -0,0 +1 @@
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;AAGxG,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAC,oBAAoB,EAAE,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAAC,sBAAsB,EAAC,MAAM,2BAA2B,CAAC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C5D,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}"]}
@@ -0,0 +1,71 @@
1
+ import { Directive, forwardRef, Inject } from '@angular/core';
2
+ import { NG_VALIDATORS } from '@angular/forms';
3
+ import { DATE_API, FORMAT_PROVIDER } from '../../../../misc/tokens';
4
+ import { datetimeMinValidator } from '../../../../misc/validators';
5
+ import { DateTimeRestrictedBase } from '../dateTimeRestrictedBase';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Applies validator for date time min value
9
+ */
10
+ export class DateTimeMinValidatorDirective extends DateTimeRestrictedBase {
11
+ //######################### constructor #########################
12
+ constructor(dateApi, formatProvider) {
13
+ super(dateApi, formatProvider);
14
+ //######################### private fields #########################
15
+ /**
16
+ * Function used for validations
17
+ */
18
+ this._validator = () => null;
19
+ }
20
+ //######################### public methods - implementation of OnInit #########################
21
+ /**
22
+ * Initialize component
23
+ */
24
+ ngOnInit() {
25
+ this._validator = datetimeMinValidator(this.dateApi, this.minDateTime, this.valueFormat, this.customFormat);
26
+ }
27
+ //######################### public methods - implementation of Validator #########################
28
+ /**
29
+ * Validates input and returns validation result
30
+ * @param control - Control that is being validated
31
+ * @returns validation results
32
+ */
33
+ validate(control) {
34
+ return this._validator(control);
35
+ }
36
+ //######################### protected methods - overrides #########################
37
+ /**
38
+ * @inheritdoc
39
+ */
40
+ onMinDateTimeChange() {
41
+ this._validator = datetimeMinValidator(this.dateApi, this.minDateTime, this.valueFormat, this.customFormat);
42
+ }
43
+ }
44
+ DateTimeMinValidatorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeMinValidatorDirective, deps: [{ token: DATE_API }, { token: FORMAT_PROVIDER }], target: i0.ɵɵFactoryTarget.Directive });
45
+ DateTimeMinValidatorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeMinValidatorDirective, selector: "[dateTime][minDateTime][validate]", providers: [
46
+ {
47
+ provide: NG_VALIDATORS,
48
+ useExisting: forwardRef(() => DateTimeMinValidatorDirective),
49
+ multi: true
50
+ },
51
+ ], usesInheritance: true, ngImport: i0 });
52
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeMinValidatorDirective, decorators: [{
53
+ type: Directive,
54
+ args: [{
55
+ selector: '[dateTime][minDateTime][validate]',
56
+ providers: [
57
+ {
58
+ provide: NG_VALIDATORS,
59
+ useExisting: forwardRef(() => DateTimeMinValidatorDirective),
60
+ multi: true
61
+ },
62
+ ],
63
+ }]
64
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
65
+ type: Inject,
66
+ args: [DATE_API]
67
+ }] }, { type: undefined, decorators: [{
68
+ type: Inject,
69
+ args: [FORMAT_PROVIDER]
70
+ }] }]; } });
71
+ //# sourceMappingURL=dateTimeMinValidator.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateTimeMinValidator.directive.js","sourceRoot":"","sources":["../../../../../../src/modules/dateTime/directives/dateTimeMinValidator/dateTimeMinValidator.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAoB,UAAU,EAAE,MAAM,EAAS,MAAM,eAAe,CAAC;AACtF,OAAO,EAAkB,aAAa,EAA2C,MAAM,gBAAgB,CAAC;AAGxG,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AAEjE,OAAO,EAAC,sBAAsB,EAAC,MAAM,2BAA2B,CAAC;;AAEjE;;GAEG;AAcH,MAAM,OAAO,6BAA+C,SAAQ,sBAA6B;IAS7F,iEAAiE;IACjE,YAA8B,OAAuB,EAChB,cAA8B;QAE/D,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAXnC,oEAAoE;QAEpE;;WAEG;QACK,eAAU,GAAgB,GAAG,EAAE,CAAC,IAAI,CAAC;IAO7C,CAAC;IAED,+FAA+F;IAE/F;;OAEG;IACI,QAAQ;QAEX,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAChH,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,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAChH,CAAC;;0HA9CQ,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 {datetimeMinValidator} from '../../../../misc/validators';\nimport {DateApi} from '../../../../services';\nimport {DateTimeRestrictedBase} from '../dateTimeRestrictedBase';\n\n/**\n * Applies validator for date time min value\n */\n@Directive(\n{\n selector: '[dateTime][minDateTime][validate]',\n providers:\n [\n <ExistingProvider>\n {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => DateTimeMinValidatorDirective),\n multi: true\n },\n ],\n})\nexport class DateTimeMinValidatorDirective<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 }\n\n //######################### public methods - implementation of OnInit #########################\n \n /**\n * Initialize component\n */\n public ngOnInit(): void\n {\n this._validator = datetimeMinValidator(this.dateApi, this.minDateTime, 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 onMinDateTimeChange(): void\n {\n this._validator = datetimeMinValidator(this.dateApi, this.minDateTime, this.valueFormat, this.customFormat);\n }\n}"]}
@@ -0,0 +1,149 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Directive, Input } from '@angular/core';
3
+ import { BindThis, isBlank } from '@jscrpt/common';
4
+ import { getSingleDateTimeValue } from '../../../misc/utils';
5
+ import { DateTimeBase } from './dateTimeBase';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * Base class for date time directives with value restrictions
9
+ */
10
+ export class DateTimeRestrictedBase extends DateTimeBase {
11
+ //######################### public properties - inputs #########################
12
+ /**
13
+ * Gets or sets max allowed date for date time
14
+ */
15
+ get maxDateTime() {
16
+ return this.ɵMaxDateTime;
17
+ }
18
+ set maxDateTime(value) {
19
+ this._maxDateInstanceChange?.unsubscribe();
20
+ this._maxDateInstanceChange = null;
21
+ if (isBlank(value)) {
22
+ this.maxDateSet(value);
23
+ return;
24
+ }
25
+ let val = value;
26
+ if (value instanceof (DateTimeBase)) {
27
+ this._maxDateInstanceChange = value.valueChange.subscribe(() => {
28
+ const val = getSingleDateTimeValue(value.value);
29
+ if (isBlank(val)) {
30
+ this.maxDateSet(null);
31
+ return;
32
+ }
33
+ this.setMinMaxValue(val, this.maxDateSet);
34
+ });
35
+ const v = getSingleDateTimeValue(value.value);
36
+ if (isBlank(v)) {
37
+ this.maxDateSet(null);
38
+ return;
39
+ }
40
+ val = v;
41
+ }
42
+ this.setMinMaxValue(val, this.maxDateSet);
43
+ }
44
+ /**
45
+ * Gets or sets min allowed date for date time
46
+ */
47
+ get minDateTime() {
48
+ return this.ɵMinDateTime;
49
+ }
50
+ set minDateTime(value) {
51
+ this._minDateInstanceChange?.unsubscribe();
52
+ this._minDateInstanceChange = null;
53
+ if (isBlank(value)) {
54
+ this.minDateSet(value);
55
+ return;
56
+ }
57
+ let val = value;
58
+ if (value instanceof (DateTimeBase)) {
59
+ this._minDateInstanceChange = value.valueChange.subscribe(() => {
60
+ const val = getSingleDateTimeValue(value.value);
61
+ if (isBlank(val)) {
62
+ this.minDateSet(null);
63
+ return;
64
+ }
65
+ this.setMinMaxValue(val, this.minDateSet);
66
+ });
67
+ const v = getSingleDateTimeValue(value.value);
68
+ if (isBlank(v)) {
69
+ this.minDateSet(null);
70
+ return;
71
+ }
72
+ val = v;
73
+ }
74
+ this.setMinMaxValue(val, this.minDateSet);
75
+ }
76
+ //######################### public methods - implementation of OnDestroy #########################
77
+ /**
78
+ * Called when component is destroyed
79
+ */
80
+ ngOnDestroy() {
81
+ this._maxDateInstanceChange?.unsubscribe();
82
+ this._maxDateInstanceChange = null;
83
+ this._minDateInstanceChange?.unsubscribe();
84
+ this._minDateInstanceChange = null;
85
+ }
86
+ //######################### protected methods #########################
87
+ /**
88
+ * Called whenever max date time restriction changes
89
+ */
90
+ onMaxDateTimeChange() {
91
+ }
92
+ /**
93
+ * Called whenever min date time restriction changes
94
+ */
95
+ onMinDateTimeChange() {
96
+ }
97
+ /**
98
+ * Sets min date time and notifies about changes
99
+ * @param value - Value to be set
100
+ */
101
+ minDateSet(value) {
102
+ this.ɵMinDateTime = value;
103
+ this.onMinDateTimeChange();
104
+ }
105
+ /**
106
+ * Sets max date time and notifies about changes
107
+ * @param value - Value to be set
108
+ */
109
+ maxDateSet(value) {
110
+ this.ɵMaxDateTime = value;
111
+ this.onMaxDateTimeChange();
112
+ }
113
+ /**
114
+ * Sets min or max date time value
115
+ * @param value - Value to be set
116
+ * @param setter - Action used for setting value
117
+ */
118
+ setMinMaxValue(value, setter) {
119
+ const val = this.dateApi.getValue(value, this.customFormat);
120
+ if (val.isValid()) {
121
+ setter(val.value);
122
+ }
123
+ else {
124
+ setter(null);
125
+ }
126
+ }
127
+ }
128
+ DateTimeRestrictedBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeRestrictedBase, deps: null, target: i0.ɵɵFactoryTarget.Directive });
129
+ DateTimeRestrictedBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.6", type: DateTimeRestrictedBase, inputs: { maxDateTime: "maxDateTime", minDateTime: "minDateTime" }, usesInheritance: true, ngImport: i0 });
130
+ __decorate([
131
+ BindThis,
132
+ __metadata("design:type", Function),
133
+ __metadata("design:paramtypes", [Object]),
134
+ __metadata("design:returntype", void 0)
135
+ ], DateTimeRestrictedBase.prototype, "minDateSet", null);
136
+ __decorate([
137
+ BindThis,
138
+ __metadata("design:type", Function),
139
+ __metadata("design:paramtypes", [Object]),
140
+ __metadata("design:returntype", void 0)
141
+ ], DateTimeRestrictedBase.prototype, "maxDateSet", null);
142
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: DateTimeRestrictedBase, decorators: [{
143
+ type: Directive
144
+ }], propDecorators: { maxDateTime: [{
145
+ type: Input
146
+ }], minDateTime: [{
147
+ type: Input
148
+ }], minDateSet: [], maxDateSet: [] } });
149
+ //# sourceMappingURL=dateTimeRestrictedBase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateTimeRestrictedBase.js","sourceRoot":"","sources":["../../../../../src/modules/dateTime/directives/dateTimeRestrictedBase.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,KAAK,EAAY,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAU,QAAQ,EAAE,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAI1D,OAAO,EAAC,sBAAsB,EAAC,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;;AAE5C;;GAEG;AAEH,MAAM,OAAO,sBAAwC,SAAQ,YAAmB;IA0B5E,gFAAgF;IAEhF;;OAEG;IACH,IACW,WAAW;QAElB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,IAAW,WAAW,CAAC,KAA2B;QAE9C,IAAI,CAAC,sBAAsB,EAAE,WAAW,EAAE,CAAC;QAC3C,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC;QAEnC,IAAG,OAAO,CAAC,KAAK,CAAC,EACjB;YACI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAEvB,OAAO;SACV;QAED,IAAI,GAAG,GAAoC,KAAK,CAAC;QAEjD,IAAG,KAAK,aAAY,YAAmB,CAAA,EACvC;YACI,IAAI,CAAC,sBAAsB,GAAG,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,EAAE;gBAE3D,MAAM,GAAG,GAAG,sBAAsB,CAAQ,KAAK,CAAC,KAAK,CAAC,CAAC;gBAEvD,IAAG,OAAO,CAAC,GAAG,CAAC,EACf;oBACI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC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;;;wDAKR;2FAxLQ,sBAAsB;kBADlC,SAAS;8BAiCK,WAAW;sBADrB,KAAK;gBAsDK,WAAW;sBADrB,KAAK;gBAqFI,UAAU,MAWV,UAAU","sourcesContent":["import {Directive, Input, OnDestroy} from '@angular/core';\nimport {Action1, BindThis, isBlank} from '@jscrpt/common';\nimport {Subscription} from 'rxjs';\n\nimport {DateTimeInputOutputValue} from '../../../misc/types';\nimport {getSingleDateTimeValue} from '../../../misc/utils';\nimport {DateTimeBase} from './dateTimeBase';\n\n/**\n * Base class for date time directives with value restrictions\n */\n@Directive()\nexport class DateTimeRestrictedBase<TDate = unknown> extends DateTimeBase<TDate> implements OnDestroy\n{\n //######################### private fields #########################\n\n /**\n * Subscription for max date instance value changes\n */\n private _maxDateInstanceChange: Subscription|undefined|null;\n\n /**\n * Subscription for min date instance value changes\n */\n private _minDateInstanceChange: Subscription|undefined|null;\n\n //######################### protected properties #########################\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 //######################### public properties - inputs #########################\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 * 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 /**\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.onMinDateTimeChange();\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.onMaxDateTimeChange();\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 `maxDateTime` input\n */\n public static ngAcceptInputType_maxDateTime: string|number|DateTimeBase|Date;\n\n /**\n * Custom input type for `minDateTime` input\n */\n public static ngAcceptInputType_minDateTime: string|number|DateTimeBase|Date;\n}\n"]}