Class: StimulusPlumbers::Components::Combobox::Dropdown
- Inherits:
-
Plumber::Base
- Object
- Plumber::Base
- StimulusPlumbers::Components::Combobox::Dropdown
- Defined in:
- lib/stimulus_plumbers/components/combobox/dropdown.rb
Constant Summary collapse
- STIMULUS_CONTROLLER =
"combobox-dropdown"- STIMULUS_ACTION =
[ "click->#{STIMULUS_CONTROLLER}#select", "keydown->#{STIMULUS_CONTROLLER}#onNavigate", "#{STIMULUS_CONTROLLER}:selected->#{Combobox::STIMULUS_CONTROLLER}#onSelect" ].join(" ").freeze
Constants included from Plumber::HtmlOptions
Plumber::HtmlOptions::STIMULUS_SPACEJOIN_KEYS
Instance Attribute Summary
Attributes inherited from Plumber::Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Plumber::Base
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::Plumber::Base
Class Method Details
.default_opts ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/stimulus_plumbers/components/combobox/dropdown.rb', line 14 def self.default_opts { popover: { tag: :div, haspopup: "listbox", data: { controller: STIMULUS_CONTROLLER, action: STIMULUS_ACTION } } } end |
Instance Method Details
#render(options: [], value: nil, label: nil, **_kwargs) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/stimulus_plumbers/components/combobox/dropdown.rb', line 24 def render(options: [], value: nil, label: nil, **_kwargs) listbox_attrs = ( { classes: theme.resolve(:combobox_listbox).fetch(:classes, "") }, { role: "listbox", data: { "#{STIMULUS_CONTROLLER}_target": "listbox" } } ) listbox_attrs[:aria] = { label: label } if label template.content_tag(:ul, **listbox_attrs) do Options.new(template).render(, value: value) end end |