@kep-platform/basic-component 0.0.18 → 0.0.20
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/dist/Columns/Columns.js +1 -1
- package/dist/Table/Table.d.ts +2 -2
- package/dist/Table/Table.js +29 -14
- package/package.json +3 -3
package/dist/Columns/Columns.js
CHANGED
@@ -124,6 +124,6 @@ export default function Columns(_ref) {
|
|
124
124
|
return /*#__PURE__*/React.createElement(Column, _extends({}, listItemRestProps, {
|
125
125
|
key: key,
|
126
126
|
isFlex: isFlex
|
127
|
-
}), (render === null || render === void 0 ? void 0 : render(rowData[dataIndex], rowData, rowIndex)) || rowData[dataIndex]
|
127
|
+
}), (render === null || render === void 0 ? void 0 : render(rowData[dataIndex], rowData, rowIndex)) || rowData[dataIndex]);
|
128
128
|
}));
|
129
129
|
}
|
package/dist/Table/Table.d.ts
CHANGED
@@ -14,7 +14,7 @@ export type TableProps = {
|
|
14
14
|
onChange?: (pagination?: Pagination, sorter?: SorterDesc, fitler?: FilterDesc) => void;
|
15
15
|
headerRender?: (column: ColumnType) => ReactNode;
|
16
16
|
groupBy?: string;
|
17
|
-
pagination?: Pagination;
|
17
|
+
pagination?: Pagination | false;
|
18
18
|
};
|
19
|
-
export default function Table({ columns, dataSource, rowKey, actions, title, scroll, onChange, headerRender, pagination, }: TableProps): React.JSX.Element;
|
19
|
+
export default function Table({ columns, dataSource, rowKey, actions, title, scroll, onChange, headerRender, pagination: outerPagination, }: TableProps): React.JSX.Element;
|
20
20
|
export {};
|
package/dist/Table/Table.js
CHANGED
@@ -14,7 +14,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
15
15
|
import CaretDownOutlined from '@ant-design/icons/CaretDownOutlined';
|
16
16
|
import CaretUpOutlined from '@ant-design/icons/CaretUpOutlined';
|
17
|
-
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
17
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
18
18
|
import styled, { css } from 'styled-components';
|
19
19
|
import { BoxShadowBox } from "../BoxShadowBox";
|
20
20
|
import { Column, Columns } from "../Columns";
|
@@ -137,11 +137,21 @@ export default function Table(_ref3) {
|
|
137
137
|
scroll = _ref3.scroll,
|
138
138
|
_onChange2 = _ref3.onChange,
|
139
139
|
headerRender = _ref3.headerRender,
|
140
|
-
|
140
|
+
outerPagination = _ref3.pagination;
|
141
141
|
var _useState = useState(null),
|
142
142
|
_useState2 = _slicedToArray(_useState, 2),
|
143
143
|
sorterController = _useState2[0],
|
144
144
|
setSorterController = _useState2[1];
|
145
|
+
var _useState3 = useState(outerPagination === false ? false : outerPagination || {
|
146
|
+
current: 1,
|
147
|
+
pageSize: 10
|
148
|
+
}),
|
149
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
150
|
+
pagination = _useState4[0],
|
151
|
+
setPagination = _useState4[1];
|
152
|
+
useEffect(function () {
|
153
|
+
if (outerPagination !== undefined) setPagination(outerPagination);
|
154
|
+
}, [outerPagination]);
|
145
155
|
var titleRowData = useMemo(function () {
|
146
156
|
var data = {};
|
147
157
|
columns.forEach(function (column) {
|
@@ -178,16 +188,17 @@ export default function Table(_ref3) {
|
|
178
188
|
}, 0);
|
179
189
|
}, [columns]);
|
180
190
|
var formatedDataSource = useMemo(function () {
|
181
|
-
var formatedDataSource;
|
182
|
-
|
183
|
-
if (pagination && dataSource.length > (pagination.pageSize || 10)) {
|
191
|
+
var formatedDataSource = dataSource;
|
192
|
+
if (pagination !== false) {
|
184
193
|
var startIndex = ((pagination.current || 1) - 1) * (pagination.pageSize || 10);
|
185
194
|
var endIndex = startIndex + (pagination.pageSize || 10) - 1;
|
186
|
-
formatedDataSource = dataSource.
|
187
|
-
|
195
|
+
formatedDataSource = dataSource.map(function (rowData, index) {
|
196
|
+
if (index >= startIndex && index <= endIndex) {
|
197
|
+
return rowData;
|
198
|
+
} else {
|
199
|
+
return undefined;
|
200
|
+
}
|
188
201
|
});
|
189
|
-
} else {
|
190
|
-
formatedDataSource = dataSource;
|
191
202
|
}
|
192
203
|
/* 排序 */
|
193
204
|
if (sorterController && sorterController.sorterType !== undefined) {
|
@@ -200,7 +211,7 @@ export default function Table(_ref3) {
|
|
200
211
|
/* 条件过滤 */
|
201
212
|
return formatedDataSource;
|
202
213
|
}, [sorterController, dataSource, columns, pagination]);
|
203
|
-
return /*#__PURE__*/React.createElement(TableContainer, null, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, {
|
214
|
+
return /*#__PURE__*/React.createElement(TableContainer, null, (title || actions) && /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, {
|
204
215
|
span: 8
|
205
216
|
}, /*#__PURE__*/React.createElement(TableTitle, null, title)), /*#__PURE__*/React.createElement(Col, {
|
206
217
|
span: 16
|
@@ -239,22 +250,26 @@ export default function Table(_ref3) {
|
|
239
250
|
}), /*#__PURE__*/React.createElement(TableBody, {
|
240
251
|
direction: "column"
|
241
252
|
}, formatedDataSource.map(function (rowData, index) {
|
242
|
-
return /*#__PURE__*/React.createElement(TableBodyRow, {
|
253
|
+
if (rowData) return /*#__PURE__*/React.createElement(TableBodyRow, {
|
243
254
|
key: rowData[rowKey]
|
244
255
|
}, /*#__PURE__*/React.createElement(Columns, {
|
245
256
|
rowIndex: index,
|
246
257
|
rowData: rowData,
|
247
258
|
columns: columns,
|
248
259
|
isFlex: !scroll
|
249
|
-
}));
|
250
|
-
}))), /*#__PURE__*/React.createElement("br", null), pagination && /*#__PURE__*/React.createElement(Pagination, _extends({}, pagination, {
|
251
|
-
total: pagination.total || dataSource.length,
|
260
|
+
}));else return undefined;
|
261
|
+
}))), /*#__PURE__*/React.createElement("br", null), pagination !== false && /*#__PURE__*/React.createElement(Pagination, _extends({}, pagination, {
|
262
|
+
total: (pagination === null || pagination === void 0 ? void 0 : pagination.total) || dataSource.length,
|
252
263
|
justifyContent: "right",
|
253
264
|
onChange: function onChange(current, pageSize) {
|
254
265
|
_onChange2 === null || _onChange2 === void 0 || _onChange2({
|
255
266
|
current: current,
|
256
267
|
pageSize: pageSize
|
257
268
|
});
|
269
|
+
setPagination({
|
270
|
+
current: current,
|
271
|
+
pageSize: pageSize
|
272
|
+
});
|
258
273
|
}
|
259
274
|
})));
|
260
275
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@kep-platform/basic-component",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.20",
|
4
4
|
"description": "A react library developed with dumi",
|
5
5
|
"module": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -74,10 +74,10 @@
|
|
74
74
|
"react-dom": "^18.0.0",
|
75
75
|
"stylelint": "^14.9.1"
|
76
76
|
},
|
77
|
-
"gitHead": "
|
77
|
+
"gitHead": "d4f36d49811bbff1291bc103c104a2f9c947fc4b",
|
78
78
|
"dependencies": {
|
79
79
|
"@ant-design/icons": "^5.3.7",
|
80
|
-
"@kep-platform/hooks": "^0.0.
|
80
|
+
"@kep-platform/hooks": "^0.0.20",
|
81
81
|
"color": "^4.2.3",
|
82
82
|
"rc-pagination": "^4.1.0",
|
83
83
|
"styled-components": "^6.1.11"
|