import type { AdaptorSelectOption, StringSelectComponentBuilder, AdaptorStringSelectInteraction } from "../../adaptor"; import type { Lazy } from "../../util/lazy"; import type { SetOptional } from "type-fest"; export type SelectItem = Omit & { payload: T; key: string; inactive: boolean; }; export type PartialSelectItem = SetOptional, "key" | "inactive">; export type SelectItemResult = SelectItem & { selected: boolean; }; export type UseSelectComponentResult = [ selectResult: SelectItemResult[], StringSelect: StringSelectComponentBuilder<{ customId: string; options: AdaptorSelectOption[]; minValues: number | undefined; maxValues: number | undefined; }>, stateAccessor: UseSelectResult ]; export type UseSingleSelectComponentResult = [ selectResult: SelectItemResult | null, StringSelect: StringSelectComponentBuilder<{ customId: string; options: AdaptorSelectOption[]; minValues: number | undefined; maxValues: 1; }>, stateAccessor: UseSelectResult ]; export type UseSelectComponentParams = { options: readonly PartialSelectItem[]; onSelected?: (selected: SelectItemResult[]) => void; minValues?: number; maxValues?: number; filter?: (interaction: Readonly) => boolean; }; /** * StringSelectコンポーネントと選択状態を提供するrenderHook * @param options 選択肢 payloadにはstringだけでなく任意のオブジェクトを指定でき、結果として受け取ることができる * @param onSelected 選択状態が変更されたときに呼び出される * @param maxValues 選択可能なオプションの最大数 (デフォルト: 制限無し) * @param minValues 選択可能なオプションの最小数 (デフォルト: 0) * @param filter interactionに反応するかどうかのフィルタ falseを返すとdeferUpdateとonClickは実行されない * @returns [selectResult, StringSelect, stateAccessor] */ export declare const useSelectComponent: ({ options, onSelected, maxValues, minValues, filter, }: UseSelectComponentParams) => UseSelectComponentResult; export type UseSelectStateParam = { customId: string; options: readonly { key: string; default?: boolean; }[]; selectedUpdateHook?: (key: string, prev: boolean, next: boolean, selectedKeys: readonly string[]) => boolean; filter?: (interaction: AdaptorStringSelectInteraction) => boolean; }; export type UseSelectResult = UseSelectResultStateAccessor; export type UseSelectResultStateAccessor = { get: (key: string) => boolean; set: (key: string, updater: Lazy) => void; setEach: (updater: (prev: boolean, key: string) => boolean) => void; }; export declare const useSelectState: ({ customId, options, selectedUpdateHook, filter, }: UseSelectStateParam) => UseSelectResult; export type UseSingleSelectComponentParam = Omit, "onSelected" | "maxValues"> & { onSelected?: (selected: SelectItemResult | null) => void; }; /** * StringSelectコンポーネントと選択状態を提供するrenderHook * useSelectComponentの単一選択版 * @param options 選択肢 payloadにはstringだけでなく任意のオブジェクトを指定でき、結果として受け取ることができる * @param onSelected 選択状態が変更されたときに呼び出される * @param minValues 選択可能なオプションの最小数 (デフォルト: 0) * @param filter interactionに反応するかどうかのフィルタ falseを返すとdeferUpdateとonClickは実行されない * @returns [selectResult, StringSelect, stateAccessor] */ export declare const useSingleSelectComponent: ({ options, onSelected, minValues, filter, }: UseSingleSelectComponentParam) => UseSingleSelectComponentResult; //# sourceMappingURL=useSelectComponent.d.ts.map