@base-stone/hooks 1.0.4 → 1.0.5
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.
|
@@ -10,6 +10,8 @@ import { TableProps as TableProps_2 } from 'antd';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function configureTableOption(config: GlobalTableConfig): void;
|
|
12
12
|
|
|
13
|
+
declare type DataType = 'Array' | 'Object';
|
|
14
|
+
|
|
13
15
|
export declare interface DrawerProps {
|
|
14
16
|
size: number | 'default' | 'large';
|
|
15
17
|
title: string | ReactElement;
|
|
@@ -97,10 +99,10 @@ declare interface RequestFn {
|
|
|
97
99
|
}>;
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
declare interface RequestQueryOptions<K extends string = string, T = Record<string, any
|
|
102
|
+
declare interface RequestQueryOptions<K extends string = string, T = Record<string, any> | Record<string, any>[]> {
|
|
101
103
|
queryFn: (data: QueryParamsData_2) => Promise<QueryResponse_2<T>>;
|
|
102
|
-
initialValue?: T;
|
|
103
104
|
params?: Record<string, any>;
|
|
105
|
+
dataType: DataType;
|
|
104
106
|
dataKey: K;
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -193,7 +195,7 @@ export declare function useFormSubmit(requestFn: RequestFn, successFn: SuccessFn
|
|
|
193
195
|
|
|
194
196
|
export declare function useMemoizedFn<T extends noop>(fn: T): PickFunction<T>;
|
|
195
197
|
|
|
196
|
-
export declare function useRequestQuery<K extends string = string, T = Record<string, any
|
|
198
|
+
export declare function useRequestQuery<K extends string = string, T = Record<string, any> | Record<string, any>[]>({ queryFn, params, dataType, dataKey }: RequestQueryOptions<K, T>): RequestQueryResult<K, T>;
|
|
197
199
|
|
|
198
200
|
export declare function useSelectOptions<T extends string | number = string | number, K extends string = string>({ queryFn, params, dataKey, fieldNames }: SelectConfig<K>): SelectOptionsResult<K, T>;
|
|
199
201
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useRef as x, useMemo as
|
|
2
|
-
import { Empty as
|
|
1
|
+
import { useRef as x, useMemo as q, useState as v, useEffect as D, useId as B, useCallback as U } from "react";
|
|
2
|
+
import { Empty as A, App as W } from "antd";
|
|
3
3
|
import { create as X } from "zustand";
|
|
4
4
|
var P = { exports: {} }, y = {};
|
|
5
|
-
var
|
|
5
|
+
var N;
|
|
6
6
|
function K() {
|
|
7
|
-
if (
|
|
8
|
-
|
|
7
|
+
if (N) return y;
|
|
8
|
+
N = 1;
|
|
9
9
|
var a = /* @__PURE__ */ Symbol.for("react.transitional.element"), o = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
10
10
|
function t(e, s, n) {
|
|
11
11
|
var p = null;
|
|
@@ -24,14 +24,14 @@ function K() {
|
|
|
24
24
|
}
|
|
25
25
|
return y.Fragment = o, y.jsx = t, y.jsxs = t, y;
|
|
26
26
|
}
|
|
27
|
-
var
|
|
27
|
+
var j;
|
|
28
28
|
function ee() {
|
|
29
|
-
return
|
|
29
|
+
return j || (j = 1, P.exports = K()), P.exports;
|
|
30
30
|
}
|
|
31
31
|
var te = ee();
|
|
32
32
|
function M(a) {
|
|
33
33
|
const o = x(a);
|
|
34
|
-
o.current =
|
|
34
|
+
o.current = q(() => a, [a]);
|
|
35
35
|
const t = x(void 0);
|
|
36
36
|
return t.current || (t.current = function(...e) {
|
|
37
37
|
return o.current.apply(this, e);
|
|
@@ -66,7 +66,7 @@ function ie({
|
|
|
66
66
|
pageSize: e,
|
|
67
67
|
...o
|
|
68
68
|
}
|
|
69
|
-
}), { pagination: p, list: d, queryParams: l } = s, { pageNo: r, pageSize: c } = l, [g, i] = v(!0), S = x(l), [f, b] = v([]), E =
|
|
69
|
+
}), { pagination: p, list: d, queryParams: l } = s, { pageNo: r, pageSize: c } = l, [g, i] = v(!0), S = x(l), [f, b] = v([]), E = q(() => {
|
|
70
70
|
if (t)
|
|
71
71
|
return {
|
|
72
72
|
selectedRowKeys: f,
|
|
@@ -92,9 +92,9 @@ function ie({
|
|
|
92
92
|
}), i(!1);
|
|
93
93
|
}, k = (u) => {
|
|
94
94
|
m({ ...l, ...u, pageNo: 1 });
|
|
95
|
-
},
|
|
95
|
+
}, F = (u) => {
|
|
96
96
|
m({ ...l, ...u });
|
|
97
|
-
},
|
|
97
|
+
}, L = (u) => {
|
|
98
98
|
m({ ...u, pageSize: c, pageNo: 1 });
|
|
99
99
|
}, J = (u, O, h, $) => {
|
|
100
100
|
const { action: T } = $;
|
|
@@ -114,8 +114,8 @@ function ie({
|
|
|
114
114
|
}, []), {
|
|
115
115
|
queryParams: l,
|
|
116
116
|
search: M(k),
|
|
117
|
-
refresh: M(
|
|
118
|
-
reset: M(
|
|
117
|
+
refresh: M(F),
|
|
118
|
+
reset: M(L),
|
|
119
119
|
selectedRowKeys: f,
|
|
120
120
|
tableProps: {
|
|
121
121
|
bordered: !0,
|
|
@@ -127,7 +127,7 @@ function ie({
|
|
|
127
127
|
pagination: { ...p, showTotal: z },
|
|
128
128
|
onChange: M(J),
|
|
129
129
|
locale: {
|
|
130
|
-
emptyText: g ? "" : /* @__PURE__ */ te.jsx(
|
|
130
|
+
emptyText: g ? "" : /* @__PURE__ */ te.jsx(A, { image: A.PRESENTED_IMAGE_SIMPLE })
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
};
|
|
@@ -253,10 +253,10 @@ function ue(a, o) {
|
|
|
253
253
|
function de({
|
|
254
254
|
queryFn: a,
|
|
255
255
|
params: o,
|
|
256
|
-
|
|
256
|
+
dataType: t,
|
|
257
257
|
dataKey: e
|
|
258
258
|
}) {
|
|
259
|
-
const [s, n] = v(t), [p, d] = v(!1);
|
|
259
|
+
const [s, n] = v(t === "Array" ? [] : /* @__PURE__ */ Object.create(null)), [p, d] = v(!1);
|
|
260
260
|
return {
|
|
261
261
|
[e]: s,
|
|
262
262
|
loading: p,
|