-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathinput.rb
More file actions
34 lines (30 loc) · 1.1 KB
/
input.rb
File metadata and controls
34 lines (30 loc) · 1.1 KB
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
# frozen_string_literal: true
module RubyUI
class Input < Base
def initialize(type: :string, **attrs)
@type = type.to_sym
super(**attrs)
end
def view_template
input(type: @type, **attrs)
end
private
def default_attrs
{
data: {
ruby_ui__form_field_target: "input",
action: "input->ruby-ui--form-field#onInput invalid->ruby-ui--form-field#onInvalid"
},
class: [
"flex h-9 w-full rounded-md border bg-background px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] border-border ring-0 ring-ring/0",
"placeholder:text-muted-foreground",
"disabled:cursor-not-allowed disabled:opacity-50",
"file:border-0 file:bg-transparent file:text-sm file:font-medium",
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none",
"focus-visible:outline-none focus-visible:ring-ring/50 focus-visible:ring-2 focus-visible:border-ring focus-visible:shadow-sm",
(@type.to_s == "file") ? "pt-[7px]" : ""
]
}
end
end
end