Class: StimulusPlumbers::Components::Combobox::Time

Inherits:
Plumber::Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/components/combobox/time.rb

Overview

Renders an iOS-style drum/wheel time picker as the popover body. Wires ComboboxTimeController; dispatches combobox-time:selected → InputComboboxController.

Constant Summary collapse

PICKER_CONTROLLER =
"combobox-time"

Constants included from Plumber::HtmlOptions

Plumber::HtmlOptions::STIMULUS_SPACEJOIN_KEYS

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::HtmlOptions

#merge_data_options, #merge_html_options, #merge_string_option, #normalize_part

Constructor Details

This class inherits a constructor from StimulusPlumbers::Components::Plumber::Base

Class Method Details

.default_optsObject



11
12
13
14
15
# File 'lib/stimulus_plumbers/components/combobox/time.rb', line 11

def self.default_opts
  {
    popover: { label: "Picker", role: "dialog", tag: :div }
  }
end

Instance Method Details

#render(format: :h12, step: 1, value: nil, **_kwargs) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/stimulus_plumbers/components/combobox/time.rb', line 17

def render(format: :h12, step: 1, value: nil, **_kwargs)
  @format = format
  @step   = [1, step.to_i].max
  @time   = parse_time(value)

  template.(
    :div,
    data: {
      controller: PICKER_CONTROLLER,
      action:     "#{PICKER_CONTROLLER}:selected->input-combobox#onSelected"
    }
  ) do
    template.safe_join(drums)
  end
end