@lemon-fe/components 0.1.6 → 0.1.7
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/BaseTable/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _excluded = ["onWidthChange", "width", "fullTableRef", "children", "className"],
|
|
2
|
-
_excluded2 = ["id", "columns", "defaultColumnProps", "rowKey", "children", "summaryTitle", "summaryRecord", "dataSource", "onSortChange", "sort", "scroll", "virtual", "components", "pagination", "
|
|
2
|
+
_excluded2 = ["id", "columns", "defaultColumnProps", "rowKey", "children", "summaryTitle", "summaryRecord", "dataSource", "onSortChange", "sort", "scroll", "virtual", "components", "pagination", "rowHeight", "tableLayout", "rowActions", "style"];
|
|
3
3
|
|
|
4
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
5
|
|
|
@@ -37,7 +37,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
37
37
|
import React, { useMemo, useState, useEffect, useRef } from 'react';
|
|
38
38
|
import { Table as AntdTable } from 'antd';
|
|
39
39
|
import { get } from 'lodash';
|
|
40
|
-
import
|
|
40
|
+
import ResizeObserver from 'rc-resize-observer';
|
|
41
41
|
import { isColumnType, getColumnKey } from './utils';
|
|
42
42
|
import ResizeHeaderCell from './ResizeHeaderCell';
|
|
43
43
|
import { PREFIX_CLS } from '../constants';
|
|
@@ -116,26 +116,29 @@ function BaseTable(props) {
|
|
|
116
116
|
virtual = props.virtual,
|
|
117
117
|
componentsProp = props.components,
|
|
118
118
|
paginationProp = props.pagination,
|
|
119
|
-
onChangeProp = props.onChange,
|
|
120
119
|
rowHeight = props.rowHeight,
|
|
121
120
|
_props$tableLayout = props.tableLayout,
|
|
122
121
|
tableLayout = _props$tableLayout === void 0 ? 'fixed' : _props$tableLayout,
|
|
123
122
|
rowActions = props.rowActions,
|
|
123
|
+
style = props.style,
|
|
124
124
|
restProps = _objectWithoutProperties(props, _excluded2);
|
|
125
125
|
|
|
126
126
|
var fullTableRef = useRef(null);
|
|
127
127
|
|
|
128
|
-
var _useState = useState(
|
|
128
|
+
var _useState = useState(new Map()),
|
|
129
129
|
_useState2 = _slicedToArray(_useState, 2),
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
colsState = _useState2[0],
|
|
131
|
+
setColsState = _useState2[1];
|
|
132
132
|
|
|
133
|
-
var
|
|
133
|
+
var scrollYProp = scroll === null || scroll === void 0 ? void 0 : scroll.y;
|
|
134
|
+
|
|
135
|
+
var _useState3 = useState(scrollYProp === true ? 0 : scrollYProp),
|
|
134
136
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/** auto scroll y */
|
|
137
|
+
scrollY = _useState4[0],
|
|
138
|
+
setScrollY = _useState4[1];
|
|
138
139
|
|
|
140
|
+
var memoHeight = useRef(0);
|
|
141
|
+
/** auto scroll y */
|
|
139
142
|
|
|
140
143
|
var calcScrollY = function calcScrollY() {
|
|
141
144
|
var wrapper = fullTableRef.current;
|
|
@@ -181,31 +184,34 @@ function BaseTable(props) {
|
|
|
181
184
|
return contentHeight;
|
|
182
185
|
};
|
|
183
186
|
|
|
184
|
-
var changeScrollY =
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if ((scroll === null || scroll === void 0 ? void 0 : scroll.y) === true) {
|
|
188
|
-
var y = calcScrollY();
|
|
189
|
-
nextScrollY = y || undefined;
|
|
190
|
-
} else {
|
|
191
|
-
nextScrollY = scroll === null || scroll === void 0 ? void 0 : scroll.y;
|
|
187
|
+
var changeScrollY = function changeScrollY(height) {
|
|
188
|
+
if (height === memoHeight.current) {
|
|
189
|
+
return;
|
|
192
190
|
}
|
|
193
191
|
|
|
194
|
-
|
|
192
|
+
memoHeight.current = height;
|
|
193
|
+
setScrollY(calcScrollY() || undefined);
|
|
194
|
+
};
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
useEffect(function () {
|
|
197
|
+
if (scrollYProp !== true) {
|
|
198
|
+
setScrollY(scrollYProp);
|
|
199
|
+
}
|
|
200
|
+
}, [scrollYProp]);
|
|
201
|
+
useEffect(function () {
|
|
202
|
+
if (scrollY !== undefined && fullTableRef.current !== null) {
|
|
197
203
|
var body = fullTableRef.current.querySelector('.ant-table-body');
|
|
198
204
|
|
|
199
205
|
if (body !== null) {
|
|
200
|
-
var dataType = _typeof(
|
|
206
|
+
var dataType = _typeof(scrollY);
|
|
201
207
|
|
|
202
208
|
switch (dataType) {
|
|
203
209
|
case 'string':
|
|
204
|
-
body.style.height =
|
|
210
|
+
body.style.height = scrollY;
|
|
205
211
|
break;
|
|
206
212
|
|
|
207
213
|
case 'number':
|
|
208
|
-
body.style.height =
|
|
214
|
+
body.style.height = scrollY + 'px';
|
|
209
215
|
break;
|
|
210
216
|
|
|
211
217
|
default:
|
|
@@ -213,29 +219,9 @@ function BaseTable(props) {
|
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
}
|
|
216
|
-
},
|
|
217
|
-
trailing: true
|
|
218
|
-
});
|
|
219
|
-
useEffect(function () {
|
|
220
|
-
changeScrollY();
|
|
221
|
-
}, [scroll === null || scroll === void 0 ? void 0 : scroll.y, dataSource]);
|
|
222
|
-
useEffect(function () {
|
|
223
|
-
window.addEventListener('resize', changeScrollY);
|
|
224
|
-
return function () {
|
|
225
|
-
window.removeEventListener('resize', changeScrollY);
|
|
226
|
-
};
|
|
227
|
-
}, []);
|
|
228
|
-
|
|
229
|
-
var handleChange = function handleChange() {
|
|
230
|
-
changeScrollY();
|
|
231
|
-
|
|
232
|
-
if (onChangeProp) {
|
|
233
|
-
onChangeProp.apply(void 0, arguments);
|
|
234
|
-
}
|
|
235
|
-
};
|
|
222
|
+
}, [scrollY]);
|
|
236
223
|
/** resizable column */
|
|
237
224
|
|
|
238
|
-
|
|
239
225
|
var _useMemo = useMemo(function () {
|
|
240
226
|
var flattenCols = [];
|
|
241
227
|
var isFixedLayout = tableLayout === 'fixed';
|
|
@@ -400,22 +386,22 @@ function BaseTable(props) {
|
|
|
400
386
|
rowHeight: rowHeight
|
|
401
387
|
};
|
|
402
388
|
}, [scrollY, rowHeight]);
|
|
403
|
-
|
|
404
|
-
value: ctx
|
|
405
|
-
}, /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread({
|
|
389
|
+
var tableNode = /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread({
|
|
406
390
|
size: "small",
|
|
407
391
|
ref: fullTableRef,
|
|
408
392
|
columns: formatedColumns,
|
|
409
393
|
dataSource: dataSource,
|
|
410
394
|
rowKey: rowKey,
|
|
411
395
|
summary: summary,
|
|
396
|
+
components: components,
|
|
397
|
+
tableLayout: tableLayout,
|
|
412
398
|
scroll: {
|
|
413
399
|
x: (scroll === null || scroll === void 0 ? void 0 : scroll.x) || '100%',
|
|
414
400
|
y: scrollY
|
|
415
401
|
},
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
402
|
+
style: scrollYProp === true ? _objectSpread(_objectSpread({}, style), {}, {
|
|
403
|
+
height: '100%'
|
|
404
|
+
}) : style,
|
|
419
405
|
locale: {
|
|
420
406
|
emptyText: /*#__PURE__*/React.createElement("div", {
|
|
421
407
|
className: "".concat(PREFIX_CLS, "-table-empty")
|
|
@@ -434,7 +420,19 @@ function BaseTable(props) {
|
|
|
434
420
|
},
|
|
435
421
|
defaultPageSize: 20
|
|
436
422
|
}, paginationProp) : false
|
|
437
|
-
}))
|
|
423
|
+
}));
|
|
424
|
+
|
|
425
|
+
if (scrollYProp === true) {
|
|
426
|
+
tableNode = /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
427
|
+
onResize: function onResize(size) {
|
|
428
|
+
return changeScrollY(size.height);
|
|
429
|
+
}
|
|
430
|
+
}, tableNode);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return /*#__PURE__*/React.createElement(BaseTableContext.Provider, {
|
|
434
|
+
value: ctx
|
|
435
|
+
}, tableNode);
|
|
438
436
|
}
|
|
439
437
|
|
|
440
438
|
BaseTable.Summary = AntdTable.Summary;
|
package/es/Section/index.less
CHANGED
|
@@ -63,7 +63,8 @@ export default function TreeNodeTitle(props) {
|
|
|
63
63
|
var others = (_operation$others = operation.others) === null || _operation$others === void 0 ? void 0 : _operation$others.call(operation, item);
|
|
64
64
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
65
65
|
className: "".concat(prefixCls, "-title-content"),
|
|
66
|
-
ref: trigger
|
|
66
|
+
ref: trigger,
|
|
67
|
+
title: item.title.toString()
|
|
67
68
|
}, item.title), /*#__PURE__*/React.createElement("div", {
|
|
68
69
|
className: "".concat(prefixCls, "-title-operators"),
|
|
69
70
|
style: {
|
package/es/SiderTree/index.less
CHANGED
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
&-unit {
|
|
70
70
|
display: inline-block;
|
|
71
71
|
width: @indentWidth;
|
|
72
|
+
vertical-align: top;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -121,7 +122,7 @@
|
|
|
121
122
|
flex: 1;
|
|
122
123
|
align-items: center;
|
|
123
124
|
justify-content: space-between;
|
|
124
|
-
min-width:
|
|
125
|
+
min-width: 56px;
|
|
125
126
|
padding: 0 8px;
|
|
126
127
|
border-radius: 4px;
|
|
127
128
|
cursor: pointer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
6
6
|
"homepage": "",
|
|
@@ -17,11 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@lemon-fe/hooks": "^0.1.2",
|
|
20
|
-
"antd": "^4.20.2",
|
|
21
20
|
"classnames": "^2.2.6",
|
|
22
21
|
"lodash": "^4.17.21",
|
|
23
|
-
"react": "^17.0.2",
|
|
24
|
-
"react-dom": "^17.0.2",
|
|
25
22
|
"react-resizable": "^3.0.4"
|
|
26
23
|
},
|
|
27
24
|
"peerDependencies": {
|
|
@@ -30,6 +27,7 @@
|
|
|
30
27
|
"classnames": ">=2.2.6",
|
|
31
28
|
"color-string": ">=1.0.0",
|
|
32
29
|
"lodash": ">=4.17.0",
|
|
30
|
+
"rc-resize-observer": "^1.0.0",
|
|
33
31
|
"rc-tree": ">=4.0.0",
|
|
34
32
|
"react": ">=16.9.0",
|
|
35
33
|
"react-dom": ">=16.9.0"
|
|
@@ -37,7 +35,11 @@
|
|
|
37
35
|
"devDependencies": {
|
|
38
36
|
"@types/color-string": "^1.5.2",
|
|
39
37
|
"@types/lodash": "^4.14.179",
|
|
40
|
-
"@types/react-resizable": "^1.7.4"
|
|
38
|
+
"@types/react-resizable": "^1.7.4",
|
|
39
|
+
"antd": "^4.20.2",
|
|
40
|
+
"rc-resize-observer": "^1.2.0",
|
|
41
|
+
"react": "^17.0.2",
|
|
42
|
+
"react-dom": "^17.0.2"
|
|
41
43
|
},
|
|
42
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "84f94d37e2938930fa2c32d2da6573dfc517b458"
|
|
43
45
|
}
|