Sha256: 620e630f9797632f4a9de61f25ca9e094fe1ad2809d4454b530f0e41792f39d8
Contents?: true
Size: 879 Bytes
Versions: 4
Compression:
Stored size: 879 Bytes
Contents
import {Controller} from "@hotwired/stimulus" import flatpickr from "flatpickr"; import {Dutch} from "flatpickr/dist/esm/l10n/nl.js" import I18n from "../config/i18n"; export default class extends Controller { static get targets() { return ["input"] } connect() { const options = {...this.defaultOptions(), ...this.options()} flatpickr(this.inputTarget, options); } options() { return JSON.parse(this.inputTarget.getAttribute('data-flatpickr-options')) } defaultOptions() { return { allowInput: true, dateFormat: 'd/m/Y', locale: this.getLocale(I18n.locale) } } getLocale(locale) { const locales = this.locales() return locales[locale] } locales() { return { en: null, nl: Dutch } } }
Version data entries
4 entries across 4 versions & 1 rubygems