Class: Primer::AutoComplete
- Defined in:
- app/components/primer/auto_complete.rb,
app/components/primer/auto_complete/item.rb
Overview
Use AutoComplete to populate input values from server search results.
Defined Under Namespace
Classes: Item
Constant Summary collapse
- DEFAULT_INPUT_TYPE =
:text- INPUT_TYPE_OPTIONS =
[DEFAULT_INPUT_TYPE, :search].freeze
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 ‘results` without needing to explicitly call it in the view.
-
#initialize(src:, id:, **system_arguments) ⇒ AutoComplete
constructor
A new instance of AutoComplete.
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(src:, id:, **system_arguments) ⇒ AutoComplete
Returns a new instance of AutoComplete.
82 83 84 85 86 87 88 89 |
# File 'app/components/primer/auto_complete.rb', line 82 def initialize(src:, id:, **system_arguments) @id = id @system_arguments = system_arguments @system_arguments[:tag] = "auto-complete" @system_arguments[:src] = src @system_arguments[:for] = id end |
Instance Method Details
#before_render ⇒ Object
add ‘results` without needing to explicitly call it in the view
92 93 94 95 96 |
# File 'app/components/primer/auto_complete.rb', line 92 def before_render raise ArgumentError, "Missing `input` slot" if input.blank? results(classes: "") unless results end |