Class: Anchor::AutocompleteComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/anchor/autocomplete_component.rb

Constant Summary collapse

COMMON_CLASSES =
%w(
  text-center
  text-gray-500
  hidden
).freeze
LIST_BOX_CLASSES =
%w(
  absolute
  bg-white
  border
  border-gray-300
  max-h-[200px]
  mt-2
  overflow-y-auto
  py-2
  rounded-md
  shadow-lg
  w-full
  z-10
).freeze
UL_CLASSES =
%w(
  group-data-[empty='true']:hidden
  group-data-[loading='true']:hidden
  [&>li]:py-2
  [&>li]:px-3
  [&>li]:cursor-pointer
  [&>[aria-selected='true']]:bg-accent-subdued
).freeze
NO_OPTIONS_CLASSES =
%w(
  group-aria-[expanded][data-empty='true'][data-loading='false']:block
).freeze
LOADING_CLASSES =
%w(
  group-aria-[expanded][data-loading='true']:block
).freeze

Constants included from ViewHelper

ViewHelper::ANCHOR_HELPERS

Instance Method Summary collapse

Methods inherited from Component

generate_id

Methods included from ViewHelper

#anchor_form_with, #anchor_svg, #deep_blank?, #merge_options, #popover_trigger_attributes

Methods included from FetchOrFallbackHelper

#fetch_or_fallback

Constructor Details

#initialize(form_builder:, name:, src:, input_options: {}, list_options: {}, **kwargs) ⇒ AutocompleteComponent

Returns a new instance of AutocompleteComponent.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/components/anchor/autocomplete_component.rb', line 41

def initialize(
  form_builder:,
  name:,
  src:,
  input_options: {},
  list_options: {},
  **kwargs
)
  @form_builder = form_builder
  @name = name
  @input_options = input_options
  @list_options = list_options
  @src = src

  super(**kwargs)
end

Instance Method Details

#list_box_classesObject



58
59
60
# File 'app/components/anchor/autocomplete_component.rb', line 58

def list_box_classes
  LIST_BOX_CLASSES
end