xmirror-components 1.0.30-alpha.7 → 1.0.30

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.
Files changed (76) hide show
  1. package/README.md +1158 -10
  2. package/build/dist/index.cjs +65 -34
  3. package/build/dist/index.mjs +4342 -2757
  4. package/build/es/components/ConfigProvider/index.js +11 -14
  5. package/build/es/components/ConfigProvider/types.d.ts +2 -0
  6. package/build/es/components/IntlProvider/FormattedMessage/index.d.ts +7 -0
  7. package/build/es/components/IntlProvider/FormattedMessage/index.js +8 -0
  8. package/build/es/components/IntlProvider/index.d.ts +12 -0
  9. package/build/es/components/IntlProvider/index.js +17 -0
  10. package/build/es/components/IntlProvider/types.d.ts +7 -0
  11. package/build/es/components/IntlProvider/types.js +1 -0
  12. package/build/es/components/IntlProvider/useIntl/index.d.ts +14 -0
  13. package/build/es/components/IntlProvider/useIntl/index.js +26 -0
  14. package/build/es/components/SearchArea/ToggleButton/index.js +2 -1
  15. package/build/es/components/SearchArea/index.js +6 -3
  16. package/build/es/components/Table/Footer/index.d.ts +1 -1
  17. package/build/es/components/Table/Footer/index.js +1 -1
  18. package/build/es/components/Table/PopoverSetColumns/index.js +1 -1
  19. package/build/es/components/Table/ResizableColumns/index.d.ts +9 -0
  20. package/build/es/components/Table/ResizableColumns/index.js +76 -0
  21. package/build/es/components/Table/ResizableColumns/styles.d.ts +8 -0
  22. package/build/es/components/Table/ResizableColumns/styles.js +11 -0
  23. package/build/es/components/Table/index.js +3 -2
  24. package/build/es/components/Table/types.d.ts +4 -0
  25. package/build/es/components/Table/utils.d.ts +6 -0
  26. package/build/es/components/Table/utils.js +13 -0
  27. package/build/es/hooks/useTable/index.js +20 -14
  28. package/build/es/hooks/useTable/types.d.ts +8 -29
  29. package/build/es/locale/en-us.d.ts +25 -0
  30. package/build/es/locale/en-us.js +27 -0
  31. package/build/es/locale/index.d.ts +3 -0
  32. package/build/es/locale/index.js +7 -0
  33. package/build/es/locale/types.d.ts +9 -0
  34. package/build/es/locale/types.js +1 -0
  35. package/build/es/locale/zh-cn.d.ts +25 -0
  36. package/build/es/locale/zh-cn.js +28 -0
  37. package/build/lib/components/ConfigProvider/index.js +11 -14
  38. package/build/lib/components/IntlProvider/FormattedMessage/index.js +11 -0
  39. package/build/lib/components/IntlProvider/index.js +25 -0
  40. package/build/lib/components/IntlProvider/types.js +2 -0
  41. package/build/lib/components/IntlProvider/useIntl/index.js +31 -0
  42. package/build/lib/components/SearchArea/ToggleButton/index.js +2 -1
  43. package/build/lib/components/SearchArea/index.js +6 -3
  44. package/build/lib/components/Table/Footer/index.js +2 -2
  45. package/build/lib/components/Table/PopoverSetColumns/index.js +2 -2
  46. package/build/lib/components/Table/ResizableColumns/index.js +114 -0
  47. package/build/lib/components/Table/ResizableColumns/styles.js +17 -0
  48. package/build/lib/components/Table/index.js +3 -2
  49. package/build/lib/components/Table/utils.js +17 -0
  50. package/build/lib/hooks/useTable/index.js +21 -15
  51. package/build/lib/index.d.ts +8 -36
  52. package/build/lib/locale/en-us.d.ts +25 -0
  53. package/build/lib/locale/en-us.js +29 -0
  54. package/build/lib/locale/index.d.ts +3 -0
  55. package/build/lib/locale/index.js +13 -0
  56. package/build/lib/locale/types.d.ts +9 -0
  57. package/build/lib/locale/types.js +2 -0
  58. package/build/lib/locale/zh-cn.d.ts +25 -0
  59. package/build/lib/locale/zh-cn.js +30 -0
  60. package/build/package.json +7 -5
  61. package/build/types/components/ConfigProvider/types.d.ts +2 -0
  62. package/build/types/components/IntlProvider/FormattedMessage/index.d.ts +7 -0
  63. package/build/types/components/IntlProvider/index.d.ts +12 -0
  64. package/build/types/components/IntlProvider/types.d.ts +7 -0
  65. package/build/types/components/IntlProvider/useIntl/index.d.ts +14 -0
  66. package/build/types/components/Table/Footer/index.d.ts +1 -1
  67. package/build/types/components/Table/ResizableColumns/index.d.ts +9 -0
  68. package/build/types/components/Table/ResizableColumns/styles.d.ts +8 -0
  69. package/build/types/components/Table/types.d.ts +4 -0
  70. package/build/types/components/Table/utils.d.ts +6 -0
  71. package/build/types/hooks/useTable/types.d.ts +8 -29
  72. package/build/types/locale/en-us.d.ts +25 -0
  73. package/build/types/locale/index.d.ts +3 -0
  74. package/build/types/locale/types.d.ts +9 -0
  75. package/build/types/locale/zh-cn.d.ts +25 -0
  76. package/package.json +7 -5
