Class: Yattho::Alpha::AutoComplete
- Defined in:
- app/components/yattho/alpha/auto_complete.rb,
app/components/yattho/alpha/auto_complete/item.rb
Overview
Use ‘AutoComplete` to provide a user with a list of selectable suggestions that appear when they type into the input field. This list is populated by server search results.
Defined Under Namespace
Classes: Item
Constant Summary
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
-
#before_render ⇒ Object
add ‘input` and `results` without needing to explicitly call them in the view.
-
#initialize(label_text:, src:, list_id:, input_id:, input_name: nil, is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false, **system_arguments) ⇒ AutoComplete
constructor
A new instance of AutoComplete.
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Constructor Details
#initialize(label_text:, src:, list_id:, input_id:, input_name: nil, is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false, **system_arguments) ⇒ AutoComplete
Returns a new instance of AutoComplete.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'app/components/yattho/alpha/auto_complete.rb', line 122 def initialize(label_text:, src:, list_id:, input_id:, input_name: nil, is_label_visible: true, is_label_inline: false, with_icon: false, is_clearable: false, **system_arguments) @label_text = label_text @list_id = list_id @input_id = input_id @input_name = input_name || input_id @is_label_visible = is_label_visible @with_icon = with_icon @is_clearable = is_clearable @label_classes = label_classes(is_label_visible: is_label_visible, is_label_inline: is_label_inline) @system_arguments = deny_tag_argument(**system_arguments) @system_arguments[:tag] = "auto-complete" @system_arguments[:src] = src @system_arguments[:for] = list_id end |
Instance Method Details
#before_render ⇒ Object
add ‘input` and `results` without needing to explicitly call them in the view
139 140 141 142 |
# File 'app/components/yattho/alpha/auto_complete.rb', line 139 def before_render with_results(classes: "") unless results? with_input(classes: "") unless input? end |