Sha256: 7826dcc6f26af9317ca2d1e0a6856c668bccfee75a0c744c8e6cb9ebfc5caa06
Contents?: true
Size: 1.23 KB
Versions: 10
Compression:
Stored size: 1.23 KB
Contents
import { Controller } from "@hotwired/stimulus" import flatpickr from "https://esm.sh/flatpickr@4.6.13?standalone" 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
10 entries across 10 versions & 1 rubygems