Module: UI::CommandItemBehavior

Included in:
CommandItem, CommandItemComponent
Defined in:
app/behaviors/ui/command_item_behavior.rb

Overview

ItemBehavior

Shared behavior for CommandItem component.

Instance Method Summary collapse

Instance Method Details

#command_item_classesObject



20
21
22
23
24
25
26
# File 'app/behaviors/ui/command_item_behavior.rb', line 20

def command_item_classes
  classes_value = respond_to?(:classes, true) ? classes : @classes
  TailwindMerge::Merger.new.merge([
    command_item_base_classes,
    classes_value
  ].compact.join(" "))
end

#command_item_data_attributesObject



28
29
30
31
32
33
34
35
36
37
# File 'app/behaviors/ui/command_item_behavior.rb', line 28

def command_item_data_attributes
  attrs = {
    slot: "command-item",
    ui__command_target: "item",
    action: "click->ui--command#select",
    value: @value || ""
  }
  attrs[:disabled] = "" if @disabled
  attrs
end

#command_item_html_attributesObject



9
10
11
12
13
14
15
16
17
18
# File 'app/behaviors/ui/command_item_behavior.rb', line 9

def command_item_html_attributes
  attrs = {
    class: command_item_classes,
    data: command_item_data_attributes,
    role: "option",
    "aria-selected": "false"
  }
  attrs["aria-disabled"] = "true" if @disabled
  attrs
end