Method: Primer::Alpha::AutoComplete#initialize

Defined in:
app/components/primer/alpha/auto_complete.rb

#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.

Parameters:

  • label_text (String)

    The label of the input.

  • src (String)

    The route to query.

  • input_id (String)

    Id of the input element.

  • input_name (String) (defaults to: nil)

    Optional name of the input element, defaults to ‘input_id` when not set.

  • list_id (String)

    Id of the list element.

  • with_icon (Boolean) (defaults to: false)

    Controls if a search icon is visible, defaults to ‘false`.

  • is_label_visible (Boolean) (defaults to: true)

    Controls if the label is visible. If ‘false`, screen reader only text will be added.

  • is_clearable (Boolean) (defaults to: false)

    Adds optional clear button.

  • is_label_inline (Boolean) (defaults to: false)

    Controls if the label is inline. On smaller screens, label will always become stacked.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>


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