react-hook-toolkit 1.1.9 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk1213/chunk158261.d.ts +16 -0
- package/dist/chunk1213/chunk158862.d.ts +17 -0
- package/dist/chunk1415/chunk143.d.ts +20 -0
- package/dist/chunk1516/chunk0021.d.ts +109 -0
- package/dist/chunk1516/chunk0022.d.ts +2 -0
- package/dist/chunk1516/chunk613852.d.ts +10 -0
- package/dist/chunk1516/chunk726433.d.ts +58 -0
- package/dist/chunk1516/chunk940514.d.ts +93 -0
- package/dist/chunk1617/chunk613555.d.ts +23 -0
- package/dist/chunk1617/chunk613557.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/type.d.ts +286 -0
- package/dist/utils.d.ts +21 -0
- package/package.json +60 -61
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FC, ReactNode } from 'react';
|
|
2
|
+
export interface DrawerContextValue {
|
|
3
|
+
drawerOpen: boolean;
|
|
4
|
+
openDrawer: () => void;
|
|
5
|
+
closeDrawer: () => void;
|
|
6
|
+
openDrawerInButton: () => void;
|
|
7
|
+
closeDrawerInButton: () => void;
|
|
8
|
+
currentMainMenu?: string;
|
|
9
|
+
setCurrentMainMenu?: (value: string) => void;
|
|
10
|
+
}
|
|
11
|
+
interface DrawerProviderProps {
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
declare const DrawerContext: import("react").Context<DrawerContextValue>;
|
|
15
|
+
export declare const DrawerProvider: FC<DrawerProviderProps>;
|
|
16
|
+
export default DrawerContext;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
|
|
2
|
+
interface AxiosConfigProps {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
handleAuthError?: (axiosInstance: AxiosInstance, originalRequest: AxiosRequestConfig, err: AxiosError) => Promise<AxiosResponse>;
|
|
5
|
+
timeout: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const privateAxios: ({ baseURL, handleAuthError, timeout }: AxiosConfigProps) => AxiosInstance;
|
|
8
|
+
interface AxiosNoAuthConfigProps {
|
|
9
|
+
baseURL: string;
|
|
10
|
+
timeout: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const publicAxios: ({ baseURL, timeout }: AxiosNoAuthConfigProps) => AxiosInstance;
|
|
13
|
+
declare const _default: {
|
|
14
|
+
privateAxios: ({ baseURL, handleAuthError, timeout }: AxiosConfigProps) => AxiosInstance;
|
|
15
|
+
publicAxios: ({ baseURL, timeout }: AxiosNoAuthConfigProps) => AxiosInstance;
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license HEXE
|
|
3
|
+
* Copyright (c) 2020-2024 Shivaji & Collaborators
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
type HookFunction = () => any;
|
|
9
|
+
declare class HEXE {
|
|
10
|
+
private hs;
|
|
11
|
+
private ss;
|
|
12
|
+
constructor();
|
|
13
|
+
setHook(name: string, hookFunction: HookFunction): this;
|
|
14
|
+
private putHooks;
|
|
15
|
+
component(): React.FC;
|
|
16
|
+
getHook(name: string): any;
|
|
17
|
+
}
|
|
18
|
+
declare const ReactHooksWrapper: React.FC<{}>;
|
|
19
|
+
declare const getHook: (name: string) => any, setHook: (name: string, hookFunction: HookFunction) => HEXE;
|
|
20
|
+
export { ReactHooksWrapper, getHook, setHook };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { BatteryState, UseHistory, UseSessionStorage, UseSound, UseTouch } from '../type';
|
|
2
|
+
export declare function useGeoLocation(): {
|
|
3
|
+
position: GeolocationPosition | null;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
};
|
|
6
|
+
export declare function useTimer(initialTime: number): {
|
|
7
|
+
time: number;
|
|
8
|
+
error: Error | null;
|
|
9
|
+
};
|
|
10
|
+
export declare function useIsMounted(): boolean;
|
|
11
|
+
export declare function useCss(css: string): {
|
|
12
|
+
error: Error | null;
|
|
13
|
+
};
|
|
14
|
+
export declare function useSpeak(text: string): {
|
|
15
|
+
speak: () => void;
|
|
16
|
+
error: Error | null;
|
|
17
|
+
};
|
|
18
|
+
export declare function useCountUp(target: number, duration: number): {
|
|
19
|
+
count: number;
|
|
20
|
+
error: Error | null;
|
|
21
|
+
};
|
|
22
|
+
export declare function useCountDown(start: number): {
|
|
23
|
+
count: number;
|
|
24
|
+
error: Error | null;
|
|
25
|
+
};
|
|
26
|
+
export declare const useBattery: () => BatteryState;
|
|
27
|
+
export declare const useEventListener: (eventName: string, handler: (event: Event) => void, elementRef?: React.RefObject<HTMLElement>, options?: boolean | AddEventListenerOptions) => void;
|
|
28
|
+
export declare const useHistory: () => UseHistory;
|
|
29
|
+
interface UsePreferredLanguage {
|
|
30
|
+
language: string;
|
|
31
|
+
languages: Array<string>;
|
|
32
|
+
isSupported: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare const usePreferredLanguage: () => UsePreferredLanguage;
|
|
35
|
+
export declare const useSessionStorage: UseSessionStorage<any>;
|
|
36
|
+
export declare const useSound: (url: string) => UseSound;
|
|
37
|
+
export declare const useTouch: UseTouch;
|
|
38
|
+
export declare const useUpdateEffect: (effect: React.EffectCallback, deps: React.DependencyList) => void;
|
|
39
|
+
export declare const usePersistedForm: <T>(key: string, initialValue: T) => [T, (value: T) => void];
|
|
40
|
+
export declare const useCrossFieldValidation: <T extends Record<string, any>>(validate: (values: T) => Record<keyof T, string | null>) => {
|
|
41
|
+
errors: Record<keyof T, string | null>;
|
|
42
|
+
validateFields: (values: T) => boolean;
|
|
43
|
+
};
|
|
44
|
+
export declare const useFieldArray: <T>(initialValue: T[]) => {
|
|
45
|
+
fields: T[];
|
|
46
|
+
append: (item: T) => void;
|
|
47
|
+
remove: (index: number) => void;
|
|
48
|
+
update: (index: number, item: T) => void;
|
|
49
|
+
};
|
|
50
|
+
type SubmitHandler<T> = (data: T) => Promise<void>;
|
|
51
|
+
export declare const useFormSubmit: <T>(handler: SubmitHandler<T>) => {
|
|
52
|
+
handleSubmit: (data: T) => Promise<void>;
|
|
53
|
+
isSubmitting: boolean;
|
|
54
|
+
submitError: string | null;
|
|
55
|
+
};
|
|
56
|
+
export declare const useSmartForm: <T extends Record<string, any>>(initialValues: T, storageKey?: string) => {
|
|
57
|
+
values: T;
|
|
58
|
+
handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
59
|
+
setValues: import("react").Dispatch<import("react").SetStateAction<T>>;
|
|
60
|
+
dirty: boolean;
|
|
61
|
+
};
|
|
62
|
+
export declare const useUndo: <T>(initialState: T) => {
|
|
63
|
+
state: T;
|
|
64
|
+
setState: (newState: T) => void;
|
|
65
|
+
undo: () => false | void;
|
|
66
|
+
redo: () => false | void;
|
|
67
|
+
canUndo: boolean;
|
|
68
|
+
canRedo: boolean;
|
|
69
|
+
};
|
|
70
|
+
export declare const useFormWizard: <T extends Record<string, any>>(steps: {
|
|
71
|
+
validate?: (values: T) => Record<string, string>;
|
|
72
|
+
component: React.FC<{
|
|
73
|
+
values: T;
|
|
74
|
+
setValues: (v: T) => void;
|
|
75
|
+
}>;
|
|
76
|
+
}[], initialValues: T) => {
|
|
77
|
+
currentStep: number;
|
|
78
|
+
CurrentStep: import("react").FC<{
|
|
79
|
+
values: T;
|
|
80
|
+
setValues: (v: T) => void;
|
|
81
|
+
}>;
|
|
82
|
+
values: T;
|
|
83
|
+
setValues: import("react").Dispatch<import("react").SetStateAction<T>>;
|
|
84
|
+
next: () => void;
|
|
85
|
+
prev: () => void;
|
|
86
|
+
errors: Record<string, string>;
|
|
87
|
+
isFirstStep: boolean;
|
|
88
|
+
isLastStep: boolean;
|
|
89
|
+
};
|
|
90
|
+
export declare const createOptimizedContext: <T>() => readonly [import("react").Provider<T | undefined>, <U>(selector: (value: T) => U) => U];
|
|
91
|
+
export declare const useWebSocket: <T>(url: string, onMessage?: (data: T) => void) => {
|
|
92
|
+
data: T | null;
|
|
93
|
+
send: (message: any) => void;
|
|
94
|
+
isConnected: boolean;
|
|
95
|
+
};
|
|
96
|
+
export declare const useDragReorder: <T>(initialItems: T[]) => {
|
|
97
|
+
items: T[];
|
|
98
|
+
handleDragStart: (index: number) => void;
|
|
99
|
+
handleDragEnter: (index: number) => void;
|
|
100
|
+
handleDrop: () => void;
|
|
101
|
+
};
|
|
102
|
+
export declare const useInfiniteScroll: <T>(fetchData: (page: number) => Promise<T[]>, initialData?: T[]) => {
|
|
103
|
+
data: T[];
|
|
104
|
+
loading: boolean;
|
|
105
|
+
hasMore: boolean;
|
|
106
|
+
lastElementRef: (node: HTMLElement | null) => void;
|
|
107
|
+
};
|
|
108
|
+
export declare const useEventListeners: (eventType: string, handler: (event: Event) => void, element?: HTMLElement | Window, options?: AddEventListenerOptions) => void;
|
|
109
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { FileComponentProps, AlertPropsType, DetailsCardProps, UploadButtonProps, DownloadFileProps, ContextMenuProps } from '../type';
|
|
3
|
+
export declare const DynamicLoader: (Component: any) => (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const AlertMessage: FC<AlertPropsType>;
|
|
5
|
+
export declare const DetailsCard: ({ isLoading, title, details, spacing, boxShadow, background, loaderType, displayType, }: DetailsCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const LabeledValue: ({ label, value, style }: any) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const FilePreview: ({ primaryKey, filename, size, onDownload, width, borderColor, fileColor, isDownloading, }: FileComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const UploadFile: React.FC<UploadButtonProps>;
|
|
9
|
+
export declare const DownloadFile: React.FC<DownloadFileProps>;
|
|
10
|
+
export declare const ContextMenuWrapper: React.FC<ContextMenuProps>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import { UseRecentSearchOptions, ISpeechOptions, ISpeechState, MotionSensorState, IPermissionDescriptor, IState } from "../type";
|
|
3
|
+
export declare function useHistoryState<T>(initialPresent: T): {
|
|
4
|
+
state: T;
|
|
5
|
+
set: (newPresent: T) => void;
|
|
6
|
+
undo: () => void;
|
|
7
|
+
redo: () => void;
|
|
8
|
+
reset: (newPresent: T) => void;
|
|
9
|
+
clear: () => void;
|
|
10
|
+
canUndo: boolean;
|
|
11
|
+
canRedo: boolean;
|
|
12
|
+
past: T[];
|
|
13
|
+
future: T[];
|
|
14
|
+
};
|
|
15
|
+
export declare function useIdle(ms?: number): boolean;
|
|
16
|
+
export declare function useIsFirstRender(): boolean;
|
|
17
|
+
export declare function useList<T>(initialList?: T[]): {
|
|
18
|
+
list: T[];
|
|
19
|
+
actions: {
|
|
20
|
+
set: (newList: T[]) => void;
|
|
21
|
+
push: (element: T) => void;
|
|
22
|
+
removeAt: (index: number) => void;
|
|
23
|
+
insertAt: (index: number, element: T) => void;
|
|
24
|
+
updateAt: (index: number, element: T) => void;
|
|
25
|
+
clear: () => void;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function useLockBodyScroll(lock?: boolean): void;
|
|
29
|
+
type LongPressOptions = {
|
|
30
|
+
threshold?: number;
|
|
31
|
+
onStart?: (event: Event) => void;
|
|
32
|
+
onFinish?: (event: Event) => void;
|
|
33
|
+
onCancel?: (event: Event) => void;
|
|
34
|
+
};
|
|
35
|
+
export declare function useLongPress(callback: (event: Event) => void, options?: LongPressOptions): {
|
|
36
|
+
onMouseDown: any;
|
|
37
|
+
onMouseUp: any;
|
|
38
|
+
onMouseLeave: any;
|
|
39
|
+
onTouchStart: any;
|
|
40
|
+
onTouchEnd: any;
|
|
41
|
+
};
|
|
42
|
+
export declare const useRecentSearch: (options?: UseRecentSearchOptions) => {
|
|
43
|
+
recentSearches: any;
|
|
44
|
+
addSearch: (item: any) => void;
|
|
45
|
+
clearSearch: () => void;
|
|
46
|
+
hasSearch: (value: string) => any;
|
|
47
|
+
};
|
|
48
|
+
export declare const useUnmountedRef: () => import("react").MutableRefObject<boolean>;
|
|
49
|
+
export declare function configResponsive(config: any): void;
|
|
50
|
+
export declare const useResponsive: () => any;
|
|
51
|
+
export declare const useClickAway: <E extends Event = Event>(ref: RefObject<HTMLElement | null>, onClickAway: (event: E) => void, events?: string[]) => void;
|
|
52
|
+
export declare const useBeforeUnload: (enabled?: boolean | (() => boolean), message?: string) => void;
|
|
53
|
+
export declare const useHoverDirty: (ref: RefObject<Element>, enabled?: boolean) => boolean;
|
|
54
|
+
export declare const useMotion: (initialState?: MotionSensorState) => MotionSensorState;
|
|
55
|
+
export declare const usePageLeave: (onPageLeave: any, args?: never[]) => void;
|
|
56
|
+
export declare const usePermission: (permissionDesc: IPermissionDescriptor) => IState;
|
|
57
|
+
export declare const useSpeech: (text: string, options: ISpeechOptions) => ISpeechState;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { AsyncFunction, FetchState, MousePosition, ScrollPosition, UseAsyncReturn, UseAxiosConfig, UseAxiosResponse, WindowSize } from '../type';
|
|
3
|
+
export declare const isReady: () => boolean;
|
|
4
|
+
export declare const useAxios: <T>(config?: UseAxiosConfig) => UseAxiosResponse<T>;
|
|
5
|
+
export declare const useDrawer: () => import("../chunk1213/chunk158261").DrawerContextValue;
|
|
6
|
+
export declare const useGenericReducer: <State, Action extends {
|
|
7
|
+
type: string;
|
|
8
|
+
}>(initialState: State, actions: Record<string, (state: State, action: Action) => State>) => (state: State | undefined, action: Action) => State;
|
|
9
|
+
export declare function useRequest<T>(url: string): FetchState<T>;
|
|
10
|
+
export declare function useLocalStorage<T>(key: string, initialValue: T): [T, (value: T) => void];
|
|
11
|
+
export declare function useToggle(initialValue?: boolean): [boolean, () => void];
|
|
12
|
+
export declare function useDebounce<T>(value: T, delay: number): T;
|
|
13
|
+
export declare function useThrottle<T>(value: T, limit: number): T;
|
|
14
|
+
export declare function usePrevious<T>(value: T): T | undefined;
|
|
15
|
+
export declare function useMediaQuery(query: string): boolean;
|
|
16
|
+
export declare function useClipboard(): [boolean, (text: string) => Promise<void>];
|
|
17
|
+
export declare function useInterval(callback: () => void, delay: number | null): void;
|
|
18
|
+
export declare function useWindowSize(): WindowSize;
|
|
19
|
+
export declare function useKeyPress(targetKey: string): boolean;
|
|
20
|
+
export declare function useOnlineStatus(): boolean;
|
|
21
|
+
export declare function useScrollPosition(): ScrollPosition;
|
|
22
|
+
export declare function useTimeout(callback: () => void, delay: number | null): void;
|
|
23
|
+
export declare function useDarkMode(): [boolean, () => void];
|
|
24
|
+
export declare function useForm<T extends Record<string, any>>(initialValues: T): {
|
|
25
|
+
values: T;
|
|
26
|
+
errors: Partial<Record<keyof T, string>>;
|
|
27
|
+
handleChange: (name: keyof T, value: any) => void;
|
|
28
|
+
validate: (validators: Partial<Record<keyof T, (value: any) => string | null>>) => boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare function useArray<T>(initialArray: T[]): {
|
|
31
|
+
array: T[];
|
|
32
|
+
set: import("react").Dispatch<import("react").SetStateAction<T[]>>;
|
|
33
|
+
push: (item: T) => void;
|
|
34
|
+
removeByIndex: (index: number) => void;
|
|
35
|
+
clear: () => void;
|
|
36
|
+
};
|
|
37
|
+
export declare const useStepper: (totalSteps: number) => {
|
|
38
|
+
activeStep: number;
|
|
39
|
+
handleNext: () => void;
|
|
40
|
+
handleBack: () => void;
|
|
41
|
+
handleReset: () => void;
|
|
42
|
+
totalSteps: number;
|
|
43
|
+
isFirstStep: boolean;
|
|
44
|
+
isLastStep: boolean;
|
|
45
|
+
isProccesing: boolean;
|
|
46
|
+
setIsProccesing: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
47
|
+
goto: (step: number) => void;
|
|
48
|
+
};
|
|
49
|
+
export declare const useSteps: (totalSteps: number) => {
|
|
50
|
+
activeStep: number;
|
|
51
|
+
handleNext: () => void;
|
|
52
|
+
handleBack: () => void;
|
|
53
|
+
handleReset: () => void;
|
|
54
|
+
goto: (step: number) => void;
|
|
55
|
+
totalSteps: number;
|
|
56
|
+
isFirstStep: boolean;
|
|
57
|
+
isLastStep: boolean;
|
|
58
|
+
isProcessing: boolean;
|
|
59
|
+
setIsProcessing: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
60
|
+
};
|
|
61
|
+
export declare function useTimeoutFn(callback: () => void, delay: number | null): {
|
|
62
|
+
reset: () => void;
|
|
63
|
+
clear: () => void;
|
|
64
|
+
};
|
|
65
|
+
export declare function useDebouncedCallback(callback: () => void, delay: number): () => void;
|
|
66
|
+
export declare function useScrollLock(lock: boolean): void;
|
|
67
|
+
export declare function useResizeObserver<T extends HTMLElement>(ref: RefObject<T>): WindowSize | null;
|
|
68
|
+
export declare function useMousePosition(): MousePosition;
|
|
69
|
+
type ScrollDirection = 'up' | 'down';
|
|
70
|
+
export declare function useScrollDirection(): ScrollDirection;
|
|
71
|
+
export declare function useImageLoader(src: string): {
|
|
72
|
+
loaded: boolean;
|
|
73
|
+
error: boolean;
|
|
74
|
+
};
|
|
75
|
+
export declare function usePersistedState<T>(key: string, initialValue: T): [T, React.Dispatch<React.SetStateAction<T>>];
|
|
76
|
+
export declare function useReducedMotion(): boolean;
|
|
77
|
+
export declare function useCookie(key: string): [string | null, (value: string, options?: any) => void, () => void];
|
|
78
|
+
export declare function useRequestRetry<T>(url: string, options: RequestInit, retries?: number): {
|
|
79
|
+
data: T | null;
|
|
80
|
+
error: string | null;
|
|
81
|
+
loading: boolean;
|
|
82
|
+
};
|
|
83
|
+
export declare function useDelay<T>(value: T, delay: number): T;
|
|
84
|
+
export declare function useVisibilityChange(): boolean;
|
|
85
|
+
export declare function useDebouncedValue<T>(value: T, delay: number): T;
|
|
86
|
+
export declare function useAsync<T>(asyncFunction: AsyncFunction<T>, immediate?: boolean): UseAsyncReturn<T>;
|
|
87
|
+
export type ScriptStatus = 'loading' | 'ready' | 'error' | 'unknown';
|
|
88
|
+
export declare function useScript(src: string, removeOnUnmount?: boolean): ScriptStatus;
|
|
89
|
+
export declare function useIndexedDB<T>(dbName: string, storeName: string): {
|
|
90
|
+
data: T | null;
|
|
91
|
+
error: Error | null;
|
|
92
|
+
};
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const FileSkeleton: ({ length, width, borderColor }: {
|
|
2
|
+
length?: number | undefined;
|
|
3
|
+
width?: number | undefined;
|
|
4
|
+
borderColor?: string | undefined;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const TableSkeleton: ({ rows, columns }: {
|
|
7
|
+
rows?: number | undefined;
|
|
8
|
+
columns?: number | undefined;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const LineChartSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const CardSkeleton: () => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const PieChartSkeleton: React.FC;
|
|
13
|
+
export declare const FieldSkeleton: ({ length, width, spacing, isLabel, responsive, }: {
|
|
14
|
+
length?: number | undefined;
|
|
15
|
+
width?: string | undefined;
|
|
16
|
+
spacing?: number | undefined;
|
|
17
|
+
isLabel?: boolean | undefined;
|
|
18
|
+
responsive?: {
|
|
19
|
+
xs: number;
|
|
20
|
+
sm: number;
|
|
21
|
+
md: number;
|
|
22
|
+
} | undefined;
|
|
23
|
+
}) => import("react/jsx-runtime").JSX.Element;
|