@base-stone/hooks 0.9.5 → 0.9.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.
@@ -35,7 +35,7 @@ declare type MapData<T extends string | number = string | number> = Map<T, strin
35
35
 
36
36
  declare interface ModalConfig<T = Record<string, any>> {
37
37
  width: number;
38
- title: string | ((data: T) => string);
38
+ title: string | ReactElement | ((data: T) => string);
39
39
  maskClosable?: boolean;
40
40
  centered?: boolean;
41
41
  destroyOnHidden?: boolean;
@@ -113,7 +113,7 @@ declare interface TableListResult<T> {
113
113
  /** 查询参数 */
114
114
  queryParams: QueryParamsData;
115
115
  /** 执行查询方法 */
116
- reload: (params?: Record<string, any>) => void;
116
+ search: (params?: Record<string, any>) => void;
117
117
  refresh: (params?: Record<string, any>) => void;
118
118
  reset: (params?: Record<string, any>) => void;
119
119
  /** 选中的行 keys */
@@ -1,4 +1,4 @@
1
- import { useState as b, useRef as I, useMemo as A, useCallback as S, useEffect as k, useId as W } from "react";
1
+ import { useState as y, useRef as I, useMemo as A, useCallback as S, useEffect as k, useId as W } from "react";
2
2
  import { Empty as L, App as X } from "antd";
3
3
  import { create as K } from "zustand";
4
4
  var T = { exports: {} }, E = {};
@@ -40,7 +40,7 @@ function ie(n) {
40
40
  });
41
41
  }
42
42
  function le(n, r = {}) {
43
- const { rowSelection: a, ...t } = r, o = R.pageSize, [s, m] = b({
43
+ const { rowSelection: a, ...t } = r, o = R.pageSize, [s, m] = y({
44
44
  pagination: {
45
45
  showSizeChanger: !0,
46
46
  showQuickJumper: !0,
@@ -54,7 +54,7 @@ function le(n, r = {}) {
54
54
  pageSize: o,
55
55
  ...t
56
56
  }
57
- }), { pagination: l, list: f, queryParams: e } = s, { pageNo: d, pageSize: u } = e, [i, M] = b(!0), g = I(e), [v, C] = b([]), h = A(() => {
57
+ }), { pagination: l, list: f, queryParams: e } = s, { pageNo: d, pageSize: u } = e, [i, M] = y(!0), g = I(e), [v, C] = y([]), b = A(() => {
58
58
  if (a)
59
59
  return {
60
60
  selectedRowKeys: v,
@@ -67,16 +67,16 @@ function le(n, r = {}) {
67
67
  async (c) => {
68
68
  const { pageNo: O } = c;
69
69
  M(!0);
70
- const y = { ...t, pageSize: u, ...c };
71
- c.pageNo === void 0 && (y.pageNo = 1), c.pageSize === void 0 && (y.pageSize = u);
72
- const { data: $ } = await n(y), { list: z = [], totalCount: P = 0 } = $ || {};
70
+ const h = { ...t, pageSize: u, ...c };
71
+ c.pageNo === void 0 && (h.pageNo = 1), c.pageSize === void 0 && (h.pageSize = u);
72
+ const { data: $ } = await n(h), { list: z = [], totalCount: P = 0 } = $ || {};
73
73
  a && C([]), m({
74
74
  list: z,
75
- queryParams: y,
75
+ queryParams: h,
76
76
  pagination: {
77
77
  ...l,
78
78
  current: O,
79
- pageSize: y.pageSize,
79
+ pageSize: h.pageSize,
80
80
  total: P
81
81
  }
82
82
  }), M(!1);
@@ -98,10 +98,10 @@ function le(n, r = {}) {
98
98
  },
99
99
  [p, u]
100
100
  ), N = S(
101
- (c, O, y, $) => {
101
+ (c, O, h, $) => {
102
102
  const { action: z } = $;
103
103
  if (["paginate", "sort"].includes(z)) {
104
- const { current: P, pageSize: G } = c, { field: V, order: _ } = y, [Q, Y] = R.sortField, [Z, B] = R.sortOrder, U = {
104
+ const { current: P, pageSize: G } = c, { field: V, order: _ } = h, [Q, Y] = R.sortField, [Z, B] = R.sortOrder, U = {
105
105
  ...e,
106
106
  [Q]: _ ? _ === "ascend" ? Z : B : void 0,
107
107
  [Y]: V,
@@ -116,7 +116,7 @@ function le(n, r = {}) {
116
116
  bordered: !0,
117
117
  size: "middle",
118
118
  sticky: !0,
119
- rowSelection: h,
119
+ rowSelection: b,
120
120
  pagination: { ...l, showTotal: x },
121
121
  loading: i,
122
122
  dataSource: f,
@@ -124,12 +124,12 @@ function le(n, r = {}) {
124
124
  locale: {
125
125
  emptyText: i ? "" : /* @__PURE__ */ oe.jsx(L, { image: L.PRESENTED_IMAGE_SIMPLE })
126
126
  }
127
- }), [h, l, x, i, f, N]);
127
+ }), [b, l, x, i, f, N]);
128
128
  return k(() => {
129
129
  D(g.current);
130
130
  }, []), {
131
131
  queryParams: e,
132
- reload: D,
132
+ search: D,
133
133
  refresh: J,
134
134
  reset: F,
135
135
  selectedRowKeys: v,
@@ -211,19 +211,19 @@ function ce(n) {
211
211
  }
212
212
  const ae = (n, r = "value", a = "label") => new Map(n.map((t) => [t[r], t[a]]));
213
213
  function de(n, r) {
214
- const [a, t] = b({
214
+ const [a, t] = y({
215
215
  options: [],
216
216
  mapData: /* @__PURE__ */ new Map()
217
- }), [o, s] = b(!0), { params: m, selectKey: l, fieldNames: f } = r, e = async () => {
217
+ }), [o, s] = y(!0), { params: m, selectKey: l, fieldNames: f } = r, e = async () => {
218
218
  s(!0);
219
219
  const { data: M } = await n(m), g = M || [];
220
220
  if (f) {
221
- const { label: v, value: C } = f, h = g.map((p) => ({
221
+ const { label: v, value: C } = f, b = g.map((p) => ({
222
222
  data: p,
223
223
  label: p[v],
224
224
  value: p[C]
225
- })), x = ae(h);
226
- t((p) => ({ ...p, options: h, mapData: x }));
225
+ })), x = ae(b);
226
+ t((p) => ({ ...p, options: b, mapData: x }));
227
227
  } else
228
228
  t((v) => ({ ...v, options: g }));
229
229
  s(!1);
@@ -242,7 +242,7 @@ function de(n, r) {
242
242
  };
243
243
  }
244
244
  function ue(n, r) {
245
- const [a, t] = b(!1), { message: o } = X.useApp(), s = S(async (m) => {
245
+ const [a, t] = y(!1), { message: o } = X.useApp(), s = S(async (m) => {
246
246
  try {
247
247
  t(!0);
248
248
  const l = await n(m), { status: f, info: e } = l;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@base-stone/hooks",
3
3
  "license": "MIT",
4
- "version": "0.9.5",
4
+ "version": "0.9.7",
5
5
  "author": {
6
6
  "name": "leafront",
7
7
  "email": "leafront@126.com"