export interface UseCycleListOptions { /** * Initial value */ initialValue?: R; /** * Fallback index when the value is not found */ fallbackIndex?: number; /** * Custom function to get the index of the value * * @param {T} value - `T`, the value to find * @param {T[]} list - `T[]`, the list to search * @returns {number} `number`, the index of the value */ getIndexOf?: (value: T, list: T[]) => number; } export type UseCycleListReturnsActions = { /** * Move to the next value * * @param {number} [step] - `number`, the step to move * @returns {T} `T`, the next value */ next: (step?: number) => T; /** * Move to the previous value * * @param {number} [step] - `number`, the step to move * @returns {T} `T`, the previous value */ prev: (step?: number) => T; /** * Move to the value at the specified index * * @param {number} index - `number`, the index to move * @returns {T} `T`, the value at the specified index */ go: (index: number) => T; }; export type UseCycleListReturns = readonly [ /** * Current value */ state: T, /** * Actions to control the list */ UseCycleListReturnsActions, /** * Current index */ index: number ]; /** * A React Hook that helps to create a circular list that can cycle through the list. * * TODO: rewrite using `NoInfer` in TS 5.4, now downgrade temporarily * * @param {T[]} list - `T[]`, the list to cycle * @param {UseCycleListOptions} [options] - `UseCycleListOptions`, see {@link UseCycleListOptions} * @returns {UseCycleListReturns} `UseCycleListReturns`, see {@link UseCycleListReturns} and {@link UseCycleListReturnsActions} */ export declare function useCircularList(list: T[], options?: UseCycleListOptions): UseCycleListReturns;