@cloudtower/eagle 490.0.3 → 490.0.5

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.
@@ -3,7 +3,7 @@ import { ColumnBodyImpls } from './Columns/index.js';
3
3
  import { FormItem } from './Columns/FormItem.js';
4
4
  import { ValidateTriggerType } from './types.js';
5
5
  import { Typo } from '../Typo/index.js';
6
- import React__default, { useState, useEffect, useCallback, useMemo } from 'react';
6
+ import React__default, { useState, useCallback, useEffect, useMemo } from 'react';
7
7
 
8
8
  var __defProp = Object.defineProperty;
9
9
  var __defProps = Object.defineProperties;
@@ -36,24 +36,16 @@ const TableFormBodyCell = (props) => {
36
36
  disabled,
37
37
  onChange,
38
38
  onBlur,
39
- validateAll,
39
+ validateAllCount,
40
40
  error,
41
41
  onValidate
42
42
  } = props;
43
43
  const [validateResult, setValidateResult] = useState();
44
44
  const [isTouched, setIsTouched] = useState(false);
45
45
  const width = typeof column.width === "number" ? column.width + "px" : column.width;
46
- const isCellErrorStyle = Boolean((validateResult == null ? void 0 : validateResult.isError) || isRowError);
47
- useEffect(() => {
48
- if (isTouched) {
49
- setValidateResult(
50
- error ? {
51
- msg: error,
52
- isError: true
53
- } : void 0
54
- );
55
- }
56
- }, [error, isTouched]);
46
+ const isCellErrorStyle = Boolean(
47
+ isTouched && error || (validateResult == null ? void 0 : validateResult.isError) || isRowError
48
+ );
57
49
  const triggerValidate = useCallback(
58
50
  (currentValue) => {
59
51
  var _a;
@@ -78,11 +70,11 @@ const TableFormBodyCell = (props) => {
78
70
  [data, rowIndex, column, getRowValidateResult, onValidate]
79
71
  );
80
72
  useEffect(() => {
81
- if (validateAll) {
73
+ if (validateAllCount > 0) {
82
74
  setIsTouched(true);
83
75
  triggerValidate();
84
76
  }
85
- }, [validateAll, triggerValidate, setIsTouched]);
77
+ }, [validateAllCount, triggerValidate, setIsTouched]);
86
78
  const _onChange = (value, data2) => {
87
79
  const newData = data2.map(
88
80
  (row, i) => i === rowIndex ? __spreadProps(__spreadValues({}, row), { [column.key]: value }) : row
@@ -156,7 +148,7 @@ const TableFormBodyCell = (props) => {
156
148
  FormItem,
157
149
  {
158
150
  validateStatus: isCellErrorStyle ? "error" : "",
159
- message: isRowError ? "" : validateResult == null ? void 0 : validateResult.msg
151
+ message: isRowError ? "" : (isTouched ? error : void 0) || (validateResult == null ? void 0 : validateResult.msg)
160
152
  },
161
153
  Cell
162
154
  ),
@@ -78,7 +78,7 @@ const TableFormRow = (props) => {
78
78
  updateData,
79
79
  onBodyBlur,
80
80
  renderRowDescription,
81
- validateAll,
81
+ validateAllCount,
82
82
  onValidate
83
83
  } = props;
84
84
  const rowData = data[rowIndex];
@@ -121,7 +121,7 @@ const TableFormRow = (props) => {
121
121
  validateTriggerType,
122
122
  isRowError: !!rowError,
123
123
  getRowValidateResult,
124
- validateAll,
124
+ validateAllCount,
125
125
  error: cellError,
126
126
  onValidate
127
127
  }
@@ -53,7 +53,7 @@ const TableForm = React__default.forwardRef(
53
53
  const [data, setData] = useState(defaultData || []);
54
54
  const [passwordVisible, setPasswordVisible] = useState(false);
55
55
  const [latestData, setLatestData] = useState(defaultData || []);
56
- const [validateAll, setValidateAll] = useState(false);
56
+ const [validateAllCount, setValidateAllCount] = useState(0);
57
57
  const rowSplitType = (row == null ? void 0 : row.splitType) || props.rowSplitType || "border";
58
58
  const draggable = (_b = (_a = row == null ? void 0 : row.draggable) != null ? _a : props.draggable) != null ? _b : false;
59
59
  const formValidMapRef = useRef({});
@@ -116,7 +116,7 @@ const TableForm = React__default.forwardRef(
116
116
  },
117
117
  validateWholeFields() {
118
118
  formValidMapRef.current = {};
119
- setValidateAll(true);
119
+ setValidateAllCount((c) => c + 1);
120
120
  },
121
121
  isValid() {
122
122
  return Object.values(formValidMapRef.current).every(
@@ -183,7 +183,7 @@ const TableForm = React__default.forwardRef(
183
183
  updateData,
184
184
  renderRowDescription,
185
185
  rowValidator,
186
- validateAll,
186
+ validateAllCount,
187
187
  errors,
188
188
  onValidate
189
189
  }