fix(date-picker): resolve flatpickr "no default" error when using esm

This commit is contained in:
Eric Liu 2020-08-08 16:07:10 -07:00
commit 6d5f1e53de

View file

@ -1,6 +1,6 @@
import flatpickr from "flatpickr"; import * as flatpickr from "flatpickr";
import l10n from "flatpickr/dist/l10n/index.js"; import * as l10n from "flatpickr/dist/l10n/index.js";
import rangePlugin from "flatpickr/dist/plugins/rangePlugin"; import * as rangePlugin from "flatpickr/dist/plugins/rangePlugin";
function updateClasses(instance) { function updateClasses(instance) {
const { const {
@ -50,14 +50,14 @@ function updateMonthNode(instance) {
function createCalendar({ options, base, input, dispatch }) { function createCalendar({ options, base, input, dispatch }) {
let locale = options.locale; let locale = options.locale;
if (options.locale === "en" && l10n && l10n.en) { if (options.locale === "en" && l10n.default && l10n.default.en) {
l10n.en.weekdays.shorthand.forEach((_, index) => { l10n.default.en.weekdays.shorthand.forEach((_, index) => {
const shorthand = _.slice(0, 2); const shorthand = _.slice(0, 2);
l10n.en.weekdays.shorthand[index] = l10n.default.en.weekdays.shorthand[index] =
shorthand === "Th" ? "Th" : shorthand.charAt(0); shorthand === "Th" ? "Th" : shorthand.charAt(0);
}); });
locale = l10n.en; locale = l10n.default.en;
} }
return new flatpickr(base, { return new flatpickr(base, {