Class: StimulusPlumbers::Components::Combobox::Renderer
- Inherits:
-
Plumber::Base
- Object
- Plumber::Base
- StimulusPlumbers::Components::Combobox::Renderer
- Defined in:
- lib/stimulus_plumbers/components/combobox/renderer.rb
Constant Summary collapse
- STIMULUS_CONTROLLER =
"input-combobox"- FORMAT_CONTROLLER =
"input-format"- FORMAT_ACTION =
"input-combobox:changed->input-format#format"
Constants included from Plumber::HtmlOptions
Plumber::HtmlOptions::STIMULUS_SPACEJOIN_KEYS
Instance Attribute Summary
Attributes inherited from Plumber::Base
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::Components::Plumber::Base
Instance Method Details
#render(base_id:, options: {}, **kwargs) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stimulus_plumbers/components/combobox/renderer.rb', line 11 def render(base_id:, options: {}, **kwargs) popover_id = "#{base_id}_popover" initial_value = .dig(:input, :value) base_data = { controller: "#{STIMULUS_CONTROLLER} #{FORMAT_CONTROLLER}", action: FORMAT_ACTION } base_data[:input_combobox_value_value] = initial_value if initial_value.present? = ({ data: base_data }, kwargs) template.content_tag(:div, **) do template.safe_join( [ trigger_input( popover_id, .dig(:popover, :haspopup) || .dig(:popover, :role) || "dialog", .fetch(:trigger, {}) ), hidden_input(.fetch(:input, {})), popover_element(popover_id, .fetch(:popover, {})) ] ) end end |