Class: PhlexKit::SelectContent

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/select/select_content.rb

Overview

The dropdown panel for PhlexKit::Select — a native [popover=manual] the controller toggles, anchor-positioned to the trigger with viewport-edge flipping (select.css). Outer div is the positioned/targeted layer; the inner .pk-select-viewport is the bordered, scrollable box. Holds SelectGroup / SelectLabel / SelectItem children. See select.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ SelectContent

Returns a new instance of SelectContent.



8
9
10
11
# File 'app/components/phlex_kit/select/select_content.rb', line 8

def initialize(**attrs)
  @id = "pk-select-content-#{SecureRandom.hex(4)}"
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



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

def view_template(&block)
  div(**mix({
    id: @id,
    role: "listbox",
    tabindex: "-1",
    class: "pk-select-content",
    popover: "manual",
    data: { phlex_kit__select_target: "content" }
  }, @attrs)) do
    div(class: "pk-select-viewport", &block)
  end
end