@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
25 lines (24 loc) • 1.13 kB
TypeScript
import React from "react";
import { ComboboxOption, ComboboxProps } from "../types.js";
type SelectedOptionsContextValue = {
addSelectedOption: (option: ComboboxOption) => void;
isMultiSelect?: boolean;
removeSelectedOption: (option: ComboboxOption) => void;
prevSelectedOptions?: ComboboxOption[];
selectedOptions: ComboboxOption[];
maxSelected: {
limit: number | undefined;
isLimitReached: boolean;
};
setSelectedOptions: (any: any) => void;
toggleOption: (option: ComboboxOption, event: React.KeyboardEvent | React.PointerEvent) => void;
};
declare const useSelectedOptionsContext: <S extends boolean = true>(strict?: S) => S extends true ? SelectedOptionsContextValue : SelectedOptionsContextValue | undefined;
declare const SelectedOptionsProvider: ({ children, value, }: {
children: any;
value: Pick<ComboboxProps, "allowNewValues" | "isMultiSelect" | "onToggleSelected" | "maxSelected"> & {
options: ComboboxOption[];
selectedOptions?: ComboboxOption[];
};
}) => React.JSX.Element;
export { SelectedOptionsProvider, useSelectedOptionsContext };