@nokecy/qc-ui-components 2.0.0-beta.3 → 2.0.0-beta.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.
@@ -128,8 +128,11 @@ var ArrayTableInner = (0, _formilyReact.observer)(function (props) {
128
128
  var _useFeedbackRows = (0, _rowFeedback.useFeedbackRows)(field, _formilyAntd.FormLayout.useFormLayout().feedbackLayout),
129
129
  feedbackRowsRef = _useFeedbackRows.rowsRef,
130
130
  feedbackSignature = _useFeedbackRows.signature;
131
+ // 修复:用行下标(node.rowIndex)判定出错行,而非 rowData 对象引用。
132
+ // formily observable 数组 slice 后,getRowHeight 拿到的 rowData 元素与 useFeedbackRows 里取到的表单值元素不是同一引用,
133
+ // 用对象引用 has() 会恒为 false,导致出错行不撑高、校验浮层溢出遮挡下一行/合计行。@author nokecy
131
134
  var getRowHeight = (0, _react.useCallback)(function (params) {
132
- return params.data && feedbackRowsRef.current.has(params.data) ? rowHeight + _rowFeedback.ROW_FEEDBACK_EXTRA_HEIGHT : rowHeight;
135
+ return params.node != null && feedbackRowsRef.current.has(params.node.rowIndex) ? rowHeight + _rowFeedback.ROW_FEEDBACK_EXTRA_HEIGHT : rowHeight;
133
136
  }, [rowHeight]);
134
137
  var isAutoHeight = height === 'auto';
135
138
  var autoGridHeight = isAutoHeight ? (0, _autoHeight.calcAutoGridHeight)({
@@ -13,6 +13,13 @@ export declare const ROW_FEEDBACK_EXTRA_HEIGHT = 24;
13
13
  * 渲染期读它会让组件订阅字段表,每创建一个字段就重渲一次。请用 useFeedbackRows。@author nokecy
14
14
  */
15
15
  export declare const collectFeedbackRows: (arrayField: ArrayField, defaultLayout?: string) => Set<object>;
16
+ /**
17
+ * 与 collectFeedbackRows 同源,但返回「有行内错误文字的行的下标」(Set<number>) 而非行对象引用。
18
+ * 渲染期之外读反馈会订阅整张字段表(见 collectFeedbackRows),这里只供 useFeedbackRows 在事件驱动后重算。
19
+ * 用下标而非对象引用,是为了避开 formily observable 数组 slice 后元素引用不一致导致撑高判空的问题
20
+ * (getRowHeight 拿到的 rowData 元素与这里取到的不是同一引用)。@author nokecy
21
+ */
22
+ export declare const collectFeedbackIndexes: (arrayField: ArrayField, defaultLayout?: string) => Set<number>;
16
23
  /**
17
24
  * 订阅数组下字段的校验反馈,返回「有行内错误文字的行」。
18
25
  *
@@ -21,6 +28,6 @@ export declare const collectFeedbackRows: (arrayField: ArrayField, defaultLayout
21
28
  * signature(有错误的行下标)变化时调用方让网格重算行高。@author nokecy
22
29
  */
23
30
  export declare const useFeedbackRows: (arrayField: ArrayField, defaultLayout?: string) => {
24
- rowsRef: import("react").RefObject<Set<object>>;
31
+ rowsRef: import("react").RefObject<Set<number>>;
25
32
  signature: string;
26
33
  };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useFeedbackRows = exports.collectFeedbackRows = exports.ROW_FEEDBACK_EXTRA_HEIGHT = void 0;
6
+ exports.useFeedbackRows = exports.collectFeedbackRows = exports.collectFeedbackIndexes = exports.ROW_FEEDBACK_EXTRA_HEIGHT = void 0;
7
7
  var _react = require("react");
8
8
  var _formilyCore = require("@nokecy/formily-core");
9
9
  var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
@@ -63,6 +63,42 @@ var collectFeedbackRows = exports.collectFeedbackRows = function collectFeedback
63
63
  return rows;
64
64
  };
65
65
 
66
+ /**
67
+ * 与 collectFeedbackRows 同源,但返回「有行内错误文字的行的下标」(Set<number>) 而非行对象引用。
68
+ * 渲染期之外读反馈会订阅整张字段表(见 collectFeedbackRows),这里只供 useFeedbackRows 在事件驱动后重算。
69
+ * 用下标而非对象引用,是为了避开 formily observable 数组 slice 后元素引用不一致导致撑高判空的问题
70
+ * (getRowHeight 拿到的 rowData 元素与这里取到的不是同一引用)。@author nokecy
71
+ */
72
+ var collectFeedbackIndexes = exports.collectFeedbackIndexes = function collectFeedbackIndexes(arrayField, defaultLayout) {
73
+ var indexes = new Set();
74
+ var form = arrayField === null || arrayField === void 0 ? void 0 : arrayField.form;
75
+ var value = arrayField === null || arrayField === void 0 ? void 0 : arrayField.value;
76
+ if (!form || !Array.isArray(value)) return indexes;
77
+ var base = arrayField.address.toString();
78
+ var baseLength = arrayField.path.length;
79
+ var _iterator2 = _createForOfIteratorHelper(form.queryFeedbacks({
80
+ type: 'error',
81
+ address: "".concat(base, ".*")
82
+ })),
83
+ _step2;
84
+ try {
85
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
86
+ var _feedback$path$segmen2, _feedback$path4, _feedback$path5, _feedback$path5$toStr, _feedback$path6, _form$query$take$deco2, _form$query$take2;
87
+ var feedback = _step2.value;
88
+ var index = Number((_feedback$path$segmen2 = (_feedback$path4 = feedback.path) === null || _feedback$path4 === void 0 || (_feedback$path4 = _feedback$path4.segments) === null || _feedback$path4 === void 0 ? void 0 : _feedback$path4[baseLength]) !== null && _feedback$path$segmen2 !== void 0 ? _feedback$path$segmen2 : (_feedback$path5 = feedback.path) === null || _feedback$path5 === void 0 || (_feedback$path5$toStr = (_feedback$path6 = _feedback$path5).toString) === null || _feedback$path5$toStr === void 0 ? void 0 : _feedback$path5$toStr.call(_feedback$path6).split('.')[baseLength]);
89
+ if (!Number.isInteger(index)) continue;
90
+ var layout = (_form$query$take$deco2 = (_form$query$take2 = form.query(feedback.address).take()) === null || _form$query$take2 === void 0 || (_form$query$take2 = _form$query$take2.decoratorProps) === null || _form$query$take2 === void 0 ? void 0 : _form$query$take2.feedbackLayout) !== null && _form$query$take$deco2 !== void 0 ? _form$query$take$deco2 : defaultLayout;
91
+ if (OUT_OF_FLOW_LAYOUTS.has(layout)) continue;
92
+ indexes.add(index);
93
+ }
94
+ } catch (err) {
95
+ _iterator2.e(err);
96
+ } finally {
97
+ _iterator2.f();
98
+ }
99
+ return indexes;
100
+ };
101
+
66
102
  /**
67
103
  * 订阅数组下字段的校验反馈,返回「有行内错误文字的行」。
68
104
  *
@@ -86,11 +122,13 @@ var useFeedbackRows = exports.useFeedbackRows = function useFeedbackRows(arrayFi
86
122
  if (timer !== undefined) clearTimeout(timer);
87
123
  timer = setTimeout(function () {
88
124
  timer = undefined;
89
- var rows = collectFeedbackRows(arrayField, defaultLayout);
90
- rowsRef.current = rows;
125
+ // 用下标集合(而非对象引用)判定出错行:formily observable 数组 slice 后,rowData 元素与表单值元素引用不一致,
126
+ // 以对象引用做 has 判定会落空,导致出错行不撑高、校验浮层溢出遮挡下一行。@author nokecy
127
+ var indexes = collectFeedbackIndexes(arrayField, defaultLayout);
128
+ rowsRef.current = indexes;
91
129
  var value = Array.isArray(arrayField.value) ? arrayField.value : [];
92
- var next = value.flatMap(function (row, index) {
93
- return rows.has(row) ? [index] : [];
130
+ var next = value.flatMap(function (_, index) {
131
+ return indexes.has(index) ? [index] : [];
94
132
  }).join(',');
95
133
  setSignature(function (prev) {
96
134
  return prev === next ? prev : next;
@@ -127,8 +127,11 @@ var ArrayTableInner = observer(function (props) {
127
127
  var _useFeedbackRows = useFeedbackRows(field, FormLayout.useFormLayout().feedbackLayout),
128
128
  feedbackRowsRef = _useFeedbackRows.rowsRef,
129
129
  feedbackSignature = _useFeedbackRows.signature;
130
+ // 修复:用行下标(node.rowIndex)判定出错行,而非 rowData 对象引用。
131
+ // formily observable 数组 slice 后,getRowHeight 拿到的 rowData 元素与 useFeedbackRows 里取到的表单值元素不是同一引用,
132
+ // 用对象引用 has() 会恒为 false,导致出错行不撑高、校验浮层溢出遮挡下一行/合计行。@author nokecy
130
133
  var getRowHeight = useCallback(function (params) {
131
- return params.data && feedbackRowsRef.current.has(params.data) ? rowHeight + ROW_FEEDBACK_EXTRA_HEIGHT : rowHeight;
134
+ return params.node != null && feedbackRowsRef.current.has(params.node.rowIndex) ? rowHeight + ROW_FEEDBACK_EXTRA_HEIGHT : rowHeight;
132
135
  }, [rowHeight]);
133
136
  var isAutoHeight = height === 'auto';
134
137
  var autoGridHeight = isAutoHeight ? calcAutoGridHeight({
@@ -13,6 +13,13 @@ export declare const ROW_FEEDBACK_EXTRA_HEIGHT = 24;
13
13
  * 渲染期读它会让组件订阅字段表,每创建一个字段就重渲一次。请用 useFeedbackRows。@author nokecy
14
14
  */
15
15
  export declare const collectFeedbackRows: (arrayField: ArrayField, defaultLayout?: string) => Set<object>;
16
+ /**
17
+ * 与 collectFeedbackRows 同源,但返回「有行内错误文字的行的下标」(Set<number>) 而非行对象引用。
18
+ * 渲染期之外读反馈会订阅整张字段表(见 collectFeedbackRows),这里只供 useFeedbackRows 在事件驱动后重算。
19
+ * 用下标而非对象引用,是为了避开 formily observable 数组 slice 后元素引用不一致导致撑高判空的问题
20
+ * (getRowHeight 拿到的 rowData 元素与这里取到的不是同一引用)。@author nokecy
21
+ */
22
+ export declare const collectFeedbackIndexes: (arrayField: ArrayField, defaultLayout?: string) => Set<number>;
16
23
  /**
17
24
  * 订阅数组下字段的校验反馈,返回「有行内错误文字的行」。
18
25
  *
@@ -21,6 +28,6 @@ export declare const collectFeedbackRows: (arrayField: ArrayField, defaultLayout
21
28
  * signature(有错误的行下标)变化时调用方让网格重算行高。@author nokecy
22
29
  */
23
30
  export declare const useFeedbackRows: (arrayField: ArrayField, defaultLayout?: string) => {
24
- rowsRef: import("react").RefObject<Set<object>>;
31
+ rowsRef: import("react").RefObject<Set<number>>;
25
32
  signature: string;
26
33
  };
@@ -57,6 +57,42 @@ export var collectFeedbackRows = function collectFeedbackRows(arrayField, defaul
57
57
  return rows;
58
58
  };
59
59
 
60
+ /**
61
+ * 与 collectFeedbackRows 同源,但返回「有行内错误文字的行的下标」(Set<number>) 而非行对象引用。
62
+ * 渲染期之外读反馈会订阅整张字段表(见 collectFeedbackRows),这里只供 useFeedbackRows 在事件驱动后重算。
63
+ * 用下标而非对象引用,是为了避开 formily observable 数组 slice 后元素引用不一致导致撑高判空的问题
64
+ * (getRowHeight 拿到的 rowData 元素与这里取到的不是同一引用)。@author nokecy
65
+ */
66
+ export var collectFeedbackIndexes = function collectFeedbackIndexes(arrayField, defaultLayout) {
67
+ var indexes = new Set();
68
+ var form = arrayField === null || arrayField === void 0 ? void 0 : arrayField.form;
69
+ var value = arrayField === null || arrayField === void 0 ? void 0 : arrayField.value;
70
+ if (!form || !Array.isArray(value)) return indexes;
71
+ var base = arrayField.address.toString();
72
+ var baseLength = arrayField.path.length;
73
+ var _iterator2 = _createForOfIteratorHelper(form.queryFeedbacks({
74
+ type: 'error',
75
+ address: "".concat(base, ".*")
76
+ })),
77
+ _step2;
78
+ try {
79
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
80
+ var _feedback$path$segmen2, _feedback$path4, _feedback$path5, _feedback$path5$toStr, _feedback$path6, _form$query$take$deco2, _form$query$take2;
81
+ var feedback = _step2.value;
82
+ var index = Number((_feedback$path$segmen2 = (_feedback$path4 = feedback.path) === null || _feedback$path4 === void 0 || (_feedback$path4 = _feedback$path4.segments) === null || _feedback$path4 === void 0 ? void 0 : _feedback$path4[baseLength]) !== null && _feedback$path$segmen2 !== void 0 ? _feedback$path$segmen2 : (_feedback$path5 = feedback.path) === null || _feedback$path5 === void 0 || (_feedback$path5$toStr = (_feedback$path6 = _feedback$path5).toString) === null || _feedback$path5$toStr === void 0 ? void 0 : _feedback$path5$toStr.call(_feedback$path6).split('.')[baseLength]);
83
+ if (!Number.isInteger(index)) continue;
84
+ var layout = (_form$query$take$deco2 = (_form$query$take2 = form.query(feedback.address).take()) === null || _form$query$take2 === void 0 || (_form$query$take2 = _form$query$take2.decoratorProps) === null || _form$query$take2 === void 0 ? void 0 : _form$query$take2.feedbackLayout) !== null && _form$query$take$deco2 !== void 0 ? _form$query$take$deco2 : defaultLayout;
85
+ if (OUT_OF_FLOW_LAYOUTS.has(layout)) continue;
86
+ indexes.add(index);
87
+ }
88
+ } catch (err) {
89
+ _iterator2.e(err);
90
+ } finally {
91
+ _iterator2.f();
92
+ }
93
+ return indexes;
94
+ };
95
+
60
96
  /**
61
97
  * 订阅数组下字段的校验反馈,返回「有行内错误文字的行」。
62
98
  *
@@ -80,11 +116,13 @@ export var useFeedbackRows = function useFeedbackRows(arrayField, defaultLayout)
80
116
  if (timer !== undefined) clearTimeout(timer);
81
117
  timer = setTimeout(function () {
82
118
  timer = undefined;
83
- var rows = collectFeedbackRows(arrayField, defaultLayout);
84
- rowsRef.current = rows;
119
+ // 用下标集合(而非对象引用)判定出错行:formily observable 数组 slice 后,rowData 元素与表单值元素引用不一致,
120
+ // 以对象引用做 has 判定会落空,导致出错行不撑高、校验浮层溢出遮挡下一行。@author nokecy
121
+ var indexes = collectFeedbackIndexes(arrayField, defaultLayout);
122
+ rowsRef.current = indexes;
85
123
  var value = Array.isArray(arrayField.value) ? arrayField.value : [];
86
- var next = value.flatMap(function (row, index) {
87
- return rows.has(row) ? [index] : [];
124
+ var next = value.flatMap(function (_, index) {
125
+ return indexes.has(index) ? [index] : [];
88
126
  }).join(',');
89
127
  setSignature(function (prev) {
90
128
  return prev === next ? prev : next;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nokecy/qc-ui-components",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.4",
4
4
  "description": "QC_UI backend-neutral React components",
5
5
  "license": "MIT",
6
6
  "private": false,