@nokecy/qc-ui 1.1.86 → 1.1.88

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.
Files changed (108) hide show
  1. package/dist/cjs/ag-grid-plus/ag-gridPlus.js +148 -144
  2. package/dist/cjs/ag-grid-plus/context/useSchemeDataFlow.js +4 -4
  3. package/dist/cjs/ag-grid-plus/errors/types.d.ts +9 -0
  4. package/dist/cjs/ag-grid-plus/errors/types.js +20 -0
  5. package/dist/cjs/ag-grid-plus/interface.d.ts +2 -0
  6. package/dist/cjs/ag-grid-plus/locale.d.ts +413 -1
  7. package/dist/cjs/ag-grid-plus/locale.js +14 -3
  8. package/dist/cjs/ag-grid-plus/queryForm/index.d.ts +2 -0
  9. package/dist/cjs/ag-grid-plus/queryForm/index.js +47 -51
  10. package/dist/cjs/ag-grid-plus/queryForm/queryColumns.d.ts +8 -0
  11. package/dist/cjs/ag-grid-plus/queryForm/queryColumns.js +52 -0
  12. package/dist/cjs/ag-grid-plus/queryForm/schemaKey.d.ts +15 -8
  13. package/dist/cjs/ag-grid-plus/queryForm/schemaKey.js +64 -12
  14. package/dist/cjs/ag-grid-plus/setting/ColumnConfigForm.js +3 -0
  15. package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +69 -106
  16. package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +3 -1
  17. package/dist/cjs/ag-grid-plus/setting/columnGroupTypes.d.ts +2 -0
  18. package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.d.ts +14 -0
  19. package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.js +98 -110
  20. package/dist/cjs/ag-grid-plus/types.d.ts +6 -0
  21. package/dist/cjs/array-table/batchRemove.d.ts +36 -0
  22. package/dist/cjs/array-table/batchRemove.js +299 -0
  23. package/dist/cjs/array-table/cellFocusScope.js +58 -7
  24. package/dist/cjs/array-table/cellInteractionLock.d.ts +13 -0
  25. package/dist/cjs/array-table/cellInteractionLock.js +26 -0
  26. package/dist/cjs/array-table/hooks.d.ts +11 -6
  27. package/dist/cjs/array-table/hooks.js +138 -88
  28. package/dist/cjs/array-table/index.d.ts +8 -2
  29. package/dist/cjs/array-table/index.js +55 -32
  30. package/dist/cjs/array-table/indexColumn.d.ts +1 -1
  31. package/dist/cjs/array-table/indexColumn.js +3 -2
  32. package/dist/cjs/array-table/interface.d.ts +13 -1
  33. package/dist/cjs/array-table/preview.js +8 -0
  34. package/dist/cjs/array-table/readOnlyFormatters.d.ts +9 -1
  35. package/dist/cjs/array-table/readOnlyFormatters.js +41 -13
  36. package/dist/cjs/array-table/rowIdentity.d.ts +17 -0
  37. package/dist/cjs/array-table/rowIdentity.js +43 -0
  38. package/dist/cjs/array-table/sorting.d.ts +3 -0
  39. package/dist/cjs/array-table/sorting.js +46 -0
  40. package/dist/cjs/array-table/utils.js +146 -67
  41. package/dist/cjs/dialogSelect/index.d.ts +3 -0
  42. package/dist/cjs/dialogSelect/index.js +13 -3
  43. package/dist/cjs/editable/index.js +101 -139
  44. package/dist/cjs/index.d.ts +2 -2
  45. package/dist/cjs/index.js +14 -0
  46. package/dist/cjs/readPretty/arrayTable.js +29 -14
  47. package/dist/cjs/readPretty/formily.d.ts +1 -0
  48. package/dist/cjs/readPretty/formily.js +7 -0
  49. package/dist/cjs/readPretty/index.d.ts +1 -0
  50. package/dist/cjs/readPretty/index.js +7 -0
  51. package/dist/cjs/readPretty/schemaScope.d.ts +2 -0
  52. package/dist/cjs/readPretty/schemaScope.js +49 -0
  53. package/dist/cjs/standardList/emptyState.js +9 -0
  54. package/dist/esm/ag-grid-plus/ag-gridPlus.js +148 -144
  55. package/dist/esm/ag-grid-plus/context/useSchemeDataFlow.js +4 -4
  56. package/dist/esm/ag-grid-plus/errors/types.d.ts +9 -0
  57. package/dist/esm/ag-grid-plus/errors/types.js +20 -0
  58. package/dist/esm/ag-grid-plus/interface.d.ts +2 -0
  59. package/dist/esm/ag-grid-plus/locale.d.ts +413 -1
  60. package/dist/esm/ag-grid-plus/locale.js +15 -3
  61. package/dist/esm/ag-grid-plus/queryForm/index.d.ts +2 -0
  62. package/dist/esm/ag-grid-plus/queryForm/index.js +47 -52
  63. package/dist/esm/ag-grid-plus/queryForm/queryColumns.d.ts +8 -0
  64. package/dist/esm/ag-grid-plus/queryForm/queryColumns.js +46 -0
  65. package/dist/esm/ag-grid-plus/queryForm/schemaKey.d.ts +15 -8
  66. package/dist/esm/ag-grid-plus/queryForm/schemaKey.js +64 -12
  67. package/dist/esm/ag-grid-plus/setting/ColumnConfigForm.js +3 -0
  68. package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +70 -107
  69. package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +3 -1
  70. package/dist/esm/ag-grid-plus/setting/columnGroupTypes.d.ts +2 -0
  71. package/dist/esm/ag-grid-plus/setting/columnGroupUtils.d.ts +14 -0
  72. package/dist/esm/ag-grid-plus/setting/columnGroupUtils.js +95 -110
  73. package/dist/esm/ag-grid-plus/types.d.ts +6 -0
  74. package/dist/esm/array-table/batchRemove.d.ts +36 -0
  75. package/dist/esm/array-table/batchRemove.js +289 -0
  76. package/dist/esm/array-table/cellFocusScope.js +59 -8
  77. package/dist/esm/array-table/cellInteractionLock.d.ts +13 -0
  78. package/dist/esm/array-table/cellInteractionLock.js +21 -0
  79. package/dist/esm/array-table/hooks.d.ts +11 -6
  80. package/dist/esm/array-table/hooks.js +139 -89
  81. package/dist/esm/array-table/index.d.ts +8 -2
  82. package/dist/esm/array-table/index.js +55 -32
  83. package/dist/esm/array-table/indexColumn.d.ts +1 -1
  84. package/dist/esm/array-table/indexColumn.js +3 -2
  85. package/dist/esm/array-table/interface.d.ts +13 -1
  86. package/dist/esm/array-table/preview.js +8 -0
  87. package/dist/esm/array-table/readOnlyFormatters.d.ts +9 -1
  88. package/dist/esm/array-table/readOnlyFormatters.js +41 -12
  89. package/dist/esm/array-table/rowIdentity.d.ts +17 -0
  90. package/dist/esm/array-table/rowIdentity.js +37 -0
  91. package/dist/esm/array-table/sorting.d.ts +3 -0
  92. package/dist/esm/array-table/sorting.js +40 -0
  93. package/dist/esm/array-table/utils.js +147 -68
  94. package/dist/esm/dialogSelect/index.d.ts +3 -0
  95. package/dist/esm/dialogSelect/index.js +13 -3
  96. package/dist/esm/editable/index.js +102 -140
  97. package/dist/esm/index.d.ts +2 -2
  98. package/dist/esm/index.js +1 -1
  99. package/dist/esm/readPretty/arrayTable.js +30 -13
  100. package/dist/esm/readPretty/formily.d.ts +1 -0
  101. package/dist/esm/readPretty/formily.js +1 -0
  102. package/dist/esm/readPretty/index.d.ts +1 -0
  103. package/dist/esm/readPretty/index.js +1 -0
  104. package/dist/esm/readPretty/schemaScope.d.ts +2 -0
  105. package/dist/esm/readPretty/schemaScope.js +42 -0
  106. package/dist/esm/standardList/emptyState.js +9 -0
  107. package/dist/umd/qc-ui.min.js +1 -1
  108. package/package.json +3 -1
