@skyux/datetime 5.1.4 → 5.5.0-alpha.0

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 (198) hide show
  1. package/README.md +6 -4
  2. package/bundles/skyux-datetime.umd.js +80 -80
  3. package/documentation.json +379 -22
  4. package/esm2015/index.js +28 -0
  5. package/esm2015/index.js.map +1 -0
  6. package/esm2015/lib/modules/date-pipe/date-format-utility.js +48 -0
  7. package/esm2015/lib/modules/date-pipe/date-format-utility.js.map +1 -0
  8. package/esm2015/lib/modules/date-pipe/date-pipe.module.js +21 -0
  9. package/esm2015/lib/modules/date-pipe/date-pipe.module.js.map +1 -0
  10. package/esm2015/lib/modules/date-pipe/date.pipe.js +65 -0
  11. package/esm2015/lib/modules/date-pipe/date.pipe.js.map +1 -0
  12. package/esm2015/lib/modules/date-pipe/fuzzy-date.pipe.js +47 -0
  13. package/esm2015/lib/modules/date-pipe/fuzzy-date.pipe.js.map +1 -0
  14. package/esm2015/lib/modules/date-range-picker/date-range-picker.component.js +464 -0
  15. package/esm2015/lib/modules/date-range-picker/date-range-picker.component.js.map +1 -0
  16. package/esm2015/lib/modules/date-range-picker/date-range-picker.module.js +47 -0
  17. package/esm2015/lib/modules/date-range-picker/date-range-picker.module.js.map +1 -0
  18. package/esm2015/lib/modules/date-range-picker/date-range.service.js +97 -0
  19. package/esm2015/lib/modules/date-range-picker/date-range.service.js.map +1 -0
  20. package/esm2015/lib/modules/date-range-picker/types/date-range-calculation.js +2 -0
  21. package/esm2015/lib/modules/date-range-picker/types/date-range-calculation.js.map +1 -0
  22. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-config.js +2 -0
  23. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-config.js.map +1 -0
  24. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-date-range-function.js +2 -0
  25. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-date-range-function.js.map +1 -0
  26. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-id.js +118 -0
  27. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-id.js.map +1 -0
  28. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-type.js +23 -0
  29. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-type.js.map +1 -0
  30. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-validate-function.js +2 -0
  31. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator-validate-function.js.map +1 -0
  32. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator.js +56 -0
  33. package/esm2015/lib/modules/date-range-picker/types/date-range-calculator.js.map +1 -0
  34. package/esm2015/lib/modules/date-range-picker/types/date-range-default-calculator-config.js +2 -0
  35. package/esm2015/lib/modules/date-range-picker/types/date-range-default-calculator-config.js.map +1 -0
  36. package/esm2015/lib/modules/date-range-picker/types/date-range-default-calculator-configs.js +147 -0
  37. package/esm2015/lib/modules/date-range-picker/types/date-range-default-calculator-configs.js.map +1 -0
  38. package/esm2015/lib/modules/date-range-picker/types/date-range-relative-value.js +252 -0
  39. package/esm2015/lib/modules/date-range-picker/types/date-range-relative-value.js.map +1 -0
  40. package/esm2015/lib/modules/date-range-picker/types/date-range.js +2 -0
  41. package/esm2015/lib/modules/date-range-picker/types/date-range.js.map +1 -0
  42. package/esm2015/lib/modules/datepicker/date-formatter.js +38 -0
  43. package/esm2015/lib/modules/datepicker/date-formatter.js.map +1 -0
  44. package/esm2015/lib/modules/datepicker/datepicker-adapter.service.js +33 -0
  45. package/esm2015/lib/modules/datepicker/datepicker-adapter.service.js.map +1 -0
  46. package/esm2015/lib/modules/datepicker/datepicker-calendar-change.js +2 -0
  47. package/esm2015/lib/modules/datepicker/datepicker-calendar-change.js.map +1 -0
  48. package/esm2015/lib/modules/datepicker/datepicker-calendar-inner.component.js +315 -0
  49. package/esm2015/lib/modules/datepicker/datepicker-calendar-inner.component.js.map +1 -0
  50. package/esm2015/lib/modules/datepicker/datepicker-calendar.component.js +109 -0
  51. package/esm2015/lib/modules/datepicker/datepicker-calendar.component.js.map +1 -0
  52. package/esm2015/lib/modules/datepicker/datepicker-config.service.js +21 -0
  53. package/esm2015/lib/modules/datepicker/datepicker-config.service.js.map +1 -0
  54. package/esm2015/lib/modules/datepicker/datepicker-custom-date.js +2 -0
  55. package/esm2015/lib/modules/datepicker/datepicker-custom-date.js.map +1 -0
  56. package/esm2015/lib/modules/datepicker/datepicker-date.js +2 -0
  57. package/esm2015/lib/modules/datepicker/datepicker-date.js.map +1 -0
  58. package/esm2015/lib/modules/datepicker/datepicker-input-fuzzy.directive.js +457 -0
  59. package/esm2015/lib/modules/datepicker/datepicker-input-fuzzy.directive.js.map +1 -0
  60. package/esm2015/lib/modules/datepicker/datepicker-input.directive.js +435 -0
  61. package/esm2015/lib/modules/datepicker/datepicker-input.directive.js.map +1 -0
  62. package/esm2015/lib/modules/datepicker/datepicker.component.js +333 -0
  63. package/esm2015/lib/modules/datepicker/datepicker.component.js.map +1 -0
  64. package/esm2015/lib/modules/datepicker/datepicker.module.js +95 -0
  65. package/esm2015/lib/modules/datepicker/datepicker.module.js.map +1 -0
  66. package/esm2015/lib/modules/datepicker/datepicker.service.js +21 -0
  67. package/esm2015/lib/modules/datepicker/datepicker.service.js.map +1 -0
  68. package/esm2015/lib/modules/datepicker/daypicker-button.component.js +26 -0
  69. package/esm2015/lib/modules/datepicker/daypicker-button.component.js.map +1 -0
  70. package/esm2015/lib/modules/datepicker/daypicker-cell.component.js +130 -0
  71. package/esm2015/lib/modules/datepicker/daypicker-cell.component.js.map +1 -0
  72. package/esm2015/lib/modules/datepicker/daypicker.component.js +215 -0
  73. package/esm2015/lib/modules/datepicker/daypicker.component.js.map +1 -0
  74. package/esm2015/lib/modules/datepicker/fuzzy-date.js +2 -0
  75. package/esm2015/lib/modules/datepicker/fuzzy-date.js.map +1 -0
  76. package/esm2015/lib/modules/datepicker/fuzzy-date.service.js +403 -0
  77. package/esm2015/lib/modules/datepicker/fuzzy-date.service.js.map +1 -0
  78. package/esm2015/lib/modules/datepicker/monthpicker.component.js +84 -0
  79. package/esm2015/lib/modules/datepicker/monthpicker.component.js.map +1 -0
  80. package/esm2015/lib/modules/datepicker/yearpicker.component.js +90 -0
  81. package/esm2015/lib/modules/datepicker/yearpicker.component.js.map +1 -0
  82. package/esm2015/lib/modules/shared/sky-datetime-resources.module.js +131 -0
  83. package/esm2015/lib/modules/shared/sky-datetime-resources.module.js.map +1 -0
  84. package/esm2015/lib/modules/timepicker/timepicker.component.js +367 -0
  85. package/esm2015/lib/modules/timepicker/timepicker.component.js.map +1 -0
  86. package/esm2015/lib/modules/timepicker/timepicker.directive.js +229 -0
  87. package/esm2015/lib/modules/timepicker/timepicker.directive.js.map +1 -0
  88. package/esm2015/lib/modules/timepicker/timepicker.interface.js +2 -0
  89. package/esm2015/lib/modules/timepicker/timepicker.interface.js.map +1 -0
  90. package/esm2015/lib/modules/timepicker/timepicker.module.js +46 -0
  91. package/esm2015/lib/modules/timepicker/timepicker.module.js.map +1 -0
  92. package/esm2015/skyux-datetime.js +2 -2
  93. package/esm2015/skyux-datetime.js.map +1 -0
  94. package/esm2015/testing/datepicker-fixture.js +1 -1
  95. package/esm2015/testing/datepicker-fixture.js.map +1 -0
  96. package/esm2015/testing/public-api.js +1 -1
  97. package/esm2015/testing/public-api.js.map +1 -0
  98. package/esm2015/testing/skyux-datetime-testing.js +1 -1
  99. package/esm2015/testing/skyux-datetime-testing.js.map +1 -0
  100. package/esm2015/testing/timepicker-fixture.js +1 -1
  101. package/esm2015/testing/timepicker-fixture.js.map +1 -0
  102. package/fesm2015/skyux-datetime-testing.js.map +1 -1
  103. package/fesm2015/skyux-datetime.js +301 -301
  104. package/fesm2015/skyux-datetime.js.map +1 -1
  105. package/index.d.ts +25 -0
  106. package/{modules → lib/modules}/date-pipe/date-format-utility.d.ts +0 -0
  107. package/{modules → lib/modules}/date-pipe/date-pipe.module.d.ts +0 -0
  108. package/{modules → lib/modules}/date-pipe/date.pipe.d.ts +0 -0
  109. package/{modules → lib/modules}/date-pipe/fuzzy-date.pipe.d.ts +0 -0
  110. package/{modules → lib/modules}/date-range-picker/date-range-picker.component.d.ts +0 -0
  111. package/{modules → lib/modules}/date-range-picker/date-range-picker.module.d.ts +0 -0
  112. package/{modules → lib/modules}/date-range-picker/date-range.service.d.ts +0 -0
  113. package/{modules → lib/modules}/date-range-picker/types/date-range-calculation.d.ts +0 -0
  114. package/{modules → lib/modules}/date-range-picker/types/date-range-calculator-config.d.ts +0 -0
  115. package/{modules → lib/modules}/date-range-picker/types/date-range-calculator-date-range-function.d.ts +0 -0
  116. package/{modules → lib/modules}/date-range-picker/types/date-range-calculator-id.d.ts +0 -0
  117. package/{modules → lib/modules}/date-range-picker/types/date-range-calculator-type.d.ts +0 -0
  118. package/{modules → lib/modules}/date-range-picker/types/date-range-calculator-validate-function.d.ts +0 -0
  119. package/{modules → lib/modules}/date-range-picker/types/date-range-calculator.d.ts +0 -0
  120. package/{modules → lib/modules}/date-range-picker/types/date-range-default-calculator-config.d.ts +0 -0
  121. package/{modules → lib/modules}/date-range-picker/types/date-range-default-calculator-configs.d.ts +0 -0
  122. package/{modules → lib/modules}/date-range-picker/types/date-range-relative-value.d.ts +0 -0
  123. package/{modules → lib/modules}/date-range-picker/types/date-range.d.ts +0 -0
  124. package/{modules → lib/modules}/datepicker/date-formatter.d.ts +0 -0
  125. package/{modules → lib/modules}/datepicker/datepicker-adapter.service.d.ts +0 -0
  126. package/{modules → lib/modules}/datepicker/datepicker-calendar-change.d.ts +0 -0
  127. package/{modules → lib/modules}/datepicker/datepicker-calendar-inner.component.d.ts +0 -0
  128. package/{modules → lib/modules}/datepicker/datepicker-calendar.component.d.ts +0 -0
  129. package/{modules → lib/modules}/datepicker/datepicker-config.service.d.ts +0 -0
  130. package/{modules → lib/modules}/datepicker/datepicker-custom-date.d.ts +0 -0
  131. package/{modules → lib/modules}/datepicker/datepicker-date.d.ts +0 -0
  132. package/{modules → lib/modules}/datepicker/datepicker-input-fuzzy.directive.d.ts +0 -0
  133. package/{modules → lib/modules}/datepicker/datepicker-input.directive.d.ts +0 -0
  134. package/{modules → lib/modules}/datepicker/datepicker.component.d.ts +0 -0
  135. package/{modules → lib/modules}/datepicker/datepicker.module.d.ts +0 -0
  136. package/{modules → lib/modules}/datepicker/datepicker.service.d.ts +0 -0
  137. package/{modules → lib/modules}/datepicker/daypicker-button.component.d.ts +0 -0
  138. package/{modules → lib/modules}/datepicker/daypicker-cell.component.d.ts +0 -0
  139. package/{modules → lib/modules}/datepicker/daypicker.component.d.ts +0 -0
  140. package/{modules → lib/modules}/datepicker/fuzzy-date.d.ts +0 -0
  141. package/{modules → lib/modules}/datepicker/fuzzy-date.service.d.ts +0 -0
  142. package/{modules → lib/modules}/datepicker/monthpicker.component.d.ts +0 -0
  143. package/{modules → lib/modules}/datepicker/yearpicker.component.d.ts +0 -0
  144. package/{modules → lib/modules}/shared/sky-datetime-resources.module.d.ts +0 -0
  145. package/{modules → lib/modules}/timepicker/timepicker.component.d.ts +0 -0
  146. package/{modules → lib/modules}/timepicker/timepicker.directive.d.ts +0 -0
  147. package/{modules → lib/modules}/timepicker/timepicker.interface.d.ts +0 -0
  148. package/{modules → lib/modules}/timepicker/timepicker.module.d.ts +0 -0
  149. package/package.json +10 -10
  150. package/skyux-datetime.d.ts +1 -1
  151. package/LICENSE +0 -21
  152. package/bundles/skyux-datetime-testing.umd.js.map +0 -1
  153. package/bundles/skyux-datetime.umd.js.map +0 -1
  154. package/esm2015/modules/date-pipe/date-format-utility.js +0 -48
  155. package/esm2015/modules/date-pipe/date-pipe.module.js +0 -21
  156. package/esm2015/modules/date-pipe/date.pipe.js +0 -64
  157. package/esm2015/modules/date-pipe/fuzzy-date.pipe.js +0 -46
  158. package/esm2015/modules/date-range-picker/date-range-picker.component.js +0 -460
  159. package/esm2015/modules/date-range-picker/date-range-picker.module.js +0 -47
  160. package/esm2015/modules/date-range-picker/date-range.service.js +0 -96
  161. package/esm2015/modules/date-range-picker/types/date-range-calculation.js +0 -2
  162. package/esm2015/modules/date-range-picker/types/date-range-calculator-config.js +0 -2
  163. package/esm2015/modules/date-range-picker/types/date-range-calculator-date-range-function.js +0 -2
  164. package/esm2015/modules/date-range-picker/types/date-range-calculator-id.js +0 -118
  165. package/esm2015/modules/date-range-picker/types/date-range-calculator-type.js +0 -23
  166. package/esm2015/modules/date-range-picker/types/date-range-calculator-validate-function.js +0 -2
  167. package/esm2015/modules/date-range-picker/types/date-range-calculator.js +0 -56
  168. package/esm2015/modules/date-range-picker/types/date-range-default-calculator-config.js +0 -2
  169. package/esm2015/modules/date-range-picker/types/date-range-default-calculator-configs.js +0 -147
  170. package/esm2015/modules/date-range-picker/types/date-range-relative-value.js +0 -252
  171. package/esm2015/modules/date-range-picker/types/date-range.js +0 -2
  172. package/esm2015/modules/datepicker/date-formatter.js +0 -38
  173. package/esm2015/modules/datepicker/datepicker-adapter.service.js +0 -33
  174. package/esm2015/modules/datepicker/datepicker-calendar-change.js +0 -2
  175. package/esm2015/modules/datepicker/datepicker-calendar-inner.component.js +0 -315
  176. package/esm2015/modules/datepicker/datepicker-calendar.component.js +0 -108
  177. package/esm2015/modules/datepicker/datepicker-config.service.js +0 -21
  178. package/esm2015/modules/datepicker/datepicker-custom-date.js +0 -2
  179. package/esm2015/modules/datepicker/datepicker-date.js +0 -2
  180. package/esm2015/modules/datepicker/datepicker-input-fuzzy.directive.js +0 -453
  181. package/esm2015/modules/datepicker/datepicker-input.directive.js +0 -432
  182. package/esm2015/modules/datepicker/datepicker.component.js +0 -331
  183. package/esm2015/modules/datepicker/datepicker.module.js +0 -95
  184. package/esm2015/modules/datepicker/datepicker.service.js +0 -21
  185. package/esm2015/modules/datepicker/daypicker-button.component.js +0 -25
  186. package/esm2015/modules/datepicker/daypicker-cell.component.js +0 -128
  187. package/esm2015/modules/datepicker/daypicker.component.js +0 -214
  188. package/esm2015/modules/datepicker/fuzzy-date.js +0 -2
  189. package/esm2015/modules/datepicker/fuzzy-date.service.js +0 -402
  190. package/esm2015/modules/datepicker/monthpicker.component.js +0 -83
  191. package/esm2015/modules/datepicker/yearpicker.component.js +0 -89
  192. package/esm2015/modules/shared/sky-datetime-resources.module.js +0 -131
  193. package/esm2015/modules/timepicker/timepicker.component.js +0 -365
  194. package/esm2015/modules/timepicker/timepicker.directive.js +0 -227
  195. package/esm2015/modules/timepicker/timepicker.interface.js +0 -2
  196. package/esm2015/modules/timepicker/timepicker.module.js +0 -46
  197. package/esm2015/public-api.js +0 -28
  198. package/public-api.d.ts +0 -25