@@ -0,0 +1,25 @@
1
+ declare const messages: {
2
+ 'operation.add': string;
3
+ 'operation.delete': string;
4
+ 'operation.batchDelete': string;
5
+ 'operation.edit': string;
6
+ 'operation.download': string;
7
+ 'operation.logout': string;
8
+ 'operation.export': string;
9
+ 'operation.close': string;
10
+ 'operation.details': string;
11
+ 'operation.confirm': string;
12
+ 'operation.save': string;
13
+ 'operation.cancel': string;
14
+ 'component.table.selected': string;
15
+ 'component.table.total': string;
16
+ 'component.table.visibleError': string;
17
+ 'component.searcharea.toggle': string;
18
+ 'component.searcharea.submit': string;
19
+ 'component.searcharea.reset': string;
20
+ 'component.searcharea.close': string;
21
+ 'message.delete': string;
22
+ 'message.success': string;
23
+ 'table.pagination.total': string;
24
+ };
25
+ export default messages;
@@ -0,0 +1,28 @@
1
+ var messages = {
2
+ // 操作类
3
+ 'operation.add': '添加',
4
+ 'operation.delete': '删除',
5
+ 'operation.batchDelete': '批量删除',
6
+ 'operation.edit': '编辑',
7
+ 'operation.download': '下载',
8
+ 'operation.logout': '退出登录',
9
+ 'operation.export': '导出',
10
+ 'operation.close': '关闭',
11
+ 'operation.details': '详情',
12
+ 'operation.confirm': '确认',
13
+ 'operation.save': '保存',
14
+ 'operation.cancel': '取消',
15
+ // 组件
16
+ 'component.table.selected': '已选{length}条',
17
+ 'component.table.total': '共{total}条',
18
+ 'component.table.visibleError': '列表最少保留一个字段',
19
+ 'component.searcharea.toggle': '高级搜索',
20
+ 'component.searcharea.submit': '筛选',
21
+ 'component.searcharea.reset': '重置',
22
+ 'component.searcharea.close': '收起',
23
+ // 提示类
24
+ 'message.delete': '删除操作无法恢复,确认删除?',
25
+ 'message.success': '操作成功',
26
+ 'table.pagination.total': '共{total}条',
27
+ };
28
+ export default messages;
@@ -10,17 +10,6 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
25
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
15
  };
@@ -28,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
28
17
  exports.ConfigContext = void 0;
29
18
  exports.default = ConfigProvider;
30
19
  var react_1 = __importDefault(require("react"));
20
+ var IntlProvider_1 = __importDefault(require("../IntlProvider"));
21
+ var locale_1 = require("../../locale");
31
22
  // 递归合并函数
