@ecoding/components.antd 0.2.25 → 0.2.26

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.
@@ -23,7 +23,7 @@ interface IProps extends SelectProps<any> {
23
23
  data?: IData;
24
24
  searchIface?: IFace;
25
25
  onChange?: any;
26
- onChangeAry?: any;
26
+ onChangeOpts?: any;
27
27
  }
28
28
  declare const AsyncSlect: React.FC<IProps>;
29
29
  export default AsyncSlect;
@@ -117,9 +117,9 @@ const AsyncSlect = memo((props) => {
117
117
  });
118
118
  timeout = setTimeout(innerEx, 300);
119
119
  });
120
- const changeHandler = (v, ary) => {
120
+ const changeHandler = (v, opts) => {
121
121
  props.onChange(v);
122
- props.onChangeAry && props.onChangeAry(ary);
122
+ props.onChangeOpts && props.onChangeOpts(opts);
123
123
  };
124
124
  const children = useMemo(() => {
125
125
  return (options &&
@@ -15,6 +15,8 @@ interface IProps {
15
15
  offsetY?: number;
16
16
  filterTitle?: string;
17
17
  columnsTitle?: string;
18
+ selectType?: "checkbox" | "radio";
19
+ selectChangeHandler?: any;
18
20
  }
19
21
  declare const TablePro: React.FC<IProps>;
20
22
  export default TablePro;
@@ -2,11 +2,12 @@ import React, { memo, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Popover, Button, Typography, Table } from 'antd';
3
3
  import { FilterOutlined, MenuOutlined } from '@ant-design/icons';
4
4
  import TableProColumns from "./columns";
5
- const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputArea, loading, rowKey, dataSource, pagination, offsetY, columns, operationColumn, bordered, columnsTitle, filterTitle }) => {
5
+ const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputArea, loading, rowKey, dataSource, pagination, offsetY, columns, operationColumn, bordered, selectChangeHandler, selectType, columnsTitle, filterTitle }) => {
6
6
  const ref = useRef(null);
7
7
  const disColumnRef = useRef([]);
8
8
  const [y, setY] = useState('100%');
9
9
  const [innerColumns, setColumns] = useState(columns);
10
+ const [selectedRowKeys, setSelectedRowKeys] = useState([]);
10
11
  const flexColumnStyle = {
11
12
  display: 'flex',
12
13
  height: '100%',
@@ -29,6 +30,15 @@ const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputA
29
30
  }
30
31
  return [];
31
32
  }, [innerColumns, dataSource]);
33
+ const onSelectChange = (newSelectedRowKeys) => {
34
+ setSelectedRowKeys(newSelectedRowKeys);
35
+ selectChangeHandler && selectChangeHandler(newSelectedRowKeys);
36
+ };
37
+ const rowSelection = {
38
+ type: selectType,
39
+ selectedRowKeys,
40
+ onChange: onSelectChange,
41
+ };
32
42
  useEffect(() => {
33
43
  if (disColumnRef.current && disColumnRef.current.length > 0 && columns.length > 0) {
34
44
  setColumns(columns.map((c) => {
@@ -71,7 +81,7 @@ const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputA
71
81
  } },
72
82
  React.createElement(Button, { type: "text", icon: React.createElement(MenuOutlined, null) }, columnsTitle))) : null)),
73
83
  dataSource ? (React.createElement("div", { style: { height: '100%', overflow: 'hidden' }, ref: ref },
74
- React.createElement(Table, { bordered: bordered, rowKey: rowKey, columns: showColumns, dataSource: dataSource, scroll: { y }, loading: loading, pagination: pagination || false }))) : null));
84
+ React.createElement(Table, { rowSelection: selectType ? rowSelection : undefined, bordered: bordered, rowKey: rowKey, columns: showColumns, dataSource: dataSource, scroll: { y }, loading: loading, pagination: pagination || false }))) : null));
75
85
  });
76
86
  TablePro.defaultProps = {
77
87
  filterTitle: "筛选",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -44,5 +44,5 @@
44
44
  "dependencies": {
45
45
  "react-quill": "^2.0.0"
46
46
  },
47
- "gitHead": "d70071f8ed2efa6df62ff1dcf2870eefec83e45c"
47
+ "gitHead": "6d629d39912b32986f91b6e2014db2b21f0605c2"
48
48
  }