@nokecy/qc-ui 1.1.87 → 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 (98) 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/interface.d.ts +2 -0
  4. package/dist/cjs/ag-grid-plus/queryForm/index.d.ts +2 -0
  5. package/dist/cjs/ag-grid-plus/queryForm/index.js +47 -51
  6. package/dist/cjs/ag-grid-plus/queryForm/queryColumns.d.ts +8 -0
  7. package/dist/cjs/ag-grid-plus/queryForm/queryColumns.js +52 -0
  8. package/dist/cjs/ag-grid-plus/queryForm/schemaKey.d.ts +15 -8
  9. package/dist/cjs/ag-grid-plus/queryForm/schemaKey.js +64 -12
  10. package/dist/cjs/ag-grid-plus/setting/ColumnConfigForm.js +3 -0
  11. package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +69 -106
  12. package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +3 -1
  13. package/dist/cjs/ag-grid-plus/setting/columnGroupTypes.d.ts +2 -0
  14. package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.d.ts +14 -0
  15. package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.js +98 -110
  16. package/dist/cjs/ag-grid-plus/types.d.ts +6 -0
  17. package/dist/cjs/array-table/batchRemove.d.ts +36 -0
  18. package/dist/cjs/array-table/batchRemove.js +299 -0
  19. package/dist/cjs/array-table/cellFocusScope.js +44 -8
  20. package/dist/cjs/array-table/cellInteractionLock.d.ts +13 -0
  21. package/dist/cjs/array-table/cellInteractionLock.js +26 -0
  22. package/dist/cjs/array-table/hooks.d.ts +11 -6
  23. package/dist/cjs/array-table/hooks.js +138 -88
  24. package/dist/cjs/array-table/index.d.ts +8 -2
  25. package/dist/cjs/array-table/index.js +55 -32
  26. package/dist/cjs/array-table/indexColumn.d.ts +1 -1
  27. package/dist/cjs/array-table/indexColumn.js +3 -2
  28. package/dist/cjs/array-table/interface.d.ts +13 -1
  29. package/dist/cjs/array-table/preview.js +8 -0
  30. package/dist/cjs/array-table/readOnlyFormatters.d.ts +9 -1
  31. package/dist/cjs/array-table/readOnlyFormatters.js +41 -13
  32. package/dist/cjs/array-table/rowIdentity.d.ts +17 -0
  33. package/dist/cjs/array-table/rowIdentity.js +43 -0
  34. package/dist/cjs/array-table/sorting.d.ts +3 -0
  35. package/dist/cjs/array-table/sorting.js +46 -0
  36. package/dist/cjs/array-table/utils.js +146 -67
  37. package/dist/cjs/dialogSelect/index.d.ts +3 -0
  38. package/dist/cjs/dialogSelect/index.js +13 -3
  39. package/dist/cjs/editable/index.js +101 -139
  40. package/dist/cjs/index.d.ts +2 -2
  41. package/dist/cjs/index.js +14 -0
  42. package/dist/cjs/readPretty/arrayTable.js +29 -14
  43. package/dist/cjs/readPretty/formily.d.ts +1 -0
  44. package/dist/cjs/readPretty/formily.js +7 -0
  45. package/dist/cjs/readPretty/index.d.ts +1 -0
  46. package/dist/cjs/readPretty/index.js +7 -0
  47. package/dist/cjs/readPretty/schemaScope.d.ts +2 -0
  48. package/dist/cjs/readPretty/schemaScope.js +49 -0
  49. package/dist/esm/ag-grid-plus/ag-gridPlus.js +148 -144
  50. package/dist/esm/ag-grid-plus/context/useSchemeDataFlow.js +4 -4
  51. package/dist/esm/ag-grid-plus/interface.d.ts +2 -0
  52. package/dist/esm/ag-grid-plus/queryForm/index.d.ts +2 -0
  53. package/dist/esm/ag-grid-plus/queryForm/index.js +47 -52
  54. package/dist/esm/ag-grid-plus/queryForm/queryColumns.d.ts +8 -0
  55. package/dist/esm/ag-grid-plus/queryForm/queryColumns.js +46 -0
  56. package/dist/esm/ag-grid-plus/queryForm/schemaKey.d.ts +15 -8
  57. package/dist/esm/ag-grid-plus/queryForm/schemaKey.js +64 -12
  58. package/dist/esm/ag-grid-plus/setting/ColumnConfigForm.js +3 -0
  59. package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +70 -107
  60. package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +3 -1
  61. package/dist/esm/ag-grid-plus/setting/columnGroupTypes.d.ts +2 -0
  62. package/dist/esm/ag-grid-plus/setting/columnGroupUtils.d.ts +14 -0
  63. package/dist/esm/ag-grid-plus/setting/columnGroupUtils.js +95 -110
  64. package/dist/esm/ag-grid-plus/types.d.ts +6 -0
  65. package/dist/esm/array-table/batchRemove.d.ts +36 -0
  66. package/dist/esm/array-table/batchRemove.js +289 -0
  67. package/dist/esm/array-table/cellFocusScope.js +45 -9
  68. package/dist/esm/array-table/cellInteractionLock.d.ts +13 -0
  69. package/dist/esm/array-table/cellInteractionLock.js +21 -0
  70. package/dist/esm/array-table/hooks.d.ts +11 -6
  71. package/dist/esm/array-table/hooks.js +139 -89
  72. package/dist/esm/array-table/index.d.ts +8 -2
  73. package/dist/esm/array-table/index.js +55 -32
  74. package/dist/esm/array-table/indexColumn.d.ts +1 -1
  75. package/dist/esm/array-table/indexColumn.js +3 -2
  76. package/dist/esm/array-table/interface.d.ts +13 -1
  77. package/dist/esm/array-table/preview.js +8 -0
  78. package/dist/esm/array-table/readOnlyFormatters.d.ts +9 -1
  79. package/dist/esm/array-table/readOnlyFormatters.js +41 -12
  80. package/dist/esm/array-table/rowIdentity.d.ts +17 -0
  81. package/dist/esm/array-table/rowIdentity.js +37 -0
  82. package/dist/esm/array-table/sorting.d.ts +3 -0
  83. package/dist/esm/array-table/sorting.js +40 -0
  84. package/dist/esm/array-table/utils.js +147 -68
  85. package/dist/esm/dialogSelect/index.d.ts +3 -0
  86. package/dist/esm/dialogSelect/index.js +13 -3
  87. package/dist/esm/editable/index.js +102 -140
  88. package/dist/esm/index.d.ts +2 -2
  89. package/dist/esm/index.js +1 -1
  90. package/dist/esm/readPretty/arrayTable.js +30 -13
  91. package/dist/esm/readPretty/formily.d.ts +1 -0
  92. package/dist/esm/readPretty/formily.js +1 -0
  93. package/dist/esm/readPretty/index.d.ts +1 -0
  94. package/dist/esm/readPretty/index.js +1 -0
  95. package/dist/esm/readPretty/schemaScope.d.ts +2 -0
  96. package/dist/esm/readPretty/schemaScope.js +42 -0
  97. package/dist/umd/qc-ui.min.js +1 -1
  98. package/package.json +1 -1
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.registerReadOnlyRenderer = exports.registerReadOnlyLabels = exports.registerReadOnlyFormatter = exports.getReadOnlyRenderer = exports.getReadOnlyFormatter = exports.fallbackFormatter = void 0;
6
+ exports.withReadOnlyFormatter = exports.registerReadOnlyRenderer = exports.registerReadOnlyLabels = exports.registerReadOnlyFormatter = exports.getReadOnlyRenderer = exports.getReadOnlyFormatter = exports.formatSelectDisplay = exports.fallbackFormatter = void 0;
7
7
  var _dayjs = _interopRequireDefault(require("dayjs"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -27,6 +27,26 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
27
27
  *
28
28
  * @author nokecy
29
29
  */
30
+ /** 选择器的展示字段;只影响回显,不改变 labelInValue 的提交值。@author nokecy */
31
+
32
+ /** 从选择值提取展示文字;编码展示不能因描述为空或过期而改变。@author nokecy */
33
+ var formatSelectDisplay = exports.formatSelectDisplay = function formatSelectDisplay(value) {
34
+ var _value$label;
35
+ var displayField = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'label';
36
+ if (value == null) return '';
37
+ if (Array.isArray(value)) return value.map(function (item) {
38
+ return formatSelectDisplay(item, displayField);
39
+ }).filter(Boolean).join(', ');
40
+ if (_typeof(value) === 'object') return formatSelectDisplay(displayField === 'value' ? value.value : (_value$label = value.label) !== null && _value$label !== void 0 ? _value$label : value.value, displayField);
41
+ return String(value);
42
+ };
43
+
44
+ /** 给选择组件声明与其回显一致的表格格式化器,组件别名和不同页面各自生效。@author nokecy */
45
+ var withReadOnlyFormatter = exports.withReadOnlyFormatter = function withReadOnlyFormatter(component, formatter) {
46
+ return Object.assign(component, {
47
+ readOnlyFormatter: formatter
48
+ });
49
+ };
30
50
  /** 从字段 schema / 列 props 里尽量取到 Select 的可选项(value->label 映射用) */
31
51
  var resolveOptions = function resolveOptions(ctx) {
32
52
  var _ref, _ref2, _ref3, _fieldSchema$enum, _fieldSchema$xCompon, _fieldSchema$xCompon2;
@@ -39,10 +59,10 @@ var resolveOptions = function resolveOptions(ctx) {
39
59
 
40
60
  /** 单个值映射成 label:兼容 labelInValue 对象、{label,value} 选项、原始值 */
41
61
  var mapOptionLabel = function mapOptionLabel(value, options) {
42
- var _ref4, _value$label, _ref5, _hit$label;
62
+ var _ref4, _value$label2, _ref5, _hit$label;
43
63
  if (value == null) return '';
44
64
  // labelInValue: 值本身就是 { label, value }
45
- 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 : '');
65
+ 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 : '');
46
66
  // 严格相等优先;退一步按 String 宽松比对,容忍后端类型漂移(如返回 "0" 而 enum 存数字 0)
47
67
  var hit = options.find(function (o) {
48
68
  var ov = o && _typeof(o) === 'object' ? o.value : o;
@@ -55,7 +75,9 @@ var textFormatter = function textFormatter(value) {
55
75
  return value == null ? '' : String(value);
56
76
  };
57
77
  var selectFormatter = function selectFormatter(value, ctx) {
78
+ var _ctx$fieldSchema;
58
79
  if (value == null) return '';
80
+ 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');
59
81
  var options = resolveOptions(ctx);
60
82
  // 多选:数组 -> 逗号拼接
61
83
  if (Array.isArray(value)) {
@@ -79,14 +101,14 @@ var defaultDateFormat = function defaultDateFormat(component, props) {
79
101
  return 'YYYY-MM-DD';
80
102
  };
81
103
  var dateFormatter = function dateFormatter(value, ctx) {
82
- var _ctx$fieldSchema, _ctx$columnProps, _ctx$fieldSchema2;
104
+ var _ctx$fieldSchema2, _ctx$columnProps, _ctx$fieldSchema3;
83
105
  if (value == null || value === '') return '';
84
- var props = (_ctx$fieldSchema = ctx.fieldSchema) === null || _ctx$fieldSchema === void 0 ? void 0 : _ctx$fieldSchema['x-component-props'];
106
+ var props = (_ctx$fieldSchema2 = ctx.fieldSchema) === null || _ctx$fieldSchema2 === void 0 ? void 0 : _ctx$fieldSchema2['x-component-props'];
85
107
  // antd 的 format 还可以是数组/函数,文本态只认字符串,其余回到默认
86
108
  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) {
87
109
  return typeof f === 'string' && f;
88
110
  });
89
- 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);
111
+ 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);
90
112
  if (typeof value.format === 'function') return value.format(fmt);
91
113
  // 后端回来的多是 ISO 串(2024-10-19T00:00:00)或时间戳:与 Formily readPretty 一致,按 dayjs(value).format(fmt) 显示;
92
114
  // 解析不了的文本(如「待定」、纯时间 08:30:00)原样显示,不吞掉。dayjs 随 antd 传递依赖引入,本库其他模块已直接使用。
@@ -99,9 +121,9 @@ var dateFormatter = function dateFormatter(value, ctx) {
99
121
  * 与点开后的 InputNumber 一致;没配这两项时与原样输出相同。
100
122
  */
101
123
  var numberFormatter = function numberFormatter(value, ctx) {
102
- var _ctx$fieldSchema$xCo, _ctx$fieldSchema3, _ctx$columnProps$prec, _ctx$columnProps2, _ctx$columnProps$form, _ctx$columnProps3;
124
+ var _ctx$fieldSchema$xCo, _ctx$fieldSchema4, _ctx$columnProps$prec, _ctx$columnProps2, _ctx$columnProps$form, _ctx$columnProps3;
103
125
  if (value == null || value === '') return '';
104
- 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 : {};
126
+ 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 : {};
105
127
  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;
106
128
  var num = Number(value);
107
129
  var base = typeof precision === 'number' && precision >= 0 && Number.isFinite(num) ? num.toFixed(precision) : String(value);
@@ -119,9 +141,9 @@ var numberFormatter = function numberFormatter(value, ctx) {
119
141
  return base;
120
142
  };
121
143
  var booleanFormatter = function booleanFormatter(value, ctx) {
122
- var _ctx$fieldSchema$xCo2, _ctx$fieldSchema4, _props$checkedChildre, _props$unCheckedChild;
144
+ var _ctx$fieldSchema$xCo2, _ctx$fieldSchema5, _props$checkedChildre, _props$unCheckedChild;
123
145
  if (value == null || value === '') return '';
124
- 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 : {};
146
+ 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 : {};
125
147
  var truthy = (_props$checkedChildre = props.checkedChildren) !== null && _props$checkedChildre !== void 0 ? _props$checkedChildre : '是';
126
148
  var falsy = (_props$unCheckedChild = props.unCheckedChildren) !== null && _props$unCheckedChild !== void 0 ? _props$unCheckedChild : '否';
127
149
  return value ? String(truthy) : String(falsy);
@@ -158,15 +180,17 @@ var registry = {
158
180
  * 消费方用 registerReadOnlyFormatter 注册专用格式化器覆盖。@author nokecy
159
181
  */
160
182
  var fallbackFormatter = exports.fallbackFormatter = function fallbackFormatter(value, ctx) {
183
+ var _ctx$fieldSchema6;
161
184
  if (value == null || value === '') return '';
185
+ 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');
162
186
  if (Array.isArray(value)) return value.map(function (v) {
163
187
  return fallbackFormatter(v, ctx);
164
188
  }).filter(Boolean).join(', ');
165
189
  if (typeof value === 'boolean') return booleanFormatter(value, ctx);
166
190
  if (_typeof(value) === 'object') {
167
- var _value$label2;
191
+ var _value$label3;
168
192
  if (typeof value.format === 'function') return dateFormatter(value, ctx);
169
- var shown = (_value$label2 = value.label) !== null && _value$label2 !== void 0 ? _value$label2 : value.value;
193
+ var shown = (_value$label3 = value.label) !== null && _value$label3 !== void 0 ? _value$label3 : value.value;
170
194
  return shown == null ? '' : String(shown);
171
195
  }
172
196
  return String(value);
@@ -242,8 +266,12 @@ var getReadOnlyRenderer = exports.getReadOnlyRenderer = function getReadOnlyRend
242
266
  /**
243
267
  * 取某组件类型的只读格式化器。命中返回函数,未命中返回 null(调用方回退 AgField)。
244
268
  */
245
- var getReadOnlyFormatter = exports.getReadOnlyFormatter = function getReadOnlyFormatter(component) {
269
+ var getReadOnlyFormatter = exports.getReadOnlyFormatter = function getReadOnlyFormatter(component, components) {
246
270
  var _registry$component;
247
271
  if (!component) return null;
272
+ var control = component.split('.').reduce(function (current, key) {
273
+ return current === null || current === void 0 ? void 0 : current[key];
274
+ }, components);
275
+ if (typeof (control === null || control === void 0 ? void 0 : control.readOnlyFormatter) === 'function') return control.readOnlyFormatter;
248
276
  return (_registry$component = registry[component]) !== null && _registry$component !== void 0 ? _registry$component : null;
249
277
  };
@@ -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,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getArrayTableRowId = exports.ensureArrayTableRowIds = void 0;
7
+ var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ 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); }
10
+ /**
11
+ * 读取业务行标识;尚未补入表单的行按对象缓存临时标识,不在渲染期间改写表单。
12
+ * @param row 明细行。
13
+ * @param generatedIds 当前表格已分配的临时行标识。
14
+ * @returns AG-Grid 使用的稳定字符串标识。
15
+ * @author nokecy
16
+ */
17
+ var getArrayTableRowId = exports.getArrayTableRowId = function getArrayTableRowId(row, generatedIds) {
18
+ var _row$_id;
19
+ var existingId = (_row$_id = row._id) !== null && _row$_id !== void 0 ? _row$_id : row.id;
20
+ if (existingId != null) return String(existingId);
21
+ var generatedId = generatedIds.get(row);
22
+ if (!generatedId) {
23
+ generatedId = (0, _uniqueId.default)('row_');
24
+ generatedIds.set(row, generatedId);
25
+ }
26
+ return generatedId;
27
+ };
28
+
29
+ /**
30
+ * 在 effect 中为缺少业务标识的明细补入可枚举 _id,使业务克隆行时保留 AG-Grid 行身份。
31
+ * 复用首次渲染已分配的标识,补值本身不会使单元格重挂;已有 _id/id(含 0)保持原值。
32
+ * @param field 当前明细数组字段。
33
+ * @param generatedIds 当前表格已分配的临时行标识。
34
+ * @author nokecy
35
+ */
36
+ var ensureArrayTableRowIds = exports.ensureArrayTableRowIds = function ensureArrayTableRowIds(field, generatedIds) {
37
+ if (!Array.isArray(field.value)) return;
38
+ field.value.forEach(function (row, index) {
39
+ var _row$_id2;
40
+ if (row == null || _typeof(row) !== 'object' || ((_row$_id2 = row._id) !== null && _row$_id2 !== void 0 ? _row$_id2 : row.id) != null) return;
41
+ field.form.setValuesIn(field.path.concat(index).concat('_id'), getArrayTableRowId(row, generatedIds));
42
+ });
43
+ };
@@ -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,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createArrayTableComparator = void 0;
7
+ var _decimal = _interopRequireDefault(require("decimal.js"));
8
+ var _dayjs = _interopRequireDefault(require("dayjs"));
9
+ var _readOnlyFormatters = require("./readOnlyFormatters");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ 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); }
12
+ /** 按列的展示字段和数据类型比较明细值,保留原始选择对象供表单绑定使用。@author nokecy */
13
+ var createArrayTableComparator = exports.createArrayTableComparator = function createArrayTableComparator(fieldSchema, columnProps, formatter) {
14
+ var _fieldSchema$xCompon, _fieldSchema$xCompon2;
15
+ var component = String((_fieldSchema$xCompon = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component']) !== null && _fieldSchema$xCompon !== void 0 ? _fieldSchema$xCompon : '');
16
+ 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) {
17
+ return type === 'numericColumn' || type === 'numberColumn';
18
+ });
19
+ var temporal = /^(DatePicker|TimePicker)(\.|$)/.test(component);
20
+ 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';
21
+ var scalar = function scalar(value) {
22
+ var _value$label;
23
+ if (value == null) return null;
24
+ if (Array.isArray(value)) return (0, _readOnlyFormatters.formatSelectDisplay)(value, displayField);
25
+ 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);
26
+ if (temporal && (0, _dayjs.default)(value).isValid()) return (0, _dayjs.default)(value).valueOf();
27
+ if (numeric || typeof value === 'number' || typeof value === 'boolean') return value;
28
+ return formatter ? formatter(value, {
29
+ columnProps: columnProps,
30
+ fieldSchema: fieldSchema
31
+ }) : String(value);
32
+ };
33
+ return function (a, b) {
34
+ var left = scalar(a);
35
+ var right = scalar(b);
36
+ if (left == null || left === '') return right == null || right === '' ? 0 : -1;
37
+ if (right == null || right === '') return 1;
38
+ if (numeric || temporal || typeof left === 'number' && typeof right === 'number') {
39
+ try {
40
+ return new _decimal.default(left).cmp(new _decimal.default(right));
41
+ } catch (_unused) {/* 无效数值按展示文字排序。 */}
42
+ }
43
+ if (typeof left === 'boolean' && typeof right === 'boolean') return Number(left) - Number(right);
44
+ return String(left).localeCompare(String(right), 'zh-CN');
45
+ };
46
+ };