32
23
  function deepMerge(target, source) {
33
24
  var result = __assign({}, target);
@@ -47,14 +38,20 @@ var baseConfig = {
47
38
  iconButton: {
48
39
  size: 'small',
49
40
  render: function (_a) {
50
- var children = _a.children, params = __rest(_a, ["children"]);
41
+ var children = _a.children;
51
42
  return children;
52
43
  }
53
44
  },
54
- iconFont: {}
45
+ iconFont: {},
46
+ locale: 'zh'
55
47
  };
56
48
  exports.ConfigContext = react_1.default.createContext(baseConfig);
57
49
  function ConfigProvider(_a) {
58
50
  var children = _a.children, config = _a.config;
59
- return (react_1.default.createElement(exports.ConfigContext.Provider, { value: deepMerge(baseConfig, config) }, children));
51
+ var mergeConfig = deepMerge(baseConfig, config);
52
+ return (react_1.default.createElement(exports.ConfigContext.Provider, { value: mergeConfig },
53
+ react_1.default.createElement(IntlProvider_1.default, { config: {
54
+ locale: config.locale,
55
+ messages: locale_1.messages
56
+ } }, children)));
60
57
  }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = FormattedMessage;
4
+ var react_1 = require("react");
5
+ var index_1 = require("../index");
6
+ var useIntl_1 = require("../useIntl");
7
+ function FormattedMessage(_a) {
8
+ var id = _a.id, defaultMessage = _a.defaultMessage, values = _a.values;
9
+ var _b = (0, react_1.useContext)(index_1.IntlContext), messages = _b.messages, locale = _b.locale;
10
+ return (0, useIntl_1.formatMessageFn)({ messages: messages, locale: locale })({ id: id, defaultMessage: defaultMessage, values: values });
11
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useIntl = exports.FormattedMessage = exports.IntlContext = void 0;
7
+ exports.default = IntlProvider;
8
+ var react_1 = __importDefault(require("react"));
9
+ var locale_1 = require("../../locale");
10
+ var FormattedMessage_1 = __importDefault(require("./FormattedMessage"));
11
+ exports.FormattedMessage = FormattedMessage_1.default;
12
+ var useIntl_1 = __importDefault(require("./useIntl"));
13
+ exports.useIntl = useIntl_1.default;
14
+ var baseConfig = {
15
+ locale: 'zh',
16
+ messages: locale_1.messages
17
+ };
18
+ exports.IntlContext = react_1.default.createContext(baseConfig);
19
+ function IntlProvider(_a) {
20
+ var children = _a.children, config = _a.config;
21
+ return (react_1.default.createElement(exports.IntlContext.Provider, { value: {
22
+ locale: config.locale,
23
+ messages: locale_1.messages
24
+ } }, children));
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatMessageFn = void 0;
4
+ exports.default = useIntl;
5
+ var react_1 = require("react");
6
+ var index_1 = require("../index");
7
+ var formatMessageFn = function (_a) {
8
+ var messages = _a.messages, locale = _a.locale;
9
+ return function (_a) {
10
+ var _b;
11
+ var id = _a.id, defaultMessage = _a.defaultMessage, values = _a.values;
12
+ var message = ((_b = messages === null || messages === void 0 ? void 0 : messages[locale]) === null || _b === void 0 ? void 0 : _b[id]) || defaultMessage;
13
+ if (typeof values === 'object') {
14
+ Object.keys(values).forEach(function (key) {
15
+ message = message.replace("{".concat(key, "}"), values[key]);
16
+ });
17
+ }
18
+ return message;
19
+ };
20
+ };
21
+ exports.formatMessageFn = formatMessageFn;
22
+ function useIntl() {
23
+ var _a = (0, react_1.useContext)(index_1.IntlContext), messages = _a.messages, locale = _a.locale;
24
+ return {
25
+ $t: function (_a, values) {
26
+ var id = _a.id, defaultMessage = _a.defaultMessage;
27
+ return (0, exports.formatMessageFn)({ messages: messages, locale: locale })({ id: id, defaultMessage: defaultMessage, values: values });
28
+ },
29
+ formatMessage: (0, exports.formatMessageFn)({ messages: messages, locale: locale })
30
+ };
31
+ }
@@ -44,6 +44,7 @@ var react_1 = __importStar(require("react"));
44
44
  var antd_1 = require("antd");
45
45
  var icons_1 = require("@ant-design/icons");
46
46
  var styled_1 = __importDefault(require("@emotion/styled"));
47
+ var IntlProvider_1 = require("../../IntlProvider");
47
48
  var AnimatedIcon = (0, styled_1.default)(icons_1.CaretUpOutlined, {
48
49
  shouldForwardProp: function (prop) { return prop !== 'show'; },
49
50
  })(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n transition: transform 0.3s ease-in-out;\n transform: rotate(", ");\n"], ["\n transition: transform 0.3s ease-in-out;\n transform: rotate(", ");\n"])), function (props) { return props.show ? '0deg' : '180deg'; });
@@ -62,7 +63,7 @@ function ToggleButton(_a) {
62
63
  onChange === null || onChange === void 0 ? void 0 : onChange(!(panel === null || panel === void 0 ? void 0 : panel.show));
63
64
  }, [panel]);
64
65
  return (react_1.default.createElement(antd_1.Button, { type: "link", style: { paddingLeft: 0, paddingRight: 0 }, onClick: toggle },
65
- "\u9AD8\u7EA7\u641C\u7D22",
66
+ react_1.default.createElement(IntlProvider_1.FormattedMessage, { id: "comgponent.searcharea.togle", defaultMessage: '高级搜索' }),
66
67
  react_1.default.createElement(AnimatedIcon, { show: show })));
67
68
  }
68
69
  exports.default = ToggleButton;
@@ -68,6 +68,7 @@ var icons_1 = require("@ant-design/icons");
68
68
  var styled_1 = __importDefault(require("@emotion/styled"));
69
69
  var Item_1 = __importDefault(require("./Item"));
70
70
  var ToggleButton_1 = __importDefault(require("./ToggleButton"));
71
+ var IntlProvider_1 = require("../IntlProvider");
71
72
  var AnimatedContainer = (0, styled_1.default)('div', {
72
73
  shouldForwardProp: function (prop) { return prop !== 'show'; },
73
74
  })(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n overflow: hidden;\n transition: max-height 0.4s ease-in-out;\n max-height: ", ";\n"], ["\n overflow: hidden;\n transition: max-height 0.4s ease-in-out;\n max-height: ", ";\n"])), function (props) { return props.show ? '450px' : '0'; });
@@ -144,13 +145,15 @@ function InternalSearchArea(_a) {
144
145
  : children,
145
146
  react_1.default.createElement(antd_1.Col, { flex: 1 },
146
147
  react_1.default.createElement(SearchAreaHandle, null,
147
- react_1.default.createElement(antd_1.Button, { loading: loading, type: "primary", onClick: submit }, "\u7B5B\u9009"),
148
- react_1.default.createElement(antd_1.Button, { loading: loading, onClick: reset }, "\u91CD\u7F6E"),
148
+ react_1.default.createElement(antd_1.Button, { loading: loading, type: "primary", onClick: submit },
149
+ react_1.default.createElement(IntlProvider_1.FormattedMessage, { id: "component.searcharea.submit", defaultMessage: '筛选' })),
150
+ react_1.default.createElement(antd_1.Button, { loading: loading, onClick: reset },
151
+ react_1.default.createElement(IntlProvider_1.FormattedMessage, { id: "component.searcharea.reset", defaultMessage: '重置' })),
149
152
  react_1.default.createElement(antd_1.Button, { type: "link", style: {
150
153
  paddingLeft: 0,
151
154
  paddingRight: 0
152
155
  }, onClick: close },
153
- "\u6536\u8D77",
156
+ react_1.default.createElement(IntlProvider_1.FormattedMessage, { id: "component.searcharea.close", defaultMessage: '收起' }),
154
157
  react_1.default.createElement(icons_1.UpOutlined, null))))))));
