Class: PhlexKit::ComboboxRadio

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

Overview

Single-select input inside a PhlexKit::ComboboxItem — selecting one closes the popover. Also wired as a phlex-kit--form-field input so live validation works when the combobox sits inside a PhlexKit::FormField. See combobox.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ ComboboxRadio

Returns a new instance of ComboboxRadio.



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

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

Instance Method Details

#view_templateObject



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

def view_template
  input(**mix({
    type: :radio,
    # The option label is the interactive surface (ARIA option); the real
    # input must not be a second tab stop inside it.
    tabindex: "-1",
    class: "pk-combobox-radio",
    data: {
      phlex_kit__combobox_target: "input",
      phlex_kit__form_field_target: "input",
      action: [
        "phlex-kit--combobox#inputChanged",
        "input->phlex-kit--form-field#onInput",
        "invalid->phlex-kit--form-field#onInvalid"
      ].join(" ")
    }
  }, @attrs))
end