summaryrefslogtreecommitdiff
path: root/frontend/src/lib/components/ui/input/input.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/lib/components/ui/input/input.svelte')
-rw-r--r--frontend/src/lib/components/ui/input/input.svelte48
1 files changed, 48 insertions, 0 deletions
diff --git a/frontend/src/lib/components/ui/input/input.svelte b/frontend/src/lib/components/ui/input/input.svelte
new file mode 100644
index 0000000..549c6b8
--- /dev/null
+++ b/frontend/src/lib/components/ui/input/input.svelte
@@ -0,0 +1,48 @@
+<script lang="ts">
+ import { cn, type WithElementRef } from "$lib/utils.js";
+ import type { HTMLInputAttributes, HTMLInputTypeAttribute } from "svelte/elements";
+
+ type InputType = Exclude<HTMLInputTypeAttribute, "file">;
+
+ type Props = WithElementRef<
+ Omit<HTMLInputAttributes, "type"> &
+ ({ type: "file"; files?: FileList } | { type?: InputType; files?: undefined })
+ >;
+
+ let {
+ ref = $bindable(null),
+ value = $bindable(),
+ type,
+ files = $bindable(),
+ class: className,
+ "data-slot": dataSlot = "input",
+ ...restProps
+ }: Props = $props();
+</script>
+
+{#if type === "file"}
+ <input
+ bind:this={ref}
+ data-slot={dataSlot}
+ class={cn(
+ "bg-input/20 dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 h-7 rounded-md border px-2 py-0.5 text-sm transition-colors file:h-6 file:text-xs/relaxed file:font-medium focus-visible:ring-2 aria-invalid:ring-2 md:text-xs/relaxed w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
+ className
+ )}
+ type="file"
+ bind:files
+ bind:value
+ {...restProps}
+ />
+{:else}
+ <input
+ bind:this={ref}
+ data-slot={dataSlot}
+ class={cn(
+ "bg-input/20 dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 h-7 rounded-md border px-2 py-0.5 text-sm transition-colors file:h-6 file:text-xs/relaxed file:font-medium focus-visible:ring-2 aria-invalid:ring-2 md:text-xs/relaxed w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
+ className
+ )}
+ {type}
+ bind:value
+ {...restProps}
+ />
+{/if}