import type { Component } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";
import { tv, type VariantProps } from "tailwind-variants";
export interface SelectOption {
value: string;
label?: string;
hint?: string;
group?: string;
disabled?: boolean;
separator?: boolean;
icon?: Component<SvelteHTMLElements["svg"]>;
}
export type SelectAlign = "left" | "right";
export const selectField = tv({
slots: {
box: "w-full rounded-md bg-background-default edge-ring-inset transition-colors focus-visible:outline-none disabled:cursor-not-allowed",
chevron: "shrink-0 text-foreground-subtle"
},
variants: {
error: {
false: {
box: "text-foreground-default focus-visible:ring-1 focus-visible:ring-border-focus focus-visible:inset-ring-border-focus aria-expanded:ring-1 aria-expanded:ring-border-focus aria-expanded:inset-ring-border-focus"
},
true: {
box: "bg-background-danger-subtle text-foreground-danger inset-ring-border-danger focus-visible:ring-1 focus-visible:ring-border-focus-danger focus-visible:inset-ring-border-focus-danger aria-expanded:ring-1 aria-expanded:ring-border-focus-danger aria-expanded:inset-ring-border-focus-danger",
chevron: "text-foreground-danger"
}
},
disabled: {
false: {},
true: {
box: "text-foreground-disabled",
chevron: "text-foreground-disabled"
}
}
},
compoundVariants: [
{
error: true,
disabled: true,
class: {
box: "bg-background-danger-subtle text-foreground-danger-subtle inset-ring-border-danger-subtle",
chevron: "text-foreground-danger-subtle"
}
}
],
defaultVariants: {
error: false,
disabled: false
}
});
export type SelectFieldVariants = VariantProps<typeof selectField>;