@ccs-ui/rc-pro 1.1.18 → 1.1.19

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.
package/es/table/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["data", "style", "scroll", "event$", "rowKey", "columns", "pagination", "rowSelection", "className"];
2
+ var _excluded = ["onResize", "width"],
3
+ _excluded2 = ["data", "style", "scroll", "event$", "rowKey", "columns", "pagination", "rowSelection", "className"];
3
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
6
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -11,6 +12,7 @@ import { useDebounceFn, useEventListener, useUpdate, useUpdateEffect } from 'aho
11
12
  import { Table, Tooltip, theme } from 'antd';
12
13
  import classNames from 'classnames';
13
14
  import { useRef } from 'react';
15
+ import { Resizable } from 'react-resizable';
14
16
  import "./index.less";
15
17
  import { jsx as _jsx } from "react/jsx-runtime";
16
18
  var DEFAULT_PAGE = {
@@ -19,6 +21,29 @@ var DEFAULT_PAGE = {
19
21
  pageSize: 10,
20
22
  pageNo: 1
21
23
  };
24
+ var ResizableTitle = function ResizableTitle(props) {
25
+ var onResize = props.onResize,
26
+ width = props.width,
27
+ restProps = _objectWithoutProperties(props, _excluded);
28
+ if (!width) {
29
+ return /*#__PURE__*/_jsx("th", _objectSpread({}, restProps));
30
+ }
31
+ return /*#__PURE__*/_jsx(Resizable, {
32
+ width: width,
33
+ height: 0,
34
+ handle: /*#__PURE__*/_jsx("span", {
35
+ className: "react-resizable-handle",
36
+ onClick: function onClick(e) {
37
+ e.stopPropagation();
38
+ }
39
+ }),
40
+ onResize: onResize,
41
+ draggableOpts: {
42
+ enableUserSelectHack: false
43
+ },
44
+ children: /*#__PURE__*/_jsx("th", _objectSpread({}, restProps))
45
+ });
46
+ };
22
47
  var CustomTable = function CustomTable(props) {
23
48
  var data = props.data,
24
49
  style = props.style,
@@ -30,7 +55,7 @@ var CustomTable = function CustomTable(props) {
30
55
  rowSelection = props.rowSelection,
31
56
  _props$className = props.className,
32
57
  className = _props$className === void 0 ? '' : _props$className,
33
- restProps = _objectWithoutProperties(props, _excluded);
58
+ restProps = _objectWithoutProperties(props, _excluded2);
34
59
 
35
60
  // 固定表头获取table可视高度
36
61
  var ref = useRef(null);
@@ -95,6 +120,18 @@ var CustomTable = function CustomTable(props) {
95
120
  }
96
121
  });
97
122
 
123
+ // 改变列宽
124
+ var onResize = function onResize(dataIndex) {
125
+ return function (_, _ref3) {
126
+ var size = _ref3.size;
127
+ var column = columns === null || columns === void 0 ? void 0 : columns.find(function (c) {
128
+ return c.dataIndex === dataIndex;
129
+ });
130
+ column.width = size.width;
131
+ update();
132
+ };
133
+ };
134
+
98
135
  // 列过滤
99
136
  var filterColumns = function filterColumns() {
100
137
  var cls = columns === null || columns === void 0 ? void 0 : columns.filter(function (t) {
@@ -116,6 +153,13 @@ var CustomTable = function CustomTable(props) {
116
153
  });
117
154
  };
118
155
  }
156
+ // 拖拽头部改变列宽响应
157
+ c.onHeaderCell = function (column) {
158
+ return {
159
+ width: column.width,
160
+ onResize: onResize(c.dataIndex)
161
+ };
162
+ };
119
163
  });
120
164
  return cls;
121
165
  };
@@ -128,10 +172,10 @@ var CustomTable = function CustomTable(props) {
128
172
  }),
129
173
  children: /*#__PURE__*/_jsx("div", {
130
174
  ref: ref,
131
- children: /*#__PURE__*/_jsx(Table, _objectSpread({}, _objectSpread(_objectSpread({
175
+ children: /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({
132
176
  rowKey: rowKey,
133
177
  dataSource: result,
134
- pagination: pagination === false ? false : _objectSpread({
178
+ pagination: pagination !== null && pagination !== void 0 ? pagination : _objectSpread({
135
179
  total: totalNum,
136
180
  pageSize: pageSize,
137
181
  current: pageNo,
@@ -143,7 +187,7 @@ var CustomTable = function CustomTable(props) {
143
187
  pageSizeOptions: ['10', '20', '30', '50', '100'],
144
188
  size: restProps.size === 'small' ? 'small' : 'default',
145
189
  simple: restProps.size === 'small'
146
- }, pagination),
190
+ }, pagination || {}),
147
191
  rowSelection: rowSelection ? _objectSpread(_objectSpread({}, rowSelection), {}, {
148
192
  columnWidth: 60
149
193
  }) : undefined,
@@ -151,8 +195,13 @@ var CustomTable = function CustomTable(props) {
151
195
  }, restProps), {}, {
152
196
  size: restProps.size || 'middle',
153
197
  className: classNames(!totalNum ? 'ccs-table-nodata' : '', className),
154
- scroll: scroll
155
- })))
198
+ scroll: scroll,
199
+ components: {
200
+ header: {
201
+ cell: ResizableTitle
202
+ }
203
+ }
204
+ }))
156
205
  })
157
206
  });
158
207
  };
@@ -87,6 +87,21 @@
87
87
  .ant-table-sticky-holder {
88
88
  z-index: 100;
89
89
  }
90
+
91
+ .react-resizable {
92
+ position: relative;
93
+ background-clip: padding-box;
94
+ }
95
+
96
+ .react-resizable-handle {
97
+ position: absolute;
98
+ right: -5px;
99
+ bottom: 0;
100
+ z-index: 1;
101
+ width: 15px;
102
+ height: 100%;
103
+ cursor: col-resize;
104
+ }
90
105
  }
91
106
 
92
107
  &-nodata {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "1.1.18",
4
- "description": "测试更新说明;测试更新说明2;测试更新说明3",
3
+ "version": "1.1.19",
4
+ "description": " ProTable支持拖拽改变宽度,需设置列宽",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Hong",
@@ -68,6 +68,7 @@
68
68
  "react-color": "^2.19.3",
69
69
  "react-custom-scrollbars": "^4.2.1",
70
70
  "react-draggable": "^4.4.5",
71
+ "react-resizable": "^3.0.5",
71
72
  "react-router": "^6.11.2",
72
73
  "react-router-dom": "^6.11.2",
73
74
  "shortid": "^2.2.16"
@@ -80,7 +81,9 @@
80
81
  "@types/react-color": "^3.0.6",
81
82
  "@types/react-custom-scrollbars": "^4.0.10",
82
83
  "@types/react-dom": "^18.0.0",
84
+ "@types/react-resizable": "^3.0.7",
83
85
  "@types/shortid": "^0.0.29",
86
+ "@types/throttle-debounce": "^5.0.2",
84
87
  "@umijs/lint": "^4.0.0",
85
88
  "cross-env": "^7.0.3",
86
89
  "dumi": "^2.2.0",