Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib/ruby_ui/select/select_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,24 @@ def default_attrs
{
role: "option",
tabindex: "0",
class: "item group relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
data_value: @value,
aria_selected: "false",
data_orientation: "vertical",
class: [
"item group relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors",
"focus:bg-accent focus:text-accent-foreground",
"hover:bg-accent hover:text-accent-foreground",
"disabled:pointer-events-none disabled:opacity-50",
"aria-selected:bg-accent aria-selected:text-accent-foreground",
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
"aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed"
],
data: {
controller: "ruby-ui--select-item",
action: "click->ruby-ui--select#selectItem keydown.enter->ruby-ui--select#selectItem keydown.down->ruby-ui--select#handleKeyDown keydown.up->ruby-ui--select#handleKeyUp keydown.esc->ruby-ui--select#handleEsc",
ruby_ui__select_target: "item"
},
data_value: @value,
data_orientation: "vertical",
aria_selected: "false"
}

}
end
end
Expand Down
13 changes: 9 additions & 4 deletions lib/ruby_ui/select/select_trigger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,26 @@ def icon

def default_attrs
{
type: "button",
role: "combobox",
data: {
action: "ruby-ui--select#onClick",
ruby_ui__select_target: "trigger"
},
type: "button",
role: "combobox",
aria: {
controls: "radix-:r0:",
expanded: "false",
autocomplete: "none",
haspopup: "listbox",
activedescendant: true
},
class:
"truncate w-full flex h-9 items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
class: [
"truncate w-full flex h-9 items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background",
"placeholder:text-muted-foreground",
"focus:outline-none focus:ring-1 focus:ring-ring",
"disabled:cursor-not-allowed disabled:opacity-50",
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none"
]
}
end
end
Expand Down