@@ -13,7 +13,6 @@ import {
13
13
AfterViewChecked ,
14
14
AfterViewInit ,
15
15
ViewChild ,
16
- AfterContentInit ,
17
16
OnInit ,
18
17
SimpleChange
19
18
} from "@angular/core" ;
@@ -23,9 +22,25 @@ import { NG_VALUE_ACCESSOR } from "@angular/forms";
23
22
import { carbonFlatpickrMonthSelectPlugin } from "./carbon-flatpickr-month-select" ;
24
23
import * as languages from "flatpickr/dist/l10n/index" ;
25
24
import { DatePickerInput } from "carbon-components-angular/datepicker-input" ;
26
- import { ElementService } from "carbon-components-angular/utils" ;
27
25
import { I18n } from "carbon-components-angular/i18n" ;
28
26
27
+ /**
28
+ * Due to type error, we have to use square brackets property accessor
29
+ * There is a webpack issue when attempting to access exported languages from flatpickr l10n Angular 14+ apps
30
+ * languages.default[locale] fails in app consuming CCA library but passes in test
31
+ * languages.default.default[locale] fails in test but works in app consuming CCA library.
32
+ *
33
+ * To please both scenarios, we are adding a condition to prevent tests from failing
34
+ */
35
+ if ( languages . default ?. default [ "en" ] ?. weekdays ) {
36
+ ( languages . default . default [ "en" ] . weekdays . shorthand as string [ ] ) = languages . default . default [ "en" ] . weekdays . longhand . map ( day => {
37
+ if ( day === "Thursday" ) {
38
+ return "Th" ;
39
+ }
40
+ return day . charAt ( 0 ) ;
41
+ } ) ;
42
+ }
43
+
29
44
/**
30
45
* [See demo](../../?path=/story/components-date-picker--single)
31
46
*/
@@ -101,8 +116,7 @@ export class DatePicker implements
101
116
OnDestroy ,
102
117
OnChanges ,
103
118
AfterViewChecked ,
104
- AfterViewInit ,
105
- AfterContentInit {
119
+ AfterViewInit {
106
120
private static datePickerCount = 0 ;
107
121
108
122
/**
@@ -214,7 +228,7 @@ export class DatePicker implements
214
228
mode : this . range ? "range" : "single" ,
215
229
plugins,
216
230
dateFormat : this . dateFormat ,
217
- locale : languages . default [ this . language ]
231
+ locale : languages . default ?. default [ this . language ] || languages . default [ this . language ]
218
232
} ) ;
219
233
}
220
234
@@ -330,16 +344,6 @@ export class DatePicker implements
330
344
}
331
345
}
332
346
333
- ngAfterContentInit ( ) {
334
- ( languages . default . en . weekdays . shorthand as string [ ] )
335
- = languages . default . en . weekdays . longhand . map ( day => {
336
- if ( day === "Thursday" ) {
337
- return "Th" ;
338
- }
339
- return day . charAt ( 0 ) ;
340
- } ) ;
341
- }
342
-
343
347
@HostListener ( "focusin" )
344
348
onFocus ( ) {
345
349
// Updates the month manually when calendar mode is range because month
0 commit comments