@base-stone/hooks 1.2.6 → 1.2.7
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.
|
@@ -72,11 +72,11 @@ declare type PickFunction<T extends noop> = (this: ThisParameterType<T>, ...args
|
|
|
72
72
|
|
|
73
73
|
declare type Placement = 'top' | 'bottom' | 'left' | 'right';
|
|
74
74
|
|
|
75
|
-
declare interface QueryOptions<T = Record<string, any>> {
|
|
75
|
+
declare interface QueryOptions<K extends string, T = Record<string, any>> {
|
|
76
76
|
queryFn: (data: QueryParamsData_2) => Promise<QueryResponse_2<T>>;
|
|
77
77
|
params?: Record<string, any> | undefined;
|
|
78
78
|
dataType: DataType;
|
|
79
|
-
dataKey:
|
|
79
|
+
dataKey: K;
|
|
80
80
|
transform?: (result: Record<string, any>) => Record<string, any>[];
|
|
81
81
|
initialValue?: Record<string, any> | Record<string, any>[];
|
|
82
82
|
}
|
|
@@ -101,11 +101,11 @@ declare interface QueryResponse_2<T> {
|
|
|
101
101
|
data: T;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
declare type QueryResult<T = Record<string, any>> = {
|
|
104
|
+
declare type QueryResult<K extends string, T = Record<string, any>> = {
|
|
105
105
|
loading: boolean;
|
|
106
106
|
refresh: (params?: Record<string, any> | undefined) => void;
|
|
107
107
|
} & {
|
|
108
|
-
[P in
|
|
108
|
+
[P in K]?: T;
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
declare interface RequestFn {
|
|
@@ -133,13 +133,13 @@ declare type SelectOption<K extends string | number = string | number> = {
|
|
|
133
133
|
[key: string]: any;
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
declare type SelectOptionsResult<K extends string | number> = Readonly<{
|
|
136
|
+
declare type SelectOptionsResult<K extends string, V extends string | number = string | number> = Readonly<{
|
|
137
137
|
loading: boolean;
|
|
138
138
|
refresh: () => void;
|
|
139
139
|
} & {
|
|
140
|
-
[P in `${
|
|
140
|
+
[P in `${K}Options`]: (SelectOption<V> & Record<string, any>)[];
|
|
141
141
|
} & {
|
|
142
|
-
[P in `${
|
|
142
|
+
[P in `${K}Map`]?: MapData<V>;
|
|
143
143
|
}>;
|
|
144
144
|
|
|
145
145
|
declare interface SuccessFn {
|
|
@@ -200,9 +200,9 @@ export declare function useFormSubmit(requestFn: RequestFn, successFn: SuccessFn
|
|
|
200
200
|
|
|
201
201
|
export declare function useMemoizedFn<T extends noop>(fn: T): PickFunction<T>;
|
|
202
202
|
|
|
203
|
-
export declare function useRequestQuery<T = Record<string, any> | Record<string, any>[] | undefined>({ queryFn, params, dataType, dataKey, initialValue, transform }: QueryOptions<T>): QueryResult<T>;
|
|
203
|
+
export declare function useRequestQuery<T = Record<string, any> | Record<string, any>[] | undefined>({ queryFn, params, dataType, dataKey, initialValue, transform }: QueryOptions<typeof dataKey, T>): QueryResult<typeof dataKey, T>;
|
|
204
204
|
|
|
205
|
-
export declare function useSelectOptions<
|
|
205
|
+
export declare function useSelectOptions<V extends string | number = string | number>({ queryFn, params, dataKey, fieldNames, transform }: SelectConfig): SelectOptionsResult<typeof dataKey, V>;
|
|
206
206
|
|
|
207
207
|
export declare function useTableList<T extends Record<string, any> = Record<string, any>>({ queryFn, params: initParams, transform, rowSelection }: TableOptions<T>): TableResult<T>;
|
|
208
208
|
|