@ark-ui/solid
Version:
A collection of unstyled, accessible UI components for Solid, utilizing state machines for seamless interaction.
102 lines (98 loc) • 3.22 kB
TypeScript
import { CollectionItem, GridCollectionOptions, GridCollection, SelectionMode, ListCollection } from '@zag-js/collection';
export { CollectionItem, CollectionOptions, FilePathTreeNode, FlatTreeNode, GridCollection, GridCollectionOptions, ListCollection, TreeCollection, TreeCollectionOptions, TreeNode } from '@zag-js/collection';
export { c as createListCollection } from '../../list-collection-nOYDJvsQ.js';
export { c as createFileTreeCollection, a as createTreeCollection } from '../../tree-collection-BGrnj3vg.js';
export { U as UseListCollectionProps, a as UseListCollectionReturn, u as useListCollection } from '../../use-list-collection-Dk2gVdQ2.js';
import { M as MaybeAccessor } from '../../types-Bc0WfPsv.js';
import 'solid-js';
declare const createGridCollection: <T extends CollectionItem>(options: GridCollectionOptions<T>) => GridCollection<T>;
interface UseListSelectionProps<T extends CollectionItem> {
/**
* The selection mode.
*/
selectionMode?: SelectionMode;
/**
* Whether the selection is deselectable.
*/
deselectable?: boolean;
/**
* The initial selected values.
*/
initialSelectedValues?: string[];
/**
* Whether to reset the selection when the collection changes.
*/
resetOnCollectionChange?: boolean;
/**
* The collection to use.
*/
collection: ListCollection<T>;
}
declare function useListSelection<T extends CollectionItem>(props: MaybeAccessor<UseListSelectionProps<T>>): UseListSelectionReturn;
interface UseListSelectionReturn {
/**
* The selected values as an array.
*/
selectedValues: () => string[];
/**
* Whether the selection is empty.
*/
isEmpty: () => boolean;
/**
* The first selected value.
*/
firstSelectedValue: () => string | null;
/**
* The last selected value.
*/
lastSelectedValue: () => string | null;
/**
* Check if a value is selected.
*/
isSelected: (value: string | null) => boolean;
/**
* Check if a value can be selected.
*/
canSelect: (value: string) => boolean;
/**
* Select a value.
*/
select: (value: string, forceToggle?: boolean) => void;
/**
* Deselect a value.
*/
deselect: (value: string) => void;
/**
* Toggle selection of a value.
*/
toggle: (value: string) => void;
/**
* Replace the selection with a single value.
*/
replace: (value: string | null) => void;
/**
* Extend the selection from anchor to target.
*/
extend: (anchorValue: string, targetValue: string) => void;
/**
* Set the selected values.
*/
setSelectedValues: (values: string[]) => void;
/**
* Clear the selection.
*/
clear: () => void;
/**
* Clear all selections.
*/
resetSelection: () => void;
/**
* Returns true if all items from the collection are selected.
*/
isAllSelected: () => boolean;
/**
* Returns true if at least one item from the collection is selected.
*/
isSomeSelected: () => boolean;
}
export { type UseListSelectionProps, type UseListSelectionReturn, createGridCollection, useListSelection };