/*!
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import { type ComboboxAction, type ComboboxFilterOption, type ComboboxOption, type ComboboxOptionGroup } from './combobox-types';
type ComboboxOptions = TOption[] | ComboboxOptionGroup[];
declare const isOptionGroup: (item: TOption | ComboboxOptionGroup) => item is ComboboxOptionGroup;
/**
* Filters options against the search value, keeping the grouped or flat shape
* of the input. Groups that end up without matches are dropped.
*/
declare const filterComboboxOptions: (options: ComboboxOptions, searchValue: string, filterOption?: ComboboxFilterOption) => ComboboxOptions;
/** Flattens grouped options into the visual order used for option ids. */
declare const flattenComboboxOptions: (options: (TOption | ComboboxOptionGroup)[]) => TOption[];
declare const CREATE_MARKER: unique symbol;
type ComboboxCreateOption = TOption & {
readonly [CREATE_MARKER]: true;
};
declare const isCreateOption: (option: TOption) => option is ComboboxCreateOption;
/** Tags an option as the create row, so activating it creates instead of selects. */
declare const asCreateOption: (option: TOption) => ComboboxCreateOption;
/**
* The default way to build the option to create. It can only fill in the fields
* of `ComboboxOption`, so an option type with more required fields of its own
* has to supply `createOption`.
*/
declare const buildCreateOption: (searchValue: string) => TOption;
declare const formatCreateOptionLabel: (searchValue: string) => string;
declare const ACTION_MARKER: unique symbol;
type ComboboxActionRow = ComboboxOption & {
readonly [ACTION_MARKER]: ComboboxAction;
};
/** A row of the rendered list, which is either an option or an action. */
type ComboboxRow = TOption | ComboboxActionRow;
declare const isActionRow: (row: ComboboxRow) => row is ComboboxActionRow;
/**
* Wraps an action as a list row. The position in `actions` gives the row a
* stable value, which keeps the active row from being reset every render.
*/
declare const asActionRow: (action: ComboboxAction, index: number) => ComboboxActionRow;
declare const getAction: (row: ComboboxActionRow) => ComboboxAction;
/**
* A created option is never added to `options`, so the current selection is
* checked too. Without that, retyping a created value would offer to create it
* again and toggle the existing selection back off in multi select.
*/
declare const isValidNewComboboxOption: (searchValue: string, options: ComboboxOption[]) => boolean;
/**
* Disabled options are deliberately included in keyboard navigation, following
* the APG guidance on the focusability of disabled controls: skipping them
* would make them undiscoverable to screen reader users. Activation is what
* ignores them instead.
*/
declare const getFirstOptionIndex: (options: ComboboxOption[]) => -1 | 0;
declare const getLastOptionIndex: (options: ComboboxOption[]) => number;
/**
* Steps one option in the given direction, clamping at the ends of the list
* as the combobox pattern permits.
*/
declare const getNextOptionIndex: (options: ComboboxOption[], fromIndex: number, direction: 1 | -1) => number;
type ComboboxValue = TOption | TOption[] | null;
declare const getInitialValue: (value: ComboboxValue | undefined, defaultValue: ComboboxValue | undefined, isMulti: boolean) => ComboboxValue;
export { asActionRow, asCreateOption, buildCreateOption, filterComboboxOptions, flattenComboboxOptions, formatCreateOptionLabel, getAction, getFirstOptionIndex, getLastOptionIndex, getNextOptionIndex, isActionRow, isCreateOption, isOptionGroup, isValidNewComboboxOption, getInitialValue, };
export type { ComboboxActionRow, ComboboxRow, ComboboxValue };
//# sourceMappingURL=combobox-utils.d.ts.map