yuand 1.0.3 → 1.0.5
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.
|
@@ -11,31 +11,40 @@ import useFetch from "../../hooks/useFetch";
|
|
|
11
11
|
import useX from "../../hooks/useX";
|
|
12
12
|
import useTable from "./useTable";
|
|
13
13
|
import "./style.css";
|
|
14
|
+
|
|
15
|
+
// 统一默认配置管理
|
|
14
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
|
|
19
|
+
var DEFAULT_CONFIG = {
|
|
20
|
+
classNames: {
|
|
21
|
+
root: "main-container",
|
|
22
|
+
form: "search-form",
|
|
23
|
+
table: "main-table"
|
|
24
|
+
},
|
|
25
|
+
styles: {
|
|
26
|
+
root: {},
|
|
27
|
+
form: {
|
|
28
|
+
display: "flex",
|
|
29
|
+
justifyContent: "space-between"
|
|
30
|
+
},
|
|
31
|
+
table: {},
|
|
32
|
+
toolbar: {
|
|
33
|
+
marginBottom: 15
|
|
34
|
+
}
|
|
26
35
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
pagination: {
|
|
37
|
+
showQuickJumper: true,
|
|
38
|
+
showSizeChanger: true,
|
|
39
|
+
hideOnSinglePage: false
|
|
30
40
|
}
|
|
31
41
|
};
|
|
32
|
-
var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
|
|
33
42
|
var ProTable = function ProTable(props) {
|
|
34
|
-
var _pagination$
|
|
43
|
+
var _pagination$showTotal, _pagination$pageSizeO, _classNames$root, _classNames$form, _classNames$table;
|
|
35
44
|
var _props$classNames = props.classNames,
|
|
36
|
-
classNames = _props$classNames === void 0 ?
|
|
45
|
+
classNames = _props$classNames === void 0 ? DEFAULT_CONFIG.classNames : _props$classNames,
|
|
37
46
|
_props$styles = props.styles,
|
|
38
|
-
styles = _props$styles === void 0 ?
|
|
47
|
+
styles = _props$styles === void 0 ? DEFAULT_CONFIG.styles : _props$styles,
|
|
39
48
|
table = props.table,
|
|
40
49
|
locale = props.locale,
|
|
41
50
|
_props$dataKey = props.dataKey,
|
|
@@ -51,16 +60,14 @@ var ProTable = function ProTable(props) {
|
|
|
51
60
|
alert = props.alert,
|
|
52
61
|
_props$toolbar = props.toolbar,
|
|
53
62
|
toolbar = _props$toolbar === void 0 ? null : _props$toolbar,
|
|
54
|
-
pagination = props.pagination,
|
|
63
|
+
_props$pagination = props.pagination,
|
|
64
|
+
pagination = _props$pagination === void 0 ? DEFAULT_CONFIG.pagination : _props$pagination,
|
|
55
65
|
scroll = props.scroll,
|
|
56
66
|
prop = _objectWithoutProperties(props, _excluded);
|
|
57
|
-
(_pagination$showQuick = pagination.showQuickJumper) !== null && _pagination$showQuick !== void 0 ? _pagination$showQuick : pagination.showQuickJumper = true;
|
|
58
|
-
(_pagination$showSizeC = pagination.showSizeChanger) !== null && _pagination$showSizeC !== void 0 ? _pagination$showSizeC : pagination.showSizeChanger = true;
|
|
59
|
-
(_pagination$hideOnSin = pagination.hideOnSinglePage) !== null && _pagination$hideOnSin !== void 0 ? _pagination$hideOnSin : pagination.hideOnSinglePage = false;
|
|
60
|
-
(_pagination$pageSizeO = pagination.pageSizeOptions) !== null && _pagination$pageSizeO !== void 0 ? _pagination$pageSizeO : pagination.pageSizeOptions = ProTable.pageSizeOptions;
|
|
61
67
|
(_pagination$showTotal = pagination.showTotal) !== null && _pagination$showTotal !== void 0 ? _pagination$showTotal : pagination.showTotal = function (total) {
|
|
62
68
|
return "\u5171 ".concat(total, " \u6761\u8BB0\u5F55");
|
|
63
69
|
};
|
|
70
|
+
(_pagination$pageSizeO = pagination.pageSizeOptions) !== null && _pagination$pageSizeO !== void 0 ? _pagination$pageSizeO : pagination.pageSizeOptions = ProTable.pageSizeOptions;
|
|
64
71
|
var formTitle = form.title,
|
|
65
72
|
formExtra = form.extra,
|
|
66
73
|
formRight = form.right,
|
|
@@ -163,6 +170,11 @@ var ProTable = function ProTable(props) {
|
|
|
163
170
|
ready: true
|
|
164
171
|
});
|
|
165
172
|
}
|
|
173
|
+
}, []);
|
|
174
|
+
useEffect(function () {
|
|
175
|
+
return function () {
|
|
176
|
+
table.resetStore();
|
|
177
|
+
};
|
|
166
178
|
}, [table]);
|
|
167
179
|
var onFinish = function onFinish(values) {
|
|
168
180
|
if (formHandleValues) {
|
|
@@ -206,10 +218,10 @@ var ProTable = function ProTable(props) {
|
|
|
206
218
|
}, prop));
|
|
207
219
|
};
|
|
208
220
|
return /*#__PURE__*/_jsxs("div", {
|
|
209
|
-
className: (_classNames$root = classNames === null || classNames === void 0 ? void 0 : classNames.root) !== null && _classNames$root !== void 0 ? _classNames$root :
|
|
221
|
+
className: (_classNames$root = classNames === null || classNames === void 0 ? void 0 : classNames.root) !== null && _classNames$root !== void 0 ? _classNames$root : DEFAULT_CONFIG.classNames.root,
|
|
210
222
|
style: styles.root,
|
|
211
223
|
children: [!!formItems && /*#__PURE__*/_jsxs("div", {
|
|
212
|
-
className: (_classNames$form = classNames === null || classNames === void 0 ? void 0 : classNames.form) !== null && _classNames$form !== void 0 ? _classNames$form :
|
|
224
|
+
className: (_classNames$form = classNames === null || classNames === void 0 ? void 0 : classNames.form) !== null && _classNames$form !== void 0 ? _classNames$form : DEFAULT_CONFIG.classNames.form,
|
|
213
225
|
style: styles.form,
|
|
214
226
|
children: [/*#__PURE__*/_jsxs(Form, _objectSpread(_objectSpread({
|
|
215
227
|
form: table.form,
|
|
@@ -234,7 +246,7 @@ var ProTable = function ProTable(props) {
|
|
|
234
246
|
})]
|
|
235
247
|
})), formRight]
|
|
236
248
|
}), /*#__PURE__*/_jsxs("div", {
|
|
237
|
-
className: (_classNames$table = classNames === null || classNames === void 0 ? void 0 : classNames.table) !== null && _classNames$table !== void 0 ? _classNames$table :
|
|
249
|
+
className: (_classNames$table = classNames === null || classNames === void 0 ? void 0 : classNames.table) !== null && _classNames$table !== void 0 ? _classNames$table : DEFAULT_CONFIG.classNames.table,
|
|
238
250
|
style: styles.table,
|
|
239
251
|
children: [toolbar && /*#__PURE__*/_jsx("div", {
|
|
240
252
|
style: styles.toolbar,
|
|
@@ -42,27 +42,29 @@ var import_useX = __toESM(require("../../hooks/useX"));
|
|
|
42
42
|
var import_useTable = __toESM(require("./useTable"));
|
|
43
43
|
var import_style = require("./style.css");
|
|
44
44
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
root: {},
|
|
52
|
-
form: {
|
|
53
|
-
display: "flex",
|
|
54
|
-
justifyContent: "space-between"
|
|
45
|
+
var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
|
|
46
|
+
var DEFAULT_CONFIG = {
|
|
47
|
+
classNames: {
|
|
48
|
+
root: "main-container",
|
|
49
|
+
form: "search-form",
|
|
50
|
+
table: "main-table"
|
|
55
51
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
styles: {
|
|
53
|
+
root: {},
|
|
54
|
+
form: { display: "flex", justifyContent: "space-between" },
|
|
55
|
+
table: {},
|
|
56
|
+
toolbar: { marginBottom: 15 }
|
|
57
|
+
},
|
|
58
|
+
pagination: {
|
|
59
|
+
showQuickJumper: true,
|
|
60
|
+
showSizeChanger: true,
|
|
61
|
+
hideOnSinglePage: false
|
|
59
62
|
}
|
|
60
63
|
};
|
|
61
|
-
var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
|
|
62
64
|
var ProTable = (props) => {
|
|
63
65
|
const {
|
|
64
|
-
classNames =
|
|
65
|
-
styles =
|
|
66
|
+
classNames = DEFAULT_CONFIG.classNames,
|
|
67
|
+
styles = DEFAULT_CONFIG.styles,
|
|
66
68
|
table,
|
|
67
69
|
locale,
|
|
68
70
|
dataKey = "data",
|
|
@@ -73,15 +75,12 @@ var ProTable = (props) => {
|
|
|
73
75
|
form = {},
|
|
74
76
|
alert,
|
|
75
77
|
toolbar = null,
|
|
76
|
-
pagination,
|
|
78
|
+
pagination = DEFAULT_CONFIG.pagination,
|
|
77
79
|
scroll,
|
|
78
80
|
...prop
|
|
79
81
|
} = 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
82
|
pagination.showTotal ?? (pagination.showTotal = (total2) => `共 ${total2} 条记录`);
|
|
83
|
+
pagination.pageSizeOptions ?? (pagination.pageSizeOptions = ProTable.pageSizeOptions);
|
|
85
84
|
const {
|
|
86
85
|
title: formTitle,
|
|
87
86
|
extra: formExtra,
|
|
@@ -178,6 +177,11 @@ var ProTable = (props) => {
|
|
|
178
177
|
ready: true
|
|
179
178
|
});
|
|
180
179
|
}
|
|
180
|
+
}, []);
|
|
181
|
+
(0, import_react.useEffect)(() => {
|
|
182
|
+
return () => {
|
|
183
|
+
table.resetStore();
|
|
184
|
+
};
|
|
181
185
|
}, [table]);
|
|
182
186
|
const onFinish = (values) => {
|
|
183
187
|
if (formHandleValues) {
|
|
@@ -224,13 +228,13 @@ var ProTable = (props) => {
|
|
|
224
228
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
225
229
|
"div",
|
|
226
230
|
{
|
|
227
|
-
className: (classNames == null ? void 0 : classNames.root) ??
|
|
231
|
+
className: (classNames == null ? void 0 : classNames.root) ?? DEFAULT_CONFIG.classNames.root,
|
|
228
232
|
style: styles.root,
|
|
229
233
|
children: [
|
|
230
234
|
!!formItems && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
231
235
|
"div",
|
|
232
236
|
{
|
|
233
|
-
className: (classNames == null ? void 0 : classNames.form) ??
|
|
237
|
+
className: (classNames == null ? void 0 : classNames.form) ?? DEFAULT_CONFIG.classNames.form,
|
|
234
238
|
style: styles.form,
|
|
235
239
|
children: [
|
|
236
240
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
@@ -258,7 +262,7 @@ var ProTable = (props) => {
|
|
|
258
262
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
259
263
|
"div",
|
|
260
264
|
{
|
|
261
|
-
className: (classNames == null ? void 0 : classNames.table) ??
|
|
265
|
+
className: (classNames == null ? void 0 : classNames.table) ?? DEFAULT_CONFIG.classNames.table,
|
|
262
266
|
style: styles.table,
|
|
263
267
|
children: [
|
|
264
268
|
toolbar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: styles.toolbar, children: toolbar }),
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuand",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "hyu",
|
|
5
5
|
"module": "./es/index",
|
|
6
6
|
"main": "./lib/index",
|
|
7
7
|
"types": "./es/index.d.ts",
|
|
8
|
-
"repository": "
|
|
8
|
+
"repository": "https://github.com/hyusuyi/yuand.git",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "father dev",
|
|
11
11
|
"build": "sudo father build",
|