ronds-metadata 1.2.54 → 1.2.56

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,11 +6,11 @@ var _excluded = ["title", "isAddColumn", "editable", "record", "editableType", "
6
6
  /*
7
7
  * @Author: wangxian
8
8
  * @Date: 2022-03-04 10:01:10
9
- * @LastEditTime: 2023-03-25 09:01:46
9
+ * @LastEditTime: 2023-05-23 10:17:15
10
10
  */
11
11
  import React from 'react';
12
12
  import { EditableContext } from '../interface';
13
- import { getDataCell, isFreeEditCell, isFreeEditRow } from '../utils';
13
+ import { getDataCell, isCellDisabled, isFreeEditCell, isFreeEditRow } from '../utils';
14
14
  import './index.less';
15
15
  import Texty from './Texty';
16
16
  import { tr } from '../../../framework/locale';
@@ -88,7 +88,7 @@ var EditableCell = function EditableCell(props) {
88
88
  }
89
89
  return /*#__PURE__*/React.createElement("td", _extends({}, restProps, {
90
90
  className: "".concat(className, " ").concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right' : '', " ")
91
- }), editable ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
91
+ }), editable && isCellDisabled(record, restProps === null || restProps === void 0 ? void 0 : restProps.cellDisabled) ? getDataCell(props) : /*#__PURE__*/React.createElement(Texty, {
92
92
  tooltipStyle: {
93
93
  wordWrap: 'break-word'
94
94
  },
@@ -11,7 +11,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
11
  /*
12
12
  * @Author: wangxain
13
13
  * @Date: 2022-03-04 08:53:04
14
- * @LastEditTime: 2023-02-25 11:11:58
14
+ * @LastEditTime: 2023-05-23 09:20:36
15
15
  */
16
16
  import React from 'react';
17
17
  import { pick, isArray } from 'lodash';
@@ -205,7 +205,7 @@ var Editable = function Editable(props) {
205
205
  record: record,
206
206
  editableType: type,
207
207
  isAddColumn: isAddColumn
208
- }, pick(column, ['editable', 'title', 'dataIndex', 'type', 'enum', 'mode', 'disabled'])), {}, {
208
+ }, pick(column, ['editable', 'title', 'dataIndex', 'type', 'enum', 'mode', 'disabled', 'cellDisabled'])), {}, {
209
209
  rowIndex: rowIndex
210
210
  });
211
211
  };
@@ -5,6 +5,7 @@ export interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
5
5
  title: any;
6
6
  editable: boolean;
7
7
  disabled?: boolean;
8
+ cellDisabled?: string;
8
9
  dataIndex: string;
9
10
  isAddColumn: boolean;
10
11
  rowIndex: number;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2022-03-04 15:07:57
4
- * @LastEditTime: 2023-01-04 10:38:53
4
+ * @LastEditTime: 2023-05-23 09:16:25
5
5
  */
6
6
  import React from 'react';
7
7
  export var EditableContext = /*#__PURE__*/React.createContext(null);
@@ -2,4 +2,5 @@ import { EditableCellProps } from './interface';
2
2
  export declare function getDataCell(item: EditableCellProps): JSX.Element;
3
3
  export declare function isFreeEditRow(curRow: any, rowIndex: number): boolean;
4
4
  export declare function isFreeEditCell(editCellKey: any, dataIndex: string, rowIndex: number): boolean;
5
+ export declare function isCellDisabled(record: any, cellDisabled?: string): boolean;
5
6
  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-07-07 08:35:35
4
+ * @LastEditTime: 2023-05-23 10:33:54
5
5
  */
6
6
  import React from 'react';
7
7
  import Input from './DataCell/Input';
@@ -31,6 +31,30 @@ export function isFreeEditRow(curRow, rowIndex) {
31
31
  export function isFreeEditCell(editCellKey, dataIndex, rowIndex) {
32
32
  return (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.dataIndex) === dataIndex && (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.rowIndex) === rowIndex;
33
33
  }
34
+ export function isCellDisabled(record, cellDisabled) {
35
+ if (cellDisabled) {
36
+ var regex = /\w+(\.\w+)?[=<>!]{1}|\w+(\.\w+)?(\.indexOf\('.+'\)[=<>!]{1})/g;
37
+ var keys = cellDisabled.trim().match(regex);
38
+ if (!keys) {
39
+ return true;
40
+ }
41
+ var expression = cellDisabled;
42
+ for (var i = 0; i < keys.length; i++) {
43
+ var key = keys[i].substring(0, keys[i].length - 1);
44
+ // 处理.length 之类的状况
45
+ var _key = key.split('.');
46
+ var _changeData = record[_key[0]];
47
+ if (_changeData || _changeData === 0) {
48
+ var r = key === _key[0] ? "'".concat(_changeData, "'") : eval("_changeData.".concat(_key[1]));
49
+ expression = expression.replace(key, r);
50
+ } else {
51
+ expression = expression.replace(key, undefined);
52
+ }
53
+ }
54
+ return !eval(expression);
55
+ }
56
+ return true;
57
+ }
34
58
  export function removeCurKeyFromEditRow(editRowKey, curKey) {
35
59
  var keys = editRowKey.toString().split(',');
36
60
  var res = [];
@@ -37,7 +37,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
37
37
  /*
38
38
  * @Author:wangxian
39
39
  * @Date: 2021-09-18 14:15:04
40
- * @LastEditTime: 2023-05-18 16:47:45
40
+ * @LastEditTime: 2023-05-18 17:18:32
41
41
  */
42
42
  import React from 'react';
43
43
  import { MetadataFormContext, MetadataRefContext } from '../interface';
@@ -91,7 +91,7 @@ function Index(props) {
91
91
  _React$useState12 = _slicedToArray(_React$useState11, 2),
92
92
  expandedKeys = _React$useState12[0],
93
93
  setExpandedKeys = _React$useState12[1];
94
- var firstLoadTreeSelectRef = React.useRef(true);
94
+ var firstLoadTreeSelectRef = React.useRef(false);
95
95
  var pageRef = React.useRef(1);
96
96
  var totalRef = React.useRef();
97
97
  var onSelect = function onSelect(value) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.2.54",
4
+ "version": "1.2.56",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",