@base-stone/hooks 0.7.4 → 0.7.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.
@@ -9,12 +9,27 @@ import { TableProps as TableProps_2 } from 'antd';
9
9
  */
10
10
  export declare function configureTableOption(config: GlobalTableConfig): void;
11
11
 
12
+ declare interface FormSubmitResult {
13
+ loading: boolean;
14
+ submit: (number?: unknown) => void;
15
+ }
16
+
12
17
  declare interface GlobalTableConfig {
13
18
  sortField: string[];
14
19
  sortOrder: string[];
15
20
  pageSize: number;
16
21
  }
17
22
 
23
+ declare type MapData<T extends string | number = string | number> = Map<T, string | number | undefined>;
24
+
25
+ declare type ModalInstance<T = any> = {
26
+ visible: boolean;
27
+ data: T;
28
+ toggle: (data?: T) => void;
29
+ open: (data?: T) => void;
30
+ close: () => void;
31
+ };
32
+
18
33
  export declare interface QueryParamsData {
19
34
  pageNo: number;
20
35
  pageSize: number;
@@ -23,6 +38,41 @@ export declare interface QueryParamsData {
23
38
  [key: string]: any;
24
39
  }
25
40
 
41
+ declare interface RequestFn {
42
+ (val?: unknown): Promise<{
43
+ status: string;
44
+ info: string;
45
+ }>;
46
+ }
47
+
48
+ declare interface SelectConfig<K> {
49
+ params?: Record<string, any>;
50
+ selectKey: K;
51
+ fieldNames?: {
52
+ label: string;
53
+ value: string;
54
+ };
55
+ }
56
+
57
+ declare type SelectOption<T extends string | number = string | number> = {
58
+ label: string;
59
+ value: T;
60
+ data?: Record<string, unknown>;
61
+ };
62
+
63
+ declare type SelectOptionsResult<K extends string, T extends string | number> = {
64
+ loading: boolean;
65
+ refresh: () => void;
66
+ } & {
67
+ [P in `${K}Options`]: (SelectOption<T> & Record<string, any>)[];
68
+ } & {
69
+ [P in `${K}Map`]: MapData<T>;
70
+ };
71
+
72
+ declare interface SuccessFn {
73
+ (data: Record<string, any>): void;
74
+ }
75
+
26
76
  declare interface TableListResult<T> {
27
77
  /** 查询参数 */
28
78
  queryParams: QueryParamsData;
@@ -58,6 +108,21 @@ declare interface TableResponse<T> {
58
108
  };
59
109
  }
60
110
 
111
+ /**
112
+ * 批量创建多个模态框 hook
113
+ * @param suffixes 模态框后缀数组
114
+ * @returns 包含所有模态框实例的对象,以及统一的 toggle/open/close 函数
115
+ */
116
+ export declare function useCreateModal<T extends readonly string[]>(suffixes: T): Record<`${T[number]}Modal`, ModalInstance> & {
117
+ toggle: (type: T[number], data?: any) => void;
118
+ open: (type: T[number], data?: any) => void;
119
+ close: (type: T[number]) => void;
120
+ };
121
+
122
+ export declare function useFormSubmit(requestFn: RequestFn, successFn: SuccessFn): FormSubmitResult;
123
+
124
+ export declare function useSelectOptions<K extends string = string, T extends string | number = string | number>(getRequestFn: (params: Record<string, any>) => Promise<any>, selectConfig: SelectConfig<K>): SelectOptionsResult<K, T>;
125
+
61
126
  export declare function useTableList<T>(getRequestFn: (data: QueryParamsData) => Promise<TableResponse<T>>, initParams?: Record<string, any>): TableListResult<T>;
62
127
 
63
128
  export { }
@@ -1,141 +1,245 @@
1
- import { useState as z, useRef as B, useMemo as q, useCallback as d, useEffect as H } from "react";
2
- import { Empty as A } from "antd";
3
- var T = { exports: {} }, S = {};
4
- var F;
5
- function U() {
6
- if (F) return S;
7
- F = 1;
8
- var n = /* @__PURE__ */ Symbol.for("react.transitional.element"), l = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function i(p, t, o) {
10
- var g = null;
11
- if (o !== void 0 && (g = "" + o), t.key !== void 0 && (g = "" + t.key), "key" in t) {
12
- o = {};
13
- for (var a in t)
14
- a !== "key" && (o[a] = t[a]);
15
- } else o = t;
16
- return t = o.ref, {
17
- $$typeof: n,
18
- type: p,
19
- key: g,
20
- ref: t !== void 0 ? t : null,
21
- props: o
1
+ import { useState as M, useRef as J, useMemo as j, useCallback as m, useEffect as C, useId as W } from "react";
2
+ import { Empty as q, App as X } from "antd";
3
+ import { create as K } from "zustand";
4
+ var k = { exports: {} }, x = {};
5
+ var D;
6
+ function ee() {
7
+ if (D) return x;
8
+ D = 1;
9
+ var i = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
10
+ function a(e, s, n) {
11
+ var d = null;
12
+ if (n !== void 0 && (d = "" + n), s.key !== void 0 && (d = "" + s.key), "key" in s) {
13
+ n = {};
14
+ for (var l in s)
15
+ l !== "key" && (n[l] = s[l]);
16
+ } else n = s;
17
+ return s = n.ref, {
18
+ $$typeof: i,
19
+ type: e,
20
+ key: d,
21
+ ref: s !== void 0 ? s : null,
22
+ props: n
22
23
  };
23
24
  }
24
- return S.Fragment = l, S.jsx = i, S.jsxs = i, S;
25
+ return x.Fragment = r, x.jsx = a, x.jsxs = a, x;
25
26
  }
26
- var J;
27
- function W() {
28
- return J || (J = 1, T.exports = U()), T.exports;
27
+ var I;
28
+ function te() {
29
+ return I || (I = 1, k.exports = ee()), k.exports;
29
30
  }
30
- var X = W();
31
- const f = {
31
+ var oe = te();
32
+ const b = {
32
33
  sortField: ["orderType", "orderField"],
33
34
  sortOrder: ["ASC", "DESC"],
34
35
  pageSize: 15
35
36
  };
36
- function te(n) {
37
- Object.keys(n).forEach((l) => {
38
- f[l] = n[l];
37
+ function ie(i) {
38
+ Object.keys(i).forEach((r) => {
39
+ b[r] = i[r];
39
40
  });
40
41
  }
41
- function re(n, l = {}) {
42
- const { rowSelection: i, ...p } = l, t = f.pageSize, [o, g] = z({
42
+ function le(i, r = {}) {
43
+ const { rowSelection: a, ...e } = r, s = b.pageSize, [n, d] = M({
43
44
  pagination: {
44
45
  showSizeChanger: !0,
45
46
  showQuickJumper: !0,
46
47
  total: 0,
47
- pageSize: t,
48
+ pageSize: s,
48
49
  current: 1
49
50
  },
50
51
  list: [],
51
52
  queryParams: {
52
53
  pageNo: 1,
53
- pageSize: t,
54
- ...p
54
+ pageSize: s,
55
+ ...e
55
56
  }
56
- }), { pagination: a, list: P, queryParams: r } = o, { pageNo: h, pageSize: u } = r, [E, y] = z(!0), L = B(r), [m, C] = z([]), N = q(() => {
57
- if (i)
57
+ }), { pagination: l, list: o, queryParams: t } = n, { pageNo: p, pageSize: u } = t, [f, R] = M(!0), $ = J(t), [y, h] = M([]), E = j(() => {
58
+ if (a)
58
59
  return {
59
- selectedRowKeys: m,
60
- onChange: (e) => C(e)
60
+ selectedRowKeys: y,
61
+ onChange: (c) => h(c)
61
62
  };
62
- }, [i, m]), _ = d(
63
- (e) => `共 ${e} 条记录 第 ${h}/${Math.ceil(e / u)} 页 `,
64
- [h, u]
65
- ), s = d(
66
- async (e) => {
67
- const { pageNo: w } = e;
68
- y(!0);
69
- const c = { ...p, pageSize: u, ...e };
70
- e.pageNo === void 0 && (c.pageNo = 1), e.pageSize === void 0 && (c.pageSize = u);
71
- const { data: x } = await n(c), { list: R = [], totalCount: v = 0 } = x || {};
72
- i && C([]), g({
73
- list: R,
74
- queryParams: c,
63
+ }, [a, y]), v = m(
64
+ (c) => `共 ${c} 条记录 第 ${p}/${Math.ceil(c / u)} 页 `,
65
+ [p, u]
66
+ ), g = m(
67
+ async (c) => {
68
+ const { pageNo: _ } = c;
69
+ R(!0);
70
+ const S = { ...e, pageSize: u, ...c };
71
+ c.pageNo === void 0 && (S.pageNo = 1), c.pageSize === void 0 && (S.pageSize = u);
72
+ const { data: z } = await i(S), { list: w = [], totalCount: P = 0 } = z || {};
73
+ a && h([]), d({
74
+ list: w,
75
+ queryParams: S,
75
76
  pagination: {
76
- ...a,
77
- current: w,
78
- pageSize: c.pageSize,
79
- total: v
77
+ ...l,
78
+ current: _,
79
+ pageSize: S.pageSize,
80
+ total: P
80
81
  }
81
- }), y(!1);
82
+ }), R(!1);
82
83
  },
83
- [r, p, i, u, n, a]
84
- ), M = d(
85
- (e) => {
86
- s({ ...r, ...e, pageNo: 1 });
84
+ [t, e, a, u, i, l]
85
+ ), L = m(
86
+ (c) => {
87
+ g({ ...t, ...c, pageNo: 1 });
87
88
  },
88
- [s, r]
89
- ), b = d(
90
- (e) => {
91
- s({ ...r, ...e });
89
+ [g, t]
90
+ ), O = m(
91
+ (c) => {
92
+ g({ ...t, ...c });
92
93
  },
93
- [s, r]
94
- ), I = d(
95
- (e) => {
96
- s({ ...e, pageSize: u, pageNo: 1 });
94
+ [g, t]
95
+ ), F = m(
96
+ (c) => {
97
+ g({ ...c, pageSize: u, pageNo: 1 });
97
98
  },
98
- [s, u]
99
- ), k = d(
100
- (e, w, c, x) => {
101
- const { action: R } = x;
102
- if (["paginate", "sort"].includes(R)) {
103
- const { current: v, pageSize: D } = e, { field: O, order: j } = c, [G, Q] = f.sortField, [V, Y] = f.sortOrder, Z = {
104
- ...r,
105
- [G]: j ? j === "ascend" ? V : Y : void 0,
106
- [Q]: O,
107
- pageNo: v,
108
- pageSize: D
99
+ [g, u]
100
+ ), N = m(
101
+ (c, _, S, z) => {
102
+ const { action: w } = z;
103
+ if (["paginate", "sort"].includes(w)) {
104
+ const { current: P, pageSize: V } = c, { field: Q, order: A } = S, [Y, Z] = b.sortField, [B, H] = b.sortOrder, U = {
105
+ ...t,
106
+ [Y]: A ? A === "ascend" ? B : H : void 0,
107
+ [Z]: Q,
108
+ pageNo: P,
109
+ pageSize: V
109
110
  };
110
- s(Z);
111
+ g(U);
111
112
  }
112
113
  },
113
- [r, s]
114
- ), $ = q(() => ({
114
+ [t, g]
115
+ ), G = j(() => ({
115
116
  bordered: !0,
116
117
  size: "middle",
117
118
  sticky: !0,
118
- rowSelection: N,
119
- pagination: { ...a, showTotal: _ },
120
- loading: E,
121
- dataSource: P,
122
- onChange: k,
119
+ rowSelection: E,
120
+ pagination: { ...l, showTotal: v },
121
+ loading: f,
122
+ dataSource: o,
123
+ onChange: N,
123
124
  locale: {
124
- emptyText: E ? "" : /* @__PURE__ */ X.jsx(A, { image: A.PRESENTED_IMAGE_SIMPLE })
125
+ emptyText: f ? "" : /* @__PURE__ */ oe.jsx(q, { image: q.PRESENTED_IMAGE_SIMPLE })
125
126
  }
126
- }), [N, a, _, E, P, k]);
127
- return H(() => {
128
- s(L.current);
127
+ }), [E, l, v, f, o, N]);
128
+ return C(() => {
129
+ L($.current);
129
130
  }, []), {
130
- queryParams: r,
131
- reload: M,
132
- refresh: b,
133
- reset: I,
134
- selectedRowKeys: m,
135
- tableProps: $
131
+ queryParams: t,
132
+ reload: L,
133
+ refresh: O,
134
+ reset: F,
135
+ selectedRowKeys: y,
136
+ tableProps: G
137
+ };
138
+ }
139
+ const T = K((i) => ({
140
+ modals: {},
141
+ toggleModal: (r, a) => i((e) => {
142
+ const n = e.modals[r]?.visible || !1;
143
+ return {
144
+ modals: {
145
+ ...e.modals,
146
+ [r]: {
147
+ visible: !n,
148
+ data: n ? {} : a || {}
149
+ }
150
+ }
151
+ };
152
+ }),
153
+ setModal: (r, a, e) => i((s) => ({
154
+ modals: {
155
+ ...s.modals,
156
+ [r]: {
157
+ visible: a,
158
+ data: a ? e || {} : {}
159
+ }
160
+ }
161
+ })),
162
+ clearModals: (r) => i((a) => {
163
+ const e = { ...a.modals };
164
+ return r.forEach((s) => {
165
+ delete e[s];
166
+ }), { modals: e };
167
+ })
168
+ }));
169
+ function ce(i) {
170
+ const r = T((o) => o.modals), a = T((o) => o.toggleModal), e = T((o) => o.setModal), s = T((o) => o.clearModals), n = W(), d = J(i.map((o) => `${n}-${o}`));
171
+ C(() => () => {
172
+ s(d.current);
173
+ }, []);
174
+ const l = {};
175
+ for (const o of i) {
176
+ const t = `${n}-${o}`, u = r[t] ?? { visible: !1, data: {} };
177
+ l[`${o}Modal`] = {
178
+ visible: u.visible,
179
+ data: u.data,
180
+ toggle: (f) => a(t, f),
181
+ open: (f) => e(t, !0, f),
182
+ close: () => e(t, !1)
183
+ };
184
+ }
185
+ return l.toggle = (o, t) => {
186
+ const p = `${n}-${o}`;
187
+ a(p, t);
188
+ }, l.open = (o, t) => {
189
+ const p = `${n}-${o}`;
190
+ e(p, !0, t);
191
+ }, l.close = (o) => {
192
+ const t = `${n}-${o}`;
193
+ e(t, !1);
194
+ }, l;
195
+ }
196
+ const se = (i, r = "value", a = "label") => new Map(i.map((e) => [e[r], e[a]]));
197
+ function ue(i, r) {
198
+ const [a, e] = M([]), [s, n] = M(/* @__PURE__ */ new Map()), [d, l] = M(!0), { params: o, selectKey: t, fieldNames: p } = r, u = async () => {
199
+ l(!0);
200
+ const { data: R } = await i(o), $ = R || [];
201
+ if (p) {
202
+ const { label: y, value: h } = p, E = $.map((v) => ({
203
+ data: v,
204
+ label: v[y],
205
+ value: v[h]
206
+ }));
207
+ e(E), n(se(E));
208
+ } else
209
+ e($);
210
+ l(!1);
211
+ }, f = m(() => {
212
+ u();
213
+ }, [u]);
214
+ return C(() => {
215
+ f();
216
+ }, []), {
217
+ loading: d,
218
+ refresh: f,
219
+ [`${t}Options`]: a,
220
+ [`${t}Map`]: s
221
+ };
222
+ }
223
+ function de(i, r) {
224
+ const [a, e] = M(!1), { message: s } = X.useApp(), n = m(async (d) => {
225
+ try {
226
+ const l = await i(d);
227
+ e(!0);
228
+ const { status: o, info: t } = l;
229
+ o == "success" && (r(l), s.success(t));
230
+ } catch {
231
+ }
232
+ e(!1);
233
+ }, [i, r, s]);
234
+ return {
235
+ loading: a,
236
+ submit: n
136
237
  };
137
238
  }
138
239
  export {
139
- te as configureTableOption,
140
- re as useTableList
240
+ ie as configureTableOption,
241
+ ce as useCreateModal,
242
+ de as useFormSubmit,
243
+ ue as useSelectOptions,
244
+ le as useTableList
141
245
  };
@@ -1 +1 @@
1
- (function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react"),require("antd")):typeof define=="function"&&define.amd?define(["exports","react","antd"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.DesignReact={},r.React,r.antd))})(this,(function(r,e,y){"use strict";var T={exports:{}},f={};var C;function L(){if(C)return f;C=1;var u=Symbol.for("react.transitional.element"),p=Symbol.for("react.fragment");function l(g,o,s){var S=null;if(s!==void 0&&(S=""+s),o.key!==void 0&&(S=""+o.key),"key"in o){s={};for(var a in o)a!=="key"&&(s[a]=o[a])}else s=o;return o=s.ref,{$$typeof:u,type:g,key:S,ref:o!==void 0?o:null,props:s}}return f.Fragment=p,f.jsx=l,f.jsxs=l,f}var z;function A(){return z||(z=1,T.exports=L()),T.exports}var F=A();const E={sortField:["orderType","orderField"],sortOrder:["ASC","DESC"],pageSize:15};function J(u){Object.keys(u).forEach(p=>{E[p]=u[p]})}function O(u,p={}){const{rowSelection:l,...g}=p,o=E.pageSize,[s,S]=e.useState({pagination:{showSizeChanger:!0,showQuickJumper:!0,total:0,pageSize:o,current:1},list:[],queryParams:{pageNo:1,pageSize:o,...g}}),{pagination:a,list:P,queryParams:n}=s,{pageNo:k,pageSize:c}=n,[m,b]=e.useState(!0),D=e.useRef(n),[R,N]=e.useState([]),_=e.useMemo(()=>{if(l)return{selectedRowKeys:R,onChange:t=>N(t)}},[l,R]),j=e.useCallback(t=>`共 ${t} 条记录 第 ${k}/${Math.ceil(t/c)} 页 `,[k,c]),i=e.useCallback(async t=>{const{pageNo:w}=t;b(!0);const d={...g,pageSize:c,...t};t.pageNo===void 0&&(d.pageNo=1),t.pageSize===void 0&&(d.pageSize=c);const{data:x}=await u(d),{list:h=[],totalCount:v=0}=x||{};l&&N([]),S({list:h,queryParams:d,pagination:{...a,current:w,pageSize:d.pageSize,total:v}}),b(!1)},[n,g,l,c,u,a]),I=e.useCallback(t=>{i({...n,...t,pageNo:1})},[i,n]),$=e.useCallback(t=>{i({...n,...t})},[i,n]),G=e.useCallback(t=>{i({...t,pageSize:c,pageNo:1})},[i,c]),q=e.useCallback((t,w,d,x)=>{const{action:h}=x;if(["paginate","sort"].includes(h)){const{current:v,pageSize:V}=t,{field:Y,order:M}=d,[Z,B]=E.sortField,[H,U]=E.sortOrder,W={...n,[Z]:M?M==="ascend"?H:U:void 0,[B]:Y,pageNo:v,pageSize:V};i(W)}},[n,i]),Q=e.useMemo(()=>({bordered:!0,size:"middle",sticky:!0,rowSelection:_,pagination:{...a,showTotal:j},loading:m,dataSource:P,onChange:q,locale:{emptyText:m?"":F.jsx(y.Empty,{image:y.Empty.PRESENTED_IMAGE_SIMPLE})}}),[_,a,j,m,P,q]);return e.useEffect(()=>{i(D.current)},[]),{queryParams:n,reload:I,refresh:$,reset:G,selectedRowKeys:R,tableProps:Q}}r.configureTableOption=J,r.useTableList=O,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react"),require("antd"),require("zustand")):typeof define=="function"&&define.amd?define(["exports","react","antd","zustand"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.DesignReact={},d.React,d.antd,d.zustand))})(this,(function(d,e,z,O){"use strict";var $={exports:{}},b={};var L;function D(){if(L)return b;L=1;var l=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function n(t,a,i){var f=null;if(i!==void 0&&(f=""+i),a.key!==void 0&&(f=""+a.key),"key"in a){i={};for(var u in a)u!=="key"&&(i[u]=a[u])}else i=a;return a=i.ref,{$$typeof:l,type:t,key:f,ref:a!==void 0?a:null,props:i}}return b.Fragment=r,b.jsx=n,b.jsxs=n,b}var N;function F(){return N||(N=1,$.exports=D()),$.exports}var I=F();const C={sortField:["orderType","orderField"],sortOrder:["ASC","DESC"],pageSize:15};function J(l){Object.keys(l).forEach(r=>{C[r]=l[r]})}function G(l,r={}){const{rowSelection:n,...t}=r,a=C.pageSize,[i,f]=e.useState({pagination:{showSizeChanger:!0,showQuickJumper:!0,total:0,pageSize:a,current:1},list:[],queryParams:{pageNo:1,pageSize:a,...t}}),{pagination:u,list:o,queryParams:s}=i,{pageNo:g,pageSize:p}=s,[S,T]=e.useState(!0),h=e.useRef(s),[E,k]=e.useState([]),v=e.useMemo(()=>{if(n)return{selectedRowKeys:E,onChange:c=>k(c)}},[n,E]),y=e.useCallback(c=>`共 ${c} 条记录 第 ${g}/${Math.ceil(c/p)} 页 `,[g,p]),m=e.useCallback(async c=>{const{pageNo:q}=c;T(!0);const M={...t,pageSize:p,...c};c.pageNo===void 0&&(M.pageNo=1),c.pageSize===void 0&&(M.pageSize=p);const{data:x}=await l(M),{list:P=[],totalCount:w=0}=x||{};n&&k([]),f({list:P,queryParams:M,pagination:{...u,current:q,pageSize:M.pageSize,total:w}}),T(!1)},[s,t,n,p,l,u]),_=e.useCallback(c=>{m({...s,...c,pageNo:1})},[m,s]),B=e.useCallback(c=>{m({...s,...c})},[m,s]),H=e.useCallback(c=>{m({...c,pageSize:p,pageNo:1})},[m,p]),j=e.useCallback((c,q,M,x)=>{const{action:P}=x;if(["paginate","sort"].includes(P)){const{current:w,pageSize:W}=c,{field:X,order:A}=M,[K,ee]=C.sortField,[te,se]=C.sortOrder,oe={...s,[K]:A?A==="ascend"?te:se:void 0,[ee]:X,pageNo:w,pageSize:W};m(oe)}},[s,m]),U=e.useMemo(()=>({bordered:!0,size:"middle",sticky:!0,rowSelection:v,pagination:{...u,showTotal:y},loading:S,dataSource:o,onChange:j,locale:{emptyText:S?"":I.jsx(z.Empty,{image:z.Empty.PRESENTED_IMAGE_SIMPLE})}}),[v,u,y,S,o,j]);return e.useEffect(()=>{_(h.current)},[]),{queryParams:s,reload:_,refresh:B,reset:H,selectedRowKeys:E,tableProps:U}}const R=O.create(l=>({modals:{},toggleModal:(r,n)=>l(t=>{const i=t.modals[r]?.visible||!1;return{modals:{...t.modals,[r]:{visible:!i,data:i?{}:n||{}}}}}),setModal:(r,n,t)=>l(a=>({modals:{...a.modals,[r]:{visible:n,data:n?t||{}:{}}}})),clearModals:r=>l(n=>{const t={...n.modals};return r.forEach(a=>{delete t[a]}),{modals:t}})}));function V(l){const r=R(o=>o.modals),n=R(o=>o.toggleModal),t=R(o=>o.setModal),a=R(o=>o.clearModals),i=e.useId(),f=e.useRef(l.map(o=>`${i}-${o}`));e.useEffect(()=>()=>{a(f.current)},[]);const u={};for(const o of l){const s=`${i}-${o}`,p=r[s]??{visible:!1,data:{}};u[`${o}Modal`]={visible:p.visible,data:p.data,toggle:S=>n(s,S),open:S=>t(s,!0,S),close:()=>t(s,!1)}}return u.toggle=(o,s)=>{const g=`${i}-${o}`;n(g,s)},u.open=(o,s)=>{const g=`${i}-${o}`;t(g,!0,s)},u.close=o=>{const s=`${i}-${o}`;t(s,!1)},u}const Q=(l,r="value",n="label")=>new Map(l.map(t=>[t[r],t[n]]));function Y(l,r){const[n,t]=e.useState([]),[a,i]=e.useState(new Map),[f,u]=e.useState(!0),{params:o,selectKey:s,fieldNames:g}=r,p=async()=>{u(!0);const{data:T}=await l(o),h=T||[];if(g){const{label:E,value:k}=g,v=h.map(y=>({data:y,label:y[E],value:y[k]}));t(v),i(Q(v))}else t(h);u(!1)},S=e.useCallback(()=>{p()},[p]);return e.useEffect(()=>{S()},[]),{loading:f,refresh:S,[`${s}Options`]:n,[`${s}Map`]:a}}function Z(l,r){const[n,t]=e.useState(!1),{message:a}=z.App.useApp(),i=e.useCallback(async f=>{try{const u=await l(f);t(!0);const{status:o,info:s}=u;o=="success"&&(r(u),a.success(s))}catch{}t(!1)},[l,r,a]);return{loading:n,submit:i}}d.configureTableOption=J,d.useCreateModal=V,d.useFormSubmit=Z,d.useSelectOptions=Y,d.useTableList=G,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@base-stone/hooks",
3
3
  "license": "MIT",
4
- "version": "0.7.4",
4
+ "version": "0.7.6",
5
5
  "author": {
6
6
  "name": "yeliang",
7
7
  "email": "leafront@126.com"
@@ -36,9 +36,10 @@
36
36
  "lint:js": "npm run eslint && npm run prettier"
37
37
  },
38
38
  "devDependencies": {
39
+ "@eslint/js": "^9.39.2",
39
40
  "@types/node": "^25.0.3",
40
41
  "@types/react": "^19.2.7",
41
- "@eslint/js": "^9.39.2",
42
+ "@vitejs/plugin-react-swc": "^4.2.2",
42
43
  "classnames": "^2.5.1",
43
44
  "eslint": "^9.39.2",
44
45
  "eslint-plugin-prettier": "^5.5.4",
@@ -46,14 +47,14 @@
46
47
  "eslint-plugin-react-refresh": "^0.4.26",
47
48
  "prettier": "^3.7.4",
48
49
  "rollup-plugin-shell": "^1.0.9",
49
- "@vitejs/plugin-react-swc": "^4.2.2",
50
50
  "typescript": "^5.9.3",
51
+ "typescript-eslint": "^8.50.0",
51
52
  "vite": "^7.3.0",
52
- "vite-plugin-dts": "^4.5.4",
53
- "typescript-eslint": "^8.50.0"
53
+ "vite-plugin-dts": "^4.5.4"
54
54
  },
55
55
  "dependencies": {
56
56
  "antd": "^6.1.1",
57
- "react": "^19.2.3"
57
+ "react": "^19.2.3",
58
+ "zustand": "^5.0.9"
58
59
  }
59
60
  }