@ecoding/components.antd 0.3.34 → 0.3.36

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.
@@ -5,6 +5,7 @@ interface IProps {
5
5
  header?: React.ReactNode;
6
6
  buttonArea?: React.ReactNode;
7
7
  filterArea?: React.ReactElement;
8
+ horizontalArea?: React.ReactElement;
8
9
  searchInputArea?: React.ReactElement;
9
10
  loading?: boolean;
10
11
  rowKey: string;
@@ -15,6 +16,7 @@ interface IProps {
15
16
  pagination?: any;
16
17
  offsetY?: number;
17
18
  onChange?: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<any> | SorterResult<any>[], extra: TableCurrentDataSource<any>) => void;
19
+ expandable?: any;
18
20
  filterTitle?: string;
19
21
  columnsTitle?: string;
20
22
  selectType?: "checkbox" | "radio";
@@ -2,7 +2,8 @@ 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, selectChangeHandler, selectType, onChange, columnsTitle, filterTitle }) => {
5
+ import { getDelateTargetByClassName } from "../../helpers/dom";
6
+ const TablePro = memo(({ className, header, buttonArea, filterArea, horizontalArea, searchInputArea, loading, rowKey, dataSource, pagination, offsetY, columns, operationColumn, bordered, selectChangeHandler, selectType, onChange, expandable, columnsTitle, filterTitle }) => {
6
7
  const ref = useRef(null);
7
8
  const disColumnRef = useRef([]);
8
9
  const [y, setY] = useState('100%');
@@ -72,7 +73,7 @@ const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputA
72
73
  }, [header, loading, innerColumns]);
73
74
  return (React.createElement("div", { style: flexColumnStyle, className: className || '' },
74
75
  header ? header : null,
75
- React.createElement("div", { style: operationWrap },
76
+ horizontalArea ? (React.createElement("div", { style: operationWrap }, horizontalArea)) : (React.createElement("div", { style: operationWrap },
76
77
  buttonArea ? React.createElement("div", null, buttonArea) : null,
77
78
  React.createElement("div", null,
78
79
  searchInputArea ? searchInputArea : null,
@@ -83,9 +84,22 @@ const TablePro = memo(({ className, header, buttonArea, filterArea, searchInputA
83
84
  innerColumns ? (React.createElement(Popover, { placement: "leftBottom", title: React.createElement(Typography.Title, { level: 5 }, columnsTitle), content: React.createElement(TableProColumns, { disColumnRef: disColumnRef, columns: innerColumns, setColumns: setColumns }), trigger: "click", open: openColumnFilter, onOpenChange: (newOpen) => {
84
85
  setOpenColumnFilter(newOpen);
85
86
  } },
86
- React.createElement(Button, { type: "text", icon: React.createElement(MenuOutlined, null) }, columnsTitle))) : null)),
87
+ React.createElement(Button, { type: "text", icon: React.createElement(MenuOutlined, null) }, columnsTitle))) : null))),
87
88
  dataSource ? (React.createElement("div", { style: { height: '100%', overflow: 'hidden' }, ref: ref },
88
- React.createElement(Table, { rowSelection: selectType ? rowSelection : undefined, bordered: bordered, rowKey: rowKey, columns: showColumns, dataSource: dataSource, scroll: { y }, loading: loading, pagination: pagination || false, onChange: onChange || undefined }))) : null));
89
+ React.createElement(Table, { rowSelection: selectType ? rowSelection : undefined, onRow: (record, index) => {
90
+ return {
91
+ onClick: (e) => {
92
+ const parent = getDelateTargetByClassName(e.target, "ant-table-tbody");
93
+ if (parent) {
94
+ const list = parent.querySelectorAll(".ant-table-row");
95
+ list.forEach(elem => {
96
+ elem.style = "";
97
+ });
98
+ list[index].style = "background: #e6f4ff";
99
+ }
100
+ }, // 点击行
101
+ };
102
+ }, expandable: expandable || undefined, bordered: bordered, rowKey: rowKey, columns: showColumns, dataSource: dataSource, scroll: { y }, loading: loading, pagination: pagination || false, onChange: onChange || undefined }))) : null));
89
103
  });
90
104
  TablePro.defaultProps = {
91
105
  filterTitle: "筛选",
@@ -0,0 +1 @@
1
+ export declare const getDelateTargetByClassName: (elem: any, str: string) => any;
@@ -0,0 +1,61 @@
1
+ export const getDelateTargetByClassName = (elem, str) => {
2
+ if (!elem) {
3
+ return null;
4
+ }
5
+ const re = new RegExp("(\\s|^)" + str + "(\\s|$)", "i");
6
+ let parent = elem;
7
+ while (parent && !re.test(parent.className)) {
8
+ parent = parent.parentNode;
9
+ }
10
+ return parent ? parent : null;
11
+ };
12
+ // export const addClass = (elem, className: string) => {
13
+ // if (!className) {
14
+ // return this;
15
+ // }
16
+ // let arr;
17
+ // if (elem!.className) {
18
+ // // 解析当前 className 转换为数组
19
+ // arr = elem!.className.split(/\s/);
20
+ // arr = arr.filter((item) => {
21
+ // return !!item.trim();
22
+ // });
23
+ // // 添加 class
24
+ // if (arr.indexOf(className) < 0) {
25
+ // arr.push(className);
26
+ // }
27
+ // // 修改 elem.class
28
+ // elem!.className = arr.join(" ");
29
+ // } else {
30
+ // elem!.className = className;
31
+ // }
32
+ // return this;
33
+ // }
34
+ // // 删除 class
35
+ // export const removeClass = (elem, className: string) => {
36
+ // if (!className) {
37
+ // return this;
38
+ // }
39
+ // let arr;
40
+ // if (elem!.className) {
41
+ // // 解析当前 className 转换为数组
42
+ // arr = elem!.className.split(/\s/);
43
+ // arr = arr.filter((item) => {
44
+ // item = item.trim();
45
+ // // 删除 class
46
+ // if (!item || item === className) {
47
+ // return false;
48
+ // }
49
+ // return true;
50
+ // });
51
+ // // 修改 elem.class
52
+ // elem!.className = arr.join(" ");
53
+ // }
54
+ // return this;
55
+ // }
56
+ // export const hasClass = (elem, className) => {
57
+ // if (!className) {
58
+ // return false;
59
+ // }
60
+ // return elem.className.match(new RegExp(`(\\s|^)${className}(\\s|$)`));
61
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.3.34",
3
+ "version": "0.3.36",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -43,5 +43,5 @@
43
43
  "antd": "^5.8.4",
44
44
  "axios": "^1.1.2"
45
45
  },
46
- "gitHead": "aec3b5b35f5a1ebedc7f09c378da17403aa2e574"
46
+ "gitHead": "972f3418fd6fdf656f374823d1c804d6519bcb6b"
47
47
  }