Skip to content

Commit 229f87d

Browse files
committed
fix: access correct object property to resolve webpack import error
Signed-off-by: Akshat Patel <akshat@live.ca>
1 parent 268fbe1 commit 229f87d

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

src/datepicker/datepicker.component.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@ import rangePlugin from "flatpickr/dist/plugins/rangePlugin";
2121
import flatpickr from "flatpickr";
2222
import { NG_VALUE_ACCESSOR } from "@angular/forms";
2323
import { carbonFlatpickrMonthSelectPlugin } from "./carbon-flatpickr-month-select";
24-
import * as languages from "flatpickr/dist/l10n/index";
24+
import languages from "flatpickr/dist/l10n/index";
2525
import { DatePickerInput } from "carbon-components-angular/datepicker-input";
26-
import { ElementService } from "carbon-components-angular/utils";
2726
import { I18n } from "carbon-components-angular/i18n";
2827

28+
// Due to type error, we have to use square brackets property accessor
29+
(languages.default["en"].weekdays.shorthand as string[])
30+
= languages.default["en"].weekdays.longhand.map(day => {
31+
if (day === "Thursday") {
32+
return "Th";
33+
}
34+
return day.charAt(0);
35+
});
36+
2937
/**
3038
* [See demo](../../?path=/story/components-date-picker--single)
3139
*/
@@ -101,8 +109,7 @@ export class DatePicker implements
101109
OnDestroy,
102110
OnChanges,
103111
AfterViewChecked,
104-
AfterViewInit,
105-
AfterContentInit {
112+
AfterViewInit {
106113
private static datePickerCount = 0;
107114

108115
/**
@@ -330,16 +337,6 @@ export class DatePicker implements
330337
}
331338
}
332339

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-
343340
@HostListener("focusin")
344341
onFocus() {
345342
// Updates the month manually when calendar mode is range because month

src/datepicker/datepicker.stories.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export default {
1717
invalid: false,
1818
warnText: "This is a warning",
1919
warn: false,
20-
disabled: false
20+
disabled: false,
21+
language: "en"
2122
},
2223
argTypes: {
2324
theme: {

0 commit comments

Comments
 (0)