import { GenesisResources } from '@genesislcap/foundation-comms'; import type { Combobox } from '../combobox'; import type { Select } from '../select'; import { BaseDatasource } from '../utils'; /** * Detail payload of the `value-change` event. * @public */ export interface ValueChangeEventDetail { value: any; label: string; } /** * Datasource element for select/combobox option loading. * @public * * @tagname options-datasource * * @fires value-change - Fired when the selected value changes. detail: `ValueChangeEventDetail` */ export declare class OptionsDatasource extends BaseDatasource { resources: GenesisResources; labelField: string; optionElement: string; valueField: string; emptyDataLabel: string; allowCustomOptions: boolean; /** * Enables infinite scrolling. Instead of loading everything upfront, only `page-size` * options are loaded initially and the next page is requested when the user scrolls near * the bottom of the dropdown. REQUEST_SERVER resources page by OFFSET; DATASERVER * resources page via MORE_ROWS on a live stream (total still capped by `maxView`). * * @remarks * When paging REQUEST_SERVER resources by OFFSET, set a stable `order-by` — without one * the server has no other guaranteed ordering between requests, so rows can shift across * pages (duplicates/gaps) as the underlying data changes between fetches. Also, when the * parent is a combobox, this forces `async` mode on it (see `Combobox.async`), since only * a page of options is loaded client-side. */ infiniteScroll: boolean; /** * Number of options fetched per page when `infinite-scroll` is enabled. Defaults to 20. */ pageSize: number; labelFormatter: any; labelRowFormatter: (any: any) => string; initialSelectedValue: string | number; initialSelectedValueChanged(oldValue: any, newValue: any): void; initalSelectedValueInitialized: boolean; protected select: Select | Combobox; isSnapshot: boolean; protected options: { value: any; label: string; }[]; baseCriteria: string; private resizeObserver; private static readonly defaultPageSize; /** * Distance from the bottom of the listbox (in px) at which the next page is requested. */ private static readonly scrollLoadThresholdPx; private listboxElement; private loadingMoreRows; private renderedOptionsCount; private lastTopUpScrollHeight; private emptyDataOption; connectedCallback(): Promise; disconnectedCallback(): void; /** * While the dropdown is closed, the listbox has no dimensions and cannot be scrolled, * so re-check whether the visible listbox needs topping up every time it opens. Also * retries attaching the scroll listener if the initial attempt (queued on connect) * missed the listbox because the host hadn't rendered it yet. */ private selectOpenChangeHandler; /** * REQUEST_SERVER resources page by OFFSET against one-shot requests, so they keep the * default snapshot mode. DATASERVER resources page via MORE_ROWS, which needs the live * stream's SOURCE_REF, so they switch to stream mode. */ private applyInfiniteScrollFetchMode; private attachListboxScrollListener; private listboxScrollHandler; private loadNextPage; /** * If the loaded options don't fill the visible listbox (so it can't be scrolled), * keep requesting pages until it overflows or the server runs out of rows. */ private topUpVisibleListbox; private resizeObserverCallback; selectChangeHandler: (e: any) => void; fetchData(): void; asyncModeIntialization(): Promise; clearData(): void; private checkOverflow; private rowToOption; private renderListboxOptions; private removeEmptyDataOption; syncComponentData(snapshotData?: any[]): void; getInitialLabel(): string; private getDisplayForValue; resetCombobox(): void; /** * Appends rows to the already rendered options. Used by REQUEST_SERVER * infinite scroll paging, where each page contains only the new rows. */ handleStreamInserts(insertedRows: any[]): void; /** * @remarks * Not implemented: rendered options are only ever appended (see `syncComponentData` / * `handleStreamInserts`). For DATASERVER `infinite-scroll`, a live delete/update on a * row already rendered in an open dropdown will not be reflected until the datasource * is refetched (e.g. criteria change) — tracked as a known limitation, not a v1 goal. */ handleStreamDeletes(deletedRows: any[]): void; /** * @remarks * Not implemented — see {@link OptionsDatasource.handleStreamDeletes}. */ handleStreamUpdates(updatedRows: any[]): void; } //# sourceMappingURL=options-datasource.d.ts.map