Class: PhlexKit::ComboboxItem

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

Overview

One option row — a

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ ComboboxItem

Returns a new instance of ComboboxItem.



9
10
11
# File 'app/components/phlex_kit/combobox/combobox_item.rb', line 9

def initialize(**attrs)
  @attrs = attrs
end

Instance Method Details

#view_templateObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/components/phlex_kit/combobox/combobox_item.rb', line 13

def view_template(&)
  base = {
    class: "pk-combobox-item",
    data: { phlex_kit__combobox_target: "item" }
  }
  # Defaults only when the caller didn't supply their own — `mix` fuses
  # (a server-rendered initially-selected option sets its own selected).
  base[:role] = "option" unless attr_set?(:role)
  base[:aria] = { selected: "false" } unless aria_key_set?(:selected)
  label(**mix(base, @attrs), &)
end