ronds-metadata 1.0.43 → 1.0.46

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.
@@ -6,7 +6,7 @@ import _Input from "antd/es/input";
6
6
  /*
7
7
  * @Author: wangxian
8
8
  * @Date: 2022-03-04 14:53:50
9
- * @LastEditTime: 2022-03-08 17:22:26
9
+ * @LastEditTime: 2022-03-10 14:38:32
10
10
  */
11
11
  import React from 'react';
12
12
  import { EditableContext } from '../interface';
@@ -20,15 +20,23 @@ function Index(props) {
20
20
  editConfig = _ref.editConfig;
21
21
 
22
22
  var inputRef = React.useRef();
23
+ var firstLoadRef = React.useRef(true);
23
24
  React.useEffect(function () {
24
25
  var _editConfig$editCellK, _editConfig$editCellK2;
25
26
 
26
27
  if (!inputRef.current) return;
27
28
 
28
29
  if (((_editConfig$editCellK = editConfig.editCellKey) === null || _editConfig$editCellK === void 0 ? void 0 : _editConfig$editCellK.dataIndex) === dataIndex && ((_editConfig$editCellK2 = editConfig.editCellKey) === null || _editConfig$editCellK2 === void 0 ? void 0 : _editConfig$editCellK2.rowIndex) === rowIndex) {
29
- inputRef.current.input.setSelectionRange(0, inputRef.current.state.value.length); // 选中内容
30
+ if (firstLoadRef.current) {
31
+ var _inputRef$current$sta, _inputRef$current$sta2;
30
32
 
31
- inputRef.current.focus(); // 设置焦点
33
+ // 选中内容
34
+ inputRef.current.input.setSelectionRange(0, ((_inputRef$current$sta = inputRef.current.state) === null || _inputRef$current$sta === void 0 ? void 0 : (_inputRef$current$sta2 = _inputRef$current$sta.value) === null || _inputRef$current$sta2 === void 0 ? void 0 : _inputRef$current$sta2.length) || 0);
35
+ firstLoadRef.current = false;
36
+ } // 设置焦点
37
+
38
+
39
+ inputRef.current.focus();
32
40
  }
33
41
  }, [editConfig]);
34
42
  return /*#__PURE__*/React.createElement(_Form.Item, {
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
2
  import { EditableCellProps } from '../interface';
3
+ import './index.less';
3
4
  declare const EditableCell: React.FC<EditableCellProps>;
4
5
  export default EditableCell;
@@ -2,13 +2,15 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import "antd/es/message/style";
3
3
  import _message from "antd/es/message";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["editable", "record", "editableType", "dataIndex", "rowIndex", "children"];
5
+ var _excluded = ["isAddColumn", "editable", "record", "editableType", "dataIndex", "rowIndex", "children"];
6
6
  import React from 'react';
7
7
  import { EditableContext } from '../interface';
8
- import { getDataCell } from '../utils';
8
+ import { getDataCell, isFreeEditCell, isFreeEditRow } from '../utils';
9
+ import "./index.css";
9
10
 
10
11
  var EditableCell = function EditableCell(props) {
11
- var editable = props.editable,
12
+ var isAddColumn = props.isAddColumn,
13
+ editable = props.editable,
12
14
  record = props.record,
13
15
  editableType = props.editableType,
14
16
  dataIndex = props.dataIndex,
@@ -18,13 +20,12 @@ var EditableCell = function EditableCell(props) {
18
20
 
19
21
  var _ref = React.useContext(EditableContext) || undefined,
20
22
  editableStream = _ref.editableStream,
21
- editConfig = _ref.editConfig;
23
+ editConfig = _ref.editConfig; // console.log('EditableCell', props, editConfig);
22
24
 
23
- var onCellClick = function onCellClick() {
24
- if (editConfig === null || editConfig === void 0 ? void 0 : editConfig.curRow) {
25
- var _editConfig$curRow;
26
25
 
27
- if (((_editConfig$curRow = editConfig.curRow) === null || _editConfig$curRow === void 0 ? void 0 : _editConfig$curRow.toString().split(',').indexOf("".concat(rowIndex))) > -1) return;
26
+ var onCellDoubleClick = function onCellDoubleClick() {
27
+ if ((editConfig === null || editConfig === void 0 ? void 0 : editConfig.curRow) && (editConfig === null || editConfig === void 0 ? void 0 : editConfig.curRow) !== 'undefined') {
28
+ if (isFreeEditRow(editConfig.curRow, rowIndex)) return;
28
29
 
29
30
  _message.warning('请先保存正在编辑的行');
30
31
 
@@ -40,21 +41,43 @@ var EditableCell = function EditableCell(props) {
40
41
  });
41
42
  };
42
43
 
44
+ var onCellClick = function onCellClick() {
45
+ if (!isFreeEditCell(editConfig.editCellKey, dataIndex, rowIndex)) {
46
+ editableStream.next({
47
+ type: 'editCellKey',
48
+ payload: {
49
+ dataIndex: undefined,
50
+ rowIndex: undefined
51
+ }
52
+ });
53
+ }
54
+
55
+ if (isAddColumn) {
56
+ editableStream.next({
57
+ type: 'editHeardCellKey',
58
+ payload: undefined
59
+ });
60
+ }
61
+ };
62
+
43
63
  if (editableType === 'single') {
44
- return /*#__PURE__*/React.createElement("td", restProps, editable && editConfig.curRow === rowIndex ? getDataCell(props) : children);
64
+ return /*#__PURE__*/React.createElement("td", _extends({}, restProps, {
65
+ className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
66
+ }), editable && editConfig.curRow === rowIndex ? getDataCell(props) : children);
45
67
  }
46
68
 
47
69
  if (editableType === 'freedom') {
48
- var _editConfig$curRow2, _editConfig$editCellK, _editConfig$editCellK2;
49
-
50
- var isAddRow = editable && ((_editConfig$curRow2 = editConfig.curRow) === null || _editConfig$curRow2 === void 0 ? void 0 : _editConfig$curRow2.toString().split(',').indexOf("".concat(rowIndex))) > -1;
51
- var isCell = editable && ((_editConfig$editCellK = editConfig.editCellKey) === null || _editConfig$editCellK === void 0 ? void 0 : _editConfig$editCellK.dataIndex) === dataIndex && ((_editConfig$editCellK2 = editConfig.editCellKey) === null || _editConfig$editCellK2 === void 0 ? void 0 : _editConfig$editCellK2.rowIndex) === rowIndex;
52
70
  return /*#__PURE__*/React.createElement("td", _extends({
53
- onDoubleClick: onCellClick
54
- }, restProps), isAddRow || isCell ? getDataCell(props) : children);
71
+ onDoubleClick: onCellDoubleClick,
72
+ onClick: onCellClick
73
+ }, restProps, {
74
+ className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
75
+ }), editable && (isFreeEditRow(editConfig.curRow, rowIndex) || isFreeEditCell(editConfig.editCellKey, dataIndex, rowIndex)) ? getDataCell(props) : children);
55
76
  }
56
77
 
57
- return /*#__PURE__*/React.createElement("td", restProps, editable ? getDataCell(props) : children);
78
+ return /*#__PURE__*/React.createElement("td", _extends({}, restProps, {
79
+ className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
80
+ }), editable ? getDataCell(props) : children);
58
81
  };
59
82
 
60
83
  export default EditableCell;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { EditableHeardCellProps } from '../interface';
3
+ import './index.less';
4
+ declare const EditableHeardCell: React.FC<EditableHeardCellProps>;
5
+ export default EditableHeardCell;
@@ -0,0 +1,141 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import "antd/es/popover/style";
3
+ import _Popover from "antd/es/popover";
4
+ import "antd/es/button/style";
5
+ import _Button from "antd/es/button";
6
+ import "antd/es/input/style";
7
+ import _Input from "antd/es/input";
8
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
9
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
10
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
11
+ var _excluded = ["title", "dataIndex", "isAddColumn", "children"];
12
+ import { PlusSquareOutlined, DeleteOutlined } from '@ant-design/icons';
13
+ import React from 'react';
14
+ import { EditableContext } from '../interface';
15
+ import "./index.css";
16
+
17
+ var EditableHeardCell = function EditableHeardCell(props) {
18
+ var title = props.title,
19
+ dataIndex = props.dataIndex,
20
+ isAddColumn = props.isAddColumn,
21
+ children = props.children,
22
+ restProps = _objectWithoutProperties(props, _excluded);
23
+
24
+ var _ref = React.useContext(EditableContext) || undefined,
25
+ editableStream = _ref.editableStream,
26
+ editConfig = _ref.editConfig;
27
+
28
+ var addColumnRef = React.useRef({
29
+ key: '',
30
+ title: ''
31
+ });
32
+
33
+ var _React$useState = React.useState({
34
+ key: '',
35
+ title: ''
36
+ }),
37
+ _React$useState2 = _slicedToArray(_React$useState, 2),
38
+ addColumn = _React$useState2[0],
39
+ setAddColumn = _React$useState2[1];
40
+
41
+ var _React$useState3 = React.useState(false),
42
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
43
+ visible = _React$useState4[0],
44
+ setVisible = _React$useState4[1];
45
+
46
+ var onMouseOver = function onMouseOver() {
47
+ editableStream.next({
48
+ type: 'editHeardCellKey',
49
+ payload: dataIndex
50
+ });
51
+ };
52
+
53
+ var onMouseLeave = function onMouseLeave() {};
54
+
55
+ var onAddColumn = function onAddColumn() {
56
+ setVisible(false);
57
+ editableStream.next({
58
+ type: 'onAddColumn',
59
+ payload: _objectSpread({
60
+ dataIndex: dataIndex
61
+ }, addColumnRef.current)
62
+ });
63
+ setAddColumn({
64
+ key: '',
65
+ title: ''
66
+ });
67
+ addColumnRef.current = {
68
+ key: '',
69
+ title: ''
70
+ };
71
+ };
72
+
73
+ var content = /*#__PURE__*/React.createElement("div", {
74
+ style: {
75
+ width: '100px'
76
+ }
77
+ }, /*#__PURE__*/React.createElement("div", {
78
+ style: {
79
+ marginBottom: '10px'
80
+ }
81
+ }, /*#__PURE__*/React.createElement(_Input, {
82
+ value: addColumn.key,
83
+ style: {
84
+ width: '100%',
85
+ marginBottom: '5px'
86
+ },
87
+ onChange: function onChange(e) {
88
+ var _ = addColumnRef.current;
89
+ _.key = e.target.value;
90
+ setAddColumn(_objectSpread({}, _));
91
+ addColumnRef.current = _;
92
+ },
93
+ placeholder: "\u8BF7\u8F93\u5165key"
94
+ }), /*#__PURE__*/React.createElement(_Input, {
95
+ value: addColumn.title,
96
+ style: {
97
+ width: '100%'
98
+ },
99
+ onChange: function onChange(e) {
100
+ var _ = addColumnRef.current;
101
+ _.title = e.target.value;
102
+ setAddColumn(_objectSpread({}, _));
103
+ addColumnRef.current = _;
104
+ },
105
+ placeholder: "\u8BF7\u8F93\u5165title",
106
+ onPressEnter: onAddColumn
107
+ })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, {
108
+ type: "primary",
109
+ block: true,
110
+ onClick: onAddColumn
111
+ }, "\u786E\u5B9A")));
112
+
113
+ var onVisibleChange = function onVisibleChange(b) {
114
+ setVisible(b);
115
+ };
116
+
117
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("th", _extends({}, restProps, {
118
+ className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right ' : '', " ")
119
+ }), isAddColumn && /*#__PURE__*/React.createElement(_Popover, {
120
+ placement: "rightTop",
121
+ content: content,
122
+ trigger: "click",
123
+ visible: visible,
124
+ onVisibleChange: onVisibleChange
125
+ }, /*#__PURE__*/React.createElement("div", {
126
+ className: "".concat(editConfig.editHeardCellKey === dataIndex ? 'editable-th-hover-add' : 'display-none')
127
+ }, /*#__PURE__*/React.createElement(_Button, {
128
+ type: "link",
129
+ icon: /*#__PURE__*/React.createElement(PlusSquareOutlined, null)
130
+ }))), isAddColumn && /*#__PURE__*/React.createElement("div", {
131
+ className: "".concat(editConfig.editHeardCellKey === dataIndex ? 'editable-th-hover-delete' : 'display-none')
132
+ }, /*#__PURE__*/React.createElement(_Button, {
133
+ type: "link",
134
+ icon: /*#__PURE__*/React.createElement(DeleteOutlined, null)
135
+ })), /*#__PURE__*/React.createElement("div", {
136
+ onMouseOver: onMouseOver,
137
+ onMouseLeave: onMouseLeave
138
+ }, children)));
139
+ };
140
+
141
+ export default EditableHeardCell;
@@ -0,0 +1,19 @@
1
+ .editable-th-hover-add {
2
+ position: absolute;
3
+ right: -16px;
4
+ top: -30px;
5
+ }
6
+ .editable-th-hover-delete {
7
+ position: absolute;
8
+ left: 49%;
9
+ top: -30px;
10
+ }
11
+ .display-none {
12
+ display: none;
13
+ }
14
+ .border-right {
15
+ border-right: 1px solid var(--antd-wave-shadow-color) !important;
16
+ }
17
+ .border-top {
18
+ border-top: 1px solid var(--antd-wave-shadow-color) !important;
19
+ }
@@ -11,7 +11,7 @@ interface IEditableProps<R = any> {
11
11
  /**
12
12
  * 表格列的配置描述
13
13
  */
14
- columns: EditColumnsType;
14
+ columns: EditColumnsType[];
15
15
  /**
16
16
  * 新增一列 默认的值
17
17
  */
@@ -28,6 +28,10 @@ interface IEditableProps<R = any> {
28
28
  * 只读
29
29
  */
30
30
  readonly?: boolean;
31
+ /**
32
+ * 是否可以添加列
33
+ */
34
+ isAddColumn?: boolean;
31
35
  /**
32
36
  * antd自身的属性
33
37
  */
@@ -3,10 +3,10 @@ import _Button from "antd/es/button";
3
3
  import "antd/es/table/style";
4
4
  import _Table from "antd/es/table";
5
5
  import _extends from "@babel/runtime/helpers/esm/extends";
6
- import "antd/es/message/style";
7
- import _message from "antd/es/message";
8
6
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
9
7
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
8
+ import "antd/es/message/style";
9
+ import _message from "antd/es/message";
10
10
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
11
  import React from 'react';
12
12
  import { BehaviorSubject } from 'rxjs';
@@ -15,6 +15,8 @@ import EditableCell from './comps/EditableCell';
15
15
  import EditableRow from './comps/EditableRow';
16
16
  import { EditableContext } from './interface';
17
17
  import EditableAction from './comps/EditableAction';
18
+ import { isFreeEditRow, removeCurKeyFromEditRow } from './utils';
19
+ import EditableHeardCell from './comps/EditableHeardCell';
18
20
 
19
21
  var Editable = function Editable(props) {
20
22
  var _props$type = props.type,
@@ -25,6 +27,8 @@ var Editable = function Editable(props) {
25
27
  defaultValue = props.defaultValue,
26
28
  _props$addPosition = props.addPosition,
27
29
  addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition,
30
+ _props$isAddColumn = props.isAddColumn,
31
+ isAddColumn = _props$isAddColumn === void 0 ? false : _props$isAddColumn,
28
32
  tableProps = props.tableProps,
29
33
  onRowConfirm = props.onRowConfirm,
30
34
  onRowDelete = props.onRowDelete,
@@ -53,8 +57,21 @@ var Editable = function Editable(props) {
53
57
  var _React$useState7 = React.useState(),
54
58
  _React$useState8 = _slicedToArray(_React$useState7, 2),
55
59
  editCellKey = _React$useState8[0],
56
- setEditCellkey = _React$useState8[1]; // 记录上一次发生改变的行值
60
+ setEditCellkey = _React$useState8[1]; // 添加一列表头
61
+
57
62
 
63
+ var _React$useState9 = React.useState(),
64
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
65
+ editHeardCellKey = _React$useState10[0],
66
+ setEditHeardCellkey = _React$useState10[1]; // 记录临时加的列头
67
+
68
+
69
+ var _React$useState11 = React.useState([]),
70
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
71
+ addColumns = _React$useState12[0],
72
+ setAddColumns = _React$useState12[1];
73
+
74
+ var addColumnsRef = React.useRef([]); // 记录上一次发生改变的行值
58
75
 
59
76
  var lastValueRef = React.useRef(); // 记录上一次的datasource
60
77
 
@@ -64,6 +81,35 @@ var Editable = function Editable(props) {
64
81
  var editableStream = React.useMemo(function () {
65
82
  return new BehaviorSubject(undefined);
66
83
  }, []);
84
+
85
+ var processAddColumnsData = function processAddColumnsData(data) {
86
+ var _columns = addColumnsRef.current.length > 0 ? addColumnsRef.current : columns; // 判断key是否重复
87
+
88
+
89
+ if (_columns.findIndex(function (v) {
90
+ return v.key === data.key;
91
+ }) > -1) {
92
+ _message.warning('表格的key不可以重复');
93
+
94
+ return;
95
+ }
96
+
97
+ var idx = _columns.findIndex(function (v) {
98
+ return v.dataIndex === data.dataIndex;
99
+ });
100
+
101
+ var obj = {
102
+ title: data.title,
103
+ key: data.key,
104
+ dataIndex: data.key
105
+ };
106
+
107
+ _columns.splice(idx + 1, 0, _objectSpread(_objectSpread({}, _columns[0]), obj));
108
+
109
+ setAddColumns(_toConsumableArray(_columns));
110
+ addColumnsRef.current = _columns; // editableStream.next({ type: 'editHeardCellKey', payload: undefined });
111
+ };
112
+
67
113
  var processStreamFactory = React.useCallback(function (data) {
68
114
  switch (data === null || data === void 0 ? void 0 : data.type) {
69
115
  case 'onValuesChange':
@@ -103,7 +149,14 @@ var Editable = function Editable(props) {
103
149
  dataIndex: data.payload.dataIndex,
104
150
  rowIndex: data.payload.rowIndex
105
151
  });
106
- editRowKeyRef.current = data.payload._rowKey_;
152
+ break;
153
+
154
+ case 'editHeardCellKey':
155
+ setEditHeardCellkey(data.payload);
156
+ break;
157
+
158
+ case 'onAddColumn':
159
+ processAddColumnsData(data.payload);
107
160
  break;
108
161
 
109
162
  case 'onSingleSave':
@@ -143,6 +196,21 @@ var Editable = function Editable(props) {
143
196
 
144
197
  if (type === 'freedom') {
145
198
  // 正在全行编辑的直接删除,不需要回调
199
+ if (isFreeEditRow(editRowKeyRef.current, data.payload._rowKey_)) {
200
+ var _records4 = recordsRef.current;
201
+
202
+ _records4.splice(data.payload._rowKey_, 1);
203
+
204
+ setRecords(_toConsumableArray(_records4));
205
+ recordsRef.current = _records4; // 移除当前的行的编辑状态
206
+
207
+ var _editRowKey = removeCurKeyFromEditRow(editRowKeyRef.current, data.payload._rowKey_);
208
+
209
+ setEditRowkey(_editRowKey);
210
+ editRowKeyRef.current = _editRowKey;
211
+ return;
212
+ }
213
+
146
214
  onRowDelete && onRowDelete(data.payload);
147
215
  }
148
216
 
@@ -181,18 +249,30 @@ var Editable = function Editable(props) {
181
249
  _column.onCell = function (record, rowIndex) {
182
250
  return _objectSpread(_objectSpread({
183
251
  record: record,
184
- editableType: type
252
+ editableType: type,
253
+ isAddColumn: isAddColumn
185
254
  }, pick(column, ['editable', 'title', 'dataIndex', 'type', 'enum', 'disabled'])), {}, {
186
255
  rowIndex: rowIndex
187
256
  });
188
257
  };
189
258
  }
190
259
 
260
+ if (isAddColumn) {
261
+ _column.onHeaderCell = function (col) {
262
+ return _objectSpread({
263
+ width: col.width,
264
+ isAddColumn: isAddColumn
265
+ }, pick(column, ['title', 'dataIndex']));
266
+ };
267
+ }
268
+
191
269
  return _column;
192
270
  }, [readonly, type]); // 处理一下编辑表格的数据
193
271
 
194
272
  var _columns = React.useMemo(function () {
195
- var res = columns.map(getEditColumn);
273
+ var __columns__ = addColumns && addColumns.length > 0 ? addColumns : columns;
274
+
275
+ var res = __columns__.map(getEditColumn);
196
276
 
197
277
  if (!readonly) {
198
278
  var _aciton_ = {
@@ -214,7 +294,7 @@ var Editable = function Editable(props) {
214
294
  }
215
295
 
216
296
  return res;
217
- }, [columns, readonly, type]); // 主要是自己加一层rowkey
297
+ }, [columns, readonly, type, addColumns]); // 主要是自己加一层rowkey
218
298
 
219
299
 
220
300
  var _dataSource = React.useMemo(function () {
@@ -266,7 +346,8 @@ var Editable = function Editable(props) {
266
346
  editConfig: {
267
347
  curRow: editRowKey,
268
348
  type: editType,
269
- editCellKey: editCellKey
349
+ editCellKey: editCellKey,
350
+ editHeardCellKey: editHeardCellKey
270
351
  }
271
352
  }
272
353
  }, /*#__PURE__*/React.createElement(_Table, _extends({
@@ -278,6 +359,9 @@ var Editable = function Editable(props) {
278
359
  columns: _columns,
279
360
  dataSource: _dataSource,
280
361
  components: {
362
+ header: {
363
+ cell: EditableHeardCell
364
+ },
281
365
  body: {
282
366
  row: EditableRow,
283
367
  cell: EditableCell
@@ -289,7 +373,7 @@ var Editable = function Editable(props) {
289
373
  index: index
290
374
  };
291
375
  }
292
- })), (type === 'multiple' || type === 'freedom') && /*#__PURE__*/React.createElement(_Button, {
376
+ })), (type === 'multiple' || type === 'freedom') && !readonly && /*#__PURE__*/React.createElement(_Button, {
293
377
  block: true,
294
378
  type: "dashed",
295
379
  style: {
@@ -6,6 +6,7 @@ export interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
6
6
  editable: boolean;
7
7
  disabled?: boolean;
8
8
  dataIndex: string;
9
+ isAddColumn: boolean;
9
10
  rowIndex: number;
10
11
  record: any;
11
12
  type: InputType;
@@ -16,6 +17,13 @@ export interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
16
17
  }[];
17
18
  children: React.ReactNode;
18
19
  }
20
+ export interface EditableHeardCellProps extends React.HTMLAttributes<HTMLElement> {
21
+ title: any;
22
+ width: number;
23
+ isAddColumn: boolean;
24
+ dataIndex: string;
25
+ children: React.ReactNode;
26
+ }
19
27
  export interface EditableRowProps extends React.HTMLAttributes<HTMLElement> {
20
28
  rowIndex: number;
21
29
  record?: any;
@@ -47,6 +55,7 @@ export interface IEditableContextProps {
47
55
  dataIndex: string;
48
56
  rowIndex: number;
49
57
  };
58
+ editHeardCellKey: string;
50
59
  };
51
60
  }
52
61
  export declare const EditableContext: React.Context<IEditableContextProps>;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2022-03-04 15:07:57
4
- * @LastEditTime: 2022-03-08 17:06:55
4
+ * @LastEditTime: 2022-03-10 13:49:40
5
5
  */
6
6
  import React from 'react';
7
7
  export var EditableContext = /*#__PURE__*/React.createContext(null);
@@ -1,4 +1,5 @@
1
1
  import { EditableCellProps } from './interface';
2
2
  export declare function getDataCell(item: EditableCellProps): JSX.Element;
3
- export declare function isFreeEditRow(): void;
4
- export declare function isFreeEditCell(): void;
3
+ export declare function isFreeEditRow(curRow: any, rowIndex: number): boolean;
4
+ export declare function isFreeEditCell(editCellKey: any, dataIndex: string, rowIndex: number): boolean;
5
+ export declare function removeCurKeyFromEditRow(editRowKey: any, curKey: number): string;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2022-03-04 14:59:04
4
- * @LastEditTime: 2022-03-09 09:27:01
4
+ * @LastEditTime: 2022-03-09 10:42:38
5
5
  */
6
6
  import React from 'react';
7
7
  import Input from './DataCell/Input';
@@ -22,5 +22,21 @@ export function getDataCell(item) {
22
22
 
23
23
  return null;
24
24
  }
25
- export function isFreeEditRow() {}
26
- export function isFreeEditCell() {}
25
+ export function isFreeEditRow(curRow, rowIndex) {
26
+ return (curRow === null || curRow === void 0 ? void 0 : curRow.toString().split(',').indexOf("".concat(rowIndex))) > -1;
27
+ }
28
+ export function isFreeEditCell(editCellKey, dataIndex, rowIndex) {
29
+ return (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.dataIndex) === dataIndex && (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.rowIndex) === rowIndex;
30
+ }
31
+ export function removeCurKeyFromEditRow(editRowKey, curKey) {
32
+ var keys = editRowKey.toString().split(',');
33
+ var res = [];
34
+ keys.forEach(function (v) {
35
+ if (parseInt(v) > curKey) {
36
+ res.push(parseInt(v) - 1);
37
+ } else if (v !== "".concat(curKey)) {
38
+ res.push(v);
39
+ }
40
+ });
41
+ return res.toString();
42
+ }
@@ -5,6 +5,7 @@ interface IMetaPropsEditProps {
5
5
  metadataTag?: string;
6
6
  name: string;
7
7
  isEdit?: boolean;
8
+ isAddFields?: boolean;
8
9
  onAddFields?: (idx: number) => void;
9
10
  onNewRefClick?: () => void;
10
11
  }
@@ -23,6 +23,8 @@ var MetaPropsEdit = function MetaPropsEdit(props) {
23
23
  id = props.id,
24
24
  metadataTag = props.metadataTag,
25
25
  name = props.name,
26
+ _props$isAddFields = props.isAddFields,
27
+ isAddFields = _props$isAddFields === void 0 ? true : _props$isAddFields,
26
28
  onAddFields = props.onAddFields,
27
29
  onNewRefClick = props.onNewRefClick;
28
30
 
@@ -320,7 +322,7 @@ var MetaPropsEdit = function MetaPropsEdit(props) {
320
322
  },
321
323
  block: true,
322
324
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
323
- }, "\u6DFB\u52A0".concat(name, "\u540D\u79F0"))), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
325
+ }, "\u6DFB\u52A0".concat(name, "\u540D\u79F0"))), isAddFields && /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
324
326
  type: "dashed",
325
327
  onClick: function onClick() {
326
328
  onAddFields(-1);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.0.43",
4
+ "version": "1.0.46",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",