<script lang="ts">
  import { cn, type WithElementRef } from '$lib/utils/cn.svelte.js';
  import type { HTMLInputAttributes } from 'svelte/elements';

  type InputProps = WithElementRef<
    Omit<HTMLInputAttributes, 'value'> & {
      value?: string | number | null;
      files?: FileList | null;
    }
  >;

  let {
    ref = $bindable(null),
    value = $bindable(),
    type,
    class: className,
    ...restProps
  }: InputProps = $props();
</script>

<input
  bind:this={ref}
  bind:value
  data-slot="input"
  {type}
  class={cn(
    'border-input bg-background ring-offset-background placeholder:text-muted-foreground aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-sm shadow-xs outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
    'file:text-foreground file:inline-flex file:border-0 file:bg-transparent file:text-sm file:font-medium',
    className
  )}
  {...restProps}
/>