Class: Yattho::Beta::AutoComplete::Item
- Defined in:
- app/components/yattho/beta/auto_complete/item.rb
Overview
Use ‘AutoCompleteItem` to list results of an auto-completed search.
Constant Summary collapse
- ALLOWED_DESCRIPTION_VARIANTS =
[:inline, :block].freeze
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
-
#description_variant_class ⇒ Object
Description variant class.
-
#initialize(value:, selected: false, disabled: false, description_variant: :block, **system_arguments) ⇒ Item
constructor
A new instance of Item.
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(value:, selected: false, disabled: false, description_variant: :block, **system_arguments) ⇒ Item
Returns a new instance of Item.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/components/yattho/beta/auto_complete/item.rb', line 51 def initialize(value:, selected: false, disabled: false, description_variant: :block, **system_arguments) @description_variant = ALLOWED_DESCRIPTION_VARIANTS.include?(description_variant) ? description_variant : :block @system_arguments = deny_tag_argument(**system_arguments) @system_arguments[:tag] = :li @system_arguments[:role] = :option @system_arguments[:'data-autocomplete-value'] = value @system_arguments[:'aria-selected'] = true if selected @system_arguments[:'aria-disabled'] = true if disabled @system_arguments[:classes] = class_names( "ActionList-item", system_arguments[:classes] ) end |
Instance Method Details
#description_variant_class ⇒ Object
Description variant class.
69 70 71 72 73 74 75 76 |
# File 'app/components/yattho/beta/auto_complete/item.rb', line 69 def description_variant_class case @description_variant when :block "ActionList-item-blockDescription" when :inline "ActionList-item-descriptionWrap--inline" end end |