/**
 * Configuration for a single dropdown item.
 */
export type DropdownSourceItem = {
	/**
	 * Descriptive label associated with the item.
	 */
	label: string;
	/**
	 * Unique identifier for the item, included as detail in the `vegaDropdownClick` event upon user click.
	 */
	key: string;
	/**
	 * The number displayed in a count badge associated with the item.
	 */
	count?: number;
	/**
	 * Icon design token selected from available options or a Font Awesome class representing the item.
	 */
	prefixIcon?: string;
	/**
	 * Disables the item, preventing user selection.
	 */
	disabled?: boolean;
	/**
	 * Display the label to red.
	 */
	danger?: boolean;
};

/**
 * Configuration for a dropdown item group.
 */
export type DropdownSourceGroup = {
	/**
	 * Descriptive label associated with the item.
	 */
	label: string;
	/**
	 * Unique identifier for the item, included as detail in the `vegaDropdownClick` event upon user click.
	 */
	key: string;
	/**
	 * If the item has children, it is treated as a group.
	 */
	children: DropdownSourceItem[];
};

/**
 * Payload delivered to observers monitoring dropdown item selections.
 */
export type VegaDropdownItemSelectionObserverPayload = {
	/**
	 * Reference to the dropdown item host element.
	 */
	host: HTMLVegaDropdownItemElement;
	/**
	 * Selected item's key value.
	 */
	itemKey: string;
};

/**
 * Defines the user interaction that triggers a dropdown search.
 */
export type VegaDropdownSearchTriggerByType = 'input' | 'enter';

/**
 * Source item union used by the dropdown component (single item or group).
 */
export type VegaDropdownSourceItem = DropdownSourceItem | DropdownSourceGroup;

/**
 * Detail object for search-trigger events in the dropdown.
 */
export type VegaDropdownSearchTriggerEventDetail = {
	/**
	 * The user interaction that triggered the search.
	 */
	searchBy: VegaDropdownSearchTriggerByType;
	/**
	 * The search input value.
	 */
	value: string;
};
