@hzab/list-render 1.10.20 → 1.10.21-alpha.0

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # @hzab/list-render@1.10.21
2
+
3
+ feat: 增加行内编辑表格时,canEditCallback的回调,从外部控制cell是否能编辑,修复原有的hasEdit逻辑
4
+
1
5
  # @hzab/list-render@1.10.20
2
6
 
3
7
  fix: 修复 PaginationRender 的 全部样式
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/list-render",
3
- "version": "1.10.20",
3
+ "version": "1.10.21-alpha.0",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -30,8 +30,9 @@ export interface EditableCellProps extends React.HTMLAttributes<HTMLElement> {
30
30
  onSave: (field: { type: string; name: string }) => void;
31
31
  onCancel: () => void;
32
32
  topProps: {
33
- config: { hasEdit: boolean | Function };
33
+ tableConf: { hasEdit: boolean | Function };
34
34
  editMode: "modal" | "line" | "line-cell" | "cell";
35
+ canEditCallback: (record: Partial<Item> & { key: React.Key }, field: { type: string; name: string }, dataIndex: string) => void;
35
36
  };
36
37
  children: React.ReactNode;
37
38
  }
@@ -56,8 +57,8 @@ export const EditableCell: React.FC<EditableCellProps> = ({
56
57
  const field = getField && getField();
57
58
  const fPattern = field?.["x-pattern"];
58
59
  const fDisplay = field?.["x-display"];
59
- const { editMode = "modal" } = topProps || {};
60
- const { hasEdit } = topProps?.config || {};
60
+ const { editMode = "modal", canEditCallback } = topProps || {};
61
+ const { hasEdit } = topProps?.tableConf || {};
61
62
  const fieldRef = useRef();
62
63
 
63
64
  // 弹窗编辑模式
@@ -66,7 +67,11 @@ export const EditableCell: React.FC<EditableCellProps> = ({
66
67
  }
67
68
  // 无编辑权限或禁止编辑
68
69
  const _hasEdit = hasEdit && typeof hasEdit === "function" ? hasEdit(record, index) : hasEdit !== false;
69
- let _editable = _hasEdit && editable && !(fPattern === "disabled" || fPattern === "readOnly" || fDisplay === "none");
70
+ let _editable =
71
+ _hasEdit &&
72
+ editable &&
73
+ !(fPattern === "disabled" || fPattern === "readOnly" || fDisplay === "none") &&
74
+ (canEditCallback ? canEditCallback(record, field, dataIndex) : true);
70
75
  if (!_editable) {
71
76
  return <td {...restProps}>{children}</td>;
72
77
  }