yuand 1.0.2 → 1.0.3

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.
@@ -14,26 +14,23 @@ var useTable = function useTable() {
14
14
  form = _Form$useForm2[0];
15
15
  var tableRef = useRef(null);
16
16
  if (!tableRef.current) {
17
+ var _options$page, _options$size, _options$sorter;
18
+ var initState = {
19
+ page: (_options$page = options.page) !== null && _options$page !== void 0 ? _options$page : 1,
20
+ size: (_options$size = options.size) !== null && _options$size !== void 0 ? _options$size : 10,
21
+ sorter: (_options$sorter = options.sorter) !== null && _options$sorter !== void 0 ? _options$sorter : {},
22
+ search: {},
23
+ params: {},
24
+ data: {},
25
+ ready: false
26
+ };
17
27
  var useStore = create(function (set) {
18
- var _options$page, _options$size, _options$page2, _options$size2;
19
- return {
20
- page: (_options$page = options.page) !== null && _options$page !== void 0 ? _options$page : 1,
21
- size: (_options$size = options.size) !== null && _options$size !== void 0 ? _options$size : 10,
22
- sorter: options.sorter || {},
23
- search: {},
24
- params: {
25
- page: (_options$page2 = options.page) !== null && _options$page2 !== void 0 ? _options$page2 : 1,
26
- size: (_options$size2 = options.size) !== null && _options$size2 !== void 0 ? _options$size2 : 10,
27
- sorter: options.sorter || {},
28
- form: {}
29
- },
30
- data: {},
31
- ready: false,
28
+ return _objectSpread(_objectSpread({}, initState), {}, {
32
29
  setState: function setState() {
33
30
  var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
34
31
  set(values);
35
32
  }
36
- };
33
+ });
37
34
  });
38
35
  tableRef.current = {
39
36
  form: form,
@@ -57,6 +54,9 @@ var useTable = function useTable() {
57
54
  }
58
55
  return null;
59
56
  },
57
+ resetStore: function resetStore() {
58
+ useStore.getState().setState(initState);
59
+ },
60
60
  update: function update() {
61
61
  return _update(function (v) {
62
62
  return v + 1;
@@ -1,6 +1,6 @@
1
1
  import type { HttpClientConfig, HttpMethod } from "../fetch";
2
- import type { Result } from "ahooks/lib/useRequest/src/types";
3
- import type { Options } from "ahooks/lib/useRequest/src/types";
2
+ import type { Result } from "../../node_modules/ahooks";
3
+ import type { Options } from "../../node_modules/ahooks";
4
4
  export interface UseFetchOption<TData = any> extends Options<TData, any[]> {
5
5
  ignoreError?: boolean;
6
6
  returnData?: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { HttpMethod } from "../fetch";
2
- import type { UseMutationResult, UseMutationOptions } from "@tanstack/react-query";
2
+ import type { UseMutationResult, UseMutationOptions } from "../../node_modules/@tanstack/react-query";
3
3
  interface Options<TData, TError = unknown, TVariables = void, TOnMutateResult = unknown> extends UseMutationOptions<TData, TError, TVariables, TOnMutateResult> {
4
4
  url: string;
5
5
  method?: HttpMethod;
package/es/utils/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import dayjs from 'dayjs';
2
- import duration from 'dayjs/plugin/duration';
1
+ import dayjs from "dayjs";
2
+ import duration from "dayjs/plugin/duration";
3
3
  dayjs.extend(duration);
4
4
 
5
5
  /**
@@ -8,16 +8,16 @@ dayjs.extend(duration);
8
8
  * @returns 格式化后的字符串
9
9
  */
10
10
  export function formatDuration(seconds) {
11
- if (!seconds || seconds === 0) return '0秒';
12
- var duration = dayjs.duration(seconds, 'seconds');
11
+ if (!seconds || seconds === 0) return "0秒";
12
+ var duration = dayjs.duration(seconds, "seconds");
13
13
  var days = Math.floor(duration.asDays());
14
14
  var hours = duration.hours();
15
15
  var minutes = duration.minutes();
16
16
  var secs = duration.seconds();
17
- var result = '';
17
+ var result = "";
18
18
  if (days > 0) result += "".concat(days, "\u5929");
19
19
  if (hours > 0) result += "".concat(hours, "\u5C0F\u65F6");
20
20
  if (minutes > 0) result += "".concat(minutes, "\u5206");
21
21
  if (secs > 0) result += "".concat(secs, "\u79D2");
22
- return result || '0秒';
22
+ return result || "0秒";
23
23
  }
package/es/utils/util.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export var isObject = function isObject(oj) {
2
- return Object.prototype.toString.call(oj) === '[object Object]';
2
+ return Object.prototype.toString.call(oj) === "[object Object]";
3
3
  };
4
4
  export var isFunction = function isFunction(oj) {
5
- return Object.prototype.toString.call(oj) === '[object Function]';
5
+ return Object.prototype.toString.call(oj) === "[object Function]";
6
6
  };
@@ -1,12 +1,18 @@
1
1
  import type { ProTableProps, ProTableConfigOptions } from "./types";
2
2
  import "./style.css";
3
3
  declare const ProTable: {
4
- <T extends Record<string, any>>(props: ProTableProps<T>): import("react/jsx-runtime").JSX.Element;
4
+ <T extends Record<string, any>>(props: ProTableProps<T>): import("../../../node_modules/@types/react").JSX.Element;
5
5
  useTable: (options?: import("./types").UseTableProps) => import("./types").TableInstance<any>[];
6
6
  getQuery: ({ page, size, sorter, search, params, }: import("../../utils/table").GetQueryProps) => Record<string, unknown>;
7
7
  formatDate: (key: string, data: Record<string, any>, format?: string) => Record<string, any>;
8
8
  removeEmpty: (data: Record<string, any>) => Record<string, any>;
9
9
  pageSizeOptions: number[];
10
+ /**
11
+ * 自定义配置参数组合方式.
12
+ * getQuery函数配置默认提供 page,size,orderField,isAsc,...params,...search
13
+ * @param options
14
+ * @returns
15
+ */
10
16
  config(options: ProTableConfigOptions): void;
11
17
  };
12
18
  export default ProTable;
@@ -44,52 +44,53 @@ var import_useX = __toESM(require("../../hooks/useX"));
44
44
  var import_useTable = __toESM(require("./useTable"));
45
45
  var import_style = require("./style.css");
46
46
  var import_jsx_runtime = require("react/jsx-runtime");
47
- var defaultClassNames = {
48
- root: "main-container",
49
- form: "search-form",
50
- table: "main-table"
51
- };
52
- var defaultStyles = {
53
- root: {},
54
- form: {
55
- display: "flex",
56
- justifyContent: "space-between"
47
+ var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
48
+ var DEFAULT_CONFIG = {
49
+ classNames: {
50
+ root: "main-container",
51
+ form: "search-form",
52
+ table: "main-table"
53
+ },
54
+ styles: {
55
+ root: {},
56
+ form: { display: "flex", justifyContent: "space-between" },
57
+ table: {},
58
+ toolbar: { marginBottom: 15 }
57
59
  },
58
- table: {},
59
- toolbar: {
60
- marginBottom: 15
60
+ pagination: {
61
+ showQuickJumper: true,
62
+ showSizeChanger: true,
63
+ hideOnSinglePage: false
61
64
  }
62
65
  };
63
- var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
64
66
  var ProTable = (props) => {
65
67
  const {
66
68
  request = {},
67
- classNames = defaultClassNames,
68
- styles = defaultStyles,
69
+ classNames = DEFAULT_CONFIG.classNames,
70
+ styles = DEFAULT_CONFIG.styles,
69
71
  table,
70
72
  locale,
71
73
  dataKey = "data",
72
74
  totalKey = "total",
73
- manual = false,
74
75
  nostyle,
75
76
  columns,
76
77
  form = {},
77
78
  alert,
78
79
  toolbar = null,
79
- pageSizeOptions,
80
- pagination,
80
+ pagination = DEFAULT_CONFIG.pagination,
81
81
  scroll,
82
82
  useData,
83
83
  ...prop
84
84
  } = props;
85
85
  const { lang } = (0, import_react.useContext)(import_TableConfig.I18nContext);
86
+ pagination.showTotal ?? (pagination.showTotal = (total2) => `${(0, import_TableConfig.t)("共", lang)} ${total2} ${(0, import_TableConfig.t)("条记录", lang)}`);
87
+ pagination.pageSizeOptions ?? (pagination.pageSizeOptions = ProTable.pageSizeOptions);
86
88
  const {
87
89
  title: formTitle,
88
90
  extra: formExtra,
89
91
  right: formRight,
90
- formItem,
91
92
  layout = "inline",
92
- items,
93
+ items: formItems,
93
94
  reset: formReset,
94
95
  dataForm,
95
96
  handleValues: formHandleValues,
@@ -97,7 +98,6 @@ var ProTable = (props) => {
97
98
  ...otherFormProps
98
99
  } = form;
99
100
  const forceKey = (0, import_react.useRef)(0);
100
- const formItems = formItem || items;
101
101
  const queryClient = (0, import_react_query.useQueryClient)();
102
102
  const { page, size, sorter, search, ready, setState } = table.useStore(
103
103
  (0, import_shallow.useShallow)((state) => {
@@ -152,7 +152,7 @@ var ProTable = (props) => {
152
152
  data
153
153
  });
154
154
  }
155
- }, [data]);
155
+ }, [data, useData]);
156
156
  const { dataSource, total, column, renderAlert } = (0, import_react.useMemo)(() => {
157
157
  return {
158
158
  column: typeof columns === "function" ? columns(data) : columns,
@@ -171,8 +171,9 @@ var ProTable = (props) => {
171
171
  }
172
172
  };
173
173
  const onReset = () => {
174
+ var _a;
174
175
  setState({
175
- size: (pageSizeOptions == null ? void 0 : pageSizeOptions[0]) || ProTable.pageSizeOptions[0],
176
+ size: ((_a = pagination == null ? void 0 : pagination.pageSizeOptions) == null ? void 0 : _a[0]) ?? ProTable.pageSizeOptions[0],
176
177
  sorter: {}
177
178
  });
178
179
  if (formItems) {
@@ -184,21 +185,19 @@ var ProTable = (props) => {
184
185
  }
185
186
  }
186
187
  };
188
+ if (table) {
189
+ table.queryKey = queryKey;
190
+ table.clear = () => queryClient.setQueryData(queryKey, {});
191
+ table.run = onSearch;
192
+ table.refresh = refetch;
193
+ table.reset = () => {
194
+ if (formItems) {
195
+ onReset();
196
+ }
197
+ };
198
+ }
187
199
  (0, import_react.useEffect)(() => {
188
- if (table) {
189
- table.run = onSearch;
190
- table.queryKey = queryKey;
191
- table.clear = () => queryClient.setQueryData(queryKey, {});
192
- table.refresh = refetch;
193
- table.reset = () => {
194
- if (formItems) {
195
- onReset();
196
- }
197
- };
198
- }
199
- }, [table, queryKey]);
200
- (0, import_react.useEffect)(() => {
201
- if (manual)
200
+ if (request.manual)
202
201
  return;
203
202
  if (formItems) {
204
203
  table.form.submit();
@@ -248,14 +247,8 @@ var ProTable = (props) => {
248
247
  pagination: {
249
248
  current: page,
250
249
  pageSize: size,
251
- showQuickJumper: pagination ? pagination.showQuickJumper : true,
252
- showSizeChanger: pagination ? pagination.showSizeChanger : true,
253
- hideOnSinglePage: pagination ? pagination.hideOnSinglePage : false,
254
- pageSizeOptions: pageSizeOptions || ProTable.pageSizeOptions,
255
250
  total,
256
- showTotal(total2) {
257
- return `${(0, import_TableConfig.t)("共", lang)} ${total2} ${(0, import_TableConfig.t)("条记录", lang)}`;
258
- }
251
+ ...pagination
259
252
  },
260
253
  dataSource,
261
254
  ...prop
@@ -265,13 +258,13 @@ var ProTable = (props) => {
265
258
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
266
259
  "div",
267
260
  {
268
- className: (classNames == null ? void 0 : classNames.root) ?? defaultClassNames.root,
261
+ className: (classNames == null ? void 0 : classNames.root) ?? DEFAULT_CONFIG.classNames.root,
269
262
  style: styles.root,
270
263
  children: [
271
264
  !!formItems && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
272
265
  "div",
273
266
  {
274
- className: (classNames == null ? void 0 : classNames.form) ?? defaultClassNames.form,
267
+ className: (classNames == null ? void 0 : classNames.form) ?? DEFAULT_CONFIG.classNames.form,
275
268
  style: styles.form,
276
269
  children: [
277
270
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
@@ -299,7 +292,7 @@ var ProTable = (props) => {
299
292
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
300
293
  "div",
301
294
  {
302
- className: (classNames == null ? void 0 : classNames.table) ?? defaultClassNames.table,
295
+ className: (classNames == null ? void 0 : classNames.table) ?? DEFAULT_CONFIG.classNames.table,
303
296
  style: styles.table,
304
297
  children: [
305
298
  toolbar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: styles.toolbar, children: toolbar }),
@@ -1,3 +1,3 @@
1
1
  .search-form .ant-form-item {
2
- margin-bottom: 20px!important;
2
+ margin-bottom: 20px !important;
3
3
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import type { FormInstance, TableColumnType, TableProps, FormProps } from "antd";
2
+ import type { FormInstance, TableColumnType, TableProps, FormProps, PaginationProps } from "../../../node_modules/antd";
3
3
  import type { HttpMethod } from "../../fetch";
4
- import type { UseBoundStore, StoreApi } from "zustand";
4
+ import type { UseBoundStore, StoreApi } from "../../../node_modules/zustand";
5
5
  import type { GetQueryProps } from "../../utils/table";
6
6
  type RecordType = Record<string, any>;
7
7
  interface SorterType {
@@ -33,13 +33,11 @@ export interface TableInstance<TData = any> {
33
33
  }
34
34
  interface FormOptions extends Omit<FormProps, "form" | "title" | "children"> {
35
35
  title?: React.ReactNode;
36
- /** @deprecated 此属性已废弃,请使用新的formItem属性代替 */
37
36
  items?: React.ReactNode | React.ReactNode[];
38
- formItem?: React.ReactNode | React.ReactNode[];
39
37
  extra?: React.ReactNode;
40
38
  right?: React.ReactNode;
41
- handleValues?: (values: Record<string, any>) => any;
42
39
  reset?: boolean;
40
+ handleValues?: (values: Record<string, any>) => any;
43
41
  onResetBefore?: () => void | boolean;
44
42
  dataForm?: FormProps;
45
43
  }
@@ -59,8 +57,10 @@ export interface ProTableProps<Tdata = any> extends Omit<TableProps<Tdata>, "col
59
57
  request: {
60
58
  /** 请求地址方法 */
61
59
  url?: string;
60
+ /** 手动调用发送 table.run */
61
+ manual?: boolean;
62
62
  method?: HttpMethod;
63
- /** 请求参数 */
63
+ /** 请求额外参数 */
64
64
  params?: Record<string, any>;
65
65
  onBefore?: () => any;
66
66
  onSuccess?: (data: any) => any;
@@ -69,19 +69,12 @@ export interface ProTableProps<Tdata = any> extends Omit<TableProps<Tdata>, "col
69
69
  locale?: Record<string, any>;
70
70
  dataKey?: string;
71
71
  totalKey?: string;
72
- manual?: boolean;
73
72
  nostyle?: boolean;
74
73
  columns: ((data: Tdata) => TableColumnType<unknown>[]) | TableColumnType<unknown>[];
75
74
  form?: FormOptions;
76
75
  alert?: React.ReactNode | ((data: Tdata) => React.ReactNode);
77
76
  toolbar?: React.ReactNode;
78
- pageSizeOptions?: number[];
79
- pagination?: {
80
- showQuickJumper?: boolean;
81
- showSizeChanger?: boolean;
82
- hideOnSinglePage?: boolean;
83
- };
84
- loadingDelay?: number;
77
+ pagination?: PaginationProps;
85
78
  useData?: boolean;
86
79
  }
87
80
  export interface UseTableProps {
@@ -1,12 +1,18 @@
1
1
  import type { ProTableProps, ProTableConfigOptions } from "./types";
2
2
  import "./style.css";
3
3
  declare const ProTable: {
4
- <T extends Record<string, any>>(props: ProTableProps<T>): import("react/jsx-runtime").JSX.Element;
4
+ <T extends Record<string, any>>(props: ProTableProps<T>): import("../../../node_modules/@types/react").JSX.Element;
5
5
  useTable: (options?: import("./types").UseTableProps) => import("./types").TableRef[];
6
6
  getQuery(options: any): Record<string, unknown>;
7
7
  formatDate: (key: string, data: Record<string, any>, format?: string) => Record<string, any>;
8
8
  removeEmpty: (data: Record<string, any>) => Record<string, any>;
9
9
  pageSizeOptions: number[];
10
+ /**
11
+ * 自定义配置参数组合方式.
12
+ * getQuery函数配置默认提供 page,size,orderField,isAsc,...params,...search
13
+ * @param options
14
+ * @returns
15
+ */
10
16
  config(options: ProTableConfigOptions): void;
11
17
  };
12
18
  export default ProTable;
@@ -58,6 +58,7 @@ var defaultStyles = {
58
58
  marginBottom: 15
59
59
  }
60
60
  };
61
+ var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
61
62
  var ProTable = (props) => {
62
63
  const {
63
64
  classNames = defaultClassNames,
@@ -66,32 +67,32 @@ var ProTable = (props) => {
66
67
  locale,
67
68
  dataKey = "data",
68
69
  totalKey = "total",
69
- manual = false,
70
70
  nostyle,
71
71
  request = {},
72
72
  columns,
73
73
  form = {},
74
74
  alert,
75
75
  toolbar = null,
76
- pageSizeOptions = [10, 20, 50, 100],
77
76
  pagination,
78
- loadingDelay = 300,
79
77
  scroll,
80
78
  ...prop
81
79
  } = props;
80
+ pagination.showQuickJumper ?? (pagination.showQuickJumper = true);
81
+ pagination.showSizeChanger ?? (pagination.showSizeChanger = true);
82
+ pagination.hideOnSinglePage ?? (pagination.hideOnSinglePage = false);
83
+ pagination.pageSizeOptions ?? (pagination.pageSizeOptions = ProTable.pageSizeOptions);
84
+ pagination.showTotal ?? (pagination.showTotal = (total2) => `共 ${total2} 条记录`);
82
85
  const {
83
86
  title: formTitle,
84
87
  extra: formExtra,
85
88
  right: formRight,
86
- formItem,
87
- items,
89
+ items: formItems,
88
90
  reset: formReset,
89
91
  dataForm,
90
92
  handleValues: formHandleValues,
91
93
  onResetBefore: formOnResetBefore,
92
94
  ...otherFormProps
93
95
  } = form;
94
- const formItems = formItem || items;
95
96
  const { data, page, size, sorter, search, ready, setState } = table.useStore(
96
97
  (0, import_shallow.useShallow)((state) => {
97
98
  return {
@@ -125,8 +126,7 @@ var ProTable = (props) => {
125
126
  setState({
126
127
  data: data2
127
128
  });
128
- },
129
- loadingDelay
129
+ }
130
130
  });
131
131
  const { dataSource, total, column, renderAlert } = (0, import_react.useMemo)(() => {
132
132
  return {
@@ -146,8 +146,9 @@ var ProTable = (props) => {
146
146
  }
147
147
  };
148
148
  const onReset = () => {
149
+ var _a;
149
150
  setState({
150
- size: 10,
151
+ size: ((_a = pagination == null ? void 0 : pagination.pageSizeOptions) == null ? void 0 : _a[0]) ?? ProTable.pageSizeOptions[0],
151
152
  sorter: {}
152
153
  });
153
154
  if (formItems) {
@@ -168,7 +169,7 @@ var ProTable = (props) => {
168
169
  };
169
170
  }
170
171
  (0, import_react.useEffect)(() => {
171
- if (manual)
172
+ if (request.manual)
172
173
  return;
173
174
  if (formItems) {
174
175
  table.form.submit();
@@ -212,14 +213,8 @@ var ProTable = (props) => {
212
213
  pagination: {
213
214
  current: page,
214
215
  pageSize: size,
215
- showQuickJumper: pagination ? pagination.showQuickJumper : true,
216
- showSizeChanger: pagination ? pagination.showSizeChanger : true,
217
- hideOnSinglePage: pagination ? pagination.hideOnSinglePage : false,
218
- pageSizeOptions,
219
216
  total,
220
- showTotal(total2) {
221
- return `共 ${total2} 条记录`;
222
- }
217
+ ...pagination
223
218
  },
224
219
  dataSource,
225
220
  ...prop
@@ -289,7 +284,7 @@ ProTable.getQuery = (options) => {
289
284
  };
290
285
  ProTable.formatDate = import_table.formatDate;
291
286
  ProTable.removeEmpty = import_table.removeEmpty;
292
- ProTable.pageSizeOptions = [10, 20, 50, 100];
287
+ ProTable.pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS;
293
288
  ProTable.config = (options) => {
294
289
  if (!options || !(0, import_util.isObject)(options))
295
290
  return;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import type { FormInstance, TableColumnType, TableProps, FormProps } from "antd";
2
+ import type { FormInstance, TableColumnType, TableProps, FormProps, PaginationProps } from "../../../node_modules/antd";
3
3
  import type { HttpMethod } from "../../fetch";
4
- import type { UseBoundStore, StoreApi } from "zustand";
4
+ import type { UseBoundStore, StoreApi } from "../../../node_modules/zustand";
5
5
  import type { GetQueryProps } from "../../utils/table";
6
6
  type RecordType = Record<string, any>;
7
7
  interface SorterType {
@@ -27,17 +27,16 @@ export interface TableInstance<TData = any> {
27
27
  reset: () => void;
28
28
  sortOrder: (key: string) => any;
29
29
  update: () => void;
30
+ resetStore: () => void;
30
31
  form?: FormInstance;
31
32
  }
32
33
  interface FormOptions extends Omit<FormProps, "form" | "title"> {
33
34
  title?: React.ReactNode;
34
- /** @deprecated 此属性已废弃,请使用新的formItem属性代替 */
35
35
  items?: React.ReactNode | React.ReactNode[];
36
- formItem?: React.ReactNode | React.ReactNode[];
37
36
  extra?: React.ReactNode;
37
+ reset?: boolean;
38
38
  right?: React.ReactNode;
39
39
  handleValues?: (values: Record<string, any>) => any;
40
- reset?: boolean;
41
40
  onResetBefore?: () => void | boolean;
42
41
  dataForm?: FormProps;
43
42
  }
@@ -55,7 +54,10 @@ export interface ProTableProps<Tdata = any> extends Omit<TableProps<Tdata>, "col
55
54
  };
56
55
  request?: {
57
56
  url?: string;
57
+ /** 手动调用发送 table.run */
58
+ manual?: boolean;
58
59
  method?: HttpMethod;
60
+ /** 请求额外参数 */
59
61
  params?: RecordType;
60
62
  onBefore?: () => any;
61
63
  onSuccess?: (data: Tdata) => any;
@@ -64,18 +66,12 @@ export interface ProTableProps<Tdata = any> extends Omit<TableProps<Tdata>, "col
64
66
  locale?: Record<string, any>;
65
67
  dataKey?: string;
66
68
  totalKey?: string;
67
- manual?: boolean;
68
69
  nostyle?: boolean;
69
70
  columns: ((data: Tdata) => TableColumnType<unknown>[]) | TableColumnType<unknown>[];
70
71
  form?: FormOptions;
71
72
  alert?: React.ReactNode | ((data: Tdata) => React.ReactNode);
72
73
  toolbar?: React.ReactNode;
73
- pageSizeOptions?: number[];
74
- pagination?: {
75
- showQuickJumper?: boolean;
76
- showSizeChanger?: boolean;
77
- hideOnSinglePage?: boolean;
78
- };
74
+ pagination?: PaginationProps;
79
75
  loadingDelay?: number;
80
76
  }
81
77
  export interface UseTableProps {
@@ -91,6 +87,7 @@ export interface TableRef {
91
87
  refresh: () => void;
92
88
  reset: () => void;
93
89
  sortOrder: (key: string) => "ascend" | "descend" | null;
90
+ resetStore: () => void;
94
91
  update: () => void;
95
92
  }
96
93
  export interface ProTableConfigOptions {
@@ -30,19 +30,17 @@ var useTable = (options = {}) => {
30
30
  const [form] = import_antd.Form.useForm();
31
31
  const tableRef = (0, import_react.useRef)(null);
32
32
  if (!tableRef.current) {
33
- const useStore = (0, import_zustand.create)((set) => ({
33
+ const initState = {
34
34
  page: options.page ?? 1,
35
35
  size: options.size ?? 10,
36
- sorter: options.sorter || {},
36
+ sorter: options.sorter ?? {},
37
37
  search: {},
38
- params: {
39
- page: options.page ?? 1,
40
- size: options.size ?? 10,
41
- sorter: options.sorter || {},
42
- form: {}
43
- },
38
+ params: {},
44
39
  data: {},
45
- ready: false,
40
+ ready: false
41
+ };
42
+ const useStore = (0, import_zustand.create)((set) => ({
43
+ ...initState,
46
44
  setState(values = {}) {
47
45
  set(values);
48
46
  }
@@ -71,6 +69,9 @@ var useTable = (options = {}) => {
71
69
  }
72
70
  return null;
73
71
  },
72
+ resetStore() {
73
+ useStore.getState().setState(initState);
74
+ },
74
75
  update: () => update((v) => v + 1)
75
76
  };
76
77
  useStore.subscribe((state, prevState) => {
@@ -1,6 +1,6 @@
1
1
  import type { HttpClientConfig, HttpMethod } from "../fetch";
2
- import type { Result } from "ahooks/lib/useRequest/src/types";
3
- import type { Options } from "ahooks/lib/useRequest/src/types";
2
+ import type { Result } from "../../node_modules/ahooks";
3
+ import type { Options } from "../../node_modules/ahooks";
4
4
  export interface UseFetchOption<TData = any> extends Options<TData, any[]> {
5
5
  ignoreError?: boolean;
6
6
  returnData?: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { HttpMethod } from "../fetch";
2
- import type { UseMutationResult, UseMutationOptions } from "@tanstack/react-query";
2
+ import type { UseMutationResult, UseMutationOptions } from "../../node_modules/@tanstack/react-query";
3
3
  interface Options<TData, TError = unknown, TVariables = void, TOnMutateResult = unknown> extends UseMutationOptions<TData, TError, TVariables, TOnMutateResult> {
4
4
  url: string;
5
5
  method?: HttpMethod;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuand",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "hyu",
5
5
  "module": "./es/index",
6
6
  "main": "./lib/index",
@@ -11,7 +11,10 @@
11
11
  "build": "sudo father build",
12
12
  "build:deps": "father prebundle",
13
13
  "prepublishOnly": "father doctor && npm run build",
14
- "publish": "npm publish --access public"
14
+ "publish": "npm publish --access public",
15
+ "test": "vitest",
16
+ "test:ui": "vitest --ui",
17
+ "test:coverage": "vitest --coverage"
15
18
  },
16
19
  "keywords": [],
17
20
  "authors": [
@@ -25,11 +28,18 @@
25
28
  ],
26
29
  "devDependencies": {
27
30
  "@rc-component/father-plugin": "^2.1.3",
31
+ "@testing-library/jest-dom": "^6.6.3",
32
+ "@testing-library/react": "^16.1.0",
33
+ "@testing-library/user-event": "^14.5.2",
28
34
  "@types/react": "^18.3.12",
29
35
  "@types/react-dom": "^18.3.1",
36
+ "@vitejs/plugin-react": "^4.3.4",
37
+ "@vitest/ui": "^2.1.8",
30
38
  "babel-plugin-import": "^1.13.8",
31
39
  "father": "^4.6.9",
32
- "typescript": "^5.9.3"
40
+ "jsdom": "^25.0.1",
41
+ "typescript": "^5.9.3",
42
+ "vitest": "^2.1.8"
33
43
  },
34
44
  "dependencies": {
35
45
  "@babel/runtime": "^7.28.4",