forked from ruby-ui/web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.rb
More file actions
33 lines (29 loc) · 989 Bytes
/
input.rb
File metadata and controls
33 lines (29 loc) · 989 Bytes
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
# 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-sm transition-colors border-border",
"placeholder:text-muted-foreground",
"disabled:cursor-not-allowed disabled:opacity-50",
"file:border-0 file:bg-transparent file:text-sm file:font-medium",
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
"aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:pointer-events-none"
]
}
end
end
end