import type { VNode } from 'vue'; import type { ListboxRootEmits, ListboxRootProps } from 'reka-ui'; import type { AppConfig } from '@nuxt/schema'; import theme from '#build/b24ui/listbox'; import type { AvatarProps } from './Avatar.vue'; import type { ChipProps } from './Chip.vue'; import type { IconComponent } from '../types/icons'; import type { InputProps } from './Input.vue'; import type { ModelModifiers, ApplyModifiers } from '../types/input'; import type { ArrayOrNested, GetItemKeys, GetModelValue, NestedItem } from '../types/utils'; import type { ComponentConfig } from '../types/tv'; type Listbox = ComponentConfig; export interface ListboxItem { label?: string; description?: string; /** * @IconComponent */ icon?: IconComponent; avatar?: AvatarProps; chip?: ChipProps; /** * The item type. * @defaultValue 'item' */ type?: 'label' | 'separator' | 'item'; disabled?: boolean; onSelect?: (e: Event) => void; class?: any; b24ui?: Pick; [key: string]: any; } export interface ListboxProps = ArrayOrNested, VK extends GetItemKeys | undefined = undefined, M extends boolean = false, Mod extends Omit = Omit> extends Pick { id?: string; /** * The element or component this component should render as. * @defaultValue 'div' */ as?: any; /** * @defaultValue 'air-primary' */ color?: Listbox['variants']['color']; /** * @defaultValue 'md' */ size?: Listbox['variants']['size']; /** * The items to display in the list. */ items?: T; /** * The controlled value of the Listbox. Can be bound with `v-model`. */ modelValue?: ApplyModifiers, Mod>; modelModifiers?: Mod; /** * The default value when not controlled. */ defaultValue?: ApplyModifiers, Mod>; /** * Whether multiple items can be selected. * @defaultValue false */ multiple?: M & boolean; /** * When `items` is an array of objects, select the field to use as the value instead of the object itself. * @defaultValue undefined */ valueKey?: VK; /** * The key used to get the label from the item. * @defaultValue 'label' */ labelKey?: GetItemKeys; /** * The key used to get the description from the item. * @defaultValue 'description' */ descriptionKey?: GetItemKeys; /** * Whether the list is in a loading state. */ loading?: boolean; /** * The icon displayed when loading. * @defaultValue icons.loading * @IconComponent */ loadingIcon?: IconComponent; /** * Whether to display a filter input or not. * Can be an object to pass additional props to the input. * `{ placeholder: 'Search...', variant: 'none' }`{lang="ts-type"} * @defaultValue false */ filter?: boolean | Omit; /** * The fields to filter by. * @defaultValue [labelKey] */ filterFields?: string[]; /** * When `true`, disable the default filters, useful for custom filtering (useAsyncData, useFetch, etc.). * @defaultValue false */ ignoreFilter?: boolean; /** * The icon displayed when an item is selected. * @defaultValue icons.check * @IconComponent */ selectedIcon?: IconComponent; /** * Enable virtualization for large lists. * @defaultValue false */ virtualize?: boolean | { /** * Number of items rendered outside the visible area * @defaultValue 12 */ overscan?: number; /** * Estimated size (in px) of each item, or a function that returns the size for a given index * @defaultValue 32 */ estimateSize?: number | ((index: number) => number); }; /** Highlight the ring color like a focus state. */ highlight?: boolean; autofocus?: boolean; autofocusDelay?: number; class?: any; b24ui?: Listbox['slots']; } export type ListboxEmits = ArrayOrNested, VK extends GetItemKeys | undefined = undefined, M extends boolean = false, Mod extends Omit = Omit> = Pick & { 'change': [event: Event]; 'update:modelValue': [value: ApplyModifiers, Mod>]; }; type SlotProps = (props: { item: T; index: number; b24ui: Listbox['b24ui']; }) => VNode[]; export type ListboxSlots = ArrayOrNested> = { 'loading'?(props?: {}): VNode[]; 'empty'?(props: { searchTerm: string; }): VNode[]; 'item'?: SlotProps>; 'item-leading'?: SlotProps>; 'item-label'?(props: { item: NestedItem; index: number; }): VNode[]; 'item-description'?(props: { item: NestedItem; index: number; }): VNode[]; 'item-trailing'?: SlotProps>; }; declare const _default: typeof __VLS_export; export default _default; declare const __VLS_export: , VK extends GetItemKeys | undefined = undefined, M extends boolean = false, Mod extends Omit = Omit>(__VLS_props: NonNullable>["props"], __VLS_ctx?: __VLS_PrettifyLocal>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable>["expose"], __VLS_setup?: Promise<{ props: import("vue").PublicProps & __VLS_PrettifyLocal<(ListboxProps & { searchTerm?: string; }) & { onChange?: ((event: Event) => any) | undefined; "onUpdate:modelValue"?: ((value: Mod extends { number: true; } ? (Mod extends { optional: true; } ? (Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) | undefined : Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) extends infer T_1 ? T_1 extends (Mod extends { optional: true; } ? (Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) | undefined : Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) ? T_1 extends string ? number | T_1 : T_1 : never : never : Mod extends { optional: true; } ? (Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) | undefined : Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) => any) | undefined; onHighlight?: ((payload: { ref: HTMLElement; value: import("reka-ui").AcceptableValue; } | undefined) => any) | undefined; onEntryFocus?: ((event: CustomEvent) => any) | undefined; onLeave?: ((event: Event) => any) | undefined; "onUpdate:searchTerm"?: ((value: string) => any) | undefined; }> & (typeof globalThis extends { __VLS_PROPS_FALLBACK: infer P; } ? P : {}); expose: (exposed: {}) => void; attrs: any; slots: ListboxSlots; emit: (((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: Mod extends { number: true; } ? (Mod extends { optional: true; } ? (Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) | undefined : Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) extends infer T_1 ? T_1 extends (Mod extends { optional: true; } ? (Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) | undefined : Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) ? T_1 extends string ? number | T_1 : T_1 : never : never : Mod extends { optional: true; } ? (Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) | undefined : Mod extends { nullable: true; } ? GetModelValue | null : GetModelValue) => void) & ((evt: "highlight", payload: { ref: HTMLElement; value: import("reka-ui").AcceptableValue; } | undefined) => void) & ((evt: "entryFocus", event: CustomEvent) => void) & ((evt: "leave", event: Event) => void)) & ((event: "update:searchTerm", value: string) => void); }>) => import("vue").VNode & { __ctx?: NonNullable>; }; type __VLS_PrettifyLocal = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};