@loadsmart/miranda-wc
Version:
Miranda Web Components component library
30 lines (29 loc) • 894 B
TypeScript
/**
* Represents an option within the custom select.
*/
export type Option = {
/** The displayed text for the option. */
label: string;
/** The value associated with the option. */
value: string;
/** Leading element for this option */
leading: Element | null;
/** Trailing element for this option */
trailing: Element | null;
};
/**
* A data source for the custom select.
*/
export type DataSource = {
/** The type of data source ('static' | 'async'). */
type: 'static' | 'async';
/** The current list of options. */
options?: Option[];
/** A function to search for options (synchronous or asynchronous). */
search: (searchTerm: string) => Option[] | Promise<Option[]>;
/**
* Given a value, returns the respective label, or `null`, if the value
* was not found.
*/
resolve: (value: string) => Option | null;
};