@@ -21,6 +21,27 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
21
21
  * @author nokecy
22
22
  */
23
23
  import dayjs from 'dayjs';
24
+
25
+ /** 选择器的展示字段;只影响回显,不改变 labelInValue 的提交值。@author nokecy */
26
+
27
+ /** 从选择值提取展示文字;编码展示不能因描述为空或过期而改变。@author nokecy */
28
+ export var formatSelectDisplay = function formatSelectDisplay(value) {
29
+ var _value$label;
30
+ var displayField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'label';
31
+ if (value == null) return '';
32
+ if (Array.isArray(value)) return value.map(function (item) {
33
+ return formatSelectDisplay(item, displayField);
34
+ }).filter(Boolean).join(', ');
35
+ if (_typeof(value) === 'object') return formatSelectDisplay(displayField === 'value' ? value.value : (_value$label = value.label) !== null && _value$label !== void 0 ? _value$label : value.value, displayField);
36
+ return String(value);
37
+ };
38
+
39
+ /** 给选择组件声明与其回显一致的表格格式化器,组件别名和不同页面各自生效。@author nokecy */
40
+ export var withReadOnlyFormatter = function withReadOnlyFormatter(component, formatter) {
41
+ return Object.assign(component, {
42
+ readOnlyFormatter: formatter
43
+ });
44
+ };
24
45
  /** 从字段 schema / 列 props 里尽量取到 Select 的可选项(value->label 映射用) */