155
158
  }
156
159
  var SearchArea = InternalSearchArea;
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  var react_1 = __importStar(require("react"));
37
- var react_intl_1 = require("react-intl");
37
+ var IntlProvider_1 = require("../../IntlProvider");
38
38
  var antd_1 = require("antd");
39
39
  var react_transition_group_1 = require("react-transition-group");
40
40
  var icons_1 = require("@ant-design/icons");
@@ -111,7 +111,7 @@ function Index(props) {
111
111
  return (react_1.default.createElement(styles_1.StyledRow, { ref: transitionNodeRef, justify: "space-between" },
112
112
  react_1.default.createElement(antd_1.Col, { style: { display: 'flex', alignItems: 'center' } },
113
113
  react_1.default.createElement(antd_1.Checkbox, { checked: checked, indeterminate: indeterminate, onChange: changeCheckAll },
114
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "component.table.selected", defaultMessage: '已选{length}条', values: {
114
+ react_1.default.createElement(IntlProvider_1.FormattedMessage, { id: "component.table.selected", defaultMessage: '已选{length}条', values: {
115
115
  length: (_b = (_a = rowSelection.selectedRowKeys) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0
116
116
  } }))),
117
117
  react_1.default.createElement(antd_1.Col, { style: { display: 'flex', alignItems: 'center' } },
@@ -47,7 +47,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  var react_1 = __importStar(require("react"));
49
49
  var antd_1 = require("antd");
50
- var react_intl_1 = require("react-intl");
50
+ var IntlProvider_1 = require("../../IntlProvider");
51
51
  var icons_1 = require("@ant-design/icons");
52
52
  // import { message, IconFont } from 'xmirror-components'
53
53
  var AntdApp_1 = require("../../AntdApp");
@@ -122,7 +122,7 @@ function PopoverSetColumns(_a) {
122
122
  var checked = _a.target.checked;
123
123
  var dataIndex = _b.dataIndex;
124
124
  if (visibleItems.length === 1 && !checked) {
125
- AntdApp_1.message.error(react_1.default.createElement(react_intl_1.FormattedMessage, { id: "component.table.visibleError", defaultMessage: '列表最少保留一个字段' }));
125
+ AntdApp_1.message.error(react_1.default.createElement(IntlProvider_1.FormattedMessage, { id: "component.table.visibleError", defaultMessage: '列表最少保留一个字段' }));
126
126
  return;
127
127
  }
128
128
  var id = Array.isArray(dataIndex) ? dataIndex.join(',') : dataIndex;
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __rest = (this && this.__rest) || function (s, e) {
47
+ var t = {};
48
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
+ t[p] = s[p];
50
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
+ t[p[i]] = s[p[i]];
54
+ }
55
+ return t;
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.resizableColumns = exports.ResizableTitle = void 0;
59
+ var react_1 = __importStar(require("react"));
60
+ var ahooks_1 = require("ahooks");
61
+ var icons_1 = require("@ant-design/icons");
62
+ var react_resizable_1 = require("react-resizable");
63
+ var utils_1 = require("../utils");
64
+ var styles_1 = require("./styles");
65
+ var ResizableTitle = function (props) {
66
+ var onResize = props.onResize, width = props.width, restProps = __rest(props, ["onResize", "width"]);
67
+ var _a = (0, react_1.useState)(false), resizing = _a[0], setResizing = _a[1];
68
+ if (!width) {
69
+ return react_1.default.createElement("th", __assign({}, restProps));
70
+ }
71
+ var onResizeStart = function (_e) {
72
+ setResizing(true);
73
+ };
74
+ var onResizeStop = function (_e) {
75
+ setResizing(false);
76
+ };
77
+ return (react_1.default.createElement(react_resizable_1.Resizable, { width: width, height: 0, handle: react_1.default.createElement(styles_1.ResizableHandle, { className: resizing ? 'resizing' : '', onClick: function (e) { return e.stopPropagation(); } },
78
+ react_1.default.createElement(icons_1.MenuOutlined, { className: "react-resizable-handle-icon" })), onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, draggableOpts: { enableUserSelectHack: false } },
79
+ react_1.default.createElement("th", __assign({}, restProps))));
80
+ };
81
+ exports.ResizableTitle = ResizableTitle;
82
+ var resizableColumns = function (columns, tableId) {
83
+ // const [columnsWidth, setColumnsWidth] = useSetState({})
84
+ var _a = (0, ahooks_1.useLocalStorageState)('table-resizable_' + tableId, {}), columnsWidth = _a[0], setColumnsWidth = _a[1];
85
+ var handleResize = function (column) {
86
+ return function (_, _a) {
87
+ var size = _a.size;
88
+ var dataIndex = (0, utils_1.dataIndexToString)(column === null || column === void 0 ? void 0 : column.dataIndex);
89
+ setColumnsWidth(function (value) {
90
+ var _a;
91
+ return __assign(__assign({}, value), (_a = {}, _a[dataIndex] = size.width, _a));
92
+ });
93
+ };
94
+ };
95
+ return (0, react_1.useMemo)(function () {
96
+ return columns.map(function (col) {
97
+ var dataIndex = col.dataIndex;
98
+ if (Array.isArray(col.dataIndex)) {
99
+ dataIndex = col.dataIndex.join('.');
100
+ }
101
+ else {
102
+ dataIndex = col.dataIndex;
103
+ }
104
+ var width = (columnsWidth === null || columnsWidth === void 0 ? void 0 : columnsWidth[dataIndex]) || col.width;
105
+ return __assign(__assign({}, col), { width: width, onHeaderCell: function (column) {
106
+ return {
107
+ width: column.width,
108
+ onResize: handleResize(column)
109
+ };
110
+ } });
111
+ });
112
+ }, [columns, columnsWidth]);
113
+ };
114
+ exports.resizableColumns = resizableColumns;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ResizableHandle = void 0;
11
+ var styled_1 = __importDefault(require("@emotion/styled"));
12
+ /**
13
+ * 可调整大小的列拖拽手柄样式组件
14
+ * 用于表格列宽调整功能
15
+ */
16
+ exports.ResizableHandle = styled_1.default.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 6px;\n height: 30px;\n margin: auto 0;\n text-align: center;\n cursor: col-resize;\n user-select: none;\n background: #f0f0f0;\n border: 1px solid #d3d3d3;\n border-radius: 3px;\n opacity: 0;\n transition: all 0.1s;\n\n &.resizing,\n &:hover {\n opacity: 1;\n }\n\n .react-resizable-handle-icon {\n display: inline-block;\n transform: rotateZ(90deg) scale(0.3);\n }\n"], ["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 6px;\n height: 30px;\n margin: auto 0;\n text-align: center;\n cursor: col-resize;\n user-select: none;\n background: #f0f0f0;\n border: 1px solid #d3d3d3;\n border-radius: 3px;\n opacity: 0;\n transition: all 0.1s;\n\n &.resizing,\n &:hover {\n opacity: 1;\n }\n\n .react-resizable-handle-icon {\n display: inline-block;\n transform: rotateZ(90deg) scale(0.3);\n }\n"])));
17
+ var templateObject_1;
@@ -53,9 +53,10 @@ var ahooks_1 = require("ahooks");
53
53
  var icons_1 = require("@ant-design/icons");
54
54
  var PopoverSetColumns_1 = __importDefault(require("./PopoverSetColumns"));
55
55
  var Footer_1 = __importDefault(require("./Footer"));
56
+ var ResizableColumns_1 = require("./ResizableColumns");
56
57
  var styles_1 = require("./styles");
57
58
  function Index(props, ref) {
58
- var _a = props.columns, columns = _a === void 0 ? [] : _a, columnsSort = props.columnsSort, columnsVisible = props.columnsVisible, _b = props.tableId, tableId = _b === void 0 ? '' : _b, pagination = props.pagination, dataSource = props.dataSource;
59
+ var _a = props.columns, columns = _a === void 0 ? [] : _a, columnsSort = props.columnsSort, columnsVisible = props.columnsVisible, _b = props.tableId, tableId = _b === void 0 ? '' : _b, pagination = props.pagination, dataSource = props.dataSource, columnsResizable = props.columnsResizable;
59
60
  var pathname = location.pathname;
60
61
  var _tableId = pathname + tableId;
61
62
  var _c = (0, ahooks_1.useLocalStorageState)('TABLE_' + _tableId, {
@@ -222,6 +223,6 @@ function Index(props, ref) {
222
223
  return (react_1.default.createElement(styles_1.TableWrapper, { ref: ref },
223
224
  react_1.default.createElement(antd_1.Table, __assign({ ref: tableRef, scroll: {
224
225
  x: 900
225
- } }, props, { pagination: paginationProps, columns: renderColumns }))));
226
+ }, components: { header: { cell: columnsResizable ? ResizableColumns_1.ResizableTitle : undefined } } }, props, { pagination: paginationProps, columns: columnsResizable ? (0, ResizableColumns_1.resizableColumns)(renderColumns, tableId) : renderColumns }))));
226
227
  }
227
228
  exports.default = (0, react_1.forwardRef)(Index);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataIndexToString = void 0;
4
+ /**
5
+ * 将 dataIndex 转换为字符串
6
+ * @param dataIndex - 数据索引,可能是字符串或数组
7
+ * @returns 转换后的字符串
8
+ */
9
+ var dataIndexToString = function (dataIndex) {
10
+ if (!dataIndex)
11
+ return '';
12
+ if (Array.isArray(dataIndex)) {
13
+ return dataIndex.join('.');
14
+ }
15
+ return dataIndex;
16
+ };
17
+ exports.dataIndexToString = dataIndexToString;
@@ -57,7 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
57
57
  };
58
58
  Object.defineProperty(exports, "__esModule", { value: true });
59
59
  var react_1 = require("react");
60
- var react_intl_1 = require("react-intl");
60
+ var IntlProvider_1 = require("../../components/IntlProvider");
61
61
  var ahooks_1 = require("ahooks");
62
62
  var AntdApp_1 = require("../../components/AntdApp");
63
63
  var ORDER_MAP = {
@@ -74,17 +74,17 @@ var defaultOptions = {
74
74
  },
75
75
  showRowSelection: false,
76
76
  multiPageSelection: false,
77
- onBeforeRequest: function (params) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
77
+ onBeforeRequest: function (_) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
78
78
  return [2 /*return*/, undefined];
79
79
  }); }); },
