@nokecy/qc-ui 1.1.96 → 1.1.97

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.
@@ -20,6 +20,7 @@ var _antdV = require("@formily/antd-v5");
20
20
  var _lodash = require("lodash");
21
21
  var _constants = require("./constants");
22
22
  var _valueEnumColor = require("./valueEnumColor");
23
+ var _optionValue = require("../../utils/optionValue");
23
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
25
  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); }
25
26
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -169,16 +170,16 @@ function processEnumColumn(col, dataType, background) {
169
170
 
170
171
  // 值格式化函数
171
172
  var valueFormatter = function valueFormatter(params) {
172
- var match = valueEnum.find(function (item) {
173
- return item.value == params.value;
173
+ var match = (0, _optionValue.findOptionByValue)(valueEnum, params.value, function (item) {
174
+ return item.value;
174
175
  });
175
176
  return match ? match.label : params.value;
176
177
  };
177
178
  var fallbackRenderer = col.enumFallbackRenderer;
178
179
  return _objectSpread(_objectSpread(_objectSpread({}, toColumnType(dataType)), col), {}, {
179
180
  cellRenderer: function cellRenderer(params) {
180
- var match = valueEnum.find(function (item) {
181
- return item.value == params.value;
181
+ var match = (0, _optionValue.findOptionByValue)(valueEnum, params.value, function (item) {
182
+ return item.value;
182
183
  });
183
184
  if (match) {
184
185
  // 没配颜色的枚举项曾经默认成 '#ffffff'——白底白字,那一列直接看不见。
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
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
+ var _optionValue = require("../utils/optionValue");
8
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
10
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
11
  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."); }
@@ -59,16 +60,18 @@ var resolveOptions = function resolveOptions(ctx) {
59
60
 
60
61
  /** 单个值映射成 label:兼容 labelInValue 对象、{label,value} 选项、原始值 */
61
62
  var mapOptionLabel = function mapOptionLabel(value, options) {
62
- var _ref4, _value$label2, _ref5, _hit$label;
63
+ var _ref4, _hit$label;
63
64
  if (value == null) return '';
64
65
  // labelInValue: 值本身就是 { label, value }
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 : '');
66
- // 严格相等优先;退一步按 String 宽松比对,容忍后端类型漂移(如返回 "0" 而 enum 存数字 0)
67
- var hit = options.find(function (o) {
68
- var ov = o && _typeof(o) === 'object' ? o.value : o;
69
- return ov === value || String(ov) === String(value);
66
+ if (_typeof(value) === 'object') {
67
+ var label = value.label;
68
+ return label != null && label !== value.value ? String(label) : mapOptionLabel(value.value, options);
69
+ }
70
+ // 定长码值可能带补齐空格;与编辑控件、列表使用同一选项匹配规则。@author nokecy
71
+ var hit = (0, _optionValue.findOptionByValue)(options, value, function (o) {
72
+ return o && _typeof(o) === 'object' ? o.value : o;
70
73
  });
71
- if (hit && _typeof(hit) === 'object') return String((_ref5 = (_hit$label = hit.label) !== null && _hit$label !== void 0 ? _hit$label : hit.value) !== null && _ref5 !== void 0 ? _ref5 : value);
74
+ if (hit && _typeof(hit) === 'object') return String((_ref4 = (_hit$label = hit.label) !== null && _hit$label !== void 0 ? _hit$label : hit.value) !== null && _ref4 !== void 0 ? _ref4 : value);
72
75
  return String(value);
73
76
  };
74
77
  var textFormatter = function textFormatter(value) {
@@ -188,9 +191,9 @@ var fallbackFormatter = exports.fallbackFormatter = function fallbackFormatter(v
188
191
  }).filter(Boolean).join(', ');
189
192
  if (typeof value === 'boolean') return booleanFormatter(value, ctx);
190
193
  if (_typeof(value) === 'object') {
191
- var _value$label3;
194
+ var _value$label2;
192
195
  if (typeof value.format === 'function') return dateFormatter(value, ctx);
193
- var shown = (_value$label3 = value.label) !== null && _value$label3 !== void 0 ? _value$label3 : value.value;
196
+ var shown = (_value$label2 = value.label) !== null && _value$label2 !== void 0 ? _value$label2 : value.value;
194
197
  return shown == null ? '' : String(shown);
195
198
  }
196
199
  return String(value);
@@ -220,18 +223,20 @@ var registerReadOnlyLabels = exports.registerReadOnlyLabels = function registerR
220
223
  if (o && o.value != null) map.set(String(o.value), String((_o$label = o.label) !== null && _o$label !== void 0 ? _o$label : o.value));
221
224
  });
222
225
  } else {
223
- Object.entries(labels !== null && labels !== void 0 ? labels : {}).forEach(function (_ref6) {
224
- var _ref7 = _slicedToArray(_ref6, 2),
225
- k = _ref7[0],
226
- v = _ref7[1];
226
+ Object.entries(labels !== null && labels !== void 0 ? labels : {}).forEach(function (_ref5) {
227
+ var _ref6 = _slicedToArray(_ref5, 2),
228
+ k = _ref6[0],
229
+ v = _ref6[1];
227
230
  return map.set(String(k), String(v));
228
231
  });
229
232
  }
230
233
  var toText = function toText(v) {
231
- var _ref8, _v$label, _map$get;
232
234
  if (v == null || v === '') return '';
233
- if (_typeof(v) === 'object') return String((_ref8 = (_v$label = v.label) !== null && _v$label !== void 0 ? _v$label : v.value) !== null && _ref8 !== void 0 ? _ref8 : '');
234
- return (_map$get = map.get(String(v))) !== null && _map$get !== void 0 ? _map$get : String(v);
235
+ if (_typeof(v) === 'object') return v.label != null && v.label !== v.value ? String(v.label) : toText(v.value);
236
+ var key = (0, _optionValue.findOptionByValue)(Array.from(map.keys()), v, function (key) {
237
+ return key;
238
+ });
239
+ return key === undefined ? String(v) : map.get(key);
235
240
  };
236
241
  var formatter = function formatter(value) {
237
242
  return Array.isArray(value) ? value.map(toText).filter(Boolean).join(', ') : toText(value);
@@ -534,12 +534,24 @@ var LazyAgField = exports.LazyAgField = function LazyAgField(params) {
534
534
  // 改值(行引用不变 → AG-Grid 不刷新该格、外层 observer 也不重渲)时,本格能自行重渲刷新——
535
535
  // 免去调用方加 forceAgField 逃生阀。字段名缺失才回退 params.value。@author nokecy
536
536
  return /*#__PURE__*/_react.default.createElement(_react2.Observer, null, function () {
537
+ var _fieldSchema$xCompon2;
537
538
  var _resolveCellRow3 = resolveCellRow(field, record, node, dataSource),
538
539
  currentRecord = _resolveCellRow3.record;
539
540
  if (!currentRecord) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
540
541
  var activated = activeCells.has(key);
541
542
  // 已挂载时不读值:挂载后每敲一个字都会变,追踪它会让整棵字段树跟着重渲
542
543
  var liveValue = activated ? undefined : dataKey != null ? readByFieldPath(currentRecord, dataKey) : value;
544
+ // 解构选择值缺少名称时仍要让业务组件补全名称;有名称后才可降为静默文本。@author nokecy
545
+ if (!activated && formatter === _readOnlyFormatters.fallbackFormatter && liveValue && _typeof(liveValue) === 'object' && !Array.isArray(liveValue) && liveValue.value != null && (liveValue.label == null || liveValue.label === '' || liveValue.label === liveValue.value) && (fieldSchema === null || fieldSchema === void 0 || (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.displayField) !== 'value') {
546
+ return /*#__PURE__*/_react.default.createElement(AgField, {
547
+ value: value,
548
+ data: currentRecord,
549
+ dataSource: dataSource,
550
+ schema: schema,
551
+ field: field,
552
+ node: node
553
+ });
554
+ }
543
555
  // Editable 装饰器会把非新增行的格转成只读态、不参与校验(见 editable/index.tsx),
544
556
  // 这时挂了没用,还会把灰色「请输入」占位换成只读态的「N/A」,所以留在文本态
545
557
  var editableWillReadPretty = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-decorator']) === 'Editable' && currentRecord._isNew !== true;
@@ -710,7 +722,7 @@ var applyNumberInputDefaults = function applyNumberInputDefaults(dataField) {
710
722
  var buildArrayTableColumns = exports.buildArrayTableColumns = function buildArrayTableColumns(dataSource, field, sources) {
711
723
  var arrayPattern = field === null || field === void 0 ? void 0 : field.pattern;
712
724
  return sources.reduce(function (buf, _ref7, key) {
713
- var _dataField$xDecorato, _ref8, _getReadOnlyFormatter, _dataField$xComponen, _dataField$xComponen2;
725
+ var _dataField$xDecorato, _ref8, _getReadOnlyFormatter, _dataField$xComponen, _parseObjectDestructu, _dataField$xComponen2, _dataField$xComponen3, _dataField$xComponen4, _dataField$xComponen5;
714
726
  var name = _ref7.name,
715
727
  columnProps = _ref7.columnProps,
716
728
  schema = _ref7.schema,
@@ -761,11 +773,15 @@ var buildArrayTableColumns = exports.buildArrayTableColumns = function buildArra
761
773
  // 格子先出廉价文本、点击/导航(或必填且为空)才挂全树,焦点离开且校验通过再卸回文本。
762
774
  // ③ 兜底全树:其余(无格式化器/带 reactions/forceAgField/复杂字段名/只读但无格式化器) -> AgField。
763
775
  var component = dataField === null || dataField === void 0 ? void 0 : dataField['x-component'];
764
- // 可编辑的数据字段(非 void 操作按钮)即使是业务自定义组件,也按兜底格式化器出懒挂载文本,默认阅读态;
765
- // 只读列不兜底:自定义只读组件常显示别的字段(如 SiblingText),按自身值出文本会错。@author nokecy
766
- // 登记了只读渲染器的组件只读列也走快路径(渲染器出内容,兜底格式化器只用于判空)。@author nokecy
776
+ // 未声明显示规则的业务组件必须挂载:单位选择器等会读取同行名称或异步加载候选,
777
+ // 仅把标量码交给 fallback 会跳过这些逻辑。解构值自带名称、显式编码展示及已登记格式化器仍走快路径。
778
+ // 登记渲染器的组件只读列也可用兜底格式化器判空。@author nokecy
767
779
  var renderer = (0, _readOnlyFormatters.getReadOnlyRenderer)(component);
768
- var formatter = (_ref8 = (_getReadOnlyFormatter = (0, _readOnlyFormatters.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' ? _readOnlyFormatters.fallbackFormatter : null) !== null && _ref8 !== void 0 ? _ref8 : (!readOnly || renderer) && component && (dataField === null || dataField === void 0 ? void 0 : dataField.type) !== 'void' ? _readOnlyFormatters.fallbackFormatter : null;
780
+ var formatter = (_ref8 = (_getReadOnlyFormatter = (0, _readOnlyFormatters.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' ? _readOnlyFormatters.fallbackFormatter : null) !== null && _ref8 !== void 0 ? _ref8 : (!readOnly || renderer) && (renderer || (_parseObjectDestructu = parseObjectDestructure(dataField === null || dataField === void 0 ? void 0 : dataField.name)) !== null && _parseObjectDestructu !== void 0 && _parseObjectDestructu.some(function (_ref9) {
781
+ var _ref10 = _slicedToArray(_ref9, 1),
782
+ key = _ref10[0];
783
+ return key === 'label';
784
+ })) && component && (dataField === null || dataField === void 0 ? void 0 : dataField.type) !== 'void' ? _readOnlyFormatters.fallbackFormatter : null;
769
785
  var displayColumnProps = formatter && ((0, _readOnlyFormatters.getReadOnlyFormatter)(component, components) !== (0, _readOnlyFormatters.getReadOnlyFormatter)(component) || (dataField === null || dataField === void 0 || (_dataField$xComponen2 = dataField['x-component-props']) === null || _dataField$xComponen2 === void 0 ? void 0 : _dataField$xComponen2.displayField) === 'value') ? {
770
786
  valueFormatter: function valueFormatter(params) {
771
787
  return formatter(params.value, {
@@ -776,7 +792,14 @@ var buildArrayTableColumns = exports.buildArrayTableColumns = function buildArra
776
792
  } : {};
777
793
  var hasReactions = !!(dataField && dataField['x-reactions']);
778
794
  if (!readOnly) applyNumberInputDefaults(dataField);
779
- var forceEager = (columnProps === null || columnProps === void 0 ? void 0 : columnProps.forceAgField) === true;
795
+ // 表达式或运行时选项必须创建字段才能求值/加载,不能在没有名称表时直接显示码值。@author nokecy
796
+ var hasOptionExpression = [dataField === null || dataField === void 0 ? void 0 : dataField.enum, dataField === null || dataField === void 0 || (_dataField$xComponen3 = dataField['x-component-props']) === null || _dataField$xComponen3 === void 0 ? void 0 : _dataField$xComponen3.options, dataField === null || dataField === void 0 || (_dataField$xComponen4 = dataField['x-component-props']) === null || _dataField$xComponen4 === void 0 ? void 0 : _dataField$xComponen4.dataSource, columnProps === null || columnProps === void 0 ? void 0 : columnProps.options, columnProps === null || columnProps === void 0 ? void 0 : columnProps.dataSource].some(function (options) {
797
+ return typeof options === 'string' && options.includes('{{');
798
+ });
799
+ // 格式化表达式依赖本页 scope 与本行字段,交给 Formily 创建真实字段后编译。@author nokecy
800
+ var schemaFormatter = dataField === null || dataField === void 0 || (_dataField$xComponen5 = dataField['x-component-props']) === null || _dataField$xComponen5 === void 0 ? void 0 : _dataField$xComponen5.formatter;
801
+ var hasFormatterExpression = typeof schemaFormatter === 'string' && schemaFormatter.includes('{{');
802
+ var forceEager = (columnProps === null || columnProps === void 0 ? void 0 : columnProps.forceAgField) === true || formatter === (0, _readOnlyFormatters.getReadOnlyFormatter)('Select') && hasOptionExpression || hasFormatterExpression;
780
803
  // Switch/Checkbox 是「单击直控」组件:可编辑态本就该常驻渲染真控件(优化前即如此)。
781
804
  // 懒挂载会把它降成「是/否」纯文本(点击才挂出开关),用户会以为开关消失。故可编辑态强制 eager。
782
805
  // 只读态(下方 ① 路径)仍走「是/否」文本快路径不受影响。@author nokecy
@@ -800,7 +823,7 @@ var buildArrayTableColumns = exports.buildArrayTableColumns = function buildArra
800
823
  var canFastPath = !dataFieldName || isFastPathFieldName(dataFieldName);
801
824
 
802
825
  // ① 只读纯文本
803
- if (readOnly && formatter && canFastPath) {
826
+ if (readOnly && formatter && canFastPath && !forceEager) {
804
827
  // 列级 readPretty 在「可编辑表」里是展示列(值可能被 setValuesIn 自动带出),静态 valueFormatter
805
828
  // 读 AG-Grid 缓存值不刷新 → 反应式只读渲染。整表 readPretty(明细/详情页,数据 setValues 整体加载、
806
829
  // 行引用整体替换、AG-Grid 自然刷新)仍走更廉价的静态 valueFormatter 快路径。@author nokecy
@@ -919,9 +942,9 @@ var collectLazyDefaults = exports.collectLazyDefaults = function collectLazyDefa
919
942
  key: String((_fieldSchema$name3 = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) !== null && _fieldSchema$name3 !== void 0 ? _fieldSchema$name3 : col.field),
920
943
  value: fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.default
921
944
  };
922
- }).filter(function (_ref9) {
923
- var key = _ref9.key,
924
- value = _ref9.value;
945
+ }).filter(function (_ref11) {
946
+ var key = _ref11.key,
947
+ value = _ref11.value;
925
948
  return SIMPLE_FIELD_NAME.test(key) && value !== undefined && value !== null && !(typeof value === 'string' && value.includes('{{'));
926
949
  });
927
950
  };
@@ -940,9 +963,9 @@ var applyLazyDefaults = exports.applyLazyDefaults = function applyLazyDefaults(a
940
963
  // 已落库的行(带 id)保持库里的样子:补默认值会让受控字段凭空出现「变更」,
941
964
  // 已审批的数据保存时还会被要求填变更原因。只补新增行(按钮之外的途径推进来的行)。
942
965
  if (row.id != null || row._id != null) return;
943
- defaults.forEach(function (_ref10) {
944
- var key = _ref10.key,
945
- value = _ref10.value;
966
+ defaults.forEach(function (_ref12) {
967
+ var key = _ref12.key,
968
+ value = _ref12.value;
946
969
  if (row[key] == null) {
947
970
  form.setValuesIn(arrayField.path.concat(index).concat(key), _typeof(value) === 'object' ? JSON.parse(JSON.stringify(value)) : value);
948
971
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ 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); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -10,7 +11,13 @@ var _react = _interopRequireDefault(require("react"));
10
11
  var _hoistStatics = require("./hoistStatics");
11
12
  var _selectNumberInputTextOnClick = require("./selectNumberInputTextOnClick");
12
13
  var _values = require("./values");
14
+ var _selectValue = require("./selectValue");
13
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
20
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
21
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
22
  /** 普通表单控件统一阅读展示;数值控件禁用方向键步进,让表格负责上下导航。@author nokecy */
16
23
  var readingControl = function readingControl(Control, Preview) {
@@ -25,7 +32,7 @@ var readingControl = function readingControl(Control, Preview) {
25
32
  var reading = props.readOnly || ((_props$disabled = props.disabled) !== null && _props$disabled !== void 0 ? _props$disabled : componentDisabled);
26
33
  return reading ? /*#__PURE__*/_react.default.createElement(_antdV.PreviewText.Placeholder, {
27
34
  value: "\u2014"
28
- }, /*#__PURE__*/_react.default.createElement(Preview, map(props))) : /*#__PURE__*/_react.default.createElement(Control, _extends({}, props, numericInput ? {
35
+ }, /*#__PURE__*/_react.default.createElement(Preview, map(props))) : /*#__PURE__*/_react.default.createElement(Control, _extends({}, map(props), numericInput ? {
29
36
  keyboard: false,
30
37
  onClick: (0, _selectNumberInputTextOnClick.selectNumberInputTextOnClick)(props.onClick)
31
38
  } : {}, {
@@ -48,6 +55,15 @@ var choiceOptions = function choiceOptions(props) {
48
55
  var ChoicePreview = function ChoicePreview(props) {
49
56
  return /*#__PURE__*/_react.default.createElement("span", null, (0, _values.selectedLabels)(props.value, (0, _values.flattenOptions)(choiceOptions(props), props.fieldNames), props.labelInValue));
50
57
  };
58
+ /** 候选值只在显示边界匹配;加载含空格的码值不会把单据标成已修改。@author nokecy */
59
+ var choiceDisplayProps = function choiceDisplayProps(props) {
60
+ var options = (0, _values.flattenOptions)(choiceOptions(props), props.fieldNames);
61
+ return _objectSpread(_objectSpread(_objectSpread({}, props), 'value' in props ? {
62
+ value: (0, _selectValue.matchSelectDisplayValue)(props.value, options, props.labelInValue)
63
+ } : {}), 'defaultValue' in props ? {
64
+ defaultValue: (0, _selectValue.matchSelectDisplayValue)(props.defaultValue, options, props.labelInValue)
65
+ } : {});
66
+ };
51
67
  var BooleanPreview = function BooleanPreview(props) {
52
68
  return /*#__PURE__*/_react.default.createElement("span", null, props.children, props.children ? ':' : '', props.checked == null ? '—' : props.checked ? '是' : '否');
53
69
  };
@@ -61,7 +77,7 @@ Input.Search = readingControl(_antd.Input.Search, _antdV.PreviewText.Input);
61
77
  var InputNumber = exports.InputNumber = readingControl(_antd.InputNumber, _antdV.PreviewText.NumberPicker, undefined, true);
62
78
  /** Formily 数值控件同样关闭方向键步进,保留数值类型及原有表单绑定。@author nokecy */
63
79
  var NumberPicker = exports.NumberPicker = readingControl(_antdV.NumberPicker, _antdV.PreviewText.NumberPicker, undefined, true);
64
- var Select = exports.Select = readingControl(_antd.Select, ChoicePreview);
80
+ var Select = exports.Select = readingControl(_antd.Select, ChoicePreview, choiceDisplayProps);
65
81
  var Switch = exports.Switch = readingControl(_antd.Switch, BooleanPreview);
66
82
  var Checkbox = exports.Checkbox = readingControl(_antd.Checkbox, BooleanPreview);
67
83
  Checkbox.Group = readingControl(_antd.Checkbox.Group, ChoicePreview);
@@ -1,4 +1,7 @@
1
1
  import React from 'react';
2
2
  /** 精确业务数值录入和阅读展示,零值与原始十进制字符串始终保留。@author nokecy */
3
3
  export declare const DecimalInput: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<any>>;
4
- export declare const DecimalPicker: React.ForwardRefExoticComponent<Omit<Partial<Omit<any, "ref"> & React.RefAttributes<any>>, "ref"> & React.RefAttributes<unknown>>;
4
+ /** 精确数值的静默态沿用自身阅读规则,允许表格按已知显示契约懒挂载。@author nokecy */
5
+ export declare const DecimalPicker: React.ForwardRefExoticComponent<Omit<Partial<Omit<any, "ref"> & React.RefAttributes<any>>, "ref"> & React.RefAttributes<unknown>> & {
6
+ readOnlyFormatter: import("../array-table/readOnlyFormatters").ReadOnlyFormatter;
7
+ };
@@ -8,6 +8,7 @@ var _react = require("@formily/react");
8
8
  var _react2 = _interopRequireDefault(require("react"));
9
9
  var _controls = require("./controls");
10
10
  var _businessDecimal = require("../utils/businessDecimal");
11
+ var _readOnlyFormatters = require("../array-table/readOnlyFormatters");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
13
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
13
14
  /** 精确业务数值录入和阅读展示,零值与原始十进制字符串始终保留。@author nokecy */
@@ -20,9 +21,18 @@ var DecimalInput = exports.DecimalInput = /*#__PURE__*/_react2.default.forwardRe
20
21
  var DecimalPreview = function DecimalPreview(_ref) {
21
22
  var value = _ref.value,
22
23
  formatter = _ref.formatter;
23
- return /*#__PURE__*/_react2.default.createElement("span", null, value == null || value === '' ? '—' : formatter ? formatter(value, {
24
+ return /*#__PURE__*/_react2.default.createElement("span", null, value == null || value === '' ? '—' : typeof formatter === 'function' ? formatter(value, {
24
25
  userTyping: false,
25
26
  input: String(value)
26
27
  }) : (0, _businessDecimal.decimalText)(value));
27
28
  };
28
- var DecimalPicker = exports.DecimalPicker = (0, _react.connect)(DecimalInput, (0, _react.mapReadPretty)(DecimalPreview));
29
+ /** 精确数值的静默态沿用自身阅读规则,允许表格按已知显示契约懒挂载。@author nokecy */
30
+ var DecimalPicker = exports.DecimalPicker = (0, _readOnlyFormatters.withReadOnlyFormatter)((0, _react.connect)(DecimalInput, (0, _react.mapReadPretty)(DecimalPreview)), function (value, ctx) {
31
+ var _ctx$fieldSchema;
32
+ if (value == null || value === '') return '';
33
+ var formatter = (_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.formatter;
34
+ return typeof formatter === 'function' ? String(formatter(value, {
35
+ userTyping: false,
36
+ input: String(value)
37
+ })) : (0, _businessDecimal.decimalText)(value);
38
+ });
@@ -16,6 +16,8 @@ var _hoistStatics = require("./hoistStatics");
16
16
  var Reading = _interopRequireWildcard(require("./controls"));
17
17
  var _selectNumberInputTextOnClick = require("./selectNumberInputTextOnClick");
18
18
  var _arrayTable = require("./arrayTable");
19
+ var _values = require("./values");
20
+ var _selectValue = require("./selectValue");
19
21
  var _schemaScope = require("./schemaScope");
20
22
  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); }
21
23
  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; }
@@ -39,18 +41,24 @@ function withReadingFields(components) {
39
41
  });
40
42
  var wrap = function wrap(Control, Preview) {
41
43
  var numericInput = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
44
+ var choiceInput = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
42
45
  var Component = (0, _react.observer)(function (props) {
46
+ var _field$dataSource;
43
47
  var field = (0, _react.useField)();
44
- if (props.disabled || props.readOnly || field !== null && field !== void 0 && field.disabled || field !== null && field !== void 0 && field.readOnly) {
45
- var _field$value, _field$value2, _field$dataSource;
48
+ var options = field !== null && field !== void 0 && (_field$dataSource = field.dataSource) !== null && _field$dataSource !== void 0 && _field$dataSource.length ? field.dataSource : props.options;
49
+ var displayProps = choiceInput ? _objectSpread(_objectSpread({}, props), {}, {
50
+ value: (0, _selectValue.matchSelectDisplayValue)(props.value, (0, _values.flattenOptions)(options, props.fieldNames), props.labelInValue)
51
+ }) : props;
52
+ if (props.disabled || props.readOnly || field !== null && field !== void 0 && field.disabled || field !== null && field !== void 0 && field.readOnly || choiceInput && (field === null || field === void 0 ? void 0 : field.pattern) === 'readPretty') {
53
+ var _field$value, _field$value2, _field$dataSource2;
46
54
  return /*#__PURE__*/_react2.default.createElement(Preview, _extends({}, props, {
47
55
  value: (_field$value = field === null || field === void 0 ? void 0 : field.value) !== null && _field$value !== void 0 ? _field$value : props.value,
48
56
  checked: (_field$value2 = field === null || field === void 0 ? void 0 : field.value) !== null && _field$value2 !== void 0 ? _field$value2 : props.checked,
49
- options: field !== null && field !== void 0 && (_field$dataSource = field.dataSource) !== null && _field$dataSource !== void 0 && _field$dataSource.length ? field.dataSource : props.options,
57
+ options: field !== null && field !== void 0 && (_field$dataSource2 = field.dataSource) !== null && _field$dataSource2 !== void 0 && _field$dataSource2.length ? field.dataSource : props.options,
50
58
  disabled: true
51
59
  }));
52
60
  }
53
- return /*#__PURE__*/_react2.default.createElement(Control, _extends({}, props, numericInput ? {
61
+ return /*#__PURE__*/_react2.default.createElement(Control, _extends({}, displayProps, numericInput ? {
54
62
  keyboard: false,
55
63
  onClick: (0, _selectNumberInputTextOnClick.selectNumberInputTextOnClick)(props.onClick)
56
64
  } : {}));
@@ -70,7 +78,7 @@ function withReadingFields(components) {
70
78
  try {
71
79
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
72
80
  var name = _step.value;
73
- result[name] = wrap(components[name], previews[name], name === 'NumberPicker' || name === 'InputNumber');
81
+ result[name] = wrap(components[name], previews[name], name === 'NumberPicker' || name === 'InputNumber', name === 'Select');
74
82
  }
75
83
  // ArrayTable 阅读态保留动态列的标题和显隐状态。@author nokecy
76
84
  } catch (err) {
@@ -1,4 +1,15 @@
1
1
  import { type ReactNode } from 'react';
2
+ /**
3
+ * 仅为控件回显匹配候选中的原生值,不回写表单,不触发变更事件。
4
+ * @param value 原始单选或多选值。
5
+ * @param options 已展开的选项。
6
+ * @param labelInValue 是否使用名称编码对象。
7
+ * @returns 命中选项的控件值;未知值原样保留。
8
+ * @author nokecy
9
+ */
10
+ export declare function matchSelectDisplayValue(value: any, options: readonly {
11
+ value?: unknown;
12
+ }[], labelInValue?: boolean): any;
2
13
  /** 提取选择项的标量编码,兼容嵌套 labelInValue;保留编码 0 和显式空字符串选项。@author nokecy */
3
14
  export declare function selectCode(value: unknown, depth?: number): string | number | undefined;
4
15
  /** 标签只输出可渲染内容;选择项对象取名称后再回落编码,避免 React 对象子节点异常。@author nokecy */
@@ -3,16 +3,40 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.matchSelectDisplayValue = matchSelectDisplayValue;
6
7
  exports.normalizeSelectValue = normalizeSelectValue;
7
8
  exports.selectCode = selectCode;
8
9
  exports.selectLabel = selectLabel;
9
10
  var _react = require("react");
11
+ var _optionValue = require("../utils/optionValue");
10
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
14
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
16
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
17
  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); }
18
+ /**
19
+ * 仅为控件回显匹配候选中的原生值,不回写表单,不触发变更事件。
20
+ * @param value 原始单选或多选值。
21
+ * @param options 已展开的选项。
22
+ * @param labelInValue 是否使用名称编码对象。
23
+ * @returns 命中选项的控件值;未知值原样保留。
24
+ * @author nokecy
25
+ */
26
+ function matchSelectDisplayValue(value, options, labelInValue) {
27
+ if (Array.isArray(value)) return value.map(function (item) {
28
+ return matchSelectDisplayValue(item, options, labelInValue);
29
+ });
30
+ var raw = labelInValue && value && _typeof(value) === 'object' ? value.value : value;
31
+ var matched = (0, _optionValue.findOptionByValue)(options, raw, function (option) {
32
+ return option.value;
33
+ });
34
+ if (!matched) return value;
35
+ return labelInValue && value && _typeof(value) === 'object' ? _objectSpread(_objectSpread({}, value), {}, {
36
+ value: matched.value
37
+ }) : matched.value;
38
+ }
39
+
16
40
  /** 提取选择项的标量编码,兼容嵌套 labelInValue;保留编码 0 和显式空字符串选项。@author nokecy */
17
41
  function selectCode(value) {
18
42
  var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.flattenOptions = flattenOptions;
7
7
  exports.selectedLabels = selectedLabels;
8
8
  var _selectValue = require("./selectValue");
9
+ var _optionValue = require("../utils/optionValue");
9
10
  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
  /** 阅读态选择项展开,保留分组内选项及自定义字段名。@author nokecy */
11
12
  function flattenOptions() {
@@ -36,11 +37,11 @@ function selectedLabels(value, options, labelInValue) {
36
37
  var values = Array.isArray(normalized) ? normalized : normalized == null ? [] : [normalized];
37
38
  if (!values.length) return '—';
38
39
  var labels = values.map(function (item) {
39
- var _ref2, _selectLabel, _options$find, _item$label;
40
+ var _ref2, _selectLabel, _findOptionByValue, _item$label;
40
41
  var raw = labelInValue ? item.value : item;
41
- return (_ref2 = (_selectLabel = (0, _selectValue.selectLabel)((_options$find = options.find(function (option) {
42
- return option.value === raw;
43
- })) === null || _options$find === void 0 ? void 0 : _options$find.label)) !== null && _selectLabel !== void 0 ? _selectLabel : (0, _selectValue.selectLabel)(labelInValue ? (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : raw : raw)) !== null && _ref2 !== void 0 ? _ref2 : '—';
42
+ return (_ref2 = (_selectLabel = (0, _selectValue.selectLabel)((_findOptionByValue = (0, _optionValue.findOptionByValue)(options, raw, function (option) {
43
+ return option.value;
44
+ })) === null || _findOptionByValue === void 0 ? void 0 : _findOptionByValue.label)) !== null && _selectLabel !== void 0 ? _selectLabel : (0, _selectValue.selectLabel)(labelInValue ? (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : raw : raw)) !== null && _ref2 !== void 0 ? _ref2 : '—';
44
45
  });
45
46
  // 选项标签可以是React节点,交由调用组件按顺序渲染。
46
47
  return labels.flatMap(function (label, index) {
@@ -11,6 +11,17 @@ require("./index.less");
11
11
  var _excluded = ["children", "className", "extra", "identity", "banner", "style", "renderContent", "getTargetContainer"];
12
12
  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); }
13
13
  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; }
14
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
20
+ 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."); }
21
+ 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); }
22
+ 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; }
23
+ 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; } }
24
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
25
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
26
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
27
  /** 详情、表单共用工具栏:按实际操作元素统一留出间距,宽度不足时换行。@author nokecy */
@@ -27,10 +38,41 @@ var ToolBar = function ToolBar(props) {
27
38
  var _theme$useToken = _antd.theme.useToken(),
28
39
  token = _theme$useToken.token; // 单据操作栏跟随宿主主题。@author nokecy
29
40
  var barRef = (0, _react.useRef)(null);
41
+ var _useState = (0, _react.useState)(),
42
+ _useState2 = _slicedToArray(_useState, 2),
43
+ barHeight = _useState2[0],
44
+ setBarHeight = _useState2[1];
45
+ /** 吸顶后 Affix 的占位会固定高度,动态提示及按钮换行仍须按内容重新占位。@author nokecy */
46
+ var measureHeight = (0, _react.useCallback)(function () {
47
+ var _barRef$current;
48
+ var height = (_barRef$current = barRef.current) === null || _barRef$current === void 0 ? void 0 : _barRef$current.getBoundingClientRect().height;
49
+ // KeepAlive 隐藏页的零高度不能冲掉有效占位。@author nokecy
50
+ if (height && height > 0) setBarHeight(function (previous) {
51
+ return previous === Math.ceil(height) ? previous : Math.ceil(height);
52
+ });
53
+ }, []);
54
+ (0, _react.useLayoutEffect)(function () {
55
+ measureHeight();
56
+ });
57
+ (0, _react.useLayoutEffect)(function () {
58
+ var bar = barRef.current;
59
+ if (!bar) return;
60
+ if (typeof ResizeObserver !== 'undefined') {
61
+ var observer = new ResizeObserver(measureHeight);
62
+ observer.observe(bar);
63
+ return function () {
64
+ return observer.disconnect();
65
+ };
66
+ }
67
+ window.addEventListener('resize', measureHeight);
68
+ return function () {
69
+ return window.removeEventListener('resize', measureHeight);
70
+ };
71
+ }, [measureHeight]);
30
72
  // @author nokecy:KeepAlive 内容区独立滚动,吸顶应相对其视口,避免定位到应用顶栏下面。
31
73
  var defaultTarget = (0, _react.useCallback)(function () {
32
- var _barRef$current$paren, _barRef$current;
33
- var parent = (_barRef$current$paren = (_barRef$current = barRef.current) === null || _barRef$current === void 0 ? void 0 : _barRef$current.parentElement) !== null && _barRef$current$paren !== void 0 ? _barRef$current$paren : null;
74
+ var _barRef$current$paren, _barRef$current2;
75
+ var parent = (_barRef$current$paren = (_barRef$current2 = barRef.current) === null || _barRef$current2 === void 0 ? void 0 : _barRef$current2.parentElement) !== null && _barRef$current$paren !== void 0 ? _barRef$current$paren : null;
34
76
  while (parent) {
35
77
  if (/auto|scroll/.test(getComputedStyle(parent).overflowY)) return parent;
36
78
  parent = parent.parentElement;
@@ -39,7 +81,9 @@ var ToolBar = function ToolBar(props) {
39
81
  }, []);
40
82
  return /*#__PURE__*/_react.default.createElement(_antd.Affix, {
41
83
  offsetTop: 2,
42
- style: style,
84
+ style: _objectSpread(_objectSpread({}, style), barHeight === undefined ? {} : {
85
+ height: barHeight
86
+ }),
43
87
  offsetBottom: 2,
44
88
  target: getTargetContainer || defaultTarget
45
89
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 精确匹配优先,再按去除首尾空格的标量码匹配选项;保留前导零、大小写及未知值。
3
+ * @param options 可选项。
4
+ * @param value 待显示的原始值。
5
+ * @param getValue 读取选项编码。
6
+ * @returns 命中的选项;未命中返回 undefined,不改写原始数据。
7
+ * @author nokecy
8
+ */
9
+ export declare function findOptionByValue<T>(options: readonly T[], value: unknown, getValue: (option: T) => unknown): T | undefined;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findOptionByValue = findOptionByValue;
7
+ 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); }
8
+ /**
9
+ * 精确匹配优先,再按去除首尾空格的标量码匹配选项;保留前导零、大小写及未知值。
10
+ * @param options 可选项。
11
+ * @param value 待显示的原始值。
12
+ * @param getValue 读取选项编码。
13
+ * @returns 命中的选项;未命中返回 undefined,不改写原始数据。
14
+ * @author nokecy
15
+ */
16
+ function findOptionByValue(options, value, getValue) {
17
+ var exact = options.find(function (option) {
18
+ return getValue(option) === value;
19
+ });
20
+ if (exact !== undefined) return exact;
21
+ var code = function code(item) {
22
+ return ['string', 'number', 'boolean'].includes(_typeof(item)) ? String(item).trim() : undefined;
23
+ };
24
+ var target = code(value);
25
+ return target === undefined ? undefined : options.find(function (option) {
26
+ return code(getValue(option)) === target;
27
+ });
28
+ }
@@ -10,6 +10,7 @@ import { Select } from '@formily/antd-v5';
10
10
  import { isArray } from 'lodash';
11
11
  import { DEFAULT_SEARCH_SORT_ORDER } from "./constants";
12
12
  import { toGridTextColor } from "./valueEnumColor";
13
+ import { findOptionByValue } from "../../utils/optionValue";
13
14
  var Text = Typography.Text;
14
15
 
15
16
  /**
@@ -152,16 +153,16 @@ export function processEnumColumn(col, dataType, background) {
152
153
 
153
154
  // 值格式化函数
154
155
  var valueFormatter = function valueFormatter(params) {
155
- var match = valueEnum.find(function (item) {
156
- return item.value == params.value;
156
+ var match = findOptionByValue(valueEnum, params.value, function (item) {
157
+ return item.value;
157
158
  });
158
159
  return match ? match.label : params.value;
159
160
  };
160
161
  var fallbackRenderer = col.enumFallbackRenderer;
161
162
  return _objectSpread(_objectSpread(_objectSpread({}, toColumnType(dataType)), col), {}, {
162
163
  cellRenderer: function cellRenderer(params) {
163
- var match = valueEnum.find(function (item) {
164
- return item.value == params.value;
164
+ var match = findOptionByValue(valueEnum, params.value, function (item) {
165
+ return item.value;
165
166
  });
166
167
  if (match) {
167
168
  // 没配颜色的枚举项曾经默认成 '#ffffff'——白底白字,那一列直接看不见。