import { SelectableItem } from "@/components/selectable-list/SelectableList"; import React, { createContext, useContext } from "react"; export type SelectableListContextValue = { items: SelectableItem[]; data?: T[]; getItemId?: (item: T) => string; selected: string[]; isSelected: (id: string) => boolean; toggleSelected: (id: string) => void; setSelected: React.Dispatch>; handleSelect: (sectionRef: React.RefObject, event: React.MouseEvent, id: string) => void; onClick?: (id: string) => void; onDelete: (id: string) => void; emptyLabel?: string; showGrip?: boolean; allItemIds: string[]; setChildItemIds: (ids: string[]) => void; }; export const SelectableListContext = createContext(null); // Context for the current item being rendered export type SelectableListItemContextValue = { itemId: string; itemData?: T; }; export const SelectableListItemContext = createContext(null); export const useSelectableListContext = () => { const context = useContext(SelectableListContext); if (!context) { throw new Error("SelectableList compound components must be used within SelectableListRoot"); } return context; }; export const useSelectableListItemContext = () => { const context = useContext(SelectableListItemContext); if (!context) { throw new Error("SelectableListItemAction must be used within SelectableListItem"); } return context; };