Class: PhlexKit::ComboboxClearButton

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

Overview

× button clearing the whole combobox selection — hidden until something is checked. Ported from ruby_ui's RubyUI::ComboboxClearButton; upstream referenced a clearAll action its controller never defined, so the behaviour is PhlexKit's completion of it. See combobox.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ ComboboxClearButton

Returns a new instance of ComboboxClearButton.



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

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

Instance Method Details

#view_templateObject



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

def view_template
  button(**mix({
    type: :button,
    class: "pk-combobox-clear-button pk-hidden",
    aria: { label: "Clear selection" },
    data: {
      phlex_kit__combobox_target: "clearButton",
      action: "phlex-kit--combobox#clearAll"
    }
  }, @attrs)) do
    render Icon.new(:x, size: 24)
  end
end