mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-04-07 12:20:22 +00:00
49 lines
2.1 KiB
Svelte
49 lines
2.1 KiB
Svelte
<script lang="ts">
|
|
import type { HTMLInputAttributes, HTMLInputTypeAttribute } from "svelte/elements";
|
|
import { cn, type WithElementRef } from "$lib/utils.js";
|
|
|
|
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(
|
|
"dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:ring-3 aria-invalid:ring-3 md:text-sm file:text-foreground placeholder:text-muted-foreground w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent 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(
|
|
"dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 h-8 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:ring-3 aria-invalid:ring-3 md:text-sm file:text-foreground placeholder:text-muted-foreground w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
className
|
|
)}
|
|
{type}
|
|
bind:value
|
|
{...restProps}
|
|
/>
|
|
{/if}
|