@base-stone/hooks 1.2.5 → 1.2.6
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.
|
@@ -137,9 +137,9 @@ declare type SelectOptionsResult<K extends string | number> = Readonly<{
|
|
|
137
137
|
loading: boolean;
|
|
138
138
|
refresh: () => void;
|
|
139
139
|
} & {
|
|
140
|
-
[P in `${
|
|
140
|
+
[P in `${string}Options`]: (SelectOption<K> & Record<string, any>)[];
|
|
141
141
|
} & {
|
|
142
|
-
[P in `${
|
|
142
|
+
[P in `${string}Map`]?: MapData<K>;
|
|
143
143
|
}>;
|
|
144
144
|
|
|
145
145
|
declare interface SuccessFn {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef as _, useMemo as I, useState as
|
|
1
|
+
import { useRef as _, useMemo as I, useState as S, useEffectEvent as j, useEffect as P, useId as W, useCallback as X } from "react";
|
|
2
2
|
import { Empty as q, App as K } from "antd";
|
|
3
3
|
import { create as ee } from "zustand";
|
|
4
4
|
var N = { exports: {} }, R = {};
|
|
@@ -53,7 +53,7 @@ function ce({
|
|
|
53
53
|
transform: s,
|
|
54
54
|
rowSelection: t
|
|
55
55
|
}) {
|
|
56
|
-
const o = T.pageSize, [n, u] =
|
|
56
|
+
const o = T.pageSize, [n, u] = S({
|
|
57
57
|
pagination: {
|
|
58
58
|
showSizeChanger: !0,
|
|
59
59
|
showQuickJumper: !0,
|
|
@@ -67,7 +67,7 @@ function ce({
|
|
|
67
67
|
pageSize: o,
|
|
68
68
|
...a
|
|
69
69
|
}
|
|
70
|
-
}), { pagination: c, list: f, queryParams: e } = n, { pageNo: l, pageSize: p } = e, [i, m] =
|
|
70
|
+
}), { pagination: c, list: f, queryParams: e } = n, { pageNo: l, pageSize: p } = e, [i, m] = S(!0), [g, y] = S([]), b = I(() => {
|
|
71
71
|
if (t)
|
|
72
72
|
return {
|
|
73
73
|
selectedRowKeys: g,
|
|
@@ -75,7 +75,7 @@ function ce({
|
|
|
75
75
|
};
|
|
76
76
|
}, [t, g]), x = E(
|
|
77
77
|
(d) => `共 ${d} 条记录 第 ${l}/${Math.ceil(d / p)} 页 `
|
|
78
|
-
),
|
|
78
|
+
), h = async (d) => {
|
|
79
79
|
const { pageNo: A } = d;
|
|
80
80
|
m(!0);
|
|
81
81
|
const M = { ...a, pageSize: p, ...d };
|
|
@@ -92,13 +92,13 @@ function ce({
|
|
|
92
92
|
}
|
|
93
93
|
}), m(!1);
|
|
94
94
|
}, z = j(() => {
|
|
95
|
-
|
|
95
|
+
h({ ...e, pageNo: 1 });
|
|
96
96
|
}), C = (d) => {
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
|
|
97
|
+
h({ ...e, ...d, pageNo: 1 });
|
|
98
|
+
}, v = (d) => {
|
|
99
|
+
h({ ...e, ...d });
|
|
100
100
|
}, D = (d) => {
|
|
101
|
-
|
|
101
|
+
h({ ...d, pageSize: p, pageNo: 1 });
|
|
102
102
|
}, V = (d, A, M, $) => {
|
|
103
103
|
const { action: k } = $;
|
|
104
104
|
if (["paginate", "sort"].includes(k)) {
|
|
@@ -109,7 +109,7 @@ function ce({
|
|
|
109
109
|
pageNo: O,
|
|
110
110
|
pageSize: F
|
|
111
111
|
};
|
|
112
|
-
|
|
112
|
+
h(U);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
return P(() => {
|
|
@@ -117,7 +117,7 @@ function ce({
|
|
|
117
117
|
}, []), {
|
|
118
118
|
queryParams: e,
|
|
119
119
|
search: E(C),
|
|
120
|
-
refresh: E(
|
|
120
|
+
refresh: E(v),
|
|
121
121
|
reset: E(D),
|
|
122
122
|
selectedRowKeys: g,
|
|
123
123
|
tableProps: {
|
|
@@ -209,22 +209,22 @@ function le(r) {
|
|
|
209
209
|
}, f;
|
|
210
210
|
}
|
|
211
211
|
function de({ queryFn: r, params: a, dataKey: s, fieldNames: t, transform: o }) {
|
|
212
|
-
const [n, u] =
|
|
212
|
+
const [n, u] = S({
|
|
213
213
|
list: [],
|
|
214
214
|
mapData: /* @__PURE__ */ new Map()
|
|
215
|
-
}), [c, f] =
|
|
215
|
+
}), [c, f] = S(!0), e = async () => {
|
|
216
216
|
f(!0);
|
|
217
|
-
const { data: g } = await r(a), b = (o ? o(g) : g) || [], { label: x, value:
|
|
217
|
+
const { data: g } = await r(a), b = (o ? o(g) : g) || [], { label: x, value: h } = t, z = /* @__PURE__ */ new Map([]);
|
|
218
218
|
if (t) {
|
|
219
|
-
const C = b.map((
|
|
220
|
-
const D = h
|
|
221
|
-
return z.set(D, x), {
|
|
222
|
-
label:
|
|
219
|
+
const C = b.map((v) => {
|
|
220
|
+
const D = v[h];
|
|
221
|
+
return z.set(D, v[x]), {
|
|
222
|
+
label: v[x],
|
|
223
223
|
value: D,
|
|
224
|
-
data:
|
|
224
|
+
data: v
|
|
225
225
|
};
|
|
226
226
|
});
|
|
227
|
-
u((
|
|
227
|
+
u((v) => ({ ...v, list: C, mapData: z }));
|
|
228
228
|
} else
|
|
229
229
|
u((C) => ({ ...C, list: b }));
|
|
230
230
|
f(!1);
|
|
@@ -243,7 +243,7 @@ function de({ queryFn: r, params: a, dataKey: s, fieldNames: t, transform: o })
|
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
245
|
function ue(r, a) {
|
|
246
|
-
const [s, t] =
|
|
246
|
+
const [s, t] = S(!1), { message: o } = K.useApp(), n = X(async (u) => {
|
|
247
247
|
try {
|
|
248
248
|
t(!0);
|
|
249
249
|
const c = await r(u), { status: f, info: e } = c;
|
|
@@ -265,7 +265,7 @@ function pe({
|
|
|
265
265
|
initialValue: o,
|
|
266
266
|
transform: n
|
|
267
267
|
}) {
|
|
268
|
-
const u = o || (s === "Array" ? [] : /* @__PURE__ */ Object.create({})), [c, f] =
|
|
268
|
+
const u = o || (s === "Array" ? [] : /* @__PURE__ */ Object.create({})), [c, f] = S(u), [e, l] = S(!1), p = async (g) => {
|
|
269
269
|
l(!0);
|
|
270
270
|
const { data: y } = await r(g ?? a), b = n ? n(y) : y;
|
|
271
271
|
f(b), l(!1);
|