Class: PhlexKit::Command
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::Command
- Defined in:
- app/components/phlex_kit/command/command.rb
Overview
Command palette, ported from ruby_ui's RubyUI::Command. The palette body:
CommandInput + CommandList(CommandGroup > CommandItem) + CommandEmpty.
Normally composed inside CommandDialog/CommandDialogContent, whose cloned
wrapper carries the phlex-kit--command controller (matching ruby_ui); for an
inline palette add data: { controller: "phlex-kit--command" } yourself.
Upstream's fuse.js fuzzy search is replaced with a dependency-free substring
match in the controller. Tailwind → vanilla .pk-command* (command.css).
Constant Summary collapse
- DEFAULT_RESULTS_FORMAT =
Announcement templates for the live region — the only strings the controller writes itself (CommandEmpty is server-rendered, so it localizes with the rest of your markup). %count is interpolated.
"%{count} result(s)"- DEFAULT_NO_RESULTS_TEXT =
"No results"
Instance Method Summary collapse
-
#initialize(results_format: DEFAULT_RESULTS_FORMAT, no_results_text: DEFAULT_NO_RESULTS_TEXT, **attrs) ⇒ Command
constructor
A new instance of Command.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(results_format: DEFAULT_RESULTS_FORMAT, no_results_text: DEFAULT_NO_RESULTS_TEXT, **attrs) ⇒ Command
Returns a new instance of Command.
16 17 18 19 20 |
# File 'app/components/phlex_kit/command/command.rb', line 16 def initialize(results_format: DEFAULT_RESULTS_FORMAT, no_results_text: DEFAULT_NO_RESULTS_TEXT, **attrs) @results_format = results_format @no_results_text = no_results_text @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
22 23 24 25 26 27 |
# File 'app/components/phlex_kit/command/command.rb', line 22 def view_template div(**mix({ class: "pk-command" }, @attrs)) do live_region yield end end |