@radioactive-labs/plutonium 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Connects to data-controller="flatpickr"
4
+ export default class extends Controller {
5
+ connect() {
6
+ console.log(`flatpickr connected: ${this.element}`)
7
+ self.picker = new flatpickr(this.element, this.#buildOptions())
8
+ }
9
+
10
+ disconnect() {
11
+ self.picker.destroy()
12
+ self.picker = null
13
+ }
14
+
15
+ #buildOptions() {
16
+ let options = { altInput: true }
17
+ if (this.element.attributes.type.value == "datetime-local") {
18
+ options.enableTime = true
19
+ }
20
+ else if (this.element.attributes.type.value == "time") {
21
+ options.enableTime = true
22
+ options.noCalendar = true
23
+ // options.time_24hr = true
24
+ // options.altFormat = "H:i"
25
+ }
26
+ return options
27
+ }
28
+ }
@@ -23,6 +23,7 @@ import FrameNavigatorController from "./frame_navigator_controller.js"
23
23
  import ColorModeController from "./color_mode_controller.js"
24
24
  import EasyMDEController from "./easymde_controller.js"
25
25
  import SlimSelectController from "./slim_select_controller.js"
26
+ import FlatpickrController from "./flatpickr_controller.js"
26
27
 
27
28
  export default function (application) {
28
29
  // Register controllers here
@@ -50,4 +51,5 @@ export default function (application) {
50
51
  application.register("color-mode", ColorModeController)
51
52
  application.register("easymde", EasyMDEController)
52
53
  application.register("slim-select", SlimSelectController)
54
+ application.register("flatpickr", FlatpickrController)
53
55
  }