Class: Cmdk::Item
Overview
Command menu item. Port of ‘<Command.Item>` from cmdk.
Like the React version, ‘value` is inferred from the rendered text content when not given (the runtime assigns `data-value` at init). `onSelect` becomes a bubbling `cmdk-item-select` CustomEvent with `detail.value`. `href:` is a Turbo-friendly extension: the runtime visits the URL on select.
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#initialize(value: nil, keywords: nil, disabled: false, force_mount: false, href: nil, scope: nil, scope_only: false, enters_scope: nil, server_filtered: false, hint: nil, kbd: nil, **attributes) ⇒ Item
constructor
A new instance of Item.
- #view_template(&block) ⇒ Object
Constructor Details
#initialize(value: nil, keywords: nil, disabled: false, force_mount: false, href: nil, scope: nil, scope_only: false, enters_scope: nil, server_filtered: false, hint: nil, kbd: nil, **attributes) ⇒ Item
Returns a new instance of Item.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cmdk/item.rb', line 9 def initialize(value: nil, keywords: nil, disabled: false, force_mount: false, href: nil, scope: nil, scope_only: false, enters_scope: nil, server_filtered: false, hint: nil, kbd: nil, **attributes) @value = value @keywords = keywords @disabled = disabled @force_mount = force_mount @href = href @scope = scope @scope_only = scope_only @enters_scope = enters_scope @server_filtered = server_filtered @hint = hint @kbd = kbd @attributes = attributes end |
Instance Method Details
#view_template(&block) ⇒ Object
26 27 28 |
# File 'lib/cmdk/item.rb', line 26 def view_template(&block) div(**merged(item_attributes, @attributes), &block) end |