@radioactive-labs/plutonium 0.1.11 → 0.1.13

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.
@@ -5,10 +5,16 @@ export default class extends Controller {
5
5
  connect() {
6
6
  console.log(`easymde connected: ${this.element}`)
7
7
  self.easyMDE = new EasyMDE({ element: this.element })
8
+ this.element.setAttribute("data-action", "turbo:morph-element->easymde#reconnect")
8
9
  }
9
10
 
10
11
  disconnect() {
11
12
  self.easyMDE.toTextArea()
12
13
  self.easyMDE = null
13
14
  }
15
+
16
+ reconnect() {
17
+ this.disconnect()
18
+ this.connect()
19
+ }
14
20
  }
@@ -0,0 +1,34 @@
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
+ this.element.setAttribute("data-action", "turbo:morph-element->flatpickr#reconnect")
9
+ }
10
+
11
+ disconnect() {
12
+ self.picker.destroy()
13
+ self.picker = null
14
+ }
15
+
16
+ reconnect() {
17
+ this.disconnect()
18
+ this.connect()
19
+ }
20
+
21
+ #buildOptions() {
22
+ let options = { altInput: true }
23
+ if (this.element.attributes.type.value == "datetime-local") {
24
+ options.enableTime = true
25
+ }
26
+ else if (this.element.attributes.type.value == "time") {
27
+ options.enableTime = true
28
+ options.noCalendar = true
29
+ // options.time_24hr = true
30
+ // options.altFormat = "H:i"
31
+ }
32
+ return options
33
+ }
34
+ }
@@ -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
  }
@@ -7,10 +7,16 @@ export default class extends Controller {
7
7
  self.slimSelect = new SlimSelect({
8
8
  select: this.element
9
9
  })
10
+ this.element.setAttribute("data-action", "turbo:morph-element->slim-select#reconnect")
10
11
  }
11
12
 
12
13
  disconnect() {
13
14
  self.slimSelect.destroy()
14
15
  self.slimSelect = null
15
16
  }
17
+
18
+ reconnect() {
19
+ this.disconnect()
20
+ this.connect()
21
+ }
16
22
  }