Class: StimulusPlumbers::Components::Combobox
- Inherits:
-
Plumber::Base
- Object
- Plumber::Base
- StimulusPlumbers::Components::Combobox
- Defined in:
- lib/stimulus_plumbers/components/combobox.rb,
lib/stimulus_plumbers/components/combobox/date.rb,
lib/stimulus_plumbers/components/combobox/time.rb,
lib/stimulus_plumbers/components/combobox/options.rb,
lib/stimulus_plumbers/components/combobox/popover.rb,
lib/stimulus_plumbers/components/combobox/trigger.rb,
lib/stimulus_plumbers/components/combobox/dropdown.rb,
lib/stimulus_plumbers/components/combobox/time/drum.rb,
lib/stimulus_plumbers/components/combobox/autocomplete.rb,
lib/stimulus_plumbers/components/combobox/options/option.rb,
lib/stimulus_plumbers/components/combobox/options/option_group.rb
Defined Under Namespace
Classes: Autocomplete, Date, Dropdown, Options, Popover, Time, Trigger
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
- #popover(popover_id, options) ⇒ Object
- #render(base_id:, options: {}, **kwargs) ⇒ Object
- #trigger(popover_id, options) ⇒ Object
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
Instance Method Details
#popover(popover_id, options) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/stimulus_plumbers/components/combobox.rb', line 43 def popover(popover_id, ) Combobox::Popover.new(template).render( stimulus_controller: STIMULUS_CONTROLLER, id: popover_id, **.fetch(:popover, {}) ) end |
#render(base_id:, options: {}, **kwargs) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stimulus_plumbers/components/combobox.rb', line 10 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(popover_id, ), hidden_input(.fetch(:input, {})), popover(popover_id, ) ] ) end end |
#trigger(popover_id, options) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/stimulus_plumbers/components/combobox.rb', line 33 def trigger(popover_id, ) haspopup = .dig(:popover, :haspopup) || .dig(:popover, :role) || "dialog" Combobox::Trigger.new(template).render( stimulus_controller: STIMULUS_CONTROLLER, popover_id: popover_id, haspopup: haspopup, **.fetch(:trigger, {}) ) end |