import type { Snippet } from 'svelte'; import type { HTMLAttributes } from 'svelte/elements'; import type { MintProp } from '../../mint/index.js'; import type { SelectSlots, SelectVariants } from './select.variants.js'; /** * Primitive value types accepted by Select / Combobox options. * Strings are the default; numbers and booleans cover form fields * bound to numeric IDs or yes/no flags without forcing the consumer * to convert back and forth at every call site. */ export type SelectValue = string | number | boolean; /** A single select option. */ export interface SelectOption { label: string; value: T; disabled?: boolean; } /** A labelled group of options. */ export interface SelectGroup { label: string; options: SelectOption[]; } /** * Configuration for an explicit "no value" option rendered at the top of the listbox. * Selecting it sets `value` to `null` and fires `onValueChange(null)`. * * Pass a string to use it as the label, or an object for additional control: * `nullOption="No selection"` * `nullOption={{ label: 'Leave unassigned' }}` */ export interface NullOptionConfig { /** Label shown both in the listbox row and the trigger when `value` is `null`. */ label: string; /** Disables selection of the null option (rare, but allowed for symmetry). */ disabled?: boolean; } /** * @description Form-focused listbox with label, validation, keyboard navigation, and optional * multi-select. Single-select by default; pass `multiple` for an array-bound multi-select. * Custom render hooks (`customTrigger`, `customTriggerContent`, `customItem`) cover advanced * UI like icon-only triggers, badge-counter chrome, or complex per-option layouts. * * @tag form * @related Combobox * @related Menu * @related Input * * @example Single-select with form integration * ```svelte * ({ label: t.name, value: t.id }))} * bind:value={tenantId} * /> * ``` * * @example Multi-select with checkboxes * ```svelte * * {#snippet customTrigger(selected, isOpen, clear)} * * {/snippet} * * ``` * * @example Grouped options * ```svelte * ` * binds to `T[]`, `