Sha256: 42075b53241bdf49a15004d1f832759170c9dd77c4392fa191a15dee547129ed
Contents?: true
Size: 829 Bytes
Versions: 20
Compression:
Stored size: 829 Bytes
Contents
import { Controller } from "@hotwired/stimulus" // Connects to data-controller="flatpickr" export default class extends Controller { connect() { this.picker = new flatpickr(this.element, this.#buildOptions()) this.element.setAttribute("data-action", "turbo:morph-element->flatpickr#reconnect") } disconnect() { this.picker.destroy() this.picker = null } reconnect() { this.disconnect() this.connect() } #buildOptions() { let options = { altInput: true } if (this.element.attributes.type.value == "datetime-local") { options.enableTime = true } else if (this.element.attributes.type.value == "time") { options.enableTime = true options.noCalendar = true // options.time_24hr = true // options.altFormat = "H:i" } return options } }
Version data entries
20 entries across 20 versions & 1 rubygems