Class: StimulusPlumbers::Components::TimePicker::Renderer

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

Overview

Renders a single scrollable drum column (hour, minute, or period) as a listbox.

Constant Summary collapse

CONTROLLER =
"combobox-time"

Constants included from Plumber::HtmlOptions

Plumber::HtmlOptions::STIMULUS_SPACEJOIN_KEYS

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

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

Instance Method Details

#render(items:, label:, target:, selected: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/stimulus_plumbers/components/time_picker/renderer.rb', line 10

def render(items:, label:, target:, selected: nil)
  template.(
    :ul,
    role: "listbox",
    aria: { label: label },
    data: {
      "#{CONTROLLER}_target": target,
      action:                 "click->#{CONTROLLER}#select keydown->#{CONTROLLER}#navigate"
    }
  ) do
    template.safe_join(items.map { |text, value| render_item(text, value, selected) })
  end
end