@ccs-ui/rc-pro 1.1.18 → 1.1.19-beta-2

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.
@@ -6,17 +6,16 @@ type ClassProps = {
6
6
  style?: CSSProperties;
7
7
  };
8
8
  type CcsProGridProps = ClassProps & {
9
- bordered?: boolean;
9
+ gutter?: number;
10
10
  children?: ReactNode;
11
11
  };
12
12
  type ColProps = CardProps & {
13
- colSpan?: string | number;
14
- colStyle?: CSSProperties;
15
- colClassName?: string;
13
+ colWidth?: number;
14
+ children?: ReactNode;
16
15
  };
17
16
  type GridInstance = FC<CcsProGridProps> & {
18
17
  Col: typeof GridCol;
19
18
  };
20
- declare const GridCol: ({ colSpan, colClassName, colStyle, ...otherProps }: ColProps) => import("react/jsx-runtime").JSX.Element;
19
+ declare const GridCol: ({ children, colWidth, style, className, ...restProps }: ColProps) => import("react/jsx-runtime").JSX.Element;
21
20
  declare const ProGrid: GridInstance;
22
21
  export default ProGrid;
@@ -1,6 +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 = ["colSpan", "colClassName", "colStyle"],
3
- _excluded2 = ["bordered", "children"];
2
+ var _excluded = ["children", "colWidth", "style", "className"],
3
+ _excluded2 = ["children", "gutter"];
4
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; }
5
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; }
6
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; }
@@ -8,48 +8,51 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
8
8
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
9
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
10
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
- import { Card } from 'antd';
12
- import classNames from 'classnames';
11
+ import React from 'react';
13
12
  import "./index.less";
14
13
  import { jsx as _jsx } from "react/jsx-runtime";
15
14
  import { Fragment as _Fragment } from "react/jsx-runtime";
16
15
  var GridCol = function GridCol(_ref) {
17
- var colSpan = _ref.colSpan,
18
- colClassName = _ref.colClassName,
19
- colStyle = _ref.colStyle,
20
- otherProps = _objectWithoutProperties(_ref, _excluded);
21
- return /*#__PURE__*/_jsx(_Fragment, {
22
- children: /*#__PURE__*/_jsx("div", {
23
- className: classNames('ccs-pg-col', colClassName),
24
- style: colSpan ? _objectSpread({
25
- width: colSpan,
26
- flexShrink: 0
27
- }, colStyle) : _objectSpread({
28
- display: 'flex',
29
- width: 0,
30
- flex: 'auto',
31
- flexDirection: 'column'
32
- }, colStyle),
33
- children: /*#__PURE__*/_jsx(Card, _objectSpread({
34
- bodyStyle: {
35
- padding: 0
36
- }
37
- }, otherProps))
38
- })
16
+ var children = _ref.children,
17
+ colWidth = _ref.colWidth,
18
+ style = _ref.style,
19
+ className = _ref.className,
20
+ restProps = _objectWithoutProperties(_ref, _excluded);
21
+ console.log('restProps', restProps);
22
+ var styles = _objectSpread({}, style);
23
+ if (colWidth) {
24
+ styles.width = colWidth;
25
+ styles.flex = "0 0 ".concat(colWidth, "px");
26
+ } else {
27
+ styles.flex = "1 1 auto";
28
+ }
29
+ var _ref2 = restProps,
30
+ gutter = _ref2.gutter;
31
+ if (gutter) {
32
+ styles.marginLeft = gutter;
33
+ }
34
+ return /*#__PURE__*/_jsx("div", {
35
+ style: styles,
36
+ className: className,
37
+ children: children
39
38
  });
40
39
  };
41
- var Grid = function Grid(_ref2) {
42
- var bordered = _ref2.bordered,
43
- children = _ref2.children,
44
- restProps = _objectWithoutProperties(_ref2, _excluded2);
45
- return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, restProps), {}, {
46
- className: classNames({
47
- 'ccs-pg-border': bordered
48
- }),
49
- children: /*#__PURE__*/_jsx("div", {
50
- className: "ccs-pl-table-content",
51
- children: children
52
- })
40
+ var Grid = function Grid(_ref3) {
41
+ var children = _ref3.children,
42
+ gutter = _ref3.gutter,
43
+ restProps = _objectWithoutProperties(_ref3, _excluded2);
44
+ return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
45
+ style: {
46
+ display: 'flex'
47
+ }
48
+ }, restProps), {}, {
49
+ children: gutter ? React.Children.map(children, function (child, index) {
50
+ return /*#__PURE__*/_jsx(_Fragment, {
51
+ children: /*#__PURE__*/React.isValidElement(child) && /*#__PURE__*/React.cloneElement(child, {
52
+ gutter: index !== 0 ? gutter : 0
53
+ })
54
+ });
55
+ }) : children
53
56
  }));
54
57
  };
55
58
  var ProGrid = Grid;
@@ -1,9 +1,4 @@
1
1
  .ccs-pg {
2
- &-col:not(:first-child) {
3
- // border-right: 1px solid #f0f0f0;
4
- margin-left: 10px;
5
- }
6
-
7
2
  &-col-title {
8
3
  font-size: 15px;
9
4
  }
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 || typeof width !== 'number') {
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: _objectSpread({
135
179
  total: totalNum,
136
180
  pageSize: pageSize,
137
181
  current: pageNo,
@@ -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-beta-2",
4
+ "description": "ProGrid 调整;ProTable 传入列宽度为number类型拖拽才生效;ProTable传入pagination分页显示异常",
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",