@base-stone/hooks 1.2.1 → 1.2.2
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,7 +72,7 @@ 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<K extends string = string, T = Record<string, any
|
|
75
|
+
declare interface QueryOptions<K extends string = 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;
|
|
@@ -101,7 +101,7 @@ declare interface QueryResponse_2<T> {
|
|
|
101
101
|
data: T;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
declare type QueryResult<K extends string = string, T = Record<string, any
|
|
104
|
+
declare type QueryResult<K extends string = string, T = Record<string, any>> = {
|
|
105
105
|
loading: boolean;
|
|
106
106
|
refresh: (params?: Record<string, any> | undefined) => void;
|
|
107
107
|
} & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef as F, useMemo as J, useState as S, useEffectEvent as N, useEffect as
|
|
1
|
+
import { useRef as F, useMemo as J, useState as S, useEffectEvent as N, useEffect as D, useId as U, useCallback as W } from "react";
|
|
2
2
|
import { Empty as j, App as X } from "antd";
|
|
3
3
|
import { create as K } from "zustand";
|
|
4
4
|
var O = { exports: {} }, C = {};
|
|
@@ -79,7 +79,7 @@ function ce({
|
|
|
79
79
|
c(!0);
|
|
80
80
|
const M = { ...a, pageSize: i, ...d };
|
|
81
81
|
d.pageNo === void 0 && (M.pageNo = 1), d.pageSize === void 0 && (M.pageSize = i);
|
|
82
|
-
const { data:
|
|
82
|
+
const { data: T } = await n(M), { list: P = [], totalCount: k = 0 } = T || {};
|
|
83
83
|
t && g([]), r({
|
|
84
84
|
list: P,
|
|
85
85
|
queryParams: M,
|
|
@@ -90,16 +90,16 @@ function ce({
|
|
|
90
90
|
total: k
|
|
91
91
|
}
|
|
92
92
|
}), c(!1);
|
|
93
|
-
},
|
|
93
|
+
}, $ = N(() => {
|
|
94
94
|
v({ ...l, pageNo: 1 });
|
|
95
95
|
}), R = (d) => {
|
|
96
96
|
v({ ...l, ...d, pageNo: 1 });
|
|
97
|
-
},
|
|
97
|
+
}, w = (d) => {
|
|
98
98
|
v({ ...l, ...d });
|
|
99
99
|
}, h = (d) => {
|
|
100
100
|
v({ ...d, pageSize: i, pageNo: 1 });
|
|
101
|
-
}, H = (d, _, M,
|
|
102
|
-
const { action: P } =
|
|
101
|
+
}, H = (d, _, M, T) => {
|
|
102
|
+
const { action: P } = T;
|
|
103
103
|
if (["paginate", "sort"].includes(P)) {
|
|
104
104
|
const { current: k, pageSize: I } = d, { field: G, order: A } = M, [V, Q] = z.sortField, [Y, Z] = z.sortOrder, B = {
|
|
105
105
|
...l,
|
|
@@ -111,12 +111,12 @@ function ce({
|
|
|
111
111
|
v(B);
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
-
return
|
|
115
|
-
|
|
114
|
+
return D(() => {
|
|
115
|
+
$();
|
|
116
116
|
}, []), {
|
|
117
117
|
queryParams: l,
|
|
118
118
|
search: y(R),
|
|
119
|
-
refresh: y(
|
|
119
|
+
refresh: y(w),
|
|
120
120
|
reset: y(h),
|
|
121
121
|
selectedRowKeys: m,
|
|
122
122
|
tableProps: {
|
|
@@ -166,7 +166,7 @@ const x = K((n) => ({
|
|
|
166
166
|
}));
|
|
167
167
|
function le(n) {
|
|
168
168
|
const a = x((o) => o.modals), t = x((o) => o.toggleModal), e = x((o) => o.setModal), s = x((o) => o.clearModals), r = U(), u = F([]), p = Object.keys(n);
|
|
169
|
-
|
|
169
|
+
D(() => (u.current = p.map(
|
|
170
170
|
(o) => `${r}-${o}`
|
|
171
171
|
), () => {
|
|
172
172
|
s(u.current);
|
|
@@ -214,21 +214,21 @@ function de({ queryFn: n, params: a, dataKey: t, fieldNames: e, transform: s })
|
|
|
214
214
|
mapData: /* @__PURE__ */ new Map()
|
|
215
215
|
}), [p, l] = S(!0), o = async () => {
|
|
216
216
|
l(!0);
|
|
217
|
-
const g = await n(a), E = (s ? s(g) : g
|
|
217
|
+
const { data: g } = await n(a), E = (s ? s(g) : g) || [];
|
|
218
218
|
if (e) {
|
|
219
|
-
const { label: v, value:
|
|
219
|
+
const { label: v, value: $ } = e, R = E.map((h) => ({
|
|
220
220
|
data: h,
|
|
221
221
|
label: h[v],
|
|
222
|
-
value: h[
|
|
223
|
-
})),
|
|
224
|
-
u((h) => ({ ...h, list: R, mapData:
|
|
222
|
+
value: h[$]
|
|
223
|
+
})), w = oe(R);
|
|
224
|
+
u((h) => ({ ...h, list: R, mapData: w }));
|
|
225
225
|
} else
|
|
226
226
|
u((v) => ({ ...v, list: E }));
|
|
227
227
|
l(!1);
|
|
228
228
|
}, i = N(o), f = y(() => {
|
|
229
229
|
o();
|
|
230
230
|
});
|
|
231
|
-
|
|
231
|
+
D(() => {
|
|
232
232
|
i();
|
|
233
233
|
}, []);
|
|
234
234
|
const { list: c, mapData: m } = r;
|
|
@@ -264,10 +264,10 @@ function pe({
|
|
|
264
264
|
}) {
|
|
265
265
|
const u = s || (t === "Array" ? [] : /* @__PURE__ */ Object.create({})), [p, l] = S(u), [o, i] = S(!1), f = async (g) => {
|
|
266
266
|
i(!0);
|
|
267
|
-
const b = await n(g ?? a), E = r ? r(b) : b
|
|
267
|
+
const { data: b } = await n(g ?? a), E = r ? r(b) : b;
|
|
268
268
|
l(E), i(!1);
|
|
269
269
|
}, c = N(f);
|
|
270
|
-
|
|
270
|
+
D(() => {
|
|
271
271
|
c();
|
|
272
272
|
}, []);
|
|
273
273
|
const m = y((g) => {
|