@skyux/datetime 5.9.4 → 6.0.0-beta.10

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