@cloudtower/eagle 490.0.3 → 490.0.4

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.
@@ -42,24 +42,16 @@ const TableFormBodyCell = (props) => {
42
42
  disabled,
43
43
  onChange,
44
44
  onBlur,
45
- validateAll,
45
+ validateAllCount,
46
46
  error,
47
47
  onValidate
48
48
  } = props;
49
49
  const [validateResult, setValidateResult] = React.useState();
50
50
  const [isTouched, setIsTouched] = React.useState(false);
51
51
  const width = typeof column.width === "number" ? column.width + "px" : column.width;
52
- const isCellErrorStyle = Boolean((validateResult == null ? void 0 : validateResult.isError) || isRowError);
53
- React.useEffect(() => {
54
- if (isTouched) {
55
- setValidateResult(
56
- error ? {
57
- msg: error,
58
- isError: true
59
- } : void 0
60
- );
61
- }
62
- }, [error, isTouched]);
52
+ const isCellErrorStyle = Boolean(
53
+ isTouched && error || (validateResult == null ? void 0 : validateResult.isError) || isRowError
54
+ );
63
55
  const triggerValidate = React.useCallback(
64
56
  (currentValue) => {
65
57
  var _a;
@@ -84,11 +76,11 @@ const TableFormBodyCell = (props) => {
84
76
  [data, rowIndex, column, getRowValidateResult, onValidate]
85
77
  );
86
78
  React.useEffect(() => {
87
- if (validateAll) {
79
+ if (validateAllCount > 0) {
88
80
  setIsTouched(true);
89
81
  triggerValidate();
90
82
  }
91
- }, [validateAll, triggerValidate, setIsTouched]);
83
+ }, [validateAllCount, triggerValidate, setIsTouched]);
92
84
  const _onChange = (value, data2) => {
93
85
  const newData = data2.map(
94
86
  (row, i) => i === rowIndex ? __spreadProps(__spreadValues({}, row), { [column.key]: value }) : row
@@ -162,7 +154,7 @@ const TableFormBodyCell = (props) => {
162
154
  FormItem.FormItem,
163
155
  {
164
156
  validateStatus: isCellErrorStyle ? "error" : "",
165
- message: isRowError ? "" : validateResult == null ? void 0 : validateResult.msg
157
+ message: isRowError ? "" : (isTouched ? error : void 0) || (validateResult == null ? void 0 : validateResult.msg)
166
158
  },
167
159
  Cell
168
160
  ),
@@ -84,7 +84,7 @@ const TableFormRow = (props) => {
84
84
  updateData,
85
85
  onBodyBlur,
86
86
  renderRowDescription,
87
- validateAll,
87
+ validateAllCount,
88
88
  onValidate
89
89
  } = props;
90
90
  const rowData = data[rowIndex];
@@ -127,7 +127,7 @@ const TableFormRow = (props) => {
127
127
  validateTriggerType,
128
128
  isRowError: !!rowError,
129
129
  getRowValidateResult,
130
- validateAll,
130
+ validateAllCount,
131
131
  error: cellError,
132
132
  onValidate
133
133
  }
@@ -61,7 +61,7 @@ const TableForm = React__default.default.forwardRef(
61
61
  const [data, setData] = React.useState(defaultData || []);
62
62
  const [passwordVisible, setPasswordVisible] = React.useState(false);
63
63
  const [latestData, setLatestData] = React.useState(defaultData || []);
64
- const [validateAll, setValidateAll] = React.useState(false);
64
+ const [validateAllCount, setValidateAllCount] = React.useState(0);
65
65
  const rowSplitType = (row == null ? void 0 : row.splitType) || props.rowSplitType || "border";
66
66
  const draggable = (_b = (_a = row == null ? void 0 : row.draggable) != null ? _a : props.draggable) != null ? _b : false;
67
67
  const formValidMapRef = React.useRef({});
@@ -124,7 +124,7 @@ const TableForm = React__default.default.forwardRef(
124
124
  },
125
125
  validateWholeFields() {
126
126
  formValidMapRef.current = {};
127
- setValidateAll(true);
127
+ setValidateAllCount((c) => c + 1);
128
128
  },
129
129
  isValid() {
130
130
  return Object.values(formValidMapRef.current).every(
@@ -191,7 +191,7 @@ const TableForm = React__default.default.forwardRef(
191
191
  updateData,
192
192
  renderRowDescription,
193
193
  rowValidator,
194
- validateAll,
194
+ validateAllCount,
195
195
  errors,
196
196
  onValidate
197
197
  }