UNPKG

@furystack/shades-common-components

Version:

Common UI components for FuryStack Shades

40 lines 1.55 kB
import { ObservableValue } from '@furystack/utils'; export type ListServiceOptions<T> = { /** * An optional field that can be used for type-ahead search */ searchField?: keyof T; }; /** * Service for managing list state including focus, selection, and keyboard navigation */ export declare class ListService<T> implements Disposable { private options; [Symbol.dispose](): void; isSelected: (item: T) => boolean; addToSelection: (item: T) => void; removeFromSelection: (item: T) => void; toggleSelection: (item: T) => void; items: ObservableValue<T[]>; focusedItem: ObservableValue<T | undefined>; /** * Stores the focused item captured on pointerdown, before the focus event * can update focusedItem. Used as the anchor for SHIFT+click range selection. * Call {@link setFocusAnchor} from `onpointerdown` to snapshot the anchor * before focus shifts. */ private focusAnchor; /** Snapshot the current focused item as the anchor for SHIFT+click range selection. */ setFocusAnchor(): void; selection: ObservableValue<T[]>; searchTerm: ObservableValue<string>; hasFocus: ObservableValue<boolean>; handleKeyDown(ev: KeyboardEvent): void; handleItemClick(item: T, ev: MouseEvent): void; /** * Hook for double-click behavior. No-op in base class; overridden by TreeService for expand/collapse. */ handleItemDoubleClick(_item: T): void; constructor(options?: ListServiceOptions<T>); } //# sourceMappingURL=list-service.d.ts.map