Class: Shadcn::InputOtpComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Shadcn::InputOtpComponent
- Defined in:
- app/components/shadcn/input_otp_component.rb
Overview
Input OTP component for one-time password entry Matches shadcn/ui Input OTP component
Defined Under Namespace
Classes: GroupComponent, OtpSeparatorComponent
Constant Summary collapse
- BASE_CLASSES =
"flex items-center gap-2"- SLOT_CLASSES =
"relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm shadow-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md"- SLOT_ACTIVE_CLASSES =
"z-10 ring-1 ring-ring"- CARET_CLASSES =
"pointer-events-none absolute inset-0 flex items-center justify-center"- CARET_BLINK_CLASSES =
"animate-caret-blink h-4 w-px bg-foreground duration-1000"
Instance Attribute Summary
Attributes inherited from BaseComponent
#class_name, #data, #html_options
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(length: 6, name: nil, pattern: nil, disabled: false, required: false, autocomplete: "one-time-code", **options) ⇒ InputOtpComponent
constructor
A new instance of InputOtpComponent.
Methods inherited from BaseComponent
Methods included from Rails::Helpers::ClassNameHelper
Constructor Details
#initialize(length: 6, name: nil, pattern: nil, disabled: false, required: false, autocomplete: "one-time-code", **options) ⇒ InputOtpComponent
Returns a new instance of InputOtpComponent.
42 43 44 45 46 47 48 49 50 |
# File 'app/components/shadcn/input_otp_component.rb', line 42 def initialize(length: 6, name: nil, pattern: nil, disabled: false, required: false, autocomplete: "one-time-code", **) super(**) @length = length @name = name @pattern = pattern @disabled = disabled @required = required @autocomplete = autocomplete end |
Instance Method Details
#call ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'app/components/shadcn/input_otp_component.rb', line 52 def call tag.div(**container_attributes) do safe_join([ hidden_input, groups.any? ? render_with_groups : render_default_slots ]) end end |