import type { InputSelectionsByFieldId } from "./input-selections.svelte"; import { type Readable } from "svelte/store"; export type SelectionMode = "single" | "multiple"; export interface SelectionRange { min: number; max: number; } /** Whether a component is visible while rules see `selections`. */ export type VisibilityRule = (selections: InputSelectionsByFieldId) => boolean; /** Whether an option is hidden, so it doesn't count towards the selection. */ export type OptionHiddenCheck = (optionId: string) => boolean; interface InputChoiceContext { fieldId: string; mode: SelectionMode; required: boolean; selectionRange: SelectionRange | null; selectedOptionIds: Readable>; selectOption: (optionId: string) => void; /** True when selection count has reached the max (unselected options should be disabled) */ isAtMax: Readable; /** True when the current selection satisfies the validation requirements */ isSatisfied: Readable; /** * Reports an option's rule-driven visibility until the calling component is * destroyed. Hidden options, and options that aren't mounted, don't count * towards the selection. */ registerOption?: (optionId: string, isVisible: VisibilityRule) => void; } export declare function isSelectionSatisfied(count: number, required: boolean, selectionRange: SelectionRange | null): boolean; export declare function countShown(ids: Iterable, isHidden: OptionHiddenCheck): number; export declare function createInputChoiceContext(fieldId: string, mode: SelectionMode, required?: boolean, selectionRange?: SelectionRange | null, initialSelectedIds?: string[], isOptionHidden?: Readable): InputChoiceContext; export declare function setInputChoiceContext(context: InputChoiceContext): void; export declare function getInputChoiceContext(): InputChoiceContext | undefined; export {};