-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathselect2_component.html.erb
66 lines (65 loc) · 2.01 KB
/
select2_component.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<div
class="
inline-flex items-center px-3 py-2.5 text-sm text-slate-600 bg-slate-200 border
border-r-0 border-slate-300 rounded-l-lg dark:bg-slate-600 dark:text-slate-400
dark:border-slate-600
"
>
<%= root_url %>
</div>
<div class="flex-1">
<div data-action="keyup->viral--select2#keydown" class="select2">
<label for="select2-input" class="sr-only"><%= name %></label>
<input
type="text"
id="select2-input"
data-action="
focus->viral--select2#focus
keydown.enter->viral--select2#keyboardQuery
input->viral--select2#validateInput
"
data-viral--select2-target="input"
placeholder="<%= placeholder %>"
required="<%= required %>"
autocomplete="off"
class="
border-slate-300 text-slate-800 sm:text-sm rounded-r-md !rounded-l-none
focus:ring-primary-500 focus:border-primary-500 block w-full p-2.5
dark:bg-slate-800 dark:border-slate-600 dark:placeholder-slate-400
dark:text-slate-50 dark:focus:ring-primary-500 dark:focus:border-primary-500
"
value="<%= selected_value %>"
>
<%= form.hidden_field name, data: { "viral--select2-target": "hidden" } %>
<div
data-viral--select2-target="dropdown"
class="
z-10 hidden w-full bg-white divide-y rounded-lg shadow divide-slate-100
dark:bg-slate-700
"
>
<ul
data-viral--select2-target="scroller"
class="
max-h-[300px] w-full py-2 overflow-y-auto divide-y divide-slate-200
dark:divide-slate-800
"
>
<% options.each do |option| %>
<%= option %>
<% end %>
<% if empty_state? %>
<li
class="
hidden p-4 text-blue-800 border border-blue-300 bg-blue-50 dark:bg-slate-800
dark:text-blue-400 dark:border-blue-800
"
data-viral--select2-target="empty"
>
<%= empty_state %>
</li>
<% end %>
</ul>
</div>
</div>
</div>