@@ -0,0 +1,457 @@
1
+ import { ChangeDetectorRef, Directive, ElementRef, forwardRef, HostListener, Input, Optional, Renderer2, } from '@angular/core';
2
+ import { NG_VALIDATORS, NG_VALUE_ACCESSOR, } from '@angular/forms';
3
+ import { SkyAppLocaleProvider, SkyLibResourcesService } from '@skyux/i18n';
4
+ import { Subject } from 'rxjs';
5
+ import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
6
+ import { SkyDateFormatter } from './date-formatter';
7
+ import { SkyDatepickerConfigService } from './datepicker-config.service';
8
+ import { SkyDatepickerComponent } from './datepicker.component';
9
+ import { SkyFuzzyDateService } from './fuzzy-date.service';
10
+ import * as i0 from "@angular/core";
11
+ import * as i1 from "./datepicker-config.service";
12
+ import * as i2 from "./fuzzy-date.service";
13
+ import * as i3 from "@skyux/i18n";
14
+ import * as i4 from "./datepicker.component";
15
+ // tslint:disable:no-forward-ref no-use-before-declare
16
+ const SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR = {
17
+ provide: NG_VALUE_ACCESSOR,
18
+ useExisting: forwardRef(() => SkyFuzzyDatepickerInputDirective),
19
+ multi: true,
20
+ };
21
+ const SKY_FUZZY_DATEPICKER_VALIDATOR = {
22
+ provide: NG_VALIDATORS,
23
+ useExisting: forwardRef(() => SkyFuzzyDatepickerInputDirective),
24
+ multi: true,
25
+ };
26
+ // tslint:enable
27
+ export class SkyFuzzyDatepickerInputDirective {
28
+ constructor(changeDetector, configService, elementRef, fuzzyDateService, localeProvider, renderer, resourcesService, datepickerComponent) {
29
+ this.changeDetector = changeDetector;
30
+ this.configService = configService;
31
+ this.elementRef = elementRef;
32
+ this.fuzzyDateService = fuzzyDateService;
33
+ this.localeProvider = localeProvider;
34
+ this.renderer = renderer;
35
+ this.resourcesService = resourcesService;
36
+ this.datepickerComponent = datepickerComponent;
37
+ /**
38
+ * Indicates whether to disable date validation on the fuzzy datepicker input.
39
+ * @default false
40
+ */
41
+ this.skyDatepickerNoValidate = false;
42
+ this.dateFormatter = new SkyDateFormatter();
43
+ this.isFirstChange = true;
44
+ this.ngUnsubscribe = new Subject();
45
+ this._futureDisabled = false;
46
+ this._disabled = false;
47
+ this._yearRequired = false;
48
+ this.onChange = (_) => { };
49
+ /*istanbul ignore next */
50
+ this.onTouched = () => { };
51
+ this.onValidatorChange = () => { };
52
+ this.localeProvider
53
+ .getLocaleInfo()
54
+ .pipe(takeUntil(this.ngUnsubscribe))
55
+ .subscribe((localeInfo) => {
56
+ this.locale = localeInfo.locale;
57
+ SkyDateFormatter.setLocale(this.locale);
58
+ this.preferredShortDateFormat =
59
+ SkyDateFormatter.getPreferredShortDateFormat();
60
+ });
61
+ }
62
+ /**
63
+ * Specifies the date format for the input. Place this attribute on the `input` element
64
+ * to override the default in `SkyDatepickerConfigService`.
65
+ * @default "MM/DD/YYYY"
66
+ */
67
+ set dateFormat(value) {
68
+ this._dateFormat = value;
69
+ if (this.value) {
70
+ const formattedDate = this.fuzzyDateService.format(this.value, this.dateFormat, this.locale);
71
+ this.setInputElementValue(formattedDate);
72
+ this.changeDetector.markForCheck();
73
+ }
74
+ }
75
+ get dateFormat() {
76
+ return (this._dateFormat ||
77
+ this.configService.dateFormat ||
78
+ this.preferredShortDateFormat);
79
+ }
80
+ /**
81
+ * Indicates whether to disable the datepicker.
82
+ * @default false
83
+ */
84
+ set disabled(value) {
85
+ this._disabled = value;
86
+ this.datepickerComponent.disabled = value;
87
+ this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', value);
88
+ }
89
+ get disabled() {
90
+ return this._disabled;
91
+ }
92
+ /**
93
+ * Indicates whether to prevent users from specifying dates that are in the future.
94
+ * Place this attribute on the `input` element.
95
+ * @default false
96
+ */
97
+ set futureDisabled(value) {
98
+ this._futureDisabled = value;
99
+ this.onValidatorChange();
100
+ }
101
+ get futureDisabled() {
102
+ return this._futureDisabled;
103
+ }
104
+ /**
105
+ * Specifies the latest fuzzy date allowed. Place this attribute on the `input` element
106
+ * to prevent fuzzy dates after a specified date. This property accepts
107
+ * a `SkyFuzzyDate` value that includes numeric month, day, and year values.
108
+ * For example: `{ month: 1, day: 1, year: 2027 }`.
109
+ */
110
+ set maxDate(value) {
111
+ this._maxDate = value;
112
+ this.datepickerComponent.maxDate = this.getMaxDate();
113
+ this.onValidatorChange();
114
+ }
115
+ get maxDate() {
116
+ return this._maxDate;
117
+ }
118
+ /**
119
+ * Specifies the earliest fuzzy date allowed. Place this attribute on the `input` element
120
+ * to prevent fuzzy dates before a specified date. This property accepts a `SkyFuzzyDate` value
121
+ * that includes numeric month, day, and year values.
122
+ * For example: `{ month: 1, day: 1, year: 2007 }`.
123
+ */
124
+ set minDate(value) {
125
+ this._minDate = value;
126
+ this.datepickerComponent.minDate = this.getMinDate();
127
+ this.onValidatorChange();
128
+ }
129
+ get minDate() {
130
+ return this._minDate;
131
+ }
132
+ /**
133
+ * Creates the fuzzy datepicker input and calendar to let users specify dates that are
134
+ * not complete. For example, if users know the year but not the month or day, they can
135
+ * enter just the year. Place this directive on an `input` element, and wrap the `input`
136
+ * in a `sky-datepicker` component. The value that users select is driven
137
+ * through the `ngModel` attribute specified on the `input` element.
138
+ * @required
139
+ */
140
+ set skyFuzzyDatepickerInput(value) { }
141
+ /**
142
+ * Specifies the starting day of the week in the calendar, where `0` sets the starting day
143
+ * to Sunday. Place this attribute on the `input` element to override the default
144
+ * in `SkyDatepickerConfigService`.
145
+ * @default 0
146
+ */
147
+ set startingDay(value) {
148
+ this._startingDay = value;
149
+ this.datepickerComponent.startingDay = this.startingDay;
150
+ this.onValidatorChange();
151
+ }
152
+ get startingDay() {
153
+ return this._startingDay || this.configService.startingDay;
154
+ }
155
+ /**
156
+ * Indicates whether to require the year in fuzzy dates.
157
+ * @default false
158
+ */
159
+ set yearRequired(value) {
160
+ this._yearRequired = value;
161
+ this.onValidatorChange();
162
+ }
163
+ get yearRequired() {
164
+ return this._yearRequired;
165
+ }
166
+ get value() {
167
+ return this._value;
168
+ }
169
+ set value(value) {
170
+ let fuzzyDate;
171
+ let fuzzyMoment;
172
+ let dateValue;
173
+ let formattedDate;
174
+ if (value instanceof Date) {
175
+ dateValue = value;
176
+ formattedDate = this.dateFormatter.format(value, this.dateFormat);
177
+ fuzzyDate = this.fuzzyDateService.getFuzzyDateFromSelectedDate(value, this.dateFormat);
178
+ }
179
+ else if (typeof value === 'string') {
180
+ fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
181
+ formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
182
+ if (!formattedDate) {
183
+ formattedDate = value;
184
+ }
185
+ fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
186
+ if (fuzzyMoment) {
187
+ dateValue = fuzzyMoment.toDate();
188
+ }
189
+ }
190
+ else {
191
+ fuzzyDate = value;
192
+ formattedDate = this.fuzzyDateService.format(fuzzyDate, this.dateFormat, this.locale);
193
+ fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);
194
+ if (fuzzyMoment) {
195
+ dateValue = fuzzyMoment.toDate();
196
+ }
197
+ }
198
+ const areFuzzyDatesEqual = this.fuzzyDatesEqual(this._value, fuzzyDate);
199
+ const isNewValue = fuzzyDate !== this._value || !areFuzzyDatesEqual;
200
+ this._value = fuzzyDate || value;
201
+ if (isNewValue) {
202
+ this.onChange(this._value);
203
+ // Do not mark the field as "dirty"
204
+ // if the field has been initialized with a value.
205
+ if (this.isFirstChange && this.control) {
206
+ this.control.markAsPristine();
207
+ }
208
+ if (this.isFirstChange && this._value) {
209
+ this.isFirstChange = false;
210
+ }
211
+ this.datepickerComponent.selectedDate = dateValue;
212
+ }
213
+ this.setInputElementValue(formattedDate || '');
214
+ }
215
+ ngOnInit() {
216
+ if (this.yearRequired) {
217
+ if (this.dateFormat.toLowerCase().indexOf('y') === -1) {
218
+ throw new Error('You have configured conflicting settings. Year is required and dateFormat does not include year.');
219
+ }
220
+ }
221
+ if (!this.datepickerComponent) {
222
+ throw new Error('You must wrap the `skyFuzzyDatepickerInput` directive within a ' +
223
+ '`<sky-datepicker>` component!');
224
+ }
225
+ const element = this.elementRef.nativeElement;
226
+ this.renderer.addClass(element, 'sky-form-control');
227
+ const hasAriaLabel = element.getAttribute('aria-label');
228
+ /* istanbul ignore else */
229
+ if (!hasAriaLabel) {
230
+ this.resourcesService
231
+ .getString('skyux_date_field_default_label')
232
+ .pipe(takeUntil(this.ngUnsubscribe))
233
+ .subscribe((value) => {
234
+ this.renderer.setAttribute(element, 'aria-label', value);
235
+ });
236
+ }
237
+ }
238
+ ngAfterContentInit() {
239
+ this.datepickerComponent.dateChange
240
+ .pipe(distinctUntilChanged(), takeUntil(this.ngUnsubscribe))
241
+ .subscribe((value) => {
242
+ this.isFirstChange = false;
243
+ this.value = value;
244
+ this.onTouched();
245
+ });
246
+ }
247
+ ngAfterViewInit() {
248
+ // This is needed to address a bug in Angular 4.
249
+ // When a control value is set intially, its value is not represented on the view.
250
+ // See: https://github.com/angular/angular/issues/13792
251
+ // Of note is the parent check which allows us to determine if the form is reactive.
252
+ // Without this check there is a changed before checked error
253
+ /* istanbul ignore else */
254
+ if (this.control && this.control.parent) {
255
+ setTimeout(() => {
256
+ this.control.setValue(this.value, {
257
+ emitEvent: false,
258
+ });
259
+ this.changeDetector.markForCheck();
260
+ });
261
+ }
262
+ }
263
+ ngOnDestroy() {
264
+ this.ngUnsubscribe.next();
265
+ this.ngUnsubscribe.complete();
266
+ }
267
+ onInputChange(event) {
268
+ this.onValueChange(event.target.value);
269
+ }
270
+ onInputBlur() {
271
+ this.onTouched();
272
+ let formattedDate = this.fuzzyDateService.format(this.value, this.dateFormat, this.locale);
273
+ if (this.control.valid) {
274
+ this.setInputElementValue(formattedDate);
275
+ }
276
+ }
277
+ onInputKeyup() {
278
+ this.control.markAsDirty();
279
+ }
280
+ writeValue(value) {
281
+ this.value = value;
282
+ }
283
+ validate(control) {
284
+ if (!this.control) {
285
+ this.control = control;
286
+ }
287
+ if (this.skyDatepickerNoValidate) {
288
+ return;
289
+ }
290
+ if (!this.control.value) {
291
+ return;
292
+ }
293
+ const value = control.value;
294
+ let fuzzyDate;
295
+ let validationError;
296
+ if (typeof value === 'string') {
297
+ fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(value, this.dateFormat);
298
+ }
299
+ else {
300
+ fuzzyDate = value;
301
+ }
302
+ if (!fuzzyDate) {
303
+ validationError = {
304
+ skyFuzzyDate: {
305
+ invalid: value,
306
+ },
307
+ };
308
+ }
309
+ if (!validationError && !fuzzyDate.year && this.yearRequired) {
310
+ validationError = {
311
+ skyFuzzyDate: {
312
+ yearRequired: value,
313
+ },
314
+ };
315
+ }
316
+ if (!validationError && fuzzyDate.year) {
317
+ let fuzzyDateRange;
318
+ if (this.maxDate) {
319
+ fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.maxDate);
320
+ if (!fuzzyDateRange.valid) {
321
+ validationError = {
322
+ skyFuzzyDate: {
323
+ maxDate: value,
324
+ },
325
+ };
326
+ }
327
+ }
328
+ if (!validationError && this.minDate) {
329
+ fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(this.minDate, fuzzyDate);
330
+ if (!fuzzyDateRange.valid) {
331
+ validationError = {
332
+ skyFuzzyDate: {
333
+ minDate: value,
334
+ },
335
+ };
336
+ }
337
+ }
338
+ if (!validationError && this.futureDisabled) {
339
+ fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(fuzzyDate, this.fuzzyDateService.getCurrentFuzzyDate());
340
+ if (!fuzzyDateRange.valid) {
341
+ validationError = {
342
+ skyFuzzyDate: {
343
+ futureDisabled: value,
344
+ },
345
+ };
346
+ }
347
+ }
348
+ }
349
+ if (validationError) {
350
+ // Mark the invalid control as touched so that the input's invalid CSS styles appear.
351
+ // (This is only required when the invalid value is set by the FormControl constructor.)
352
+ this.control.markAsTouched();
353
+ }
354
+ return validationError;
355
+ }
356
+ registerOnChange(fn) {
357
+ this.onChange = fn;
358
+ }
359
+ registerOnTouched(fn) {
360
+ this.onTouched = fn;
361
+ }
362
+ registerOnValidatorChange(fn) {
363
+ this.onValidatorChange = fn;
364
+ }
365
+ setDisabledState(disabled) {
366
+ this.disabled = disabled;
367
+ this.datepickerComponent.disabled = disabled;
368
+ }
369
+ /**
370
+ * Detects changes to the underlying input element's value and updates the ngModel accordingly.
371
+ * This is useful if you need to update the ngModel value before the input element loses focus.
372
+ */
373
+ detectInputValueChange() {
374
+ this.onValueChange(this.elementRef.nativeElement.value);
375
+ }
376
+ onValueChange(newValue) {
377
+ this.isFirstChange = false;
378
+ this.value = newValue;
379
+ }
380
+ setInputElementValue(value) {
381
+ this.renderer.setProperty(this.elementRef.nativeElement, 'value', value);
382
+ }
383
+ getMaxDate() {
384
+ if (this.maxDate) {
385
+ const maxDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.maxDate);
386
+ if (maxDate.isValid()) {
387
+ return maxDate.toDate();
388
+ }
389
+ }
390
+ else if (this.futureDisabled) {
391
+ return new Date();
392
+ }
393
+ return this.configService.maxDate;
394
+ }
395
+ getMinDate() {
396
+ if (this.minDate) {
397
+ const minDate = this.fuzzyDateService.getMomentFromFuzzyDate(this.minDate);
398
+ if (minDate.isValid()) {
399
+ return minDate.toDate();
400
+ }
401
+ }
402
+ return this.configService.minDate;
403
+ }
404
+ /* istanbul ignore next */
405
+ fuzzyDatesEqual(dateA, dateB) {
406
+ return (dateA &&
407
+ dateB &&
408
+ ((!dateA.day && !dateB.day) || dateA.day === dateB.day) &&
409
+ ((!dateA.month && !dateB.month) || dateA.month === dateB.month) &&
410
+ ((!dateA.year && !dateB.year) || dateA.year === dateB.year));
411
+ }
412
+ }
413
+ SkyFuzzyDatepickerInputDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyFuzzyDatepickerInputDirective, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.SkyDatepickerConfigService }, { token: i0.ElementRef }, { token: i2.SkyFuzzyDateService }, { token: i3.SkyAppLocaleProvider }, { token: i0.Renderer2 }, { token: i3.SkyLibResourcesService }, { token: i4.SkyDatepickerComponent, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
414
+ SkyFuzzyDatepickerInputDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyFuzzyDatepickerInputDirective, selector: "[skyFuzzyDatepickerInput]", inputs: { dateFormat: "dateFormat", disabled: "disabled", futureDisabled: "futureDisabled", maxDate: "maxDate", minDate: "minDate", skyDatepickerNoValidate: "skyDatepickerNoValidate", skyFuzzyDatepickerInput: "skyFuzzyDatepickerInput", startingDay: "startingDay", yearRequired: "yearRequired" }, host: { listeners: { "change": "onInputChange($event)", "blur": "onInputBlur()", "keyup": "onInputKeyup()" } }, providers: [
415
+ SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,
416
+ SKY_FUZZY_DATEPICKER_VALIDATOR,
417
+ ], ngImport: i0 });
418
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyFuzzyDatepickerInputDirective, decorators: [{
419
+ type: Directive,
420
+ args: [{
421
+ selector: '[skyFuzzyDatepickerInput]',
422
+ providers: [
423
+ SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,
424
+ SKY_FUZZY_DATEPICKER_VALIDATOR,
425
+ ],
426
+ }]
427
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i1.SkyDatepickerConfigService }, { type: i0.ElementRef }, { type: i2.SkyFuzzyDateService }, { type: i3.SkyAppLocaleProvider }, { type: i0.Renderer2 }, { type: i3.SkyLibResourcesService }, { type: i4.SkyDatepickerComponent, decorators: [{
428
+ type: Optional
429
+ }] }]; }, propDecorators: { dateFormat: [{
430
+ type: Input
431
+ }], disabled: [{
432
+ type: Input
433
+ }], futureDisabled: [{
434
+ type: Input
435
+ }], maxDate: [{
436
+ type: Input
437
+ }], minDate: [{
438
+ type: Input
439
+ }], skyDatepickerNoValidate: [{
440
+ type: Input
441
+ }], skyFuzzyDatepickerInput: [{
442
+ type: Input
443
+ }], startingDay: [{
444
+ type: Input
445
+ }], yearRequired: [{
446
+ type: Input
447
+ }], onInputChange: [{
448
+ type: HostListener,
449
+ args: ['change', ['$event']]
450
+ }], onInputBlur: [{
451
+ type: HostListener,
452
+ args: ['blur']
453
+ }], onInputKeyup: [{
454
+ type: HostListener,
455
+ args: ['keyup']
456
+ }] } });
457
+ //# sourceMappingURL=datepicker-input-fuzzy.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datepicker-input-fuzzy.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/components/datetime/src/lib/modules/datepicker/datepicker-input-fuzzy.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EAGL,QAAQ,EACR,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAGL,aAAa,EACb,iBAAiB,GAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE3E,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAA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AU;sBADpB,KAAK;gBA4BK,QAAQ;sBADlB,KAAK;gBAkBK,cAAc;sBADxB,KAAK;gBAiBK,OAAO;sBADjB,KAAK;gBAkBK,OAAO;sBADjB,KAAK;gBAgBC,uBAAuB;sBAD7B,KAAK;gBAYK,uBAAuB;sBADjC,KAAK;gBAYK,WAAW;sBADrB,KAAK;gBAiBK,YAAY;sBADtB,KAAK;gBA0MC,aAAa;sBADnB,YAAY;uBAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC;gBAM3B,WAAW;sBADjB,YAAY;uBAAC,MAAM;gBAgBb,YAAY;sBADlB,YAAY;uBAAC,OAAO","sourcesContent":["import {\n AfterContentInit,\n AfterViewInit,\n ChangeDetectorRef,\n Directive,\n ElementRef,\n forwardRef,\n HostListener,\n Input,\n OnDestroy,\n OnInit,\n Optional,\n Renderer2,\n} from '@angular/core';\n\nimport {\n AbstractControl,\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n Validator,\n ValidationErrors,\n} from '@angular/forms';\n\nimport { SkyAppLocaleProvider, SkyLibResourcesService } from '@skyux/i18n';\n\nimport { Subject } from 'rxjs';\n\nimport { distinctUntilChanged, takeUntil } from 'rxjs/operators';\n\nimport { SkyDateFormatter } from './date-formatter';\n\nimport { SkyDatepickerConfigService } from './datepicker-config.service';\n\nimport { SkyDatepickerComponent } from './datepicker.component';\n\nimport { SkyFuzzyDate } from './fuzzy-date';\n\nimport { SkyFuzzyDateService } from './fuzzy-date.service';\n\n// tslint:disable:no-forward-ref no-use-before-declare\nconst SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SkyFuzzyDatepickerInputDirective),\n multi: true,\n};\n\nconst SKY_FUZZY_DATEPICKER_VALIDATOR = {\n provide: NG_VALIDATORS,\n useExisting: forwardRef(() => SkyFuzzyDatepickerInputDirective),\n multi: true,\n};\n// tslint:enable\n\n@Directive({\n selector: '[skyFuzzyDatepickerInput]',\n providers: [\n SKY_FUZZY_DATEPICKER_VALUE_ACCESSOR,\n SKY_FUZZY_DATEPICKER_VALIDATOR,\n ],\n})\nexport class SkyFuzzyDatepickerInputDirective\n implements\n OnInit,\n OnDestroy,\n AfterViewInit,\n AfterContentInit,\n ControlValueAccessor,\n Validator\n{\n /**\n * Specifies the date format for the input. Place this attribute on the `input` element\n * to override the default in `SkyDatepickerConfigService`.\n * @default \"MM/DD/YYYY\"\n */\n @Input()\n public set dateFormat(value: string) {\n this._dateFormat = value;\n\n if (this.value) {\n const formattedDate = this.fuzzyDateService.format(\n this.value,\n this.dateFormat,\n this.locale\n );\n this.setInputElementValue(formattedDate);\n this.changeDetector.markForCheck();\n }\n }\n\n public get dateFormat(): string {\n return (\n this._dateFormat ||\n this.configService.dateFormat ||\n this.preferredShortDateFormat\n );\n }\n\n /**\n * Indicates whether to disable the datepicker.\n * @default false\n */\n @Input()\n public set disabled(value: boolean) {\n this._disabled = value;\n this.datepickerComponent.disabled = value;\n\n this.renderer.setProperty(this.elementRef.nativeElement, 'disabled', value);\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n * Indicates whether to prevent users from specifying dates that are in the future.\n * Place this attribute on the `input` element.\n * @default false\n */\n @Input()\n public set futureDisabled(value: boolean) {\n this._futureDisabled = value;\n this.onValidatorChange();\n }\n\n public get futureDisabled(): boolean {\n return this._futureDisabled;\n }\n\n /**\n * Specifies the latest fuzzy date allowed. Place this attribute on the `input` element\n * to prevent fuzzy dates after a specified date. This property accepts\n * a `SkyFuzzyDate` value that includes numeric month, day, and year values.\n * For example: `{ month: 1, day: 1, year: 2027 }`.\n */\n @Input()\n public set maxDate(value: SkyFuzzyDate) {\n this._maxDate = value;\n this.datepickerComponent.maxDate = this.getMaxDate();\n this.onValidatorChange();\n }\n\n public get maxDate(): SkyFuzzyDate {\n return this._maxDate;\n }\n\n /**\n * Specifies the earliest fuzzy date allowed. Place this attribute on the `input` element\n * to prevent fuzzy dates before a specified date. This property accepts a `SkyFuzzyDate` value\n * that includes numeric month, day, and year values.\n * For example: `{ month: 1, day: 1, year: 2007 }`.\n */\n @Input()\n public set minDate(value: SkyFuzzyDate) {\n this._minDate = value;\n this.datepickerComponent.minDate = this.getMinDate();\n this.onValidatorChange();\n }\n\n public get minDate(): SkyFuzzyDate {\n return this._minDate;\n }\n\n /**\n * Indicates whether to disable date validation on the fuzzy datepicker input.\n * @default false\n */\n @Input()\n public skyDatepickerNoValidate = false;\n\n /**\n * Creates the fuzzy datepicker input and calendar to let users specify dates that are\n * not complete. For example, if users know the year but not the month or day, they can\n * enter just the year. Place this directive on an `input` element, and wrap the `input`\n * in a `sky-datepicker` component. The value that users select is driven\n * through the `ngModel` attribute specified on the `input` element.\n * @required\n */\n @Input()\n public set skyFuzzyDatepickerInput(\n value: SkyDatepickerComponent | undefined | ''\n ) {}\n\n /**\n * Specifies the starting day of the week in the calendar, where `0` sets the starting day\n * to Sunday. Place this attribute on the `input` element to override the default\n * in `SkyDatepickerConfigService`.\n * @default 0\n */\n @Input()\n public set startingDay(value: number) {\n this._startingDay = value;\n this.datepickerComponent.startingDay = this.startingDay;\n\n this.onValidatorChange();\n }\n\n public get startingDay(): number {\n return this._startingDay || this.configService.startingDay;\n }\n\n /**\n * Indicates whether to require the year in fuzzy dates.\n * @default false\n */\n @Input()\n public set yearRequired(value: boolean) {\n this._yearRequired = value;\n this.onValidatorChange();\n }\n\n public get yearRequired(): boolean {\n return this._yearRequired;\n }\n\n private get value(): any {\n return this._value;\n }\n\n private set value(value: any) {\n let fuzzyDate: SkyFuzzyDate;\n let fuzzyMoment: any;\n let dateValue: Date;\n let formattedDate: string;\n\n if (value instanceof Date) {\n dateValue = value;\n formattedDate = this.dateFormatter.format(value, this.dateFormat);\n fuzzyDate = this.fuzzyDateService.getFuzzyDateFromSelectedDate(\n value,\n this.dateFormat\n );\n } else if (typeof value === 'string') {\n fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(\n value,\n this.dateFormat\n );\n formattedDate = this.fuzzyDateService.format(\n fuzzyDate,\n this.dateFormat,\n this.locale\n );\n\n if (!formattedDate) {\n formattedDate = value;\n }\n\n fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);\n\n if (fuzzyMoment) {\n dateValue = fuzzyMoment.toDate();\n }\n } else {\n fuzzyDate = value as SkyFuzzyDate;\n formattedDate = this.fuzzyDateService.format(\n fuzzyDate,\n this.dateFormat,\n this.locale\n );\n fuzzyMoment = this.fuzzyDateService.getMomentFromFuzzyDate(fuzzyDate);\n\n if (fuzzyMoment) {\n dateValue = fuzzyMoment.toDate();\n }\n }\n\n const areFuzzyDatesEqual = this.fuzzyDatesEqual(this._value, fuzzyDate);\n const isNewValue = fuzzyDate !== this._value || !areFuzzyDatesEqual;\n\n this._value = fuzzyDate || value;\n\n if (isNewValue) {\n this.onChange(this._value);\n\n // Do not mark the field as \"dirty\"\n // if the field has been initialized with a value.\n if (this.isFirstChange && this.control) {\n this.control.markAsPristine();\n }\n\n if (this.isFirstChange && this._value) {\n this.isFirstChange = false;\n }\n\n this.datepickerComponent.selectedDate = dateValue;\n }\n\n this.setInputElementValue(formattedDate || '');\n }\n\n private control: AbstractControl;\n\n private dateFormatter = new SkyDateFormatter();\n\n private isFirstChange = true;\n\n private locale: string;\n\n private preferredShortDateFormat: string;\n\n private ngUnsubscribe = new Subject<void>();\n\n private _futureDisabled: boolean = false;\n\n private _dateFormat: string;\n\n private _disabled = false;\n\n private _maxDate: SkyFuzzyDate;\n\n private _minDate: SkyFuzzyDate;\n\n private _startingDay: number;\n\n private _value: any;\n\n private _yearRequired: boolean = false;\n\n constructor(\n private changeDetector: ChangeDetectorRef,\n private configService: SkyDatepickerConfigService,\n private elementRef: ElementRef,\n private fuzzyDateService: SkyFuzzyDateService,\n private localeProvider: SkyAppLocaleProvider,\n private renderer: Renderer2,\n private resourcesService: SkyLibResourcesService,\n @Optional() private datepickerComponent: SkyDatepickerComponent\n ) {\n this.localeProvider\n .getLocaleInfo()\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((localeInfo) => {\n this.locale = localeInfo.locale;\n SkyDateFormatter.setLocale(this.locale);\n this.preferredShortDateFormat =\n SkyDateFormatter.getPreferredShortDateFormat();\n });\n }\n\n public ngOnInit(): void {\n if (this.yearRequired) {\n if (this.dateFormat.toLowerCase().indexOf('y') === -1) {\n throw new Error(\n 'You have configured conflicting settings. Year is required and dateFormat does not include year.'\n );\n }\n }\n\n if (!this.datepickerComponent) {\n throw new Error(\n 'You must wrap the `skyFuzzyDatepickerInput` directive within a ' +\n '`<sky-datepicker>` component!'\n );\n }\n\n const element = this.elementRef.nativeElement;\n\n this.renderer.addClass(element, 'sky-form-control');\n\n const hasAriaLabel = element.getAttribute('aria-label');\n\n /* istanbul ignore else */\n if (!hasAriaLabel) {\n this.resourcesService\n .getString('skyux_date_field_default_label')\n .pipe(takeUntil(this.ngUnsubscribe))\n .subscribe((value: string) => {\n this.renderer.setAttribute(element, 'aria-label', value);\n });\n }\n }\n\n public ngAfterContentInit(): void {\n this.datepickerComponent.dateChange\n .pipe(distinctUntilChanged(), takeUntil(this.ngUnsubscribe))\n .subscribe((value: Date) => {\n this.isFirstChange = false;\n this.value = value;\n this.onTouched();\n });\n }\n\n public ngAfterViewInit(): void {\n // This is needed to address a bug in Angular 4.\n // When a control value is set intially, its value is not represented on the view.\n // See: https://github.com/angular/angular/issues/13792\n // Of note is the parent check which allows us to determine if the form is reactive.\n // Without this check there is a changed before checked error\n /* istanbul ignore else */\n\n if (this.control && this.control.parent) {\n setTimeout(() => {\n this.control.setValue(this.value, {\n emitEvent: false,\n });\n\n this.changeDetector.markForCheck();\n });\n }\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n @HostListener('change', ['$event'])\n public onInputChange(event: any) {\n this.onValueChange(event.target.value);\n }\n\n @HostListener('blur')\n public onInputBlur(): void {\n this.onTouched();\n\n let formattedDate = this.fuzzyDateService.format(\n this.value,\n this.dateFormat,\n this.locale\n );\n\n if (this.control.valid) {\n this.setInputElementValue(formattedDate);\n }\n }\n\n @HostListener('keyup')\n public onInputKeyup(): void {\n this.control.markAsDirty();\n }\n\n public writeValue(value: any): void {\n this.value = value;\n }\n\n public validate(control: AbstractControl): ValidationErrors {\n if (!this.control) {\n this.control = control;\n }\n\n if (this.skyDatepickerNoValidate) {\n return;\n }\n\n if (!this.control.value) {\n return;\n }\n\n const value: any = control.value;\n\n let fuzzyDate: SkyFuzzyDate;\n let validationError: ValidationErrors;\n\n if (typeof value === 'string') {\n fuzzyDate = this.fuzzyDateService.getFuzzyDateFromString(\n value,\n this.dateFormat\n );\n } else {\n fuzzyDate = value;\n }\n\n if (!fuzzyDate) {\n validationError = {\n skyFuzzyDate: {\n invalid: value,\n },\n };\n }\n\n if (!validationError && !fuzzyDate.year && this.yearRequired) {\n validationError = {\n skyFuzzyDate: {\n yearRequired: value,\n },\n };\n }\n\n if (!validationError && fuzzyDate.year) {\n let fuzzyDateRange;\n\n if (this.maxDate) {\n fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(\n fuzzyDate,\n this.maxDate\n );\n\n if (!fuzzyDateRange.valid) {\n validationError = {\n skyFuzzyDate: {\n maxDate: value,\n },\n };\n }\n }\n\n if (!validationError && this.minDate) {\n fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(\n this.minDate,\n fuzzyDate\n );\n if (!fuzzyDateRange.valid) {\n validationError = {\n skyFuzzyDate: {\n minDate: value,\n },\n };\n }\n }\n\n if (!validationError && this.futureDisabled) {\n fuzzyDateRange = this.fuzzyDateService.getFuzzyDateRange(\n fuzzyDate,\n this.fuzzyDateService.getCurrentFuzzyDate()\n );\n if (!fuzzyDateRange.valid) {\n validationError = {\n skyFuzzyDate: {\n futureDisabled: value,\n },\n };\n }\n }\n }\n\n if (validationError) {\n // Mark the invalid control as touched so that the input's invalid CSS styles appear.\n // (This is only required when the invalid value is set by the FormControl constructor.)\n this.control.markAsTouched();\n }\n\n return validationError;\n }\n\n public registerOnChange(fn: (value: any) => void): void {\n this.onChange = fn;\n }\n\n public registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n public registerOnValidatorChange(fn: () => void): void {\n this.onValidatorChange = fn;\n }\n\n public setDisabledState(disabled: boolean): void {\n this.disabled = disabled;\n this.datepickerComponent.disabled = disabled;\n }\n\n /**\n * Detects changes to the underlying input element's value and updates the ngModel accordingly.\n * This is useful if you need to update the ngModel value before the input element loses focus.\n */\n public detectInputValueChange(): void {\n this.onValueChange(this.elementRef.nativeElement.value);\n }\n\n private onValueChange(newValue: string): void {\n this.isFirstChange = false;\n this.value = newValue;\n }\n\n private setInputElementValue(value: string): void {\n this.renderer.setProperty(this.elementRef.nativeElement, 'value', value);\n }\n\n private getMaxDate(): Date {\n if (this.maxDate) {\n const maxDate = this.fuzzyDateService.getMomentFromFuzzyDate(\n this.maxDate\n );\n if (maxDate.isValid()) {\n return maxDate.toDate();\n }\n } else if (this.futureDisabled) {\n return new Date();\n }\n return this.configService.maxDate;\n }\n\n private getMinDate(): Date {\n if (this.minDate) {\n const minDate = this.fuzzyDateService.getMomentFromFuzzyDate(\n this.minDate\n );\n if (minDate.isValid()) {\n return minDate.toDate();\n }\n }\n return this.configService.minDate;\n }\n\n /* istanbul ignore next */\n private fuzzyDatesEqual(dateA: SkyFuzzyDate, dateB: SkyFuzzyDate): boolean {\n return (\n dateA &&\n dateB &&\n ((!dateA.day && !dateB.day) || dateA.day === dateB.day) &&\n ((!dateA.month && !dateB.month) || dateA.month === dateB.month) &&\n ((!dateA.year && !dateB.year) || dateA.year === dateB.year)\n );\n }\n\n private onChange = (_: any) => {};\n /*istanbul ignore next */\n private onTouched = () => {};\n private onValidatorChange = () => {};\n}\n"]}