Sha256: e838559b0c4ea5d939a5e56eac040260b7d2205531d317756d9c38b9905081c4
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
import { Controller } from "@hotwired/stimulus" import flatpickr from "https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/+esm" export default class extends Controller { static targets = [ "details" ] static values = { type: String, disable: Array, mode: { type: String, default: "single" }, dateFormat: { type: String, default: "F d, Y" }, dateTimeFormat: { type: String, default: "F d, Y H:i" } } connect() { if (this.typeValue == "time") { this.flatpickr = flatpickr(this.element, this.#timeOptions) } else if (this.typeValue == "datetime") { this.flatpickr = flatpickr(this.element, this.#dateTimeOptions) } else { this.flatpickr = flatpickr(this.element, this.#basicOptions) } } disconnect() { this.flatpickr.destroy() } get #timeOptions() { return { dateFormat: "H:i", enableTime: true, noCalendar: true } } get #dateTimeOptions() { return { ...this.#baseOptions, altFormat: this.dateTimeFormatValue, dateFormat: "Y-m-d H:i", enableTime: true } } get #basicOptions() { return { ...this.#baseOptions, altFormat: this.dateFormatValue, dateFormat: "Y-m-d" } } get #baseOptions() { return { altInput: true, disable: this.disableValue, mode: this.modeValue } } }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
css-zero-0.0.87 | lib/generators/css_zero/add/templates/app/javascript/controllers/datepicker_controller.js |