@vef-framework/hooks 1.0.135 → 2.0.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/README +15 -0
- package/dist/cjs/index.cjs +172 -0
- package/dist/cjs/lib.cjs +148 -0
- package/dist/cjs/use-authorized-items/index.cjs +20 -0
- package/dist/cjs/use-breakpoints/index.cjs +74 -0
- package/dist/cjs/use-check-permission/index.cjs +18 -0
- package/dist/cjs/use-data-dict-query/index.cjs +34 -0
- package/dist/cjs/use-data-options/index.cjs +119 -0
- package/dist/cjs/use-deep-callback/index.cjs +13 -0
- package/dist/cjs/use-deep-compare/index.cjs +36 -0
- package/dist/cjs/use-deep-effect/index.cjs +13 -0
- package/dist/cjs/use-deep-isomorphic-effect/index.cjs +14 -0
- package/dist/cjs/use-deep-layout-effect/index.cjs +13 -0
- package/dist/cjs/use-deep-memo/index.cjs +13 -0
- package/dist/cjs/use-document-event/index.cjs +22 -0
- package/dist/cjs/use-emitter-event/index.cjs +22 -0
- package/dist/cjs/use-has-fetching/index.cjs +17 -0
- package/dist/cjs/use-has-mutating/index.cjs +16 -0
- package/dist/cjs/use-is-authorized/index.cjs +18 -0
- package/dist/cjs/use-latest/index.cjs +14 -0
- package/dist/cjs/use-raf-state/index.cjs +23 -0
- package/dist/cjs/use-shallow-callback/index.cjs +13 -0
- package/dist/cjs/use-shallow-compare/index.cjs +36 -0
- package/dist/cjs/use-shallow-effect/index.cjs +13 -0
- package/dist/cjs/use-shallow-isomorphic-effect/index.cjs +14 -0
- package/dist/cjs/use-shallow-layout-effect/index.cjs +13 -0
- package/dist/cjs/use-shallow-memo/index.cjs +13 -0
- package/dist/cjs/use-singleton/index.cjs +16 -0
- package/dist/es/index.js +29 -0
- package/dist/es/lib.js +35 -0
- package/dist/es/use-authorized-items/index.js +16 -0
- package/dist/es/use-breakpoints/index.js +70 -0
- package/dist/es/use-check-permission/index.js +14 -0
- package/dist/es/use-data-dict-query/index.js +30 -0
- package/dist/es/use-data-options/index.js +115 -0
- package/dist/es/use-deep-callback/index.js +9 -0
- package/dist/es/use-deep-compare/index.js +32 -0
- package/dist/es/use-deep-effect/index.js +9 -0
- package/dist/es/use-deep-isomorphic-effect/index.js +10 -0
- package/dist/es/use-deep-layout-effect/index.js +9 -0
- package/dist/es/use-deep-memo/index.js +9 -0
- package/dist/es/use-document-event/index.js +18 -0
- package/dist/es/use-emitter-event/index.js +18 -0
- package/dist/es/use-has-fetching/index.js +13 -0
- package/dist/es/use-has-mutating/index.js +12 -0
- package/dist/es/use-is-authorized/index.js +14 -0
- package/dist/es/use-latest/index.js +10 -0
- package/dist/es/use-raf-state/index.js +19 -0
- package/dist/es/use-shallow-callback/index.js +9 -0
- package/dist/es/use-shallow-compare/index.js +32 -0
- package/dist/es/use-shallow-effect/index.js +9 -0
- package/dist/es/use-shallow-isomorphic-effect/index.js +10 -0
- package/dist/es/use-shallow-layout-effect/index.js +9 -0
- package/dist/es/use-shallow-memo/index.js +9 -0
- package/dist/es/use-singleton/index.js +12 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/lib.d.ts +6 -0
- package/{types/use-authorized-items.d.ts → dist/types/use-authorized-items/index.d.ts} +4 -3
- package/dist/types/use-breakpoints/index.d.ts +47 -0
- package/dist/types/use-check-permission/index.d.ts +8 -0
- package/dist/types/use-data-dict-query/index.d.ts +15 -0
- package/dist/types/use-data-options/index.d.ts +80 -0
- package/dist/types/use-deep-callback/index.d.ts +9 -0
- package/dist/types/use-deep-compare/index.d.ts +8 -0
- package/dist/types/use-deep-effect/index.d.ts +9 -0
- package/dist/types/use-deep-isomorphic-effect/index.d.ts +9 -0
- package/dist/types/use-deep-layout-effect/index.d.ts +9 -0
- package/dist/types/use-deep-memo/index.d.ts +9 -0
- package/dist/types/use-document-event/index.d.ts +8 -0
- package/dist/types/use-emitter-event/index.d.ts +9 -0
- package/dist/types/use-has-fetching/index.d.ts +8 -0
- package/dist/types/use-has-mutating/index.d.ts +7 -0
- package/dist/types/use-is-authorized/index.d.ts +10 -0
- package/dist/types/use-latest/index.d.ts +8 -0
- package/dist/types/use-raf-state/index.d.ts +8 -0
- package/dist/types/use-shallow-callback/index.d.ts +9 -0
- package/dist/types/use-shallow-compare/index.d.ts +8 -0
- package/dist/types/use-shallow-effect/index.d.ts +9 -0
- package/dist/types/use-shallow-isomorphic-effect/index.d.ts +9 -0
- package/dist/types/use-shallow-layout-effect/index.d.ts +9 -0
- package/dist/types/use-shallow-memo/index.d.ts +9 -0
- package/dist/types/use-singleton/index.d.ts +11 -0
- package/package.json +46 -36
- package/README.md +0 -27
- package/cjs/index.cjs +0 -2
- package/cjs/lib.cjs +0 -2
- package/cjs/use-authorized-items.cjs +0 -2
- package/cjs/use-color-tokens.cjs +0 -2
- package/cjs/use-computed-action-buttons.cjs +0 -2
- package/cjs/use-computed-options.cjs +0 -2
- package/cjs/use-context-disabled.cjs +0 -2
- package/cjs/use-data-query.cjs +0 -2
- package/cjs/use-deep-callback.cjs +0 -2
- package/cjs/use-deep-memo.cjs +0 -2
- package/cjs/use-deep-selector.cjs +0 -2
- package/cjs/use-fallback-options.cjs +0 -2
- package/cjs/use-gap-size-normalizer.cjs +0 -2
- package/cjs/use-normalized-gap-size.cjs +0 -2
- package/cjs/use-normalized-menu-items.cjs +0 -2
- package/cjs/use-normalized-options.cjs +0 -2
- package/cjs/use-option-filter.cjs +0 -2
- package/cjs/use-remote-filter.cjs +0 -2
- package/cjs/use-shallow-callback.cjs +0 -2
- package/cjs/use-shallow-memo.cjs +0 -2
- package/cjs/use-shallow-selector.cjs +0 -2
- package/cjs/use-singleton.cjs +0 -2
- package/cjs/use-theme-tokens.cjs +0 -2
- package/cjs/use-transient-store.cjs +0 -2
- package/cjs/use-window-size.cjs +0 -2
- package/esm/index.js +0 -2
- package/esm/lib.js +0 -2
- package/esm/use-authorized-items.js +0 -2
- package/esm/use-color-tokens.js +0 -2
- package/esm/use-computed-action-buttons.js +0 -2
- package/esm/use-computed-options.js +0 -2
- package/esm/use-context-disabled.js +0 -2
- package/esm/use-data-query.js +0 -2
- package/esm/use-deep-callback.js +0 -2
- package/esm/use-deep-memo.js +0 -2
- package/esm/use-deep-selector.js +0 -2
- package/esm/use-fallback-options.js +0 -2
- package/esm/use-gap-size-normalizer.js +0 -2
- package/esm/use-normalized-gap-size.js +0 -2
- package/esm/use-normalized-menu-items.js +0 -2
- package/esm/use-normalized-options.js +0 -2
- package/esm/use-option-filter.js +0 -2
- package/esm/use-remote-filter.js +0 -2
- package/esm/use-shallow-callback.js +0 -2
- package/esm/use-shallow-memo.js +0 -2
- package/esm/use-shallow-selector.js +0 -2
- package/esm/use-singleton.js +0 -2
- package/esm/use-theme-tokens.js +0 -2
- package/esm/use-transient-store.js +0 -2
- package/esm/use-window-size.js +0 -2
- package/types/index.d.ts +0 -24
- package/types/lib.d.ts +0 -3
- package/types/use-color-tokens.d.ts +0 -19
- package/types/use-computed-action-buttons.d.ts +0 -35
- package/types/use-computed-options.d.ts +0 -54
- package/types/use-context-disabled.d.ts +0 -6
- package/types/use-data-query.d.ts +0 -9
- package/types/use-deep-callback.d.ts +0 -10
- package/types/use-deep-memo.d.ts +0 -10
- package/types/use-deep-selector.d.ts +0 -8
- package/types/use-fallback-options.d.ts +0 -34
- package/types/use-gap-size-normalizer.d.ts +0 -8
- package/types/use-normalized-gap-size.d.ts +0 -9
- package/types/use-normalized-menu-items.d.ts +0 -16
- package/types/use-normalized-options.d.ts +0 -33
- package/types/use-option-filter.d.ts +0 -8
- package/types/use-remote-filter.d.ts +0 -9
- package/types/use-shallow-callback.d.ts +0 -10
- package/types/use-shallow-memo.d.ts +0 -10
- package/types/use-shallow-selector.d.ts +0 -8
- package/types/use-singleton.d.ts +0 -7
- package/types/use-theme-tokens.d.ts +0 -6
- package/types/use-transient-store.d.ts +0 -34
- package/types/use-window-size.d.ts +0 -17
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Api, DataOption, EmptyObject, IdValue, Mapper, MaybePromise, ObjectType, PureDataOption, QueryParamsWithValues } from "@vef-framework/shared";
|
|
2
|
-
/**
|
|
3
|
-
* The config of the use fallback options hook.
|
|
4
|
-
*/
|
|
5
|
-
export interface UseFallbackOptionsConfig<T extends DataOption<T> = PureDataOption, P extends ObjectType = EmptyObject, K extends string = "ids"> {
|
|
6
|
-
/**
|
|
7
|
-
* The API of fallback options.
|
|
8
|
-
*/
|
|
9
|
-
fallbackOptionsApi?: Api<QueryParamsWithValues<P, K>, T[]>;
|
|
10
|
-
/**
|
|
11
|
-
* The API params of fallback options.
|
|
12
|
-
*/
|
|
13
|
-
fallbackOptionsApiParams?: P;
|
|
14
|
-
/**
|
|
15
|
-
* The parameter name of values.
|
|
16
|
-
*/
|
|
17
|
-
valuesKey?: K;
|
|
18
|
-
/**
|
|
19
|
-
* The function to resolve fallback options.
|
|
20
|
-
*/
|
|
21
|
-
resolveFallbackOptions?: Mapper<IdValue[], MaybePromise<T[]>>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The hook to resolve fallback options.
|
|
25
|
-
*
|
|
26
|
-
* @param missingOptionValues - The missing option values.
|
|
27
|
-
* @param config - The config of the hook.
|
|
28
|
-
* @param config.fallbackOptionsApi - The API of fallback options.
|
|
29
|
-
* @param config.fallbackOptionsApiParams - The API params of fallback options.
|
|
30
|
-
* @param config.valuesKey - The parameter key of values.
|
|
31
|
-
* @param config.resolveFallbackOptions - The function to resolve fallback options.
|
|
32
|
-
* @returns The API query result.
|
|
33
|
-
*/
|
|
34
|
-
export declare function useFallbackOptions<T extends DataOption<T> = PureDataOption, P extends ObjectType = EmptyObject, K extends string = "ids">(missingOptionValues: IdValue[], { fallbackOptionsApi, fallbackOptionsApiParams, valuesKey, resolveFallbackOptions, }: UseFallbackOptionsConfig<T, P, K>): import("@vef-framework/shared").QueryResult<T[]>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { GapSize } from "@vef-framework/shared";
|
|
2
|
-
import type { CSSProperties } from "react";
|
|
3
|
-
/**
|
|
4
|
-
* The hook to normalize the gap size.
|
|
5
|
-
*
|
|
6
|
-
* @returns The function to normalize the gap size.
|
|
7
|
-
*/
|
|
8
|
-
export declare function useGapSizeNormalizer<T extends CSSProperties["gap"]>(): (gap: GapSize<T>) => number | (T & Record<never, never>);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { GapSize } from "@vef-framework/shared";
|
|
2
|
-
import type { CSSProperties } from "react";
|
|
3
|
-
/**
|
|
4
|
-
* The hook to normalize the gap size.
|
|
5
|
-
*
|
|
6
|
-
* @param gap - The gap size.
|
|
7
|
-
* @returns The normalized gap size.
|
|
8
|
-
*/
|
|
9
|
-
export declare function useNormalizedGapSize<T extends CSSProperties["gap"]>(gap: GapSize<T>): number | (T & Record<never, never>);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { MenuItem } from "@vef-framework/shared";
|
|
2
|
-
import type { ItemType } from "antd/es/menu/interface";
|
|
3
|
-
/**
|
|
4
|
-
* Normalize the menu item to the type of antd.
|
|
5
|
-
*
|
|
6
|
-
* @param item - The menu item.
|
|
7
|
-
* @returns The normalized menu item.
|
|
8
|
-
*/
|
|
9
|
-
export declare function normalizeMenuItem(item: MenuItem): ItemType;
|
|
10
|
-
/**
|
|
11
|
-
* Normalize the menu items to the type of antd.
|
|
12
|
-
*
|
|
13
|
-
* @param items - The menu items.
|
|
14
|
-
* @returns The normalized menu items.
|
|
15
|
-
*/
|
|
16
|
-
export declare function useNormalizedMenuItems<T extends readonly MenuItem[] = readonly MenuItem[]>(items: T): ItemType[];
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { DataOption, DataOptionConfig, Except, IdValue, NormalizedDataOption, PureDataOption, StringKey } from "@vef-framework/shared";
|
|
2
|
-
/**
|
|
3
|
-
* The config of the useNormalizedDataOptions hook.
|
|
4
|
-
*/
|
|
5
|
-
export interface UseNormalizedDataOptionsConfig {
|
|
6
|
-
/**
|
|
7
|
-
* Whether the options is a tree.
|
|
8
|
-
*/
|
|
9
|
-
isTree?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Whether the options are grouped.
|
|
12
|
-
*/
|
|
13
|
-
isGrouped?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Whether to parse the pinyin of the options's label and description.
|
|
16
|
-
*/
|
|
17
|
-
parsePinyin?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* The values of the selected options used to find the missing options.
|
|
20
|
-
*/
|
|
21
|
-
selectedOptionValues?: IdValue[];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The return type of the useNormalizedDataOptions hook.
|
|
25
|
-
*/
|
|
26
|
-
type UseNormalizedDataOptionsReturn<T extends DataOption<T>, F extends boolean> = F extends true ? [Array<NormalizedDataOption<T>>, IdValue[], NormalizedDataOption<T> | undefined] : [Array<NormalizedDataOption<T>>, IdValue[]];
|
|
27
|
-
/**
|
|
28
|
-
* The hook to normalize the data options.
|
|
29
|
-
*/
|
|
30
|
-
export declare function useNormalizedDataOptions<T extends DataOption<T> = PureDataOption, F extends boolean = false>(options: T[], { labelKey, valueKey, childrenKey, descriptionKey, disabledKey, defaultToFirst, }: Except<DataOptionConfig<StringKey<T>>, "defaultToFirst"> & {
|
|
31
|
-
defaultToFirst?: F;
|
|
32
|
-
}, { isTree, isGrouped, parsePinyin, selectedOptionValues, }?: UseNormalizedDataOptionsConfig): UseNormalizedDataOptionsReturn<T, F>;
|
|
33
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { DataOption, NormalizedDataOption, PureDataOption } from "@vef-framework/shared";
|
|
2
|
-
/**
|
|
3
|
-
* The hook to filter the options.
|
|
4
|
-
*
|
|
5
|
-
* @param filterable - Whether to allow filtering.
|
|
6
|
-
* @param filterFromRemote - Whether to filter from remote.
|
|
7
|
-
*/
|
|
8
|
-
export declare function useOptionFilter<T extends DataOption<T> = PureDataOption>(filterable: boolean, filterFromRemote: boolean): false | ((filterValue: string, option: NormalizedDataOption<T>) => boolean) | undefined;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EmptyObject, ObjectType, QueryParamsWithKeyword } from "@vef-framework/shared";
|
|
2
|
-
/**
|
|
3
|
-
* The hook to handle the remote filter.
|
|
4
|
-
*
|
|
5
|
-
* @param enabled - Whether to enable the remote filter.
|
|
6
|
-
* @param apiParams - The API params.
|
|
7
|
-
* @param keywordKey - The key of the keyword parameter.
|
|
8
|
-
*/
|
|
9
|
-
export declare function useRemoteFilter<P extends ObjectType = EmptyObject, K extends string = "keyword">(enabled: boolean, apiParams?: QueryParamsWithKeyword<P, K>, keywordKey?: K): readonly [QueryParamsWithKeyword<P, K> | undefined, import("radashi").DebounceFunction<[keyword: string]> | undefined];
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AnyFunction } from "@vef-framework/shared";
|
|
2
|
-
import type { DependencyList } from "react";
|
|
3
|
-
/**
|
|
4
|
-
* The hook to memoize a callback based on shallow comparison of dependencies.
|
|
5
|
-
*
|
|
6
|
-
* @param callback - The callback to be memoized.
|
|
7
|
-
* @param dependencies - The dependencies array.
|
|
8
|
-
* @returns The memoized callback.
|
|
9
|
-
*/
|
|
10
|
-
export declare function useShallowCallback<T extends AnyFunction>(callback: T, dependencies: DependencyList): T;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Provider } from "@vef-framework/shared";
|
|
2
|
-
import type { DependencyList } from "react";
|
|
3
|
-
/**
|
|
4
|
-
* The hook to memoize a value based on shallow comparison of dependencies.
|
|
5
|
-
*
|
|
6
|
-
* @param factory - The factory function to create the value.
|
|
7
|
-
* @param dependencies - The dependencies array.
|
|
8
|
-
* @returns The memoized value.
|
|
9
|
-
*/
|
|
10
|
-
export declare function useShallowMemo<T>(factory: Provider<T>, dependencies: DependencyList): T;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Mapper } from "@vef-framework/shared";
|
|
2
|
-
/**
|
|
3
|
-
* A hook that memoizes a selector based on shallow comparison of the state.
|
|
4
|
-
*
|
|
5
|
-
* @param selector - The selector to be memoized.
|
|
6
|
-
* @returns The memoized selector.
|
|
7
|
-
*/
|
|
8
|
-
export declare function useShallowSelector<S, T>(selector: Mapper<S, T>): Mapper<S, T>;
|
package/types/use-singleton.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { BiConsumer, BiMapper, Mapper, UnboundStoreApi } from "@vef-framework/shared";
|
|
2
|
-
import type { MutableRefObject } from "react";
|
|
3
|
-
type Subscribable<T> = Pick<UnboundStoreApi<T>, "subscribe" | "getState">;
|
|
4
|
-
/**
|
|
5
|
-
* The options for the useTransientStore hook
|
|
6
|
-
*/
|
|
7
|
-
export interface UseTransientStoreOptions<T, U> {
|
|
8
|
-
/**
|
|
9
|
-
* The selector to use for the transient store
|
|
10
|
-
*/
|
|
11
|
-
selector?: Mapper<T, U>;
|
|
12
|
-
/**
|
|
13
|
-
* The equality function to use for the transient store
|
|
14
|
-
*/
|
|
15
|
-
equalityFn?: BiMapper<U, U, boolean>;
|
|
16
|
-
/**
|
|
17
|
-
* The listener to use for the transient store
|
|
18
|
-
*/
|
|
19
|
-
listener?: BiConsumer<U, U>;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The hook to use for the transient store
|
|
23
|
-
*
|
|
24
|
-
* @param store - The store to use for the transient store
|
|
25
|
-
* @param store.subscribe - The subscribe function to use for the transient store
|
|
26
|
-
* @param store.getState - The getState function to use for the transient store
|
|
27
|
-
* @param options - The options for the transient store
|
|
28
|
-
* @param options.selector - The selector to use for the transient store
|
|
29
|
-
* @param options.equalityFn - The equality function to use for the transient store
|
|
30
|
-
* @param options.listener - The listener to use for the transient store
|
|
31
|
-
* @returns The transient state ref
|
|
32
|
-
*/
|
|
33
|
-
export declare function useTransientStore<T, U = T>({ subscribe, getState }: Subscribable<T>, { selector, equalityFn, listener, }?: UseTransientStoreOptions<T, U>): MutableRefObject<U>;
|
|
34
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The size of the window.
|
|
3
|
-
*/
|
|
4
|
-
export interface WindowSize {
|
|
5
|
-
/**
|
|
6
|
-
* The width of the window.
|
|
7
|
-
*/
|
|
8
|
-
width: number;
|
|
9
|
-
/**
|
|
10
|
-
* The height of the window.
|
|
11
|
-
*/
|
|
12
|
-
height: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The hook to get the size of the window.
|
|
16
|
-
*/
|
|
17
|
-
export declare function useWindowSize(): WindowSize;
|