Sha256: 3b26ced67a502fee4e7f480c38ccedbd12b32297f5ce26a332b8c0a25bf76dbd

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

import { Controller } from "@hotwired/stimulus"

// Connects to data-controller="flatpickr"
export default class extends Controller {
  connect() {
    console.log(`flatpickr connected: ${this.element}`)
    self.picker = new flatpickr(this.element, this.#buildOptions())
  }

  disconnect() {
    self.picker.destroy()
    self.picker = null
  }

  #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

1 entries across 1 versions & 1 rubygems

Version Path
plutonium-0.15.23 src/js/controllers/flatpickr_controller.js