80
- onAfterRequest: function (response) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
80
+ onAfterRequest: function (_) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
81
81
  return [2 /*return*/, undefined];
82
82
  }); }); }
83
83
  };
84
84
  function useTable(request, options) {
85
85
  var _this = this;
86
86
  if (options === void 0) { options = {}; }
87
- var intl = (0, react_intl_1.useIntl)();
87
+ var intl = (0, IntlProvider_1.useIntl)();
88
88
  var _a = __assign(__assign({}, defaultOptions), options), rowKey = _a.rowKey, interval = _a.interval, immediate = _a.immediate, defaultPagination = _a.defaultPagination, showRowSelection = _a.showRowSelection, multiPageSelection = _a.multiPageSelection, onBeforeRequest = _a.onBeforeRequest, onAfterRequest = _a.onAfterRequest;
89
89
  var tableTimerRef = (0, react_1.useRef)(null);
90
90
  var _b = (0, react_1.useState)(false), loading = _b[0], setLoading = _b[1];
@@ -152,7 +152,6 @@ function useTable(request, options) {
152
152
  total: total
153
153
  });
154
154
  }
155
- console.log(list);
156
155
  if (list.length === 0 && current && current > 1 && total && total > 0) {
157
156
  maxPage = Math.ceil(total / size);
158
157
  initList(maxPage, pageSize, auto);
@@ -201,10 +200,11 @@ function useTable(request, options) {
201
200
  }, []);
