@lemon-fe/components 0.1.50 → 0.1.52
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 +8 -7
- package/es/BaseTable/index.less +1 -1
- package/es/Table/index.js +15 -3
- package/package.json +2 -2
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", "rowHeight", "tableLayout", "rowActions", "style"];
|
|
2
|
+
_excluded2 = ["id", "columns", "defaultColumnProps", "rowKey", "children", "summaryTitle", "summaryRecord", "dataSource", "onSortChange", "sort", "scroll", "virtual", "components", "pagination", "rowHeight", "tableLayout", "rowActions", "style", "locale"];
|
|
3
3
|
|
|
4
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
5
|
|
|
@@ -34,7 +34,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
34
34
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
35
|
|
|
36
36
|
/// <reference path="../../typings.d.ts" />
|
|
37
|
-
import React, { useMemo, useState, useEffect, useRef
|
|
37
|
+
import React, { useMemo, useState, useEffect, useRef } from 'react';
|
|
38
38
|
import { Table as AntdTable } from 'antd';
|
|
39
39
|
import { get } from 'lodash';
|
|
40
40
|
import ResizeObserver from 'rc-resize-observer';
|
|
@@ -121,6 +121,7 @@ function BaseTable(props) {
|
|
|
121
121
|
tableLayout = _props$tableLayout === void 0 ? 'fixed' : _props$tableLayout,
|
|
122
122
|
rowActions = props.rowActions,
|
|
123
123
|
style = props.style,
|
|
124
|
+
localeProp = props.locale,
|
|
124
125
|
restProps = _objectWithoutProperties(props, _excluded2);
|
|
125
126
|
|
|
126
127
|
var fullTableRef = useRef(null);
|
|
@@ -204,8 +205,8 @@ function BaseTable(props) {
|
|
|
204
205
|
hasPagination = paginationProp !== undefined && !!paginationProp.total || dataSource.length > 0;
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
|
|
208
|
-
setScrollY(calcScrollY() ||
|
|
208
|
+
useEffect(function () {
|
|
209
|
+
setScrollY(calcScrollY() || 0);
|
|
209
210
|
}, [hasPagination]);
|
|
210
211
|
useEffect(function () {
|
|
211
212
|
if (scrollYProp !== true) {
|
|
@@ -416,13 +417,13 @@ function BaseTable(props) {
|
|
|
416
417
|
style: scrollYProp === true ? _objectSpread(_objectSpread({}, style), {}, {
|
|
417
418
|
height: '100%'
|
|
418
419
|
}) : style,
|
|
419
|
-
locale: {
|
|
420
|
+
locale: _objectSpread({
|
|
420
421
|
emptyText: /*#__PURE__*/React.createElement("div", {
|
|
421
422
|
className: "".concat(PREFIX_CLS, "-table-empty")
|
|
422
423
|
}, /*#__PURE__*/React.createElement("img", {
|
|
423
424
|
src: empty
|
|
424
425
|
}), /*#__PURE__*/React.createElement("div", null, "\u6682\u65E0\u6570\u636E"))
|
|
425
|
-
}
|
|
426
|
+
}, localeProp)
|
|
426
427
|
}, restProps), {}, {
|
|
427
428
|
pagination: paginationProp !== false ? _objectSpread({
|
|
428
429
|
size: 'small',
|
|
@@ -439,7 +440,7 @@ function BaseTable(props) {
|
|
|
439
440
|
if (scrollYProp === true) {
|
|
440
441
|
tableNode = /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
441
442
|
onResize: function onResize(size) {
|
|
442
|
-
|
|
443
|
+
changeScrollY(size.height);
|
|
443
444
|
}
|
|
444
445
|
}, tableNode);
|
|
445
446
|
}
|
package/es/BaseTable/index.less
CHANGED
package/es/Table/index.js
CHANGED
|
@@ -30,6 +30,8 @@ import React, { useMemo, useState, useImperativeHandle, useEffect } from 'react'
|
|
|
30
30
|
import { useRequest } from '@lemon-fe/hooks';
|
|
31
31
|
import BaseTable from '../BaseTable';
|
|
32
32
|
import { isSortValue } from './utils';
|
|
33
|
+
import empty from '../BaseTable/empty.png';
|
|
34
|
+
import { PREFIX_CLS } from '../constants';
|
|
33
35
|
export default function Table(props) {
|
|
34
36
|
var _props$dataSource = props.dataSource,
|
|
35
37
|
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
|
@@ -115,16 +117,19 @@ export default function Table(props) {
|
|
|
115
117
|
onLoading(false);
|
|
116
118
|
}
|
|
117
119
|
|
|
118
|
-
setRemote(res.result)
|
|
120
|
+
setRemote(_objectSpread(_objectSpread({}, res.result), {}, {
|
|
121
|
+
error: undefined
|
|
122
|
+
}));
|
|
119
123
|
},
|
|
120
|
-
onError: function onError() {
|
|
124
|
+
onError: function onError(error) {
|
|
121
125
|
if (onLoading) {
|
|
122
126
|
onLoading(false);
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
setRemote({
|
|
126
130
|
data: [],
|
|
127
|
-
total: 0
|
|
131
|
+
total: 0,
|
|
132
|
+
error: error
|
|
128
133
|
});
|
|
129
134
|
}
|
|
130
135
|
}),
|
|
@@ -215,6 +220,13 @@ export default function Table(props) {
|
|
|
215
220
|
});
|
|
216
221
|
}
|
|
217
222
|
},
|
|
223
|
+
locale: remote.error ? {
|
|
224
|
+
emptyText: /*#__PURE__*/React.createElement("div", {
|
|
225
|
+
className: "".concat(PREFIX_CLS, "-table-empty")
|
|
226
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
227
|
+
src: empty
|
|
228
|
+
}), /*#__PURE__*/React.createElement("div", null, remote.error.message))
|
|
229
|
+
} : undefined,
|
|
218
230
|
pagination: {
|
|
219
231
|
current: current,
|
|
220
232
|
pageSize: pageSize,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
6
6
|
"homepage": "",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"react": "^17.0.2",
|
|
42
42
|
"react-dom": "^17.0.2"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "68713e81d8cf4c82bae68564ae4c2e70c4a8cc27"
|
|
45
45
|
}
|