Class: Primer::AutoComplete::Input

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/auto_complete.rb

Overview

This component is part of ‘Primer::AutoCompleteComponent` and should not be used as a standalone component.

Constant Summary collapse

DEFAULT_TYPE =
:text
TYPE_OPTIONS =
[DEFAULT_TYPE, :search].freeze

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Instance Method Summary collapse

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(type: DEFAULT_TYPE, **system_arguments) ⇒ Input

Returns a new instance of Input.

Parameters:

  • type (Symbol) (defaults to: DEFAULT_TYPE)

    <%= one_of(Primer::AutoComplete::Input::TYPE_OPTIONS) %>

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'app/components/primer/auto_complete.rb', line 133

def initialize(type: DEFAULT_TYPE, **system_arguments)
  @system_arguments = system_arguments
  @system_arguments[:tag] = :input

  @aria_label = system_arguments[:"aria-label"]
  @aria_labelledby = system_arguments[:"aria-labelledby"] || system_arguments.dig(:aria, :labelledby)

  @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
  @system_arguments[:classes] = class_names(
    "form-control",
    system_arguments[:classes]
  )
end

Instance Method Details

#callObject



151
152
153
# File 'app/components/primer/auto_complete.rb', line 151

def call
  render(Primer::BaseComponent.new(**@system_arguments))
end

#missing_label?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'app/components/primer/auto_complete.rb', line 147

def missing_label?
  @aria_label.blank? && @aria_labelledby.blank?
end