Skip to content

Commit d29fac6

Browse files
authored
New combobox component (#208)
1 parent d761646 commit d29fac6

19 files changed

+317
-453
lines changed

lib/ruby_ui/combobox/combobox.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
module RubyUI
44
class Combobox < Base
5+
def initialize(term: "items", **)
6+
@term = term
7+
super(**)
8+
end
9+
510
def view_template(&)
611
div(**attrs, &)
712
end
@@ -10,14 +15,11 @@ def view_template(&)
1015

1116
def default_attrs
1217
{
18+
role: "combobox",
1319
data: {
1420
controller: "ruby-ui--combobox",
15-
ruby_ui__combobox_open_value: "false",
16-
action: "click@window->ruby-ui--combobox#onClickOutside",
17-
ruby_ui__combobox_ruby_ui__combobox_content_outlet: ".combobox-content",
18-
ruby_ui__combobox_ruby_ui__combobox_item_outlet: ".combobox-item"
19-
},
20-
class: "group/combobox w-full relative"
21+
ruby_ui__combobox_term_value: @term.to_s
22+
}
2123
}
2224
end
2325
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class ComboboxCheckbox < Base
5+
def view_template
6+
input(type: "checkbox", **attrs)
7+
end
8+
9+
private
10+
11+
def default_attrs
12+
{
13+
class: [
14+
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background accent-primary",
15+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
16+
"disabled:cursor-not-allowed disabled:opacity-50"
17+
],
18+
data: {
19+
ruby_ui__combobox_target: "input",
20+
action: "ruby-ui--combobox#inputChanged"
21+
}
22+
}
23+
end
24+
end
25+
end

lib/ruby_ui/combobox/combobox_content.rb

Lines changed: 0 additions & 31 deletions
This file was deleted.

lib/ruby_ui/combobox/combobox_content_controller.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)