Class: StimulusPlumbers::Components::Combobox::Popover

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

Constant Summary

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::Plumber::Base

Instance Method Details

#render(stimulus_controller:, id:, tag: :div, role: nil, label: nil, content: nil, data: {}, **_rest, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/stimulus_plumbers/components/combobox/popover.rb', line 7

def render(stimulus_controller:, id:, tag: :div, role: nil, label: nil, content: nil, data: {}, **_rest, &block)
  base_data = { "#{stimulus_controller}_target": "popover" }

  attrs = { id: id, hidden: "", data: merge_data_options(base_data, data.symbolize_keys) }
  attrs[:role] = role if role
  attrs[:aria] = { label: label } if label

  html_content = block_given? ? template.capture(&block) : content
  template.(tag, **attrs) { html_content }
end