202
201
  /**
203
202
  * 列表多选执行
204
- * @param _ 选中的key数组
203
+ * @param selectedRowKeys 选中的key数组
205
204
  * @param selectedRows 被选中的项
205
+ * @param info 选择信息
206
206
  */
207
- var onSelectChange = (0, react_1.useCallback)(function (_, selectedRows) {
207
+ var onSelectChange = (0, react_1.useCallback)(function (_, selectedRows, __) {
208
208
  setSelectedRows(selectedRows);
209
209
  }, []);
210
210
  /**
@@ -245,7 +245,7 @@ function useTable(request, options) {
245
245
  * @param order 排序的值
246
246
  */
247
247
  var onChangeTable = (0, react_1.useCallback)(function (pagination, filter, order) {
248
- var _a;
248
+ var _a, _b, _c;
249
249
  // 处理筛选参数
250
250
  Object.entries(filter).forEach(function (_a) {
251
251
  var key = _a[0], value = _a[1];
@@ -257,20 +257,26 @@ function useTable(request, options) {
257
257
  }
258
258
  });
259
259
  // 处理排序参数
260
- if (order === null || order === void 0 ? void 0 : order.order) {
261
- if ((_a = order === null || order === void 0 ? void 0 : order.column) === null || _a === void 0 ? void 0 : _a.sort) {
262
- searchParams.column = order.column.sort;
260
+ // 如果 order 是数组,取第一个元素
261
+ var sortInfo = Array.isArray(order) ? order[0] : order;
262
+ if (sortInfo === null || sortInfo === void 0 ? void 0 : sortInfo.order) {
263
+ if ((_a = sortInfo === null || sortInfo === void 0 ? void 0 : sortInfo.column) === null || _a === void 0 ? void 0 : _a.sort) {
264
+ searchParams.column = sortInfo.column.sort;
263
265
  }
264
- else {
265
- searchParams.column = order.field;
266
+ else if (sortInfo.field) {
267
+ // 处理 field 可能是数组的情况
268
+ searchParams.column = Array.isArray(sortInfo.field) ? sortInfo.field[0] : sortInfo.field;
266
269
  }
267
- searchParams.order = ORDER_MAP[order.order];
270
+ searchParams.order = ORDER_MAP[sortInfo.order];
268
271
  }
269
272
  else {
270
273
  searchParams.column = null;
271
274
  searchParams.order = null;
272
275
  }
273
- initList(pagination.current, pagination.pageSize);
276
+ // 使用当前分页值作为默认值,处理可能为 undefined 的情况
277
+ var currentPage = (_b = pagination.current) !== null && _b !== void 0 ? _b : paginationRef.current.current;
278
+ var currentPageSize = (_c = pagination.pageSize) !== null && _c !== void 0 ? _c : paginationRef.current.pageSize;
279
+ initList(currentPage, currentPageSize);
274
280
  }, [initList, searchParams]);
275
281
  // 初始化
276
282
  (0, react_1.useEffect)(function () {
@@ -14,7 +14,6 @@ import { Options as Options_2 } from 'ahooks/lib/useRequest/src/types';
14
14
  import { Plugin as Plugin_2 } from 'ahooks/lib/useRequest/src/types';
15
15
  import { Result } from 'ahooks/lib/useRequest/src/types';
16
16
  import { RowProps } from 'antd';
17
- import { RowSelectMethod } from 'antd/es/table/interface';
18
17
  import { Service } from 'ahooks/lib/useRequest/src/types';
19
18
  import { SwitchProps } from 'antd/es/switch';
20
19
  import { TableColumnType } from 'antd';
@@ -127,6 +126,7 @@ export declare const ConfigContext: default_2.Context<ConfigContextProps>;
127
126
  declare interface ConfigContextProps {
128
127
  iconButton: IconButtonConfig;
129
128
  iconFont: IconFontConfig;
129
+ locale: MessagesKeys;
130
130
  }
131
131
 
132
132
  export declare function ConfigProvider({ children, config }: ConfigProviderProps): default_2.JSX.Element;
@@ -138,8 +138,6 @@ declare interface ConfigProviderProps {
138
138
  config: ConfigProviderConfigProps;
139
139
  }
140
140
 
141
- declare type FilterParams = Record<string, string[] | string | null>;
142
-
143
141
  export declare function GlobalLoading(): default_2.JSX.Element;
144
142
 
145
143
  export declare const IconButton: default_2.ForwardRefExoticComponent<IconButtonProps & default_2.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
@@ -232,6 +230,8 @@ declare interface InternalSearchAreaProps extends FormProps<any> {
232
230
 
233
231
  export declare let message: MessageInstance;
234
232
 
233
+ declare type MessagesKeys = 'zh' | 'en';
234
+
235
235
  export declare let modal: Omit<ModalStaticFunctions, 'warn'>;
236
236
 
237
237
  export declare let notification: NotificationInstance;
@@ -320,26 +320,7 @@ declare interface ReturnData<T = BaseRecord> {
320
320
  /**
321
321
  * 列表 props,拓展到 table 上
322
322
  */
323
- tableProps: {
324
- rowKey: string;
325
- loading: boolean;
326
- dataSource: T[];
327
- rowSelection?: {
328
- selectedRowKeys: Array<string | number>;
329
- onChange?: (selectedRowKeys: Array<string | number>, selectedRows: T[], info: {
330
- type: RowSelectMethod;
331
- }) => void;
332
- };
333
- onChange: (pagination: TableChangeParams, filter: FilterParams, order: SortParams) => void;
334
- pagination: {
335
- showQuickJumper: boolean;
336
- showSizeChanger: boolean;
337
- showTotal: (total: number) => string;
338
- total: number;
339
- current: number;
340
- pageSize: number;
341
- };
342
- };
323
+ tableProps: TableComponentProps;
343
324
  /**
344
325
  * 列表搜索
345
326
  */
@@ -394,14 +375,6 @@ declare interface SearchAreaHooks {
394
375
 
395
376
  export declare let setGlobalLoading: (_value: boolean) => void;
396
377
 
397
- declare interface SortParams {
398
- field: string;
399
- order: 'ascend' | 'descend' | null;
400
- column?: {
401
- sort?: string;
402
- };
403
- }
404
-
405
378
  /**
406
379
  * Switch 可自定义 value
407
380
  */
@@ -433,11 +406,6 @@ declare interface SwitchValueProps<T = boolean | string | number, F = boolean |
433
406
 
434
407
  export declare const Table: default_2.ForwardRefExoticComponent<TableComponentProps<AnyObject> & default_2.RefAttributes<HTMLDivElement>>;
435
408
 
436
- declare interface TableChangeParams {
437
- current: number;
438
- pageSize: number;
439
- }
440
-
441
409
  declare interface TableComponentProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, 'columns'> {
442
410
  /**
443
411
  * 列表项
@@ -459,6 +427,10 @@ declare interface TableComponentProps<RecordType = AnyObject> extends Omit<Table
459
427
  * 中间的批量操作弹出层
460
428
  */
461
429
  selectionPopover?: default_2.ReactNode;
430
+ /**
431
+ * 是否开启列宽调整功能
432
+ */
433
+ columnsResizable?: boolean;
462
434
  }
463
435
 
464
436
  /**