Class: MaquinaComponents::ComboboxHelper::ComboboxContentBuilder
- Inherits:
-
Object
- Object
- MaquinaComponents::ComboboxHelper::ComboboxContentBuilder
- Defined in:
- app/helpers/maquina_components/combobox_helper.rb
Overview
Builder for combobox content
Instance Method Summary collapse
-
#empty(text: "No results found.", **options) ⇒ Object
Adds the empty state.
-
#initialize(view_context) ⇒ ComboboxContentBuilder
constructor
A new instance of ComboboxContentBuilder.
-
#input(placeholder: "Search...", **options) ⇒ Object
Adds the search input.
-
#list(**options) { ... } ⇒ Object
Adds the options list container.
-
#to_html ⇒ Object
Generates the final HTML.
Constructor Details
#initialize(view_context) ⇒ ComboboxContentBuilder
Returns a new instance of ComboboxContentBuilder.
186 187 188 189 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 186 def initialize(view_context) @view = view_context @parts = [] end |
Instance Method Details
#empty(text: "No results found.", **options) ⇒ Object
Adds the empty state
221 222 223 224 225 226 227 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 221 def empty(text: "No results found.", **) @parts << @view.render( "components/combobox/empty", text: text, ** ) end |
#input(placeholder: "Search...", **options) ⇒ Object
Adds the search input
195 196 197 198 199 200 201 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 195 def input(placeholder: "Search...", **) @parts << @view.render( "components/combobox/input", placeholder: placeholder, ** ) end |
#list(**options) { ... } ⇒ Object
Adds the options list container
207 208 209 210 211 212 213 214 215 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 207 def list(**, &block) list_builder = ComboboxListBuilder.new(@view) @view.capture(list_builder, &block) @parts << @view.render( "components/combobox/list", ** ) { list_builder.to_html } end |
#to_html ⇒ Object
Generates the final HTML
230 231 232 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 230 def to_html @view.safe_join(@parts) end |