I'm trying to incorporate the monthSelectPlugin for flatpickr in a Rails application. I have it specified in my importmap like this:
pin "flatpickr/dist/plugins/monthSelect", to: "https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee88828f9a9e878d859caedac0d8c0dfdd">[email protected]</a>/dist/plugins/monthSelect/index.js"
In my stimulus controller, I am using it as per their documentation example:
import { Controller } from "@hotwired/stimulus"
import flatpickr from "flatpickr"
import * as monthSelectPlugin from 'flatpickr/dist/plugins/monthSelect';
export default class extends Controller {
static targets = ['picker']
connect() {
const picker_div = this.pickerTargets;
flatpickr(picker_div, {
plugins: [
new monthSelectPlugin({
shorthand: true,
dateFormat: "m.y",
altFormat: "F Y",
theme: "dark"
})
]});
}
}
However, I encounter an error:
TypeError: monthSelectPlugin is not a constructor
After struggling with the import process, can anyone pinpoint what's causing this issue?