diff --git a/src/use-clipboard/index.ts b/src/use-clipboard/index.ts index e0d410bd..f293dca9 100644 --- a/src/use-clipboard/index.ts +++ b/src/use-clipboard/index.ts @@ -18,20 +18,20 @@ export interface UseClipboardOptions { */ read?: boolean /** - * Copy source + * Copy source, which is copied by default when you call the copy method directly without passing any parameters */ source?: Source /** * Milliseconds to reset state of `copied` ref * - * @defaultValue 1500 + * @defaultValue 1_500 */ copiedDuration?: number } export interface UseClipboardReturns { /** - * Whether the clipboard is supported + * Whether the Clipboard API is supported */ isSupported: boolean /** diff --git a/src/use-dynamic-list/index.ts b/src/use-dynamic-list/index.ts index b3d2580c..488f6d1a 100644 --- a/src/use-dynamic-list/index.ts +++ b/src/use-dynamic-list/index.ts @@ -3,65 +3,67 @@ import { useCreation } from '../use-creation' import { useSafeState } from '../use-safe-state' import { useStableFn } from '../use-stable-fn' +export interface UseDynamicListReturnsActions { + /** + * insert an item at the specified index + */ + insert: (index: number, item: T) => void + /** + * merge items at the specified index + */ + merge: (index: number, items: T[]) => void + /** + * replace an item at the specified index + */ + replace: (index: number, item: T) => void + /** + * remove an item at the specified index + */ + remove: (index: number) => void + /** + * get the key of the item at the specified index + */ + getKey: (index: number) => number + /** + * get the index of the item with the specified key + */ + getIndex: (key: number) => number + /** + * move an item from the old index to the new index + */ + move: (oldIndex: number, newIndex: number) => void + /** + * push an item to the end of the list + */ + push: (item: T) => void + /** + * pop an item from the end of the list + */ + pop(): void + /** + * unshift an item to the start of the list + */ + unshift: (item: T) => void + /** + * shift an item from the start of the list + */ + shift(): void + /** + * sort the list based on the specified result + */ + sort: (result: T[]) => T[] + /** + * reset the list + */ + reset: (newList: T[]) => void +} + export type UseDynamicListReturns = readonly [ /** * list of items */ list: T[], - { - /** - * insert an item at the specified index - */ - insert: (index: number, item: T) => void - /** - * merge items at the specified index - */ - merge: (index: number, items: T[]) => void - /** - * replace an item at the specified index - */ - replace: (index: number, item: T) => void - /** - * remove an item at the specified index - */ - remove: (index: number) => void - /** - * get the key of the item at the specified index - */ - getKey: (index: number) => number - /** - * get the index of the item with the specified key - */ - getIndex: (key: number) => number - /** - * move an item from the old index to the new index - */ - move: (oldIndex: number, newIndex: number) => void - /** - * push an item to the end of the list - */ - push: (item: T) => void - /** - * pop an item from the end of the list - */ - pop(): void - /** - * unshift an item to the start of the list - */ - unshift: (item: T) => void - /** - * shift an item from the start of the list - */ - shift(): void - /** - * sort the list based on the specified result - */ - sort: (result: T[]) => T[] - /** - * reset the list - */ - reset: (newList: T[]) => void - }, + UseDynamicListReturnsActions, ] /** diff --git a/src/use-pagination/index.ts b/src/use-pagination/index.ts index 52f481e5..56c111cd 100644 --- a/src/use-pagination/index.ts +++ b/src/use-pagination/index.ts @@ -29,24 +29,24 @@ export interface UsePaginationOptions { * @param {PaginationInfo} pagination - `PaginationInfo`, the pagination info * @returns {void} `void` */ - onPageChange?: (pagination: UsePaginationState) => void + onPageChange?: (pagination: UsePaginationReturnsState) => void /** * Callback when the `pageSize` change. * * @param {PaginationInfo} pagination - `PaginationInfo`, the pagination info * @returns {void} `void` */ - onPageSizeChange?: (pagination: UsePaginationState) => void + onPageSizeChange?: (pagination: UsePaginationReturnsState) => void /** * Callback when the `pageCount` change. * * @param {PaginationInfo} pagination - `PaginationInfo`, the pagination info * @returns {void} `void` */ - onPageCountChange?: (pagination: UsePaginationState) => void + onPageCountChange?: (pagination: UsePaginationReturnsState) => void } -export interface UsePaginationState { +export interface UsePaginationReturnsState { /** * Total number of items. */ @@ -73,37 +73,36 @@ export interface UsePaginationState { isLastPage: boolean } -export type UsePaginationReturns = readonly [ - UsePaginationState, - { - /** - * Go to the previous page. - * - * @returns {void} `void` - */ - prev(): void - /** - * Go to the next page. - * - * @returns {void} `void` - */ - next(): void - /** - * Go to the specified page. - * - * @param {number} page - `number`, the page number - * @returns {void} `void` - */ - go: (page: number) => void - /** - * Set the number of items to display per page. - * - * @param {number} size - `number`, the number of items to display per page - * @returns {void} `void` - */ - setPageSize: (size: number) => void - }, -] +export interface UsePaginationReturnsActions { + /** + * Go to the previous page. + * + * @returns {void} `void` + */ + prev(): void + /** + * Go to the next page. + * + * @returns {void} `void` + */ + next(): void + /** + * Go to the specified page. + * + * @param {number} page - `number`, the page number + * @returns {void} `void` + */ + go: (page: number) => void + /** + * Set the number of items to display per page. + * + * @param {number} size - `number`, the number of items to display per page + * @returns {void} `void` + */ + setPageSize: (size: number) => void +} + +export type UsePaginationReturns = readonly [UsePaginationReturnsState, UsePaginationReturnsActions] /** * A React Hook that manage pagination state. diff --git a/src/use-toggle/index.ts b/src/use-toggle/index.ts index 3ff95c9c..7dcccf2e 100644 --- a/src/use-toggle/index.ts +++ b/src/use-toggle/index.ts @@ -7,7 +7,7 @@ import { unwrapArrayable } from '../utils/unwrap' import type { ReactSetState } from '../use-safe-state' -export interface UseToggleReturnActions { +export interface UseToggleReturnsActions { /** * Set the state to the left value. */ @@ -22,7 +22,7 @@ export interface UseToggleReturnActions { setState: ReactSetState } -export type UseToggleReturns = readonly [O | T, () => void, UseToggleReturnActions] +export type UseToggleReturns = readonly [O | T, () => void, UseToggleReturnsActions] /** * A React Hook that helps to manage a togglable state.