Class: Autocomplete::OptionComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/polaris/autocomplete/option_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(label:, multiple: false, **system_arguments) ⇒ OptionComponent

Returns a new instance of OptionComponent.



6
7
8
9
10
11
12
13
14
# File 'app/components/polaris/autocomplete/option_component.rb', line 6

def initialize(
  label:,
  multiple: false,
  **system_arguments
)
  @label = label
  @multiple = multiple
  @system_arguments = system_arguments
end

Instance Method Details

#system_argumentsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/components/polaris/autocomplete/option_component.rb', line 16

def system_arguments
  @system_arguments.tap do |args|
    args[:label] = @label

    args[:wrapper_arguments] ||= {}
    args[:wrapper_arguments][:data] ||= {}
    args[:wrapper_arguments][:data][:polaris_autocomplete_target] = "option"
    args[:wrapper_arguments][:data][:label] = @label

    args[:data] ||= {}
    prepend_option(args[:data], :action, "polaris-autocomplete#select")
  end
end