Class: PhlexKit::ComboboxInputTrigger
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::ComboboxInputTrigger
- Defined in:
- app/components/phlex_kit/combobox/combobox_input_trigger.rb
Overview
Single-field trigger for PhlexKit::Combobox — the input doubles as the filter (autocomplete style): focusing or clicking opens the popover, typing filters, arrows/enter pick, and the chosen option's text becomes the field value. Ported from ruby_ui's RubyUI::ComboboxInputTrigger; upstream shipped the markup without controller support, so the behaviour (open-on-focus, keyboard nav from the field, selection reflection) is PhlexKit's completion of it. Keyboard actions live here because focus stays in this field — the popover's own bindings only fire for the button+search layout. See combobox.rb.
Instance Method Summary collapse
-
#initialize(placeholder: "", disabled: false, invalid: false, **attrs) ⇒ ComboboxInputTrigger
constructor
A new instance of ComboboxInputTrigger.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(placeholder: "", disabled: false, invalid: false, **attrs) ⇒ ComboboxInputTrigger
Returns a new instance of ComboboxInputTrigger.
12 13 14 15 16 17 |
# File 'app/components/phlex_kit/combobox/combobox_input_trigger.rb', line 12 def initialize(placeholder: "", disabled: false, invalid: false, **attrs) @placeholder = placeholder @disabled = disabled @invalid = invalid @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/components/phlex_kit/combobox/combobox_input_trigger.rb', line 19 def view_template wrapper_aria = { haspopup: "listbox", expanded: "false" } wrapper_aria[:invalid] = "true" if @invalid div(**mix({ class: "pk-combobox-input-trigger", aria: wrapper_aria, data: { placeholder: @placeholder, phlex_kit__combobox_target: "trigger", action: [ "click->phlex-kit--combobox#openPopover", "focusin->phlex-kit--combobox#openPopover", "keydown.down->phlex-kit--combobox#keyDownPressed", "keydown.up->phlex-kit--combobox#keyUpPressed", "keydown.enter->phlex-kit--combobox#keyEnterPressed", "keydown.esc->phlex-kit--combobox#closePopover:prevent" ].join(" ") } }, @attrs)) do input( type: :text, placeholder: @placeholder, disabled: @disabled, autocomplete: "off", autocorrect: "off", spellcheck: "false", class: "pk-combobox-input-trigger-field", data: { phlex_kit__combobox_target: "inputTrigger", action: "keyup->phlex-kit--combobox#filterItems input->phlex-kit--combobox#filterItems" } ) chevron_icon end end |