Skip to content

Commit

Permalink
fix: use union TS type name
Browse files Browse the repository at this point in the history
  • Loading branch information
vikiboss committed Jun 26, 2024
1 parent d1f5e1c commit 8ac5221
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 94 deletions.
6 changes: 3 additions & 3 deletions src/use-clipboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ export interface UseClipboardOptions<Source> {
*/
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<HasSource> {
/**
* Whether the clipboard is supported
* Whether the Clipboard API is supported
*/
isSupported: boolean
/**
Expand Down
110 changes: 56 additions & 54 deletions src/use-dynamic-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,67 @@ import { useCreation } from '../use-creation'
import { useSafeState } from '../use-safe-state'
import { useStableFn } from '../use-stable-fn'

export interface UseDynamicListReturnsActions<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
}

export type UseDynamicListReturns<T> = 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<T>,
]

/**
Expand Down
69 changes: 34 additions & 35 deletions src/use-pagination/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/use-toggle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { unwrapArrayable } from '../utils/unwrap'

import type { ReactSetState } from '../use-safe-state'

export interface UseToggleReturnActions<O, T> {
export interface UseToggleReturnsActions<O, T> {
/**
* Set the state to the left value.
*/
Expand All @@ -22,7 +22,7 @@ export interface UseToggleReturnActions<O, T> {
setState: ReactSetState<O | T>
}

export type UseToggleReturns<O, T> = readonly [O | T, () => void, UseToggleReturnActions<O, T>]
export type UseToggleReturns<O, T> = readonly [O | T, () => void, UseToggleReturnsActions<O, T>]

/**
* A React Hook that helps to manage a togglable state.
Expand Down

0 comments on commit 8ac5221

Please sign in to comment.