Class: PhlexKit::ComboboxSearchInput

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/combobox/combobox_search_input.rb

Overview

Filter input at the top of a PhlexKit::ComboboxPopover (magnifier icon + borderless search field). Filtering happens client-side against each item's text (or data-text). See combobox.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(placeholder:, **attrs) ⇒ ComboboxSearchInput

Returns a new instance of ComboboxSearchInput.



6
7
8
9
# File 'app/components/phlex_kit/combobox/combobox_search_input.rb', line 6

def initialize(placeholder:, **attrs)
  @placeholder = placeholder
  @attrs = attrs
end

Instance Method Details

#view_templateObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/components/phlex_kit/combobox/combobox_search_input.rb', line 11

def view_template
  div(class: "pk-combobox-search") do
    icon
    input(**mix({
      type: :search,
      role: "searchbox",
      autocorrect: "off",
      autocomplete: "off",
      spellcheck: "false",
      placeholder: @placeholder,
      class: "pk-combobox-search-input",
      data: {
        phlex_kit__combobox_target: "searchInput",
        action: "keyup->phlex-kit--combobox#filterItems search->phlex-kit--combobox#filterItems"
      }
    }, @attrs))
  end
end