import { type LLSelectWidthPolicy } from './positioning.js'; import type { LLSelectUiTranslationPack } from './i18n.js'; /** * What happens when the user clicks outside an open popup. * * - `'pass-through'` (default): close the popup; the outside click still * triggers its normal action (button click, link navigation, etc.). * - `'block'`: close the popup only; the outside click is swallowed so no * underlying handler or default action fires. Avoids accidental side * effects when the user only intended to dismiss the dropdown. * @group Settings * @category Base */ export type LLSelectOutsideClickBehavior = 'pass-through' | 'block'; /** * Who initiated a chosen-state change, delivered to `onChange` as * `meta.source`. * - `'user'`: a pointer or keyboard interaction inside the widget - an * option toggle, a tag's remove button, the clear button, the choose-all * row. * - `'api'`: any programmatic call - `setChosenItem` / `setChosenItems`, * `toggleItem`, the `choose*` bulk ops, `setItems` reconciliation. * @group Events */ export type LLSelectChangeSource = 'user' | 'api'; /** * Extra facts about one `onChange` firing, as the callback's third argument. * An object on purpose: future fields can be added without breaking the * callback signature. * @group Events */ export interface LLSelectChangeMeta { source: LLSelectChangeSource; } /** * Resolved (defaults applied) settings shared by all select variants. * Subclasses (`LLSelectSingle`, `LLSelectMultiple`) extend this with their * mode-specific options such as `onChange`. * * Settings are frozen after the constructor. What still changes at runtime: * - State changes by method, and never was a setting: the items * (`setItems`), the chosen value (`setChosenItem` / `setChosenItems`), * `disabled` (`setDisabled`). * - Two settings have a setter, because they are text: `uiTranslationPack` * (`setUiTranslationPack`) and `placeholder` (`setPlaceholder`). * - Every other setting is fixed for the instance's lifetime. * - To change a fixed setting, build a new instance. One build takes about * 0.2 ms. * - If a setting must vary at runtime, use its function form where one * exists. `filterable: (items) => boolean` is re-evaluated on every open * (and consulted by closed-state typeahead - see the setting). * @group Settings * @category Base */ export interface LLSelectBaseSettings { /** * Prefix used for every CSS class and DOM id the library generates * (default `'llselect'`). NOTE: the shipped themes target the default * prefix only - a custom prefix means bringing your own CSS. Reference the * resolved names via `instance.classIdMap` instead of hardcoding strings. * @group CSS */ cssClassPrefix: string; /** * Text shown in the trigger when nothing is selected. App copy: an explicit * value always wins; when unset, the locale default * `uiTranslationPack.triggerPlaceholder` is used (`'Please select'` in English). * @group Trigger */ placeholder: string; /** * Accessible name of the field, like the `