Class: PhlexKit::CommandList

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/command/command_list.rb

Overview

Container for CommandGroups, with dividers between them. Carries the listbox role and an id the controller points the input's aria-controls at (and derives result ids from, for aria-activedescendant). See command.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(id: nil, **attrs) ⇒ CommandList

id: is a named kwarg (not left in **attrs) because mix would merge a caller id with the generated one into an invalid two-token id, breaking aria-controls (the documented list_id: wiring) and derived result ids.



9
10
11
12
# File 'app/components/phlex_kit/command/command_list.rb', line 9

def initialize(id: nil, **attrs)
  @id = id || "pk-command-list-#{SecureRandom.hex(4)}"
  @attrs = attrs
end

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
21
# File 'app/components/phlex_kit/command/command_list.rb', line 14

def view_template(&)
  div(**mix({
    id: @id,
    class: "pk-command-list",
    role: "listbox",
    data: { phlex_kit__command_target: "list" }
  }, @attrs), &)
end