@nokecy/qc-ui 1.1.95 → 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.
- package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/setting/columnGroupUtils.js +1 -1
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +5 -4
- package/dist/cjs/array-table/columnAlign.d.ts +8 -0
- package/dist/cjs/array-table/columnAlign.js +41 -0
- package/dist/cjs/array-table/columnHelper.js +1 -1
- package/dist/cjs/array-table/readOnlyFormatters.js +21 -16
- package/dist/cjs/array-table/theme.js +1 -1
- package/dist/cjs/array-table/utils.js +41 -16
- package/dist/cjs/dashboard/dashboard/index.js +1 -1
- package/dist/cjs/dashboard/index.d.ts +1 -0
- package/dist/cjs/dashboard/index.js +12 -1
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +42 -1
- package/dist/cjs/readPretty/controls.d.ts +3 -1
- package/dist/cjs/readPretty/controls.js +22 -4
- package/dist/cjs/readPretty/decimal.d.ts +4 -1
- package/dist/cjs/readPretty/decimal.js +12 -2
- package/dist/cjs/readPretty/formily.js +13 -5
- package/dist/cjs/readPretty/selectValue.d.ts +11 -0
- package/dist/cjs/readPretty/selectValue.js +24 -0
- package/dist/cjs/readPretty/values.js +5 -4
- package/dist/cjs/scanCollect/ScanInput.d.ts +21 -0
- package/dist/cjs/scanCollect/ScanInput.js +84 -0
- package/dist/cjs/scanCollect/focus.d.ts +23 -0
- package/dist/cjs/scanCollect/focus.js +55 -0
- package/dist/cjs/scanCollect/index.d.ts +13 -0
- package/dist/cjs/scanCollect/index.js +46 -0
- package/dist/cjs/scanCollect/requestGate.d.ts +18 -0
- package/dist/cjs/scanCollect/requestGate.js +30 -0
- package/dist/cjs/scanCollect/usePromiseQueue.d.ts +34 -0
- package/dist/cjs/scanCollect/usePromiseQueue.js +156 -0
- package/dist/cjs/standardList/StandardAgGridPlus.d.ts +8 -1
- package/dist/cjs/standardList/StandardAgGridPlus.js +34 -16
- package/dist/cjs/standardList/index.d.ts +2 -2
- package/dist/cjs/standardList/index.js +6 -0
- package/dist/cjs/toolBar/index.js +47 -3
- package/dist/cjs/utils/optionValue.d.ts +9 -0
- package/dist/cjs/utils/optionValue.js +28 -0
- package/dist/esm/ag-grid-plus/setting/columnGroupUtils.d.ts +1 -1
- package/dist/esm/ag-grid-plus/setting/columnGroupUtils.js +1 -1
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +5 -4
- package/dist/esm/array-table/columnAlign.d.ts +8 -0
- package/dist/esm/array-table/columnAlign.js +35 -0
- package/dist/esm/array-table/columnHelper.js +1 -1
- package/dist/esm/array-table/readOnlyFormatters.js +21 -16
- package/dist/esm/array-table/theme.js +1 -1
- package/dist/esm/array-table/utils.js +41 -16
- package/dist/esm/dashboard/dashboard/index.js +1 -1
- package/dist/esm/dashboard/index.d.ts +1 -0
- package/dist/esm/dashboard/index.js +2 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/readPretty/controls.d.ts +3 -1
- package/dist/esm/readPretty/controls.js +22 -4
- package/dist/esm/readPretty/decimal.d.ts +4 -1
- package/dist/esm/readPretty/decimal.js +12 -2
- package/dist/esm/readPretty/formily.js +13 -5
- package/dist/esm/readPretty/selectValue.d.ts +11 -0
- package/dist/esm/readPretty/selectValue.js +23 -0
- package/dist/esm/readPretty/values.js +5 -4
- package/dist/esm/scanCollect/ScanInput.d.ts +21 -0
- package/dist/esm/scanCollect/ScanInput.js +75 -0
- package/dist/esm/scanCollect/focus.d.ts +23 -0
- package/dist/esm/scanCollect/focus.js +47 -0
- package/dist/esm/scanCollect/index.d.ts +13 -0
- package/dist/esm/scanCollect/index.js +10 -0
- package/dist/esm/scanCollect/requestGate.d.ts +18 -0
- package/dist/esm/scanCollect/requestGate.js +24 -0
- package/dist/esm/scanCollect/usePromiseQueue.d.ts +34 -0
- package/dist/esm/scanCollect/usePromiseQueue.js +151 -0
- package/dist/esm/standardList/StandardAgGridPlus.d.ts +8 -1
- package/dist/esm/standardList/StandardAgGridPlus.js +35 -17
- package/dist/esm/standardList/index.d.ts +2 -2
- package/dist/esm/standardList/index.js +1 -1
- package/dist/esm/toolBar/index.js +49 -4
- package/dist/esm/utils/optionValue.d.ts +9 -0
- package/dist/esm/utils/optionValue.js +22 -0
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -21,6 +21,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
21
21
|
* @author nokecy
|
|
22
22
|
*/
|
|
23
23
|
import dayjs from 'dayjs';
|
|
24
|
+
import { findOptionByValue } from "../utils/optionValue";
|
|
24
25
|
|
|
25
26
|
/** 选择器的展示字段;只影响回显,不改变 labelInValue 的提交值。@author nokecy */
|
|
26
27
|
|
|
@@ -54,16 +55,18 @@ var resolveOptions = function resolveOptions(ctx) {
|
|
|
54
55
|
|
|
55
56
|
/** 单个值映射成 label:兼容 labelInValue 对象、{label,value} 选项、原始值 */
|
|
56
57
|
var mapOptionLabel = function mapOptionLabel(value, options) {
|
|
57
|
-
var _ref4,
|
|
58
|
+
var _ref4, _hit$label;
|
|
58
59
|
if (value == null) return '';
|
|
59
60
|
// labelInValue: 值本身就是 { label, value }
|
|
60
|
-
if (_typeof(value) === 'object')
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
if (_typeof(value) === 'object') {
|
|
62
|
+
var label = value.label;
|
|
63
|
+
return label != null && label !== value.value ? String(label) : mapOptionLabel(value.value, options);
|
|
64
|
+
}
|
|
65
|
+
// 定长码值可能带补齐空格;与编辑控件、列表使用同一选项匹配规则。@author nokecy
|
|
66
|
+
var hit = findOptionByValue(options, value, function (o) {
|
|
67
|
+
return o && _typeof(o) === 'object' ? o.value : o;
|
|
65
68
|
});
|
|
66
|
-
if (hit && _typeof(hit) === 'object') return String((
|
|
69
|
+
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);
|
|
67
70
|
return String(value);
|
|
68
71
|
};
|
|
69
72
|
var textFormatter = function textFormatter(value) {
|
|
@@ -183,9 +186,9 @@ export var fallbackFormatter = function fallbackFormatter(value, ctx) {
|
|
|
183
186
|
}).filter(Boolean).join(', ');
|
|
184
187
|
if (typeof value === 'boolean') return booleanFormatter(value, ctx);
|
|
185
188
|
if (_typeof(value) === 'object') {
|
|
186
|
-
var _value$
|
|
189
|
+
var _value$label2;
|
|
187
190
|
if (typeof value.format === 'function') return dateFormatter(value, ctx);
|
|
188
|
-
var shown = (_value$
|
|
191
|
+
var shown = (_value$label2 = value.label) !== null && _value$label2 !== void 0 ? _value$label2 : value.value;
|
|
189
192
|
return shown == null ? '' : String(shown);
|
|
190
193
|
}
|
|
191
194
|
return String(value);
|
|
@@ -215,18 +218,20 @@ export var registerReadOnlyLabels = function registerReadOnlyLabels(component, l
|
|
|
215
218
|
if (o && o.value != null) map.set(String(o.value), String((_o$label = o.label) !== null && _o$label !== void 0 ? _o$label : o.value));
|
|
216
219
|
});
|
|
217
220
|
} else {
|
|
218
|
-
Object.entries(labels !== null && labels !== void 0 ? labels : {}).forEach(function (
|
|
219
|
-
var
|
|
220
|
-
k =
|
|
221
|
-
v =
|
|
221
|
+
Object.entries(labels !== null && labels !== void 0 ? labels : {}).forEach(function (_ref5) {
|
|
222
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
223
|
+
k = _ref6[0],
|
|
224
|
+
v = _ref6[1];
|
|
222
225
|
return map.set(String(k), String(v));
|
|
223
226
|
});
|
|
224
227
|
}
|
|
225
228
|
var toText = function toText(v) {
|
|
226
|
-
var _ref8, _v$label, _map$get;
|
|
227
229
|
if (v == null || v === '') return '';
|
|
228
|
-
if (_typeof(v) === 'object') return
|
|
229
|
-
|
|
230
|
+
if (_typeof(v) === 'object') return v.label != null && v.label !== v.value ? String(v.label) : toText(v.value);
|
|
231
|
+
var key = findOptionByValue(Array.from(map.keys()), v, function (key) {
|
|
232
|
+
return key;
|
|
233
|
+
});
|
|
234
|
+
return key === undefined ? String(v) : map.get(key);
|
|
230
235
|
};
|
|
231
236
|
var formatter = function formatter(value) {
|
|
232
237
|
return Array.isArray(value) ? value.map(toText).filter(Boolean).join(', ') : toText(value);
|
|
@@ -23,7 +23,7 @@ export var ARRAY_TABLE_ROW_HEIGHT = 38;
|
|
|
23
23
|
*/
|
|
24
24
|
var arrayTableCellFit = createPart({
|
|
25
25
|
feature: 'arrayTableCellFit',
|
|
26
|
-
css: "\n .ag-cell .ag-cell-wrapper { height: 100%; }\n .ag-cell .ant-formily-item { margin-bottom: 0; }\n /* \u6807\u9898\u548C\u8BF4\u660E\u7531\u5217\u5934\u627F\u8F7D\uFF0ClabelWidth:0 \u672C\u8EAB\u4E0D\u4F1A\u9690\u85CF\u5B57\u6BB5\u6807\u9898\u3002@author nokecy */\n .ag-cell .ant-formily-item-label { display: none; }\n .ag-cell .ant-formily-item-control { flex: 1; min-width: 0; width: 100%; }\n .ag-cell .ant-formily-item-help { position: absolute; }\n .ag-header-cell.qc-array-table-required .ag-header-cell-text::before {\n content: '*';\n color: var(--ag-invalid-color);\n margin-inline-end: 4px;\n }\n "
|
|
26
|
+
css: "\n .ag-cell .ag-cell-wrapper { height: 100%; }\n .ag-cell .ant-formily-item { margin-bottom: 0; }\n /* \u6807\u9898\u548C\u8BF4\u660E\u7531\u5217\u5934\u627F\u8F7D\uFF0ClabelWidth:0 \u672C\u8EAB\u4E0D\u4F1A\u9690\u85CF\u5B57\u6BB5\u6807\u9898\u3002@author nokecy */\n .ag-cell .ant-formily-item-label { display: none; }\n .ag-cell .ant-formily-item-control { flex: 1; min-width: 0; width: 100%; }\n .ag-cell .ant-formily-item-help { position: absolute; }\n /* \u5217\u5BF9\u9F50\uFF08align \u5199\u6CD5\uFF09\uFF1B\u6B63\u5728\u7F16\u8F91\u7684\u8F93\u5165\u6846\u8DDF\u968F\u6240\u5728\u5217\u7684\u5BF9\u9F50\uFF0C\u6570\u5B57\u5217\u70B9\u5F00\u7F16\u8F91\u65F6\u4E0D\u4F1A\u8DF3\u5230\u5DE6\u8FB9\u3002@author nokecy */\n .ag-cell.qc-array-table-align-left { text-align: left; }\n .ag-cell.qc-array-table-align-center { text-align: center; }\n .ag-cell.qc-array-table-align-right { text-align: right; }\n .ag-cell .ant-input-number .ant-input-number-input,\n .ag-cell .ant-input-affix-wrapper .ant-input,\n .ag-cell .ant-input.ant-input { text-align: inherit; }\n .ag-header-cell.qc-array-table-required .ag-header-cell-text::before {\n content: '*';\n color: var(--ag-invalid-color);\n margin-inline-end: 4px;\n }\n "
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
/** 根据当前 antd 主题生成编辑态或阅读态明细表格主题。@author nokecy */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["hide", "sort", "sortIndex", "forceAgField", "headerGroup", "defaultHide", "requiredMark"];
|
|
1
|
+
var _excluded = ["hide", "sort", "sortIndex", "forceAgField", "headerGroup", "defaultHide", "requiredMark", "align"];
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
@@ -30,6 +30,7 @@ import { createArrayTableComparator } from "./sorting";
|
|
|
30
30
|
import { containsIndexComponent } from "./indexColumn";
|
|
31
31
|
import { withDisplaySequencePolicy } from "../utils/gridSequence";
|
|
32
32
|
import { isRequiredColumn, withRequiredColumnHeader } from "./requiredHeader";
|
|
33
|
+
import { withColumnAlign } from "./columnAlign";
|
|
33
34
|
var isColumnComponent = function isColumnComponent(schema) {
|
|
34
35
|
var _schema$xComponent;
|
|
35
36
|
return ((_schema$xComponent = schema['x-component']) === null || _schema$xComponent === void 0 ? void 0 : _schema$xComponent.indexOf('Column')) > -1;
|
|
@@ -524,12 +525,24 @@ var LazyAgField = function LazyAgField(params) {
|
|
|
524
525
|
// 改值(行引用不变 → AG-Grid 不刷新该格、外层 observer 也不重渲)时,本格能自行重渲刷新——
|
|
525
526
|
// 免去调用方加 forceAgField 逃生阀。字段名缺失才回退 params.value。@author nokecy
|
|
526
527
|
return /*#__PURE__*/React.createElement(Observer, null, function () {
|
|
528
|
+
var _fieldSchema$xCompon2;
|
|
527
529
|
var _resolveCellRow3 = resolveCellRow(field, record, node, dataSource),
|
|
528
530
|
currentRecord = _resolveCellRow3.record;
|
|
529
531
|
if (!currentRecord) return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
530
532
|
var activated = activeCells.has(key);
|
|
531
533
|
// 已挂载时不读值:挂载后每敲一个字都会变,追踪它会让整棵字段树跟着重渲
|
|
532
534
|
var liveValue = activated ? undefined : dataKey != null ? readByFieldPath(currentRecord, dataKey) : value;
|
|
535
|
+
// 解构选择值缺少名称时仍要让业务组件补全名称;有名称后才可降为静默文本。@author nokecy
|
|
536
|
+
if (!activated && formatter === 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') {
|
|
537
|
+
return /*#__PURE__*/React.createElement(AgField, {
|
|
538
|
+
value: value,
|
|
539
|
+
data: currentRecord,
|
|
540
|
+
dataSource: dataSource,
|
|
541
|
+
schema: schema,
|
|
542
|
+
field: field,
|
|
543
|
+
node: node
|
|
544
|
+
});
|
|
545
|
+
}
|
|
533
546
|
// Editable 装饰器会把非新增行的格转成只读态、不参与校验(见 editable/index.tsx),
|
|
534
547
|
// 这时挂了没用,还会把灰色「请输入」占位换成只读态的「N/A」,所以留在文本态
|
|
535
548
|
var editableWillReadPretty = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-decorator']) === 'Editable' && currentRecord._isNew !== true;
|
|
@@ -700,7 +713,7 @@ var applyNumberInputDefaults = function applyNumberInputDefaults(dataField) {
|
|
|
700
713
|
var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field, sources) {
|
|
701
714
|
var arrayPattern = field === null || field === void 0 ? void 0 : field.pattern;
|
|
702
715
|
return sources.reduce(function (buf, _ref7, key) {
|
|
703
|
-
var _dataField$xDecorato, _ref8, _getReadOnlyFormatter, _dataField$xComponen, _dataField$xComponen2;
|
|
716
|
+
var _dataField$xDecorato, _ref8, _getReadOnlyFormatter, _dataField$xComponen, _parseObjectDestructu, _dataField$xComponen2, _dataField$xComponen3, _dataField$xComponen4, _dataField$xComponen5;
|
|
704
717
|
var name = _ref7.name,
|
|
705
718
|
columnProps = _ref7.columnProps,
|
|
706
719
|
schema = _ref7.schema,
|
|
@@ -721,8 +734,9 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
|
|
|
721
734
|
headerGroup = columnProps.headerGroup,
|
|
722
735
|
defaultHide = columnProps.defaultHide,
|
|
723
736
|
requiredMark = columnProps.requiredMark,
|
|
737
|
+
align = columnProps.align,
|
|
724
738
|
safeColumnProps = _objectWithoutProperties(columnProps, _excluded);
|
|
725
|
-
var base = _objectSpread(_objectSpread({}, safeColumnProps), {}, {
|
|
739
|
+
var base = withColumnAlign(_objectSpread(_objectSpread({}, safeColumnProps), {}, {
|
|
726
740
|
// 保留 width 作为列的初始宽度
|
|
727
741
|
width: columnProps.width,
|
|
728
742
|
//@ts-ignore
|
|
@@ -730,7 +744,7 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
|
|
|
730
744
|
field: name
|
|
731
745
|
}, defaultHide === true ? {
|
|
732
746
|
initialHide: true
|
|
733
|
-
} : {});
|
|
747
|
+
} : {}), align);
|
|
734
748
|
|
|
735
749
|
// 记下分组名再输出列定义;真正合并成列组在 index.tsx 交给 AG-Grid 之前(groupColumnDefs)做,
|
|
736
750
|
// 这里产出的仍是扁平列定义。@author nokecy
|
|
@@ -750,11 +764,15 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
|
|
|
750
764
|
// 格子先出廉价文本、点击/导航(或必填且为空)才挂全树,焦点离开且校验通过再卸回文本。
|
|
751
765
|
// ③ 兜底全树:其余(无格式化器/带 reactions/forceAgField/复杂字段名/只读但无格式化器) -> AgField。
|
|
752
766
|
var component = dataField === null || dataField === void 0 ? void 0 : dataField['x-component'];
|
|
753
|
-
//
|
|
754
|
-
//
|
|
755
|
-
//
|
|
767
|
+
// 未声明显示规则的业务组件必须挂载:单位选择器等会读取同行名称或异步加载候选,
|
|
768
|
+
// 仅把标量码交给 fallback 会跳过这些逻辑。解构值自带名称、显式编码展示及已登记格式化器仍走快路径。
|
|
769
|
+
// 登记渲染器的组件只读列也可用兜底格式化器判空。@author nokecy
|
|
756
770
|
var renderer = getReadOnlyRenderer(component);
|
|
757
|
-
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) &&
|
|
771
|
+
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) && (renderer || (_parseObjectDestructu = parseObjectDestructure(dataField === null || dataField === void 0 ? void 0 : dataField.name)) !== null && _parseObjectDestructu !== void 0 && _parseObjectDestructu.some(function (_ref9) {
|
|
772
|
+
var _ref10 = _slicedToArray(_ref9, 1),
|
|
773
|
+
key = _ref10[0];
|
|
774
|
+
return key === 'label';
|
|
775
|
+
})) && component && (dataField === null || dataField === void 0 ? void 0 : dataField.type) !== 'void' ? fallbackFormatter : null;
|
|
758
776
|
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') ? {
|
|
759
777
|
valueFormatter: function valueFormatter(params) {
|
|
760
778
|
return formatter(params.value, {
|
|
@@ -765,7 +783,14 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
|
|
|
765
783
|
} : {};
|
|
766
784
|
var hasReactions = !!(dataField && dataField['x-reactions']);
|
|
767
785
|
if (!readOnly) applyNumberInputDefaults(dataField);
|
|
768
|
-
|
|
786
|
+
// 表达式或运行时选项必须创建字段才能求值/加载,不能在没有名称表时直接显示码值。@author nokecy
|
|
787
|
+
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) {
|
|
788
|
+
return typeof options === 'string' && options.includes('{{');
|
|
789
|
+
});
|
|
790
|
+
// 格式化表达式依赖本页 scope 与本行字段,交给 Formily 创建真实字段后编译。@author nokecy
|
|
791
|
+
var schemaFormatter = dataField === null || dataField === void 0 || (_dataField$xComponen5 = dataField['x-component-props']) === null || _dataField$xComponen5 === void 0 ? void 0 : _dataField$xComponen5.formatter;
|
|
792
|
+
var hasFormatterExpression = typeof schemaFormatter === 'string' && schemaFormatter.includes('{{');
|
|
793
|
+
var forceEager = (columnProps === null || columnProps === void 0 ? void 0 : columnProps.forceAgField) === true || formatter === getReadOnlyFormatter('Select') && hasOptionExpression || hasFormatterExpression;
|
|
769
794
|
// Switch/Checkbox 是「单击直控」组件:可编辑态本就该常驻渲染真控件(优化前即如此)。
|
|
770
795
|
// 懒挂载会把它降成「是/否」纯文本(点击才挂出开关),用户会以为开关消失。故可编辑态强制 eager。
|
|
771
796
|
// 只读态(下方 ① 路径)仍走「是/否」文本快路径不受影响。@author nokecy
|
|
@@ -789,7 +814,7 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
|
|
|
789
814
|
var canFastPath = !dataFieldName || isFastPathFieldName(dataFieldName);
|
|
790
815
|
|
|
791
816
|
// ① 只读纯文本
|
|
792
|
-
if (readOnly && formatter && canFastPath) {
|
|
817
|
+
if (readOnly && formatter && canFastPath && !forceEager) {
|
|
793
818
|
// 列级 readPretty 在「可编辑表」里是展示列(值可能被 setValuesIn 自动带出),静态 valueFormatter
|
|
794
819
|
// 读 AG-Grid 缓存值不刷新 → 反应式只读渲染。整表 readPretty(明细/详情页,数据 setValues 整体加载、
|
|
795
820
|
// 行引用整体替换、AG-Grid 自然刷新)仍走更廉价的静态 valueFormatter 快路径。@author nokecy
|
|
@@ -909,9 +934,9 @@ export var collectLazyDefaults = function collectLazyDefaults(columns) {
|
|
|
909
934
|
key: String((_fieldSchema$name3 = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name) !== null && _fieldSchema$name3 !== void 0 ? _fieldSchema$name3 : col.field),
|
|
910
935
|
value: fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.default
|
|
911
936
|
};
|
|
912
|
-
}).filter(function (
|
|
913
|
-
var key =
|
|
914
|
-
value =
|
|
937
|
+
}).filter(function (_ref11) {
|
|
938
|
+
var key = _ref11.key,
|
|
939
|
+
value = _ref11.value;
|
|
915
940
|
return SIMPLE_FIELD_NAME.test(key) && value !== undefined && value !== null && !(typeof value === 'string' && value.includes('{{'));
|
|
916
941
|
});
|
|
917
942
|
};
|
|
@@ -930,9 +955,9 @@ export var applyLazyDefaults = function applyLazyDefaults(arrayField, defaults,
|
|
|
930
955
|
// 已落库的行(带 id)保持库里的样子:补默认值会让受控字段凭空出现「变更」,
|
|
931
956
|
// 已审批的数据保存时还会被要求填变更原因。只补新增行(按钮之外的途径推进来的行)。
|
|
932
957
|
if (row.id != null || row._id != null) return;
|
|
933
|
-
defaults.forEach(function (
|
|
934
|
-
var key =
|
|
935
|
-
value =
|
|
958
|
+
defaults.forEach(function (_ref12) {
|
|
959
|
+
var key = _ref12.key,
|
|
960
|
+
value = _ref12.value;
|
|
936
961
|
if (row[key] == null) {
|
|
937
962
|
form.setValuesIn(arrayField.path.concat(index).concat(key), _typeof(value) === 'object' ? JSON.parse(JSON.stringify(value)) : value);
|
|
938
963
|
}
|
|
@@ -439,7 +439,7 @@ var Dashboard = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
439
439
|
return removeWidget(item.i);
|
|
440
440
|
}
|
|
441
441
|
}, '删除'))));
|
|
442
|
-
})),
|
|
442
|
+
})), finLayout.length > 0 && (toolbar || !stateEditMode) ? toolbar && !stateEditMode && /*#__PURE__*/React.createElement("div", {
|
|
443
443
|
style: {
|
|
444
444
|
display: 'flex',
|
|
445
445
|
margin: '0 10px',
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -37,10 +37,15 @@ export * from './adapters';
|
|
|
37
37
|
export * from "./readPretty";
|
|
38
38
|
export * from "./standardList";
|
|
39
39
|
export * from "./attachment";
|
|
40
|
+
export * from "./scanCollect";
|
|
40
41
|
export { createEntitySelect } from "./entitySelect";
|
|
41
42
|
export { default as ExportButton, buildExportUrl, DEFAULT_EXPORT_TEMPLATE_API, resolveExportAction, resolveExportError, resolveFileName } from "./exportButton";
|
|
42
43
|
export type { ExportButtonProps, ExportTemplateApi, ExportTemplateOption } from "./exportButton";
|
|
43
44
|
export { saveAs } from "./utils/download";
|
|
45
|
+
export { WidgetSelector } from "./dashboard";
|
|
46
|
+
export type { GridProps, GridRef, AgGridColumnPropsClone } from "./ag-grid-plus/interface";
|
|
47
|
+
export { GridPlusError, ErrorType, ErrorSeverity } from "./ag-grid-plus/errors";
|
|
48
|
+
export type { ErrorHandlingConfig } from "./ag-grid-plus/errors";
|
|
44
49
|
export type { EntitySelectConfig, EntitySelectProps, EntitySelectQuery } from "./entitySelect";
|
|
45
50
|
export { semanticTextColors, toGridTextColor, gridValueEnum } from "./ag-grid-plus/utils/valueEnumColor";
|
|
46
51
|
export type { SemanticPreset } from "./ag-grid-plus/utils/valueEnumColor";
|
package/dist/esm/index.js
CHANGED
|
@@ -49,9 +49,14 @@ export * from "./adapters";
|
|
|
49
49
|
export * from "./readPretty";
|
|
50
50
|
export * from "./standardList";
|
|
51
51
|
export * from "./attachment";
|
|
52
|
+
export * from "./scanCollect";
|
|
52
53
|
export { createEntitySelect } from "./entitySelect";
|
|
53
54
|
export { default as ExportButton, buildExportUrl, DEFAULT_EXPORT_TEMPLATE_API, resolveExportAction, resolveExportError, resolveFileName } from "./exportButton";
|
|
54
55
|
export { saveAs } from "./utils/download";
|
|
56
|
+
export { WidgetSelector } from "./dashboard";
|
|
57
|
+
// 页面持有表格实例、声明列、处理表格错误时用到的类型;宿主不必再深引 dist/esm/ag-grid-plus/interface。@author nokecy
|
|
58
|
+
|
|
59
|
+
export { GridPlusError, ErrorType, ErrorSeverity } from "./ag-grid-plus/errors";
|
|
55
60
|
export { semanticTextColors, toGridTextColor, gridValueEnum } from "./ag-grid-plus/utils/valueEnumColor";
|
|
56
61
|
export { contrastRatio, relativeLuminance, darkenUntilContrast, lightenUntilContrast, toRgb, toHsl, fromHsl } from "./utils/contrast";
|
|
57
62
|
export { BusinessDecimal, decimal, decimalText, nonNegativeDecimal, roundDecimal, sumDecimals, formatDecimal } from "./utils/businessDecimal";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NumberPicker as FormilyNumberPicker } from '@formily/antd-v5';
|
|
2
|
-
import { Input as AntInput, InputNumber as AntInputNumber, Select as AntSelect, Switch as AntSwitch, Checkbox as AntCheckbox, Radio as AntRadio, DatePicker as AntDatePicker, TimePicker as AntTimePicker, TreeSelect as AntTreeSelect, Cascader as AntCascader } from 'antd';
|
|
2
|
+
import { AutoComplete as AntAutoComplete, Input as AntInput, InputNumber as AntInputNumber, Select as AntSelect, Switch as AntSwitch, Checkbox as AntCheckbox, Radio as AntRadio, DatePicker as AntDatePicker, TimePicker as AntTimePicker, TreeSelect as AntTreeSelect, Cascader as AntCascader } from 'antd';
|
|
3
3
|
export declare const Input: typeof AntInput;
|
|
4
4
|
export declare const InputNumber: typeof AntInputNumber;
|
|
5
5
|
/** Formily 数值控件同样关闭方向键步进,保留数值类型及原有表单绑定。@author nokecy */
|
|
@@ -12,3 +12,5 @@ export declare const DatePicker: typeof AntDatePicker;
|
|
|
12
12
|
export declare const TimePicker: typeof AntTimePicker;
|
|
13
13
|
export declare const TreeSelect: typeof AntTreeSelect;
|
|
14
14
|
export declare const Cascader: typeof AntCascader;
|
|
15
|
+
/** 可手输也可从候选里选的文本(Formily 适配包里没有):值就是字符串,阅读态按文本显示。@author nokecy */
|
|
16
|
+
export declare const AutoComplete: typeof AntAutoComplete;
|
|
@@ -1,10 +1,17 @@
|
|
|
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
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
1
7
|
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); }
|
|
2
8
|
import { NumberPicker as FormilyNumberPicker, PreviewText } from '@formily/antd-v5';
|
|
3
|
-
import { ConfigProvider, Input as AntInput, InputNumber as AntInputNumber, Select as AntSelect, Switch as AntSwitch, Checkbox as AntCheckbox, Radio as AntRadio, DatePicker as AntDatePicker, TimePicker as AntTimePicker, TreeSelect as AntTreeSelect, Cascader as AntCascader } from 'antd';
|
|
9
|
+
import { AutoComplete as AntAutoComplete, ConfigProvider, Input as AntInput, InputNumber as AntInputNumber, Select as AntSelect, Switch as AntSwitch, Checkbox as AntCheckbox, Radio as AntRadio, DatePicker as AntDatePicker, TimePicker as AntTimePicker, TreeSelect as AntTreeSelect, Cascader as AntCascader } from 'antd';
|
|
4
10
|
import React from 'react';
|
|
5
11
|
import { hoistStatics } from "./hoistStatics";
|
|
6
12
|
import { selectNumberInputTextOnClick } from "./selectNumberInputTextOnClick";
|
|
7
13
|
import { flattenOptions, selectedLabels } from "./values";
|
|
14
|
+
import { matchSelectDisplayValue } from "./selectValue";
|
|
8
15
|
|
|
9
16
|
/** 普通表单控件统一阅读展示;数值控件禁用方向键步进,让表格负责上下导航。@author nokecy */
|
|
10
17
|
var readingControl = function readingControl(Control, Preview) {
|
|
@@ -19,7 +26,7 @@ var readingControl = function readingControl(Control, Preview) {
|
|
|
19
26
|
var reading = props.readOnly || ((_props$disabled = props.disabled) !== null && _props$disabled !== void 0 ? _props$disabled : componentDisabled);
|
|
20
27
|
return reading ? /*#__PURE__*/React.createElement(PreviewText.Placeholder, {
|
|
21
28
|
value: "\u2014"
|
|
22
|
-
}, /*#__PURE__*/React.createElement(Preview, map(props))) : /*#__PURE__*/React.createElement(Control, _extends({}, props, numericInput ? {
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Preview, map(props))) : /*#__PURE__*/React.createElement(Control, _extends({}, map(props), numericInput ? {
|
|
23
30
|
keyboard: false,
|
|
24
31
|
onClick: selectNumberInputTextOnClick(props.onClick)
|
|
25
32
|
} : {}, {
|
|
@@ -42,6 +49,15 @@ var choiceOptions = function choiceOptions(props) {
|
|
|
42
49
|
var ChoicePreview = function ChoicePreview(props) {
|
|
43
50
|
return /*#__PURE__*/React.createElement("span", null, selectedLabels(props.value, flattenOptions(choiceOptions(props), props.fieldNames), props.labelInValue));
|
|
44
51
|
};
|
|
52
|
+
/** 候选值只在显示边界匹配;加载含空格的码值不会把单据标成已修改。@author nokecy */
|
|
53
|
+
var choiceDisplayProps = function choiceDisplayProps(props) {
|
|
54
|
+
var options = flattenOptions(choiceOptions(props), props.fieldNames);
|
|
55
|
+
return _objectSpread(_objectSpread(_objectSpread({}, props), 'value' in props ? {
|
|
56
|
+
value: matchSelectDisplayValue(props.value, options, props.labelInValue)
|
|
57
|
+
} : {}), 'defaultValue' in props ? {
|
|
58
|
+
defaultValue: matchSelectDisplayValue(props.defaultValue, options, props.labelInValue)
|
|
59
|
+
} : {});
|
|
60
|
+
};
|
|
45
61
|
var BooleanPreview = function BooleanPreview(props) {
|
|
46
62
|
return /*#__PURE__*/React.createElement("span", null, props.children, props.children ? ':' : '', props.checked == null ? '—' : props.checked ? '是' : '否');
|
|
47
63
|
};
|
|
@@ -55,7 +71,7 @@ Input.Search = readingControl(AntInput.Search, PreviewText.Input);
|
|
|
55
71
|
export var InputNumber = readingControl(AntInputNumber, PreviewText.NumberPicker, undefined, true);
|
|
56
72
|
/** Formily 数值控件同样关闭方向键步进,保留数值类型及原有表单绑定。@author nokecy */
|
|
57
73
|
export var NumberPicker = readingControl(FormilyNumberPicker, PreviewText.NumberPicker, undefined, true);
|
|
58
|
-
export var Select = readingControl(AntSelect, ChoicePreview);
|
|
74
|
+
export var Select = readingControl(AntSelect, ChoicePreview, choiceDisplayProps);
|
|
59
75
|
export var Switch = readingControl(AntSwitch, BooleanPreview);
|
|
60
76
|
export var Checkbox = readingControl(AntCheckbox, BooleanPreview);
|
|
61
77
|
Checkbox.Group = readingControl(AntCheckbox.Group, ChoicePreview);
|
|
@@ -66,4 +82,6 @@ DatePicker.RangePicker = readingControl(AntDatePicker.RangePicker, PreviewText.D
|
|
|
66
82
|
export var TimePicker = readingControl(AntTimePicker, PreviewText.TimePicker);
|
|
67
83
|
TimePicker.RangePicker = readingControl(AntTimePicker.RangePicker, PreviewText.TimeRangePicker);
|
|
68
84
|
export var TreeSelect = readingControl(AntTreeSelect, PreviewText.TreeSelect);
|
|
69
|
-
export var Cascader = readingControl(AntCascader, PreviewText.Cascader);
|
|
85
|
+
export var Cascader = readingControl(AntCascader, PreviewText.Cascader);
|
|
86
|
+
/** 可手输也可从候选里选的文本(Formily 适配包里没有):值就是字符串,阅读态按文本显示。@author nokecy */
|
|
87
|
+
export var AutoComplete = readingControl(AntAutoComplete, PreviewText.Input);
|
|
@@ -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
|
-
|
|
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
|
+
};
|
|
@@ -3,6 +3,7 @@ import { connect, mapReadPretty } from '@formily/react';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { InputNumber } from "./controls";
|
|
5
5
|
import { decimalText } from "../utils/businessDecimal";
|
|
6
|
+
import { withReadOnlyFormatter } from "../array-table/readOnlyFormatters";
|
|
6
7
|
|
|
7
8
|
/** 精确业务数值录入和阅读展示,零值与原始十进制字符串始终保留。@author nokecy */
|
|
8
9
|
export var DecimalInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
@@ -14,9 +15,18 @@ export var DecimalInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
14
15
|
var DecimalPreview = function DecimalPreview(_ref) {
|
|
15
16
|
var value = _ref.value,
|
|
16
17
|
formatter = _ref.formatter;
|
|
17
|
-
return /*#__PURE__*/React.createElement("span", null, value == null || value === '' ? '—' : formatter ? formatter(value, {
|
|
18
|
+
return /*#__PURE__*/React.createElement("span", null, value == null || value === '' ? '—' : typeof formatter === 'function' ? formatter(value, {
|
|
18
19
|
userTyping: false,
|
|
19
20
|
input: String(value)
|
|
20
21
|
}) : decimalText(value));
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
+
/** 精确数值的静默态沿用自身阅读规则,允许表格按已知显示契约懒挂载。@author nokecy */
|
|
24
|
+
export var DecimalPicker = withReadOnlyFormatter(connect(DecimalInput, mapReadPretty(DecimalPreview)), function (value, ctx) {
|
|
25
|
+
var _ctx$fieldSchema;
|
|
26
|
+
if (value == null || value === '') return '';
|
|
27
|
+
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;
|
|
28
|
+
return typeof formatter === 'function' ? String(formatter(value, {
|
|
29
|
+
userTyping: false,
|
|
30
|
+
input: String(value)
|
|
31
|
+
})) : decimalText(value);
|
|
32
|
+
});
|
|
@@ -14,6 +14,8 @@ import { hoistStatics } from "./hoistStatics";
|
|
|
14
14
|
import * as Reading from "./controls";
|
|
15
15
|
import { selectNumberInputTextOnClick } from "./selectNumberInputTextOnClick";
|
|
16
16
|
import { withReadingArrayTable } from "./arrayTable";
|
|
17
|
+
import { flattenOptions } from "./values";
|
|
18
|
+
import { matchSelectDisplayValue } from "./selectValue";
|
|
17
19
|
export { withReactiveSchemaScope } from "./schemaScope";
|
|
18
20
|
|
|
19
21
|
/** 动态表单统一阅读展示;数值控件关闭方向键步进,保留表格导航与字段值。@author nokecy */
|
|
@@ -25,18 +27,24 @@ export function withReadingFields(components) {
|
|
|
25
27
|
});
|
|
26
28
|
var wrap = function wrap(Control, Preview) {
|
|
27
29
|
var numericInput = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
30
|
+
var choiceInput = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
28
31
|
var Component = observer(function (props) {
|
|
32
|
+
var _field$dataSource;
|
|
29
33
|
var field = useField();
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
var options = field !== null && field !== void 0 && (_field$dataSource = field.dataSource) !== null && _field$dataSource !== void 0 && _field$dataSource.length ? field.dataSource : props.options;
|
|
35
|
+
var displayProps = choiceInput ? _objectSpread(_objectSpread({}, props), {}, {
|
|
36
|
+
value: matchSelectDisplayValue(props.value, flattenOptions(options, props.fieldNames), props.labelInValue)
|
|
37
|
+
}) : props;
|
|
38
|
+
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') {
|
|
39
|
+
var _field$value, _field$value2, _field$dataSource2;
|
|
32
40
|
return /*#__PURE__*/React.createElement(Preview, _extends({}, props, {
|
|
33
41
|
value: (_field$value = field === null || field === void 0 ? void 0 : field.value) !== null && _field$value !== void 0 ? _field$value : props.value,
|
|
34
42
|
checked: (_field$value2 = field === null || field === void 0 ? void 0 : field.value) !== null && _field$value2 !== void 0 ? _field$value2 : props.checked,
|
|
35
|
-
options: field !== null && field !== void 0 && (_field$
|
|
43
|
+
options: field !== null && field !== void 0 && (_field$dataSource2 = field.dataSource) !== null && _field$dataSource2 !== void 0 && _field$dataSource2.length ? field.dataSource : props.options,
|
|
36
44
|
disabled: true
|
|
37
45
|
}));
|
|
38
46
|
}
|
|
39
|
-
return /*#__PURE__*/React.createElement(Control, _extends({},
|
|
47
|
+
return /*#__PURE__*/React.createElement(Control, _extends({}, displayProps, numericInput ? {
|
|
40
48
|
keyboard: false,
|
|
41
49
|
onClick: selectNumberInputTextOnClick(props.onClick)
|
|
42
50
|
} : {}));
|
|
@@ -56,7 +64,7 @@ export function withReadingFields(components) {
|
|
|
56
64
|
try {
|
|
57
65
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
58
66
|
var name = _step.value;
|
|
59
|
-
result[name] = wrap(components[name], previews[name], name === 'NumberPicker' || name === 'InputNumber');
|
|
67
|
+
result[name] = wrap(components[name], previews[name], name === 'NumberPicker' || name === 'InputNumber', name === 'Select');
|
|
60
68
|
}
|
|
61
69
|
// ArrayTable 阅读态保留动态列的标题和显隐状态。@author nokecy
|
|
62
70
|
} 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 */
|
|
@@ -5,6 +5,29 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
5
5
|
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); }
|
|
6
6
|
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); }
|
|
7
7
|
import { isValidElement } from 'react';
|
|
8
|
+
import { findOptionByValue } from "../utils/optionValue";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 仅为控件回显匹配候选中的原生值,不回写表单,不触发变更事件。
|
|
12
|
+
* @param value 原始单选或多选值。
|
|
13
|
+
* @param options 已展开的选项。
|
|
14
|
+
* @param labelInValue 是否使用名称编码对象。
|
|
15
|
+
* @returns 命中选项的控件值;未知值原样保留。
|
|
16
|
+
* @author nokecy
|
|
17
|
+
*/
|
|
18
|
+
export function matchSelectDisplayValue(value, options, labelInValue) {
|
|
19
|
+
if (Array.isArray(value)) return value.map(function (item) {
|
|
20
|
+
return matchSelectDisplayValue(item, options, labelInValue);
|
|
21
|
+
});
|
|
22
|
+
var raw = labelInValue && value && _typeof(value) === 'object' ? value.value : value;
|
|
23
|
+
var matched = findOptionByValue(options, raw, function (option) {
|
|
24
|
+
return option.value;
|
|
25
|
+
});
|
|
26
|
+
if (!matched) return value;
|
|
27
|
+
return labelInValue && value && _typeof(value) === 'object' ? _objectSpread(_objectSpread({}, value), {}, {
|
|
28
|
+
value: matched.value
|
|
29
|
+
}) : matched.value;
|
|
30
|
+
}
|
|
8
31
|
|
|
9
32
|
/** 提取选择项的标量编码,兼容嵌套 labelInValue;保留编码 0 和显式空字符串选项。@author nokecy */
|
|
10
33
|
export function selectCode(value) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
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
2
|
import { normalizeSelectValue, selectLabel } from "./selectValue";
|
|
3
|
+
import { findOptionByValue } from "../utils/optionValue";
|
|
3
4
|
|
|
4
5
|
/** 阅读态选择项展开,保留分组内选项及自定义字段名。@author nokecy */
|
|
5
6
|
export function flattenOptions() {
|
|
@@ -30,11 +31,11 @@ export function selectedLabels(value, options, labelInValue) {
|
|
|
30
31
|
var values = Array.isArray(normalized) ? normalized : normalized == null ? [] : [normalized];
|
|
31
32
|
if (!values.length) return '—';
|
|
32
33
|
var labels = values.map(function (item) {
|
|
33
|
-
var _ref2, _selectLabel,
|
|
34
|
+
var _ref2, _selectLabel, _findOptionByValue, _item$label;
|
|
34
35
|
var raw = labelInValue ? item.value : item;
|
|
35
|
-
return (_ref2 = (_selectLabel = selectLabel((
|
|
36
|
-
return option.value
|
|
37
|
-
})) === null ||
|
|
36
|
+
return (_ref2 = (_selectLabel = selectLabel((_findOptionByValue = findOptionByValue(options, raw, function (option) {
|
|
37
|
+
return option.value;
|
|
38
|
+
})) === null || _findOptionByValue === void 0 ? void 0 : _findOptionByValue.label)) !== null && _selectLabel !== void 0 ? _selectLabel : selectLabel(labelInValue ? (_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : raw : raw)) !== null && _ref2 !== void 0 ? _ref2 : '—';
|
|
38
39
|
});
|
|
39
40
|
// 选项标签可以是React节点,交由调用组件按顺序渲染。
|
|
40
41
|
return labels.flatMap(function (label, index) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InputProps } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface ScanInputProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange' | 'onPressEnter'> {
|
|
4
|
+
value?: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
onChange?: (value: string | undefined) => void;
|
|
7
|
+
/** 回车时拿到输入框里的原文;之后输入框清空并回焦,等下一枪 */
|
|
8
|
+
onPressEnter?: (value: string | undefined) => void;
|
|
9
|
+
/** 允许 Ctrl+C / Ctrl+V 与右键菜单。默认禁止,逼着走扫码,防止手工粘贴错码 */
|
|
10
|
+
allowPaste?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 扫码输入框(Formily 受控,可直接作 schema 的 x-component)。
|
|
14
|
+
*
|
|
15
|
+
* 回车后**清空并回焦**:清空不回焦的话,操作员每扫完一枪都得用鼠标点回这个框,
|
|
16
|
+
* 第二枪根本打不进去,只会被当成扫码枪坏了。
|
|
17
|
+
*
|
|
18
|
+
* @author nokecy
|
|
19
|
+
*/
|
|
20
|
+
declare const ScanInput: React.FC<ScanInputProps>;
|
|
21
|
+
export default ScanInput;
|