A Svelte 5 hook that manages selection state for collections, providing methods to select, deselect, and toggle items in lists or grids.
// Source: https://github.com/chakra-ui/ark | License: MIT | Copyright 2024 Chakra Systems Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { Selection, type SelectionMode } from '@zag-js/collection'
import { type MaybeFunction, runIfFn } from '@zag-js/utils'
import { untrack } from 'svelte'
import type { CollectionItem, ListCollection } from './list-collection.ts'
export 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?: b
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key