@ecoding/components.antd 0.5.12 → 0.5.14

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.
@@ -8,6 +8,7 @@ interface IC {
8
8
  name?: string;
9
9
  rules?: any;
10
10
  width?: number;
11
+ valuePropName?: string;
11
12
  noStyleHidden?: boolean;
12
13
  hideRemove?: boolean | ((field: FormListFieldData, index: number) => boolean);
13
14
  render?: (field: FormListFieldData, index: number, { add, remove }: {
@@ -5,7 +5,7 @@ import { DndContext, closestCenter, PointerSensor, useSensor, useSensors } from
5
5
  import { SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
6
6
  import { CSS } from '@dnd-kit/utilities';
7
7
  const SortableItem = (props) => {
8
- const { columns, i18n, field, index, add, remove, afterRemove, enableSort, disabled } = props;
8
+ const { columns, i18n, field, index, add, remove, afterRemove, enableSort, disabled, operation } = props;
9
9
  const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
10
10
  id: props.id
11
11
  });
@@ -46,6 +46,9 @@ const SortableItem = (props) => {
46
46
  index + 1)),
47
47
  columns.map((column, i) => {
48
48
  if (column.type == "operation") {
49
+ if (operation === null || operation === void 0 ? void 0 : operation.hide) {
50
+ return null;
51
+ }
49
52
  return (React.createElement("td", { style: Object.assign({}, tdStyle, { right: 0, zIndex: 10, position: "sticky", backgroundColor: "#fff" }) },
50
53
  React.createElement(Space, null,
51
54
  column.render && column.render(field, index, { add, remove }),
@@ -60,13 +63,13 @@ const SortableItem = (props) => {
60
63
  else {
61
64
  if (column.noStyleHidden) {
62
65
  return (React.createElement("td", { style: { display: "none" } },
63
- React.createElement(Form.Item, { noStyle: true, hidden: true, name: [field.name, column.name] }, column.render(field, index, { add, remove }))));
66
+ React.createElement(Form.Item, { noStyle: true, hidden: true, name: [field.name, column.name], valuePropName: column.valuePropName ? column.valuePropName : undefined }, column.render(field, index, { add, remove }))));
64
67
  }
65
68
  return (React.createElement("td", { style: tdStyle },
66
- React.createElement(Form.Item, { style: { marginBottom: 0 }, name: [field.name, column.name], rules: column.rules || [] }, column.render(field, index, { add, remove }))));
69
+ React.createElement(Form.Item, { style: { marginBottom: 0 }, name: [field.name, column.name], rules: column.rules || [], valuePropName: column.valuePropName ? column.valuePropName : undefined }, column.render(field, index, { add, remove }))));
67
70
  }
68
71
  }),
69
- needDefaultOperation ? (React.createElement("td", { style: Object.assign({}, tdStyle, { right: 0, zIndex: 10, position: "sticky", backgroundColor: "#fff" }) },
72
+ needDefaultOperation && (operation === null || operation === void 0 ? void 0 : operation.hide) != true ? (React.createElement("td", { style: Object.assign({}, tdStyle, { right: 0, zIndex: 10, position: "sticky", backgroundColor: "#fff" }) },
70
73
  React.createElement(Typography.Text, { style: disabled ? { cursor: 'no-drop', 'color': '#ccc' } : { cursor: 'pointer' }, type: disabled ? undefined : "danger", onClick: () => {
71
74
  if (disabled) {
72
75
  return;
@@ -94,12 +97,9 @@ const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i1
94
97
  }
95
98
  w += column.width || 200;
96
99
  });
97
- if (operation) {
100
+ if (operation && operation.hide != true) {
98
101
  w += operation.width || 150;
99
102
  }
100
- else {
101
- w += 150;
102
- }
103
103
  return w;
104
104
  }, []);
105
105
  return (React.createElement(Form.List, { name: name, rules: rules || [] }, (fields, { add, remove, move }, { errors }) => {
@@ -143,7 +143,7 @@ const C = ({ columns, rules, tStyle, name, hideHeader, hideBottom, operation, i1
143
143
  }
144
144
  } },
145
145
  React.createElement(SortableContext, { items: fields.map(field => field.key), strategy: verticalListSortingStrategy }, fields.map((field, index) => {
146
- return (React.createElement(SortableItem, { columns: columns, index: index, key: field.key, disabled: disabled, id: field.key, i18n: i18n, field: field, add: add, remove: remove, afterRemove: afterRemove, enableSort: enableSort }));
146
+ return (React.createElement(SortableItem, { columns: columns, index: index, key: field.key, operation: operation, disabled: disabled, id: field.key, i18n: i18n, field: field, add: add, remove: remove, afterRemove: afterRemove, enableSort: enableSort }));
147
147
  })))))),
148
148
  hideBottom || disabled ? null : (React.createElement("div", null,
149
149
  React.createElement(Button, { icon: React.createElement(PlusCircleOutlined, null), type: "dashed", onClick: () => {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { FilterValue, SorterResult, TableCurrentDataSource, TablePaginationConfig, TableLocale } from 'antd/lib/table/interface';
3
3
  import type { ColProps } from 'antd/lib/col';
4
+ import type { TableProps } from 'antd';
4
5
  interface TableProRef {
5
6
  clear: () => void;
6
7
  setSelectedRowKeys: (key: React.Key[]) => void;
@@ -11,7 +12,7 @@ interface IProps {
11
12
  header?: React.ReactNode;
12
13
  buttonArea?: React.ReactNode;
13
14
  scrollY?: string | number;
14
- scrollX?: string | number | 'max-content';
15
+ scrollX?: 'max-content' | string | number;
15
16
  filters?: {
16
17
  overMax?: number;
17
18
  colOpts?: ColProps;
@@ -28,6 +29,7 @@ interface IProps {
28
29
  bordered?: boolean;
29
30
  dataSource: any;
30
31
  columns: any[];
32
+ rowSelection?: TableProps<any>['rowSelection'];
31
33
  selectKeys?: React.Key[];
32
34
  operationColumn?: any[];
33
35
  pagination?: any;
@@ -5,7 +5,7 @@ import { isEqual } from "@ecoding/helper.is";
5
5
  import TableProColumns from "./columns";
6
6
  import { getDelateTargetByClassName } from "../../helpers/dom";
7
7
  import FilterHorizontal from "./filters.horizontal";
8
- const TablePro = ({ className, header, buttonArea, filterArea, filters, searchInputArea, loading, rowKey, dataSource, pagination, offsetY, columns, operationColumn, bordered = false, selectChangeHandler, selectType, selectKeys, onChange, expandable, columnsTitle, filterTitle, locale, scrollY = '100%', scrollX, i18n, }, ref) => {
8
+ const TablePro = ({ className, header, buttonArea, filterArea, filters, searchInputArea, loading, rowKey, dataSource, pagination, offsetY, columns, operationColumn, bordered = false, selectChangeHandler, selectType, selectKeys, rowSelection, onChange, expandable, columnsTitle, filterTitle, locale, scrollY = '100%', scrollX, i18n, }, ref) => {
9
9
  const tableRef = useRef(null);
10
10
  const disColumnRef = useRef([]);
11
11
  const [y, setY] = useState(scrollY);
@@ -71,7 +71,7 @@ const TablePro = ({ className, header, buttonArea, filterArea, filters, searchIn
71
71
  setSelectedRowKeys(tempKeys);
72
72
  selectChangeHandler && selectChangeHandler(tempKeys, selectedRows);
73
73
  };
74
- const rowSelection = Object.assign({}, {
74
+ const rowSelections = Object.assign({}, {
75
75
  type: selectType,
76
76
  selectedRowKeys,
77
77
  }, selectType === 'checkbox' ? {
@@ -82,7 +82,7 @@ const TablePro = ({ className, header, buttonArea, filterArea, filters, searchIn
82
82
  setSelectedRowKeys(selectedRowKeys);
83
83
  selectChangeHandler && selectChangeHandler(selectedRowKeys, selectedRows);
84
84
  }
85
- } : {});
85
+ } : {}, rowSelection ? Object.assign({}, rowSelection) : {});
86
86
  useEffect(() => {
87
87
  if (disColumnRef.current && disColumnRef.current.length > 0 && columns.length > 0) {
88
88
  setColumns(columns.map((c) => {
@@ -154,7 +154,7 @@ const TablePro = ({ className, header, buttonArea, filterArea, filters, searchIn
154
154
  } },
155
155
  React.createElement(Button, { type: "text", icon: React.createElement(MenuOutlined, null) }, columnsTitleStr))) : null)),
156
156
  dataSource ? (React.createElement("div", { style: { height: '100%', overflow: 'hidden' }, ref: tableRef },
157
- React.createElement(Table, { rowSelection: selectType ? rowSelection : undefined, locale: locale ? locale : undefined, onRow: (record, index) => {
157
+ React.createElement(Table, { rowSelection: selectType ? rowSelections : undefined, locale: locale ? locale : undefined, onRow: (record, index) => {
158
158
  return {
159
159
  onClick: (e) => {
160
160
  const parent = getDelateTargetByClassName(e.target, "ant-table-tbody");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.5.12",
3
+ "version": "0.5.14",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -47,5 +47,5 @@
47
47
  "antd": "^6.0.0",
48
48
  "axios": "^1.1.2"
49
49
  },
50
- "gitHead": "cb63979a8fe80d8595a2ad966dca360f08df2fca"
50
+ "gitHead": "63dbd74fd806139370f6f812cc712756866283ff"
51
51
  }