@kep-platform/basic-component 0.0.15 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
  }
@@ -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 {};
@@ -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
- pagination = _ref3.pagination;
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.filter(function (_, index) {
187
- return index >= startIndex && index <= endIndex;
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) {
@@ -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
  }
@@ -21,21 +21,25 @@ var ExpandedIcon = styled(CaretRightOutlined).withConfig({
21
21
  return css(["transform:rotate(90deg);"]);
22
22
  }
23
23
  });
24
+ var TitleArea = styled(FlexItem).withConfig({
25
+ displayName: "TitleArea",
26
+ componentId: "basic-component-347b__sc-tzoomn-1"
27
+ })([""]);
24
28
  var TreeNode = styled(ListItem).withConfig({
25
29
  displayName: "TreeNode",
26
- componentId: "basic-component-347b__sc-tzoomn-1"
27
- })(["", " & ", ",& ", "{background-color:var(--kep-platform-color-bg-base);}&:hover{background-color:var(--kep-platform-color-bg-hover);& ", ",& ", "{background-color:var(--kep-platform-color-bg-hover);}& ", "{overflow-x:auto;& > ", "{width:auto;}}}", ""], function (props) {
30
+ componentId: "basic-component-347b__sc-tzoomn-2"
31
+ })(["", " & ", ",& ", "{background-color:var(--kep-platform-color-bg-base);}&:hover{background-color:var(--kep-platform-color-bg-hover);& ", ",& ", "{background-color:var(--kep-platform-color-bg-hover);}& ", "{overflow-x:auto;& > ", "{width:auto;}}& ", "{overflow-x:auto;}}", ""], function (props) {
28
32
  if (props.width) {
29
33
  return css(["width:", "px;"], props.width);
30
34
  }
31
- }, Column, MainArea, Column, MainArea, MainArea, Flex, function (props) {
35
+ }, Column, MainArea, Column, MainArea, MainArea, Flex, TitleArea, function (props) {
32
36
  if (props.selected) {
33
- return css(["background-color:var(--kep-platform-color-bg-active) !important;color:var(--kep-platform-color-text-active) !important;& ", ",& ", "{background-color:var(--kep-platform-color-bg-active) !important;color:var(--kep-platform-color-text-active) !important;}& ", "{overflow-x:auto;& > ", "{width:auto;}}"], Column, MainArea, MainArea, Flex);
37
+ return css(["background-color:var(--kep-platform-color-bg-active) !important;color:var(--kep-platform-color-text-active) !important;& ", ",& ", "{background-color:var(--kep-platform-color-bg-active) !important;color:var(--kep-platform-color-text-active) !important;}& ", "{overflow-x:auto;& > ", "{width:auto;}}& ", "{overflow-x:auto;}"], Column, MainArea, MainArea, Flex, TitleArea);
34
38
  }
35
39
  });
36
40
  var TreeNodeGroupNode = styled.li.withConfig({
37
41
  displayName: "TreeNodeGroupNode",
38
- componentId: "basic-component-347b__sc-tzoomn-2"
42
+ componentId: "basic-component-347b__sc-tzoomn-3"
39
43
  })(["height:40px;line-height:40px;background-color:var(--kep-platform-color-primary);color:var(--kep-platform-color-white);& span{color:var(--kep-platform-color-white) !important;}cursor:pointer;", ""], function (props) {
40
44
  if (props.width) {
41
45
  return css(["width:", "px;"], props.width);
@@ -180,7 +184,7 @@ export var TreeNodeController = function TreeNodeController(_ref) {
180
184
  onClick: onClickExpandIconhandler
181
185
  }, /*#__PURE__*/React.createElement(ExpandedIcon, {
182
186
  expanded: expanded
183
- })), /*#__PURE__*/React.createElement(FlexItem, {
187
+ })), /*#__PURE__*/React.createElement(TitleArea, {
184
188
  flex: 1
185
189
  }, titleRender ? titleRender(node) : node[fieldNames.title])),
186
190
  property: isTableMode && /*#__PURE__*/React.createElement(Columns, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kep-platform/basic-component",
3
- "version": "0.0.15",
3
+ "version": "0.0.19",
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": "fe3e26f7d0e44ccd78969f3acc6f417ce39dd32d",
77
+ "gitHead": "4e24a0c14e9b1508022d27174161eb926de711ec",
78
78
  "dependencies": {
79
79
  "@ant-design/icons": "^5.3.7",
80
- "@kep-platform/hooks": "^0.0.15",
80
+ "@kep-platform/hooks": "^0.0.19",
81
81
  "color": "^4.2.3",
82
82
  "rc-pagination": "^4.1.0",
83
83
  "styled-components": "^6.1.11"