first commit
This commit is contained in:
commit
e687b4437b
418 files changed
+33577
No files matched your search
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import { cn } from '@/lib/utils';
|
||||
import { getInputOTPContext } from './context';
|
||||
|
||||
let {
|
||||
index,
|
||||
class: className = '',
|
||||
}: {
|
||||
index: number;
|
||||
class?: string;
|
||||
} = $props();
|
||||
|
||||
const ctx = getInputOTPContext();
|
||||
|
||||
const char = $derived(ctx.value()[index]);
|
||||
const isActive = $derived(ctx.isFocused() && ctx.activeIndex() === index);
|
||||
const hasFakeCaret = $derived(isActive && !char);
|
||||
</script>
|
||||
|
||||
<div
|
||||
data-slot="input-otp-slot"
|
||||
data-active={isActive}
|
||||
class={cn(
|
||||
'data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{char ?? ''}
|
||||
{#if hasFakeCaret}
|
||||
<div class="pointer-events-none absolute inset-0 flex items-center justify-center">
|
||||
<div class="animate-caret-blink bg-foreground h-4 w-px duration-1000"></div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
Reference in new issue
Block a user