@zat-design/sisyphus-react 4.1.3-beta.2 → 4.1.3-beta.3
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/es/ProEditTable/components/RcTable/BaseTable.js +2 -1
- package/es/ProEditTable/components/RcTable/DraggableTable.js +2 -1
- package/es/ProEditTable/components/RenderField/index.js +40 -8
- package/es/ProEditTable/index.js +4 -2
- package/es/ProEditTable/utils/tools.d.ts +7 -0
- package/es/ProEditTable/utils/tools.js +17 -0
- package/es/ProForm/components/combination/FormList/index.js +6 -2
- package/lib/ProEditTable/components/RcTable/BaseTable.js +2 -1
- package/lib/ProEditTable/components/RcTable/DraggableTable.js +2 -1
- package/lib/ProEditTable/components/RenderField/index.js +40 -8
- package/lib/ProEditTable/index.js +3 -1
- package/lib/ProEditTable/utils/tools.d.ts +7 -0
- package/lib/ProEditTable/utils/tools.js +20 -1
- package/lib/ProForm/components/combination/FormList/index.js +6 -2
- package/package.json +1 -1
|
@@ -24,6 +24,7 @@ var BaseTable = _ref => {
|
|
|
24
24
|
var tableProps = _ref.tableProps,
|
|
25
25
|
resetProps = _objectWithoutProperties(_ref, _excluded);
|
|
26
26
|
var rowKey = tableProps.rowKey,
|
|
27
|
+
tableRowKey = tableProps.tableRowKey,
|
|
27
28
|
value = tableProps.value,
|
|
28
29
|
headerRender = tableProps.headerRender,
|
|
29
30
|
tableRef = tableProps.tableRef,
|
|
@@ -78,7 +79,7 @@ var BaseTable = _ref => {
|
|
|
78
79
|
onClick: () => {}
|
|
79
80
|
})
|
|
80
81
|
}, resetProps), {}, {
|
|
81
|
-
rowKey:
|
|
82
|
+
rowKey: tableRowKey,
|
|
82
83
|
summary,
|
|
83
84
|
pagination: pagination ? _objectSpread(_objectSpread({
|
|
84
85
|
showSizeChanger: true,
|
|
@@ -117,6 +117,7 @@ var DraggableTable = _ref3 => {
|
|
|
117
117
|
draggableProps = _ref3.draggableProps,
|
|
118
118
|
resetProps = _objectWithoutProperties(_ref3, _excluded2);
|
|
119
119
|
var rowKey = tableProps.rowKey,
|
|
120
|
+
tableRowKey = tableProps.tableRowKey,
|
|
120
121
|
value = tableProps.value,
|
|
121
122
|
headerRender = tableProps.headerRender,
|
|
122
123
|
tableRef = tableProps.tableRef,
|
|
@@ -173,7 +174,7 @@ var DraggableTable = _ref3 => {
|
|
|
173
174
|
}),
|
|
174
175
|
dataSource: value !== null && value !== void 0 && (_value$2 = value[0]) !== null && _value$2 !== void 0 && _value$2.rowKey ? value : []
|
|
175
176
|
}, resetProps), {}, {
|
|
176
|
-
rowKey:
|
|
177
|
+
rowKey: tableRowKey,
|
|
177
178
|
pagination: pagination ? _objectSpread({
|
|
178
179
|
current: page.pageNum,
|
|
179
180
|
pageSize: page.pageSize,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "onDiff", "className", "trim", "confirm", "dependencies", "desensitization"];
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
2
8
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
9
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
10
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -37,7 +43,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
37
43
|
var OMIT_FORM_ITEM_AND_DOM_KEYS = ['format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames', 'shouldCellUpdate' // 表格内部性能优化属性,不应传递给 Form.Item
|
|
38
44
|
];
|
|
39
45
|
var RenderField = _ref => {
|
|
40
|
-
var _type, _type$replace, _fieldProps2, _fieldProps4, _names, _TargetComponent5,
|
|
46
|
+
var _type, _type$replace, _fieldProps2, _fieldProps4, _names, _TargetComponent5, _componentProps3;
|
|
41
47
|
var value = _ref.text,
|
|
42
48
|
record = _ref.record,
|
|
43
49
|
index = _ref.index,
|
|
@@ -252,7 +258,7 @@ var RenderField = _ref => {
|
|
|
252
258
|
// required 是函数
|
|
253
259
|
isFunction(rules) ||
|
|
254
260
|
// rules 是函数
|
|
255
|
-
isFunction(isEditable) ||
|
|
261
|
+
isFunction(column === null || column === void 0 ? void 0 : column.isEditable) ||
|
|
256
262
|
// isEditable 是函数
|
|
257
263
|
isFunction(component) ||
|
|
258
264
|
// component 是函数
|
|
@@ -763,6 +769,8 @@ var RenderField = _ref => {
|
|
|
763
769
|
var shouldUpdateMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
764
770
|
// 如果处于 shouldUpdate 模式,需要重新获取最新的行数据并重新计算依赖值
|
|
765
771
|
var finalComponentProps = componentProps;
|
|
772
|
+
// shouldUpdate 模式下会被更新为最新值,供外层 FieldProvider 消费
|
|
773
|
+
var latestIsView = isView;
|
|
766
774
|
if (shouldUpdateMode) {
|
|
767
775
|
var _column$isEditable2;
|
|
768
776
|
// 重新获取最新的行数据(shouldUpdate 触发时,通过 getFieldValue 拿到最新值)
|
|
@@ -841,7 +849,7 @@ var RenderField = _ref => {
|
|
|
841
849
|
}
|
|
842
850
|
|
|
843
851
|
// 然后处理自定义 component
|
|
844
|
-
|
|
852
|
+
latestIsView = !latestIsEditable || (record === null || record === void 0 ? void 0 : record['is-view']) || config.isView || virtualKey && !_isEditing || getDisabled({
|
|
845
853
|
globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
|
|
846
854
|
formDisabled: otherProps === null || otherProps === void 0 ? void 0 : otherProps.formDisabled,
|
|
847
855
|
column,
|
|
@@ -876,6 +884,13 @@ var RenderField = _ref => {
|
|
|
876
884
|
// 使用重新计算的 TargetComponent
|
|
877
885
|
TargetComponent = latestTargetComponent;
|
|
878
886
|
|
|
887
|
+
// shouldUpdate 触发时外层 componentProps.otherProps.isView 是旧快照,需用最新值覆盖
|
|
888
|
+
finalComponentProps = _objectSpread(_objectSpread({}, finalComponentProps), {}, {
|
|
889
|
+
otherProps: _objectSpread(_objectSpread({}, finalComponentProps.otherProps), {}, {
|
|
890
|
+
isView: latestIsView
|
|
891
|
+
})
|
|
892
|
+
});
|
|
893
|
+
|
|
879
894
|
// componentProps 里展开了外层旧 TargetComponent?.props(如 { formType: "Input" }),
|
|
880
895
|
// 用 latestTargetComponent?.props 覆盖,确保不会被旧 cloneElement props 污染
|
|
881
896
|
if ( /*#__PURE__*/React.isValidElement(latestTargetComponent)) {
|
|
@@ -957,15 +972,32 @@ var RenderField = _ref => {
|
|
|
957
972
|
}))
|
|
958
973
|
}));
|
|
959
974
|
}
|
|
960
|
-
|
|
975
|
+
// shouldUpdateMode 返回元组,将 latestIsView 暴露给外层用于更新 FieldProvider context
|
|
976
|
+
return shouldUpdateMode ? [FormItem, latestIsView] : FormItem;
|
|
961
977
|
};
|
|
962
|
-
return /*#__PURE__*/_jsx(
|
|
963
|
-
value: ((_componentProps2 = componentProps) === null || _componentProps2 === void 0 ? void 0 : _componentProps2.otherProps) || {},
|
|
978
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
964
979
|
children: finalFormItemProps.shouldUpdate ? /*#__PURE__*/_jsx(Form.Item, {
|
|
965
980
|
noStyle: true,
|
|
966
981
|
shouldUpdate: finalFormItemProps.shouldUpdate,
|
|
967
|
-
children: () =>
|
|
968
|
-
|
|
982
|
+
children: () => {
|
|
983
|
+
var _componentProps2;
|
|
984
|
+
// shouldUpdate 触发时外层组件可能因 memo 未重渲染,FieldProvider context 是旧快照
|
|
985
|
+
// 从 getFieldItem(true) 的元组返回值获取 latestIsView,更新 context 确保 Input 组件读到最新 isView
|
|
986
|
+
var _ref5 = getFieldItem(true),
|
|
987
|
+
_ref6 = _slicedToArray(_ref5, 2),
|
|
988
|
+
formItem = _ref6[0],
|
|
989
|
+
latestIsView = _ref6[1];
|
|
990
|
+
return /*#__PURE__*/_jsx(FieldProvider, {
|
|
991
|
+
value: _objectSpread(_objectSpread({}, (_componentProps2 = componentProps) === null || _componentProps2 === void 0 ? void 0 : _componentProps2.otherProps), {}, {
|
|
992
|
+
isView: latestIsView
|
|
993
|
+
}),
|
|
994
|
+
children: formItem
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
}) : /*#__PURE__*/_jsx(FieldProvider, {
|
|
998
|
+
value: ((_componentProps3 = componentProps) === null || _componentProps3 === void 0 ? void 0 : _componentProps3.otherProps) || {},
|
|
999
|
+
children: getFieldItem()
|
|
1000
|
+
})
|
|
969
1001
|
});
|
|
970
1002
|
};
|
|
971
1003
|
export default /*#__PURE__*/memo(RenderField, (prevProps, nextProps) => {
|
package/es/ProEditTable/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import { useLocalStorageState, useSetState } from 'ahooks';
|
|
|
22
22
|
import { ConfigProvider, Form, Affix } from 'antd';
|
|
23
23
|
import classnames from 'classnames';
|
|
24
24
|
import { transformColumns } from "./utils";
|
|
25
|
-
import { getRandom, getNamePath, handleScrollToError, onPageCheck } from "./utils/tools";
|
|
25
|
+
import { getRandom, getNamePath, handleScrollToError, onPageCheck, buildTableRowKey } from "./utils/tools";
|
|
26
26
|
import { Validator, Summary, RenderToolbar } from "./components";
|
|
27
27
|
import ProForm from "../ProForm";
|
|
28
28
|
import Empty from "../assets/empty.png";
|
|
@@ -436,8 +436,10 @@ var ProEditTable = (_ref, ref) => {
|
|
|
436
436
|
_dragIndex: idx
|
|
437
437
|
} : {}));
|
|
438
438
|
}, [value, virtualKey, editingKeys, draggable]);
|
|
439
|
+
var tableRowKey = useMemo(() => buildTableRowKey(rowKey), [rowKey]);
|
|
439
440
|
var tableProps = useMemo(() => ({
|
|
440
441
|
rowKey,
|
|
442
|
+
tableRowKey,
|
|
441
443
|
value: enrichedValue,
|
|
442
444
|
headerRender,
|
|
443
445
|
tableRef,
|
|
@@ -457,7 +459,7 @@ var ProEditTable = (_ref, ref) => {
|
|
|
457
459
|
formatMessage,
|
|
458
460
|
locale,
|
|
459
461
|
handlePageChange
|
|
460
|
-
}), [_className, _columns, _rowClassName, disabled, editingKeys, formatMessage, handlePageChange, headerRender, isHideCheckBox, locale, page, pagination, renderRowSelection, rowDraggable, rowKey, scroll, _summary, tableRef, enrichedValue, virtualKey]);
|
|
462
|
+
}), [_className, _columns, _rowClassName, disabled, editingKeys, formatMessage, handlePageChange, headerRender, isHideCheckBox, locale, page, pagination, renderRowSelection, rowDraggable, rowKey, tableRowKey, scroll, _summary, tableRef, enrichedValue, virtualKey]);
|
|
461
463
|
|
|
462
464
|
// 拖拽排序后,enrichedValue 中含 _dragIndex(内部字段),需清除后再传给外部 onChange
|
|
463
465
|
var handleDragChange = useCallback(newValue => {
|
|
@@ -6,6 +6,13 @@ import { NamePath } from 'antd/es/form/interface';
|
|
|
6
6
|
* @returns 随机字符串
|
|
7
7
|
*/
|
|
8
8
|
export declare const getRandom: () => string;
|
|
9
|
+
/**
|
|
10
|
+
* 构建 AntD Table 的 rowKey 函数,支持字符串/函数两种形式,
|
|
11
|
+
* 当用户指定字段值无效时(新增行尚未填写业务 key),自动降级到内部 record.rowKey。
|
|
12
|
+
* @param rowKey 用户传入的 rowKey prop
|
|
13
|
+
* @returns AntD Table 可用的 rowKey 字符串或函数
|
|
14
|
+
*/
|
|
15
|
+
export declare const buildTableRowKey: (rowKey?: string | number | symbol | ((record: any) => any)) => (record: any) => string;
|
|
9
16
|
/**
|
|
10
17
|
* 深层次对比两个对象且取出来差异值
|
|
11
18
|
* @param object 比较对象
|
|
@@ -21,6 +21,23 @@ export var getRandom = () => {
|
|
|
21
21
|
return Math.random().toString(36).slice(-6);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* 构建 AntD Table 的 rowKey 函数,支持字符串/函数两种形式,
|
|
26
|
+
* 当用户指定字段值无效时(新增行尚未填写业务 key),自动降级到内部 record.rowKey。
|
|
27
|
+
* @param rowKey 用户传入的 rowKey prop
|
|
28
|
+
* @returns AntD Table 可用的 rowKey 字符串或函数
|
|
29
|
+
*/
|
|
30
|
+
export var buildTableRowKey = rowKey => {
|
|
31
|
+
return record => {
|
|
32
|
+
if (!rowKey) return String(record.rowKey || '');
|
|
33
|
+
var userKey = typeof rowKey === 'function' ? rowKey(record) : record[rowKey];
|
|
34
|
+
if (userKey != null && !Number.isNaN(userKey) && userKey !== '') {
|
|
35
|
+
return String(userKey);
|
|
36
|
+
}
|
|
37
|
+
return String(record.rowKey || '');
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
24
41
|
/**
|
|
25
42
|
* 深层次对比两个对象且取出来差异值
|
|
26
43
|
* @param object 比较对象
|
|
@@ -43,11 +43,15 @@ var FormList = (props, ref) => {
|
|
|
43
43
|
name = _ref.name,
|
|
44
44
|
isView = _ref.isView,
|
|
45
45
|
diffConfig = _ref.diffConfig,
|
|
46
|
-
namePath = _ref.namePath
|
|
46
|
+
namePath = _ref.namePath,
|
|
47
|
+
source = _ref.source;
|
|
47
48
|
var _useProConfig = useProConfig('ProForm'),
|
|
48
49
|
isDiffAll = _useProConfig.isDiffAll;
|
|
49
50
|
var errors = meta.errors;
|
|
50
|
-
|
|
51
|
+
|
|
52
|
+
// 当 FormList 作为 ProEditTable 的列时,otherProps 中的 name 是完整绝对路径(如 ['bindClauseCategoryList', 0, 'test'])
|
|
53
|
+
// 此时直接使用 toArray(name) 作为 _namePath,避免公式拼接导致前缀重复
|
|
54
|
+
var _namePath = source === 'ProEditTable' ? toArray(name) : namePath ? [...namePath.slice(0, -1), ...toArray(name)] : toArray(name);
|
|
51
55
|
var orgValues = get(diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalValues, name);
|
|
52
56
|
var _diffConfig = _objectSpread(_objectSpread({}, diffConfig), {}, {
|
|
53
57
|
originalValues: diffConfig !== null && diffConfig !== void 0 && diffConfig.originalValues && isDiffAll ? orgValues || [] : orgValues
|
|
@@ -29,6 +29,7 @@ var BaseTable = _ref => {
|
|
|
29
29
|
var tableProps = _ref.tableProps,
|
|
30
30
|
resetProps = _objectWithoutProperties(_ref, _excluded);
|
|
31
31
|
var rowKey = tableProps.rowKey,
|
|
32
|
+
tableRowKey = tableProps.tableRowKey,
|
|
32
33
|
value = tableProps.value,
|
|
33
34
|
headerRender = tableProps.headerRender,
|
|
34
35
|
tableRef = tableProps.tableRef,
|
|
@@ -83,7 +84,7 @@ var BaseTable = _ref => {
|
|
|
83
84
|
onClick: () => {}
|
|
84
85
|
})
|
|
85
86
|
}, resetProps), {}, {
|
|
86
|
-
rowKey:
|
|
87
|
+
rowKey: tableRowKey,
|
|
87
88
|
summary,
|
|
88
89
|
pagination: pagination ? _objectSpread(_objectSpread({
|
|
89
90
|
showSizeChanger: true,
|
|
@@ -125,6 +125,7 @@ var DraggableTable = _ref3 => {
|
|
|
125
125
|
draggableProps = _ref3.draggableProps,
|
|
126
126
|
resetProps = _objectWithoutProperties(_ref3, _excluded2);
|
|
127
127
|
var rowKey = tableProps.rowKey,
|
|
128
|
+
tableRowKey = tableProps.tableRowKey,
|
|
128
129
|
value = tableProps.value,
|
|
129
130
|
headerRender = tableProps.headerRender,
|
|
130
131
|
tableRef = tableProps.tableRef,
|
|
@@ -181,7 +182,7 @@ var DraggableTable = _ref3 => {
|
|
|
181
182
|
}),
|
|
182
183
|
dataSource: value !== null && value !== void 0 && (_value$2 = value[0]) !== null && _value$2 !== void 0 && _value$2.rowKey ? value : []
|
|
183
184
|
}, resetProps), {}, {
|
|
184
|
-
rowKey:
|
|
185
|
+
rowKey: tableRowKey,
|
|
185
186
|
pagination: pagination ? _objectSpread({
|
|
186
187
|
current: page.pageNum,
|
|
187
188
|
pageSize: page.pageSize,
|
|
@@ -31,6 +31,12 @@ var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "e
|
|
|
31
31
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
32
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
33
33
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
34
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
35
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
36
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
38
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
39
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
34
40
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
35
41
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
36
42
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -44,7 +50,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
44
50
|
var OMIT_FORM_ITEM_AND_DOM_KEYS = ['format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames', 'shouldCellUpdate' // 表格内部性能优化属性,不应传递给 Form.Item
|
|
45
51
|
];
|
|
46
52
|
var RenderField = _ref => {
|
|
47
|
-
var _type, _type$replace, _fieldProps2, _fieldProps4, _names, _TargetComponent5,
|
|
53
|
+
var _type, _type$replace, _fieldProps2, _fieldProps4, _names, _TargetComponent5, _componentProps3;
|
|
48
54
|
var value = _ref.text,
|
|
49
55
|
record = _ref.record,
|
|
50
56
|
index = _ref.index,
|
|
@@ -259,7 +265,7 @@ var RenderField = _ref => {
|
|
|
259
265
|
// required 是函数
|
|
260
266
|
(0, _lodash.isFunction)(rules) ||
|
|
261
267
|
// rules 是函数
|
|
262
|
-
(0, _lodash.isFunction)(isEditable) ||
|
|
268
|
+
(0, _lodash.isFunction)(column === null || column === void 0 ? void 0 : column.isEditable) ||
|
|
263
269
|
// isEditable 是函数
|
|
264
270
|
(0, _lodash.isFunction)(component) ||
|
|
265
271
|
// component 是函数
|
|
@@ -770,6 +776,8 @@ var RenderField = _ref => {
|
|
|
770
776
|
var shouldUpdateMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
771
777
|
// 如果处于 shouldUpdate 模式,需要重新获取最新的行数据并重新计算依赖值
|
|
772
778
|
var finalComponentProps = componentProps;
|
|
779
|
+
// shouldUpdate 模式下会被更新为最新值,供外层 FieldProvider 消费
|
|
780
|
+
var latestIsView = isView;
|
|
773
781
|
if (shouldUpdateMode) {
|
|
774
782
|
var _column$isEditable2;
|
|
775
783
|
// 重新获取最新的行数据(shouldUpdate 触发时,通过 getFieldValue 拿到最新值)
|
|
@@ -848,7 +856,7 @@ var RenderField = _ref => {
|
|
|
848
856
|
}
|
|
849
857
|
|
|
850
858
|
// 然后处理自定义 component
|
|
851
|
-
|
|
859
|
+
latestIsView = !latestIsEditable || (record === null || record === void 0 ? void 0 : record['is-view']) || config.isView || virtualKey && !_isEditing || (0, _tools.getDisabled)({
|
|
852
860
|
globalControl: otherProps === null || otherProps === void 0 ? void 0 : otherProps.globalControl,
|
|
853
861
|
formDisabled: otherProps === null || otherProps === void 0 ? void 0 : otherProps.formDisabled,
|
|
854
862
|
column,
|
|
@@ -883,6 +891,13 @@ var RenderField = _ref => {
|
|
|
883
891
|
// 使用重新计算的 TargetComponent
|
|
884
892
|
TargetComponent = latestTargetComponent;
|
|
885
893
|
|
|
894
|
+
// shouldUpdate 触发时外层 componentProps.otherProps.isView 是旧快照,需用最新值覆盖
|
|
895
|
+
finalComponentProps = _objectSpread(_objectSpread({}, finalComponentProps), {}, {
|
|
896
|
+
otherProps: _objectSpread(_objectSpread({}, finalComponentProps.otherProps), {}, {
|
|
897
|
+
isView: latestIsView
|
|
898
|
+
})
|
|
899
|
+
});
|
|
900
|
+
|
|
886
901
|
// componentProps 里展开了外层旧 TargetComponent?.props(如 { formType: "Input" }),
|
|
887
902
|
// 用 latestTargetComponent?.props 覆盖,确保不会被旧 cloneElement props 污染
|
|
888
903
|
if ( /*#__PURE__*/_react.default.isValidElement(latestTargetComponent)) {
|
|
@@ -964,15 +979,32 @@ var RenderField = _ref => {
|
|
|
964
979
|
}))
|
|
965
980
|
}));
|
|
966
981
|
}
|
|
967
|
-
|
|
982
|
+
// shouldUpdateMode 返回元组,将 latestIsView 暴露给外层用于更新 FieldProvider context
|
|
983
|
+
return shouldUpdateMode ? [FormItem, latestIsView] : FormItem;
|
|
968
984
|
};
|
|
969
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
970
|
-
value: ((_componentProps2 = componentProps) === null || _componentProps2 === void 0 ? void 0 : _componentProps2.otherProps) || {},
|
|
985
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
971
986
|
children: finalFormItemProps.shouldUpdate ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Form.Item, {
|
|
972
987
|
noStyle: true,
|
|
973
988
|
shouldUpdate: finalFormItemProps.shouldUpdate,
|
|
974
|
-
children: () =>
|
|
975
|
-
|
|
989
|
+
children: () => {
|
|
990
|
+
var _componentProps2;
|
|
991
|
+
// shouldUpdate 触发时外层组件可能因 memo 未重渲染,FieldProvider context 是旧快照
|
|
992
|
+
// 从 getFieldItem(true) 的元组返回值获取 latestIsView,更新 context 确保 Input 组件读到最新 isView
|
|
993
|
+
var _ref5 = getFieldItem(true),
|
|
994
|
+
_ref6 = _slicedToArray(_ref5, 2),
|
|
995
|
+
formItem = _ref6[0],
|
|
996
|
+
latestIsView = _ref6[1];
|
|
997
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
|
|
998
|
+
value: _objectSpread(_objectSpread({}, (_componentProps2 = componentProps) === null || _componentProps2 === void 0 ? void 0 : _componentProps2.otherProps), {}, {
|
|
999
|
+
isView: latestIsView
|
|
1000
|
+
}),
|
|
1001
|
+
children: formItem
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
|
|
1005
|
+
value: ((_componentProps3 = componentProps) === null || _componentProps3 === void 0 ? void 0 : _componentProps3.otherProps) || {},
|
|
1006
|
+
children: getFieldItem()
|
|
1007
|
+
})
|
|
976
1008
|
});
|
|
977
1009
|
};
|
|
978
1010
|
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(RenderField, (prevProps, nextProps) => {
|
|
@@ -443,8 +443,10 @@ var ProEditTable = (_ref, ref) => {
|
|
|
443
443
|
_dragIndex: idx
|
|
444
444
|
} : {}));
|
|
445
445
|
}, [value, virtualKey, editingKeys, draggable]);
|
|
446
|
+
var tableRowKey = (0, _react.useMemo)(() => (0, _tools.buildTableRowKey)(rowKey), [rowKey]);
|
|
446
447
|
var tableProps = (0, _react.useMemo)(() => ({
|
|
447
448
|
rowKey,
|
|
449
|
+
tableRowKey,
|
|
448
450
|
value: enrichedValue,
|
|
449
451
|
headerRender,
|
|
450
452
|
tableRef,
|
|
@@ -464,7 +466,7 @@ var ProEditTable = (_ref, ref) => {
|
|
|
464
466
|
formatMessage: _locale.formatMessage,
|
|
465
467
|
locale: _locale.default,
|
|
466
468
|
handlePageChange
|
|
467
|
-
}), [_className, _columns, _rowClassName, disabled, editingKeys, _locale.formatMessage, handlePageChange, headerRender, isHideCheckBox, _locale.default, page, pagination, renderRowSelection, rowDraggable, rowKey, scroll, _summary, tableRef, enrichedValue, virtualKey]);
|
|
469
|
+
}), [_className, _columns, _rowClassName, disabled, editingKeys, _locale.formatMessage, handlePageChange, headerRender, isHideCheckBox, _locale.default, page, pagination, renderRowSelection, rowDraggable, rowKey, tableRowKey, scroll, _summary, tableRef, enrichedValue, virtualKey]);
|
|
468
470
|
|
|
469
471
|
// 拖拽排序后,enrichedValue 中含 _dragIndex(内部字段),需清除后再传给外部 onChange
|
|
470
472
|
var handleDragChange = (0, _react.useCallback)(newValue => {
|
|
@@ -6,6 +6,13 @@ import { NamePath } from 'antd/es/form/interface';
|
|
|
6
6
|
* @returns 随机字符串
|
|
7
7
|
*/
|
|
8
8
|
export declare const getRandom: () => string;
|
|
9
|
+
/**
|
|
10
|
+
* 构建 AntD Table 的 rowKey 函数,支持字符串/函数两种形式,
|
|
11
|
+
* 当用户指定字段值无效时(新增行尚未填写业务 key),自动降级到内部 record.rowKey。
|
|
12
|
+
* @param rowKey 用户传入的 rowKey prop
|
|
13
|
+
* @returns AntD Table 可用的 rowKey 字符串或函数
|
|
14
|
+
*/
|
|
15
|
+
export declare const buildTableRowKey: (rowKey?: string | number | symbol | ((record: any) => any)) => (record: any) => string;
|
|
9
16
|
/**
|
|
10
17
|
* 深层次对比两个对象且取出来差异值
|
|
11
18
|
* @param object 比较对象
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.buildTableRowKey = void 0;
|
|
6
7
|
exports.cloneDeepFilterNode = cloneDeepFilterNode;
|
|
7
8
|
exports.splitNames = exports.onPageCheck = exports.onDelete = exports.handleScrollToError = exports.getRandom = exports.getNamePath = exports.getDisabled = exports.difference = exports.customValidate = void 0;
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -27,13 +28,31 @@ var getRandom = () => {
|
|
|
27
28
|
return Math.random().toString(36).slice(-6);
|
|
28
29
|
};
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* 构建 AntD Table 的 rowKey 函数,支持字符串/函数两种形式,
|
|
33
|
+
* 当用户指定字段值无效时(新增行尚未填写业务 key),自动降级到内部 record.rowKey。
|
|
34
|
+
* @param rowKey 用户传入的 rowKey prop
|
|
35
|
+
* @returns AntD Table 可用的 rowKey 字符串或函数
|
|
36
|
+
*/
|
|
37
|
+
exports.getRandom = getRandom;
|
|
38
|
+
var buildTableRowKey = rowKey => {
|
|
39
|
+
return record => {
|
|
40
|
+
if (!rowKey) return String(record.rowKey || '');
|
|
41
|
+
var userKey = typeof rowKey === 'function' ? rowKey(record) : record[rowKey];
|
|
42
|
+
if (userKey != null && !Number.isNaN(userKey) && userKey !== '') {
|
|
43
|
+
return String(userKey);
|
|
44
|
+
}
|
|
45
|
+
return String(record.rowKey || '');
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
30
49
|
/**
|
|
31
50
|
* 深层次对比两个对象且取出来差异值
|
|
32
51
|
* @param object 比较对象
|
|
33
52
|
* @param base 基准对象
|
|
34
53
|
* @returns 差异对象
|
|
35
54
|
*/
|
|
36
|
-
exports.
|
|
55
|
+
exports.buildTableRowKey = buildTableRowKey;
|
|
37
56
|
var difference = (object, base) => {
|
|
38
57
|
var changes = (object, base) => {
|
|
39
58
|
return (0, _lodash.transform)(object, (result, value, key) => {
|
|
@@ -51,11 +51,15 @@ var FormList = (props, ref) => {
|
|
|
51
51
|
name = _ref.name,
|
|
52
52
|
isView = _ref.isView,
|
|
53
53
|
diffConfig = _ref.diffConfig,
|
|
54
|
-
namePath = _ref.namePath
|
|
54
|
+
namePath = _ref.namePath,
|
|
55
|
+
source = _ref.source;
|
|
55
56
|
var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProForm'),
|
|
56
57
|
isDiffAll = _useProConfig.isDiffAll;
|
|
57
58
|
var errors = meta.errors;
|
|
58
|
-
|
|
59
|
+
|
|
60
|
+
// 当 FormList 作为 ProEditTable 的列时,otherProps 中的 name 是完整绝对路径(如 ['bindClauseCategoryList', 0, 'test'])
|
|
61
|
+
// 此时直接使用 toArray(name) 作为 _namePath,避免公式拼接导致前缀重复
|
|
62
|
+
var _namePath = source === 'ProEditTable' ? (0, _utils.toArray)(name) : namePath ? [...namePath.slice(0, -1), ...(0, _utils.toArray)(name)] : (0, _utils.toArray)(name);
|
|
59
63
|
var orgValues = (0, _lodash.get)(diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalValues, name);
|
|
60
64
|
var _diffConfig = _objectSpread(_objectSpread({}, diffConfig), {}, {
|
|
61
65
|
originalValues: diffConfig !== null && diffConfig !== void 0 && diffConfig.originalValues && isDiffAll ? orgValues || [] : orgValues
|