Class: Primer::Alpha::AutoComplete
- Defined in:
- app/components/primer/alpha/auto_complete.rb,
app/components/primer/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
Constants included from Primer::AttributesHelper
Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES
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
Methods included from Primer::AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
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.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/components/primer/alpha/auto_complete.rb', line 75 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
91 92 93 94 |
# File 'app/components/primer/alpha/auto_complete.rb', line 91 def before_render with_results(classes: "") unless results? with_input(classes: "") unless input? end |