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.
185 186 187 188 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 185 def initialize(view_context) @view = view_context @parts = [] end |
Instance Method Details
#empty(text: "No results found.", **options) ⇒ Object
Adds the empty state
220 221 222 223 224 225 226 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 220 def empty(text: "No results found.", **) @parts << @view.render( "components/combobox/empty", text: text, ** ) end |
#input(placeholder: "Search...", **options) ⇒ Object
Adds the search input
194 195 196 197 198 199 200 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 194 def input(placeholder: "Search...", **) @parts << @view.render( "components/combobox/input", placeholder: placeholder, ** ) end |
#list(**options) { ... } ⇒ Object
Adds the options list container
206 207 208 209 210 211 212 213 214 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 206 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
229 230 231 |
# File 'app/helpers/maquina_components/combobox_helper.rb', line 229 def to_html @view.safe_join(@parts) end |