25
46
  var resolveOptions = function resolveOptions(ctx) {
26
47
  var _ref, _ref2, _ref3, _fieldSchema$enum, _fieldSchema$xCompon, _fieldSchema$xCompon2;
@@ -33,10 +54,10 @@ var resolveOptions = function resolveOptions(ctx) {
33
54
 
34
55
  /** 单个值映射成 label:兼容 labelInValue 对象、{label,value} 选项、原始值 */
35
56
  var mapOptionLabel = function mapOptionLabel(value, options) {
36
- var _ref4, _value$label, _ref5, _hit$label;
57
+ var _ref4, _value$label2, _ref5, _hit$label;
37
58
  if (value == null) return '';
38
59
  // labelInValue: 值本身就是 { label, value }
39
- if (_typeof(value) === 'object') return String((_ref4 = (_value$label = value.label) !== null && _value$label !== void 0 ? _value$label : value.value) !== null && _ref4 !== void 0 ? _ref4 : '');
60
+ if (_typeof(value) === 'object') return String((_ref4 = (_value$label2 = value.label) !== null && _value$label2 !== void 0 ? _value$label2 : value.value) !== null && _ref4 !== void 0 ? _ref4 : '');
40
61
  // 严格相等优先;退一步按 String 宽松比对,容忍后端类型漂移(如返回 "0" 而 enum 存数字 0)
41
62
  var hit = options.find(function (o) {
42
63
  var ov = o && _typeof(o) === 'object' ? o.value : o;
@@ -49,7 +70,9 @@ var textFormatter = function textFormatter(value) {
49
70
  return value == null ? '' : String(value);
50
71
  };
51
72
  var selectFormatter = function selectFormatter(value, ctx) {
73
+ var _ctx$fieldSchema;
52
74
  if (value == null) return '';
75
+ if (((_ctx$fieldSchema = ctx.fieldSchema) === null || _ctx$fieldSchema === void 0 || (_ctx$fieldSchema = _ctx$fieldSchema['x-component-props']) === null || _ctx$fieldSchema === void 0 ? void 0 : _ctx$fieldSchema.displayField) === 'value') return formatSelectDisplay(value, 'value');
53
76
  var options = resolveOptions(ctx);
54
77
  // 多选:数组 -> 逗号拼接
55
78
  if (Array.isArray(value)) {
@@ -73,14 +96,14 @@ var defaultDateFormat = function defaultDateFormat(component, props) {
73
96
  return 'YYYY-MM-DD';
74
97
  };
75
98
  var dateFormatter = function dateFormatter(value, ctx) {
76
- var _ctx$fieldSchema, _ctx$columnProps, _ctx$fieldSchema2;
99
+ var _ctx$fieldSchema2, _ctx$columnProps, _ctx$fieldSchema3;
77
100
  if (value == null || value === '') return '';
78
- var props = (_ctx$fieldSchema = ctx.fieldSchema) === null || _ctx$fieldSchema === void 0 ? void 0 : _ctx$fieldSchema['x-component-props'];
101
+ var props = (_ctx$fieldSchema2 = ctx.fieldSchema) === null || _ctx$fieldSchema2 === void 0 ? void 0 : _ctx$fieldSchema2['x-component-props'];
79
102
  // antd 的 format 还可以是数组/函数,文本态只认字符串,其余回到默认
80
103
  var configured = [(_ctx$columnProps = ctx.columnProps) === null || _ctx$columnProps === void 0 ? void 0 : _ctx$columnProps.format, props === null || props === void 0 ? void 0 : props.format].find(function (f) {
81
104
  return typeof f === 'string' && f;
82
105
  });
83
- var fmt = configured !== null && configured !== void 0 ? configured : defaultDateFormat((_ctx$fieldSchema2 = ctx.fieldSchema) === null || _ctx$fieldSchema2 === void 0 ? void 0 : _ctx$fieldSchema2['x-component'], props);
106
+ var fmt = configured !== null && configured !== void 0 ? configured : defaultDateFormat((_ctx$fieldSchema3 = ctx.fieldSchema) === null || _ctx$fieldSchema3 === void 0 ? void 0 : _ctx$fieldSchema3['x-component'], props);
84
107
  if (typeof value.format === 'function') return value.format(fmt);
85
108
  // 后端回来的多是 ISO 串(2024-10-19T00:00:00)或时间戳:与 Formily readPretty 一致,按 dayjs(value).format(fmt) 显示;
86
109
  // 解析不了的文本(如「待定」、纯时间 08:30:00)原样显示,不吞掉。dayjs 随 antd 传递依赖引入,本库其他模块已直接使用。
@@ -93,9 +116,9 @@ var dateFormatter = function dateFormatter(value, ctx) {
93
116
  * 与点开后的 InputNumber 一致;没配这两项时与原样输出相同。
94
117
  */
95
118
  var numberFormatter = function numberFormatter(value, ctx) {
96
- var _ctx$fieldSchema$xCo, _ctx$fieldSchema3, _ctx$columnProps$prec, _ctx$columnProps2, _ctx$columnProps$form, _ctx$columnProps3;
119
+ var _ctx$fieldSchema$xCo, _ctx$fieldSchema4, _ctx$columnProps$prec, _ctx$columnProps2, _ctx$columnProps$form, _ctx$columnProps3;
97
120
  if (value == null || value === '') return '';
98
- var props = (_ctx$fieldSchema$xCo = (_ctx$fieldSchema3 = ctx.fieldSchema) === null || _ctx$fieldSchema3 === void 0 ? void 0 : _ctx$fieldSchema3['x-component-props']) !== null && _ctx$fieldSchema$xCo !== void 0 ? _ctx$fieldSchema$xCo : {};
121
+ var props = (_ctx$fieldSchema$xCo = (_ctx$fieldSchema4 = ctx.fieldSchema) === null || _ctx$fieldSchema4 === void 0 ? void 0 : _ctx$fieldSchema4['x-component-props']) !== null && _ctx$fieldSchema$xCo !== void 0 ? _ctx$fieldSchema$xCo : {};
99
122
  var precision = (_ctx$columnProps$prec = (_ctx$columnProps2 = ctx.columnProps) === null || _ctx$columnProps2 === void 0 ? void 0 : _ctx$columnProps2.precision) !== null && _ctx$columnProps$prec !== void 0 ? _ctx$columnProps$prec : props.precision;
100
123
  var num = Number(value);
101
124
  var base = typeof precision === 'number' && precision >= 0 && Number.isFinite(num) ? num.toFixed(precision) : String(value);
@@ -113,9 +136,9 @@ var numberFormatter = function numberFormatter(value, ctx) {
113
136
  return base;
114
137
  };
115
138
  var booleanFormatter = function booleanFormatter(value, ctx) {
116
- var _ctx$fieldSchema$xCo2, _ctx$fieldSchema4, _props$checkedChildre, _props$unCheckedChild;
139
+ var _ctx$fieldSchema$xCo2, _ctx$fieldSchema5, _props$checkedChildre, _props$unCheckedChild;
117
140
  if (value == null || value === '') return '';
118
- var props = (_ctx$fieldSchema$xCo2 = (_ctx$fieldSchema4 = ctx.fieldSchema) === null || _ctx$fieldSchema4 === void 0 ? void 0 : _ctx$fieldSchema4['x-component-props']) !== null && _ctx$fieldSchema$xCo2 !== void 0 ? _ctx$fieldSchema$xCo2 : {};
141
+ var props = (_ctx$fieldSchema$xCo2 = (_ctx$fieldSchema5 = ctx.fieldSchema) === null || _ctx$fieldSchema5 === void 0 ? void 0 : _ctx$fieldSchema5['x-component-props']) !== null && _ctx$fieldSchema$xCo2 !== void 0 ? _ctx$fieldSchema$xCo2 : {};
119
142
  var truthy = (_props$checkedChildre = props.checkedChildren) !== null && _props$checkedChildre !== void 0 ? _props$checkedChildre : '是';
120
143
  var falsy = (_props$unCheckedChild = props.unCheckedChildren) !== null && _props$unCheckedChild !== void 0 ? _props$unCheckedChild : '否';
121
144
  return value ? String(truthy) : String(falsy);
@@ -152,15 +175,17 @@ var registry = {
152
175
  * 消费方用 registerReadOnlyFormatter 注册专用格式化器覆盖。@author nokecy
153
176
  */
154
177
  export var fallbackFormatter = function fallbackFormatter(value, ctx) {
178
+ var _ctx$fieldSchema6;
155
179
  if (value == null || value === '') return '';
180
+ if (((_ctx$fieldSchema6 = ctx.fieldSchema) === null || _ctx$fieldSchema6 === void 0 || (_ctx$fieldSchema6 = _ctx$fieldSchema6['x-component-props']) === null || _ctx$fieldSchema6 === void 0 ? void 0 : _ctx$fieldSchema6.displayField) === 'value') return formatSelectDisplay(value, 'value');
156
181
  if (Array.isArray(value)) return value.map(function (v) {
157
182
  return fallbackFormatter(v, ctx);
158
183
  }).filter(Boolean).join(', ');
159
184
  if (typeof value === 'boolean') return booleanFormatter(value, ctx);
160
185
  if (_typeof(value) === 'object') {
161
- var _value$label2;
186
+ var _value$label3;
162
187
  if (typeof value.format === 'function') return dateFormatter(value, ctx);
163
- var shown = (_value$label2 = value.label) !== null && _value$label2 !== void 0 ? _value$label2 : value.value;
188
+ var shown = (_value$label3 = value.label) !== null && _value$label3 !== void 0 ? _value$label3 : value.value;
164
189
  return shown == null ? '' : String(shown);
165
190
  }
166
191
  return String(value);
@@ -236,8 +261,12 @@ export var getReadOnlyRenderer = function getReadOnlyRenderer(component) {
236
261
  /**
237
262
  * 取某组件类型的只读格式化器。命中返回函数,未命中返回 null(调用方回退 AgField)。
238
263
  */
239
- export var getReadOnlyFormatter = function getReadOnlyFormatter(component) {
264
+ export var getReadOnlyFormatter = function getReadOnlyFormatter(component, components) {
240
265
  var _registry$component;
241
266
  if (!component) return null;
267
+ var control = component.split('.').reduce(function (current, key) {
268
+ return current === null || current === void 0 ? void 0 : current[key];
269
+ }, components);
270
+ if (typeof (control === null || control === void 0 ? void 0 : control.readOnlyFormatter) === 'function') return control.readOnlyFormatter;
242
271
  return (_registry$component = registry[component]) !== null && _registry$component !== void 0 ? _registry$component : null;
243
272
  };
@@ -0,0 +1,17 @@
1
+ import type { ArrayField } from '@formily/core';
2
+ /**
3
+ * 读取业务行标识;尚未补入表单的行按对象缓存临时标识,不在渲染期间改写表单。
4
+ * @param row 明细行。
5
+ * @param generatedIds 当前表格已分配的临时行标识。
6
+ * @returns AG-Grid 使用的稳定字符串标识。
7
+ * @author nokecy
8
+ */
9
+ export declare const getArrayTableRowId: (row: Record<string, any>, generatedIds: WeakMap<object, string>) => string;
10
+ /**
11
+ * 在 effect 中为缺少业务标识的明细补入可枚举 _id,使业务克隆行时保留 AG-Grid 行身份。
12
+ * 复用首次渲染已分配的标识,补值本身不会使单元格重挂;已有 _id/id(含 0)保持原值。
13
+ * @param field 当前明细数组字段。
14
+ * @param generatedIds 当前表格已分配的临时行标识。
15
+ * @author nokecy
16
+ */
17
+ export declare const ensureArrayTableRowIds: (field: ArrayField, generatedIds: WeakMap<object, string>) => void;
@@ -0,0 +1,37 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import uniqueId from 'lodash/uniqueId';
3
+
4
+ /**
5
+ * 读取业务行标识;尚未补入表单的行按对象缓存临时标识,不在渲染期间改写表单。
6
+ * @param row 明细行。
7
+ * @param generatedIds 当前表格已分配的临时行标识。
8
+ * @returns AG-Grid 使用的稳定字符串标识。
9
+ * @author nokecy
10
+ */
11
+ export var getArrayTableRowId = function getArrayTableRowId(row, generatedIds) {
12
+ var _row$_id;
13
+ var existingId = (_row$_id = row._id) !== null && _row$_id !== void 0 ? _row$_id : row.id;
14
+ if (existingId != null) return String(existingId);
15
+ var generatedId = generatedIds.get(row);
16
+ if (!generatedId) {
17
+ generatedId = uniqueId('row_');
18
+ generatedIds.set(row, generatedId);
19
+ }
20
+ return generatedId;
21
+ };
22
+
23
+ /**
24
+ * 在 effect 中为缺少业务标识的明细补入可枚举 _id,使业务克隆行时保留 AG-Grid 行身份。
25
+ * 复用首次渲染已分配的标识,补值本身不会使单元格重挂;已有 _id/id(含 0)保持原值。
26
+ * @param field 当前明细数组字段。
27
+ * @param generatedIds 当前表格已分配的临时行标识。
28
+ * @author nokecy
29
+ */
30
+ export var ensureArrayTableRowIds = function ensureArrayTableRowIds(field, generatedIds) {
31
+ if (!Array.isArray(field.value)) return;
32
+ field.value.forEach(function (row, index) {
33
+ var _row$_id2;
34
+ if (row == null || _typeof(row) !== 'object' || ((_row$_id2 = row._id) !== null && _row$_id2 !== void 0 ? _row$_id2 : row.id) != null) return;
35
+ field.form.setValuesIn(field.path.concat(index).concat('_id'), getArrayTableRowId(row, generatedIds));
36
+ });
37
+ };
@@ -0,0 +1,3 @@
1
+ import { type ReadOnlyFormatter } from './readOnlyFormatters';
2
+ /** 按列的展示字段和数据类型比较明细值,保留原始选择对象供表单绑定使用。@author nokecy */
3
+ export declare const createArrayTableComparator: (fieldSchema: any, columnProps: any, formatter: ReadOnlyFormatter | null) => (a: any, b: any) => number;
@@ -0,0 +1,40 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import Decimal from 'decimal.js';
3
+ import dayjs from 'dayjs';
4
+ import { formatSelectDisplay } from "./readOnlyFormatters";
5
+
6
+ /** 按列的展示字段和数据类型比较明细值,保留原始选择对象供表单绑定使用。@author nokecy */
7
+ export var createArrayTableComparator = function createArrayTableComparator(fieldSchema, columnProps, formatter) {
8
+ var _fieldSchema$xCompon, _fieldSchema$xCompon2;
9
+ var component = String((_fieldSchema$xCompon = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component']) !== null && _fieldSchema$xCompon !== void 0 ? _fieldSchema$xCompon : '');
10
+ var numeric = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.type) === 'number' || (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.type) === 'integer' || /^(InputNumber|NumberPicker|DecimalPicker|MoneyPicker)$/.test(component) || [columnProps === null || columnProps === void 0 ? void 0 : columnProps.type].flat().some(function (type) {
11
+ return type === 'numericColumn' || type === 'numberColumn';
12
+ });
13
+ var temporal = /^(DatePicker|TimePicker)(\.|$)/.test(component);
14
+ var displayField = (fieldSchema === null || fieldSchema === void 0 || (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.displayField) === 'value' ? 'value' : 'label';
15
+ var scalar = function scalar(value) {
16
+ var _value$label;
17
+ if (value == null) return null;
18
+ if (Array.isArray(value)) return formatSelectDisplay(value, displayField);
19
+ if (_typeof(value) === 'object' && ('value' in value || 'label' in value)) return scalar(displayField === 'value' ? value.value : (_value$label = value.label) !== null && _value$label !== void 0 ? _value$label : value.value);
20
+ if (temporal && dayjs(value).isValid()) return dayjs(value).valueOf();
21
+ if (numeric || typeof value === 'number' || typeof value === 'boolean') return value;
22
+ return formatter ? formatter(value, {
23
+ columnProps: columnProps,
24
+ fieldSchema: fieldSchema
25
+ }) : String(value);
26
+ };
27
+ return function (a, b) {
28
+ var left = scalar(a);
29
+ var right = scalar(b);
30
+ if (left == null || left === '') return right == null || right === '' ? 0 : -1;
31
+ if (right == null || right === '') return 1;
32
+ if (numeric || temporal || typeof left === 'number' && typeof right === 'number') {
33
+ try {
34
+ return new Decimal(left).cmp(new Decimal(right));
35
+ } catch (_unused) {/* 无效数值按展示文字排序。 */}
36
+ }
37
+ if (typeof left === 'boolean' && typeof right === 'boolean') return Number(left) - Number(right);
38
+ return String(left).localeCompare(String(right), 'zh-CN');
39
+ };
40
+ };
@@ -18,7 +18,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
19
  import React, { useReducer, useRef } from 'react';
20
20
  import { theme } from 'antd';
21
- import { useField, useFieldSchema, RecursionField, Observer, useExpressionScope } from '@formily/react';
21
+ import { useField, useFieldSchema, RecursionField, Observer, useExpressionScope, SchemaComponentsContext } from '@formily/react';
22
22
  import { untracked } from '@formily/reactive';
23
23
  import { isArr, lazyMerge } from '@formily/shared';
24
24
  import { Schema } from '@formily/json-schema';
@@ -26,6 +26,7 @@ import ArrayBase from "./arrayBase";
26
26
  import { fallbackFormatter, getReadOnlyFormatter, getReadOnlyRenderer } from "./readOnlyFormatters";
27
27
  import { markHeaderGroup } from "./columnGroup";
28
28
  import { CellFocusScope } from "./cellFocusScope";
29
+ import { createArrayTableComparator } from "./sorting";
29
30
  var isColumnComponent = function isColumnComponent(schema) {
30
31
  var _schema$xComponent;
31
32
  return ((_schema$xComponent = schema['x-component']) === null || _schema$xComponent === void 0 ? void 0 : _schema$xComponent.indexOf('Column')) > -1;
@@ -45,6 +46,7 @@ var isActionComponent = function isActionComponent(schema) {
45
46
  var useArrayTableSources = function useArrayTableSources() {
46
47
  var arrayField = useField();
47
48
  var schema = useFieldSchema();
49
+ var components = React.useContext(SchemaComponentsContext);
48
50
  var parseSources = function parseSources(schema) {
49
51
  if (isColumnComponent(schema) || isOperationsComponent(schema) || isAdditionComponent(schema)) {
50
52
  var _schema$xComponentP, _schema$xComponentP2, _field$component;
@@ -60,7 +62,8 @@ var useArrayTableSources = function useArrayTableSources() {
60
62
  //@ts-ignore
61
63
  field: field,
62
64
  schema: schema,
63
- columnProps: columnProps
65
+ columnProps: columnProps,
66
+ components: components
64
67
  }];
65
68
  } else if (schema.properties) {
66
69
  return schema.reduceProperties(function (buf, schema) {
@@ -116,19 +119,45 @@ var useArrayTableActions = function useArrayTableActions() {
116
119
  if (!schema) throw new Error('can not found schema object');
117
120
  return schema.properties ? parseSources(schema.properties['actions'] || {}) : [];
118
121
  };
119
- var AgField = function AgField(_ref) {
120
- var _field$value$indexOf, _field$value, _field$value$indexOf2, _ref2, _node$rowIndex;
121
- var value = _ref.value,
122
- record = _ref.data,
123
- dataSource = _ref.dataSource,
124
- schema = _ref.schema,
125
- field = _ref.field,
126
- node = _ref.node;
127
- // 数据序绑定:用 field.value.indexOf(record) 取数据数组下标(record === field.value 元素引用)。
128
- // 排序/过滤后 node.rowIndex 是显示序 ≠ 数据序,会把单元格绑到别的行——故 indexOf 优先,
129
- // 仅在未命中(理论不应发生)时才回退 rowIndex/dataSource。@author nokecy
130
- var dataIndex = (_field$value$indexOf = field === null || field === void 0 || (_field$value = field.value) === null || _field$value === void 0 || (_field$value$indexOf2 = _field$value.indexOf) === null || _field$value$indexOf2 === void 0 ? void 0 : _field$value$indexOf2.call(_field$value, record)) !== null && _field$value$indexOf !== void 0 ? _field$value$indexOf : -1;
131
- var index = dataIndex >= 0 ? dataIndex : (_ref2 = (_node$rowIndex = node === null || node === void 0 ? void 0 : node.rowIndex) !== null && _node$rowIndex !== void 0 ? _node$rowIndex : dataSource === null || dataSource === void 0 ? void 0 : dataSource.indexOf(record)) !== null && _ref2 !== void 0 ? _ref2 : -1;
122
+
123
+ /**
124
+ * 从表单当前数组定位单元格所属行。批量选择可保留 _id/id 并替换整行对象,
125
+ * AG Grid 在格值未变时仍会复用带旧 data 的渲染器;判空、校验和绑定必须使用当前行。
126
+ * 不以排序/过滤后的显示行号定位数据,已删除的行也不能绑定到后继行。@author nokecy
127
+ */
128
+ var resolveCellRow = function resolveCellRow(field, record, node, dataSource) {
129
+ var _field$value, _node$data;
130
+ var rows = (_field$value = field === null || field === void 0 ? void 0 : field.value) !== null && _field$value !== void 0 ? _field$value : dataSource;
131
+ var candidate = (_node$data = node === null || node === void 0 ? void 0 : node.data) !== null && _node$data !== void 0 ? _node$data : record;
132
+ if (!Array.isArray(rows)) return {
133
+ index: -1,
134
+ record: candidate
135
+ };
136
+ var index = rows.indexOf(candidate);
137
+ if (index < 0) {
138
+ var _ref, _ref2, _candidate$_id;
139
+ var id = (_ref = (_ref2 = (_candidate$_id = candidate === null || candidate === void 0 ? void 0 : candidate._id) !== null && _candidate$_id !== void 0 ? _candidate$_id : candidate === null || candidate === void 0 ? void 0 : candidate.id) !== null && _ref2 !== void 0 ? _ref2 : record === null || record === void 0 ? void 0 : record._id) !== null && _ref !== void 0 ? _ref : record === null || record === void 0 ? void 0 : record.id;
140
+ if (id != null) index = rows.findIndex(function (row) {
141
+ var _row$_id;
142
+ var rowId = (_row$_id = row === null || row === void 0 ? void 0 : row._id) !== null && _row$_id !== void 0 ? _row$_id : row === null || row === void 0 ? void 0 : row.id;
143
+ return rowId != null && String(rowId) === String(id);
144
+ });
145
+ }
146
+ return {
147
+ index: index,
148
+ record: index >= 0 ? rows[index] : undefined
149
+ };
150
+ };
151
+ var AgField = function AgField(_ref3) {
152
+ var value = _ref3.value,
153
+ record = _ref3.data,
154
+ dataSource = _ref3.dataSource,
155
+ schema = _ref3.schema,
156
+ field = _ref3.field,
157
+ node = _ref3.node;
158
+ var _resolveCellRow = resolveCellRow(field, record, node, dataSource),
159
+ index = _resolveCellRow.index;
160
+ if (index < 0) return null;
132
161
  var children =
133
162
  /*#__PURE__*/
134
163
  //@ts-ignore
@@ -198,10 +227,10 @@ var readByFieldPath = function readByFieldPath(record, path) {
198
227
  if (record == null) return undefined;
199
228
  // 对象解构:与 Formily 一致,按成员路径分别取值拼回 {value, label} 对象 @author nokecy
200
229
  var destructure = path.startsWith('{') ? parseObjectDestructure(path) : null;
201
- if (destructure) return Object.fromEntries(destructure.map(function (_ref3) {
202
- var _ref4 = _slicedToArray(_ref3, 2),
203
- key = _ref4[0],
204
- memberPath = _ref4[1];
230
+ if (destructure) return Object.fromEntries(destructure.map(function (_ref4) {
231
+ var _ref5 = _slicedToArray(_ref4, 2),
232
+ key = _ref5[0],
233
+ memberPath = _ref5[1];
205
234
  return [key, readByFieldPath(record, memberPath)];
206
235
  }));
207
236
  if (path.indexOf('.') < 0) return record[path];
@@ -356,6 +385,7 @@ var LazyAgField = function LazyAgField(params) {
356
385
  node = params.node,
357
386
  colDef = params.colDef,
358
387
  context = params.context,
388
+ api = params.api,
359
389
  formatter = params.formatter,
360
390
  renderer = params.renderer,
361
391
  columnProps = params.columnProps,
@@ -378,59 +408,88 @@ var LazyAgField = function LazyAgField(params) {
378
408
 
379
409
  /** 离开本格:校验通过才卸回懒挂载文本。未触碰的空必填格保留控件等待填写。@author nokecy */
380
410
  var handleLeave = /*#__PURE__*/function () {
381
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(isStale, hadFocus) {
382
- var _field$value$indexOf3, _field$value3, _field$value3$indexOf, _field$form;
383
- var currentValue, index, cellField;
411
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(isStale, hadFocus) {
412
+ var _field$form, _api$isDestroyed;
413
+ var current, currentValue, index, cellField, latest, _api$refreshCells;
384
414
  return _regeneratorRuntime().wrap(function _callee$(_context) {
385
415
  while (1) switch (_context.prev = _context.next) {
386
416
  case 0:
387
- currentValue = dataKey != null ? readByFieldPath(record, dataKey) : value; // 新增行的必填空格会预先挂载以参与提交校验;若用户从未进入该格,不在点击页面其他位置时
388
- // 主动触发校验,但已带值的格子仍可恢复静默文本态。@author nokecy
389
- if (!(required && isBlank(currentValue) && !hadFocus)) {
417
+ current = resolveCellRow(field, record, node, dataSource);
418
+ if (!(current.index < 0)) {
390
419
  _context.next = 3;
391
420
  break;
392
421
  }
393
422
  return _context.abrupt("return");
394
423
  case 3:
395
- index = (_field$value$indexOf3 = field === null || field === void 0 || (_field$value3 = field.value) === null || _field$value3 === void 0 || (_field$value3$indexOf = _field$value3.indexOf) === null || _field$value3$indexOf === void 0 ? void 0 : _field$value3$indexOf.call(_field$value3, record)) !== null && _field$value$indexOf3 !== void 0 ? _field$value$indexOf3 : -1; // 字段节点按数据路径找(不含 void 容器);从没挂载过就没有节点,无需校验
424
+ currentValue = dataKey != null ? readByFieldPath(current.record, dataKey) : value; // 新增行的必填空格会预先挂载以参与提交校验;若用户从未进入该格,不在点击页面其他位置时
425
+ // 主动触发校验,但已带值的格子仍可恢复静默文本态。@author nokecy
426
+ if (!(required && isBlank(currentValue) && !hadFocus)) {
427
+ _context.next = 6;
428
+ break;
429
+ }
430
+ return _context.abrupt("return");
431
+ case 6:
432
+ index = current.index; // 字段节点按数据路径找(不含 void 容器);从没挂载过就没有节点,无需校验
396
433
  cellField = index >= 0 && dataKey ? (_field$form = field.form) === null || _field$form === void 0 ? void 0 : _field$form.query(field.path.concat(index).concat(dataKey)).take() : undefined;
397
434
  if (!cellField) {
398
- _context.next = 14;
435
+ _context.next = 17;
399
436
  break;
400
437
  }
401
- _context.prev = 6;
402
- _context.next = 9;
438
+ _context.prev = 9;
439
+ _context.next = 12;
403
440
  return cellField.validate();
404
- case 9:
405
- _context.next = 14;
441
+ case 12:
442
+ _context.next = 17;
406
443
  break;
407
- case 11:
408
- _context.prev = 11;
409
- _context.t0 = _context["catch"](6);
410
- return _context.abrupt("return");
411
444
  case 14:
445
+ _context.prev = 14;
446
+ _context.t0 = _context["catch"](9);
447
+ return _context.abrupt("return");
448
+ case 17:
412
449
  if (!isStale()) {
413
- _context.next = 16;
450
+ _context.next = 19;
451
+ break;
452
+ }
453
+ return _context.abrupt("return");
454
+ case 19:
455
+ latest = resolveCellRow(field, record, node, dataSource); // 校验期间被替换、删除或移位的行,交给下一次离开重新校验。@author nokecy
456
+ if (!(latest.index !== index || latest.record !== current.record)) {
457
+ _context.next = 22;
414
458
  break;
415
459
  }
416
460
  return _context.abrupt("return");
417
- case 16:
418
- if (!(required && isBlank(dataKey != null ? readByFieldPath(record, dataKey) : undefined))) {
419
- _context.next = 18;
461
+ case 22:
462
+ if (!(required && isBlank(dataKey != null ? readByFieldPath(latest.record, dataKey) : undefined))) {
463
+ _context.next = 24;
420
464
  break;
421
465
  }
422
466
  return _context.abrupt("return");
423
- case 18:
424
- activeCells.delete(key);
467
+ case 24:
468
+ if (activeCells.delete(key)) {
469
+ _context.next = 26;
470
+ break;
471
+ }
472
+ return _context.abrupt("return");
473
+ case 26:
425
474
  rerender();
426
- case 20:
475
+ // 激活集合由 ArrayTable 与渲染器共享;退出时也同步通知 AG Grid 刷新本格,
476
+ // 不再依赖新增行等整表更新来收回已完成编辑的控件。字段节点和值仍保留。
477
+ // @author nokecy
478
+ if (node && colDef !== null && colDef !== void 0 && colDef.field && !(api !== null && api !== void 0 && (_api$isDestroyed = api.isDestroyed) !== null && _api$isDestroyed !== void 0 && _api$isDestroyed.call(api))) {
479
+ api === null || api === void 0 || (_api$refreshCells = api.refreshCells) === null || _api$refreshCells === void 0 || _api$refreshCells.call(api, {
480
+ rowNodes: [node],
481
+ columns: [colDef.field],
482
+ force: true
483
+ });
484
+ }
485
+ case 28:
427
486
  case "end":
428
487
  return _context.stop();
429
488
  }
430
- }, _callee, null, [[6, 11]]);
489
+ }, _callee, null, [[9, 14]]);
431
490
  }));
432
491
  return function handleLeave(_x, _x2) {
433
- return _ref5.apply(this, arguments);
492
+ return _ref6.apply(this, arguments);
434
493
  };
435
494
  }();
436
495
 
@@ -443,11 +502,11 @@ var LazyAgField = function LazyAgField(params) {
443
502
  * 仅选项类组件且有值时才查;按精确地址取、放在 untracked 里,不让每个格子都订阅整张字段表。@author nokecy
444
503
  */
445
504
  var liveDataSource = function liveDataSource(liveValue) {
446
- var _field$value$indexOf4, _field$value4, _field$value4$indexOf;
447
505
  var form = field === null || field === void 0 ? void 0 : field.form;
448
506
  // 只有用「选项映射」格式化器的列(Select 一族,或登记为同一格式化器的组件)才需要运行时选项
449
507
  if (!form || !dataKey || isBlank(liveValue) || formatter !== getReadOnlyFormatter('Select')) return undefined;
450
- var index = (_field$value$indexOf4 = field === null || field === void 0 || (_field$value4 = field.value) === null || _field$value4 === void 0 || (_field$value4$indexOf = _field$value4.indexOf) === null || _field$value4$indexOf === void 0 ? void 0 : _field$value4$indexOf.call(_field$value4, record)) !== null && _field$value$indexOf4 !== void 0 ? _field$value$indexOf4 : -1;
508
+ var _resolveCellRow2 = resolveCellRow(field, record, node, dataSource),
509
+ index = _resolveCellRow2.index;
451
510
  if (index < 0) return undefined;
452
511
  var own = untracked(function () {
453
512
  return form.query(field.path.concat(index).concat(dataKey)).take();
@@ -462,14 +521,17 @@ var LazyAgField = function LazyAgField(params) {
462
521
  // 改值(行引用不变 → AG-Grid 不刷新该格、外层 observer 也不重渲)时,本格能自行重渲刷新——
463
522
  // 免去调用方加 forceAgField 逃生阀。字段名缺失才回退 params.value。@author nokecy
464
523
  return /*#__PURE__*/React.createElement(Observer, null, function () {
524
+ var _resolveCellRow3 = resolveCellRow(field, record, node, dataSource),
525
+ currentRecord = _resolveCellRow3.record;
526
+ if (!currentRecord) return /*#__PURE__*/React.createElement(React.Fragment, null);
465
527
  var activated = activeCells.has(key);
466
528
  // 已挂载时不读值:挂载后每敲一个字都会变,追踪它会让整棵字段树跟着重渲
467
- var liveValue = activated ? undefined : dataKey != null && record ? readByFieldPath(record, dataKey) : value;
529
+ var liveValue = activated ? undefined : dataKey != null ? readByFieldPath(currentRecord, dataKey) : value;
468
530
  // Editable 装饰器会把非新增行的格转成只读态、不参与校验(见 editable/index.tsx),
469
531
  // 这时挂了没用,还会把灰色「请输入」占位换成只读态的「N/A」,所以留在文本态
470
- var editableWillReadPretty = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-decorator']) === 'Editable' && (record === null || record === void 0 ? void 0 : record._isNew) !== true;
532
+ var editableWillReadPretty = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-decorator']) === 'Editable' && currentRecord._isNew !== true;
471
533
  if (!activated && required && !editableWillReadPretty && isBlank(liveValue)) {
472
- var _pattern = resolveLazyCellPattern(field, record, dataKey, fieldSchema, scope);
534
+ var _pattern = resolveLazyCellPattern(field, currentRecord, dataKey, fieldSchema, scope);
473
535
  if (_pattern == null || _pattern === 'editable') {
474
536
  // 记进激活集合:用户填了第一个字后值不再为空,但格子仍在编辑,要挂到失焦为止
475
537
  activeCells.add(key);
@@ -481,7 +543,7 @@ var LazyAgField = function LazyAgField(params) {
481
543
  onLeave: handleLeave
482
544
  }, /*#__PURE__*/React.createElement(AgField, {
483
545
  value: value,
484
- data: record,
546
+ data: currentRecord,
485
547
  dataSource: dataSource,
486
548
  schema: schema,
487
549
  field: field,
@@ -496,7 +558,7 @@ var LazyAgField = function LazyAgField(params) {
496
558
  var text = formatter ? formatter(liveValue, ctx) : liveValue == null ? '' : String(liveValue);
497
559
  // 纯文本占满单元格,点击交给 AG-Grid onCellClicked 激活;样式尽量贴近 Editable 只读态避免点开跳动
498
560
  // 只读态(readPretty/disabled/readOnly)的空格不出编辑提示,留空与只读快路径一致
499
- var pattern = text === '' ? resolveLazyCellPattern(field, record, dataKey, fieldSchema, scope) : undefined;
561
+ var pattern = text === '' ? resolveLazyCellPattern(field, currentRecord, dataKey, fieldSchema, scope) : undefined;
500
562
  if (text === '' && (pattern == null || pattern === 'editable')) {
501
563
  // 空值:出淡灰 placeholder,让用户看得出这格能填(颜色取 antd 输入框 placeholder 的 token,自动跟随暗色主题)
502
564
  return /*#__PURE__*/React.createElement("span", {
@@ -536,6 +598,8 @@ var LazyReadOnlyText = function LazyReadOnlyText(params) {
536
598
  var _fieldSchema$name2;
537
599
  var value = params.value,
538
600
  record = params.data,
601
+ field = params.field,
602
+ node = params.node,
539
603
  colDef = params.colDef,
540
604
  formatter = params.formatter,
541
605
  renderer = params.renderer,
@@ -543,7 +607,8 @@ var LazyReadOnlyText = function LazyReadOnlyText(params) {
543
607
  fieldSchema = params.fieldSchema;
544
608
  var dataKey = (_fieldSchema$name2 = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) !== null && _fieldSchema$name2 !== void 0 ? _fieldSchema$name2 : colDef === null || colDef === void 0 ? void 0 : colDef.field;
545
609
  return /*#__PURE__*/React.createElement(Observer, null, function () {
546
- var liveValue = dataKey != null && record ? readByFieldPath(record, dataKey) : value;
610
+ var currentRecord = resolveCellRow(field, record, node).record;
611
+ var liveValue = dataKey != null && currentRecord ? readByFieldPath(currentRecord, dataKey) : value;
547
612
  var text = formatter ? formatter(liveValue, {
548
613
  columnProps: columnProps,
549
614
  fieldSchema: fieldSchema
@@ -631,12 +696,13 @@ var applyNumberInputDefaults = function applyNumberInputDefaults(dataField) {
631
696
  // 重命名自 useArrayTableColumns:内部无任何 Hook 调用,use 前缀违反 Hook 命名约定且曾在 useMemo 内被调用 @author nokecy
632
697
  var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field, sources) {
633
698
  var arrayPattern = field === null || field === void 0 ? void 0 : field.pattern;
634
- return sources.reduce(function (buf, _ref6, key) {
635
- var _getReadOnlyFormatter;
636
- var name = _ref6.name,
637
- columnProps = _ref6.columnProps,
638
- schema = _ref6.schema,
639
- display = _ref6.display;
699
+ return sources.reduce(function (buf, _ref7, key) {
700
+ var _ref8, _getReadOnlyFormatter, _dataField$xComponen, _dataField$xComponen2;
701
+ var name = _ref7.name,
702
+ columnProps = _ref7.columnProps,
703
+ schema = _ref7.schema,
704
+ display = _ref7.display,
705
+ components = _ref7.components;
640
706
  if (display && display !== 'visible') return buf;
641
707
  if (!isColumnComponent(schema)) return buf;
642
708
 
@@ -680,7 +746,15 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
680
746
  // 只读列不兜底:自定义只读组件常显示别的字段(如 SiblingText),按自身值出文本会错。@author nokecy
681
747
  // 登记了只读渲染器的组件只读列也走快路径(渲染器出内容,兜底格式化器只用于判空)。@author nokecy
682
748
  var renderer = getReadOnlyRenderer(component);
683
- var formatter = (_getReadOnlyFormatter = getReadOnlyFormatter(component)) !== null && _getReadOnlyFormatter !== void 0 ? _getReadOnlyFormatter : (!readOnly || renderer) && component && (dataField === null || dataField === void 0 ? void 0 : dataField.type) !== 'void' ? fallbackFormatter : null;
749
+ var formatter = (_ref8 = (_getReadOnlyFormatter = getReadOnlyFormatter(component, components)) !== null && _getReadOnlyFormatter !== void 0 ? _getReadOnlyFormatter : (dataField === null || dataField === void 0 || (_dataField$xComponen = dataField['x-component-props']) === null || _dataField$xComponen === void 0 ? void 0 : _dataField$xComponen.displayField) === 'value' ? fallbackFormatter : null) !== null && _ref8 !== void 0 ? _ref8 : (!readOnly || renderer) && component && (dataField === null || dataField === void 0 ? void 0 : dataField.type) !== 'void' ? fallbackFormatter : null;
750
+ var displayColumnProps = formatter && (getReadOnlyFormatter(component, components) !== getReadOnlyFormatter(component) || (dataField === null || dataField === void 0 || (_dataField$xComponen2 = dataField['x-component-props']) === null || _dataField$xComponen2 === void 0 ? void 0 : _dataField$xComponen2.displayField) === 'value') ? {
751
+ valueFormatter: function valueFormatter(params) {
752
+ return formatter(params.value, {
753
+ columnProps: columnProps,
754
+ fieldSchema: dataField
755
+ });
756
+ }
757
+ } : {};
684
758
  var hasReactions = !!(dataField && dataField['x-reactions']);
685
759
  if (!readOnly) applyNumberInputDefaults(dataField);
686
760
  var forceEager = (columnProps === null || columnProps === void 0 ? void 0 : columnProps.forceAgField) === true;
@@ -697,9 +771,11 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
697
771
  // 两者不一致时 record[name] 恒为 undefined → 单元格空白(点击挂 AgField 才按内层字段名显真值)。
698
772
  // 故按内层字段名补 valueGetter(仅在与 name 不一致时,保持 name===字段名 的现状)。@author nokecy
699
773
  var dataFieldName = dataField === null || dataField === void 0 ? void 0 : dataField.name;
700
- var valueGetter = dataFieldName && dataFieldName !== name ? function (params) {
774
+ var valueGetter = !columnProps.valueGetter && dataFieldName && dataFieldName !== name ? function (params) {
701
775
  return readByFieldPath(params === null || params === void 0 ? void 0 : params.data, dataFieldName);
702
776
  } : undefined;
777
+ // 选择器解构值仍交给渲染器;排序单独提取展示字段,不能把整对象当成相等的文本。@author nokecy
778
+ if ((!dataField || dataField.type === 'void') && !columnProps.valueGetter && columnProps.sortable == null) base.sortable = false;else if (dataField && !base.comparator) base.comparator = createArrayTableComparator(dataField, columnProps, formatter);
703
779
  // 字段名是路径:`item.qty` 的值在 record.item.qty。快路径自己解析点号分段与对象解构(`{value:a,label:b}`);
704
780
  // 数组解构/下标等其余语法解析不了,回退全树交给 Formily。@author nokecy
705
781
  var canFastPath = !dataFieldName || isFastPathFieldName(dataFieldName);
@@ -715,6 +791,7 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
715
791
  } : {}), {}, {
716
792
  cellRenderer: LazyReadOnlyText,
717
793
  cellRendererParams: {
794
+ field: field,
718
795
  formatter: formatter,
719
796
  renderer: renderer,
720
797
  columnProps: columnProps,
@@ -775,11 +852,13 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
775
852
  // 必填、或带校验规则且为空的格必须挂真控件,否则没有字段节点,提交时没人校验它,见 LazyAgField
776
853
  required: isRequiredSchema(dataField) || hasValidatorRule(dataField)
777
854
  }
778
- }));
855
+ }, displayColumnProps));
779
856
  }
780
857
 
781
858
  // ③ 兜底全树
782
- return emit(_objectSpread(_objectSpread({}, base), {}, {
859
+ return emit(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, base), valueGetter ? {
860
+ valueGetter: valueGetter
861
+ } : {}), displayColumnProps), {}, {
783
862
  cellRendererParams: {
784
863
  dataSource: dataSource,
785
864
  schema: schema,
@@ -822,9 +901,9 @@ export var collectLazyDefaults = function collectLazyDefaults(columns) {
822
901
  key: String((_fieldSchema$name3 = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) !== null && _fieldSchema$name3 !== void 0 ? _fieldSchema$name3 : col.field),
823
902
  value: fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.default
824
903
  };
825
- }).filter(function (_ref7) {
826
- var key = _ref7.key,
827
- value = _ref7.value;
904
+ }).filter(function (_ref9) {
905
+ var key = _ref9.key,
906
+ value = _ref9.value;
828
907
  return SIMPLE_FIELD_NAME.test(key) && value !== undefined && value !== null && !(typeof value === 'string' && value.includes('{{'));
829
908
  });
830
909
  };
@@ -843,9 +922,9 @@ export var applyLazyDefaults = function applyLazyDefaults(arrayField, defaults,
843
922
  // 已落库的行(带 id)保持库里的样子:补默认值会让受控字段凭空出现「变更」,
844
923
  // 已审批的数据保存时还会被要求填变更原因。只补新增行(按钮之外的途径推进来的行)。
845
924
  if (row.id != null || row._id != null) return;
846
- defaults.forEach(function (_ref8) {
847
- var key = _ref8.key,
848
- value = _ref8.value;
925
+ defaults.forEach(function (_ref10) {
926
+ var key = _ref10.key,
927
+ value = _ref10.value;
849
928
  if (row[key] == null) {
850
929
  form.setValuesIn(arrayField.path.concat(index).concat(key), _typeof(value) === 'object' ? JSON.parse(JSON.stringify(value)) : value);
851
930
  }