Class: Impulse::Autocomplete::OptionComponent
- Inherits:
-
Impulse::ApplicationComponent
- Object
- ViewComponent::Base
- Impulse::ApplicationComponent
- Impulse::Autocomplete::OptionComponent
- Defined in:
- app/components/impulse/autocomplete/option_component.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#system_args ⇒ Object
readonly
Returns the value of attribute system_args.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value:, text:, description: nil, **system_args) ⇒ OptionComponent
constructor
A new instance of OptionComponent.
Methods inherited from Impulse::ApplicationComponent
Methods included from Helpers::AttributesHelper
Constructor Details
#initialize(value:, text:, description: nil, **system_args) ⇒ OptionComponent
Returns a new instance of OptionComponent.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/components/impulse/autocomplete/option_component.rb', line 6 def initialize(value:, text:, description: nil, **system_args) @value = value @text = text @description = description @text_id = self.class.generate_id @system_args = system_args @system_args[:id] = system_args.fetch(:id, self.class.generate_id) @system_args[:tag] ||= :div @system_args[:role] = :option @system_args[:value] = value @system_args[:tabindex] = "-1" @system_args[:class] = class_names( system_args[:class], "awc-autocomplete-option dropdown-item", disabled: system_args[:disabled] ) @system_args[:"data-text"] = text @system_args[:"aria-selected"] = "false" @system_args[:"aria-labelledby"] = @text_id @system_args[:"aria-disabled"] = (!!system_args[:disabled]).to_s end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'app/components/impulse/autocomplete/option_component.rb', line 4 def description @description end |
#system_args ⇒ Object (readonly)
Returns the value of attribute system_args.
4 5 6 |
# File 'app/components/impulse/autocomplete/option_component.rb', line 4 def system_args @system_args end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
4 5 6 |
# File 'app/components/impulse/autocomplete/option_component.rb', line 4 def text @text end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'app/components/impulse/autocomplete/option_component.rb', line 4 def value @value end |