Module: StimulusPlumbers::Helpers::ComboboxHelper
- Included in:
- StimulusPlumbers::Helpers
- Defined in:
- lib/stimulus_plumbers/helpers/combobox_helper.rb
Instance Method Summary collapse
- #sp_combobox_autocomplete(label: nil, options: [], value: nil, url: nil, **html_options) ⇒ Object
- #sp_combobox_date(label: nil, value: nil, **html_options) ⇒ Object
- #sp_combobox_dropdown(label: nil, options: [], value: nil, **html_options) ⇒ Object
- #sp_combobox_time(format: :h12, label: nil, step: 1, value: nil, **html_options) ⇒ Object
Instance Method Details
#sp_combobox_autocomplete(label: nil, options: [], value: nil, url: nil, **html_options) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/stimulus_plumbers/helpers/combobox_helper.rb', line 32 def sp_combobox_autocomplete(label: nil, options: [], value: nil, url: nil, **) id = sp_dom_id opts = Components::Combobox::Autocomplete.default_opts.deep_merge( input: { value: value }, trigger: { id: id, aria_label: label }.compact, popover: { data: url ? { combobox_dropdown_url_value: url } : {} } ) Components::Combobox.new(self).render( **opts, data: { input_combobox_combobox_dropdown_outlet: "##{Components::Combobox.popover_id_for(id)}", action: "input->input-combobox#onInput" }, ** ) do Components::Combobox::Autocomplete.new(self).render(options: , value: value, label: label) end end |
#sp_combobox_date(label: nil, value: nil, **html_options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/stimulus_plumbers/helpers/combobox_helper.rb', line 6 def sp_combobox_date(label: nil, value: nil, **) id = sp_dom_id opts = Components::Combobox::Date.default_opts.deep_merge( input: { value: value }, trigger: { id: id, aria_label: label }.compact ) Components::Combobox.new(self).render( **opts, data: { input_format_type_value: "date" }, ** ) do |popover_id| Components::Combobox::Date.new(self).render(value: value, popover_id: popover_id) end end |
#sp_combobox_dropdown(label: nil, options: [], value: nil, **html_options) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/stimulus_plumbers/helpers/combobox_helper.rb', line 21 def sp_combobox_dropdown(label: nil, options: [], value: nil, **) id = sp_dom_id opts = Components::Combobox::Dropdown.default_opts.deep_merge( input: { value: value }, trigger: { id: id, aria_label: label }.compact ) Components::Combobox.new(self).render(**opts, **) do Components::Combobox::Dropdown.new(self).render(options: , value: value, label: label) end end |
#sp_combobox_time(format: :h12, label: nil, step: 1, value: nil, **html_options) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/stimulus_plumbers/helpers/combobox_helper.rb', line 51 def sp_combobox_time(format: :h12, label: nil, step: 1, value: nil, **) id = sp_dom_id opts = Components::Combobox::Time.default_opts.deep_merge( input: { value: value }, trigger: { id: id, aria_label: label }.compact ) Components::Combobox.new(self).render( **opts, data: { input_format_type_value: "time", input_format_options_value: { format: format }.to_json }, ** ) do Components::Combobox::Time.new(self).render(format: format, step: step, value: value) end end |