@kne/form-creator 0.1.14 → 0.1.16
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/README.md +7 -3
- package/dist/index.css +28 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +816 -194
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +671 -125
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +3 -1
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +3 -1
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +3 -1
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +3 -1
- package/dist/locale/zh-CN.modern.js.map +1 -1
- package/package.json +9 -7
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
15
15
|
var FormInfo = require('@kne/form-info');
|
|
16
16
|
var buttonGroup = require('@kne/button-group');
|
|
17
17
|
var InfoPage = require('@kne/info-page');
|
|
18
|
+
var remoteLoader = require('@kne/remote-loader');
|
|
18
19
|
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
21
|
|
|
@@ -22,7 +23,7 @@ var SelectList__default = /*#__PURE__*/_interopDefaultLegacy(SelectList);
|
|
|
22
23
|
var FormInfo__default = /*#__PURE__*/_interopDefaultLegacy(FormInfo);
|
|
23
24
|
var InfoPage__default = /*#__PURE__*/_interopDefaultLegacy(InfoPage);
|
|
24
25
|
|
|
25
|
-
var style = {"kne-responsive-boundary":"kne-form-creator_gh14z","kne-responsive-scroll":"kne-form-creator_Kfn6L","form-creator":"kne-form-creator_Xrjrk","editor-pane":"kne-form-creator_Skfuv","preview-pane":"kne-form-creator_v4Lsp","editor-header":"kne-form-creator_WaSS-","block-list-panel":"kne-form-creator_lx8An","form-actions-setting-btn":"kne-form-creator_NekU2","panel-toolbar":"kne-form-creator_t0WxZ","panel-toolbar-extra":"kne-form-creator_O22ZM","schema-content":"kne-form-creator_9bWOD","add-block-btn":"kne-form-creator_16Zre","add-inline-btn":"kne-form-creator_iCYdB","ant-btn-disabled":"kne-form-creator_LdGtv","block-list":"kne-form-creator_wK5eK","block-section":"kne-form-creator_15IiK","block-kind-formInfo":"kne-form-creator_D0hoK","block-kind-list":"kne-form-creator_JdPhy","block-kind-tableList":"kne-form-creator_gzd64","block-kind-multiField":"kne-form-creator_t0iOJ","block-kind-steps":"kne-form-creator_QNF9W","step-section":"kne-form-creator_22ajp","block-section-header":"kne-form-creator_wS4rL","block-header-left":"kne-form-creator_t4awC","block-title":"kne-form-creator_wSVJf","block-summary":"kne-form-creator_GzeW8","block-header-actions":"kne-form-creator_Ue-nT","block-body":"kne-form-creator_je1H0","item-blocks-section":"kne-form-creator_wq4bT","nested-block-list":"kne-form-creator_4NWH4","block-section-nested":"kne-form-creator_mUKom","add-field-dropdown":"kne-form-creator_9JS0d","add-field-dropdown-item":"kne-form-creator_Ql1z3","add-field-dropdown-item-icon":"kne-form-creator_ZHB5O","add-field-dropdown-item-desc":"kne-form-creator_dcsOS","add-field-dropdown-divider":"kne-form-creator_CUK0H","add-field-dropdown-label":"kne-form-creator_bPJ-2","section-toolbar":"kne-form-creator_LUO8S","section-toolbar-label":"kne-form-creator_7KQ79","field-list":"kne-form-creator_-B7WZ","step-list":"kne-form-creator_kc1pH","step-section-header":"kne-form-creator_wkhEX","step-section-title":"kne-form-creator_NBinE","step-section-actions":"kne-form-creator_es-FC","step-index":"kne-form-creator_CCKZZ","field-row":"kne-form-creator_XMkdt","field-row-index":"kne-form-creator_a-cDo","field-row-main":"kne-form-creator_ftlwp","inline-empty":"kne-form-creator_yP-RF","action-group":"kne-form-creator_773yo","hover-reveal":"kne-form-creator_S234h","hover-reveal-active":"kne-form-creator_AE-6r","action-btn":"kne-form-creator_mLgqh","add-block-dropdown":"kne-form-creator_vmS-e","add-block-option":"kne-form-creator_gjg2Y","add-block-option-icon":"kne-form-creator_qh1hh","add-block-option-text":"kne-form-creator_G8iJO","add-block-option-title":"kne-form-creator_ETSvm","add-block-option-desc":"kne-form-creator_O0C3l","field-empty":"kne-form-creator_Nmpfl","field-label-tips-icon":"kne-form-creator_0VVaO","preview-header":"kne-form-creator_c4BT0","preview-title":"kne-form-creator_fPkK4","preview-body":"kne-form-creator_6JntQ","schema-form":"kne-form-creator_MxCWP","schema-body":"kne-form-creator_q9ydz","schema-actions":"kne-form-creator_Y4eEH","schema-actions-inner":"kne-form-creator_FT9Zf","choice-block":"kne-form-creator_RllJe","choice-selector":"kne-form-creator_5A1eM","choice-panels":"kne-form-creator_IO0MY","choice-panels-empty":"kne-form-creator_T0nND","choice-option-panel":"kne-form-creator_FQixN","choice-option-panel-title":"kne-form-creator_ofRo2","choice-option-summary":"kne-form-creator_pksH8","field-editor-form":"kne-form-creator_PGPHL","form-actions-editor":"kne-form-creator_fchMy","form-actions-switch-field":"kne-form-creator_6JE9x","form-actions-layout-panel":"kne-form-creator_rtm9D","form-actions-align-group":"kne-form-creator_51ZsV","form-actions-layout-title":"kne-form-creator_hFeiC","form-actions-gap-slider":"kne-form-creator_Gq0bk","editor-section":"kne-form-creator_jJy85","section-divider":"kne-form-creator_zA7L-","rule-editor":"kne-form-creator_bAlGU","options-editor":"kne-form-creator_AK4yO","super-select-props":"kne-form-creator_Iawhh","field-props-editor":"kne-form-creator_Gabf2","columns-editor":"kne-form-creator_DQW1N","prop-row":"kne-form-creator_7K54P","prop-label":"kne-form-creator_HAAyH","options-item":"kne-form-creator_dnOd2","table-row-card":"kne-form-creator_cwCYp","tree-options-editor":"kne-form-creator_s3nHO","tree-options-list":"kne-form-creator_Djs-E","tree-option-node":"kne-form-creator_XAcut","tree-option-row":"kne-form-creator_4K4Rj","tree-option-fields":"kne-form-creator_-4cjc","tree-option-actions":"kne-form-creator_IjCNI","tree-option-children":"kne-form-creator_pVPGJ","tree-add-sibling":"kne-form-creator_bl46P","rule-checkbox-group":"kne-form-creator_tDgVP","rule-len-row":"kne-form-creator_ATsae","rule-len-input":"kne-form-creator_jY4Ld","rule-len-sep":"kne-form-creator_jBDC8","options-list":"kne-form-creator_GUBNS","options-row":"kne-form-creator_uohD0","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","is-mobile":"kne-form-creator_LtgJz"};
|
|
26
|
+
var style = {"kne-responsive-boundary":"kne-form-creator_gh14z","kne-responsive-scroll":"kne-form-creator_Kfn6L","form-creator":"kne-form-creator_Xrjrk","editor-pane":"kne-form-creator_Skfuv","preview-pane":"kne-form-creator_v4Lsp","editor-header":"kne-form-creator_WaSS-","block-list-panel":"kne-form-creator_lx8An","form-actions-setting-btn":"kne-form-creator_NekU2","panel-toolbar":"kne-form-creator_t0WxZ","panel-toolbar-extra":"kne-form-creator_O22ZM","schema-content":"kne-form-creator_9bWOD","schema-content-file-list":"kne-form-creator_UGdXA","schema-content-file":"kne-form-creator_75EtE","schema-content-file-image":"kne-form-creator_P-be6","schema-content-file-name":"kne-form-creator_NXpTS","add-block-btn":"kne-form-creator_16Zre","add-inline-btn":"kne-form-creator_iCYdB","ant-btn-disabled":"kne-form-creator_LdGtv","block-list":"kne-form-creator_wK5eK","block-section":"kne-form-creator_15IiK","block-kind-formInfo":"kne-form-creator_D0hoK","block-kind-list":"kne-form-creator_JdPhy","block-kind-tableList":"kne-form-creator_gzd64","block-kind-multiField":"kne-form-creator_t0iOJ","block-kind-steps":"kne-form-creator_QNF9W","step-section":"kne-form-creator_22ajp","block-section-header":"kne-form-creator_wS4rL","block-header-left":"kne-form-creator_t4awC","block-title":"kne-form-creator_wSVJf","block-summary":"kne-form-creator_GzeW8","block-header-actions":"kne-form-creator_Ue-nT","block-body":"kne-form-creator_je1H0","item-blocks-section":"kne-form-creator_wq4bT","nested-block-list":"kne-form-creator_4NWH4","block-section-nested":"kne-form-creator_mUKom","add-field-dropdown":"kne-form-creator_9JS0d","add-field-dropdown-item":"kne-form-creator_Ql1z3","add-field-dropdown-item-icon":"kne-form-creator_ZHB5O","add-field-dropdown-item-desc":"kne-form-creator_dcsOS","add-field-dropdown-divider":"kne-form-creator_CUK0H","add-field-dropdown-label":"kne-form-creator_bPJ-2","section-toolbar":"kne-form-creator_LUO8S","section-toolbar-label":"kne-form-creator_7KQ79","field-list":"kne-form-creator_-B7WZ","step-list":"kne-form-creator_kc1pH","step-section-header":"kne-form-creator_wkhEX","step-section-title":"kne-form-creator_NBinE","step-section-actions":"kne-form-creator_es-FC","step-index":"kne-form-creator_CCKZZ","field-row":"kne-form-creator_XMkdt","field-row-index":"kne-form-creator_a-cDo","field-row-main":"kne-form-creator_ftlwp","inline-empty":"kne-form-creator_yP-RF","action-group":"kne-form-creator_773yo","hover-reveal":"kne-form-creator_S234h","hover-reveal-active":"kne-form-creator_AE-6r","action-btn":"kne-form-creator_mLgqh","add-block-dropdown":"kne-form-creator_vmS-e","add-block-option":"kne-form-creator_gjg2Y","add-block-option-icon":"kne-form-creator_qh1hh","add-block-option-text":"kne-form-creator_G8iJO","add-block-option-title":"kne-form-creator_ETSvm","add-block-option-desc":"kne-form-creator_O0C3l","field-empty":"kne-form-creator_Nmpfl","field-label-tips-icon":"kne-form-creator_0VVaO","preview-header":"kne-form-creator_c4BT0","preview-title":"kne-form-creator_fPkK4","preview-body":"kne-form-creator_6JntQ","schema-form":"kne-form-creator_MxCWP","schema-body":"kne-form-creator_q9ydz","schema-actions":"kne-form-creator_Y4eEH","schema-actions-inner":"kne-form-creator_FT9Zf","choice-block":"kne-form-creator_RllJe","choice-selector":"kne-form-creator_5A1eM","choice-panels":"kne-form-creator_IO0MY","choice-panels-empty":"kne-form-creator_T0nND","choice-option-panel":"kne-form-creator_FQixN","choice-option-panel-title":"kne-form-creator_ofRo2","choice-option-summary":"kne-form-creator_pksH8","field-editor-form":"kne-form-creator_PGPHL","form-actions-editor":"kne-form-creator_fchMy","form-actions-switch-field":"kne-form-creator_6JE9x","form-actions-layout-panel":"kne-form-creator_rtm9D","form-actions-align-group":"kne-form-creator_51ZsV","form-actions-layout-title":"kne-form-creator_hFeiC","form-actions-gap-slider":"kne-form-creator_Gq0bk","editor-section":"kne-form-creator_jJy85","section-divider":"kne-form-creator_zA7L-","rule-editor":"kne-form-creator_bAlGU","options-editor":"kne-form-creator_AK4yO","super-select-props":"kne-form-creator_Iawhh","field-props-editor":"kne-form-creator_Gabf2","columns-editor":"kne-form-creator_DQW1N","prop-row":"kne-form-creator_7K54P","prop-label":"kne-form-creator_HAAyH","options-item":"kne-form-creator_dnOd2","table-row-card":"kne-form-creator_cwCYp","tree-options-editor":"kne-form-creator_s3nHO","tree-options-list":"kne-form-creator_Djs-E","tree-option-node":"kne-form-creator_XAcut","tree-option-row":"kne-form-creator_4K4Rj","tree-option-fields":"kne-form-creator_-4cjc","tree-option-actions":"kne-form-creator_IjCNI","tree-option-children":"kne-form-creator_pVPGJ","tree-add-sibling":"kne-form-creator_bl46P","rule-checkbox-group":"kne-form-creator_tDgVP","rule-len-row":"kne-form-creator_ATsae","rule-len-input":"kne-form-creator_jY4Ld","rule-len-sep":"kne-form-creator_jBDC8","options-list":"kne-form-creator_GUBNS","options-row":"kne-form-creator_uohD0","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","is-mobile":"kne-form-creator_LtgJz"};
|
|
26
27
|
|
|
27
28
|
const locale$1 = {
|
|
28
29
|
addField: '添加填写项',
|
|
@@ -221,7 +222,9 @@ const locale$1 = {
|
|
|
221
222
|
schemaContentEmptyValue: '-',
|
|
222
223
|
schemaContentYes: '是',
|
|
223
224
|
schemaContentNo: '否',
|
|
224
|
-
schemaContentItemIndex: '第 {index} 项'
|
|
225
|
+
schemaContentItemIndex: '第 {index} 项',
|
|
226
|
+
schemaContentUntilToday: '至今',
|
|
227
|
+
schemaContentPasswordMasked: '••••••'
|
|
225
228
|
};
|
|
226
229
|
var zhCN = locale$1;
|
|
227
230
|
|
|
@@ -422,7 +425,9 @@ const locale = {
|
|
|
422
425
|
schemaContentEmptyValue: '-',
|
|
423
426
|
schemaContentYes: 'Yes',
|
|
424
427
|
schemaContentNo: 'No',
|
|
425
|
-
schemaContentItemIndex: 'Item {index}'
|
|
428
|
+
schemaContentItemIndex: 'Item {index}',
|
|
429
|
+
schemaContentUntilToday: 'Present',
|
|
430
|
+
schemaContentPasswordMasked: '••••••'
|
|
426
431
|
};
|
|
427
432
|
var enUS = locale;
|
|
428
433
|
|
|
@@ -1357,11 +1362,102 @@ const mapOptionItem = item => {
|
|
|
1357
1362
|
}
|
|
1358
1363
|
return next;
|
|
1359
1364
|
};
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* 搭建器选项是 { label, value, children };SelectCascader 默认 valueKey='id'、示例用 id/name。
|
|
1368
|
+
* 补齐两边的 key,避免 mapping 全部落到 undefined 导致下拉空白。
|
|
1369
|
+
*/
|
|
1370
|
+
const alignOptionKeys = function (options, _temp) {
|
|
1371
|
+
if (options === void 0) {
|
|
1372
|
+
options = [];
|
|
1373
|
+
}
|
|
1374
|
+
let {
|
|
1375
|
+
valueKey = 'value',
|
|
1376
|
+
labelKey = 'label'
|
|
1377
|
+
} = _temp === void 0 ? {} : _temp;
|
|
1378
|
+
if (!Array.isArray(options)) {
|
|
1379
|
+
return options;
|
|
1380
|
+
}
|
|
1381
|
+
return options.map(item => {
|
|
1382
|
+
if (!item || typeof item !== 'object') {
|
|
1383
|
+
return item;
|
|
1384
|
+
}
|
|
1385
|
+
const rawValue = item[valueKey] ?? item.value ?? item.id ?? item.code;
|
|
1386
|
+
const rawLabel = item[labelKey] ?? item.label ?? item.name;
|
|
1387
|
+
const next = {
|
|
1388
|
+
...item
|
|
1389
|
+
};
|
|
1390
|
+
if (rawValue != null && next[valueKey] == null) {
|
|
1391
|
+
next[valueKey] = rawValue;
|
|
1392
|
+
}
|
|
1393
|
+
if (rawLabel != null && (next[labelKey] == null || next[labelKey] === '')) {
|
|
1394
|
+
next[labelKey] = rawLabel;
|
|
1395
|
+
}
|
|
1396
|
+
if (next.id == null && rawValue != null) {
|
|
1397
|
+
next.id = rawValue;
|
|
1398
|
+
}
|
|
1399
|
+
if ((next.name == null || next.name === '') && rawLabel != null) {
|
|
1400
|
+
next.name = rawLabel;
|
|
1401
|
+
}
|
|
1402
|
+
if (Array.isArray(next.children) && next.children.length) {
|
|
1403
|
+
next.children = alignOptionKeys(next.children, {
|
|
1404
|
+
valueKey,
|
|
1405
|
+
labelKey
|
|
1406
|
+
});
|
|
1407
|
+
}
|
|
1408
|
+
return next;
|
|
1409
|
+
});
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* SelectTree 按扁平 parentId 组树,会覆盖节点上已有的 children。
|
|
1414
|
+
* 搭建器存的是嵌套 children,交给 SelectTree 前先拍平。
|
|
1415
|
+
*/
|
|
1416
|
+
const flattenTreeOptions = function (options, _temp2) {
|
|
1417
|
+
if (options === void 0) {
|
|
1418
|
+
options = [];
|
|
1419
|
+
}
|
|
1420
|
+
let {
|
|
1421
|
+
valueKey = 'value',
|
|
1422
|
+
parentKey = 'parentId',
|
|
1423
|
+
childrenKey = 'children',
|
|
1424
|
+
parentId
|
|
1425
|
+
} = _temp2 === void 0 ? {} : _temp2;
|
|
1426
|
+
const result = [];
|
|
1427
|
+
(Array.isArray(options) ? options : []).forEach(item => {
|
|
1428
|
+
if (!item || typeof item !== 'object') {
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
const nested = item[childrenKey];
|
|
1432
|
+
const node = {
|
|
1433
|
+
...item
|
|
1434
|
+
};
|
|
1435
|
+
delete node[childrenKey];
|
|
1436
|
+
if (parentId !== undefined) {
|
|
1437
|
+
node[parentKey] = parentId;
|
|
1438
|
+
}
|
|
1439
|
+
result.push(node);
|
|
1440
|
+
if (Array.isArray(nested) && nested.length) {
|
|
1441
|
+
result.push(...flattenTreeOptions(nested, {
|
|
1442
|
+
valueKey,
|
|
1443
|
+
parentKey,
|
|
1444
|
+
childrenKey,
|
|
1445
|
+
parentId: node[valueKey]
|
|
1446
|
+
}));
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
return result;
|
|
1450
|
+
};
|
|
1451
|
+
const createApiFromOptions = function (options) {
|
|
1452
|
+
if (options === void 0) {
|
|
1453
|
+
options = [];
|
|
1454
|
+
}
|
|
1455
|
+
return {
|
|
1456
|
+
loader: () => ({
|
|
1457
|
+
pageData: options.map(mapOptionItem)
|
|
1458
|
+
})
|
|
1459
|
+
};
|
|
1460
|
+
};
|
|
1365
1461
|
|
|
1366
1462
|
const {
|
|
1367
1463
|
useOnChange: useOnChange$1
|
|
@@ -1370,6 +1466,7 @@ const hasNestedOptions = options => Array.isArray(options) && options.some(item
|
|
|
1370
1466
|
const createField = function (Component, _temp) {
|
|
1371
1467
|
let {
|
|
1372
1468
|
preferOptions = false,
|
|
1469
|
+
flattenTree = false,
|
|
1373
1470
|
placeholderPrefix = '请选择'
|
|
1374
1471
|
} = _temp === void 0 ? {} : _temp;
|
|
1375
1472
|
const Field = props => {
|
|
@@ -1379,14 +1476,28 @@ const createField = function (Component, _temp) {
|
|
|
1379
1476
|
placeholder,
|
|
1380
1477
|
...rest
|
|
1381
1478
|
} = props;
|
|
1382
|
-
const
|
|
1383
|
-
const
|
|
1479
|
+
const valueKey = rest.valueKey || 'value';
|
|
1480
|
+
const labelKey = rest.labelKey || 'label';
|
|
1481
|
+
const parentKey = rest.parentKey || 'parentId';
|
|
1482
|
+
const flattened = flattenTree && Array.isArray(options) ? flattenTreeOptions(options, {
|
|
1483
|
+
valueKey,
|
|
1484
|
+
parentKey
|
|
1485
|
+
}) : options;
|
|
1486
|
+
const resolvedOptions = Array.isArray(flattened) ? alignOptionKeys(flattened, {
|
|
1487
|
+
valueKey,
|
|
1488
|
+
labelKey
|
|
1489
|
+
}) : flattened;
|
|
1490
|
+
const useOptionsDirectly = preferOptions || hasNestedOptions(resolvedOptions);
|
|
1491
|
+
const mergedApi = api || (!useOptionsDirectly && Array.isArray(resolvedOptions) && resolvedOptions.length ? createApiFromOptions(resolvedOptions) : undefined);
|
|
1384
1492
|
const resolvedPlaceholder = placeholder != null && String(placeholder).trim() ? placeholder : `${placeholderPrefix}${props.label || ''}`;
|
|
1385
1493
|
const render = useOnChange$1(Object.assign({}, {
|
|
1386
1494
|
isPopup: true,
|
|
1387
1495
|
placeholder: resolvedPlaceholder
|
|
1388
|
-
}, rest,
|
|
1389
|
-
|
|
1496
|
+
}, rest, {
|
|
1497
|
+
valueKey,
|
|
1498
|
+
labelKey
|
|
1499
|
+
}, useOptionsDirectly && Array.isArray(resolvedOptions) ? {
|
|
1500
|
+
options: resolvedOptions
|
|
1390
1501
|
} : {}, mergedApi ? {
|
|
1391
1502
|
api: mergedApi
|
|
1392
1503
|
} : {}));
|
|
@@ -1400,7 +1511,8 @@ const SuperSelectTableList = createField(SelectList.SelectTableList, {
|
|
|
1400
1511
|
preferOptions: true
|
|
1401
1512
|
});
|
|
1402
1513
|
const SuperSelectTree = createField(SelectList.SelectTree, {
|
|
1403
|
-
preferOptions: true
|
|
1514
|
+
preferOptions: true,
|
|
1515
|
+
flattenTree: true
|
|
1404
1516
|
});
|
|
1405
1517
|
const SuperSelectCascader = createField(SelectList.SelectCascader, {
|
|
1406
1518
|
preferOptions: true
|
|
@@ -1519,19 +1631,47 @@ const stringWithEnumSchema = field => {
|
|
|
1519
1631
|
}
|
|
1520
1632
|
return schema;
|
|
1521
1633
|
};
|
|
1634
|
+
const optionValueSchema = {
|
|
1635
|
+
type: 'object',
|
|
1636
|
+
display: 'option'
|
|
1637
|
+
};
|
|
1522
1638
|
const superSelectValueSchema = field => {
|
|
1523
1639
|
if (field?.props?.single) {
|
|
1524
1640
|
return {
|
|
1525
|
-
|
|
1641
|
+
...optionValueSchema
|
|
1526
1642
|
};
|
|
1527
1643
|
}
|
|
1528
1644
|
return {
|
|
1529
1645
|
type: 'array',
|
|
1530
1646
|
items: {
|
|
1531
|
-
|
|
1647
|
+
...optionValueSchema
|
|
1532
1648
|
}
|
|
1533
1649
|
};
|
|
1534
1650
|
};
|
|
1651
|
+
const PICKER_TO_FORMAT = {
|
|
1652
|
+
date: 'date',
|
|
1653
|
+
week: 'week',
|
|
1654
|
+
month: 'month',
|
|
1655
|
+
quarter: 'quarter',
|
|
1656
|
+
year: 'year'
|
|
1657
|
+
};
|
|
1658
|
+
const datePickerValueSchema = field => {
|
|
1659
|
+
const picker = field?.props?.picker || 'date';
|
|
1660
|
+
const format = field?.props?.showTime ? 'date-time' : PICKER_TO_FORMAT[picker] || 'date';
|
|
1661
|
+
const item = {
|
|
1662
|
+
type: 'string',
|
|
1663
|
+
format
|
|
1664
|
+
};
|
|
1665
|
+
if (field?.props?.range) {
|
|
1666
|
+
return {
|
|
1667
|
+
type: 'array',
|
|
1668
|
+
items: item,
|
|
1669
|
+
minItems: 2,
|
|
1670
|
+
maxItems: 2
|
|
1671
|
+
};
|
|
1672
|
+
}
|
|
1673
|
+
return item;
|
|
1674
|
+
};
|
|
1535
1675
|
defineField('Input', {
|
|
1536
1676
|
label: '单行文本',
|
|
1537
1677
|
group: '基础字段',
|
|
@@ -1753,16 +1893,7 @@ defineField('DatePicker', {
|
|
|
1753
1893
|
},
|
|
1754
1894
|
hasFieldProps: true,
|
|
1755
1895
|
resolveComponent: props => props?.range ? reactFormAntd.DatePicker.RangePicker || reactFormAntd.DatePicker : reactFormAntd.DatePicker,
|
|
1756
|
-
valueSchema:
|
|
1757
|
-
type: 'array',
|
|
1758
|
-
items: {
|
|
1759
|
-
type: 'string'
|
|
1760
|
-
},
|
|
1761
|
-
minItems: 2,
|
|
1762
|
-
maxItems: 2
|
|
1763
|
-
} : {
|
|
1764
|
-
type: 'string'
|
|
1765
|
-
}
|
|
1896
|
+
valueSchema: datePickerValueSchema
|
|
1766
1897
|
});
|
|
1767
1898
|
|
|
1768
1899
|
/**
|
|
@@ -1778,6 +1909,8 @@ defineField('DatePicker', {
|
|
|
1778
1909
|
* preset({ type, definition }) 的 fields 项还可传:
|
|
1779
1910
|
* - groupName?: string 自定义类型下拉分组名;不传则归入「扩展字段」
|
|
1780
1911
|
* - valueSchema?: object | (field) => object 提交值的 JSON Schema 片段;缺省回退 { type: 'string' }
|
|
1912
|
+
* 可含 format(date/month/week/time/date-time/password/color/json)与 display(option/phone/file/typed-date-range/date-to-today/html/money),供 SchemaContent 预览
|
|
1913
|
+
* - formatDisplayValue?: (value, field, ctx) => string 覆盖 valueSchema 默认预览
|
|
1781
1914
|
*/
|
|
1782
1915
|
const registerField = (type, definition) => {
|
|
1783
1916
|
const propsSchema = Array.isArray(definition?.propsSchema) ? definition.propsSchema : undefined;
|
|
@@ -2297,14 +2430,15 @@ const TYPE_TAG_COLORS = {
|
|
|
2297
2430
|
Checkbox: 'green',
|
|
2298
2431
|
DatePicker: 'lime'
|
|
2299
2432
|
};
|
|
2300
|
-
const FieldRow =
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2433
|
+
const FieldRow = _ref => {
|
|
2434
|
+
let {
|
|
2435
|
+
field,
|
|
2436
|
+
index,
|
|
2437
|
+
total,
|
|
2438
|
+
onEdit,
|
|
2439
|
+
onDelete,
|
|
2440
|
+
onMove
|
|
2441
|
+
} = _ref;
|
|
2308
2442
|
const {
|
|
2309
2443
|
formatMessage
|
|
2310
2444
|
} = reactIntl.useIntl();
|
|
@@ -3502,18 +3636,24 @@ const RulePresetEditor = () => {
|
|
|
3502
3636
|
id: 'ruleLenMin'
|
|
3503
3637
|
}),
|
|
3504
3638
|
min: 0,
|
|
3505
|
-
display:
|
|
3506
|
-
|
|
3507
|
-
|
|
3639
|
+
display: _ref => {
|
|
3640
|
+
let {
|
|
3641
|
+
openApi
|
|
3642
|
+
} = _ref;
|
|
3643
|
+
return (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET);
|
|
3644
|
+
}
|
|
3508
3645
|
}, "lenMin"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.InputNumber, {
|
|
3509
3646
|
name: "lenMax",
|
|
3510
3647
|
label: formatMessage({
|
|
3511
3648
|
id: 'ruleLenMax'
|
|
3512
3649
|
}),
|
|
3513
3650
|
min: 0,
|
|
3514
|
-
display:
|
|
3515
|
-
|
|
3516
|
-
|
|
3651
|
+
display: _ref2 => {
|
|
3652
|
+
let {
|
|
3653
|
+
openApi
|
|
3654
|
+
} = _ref2;
|
|
3655
|
+
return (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET);
|
|
3656
|
+
}
|
|
3517
3657
|
}, "lenMax"), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3518
3658
|
block: true,
|
|
3519
3659
|
children: /*#__PURE__*/jsxRuntime.jsx(Text$2, {
|
|
@@ -3554,19 +3694,30 @@ const createEmptyTableRow = columns => {
|
|
|
3554
3694
|
});
|
|
3555
3695
|
return row;
|
|
3556
3696
|
};
|
|
3557
|
-
const ensureOptionKeys = (list
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3697
|
+
const ensureOptionKeys = function (list) {
|
|
3698
|
+
if (list === void 0) {
|
|
3699
|
+
list = [];
|
|
3700
|
+
}
|
|
3701
|
+
return list.map(item => ({
|
|
3702
|
+
...item,
|
|
3703
|
+
_key: item._key || createOptionKey(),
|
|
3704
|
+
children: Array.isArray(item.children) ? ensureOptionKeys(item.children) : undefined
|
|
3705
|
+
}));
|
|
3706
|
+
};
|
|
3707
|
+
const hasMissingOptionKey = function (list) {
|
|
3708
|
+
if (list === void 0) {
|
|
3709
|
+
list = [];
|
|
3710
|
+
}
|
|
3711
|
+
return list.some(item => !item?._key || Array.isArray(item.children) && hasMissingOptionKey(item.children));
|
|
3712
|
+
};
|
|
3563
3713
|
|
|
3564
3714
|
/** 扁平选项(非树) */
|
|
3565
|
-
const FlatOptionRows =
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3715
|
+
const FlatOptionRows = _ref => {
|
|
3716
|
+
let {
|
|
3717
|
+
list,
|
|
3718
|
+
onChange,
|
|
3719
|
+
allowDescription
|
|
3720
|
+
} = _ref;
|
|
3570
3721
|
const {
|
|
3571
3722
|
formatMessage
|
|
3572
3723
|
} = reactIntl.useIntl();
|
|
@@ -3632,15 +3783,16 @@ const FlatOptionRows = ({
|
|
|
3632
3783
|
};
|
|
3633
3784
|
|
|
3634
3785
|
/** 树形 / 级联选项 */
|
|
3635
|
-
const TreeOptionNode =
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3786
|
+
const TreeOptionNode = _ref2 => {
|
|
3787
|
+
let {
|
|
3788
|
+
item,
|
|
3789
|
+
index,
|
|
3790
|
+
siblings,
|
|
3791
|
+
onChangeSiblings,
|
|
3792
|
+
allowDescription,
|
|
3793
|
+
depth,
|
|
3794
|
+
maxDepth = 4
|
|
3795
|
+
} = _ref2;
|
|
3644
3796
|
const {
|
|
3645
3797
|
formatMessage
|
|
3646
3798
|
} = reactIntl.useIntl();
|
|
@@ -3737,11 +3889,12 @@ const TreeOptionNode = ({
|
|
|
3737
3889
|
}) : null]
|
|
3738
3890
|
});
|
|
3739
3891
|
};
|
|
3740
|
-
const TreeOptionsEditor =
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3892
|
+
const TreeOptionsEditor = _ref3 => {
|
|
3893
|
+
let {
|
|
3894
|
+
value = [],
|
|
3895
|
+
onChange,
|
|
3896
|
+
allowDescription
|
|
3897
|
+
} = _ref3;
|
|
3745
3898
|
const {
|
|
3746
3899
|
formatMessage
|
|
3747
3900
|
} = reactIntl.useIntl();
|
|
@@ -3780,10 +3933,11 @@ const TreeOptionsEditor = ({
|
|
|
3780
3933
|
})]
|
|
3781
3934
|
});
|
|
3782
3935
|
};
|
|
3783
|
-
const ColumnsEditor =
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3936
|
+
const ColumnsEditor = _ref4 => {
|
|
3937
|
+
let {
|
|
3938
|
+
value = [],
|
|
3939
|
+
onChange
|
|
3940
|
+
} = _ref4;
|
|
3787
3941
|
const {
|
|
3788
3942
|
formatMessage
|
|
3789
3943
|
} = reactIntl.useIntl();
|
|
@@ -3878,11 +4032,12 @@ const ColumnsEditor = ({
|
|
|
3878
4032
|
}, "columns-editor")]
|
|
3879
4033
|
});
|
|
3880
4034
|
};
|
|
3881
|
-
const TableRowsEditor =
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
4035
|
+
const TableRowsEditor = _ref5 => {
|
|
4036
|
+
let {
|
|
4037
|
+
columns = [],
|
|
4038
|
+
value = [],
|
|
4039
|
+
onChange
|
|
4040
|
+
} = _ref5;
|
|
3886
4041
|
const {
|
|
3887
4042
|
formatMessage
|
|
3888
4043
|
} = reactIntl.useIntl();
|
|
@@ -4007,15 +4162,16 @@ const TableRowsEditor = ({
|
|
|
4007
4162
|
}, "table-rows-editor")]
|
|
4008
4163
|
});
|
|
4009
4164
|
};
|
|
4010
|
-
const OptionsEditor =
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4165
|
+
const OptionsEditor = _ref6 => {
|
|
4166
|
+
let {
|
|
4167
|
+
value = [],
|
|
4168
|
+
onChange,
|
|
4169
|
+
allowDescription = false,
|
|
4170
|
+
allowChildren = false,
|
|
4171
|
+
hasColumns = false,
|
|
4172
|
+
columns = [],
|
|
4173
|
+
onColumnsChange
|
|
4174
|
+
} = _ref6;
|
|
4019
4175
|
const {
|
|
4020
4176
|
formatMessage
|
|
4021
4177
|
} = reactIntl.useIntl();
|
|
@@ -4082,9 +4238,10 @@ const OptionsEditor = ({
|
|
|
4082
4238
|
};
|
|
4083
4239
|
var OptionsEditor$1 = OptionsEditor;
|
|
4084
4240
|
|
|
4085
|
-
const SuperSelectPropsEditor =
|
|
4086
|
-
|
|
4087
|
-
|
|
4241
|
+
const SuperSelectPropsEditor = _ref => {
|
|
4242
|
+
let {
|
|
4243
|
+
definition
|
|
4244
|
+
} = _ref;
|
|
4088
4245
|
const {
|
|
4089
4246
|
formatMessage
|
|
4090
4247
|
} = reactIntl.useIntl();
|
|
@@ -4122,9 +4279,12 @@ const SuperSelectPropsEditor = ({
|
|
|
4122
4279
|
})
|
|
4123
4280
|
}, "allowClear"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Checkbox, {
|
|
4124
4281
|
name: "allowSelectedAll",
|
|
4125
|
-
display:
|
|
4126
|
-
|
|
4127
|
-
|
|
4282
|
+
display: _ref2 => {
|
|
4283
|
+
let {
|
|
4284
|
+
openApi
|
|
4285
|
+
} = _ref2;
|
|
4286
|
+
return !openApi?.data?.single;
|
|
4287
|
+
},
|
|
4128
4288
|
children: formatMessage({
|
|
4129
4289
|
id: 'superSelectAllowSelectedAll'
|
|
4130
4290
|
})
|
|
@@ -4146,9 +4306,12 @@ const SuperSelectPropsEditor = ({
|
|
|
4146
4306
|
placeholder: formatMessage({
|
|
4147
4307
|
id: 'superSelectMaxLengthPlaceholder'
|
|
4148
4308
|
}),
|
|
4149
|
-
display:
|
|
4150
|
-
|
|
4151
|
-
|
|
4309
|
+
display: _ref3 => {
|
|
4310
|
+
let {
|
|
4311
|
+
openApi
|
|
4312
|
+
} = _ref3;
|
|
4313
|
+
return !openApi?.data?.single;
|
|
4314
|
+
}
|
|
4152
4315
|
}, "maxLength"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
|
|
4153
4316
|
name: "placeholder",
|
|
4154
4317
|
label: formatMessage({
|
|
@@ -4381,9 +4544,12 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4381
4544
|
}]
|
|
4382
4545
|
}, "format"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Checkbox, {
|
|
4383
4546
|
name: "showTime",
|
|
4384
|
-
display:
|
|
4385
|
-
|
|
4386
|
-
|
|
4547
|
+
display: _ref => {
|
|
4548
|
+
let {
|
|
4549
|
+
openApi
|
|
4550
|
+
} = _ref;
|
|
4551
|
+
return (openApi?.data?.picker || 'date') === 'date';
|
|
4552
|
+
},
|
|
4387
4553
|
children: formatMessage({
|
|
4388
4554
|
id: 'propShowTime'
|
|
4389
4555
|
})
|
|
@@ -4410,10 +4576,11 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4410
4576
|
return [];
|
|
4411
4577
|
}
|
|
4412
4578
|
};
|
|
4413
|
-
const FieldPropsEditor =
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4579
|
+
const FieldPropsEditor = _ref2 => {
|
|
4580
|
+
let {
|
|
4581
|
+
type,
|
|
4582
|
+
definition: definitionProp
|
|
4583
|
+
} = _ref2;
|
|
4417
4584
|
const {
|
|
4418
4585
|
formatMessage
|
|
4419
4586
|
} = reactIntl.useIntl();
|
|
@@ -5005,13 +5172,14 @@ const buildMultipleHint = (formatMessage, minLength, maxLength) => {
|
|
|
5005
5172
|
* choice:同一条选项 UI;mode=single 只挂载一支;mode=multiple 平铺所有选中支。
|
|
5006
5173
|
* 外层用 InfoPage.Part 的 title 展示标题。
|
|
5007
5174
|
*/
|
|
5008
|
-
const ChoiceBlock =
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5175
|
+
const ChoiceBlock = _ref => {
|
|
5176
|
+
let {
|
|
5177
|
+
block,
|
|
5178
|
+
preview = false,
|
|
5179
|
+
isMobile = false,
|
|
5180
|
+
formatMessage,
|
|
5181
|
+
renderOptionContent
|
|
5182
|
+
} = _ref;
|
|
5015
5183
|
const mode = block.mode === 'multiple' ? 'multiple' : 'single';
|
|
5016
5184
|
const selectorName = resolveSelectorName(block);
|
|
5017
5185
|
const options = react.useMemo(() => block.options || [], [block.options]);
|
|
@@ -5195,6 +5363,7 @@ const renderFieldElements = function (fields, preview, _temp) {
|
|
|
5195
5363
|
}
|
|
5196
5364
|
const definition = getFieldDefinition(field.type);
|
|
5197
5365
|
const props = {
|
|
5366
|
+
...(definition?.defaultProps || {}),
|
|
5198
5367
|
...(field.props || {})
|
|
5199
5368
|
};
|
|
5200
5369
|
if (definition?.optionsAllowDescription && props.options?.length && !props.api && !definition.optionsAllowChildren) {
|
|
@@ -6134,6 +6303,543 @@ const FormCreator = withLocale$1(_ref => {
|
|
|
6134
6303
|
});
|
|
6135
6304
|
var FormCreator$1 = FormCreator;
|
|
6136
6305
|
|
|
6306
|
+
const IMAGE_EXT = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(?:[?#].*)?$/i;
|
|
6307
|
+
const toFileList = value => {
|
|
6308
|
+
if (value == null || value === '') {
|
|
6309
|
+
return [];
|
|
6310
|
+
}
|
|
6311
|
+
return Array.isArray(value) ? value : [value];
|
|
6312
|
+
};
|
|
6313
|
+
const isHttpLike = value => typeof value === 'string' && /^(https?:|blob:|data:)/i.test(value);
|
|
6314
|
+
const pickFilePreviewProps = file => {
|
|
6315
|
+
if (file == null || file === '') {
|
|
6316
|
+
return null;
|
|
6317
|
+
}
|
|
6318
|
+
if (typeof file === 'string') {
|
|
6319
|
+
const filename = file.split('/').pop() || file;
|
|
6320
|
+
if (isHttpLike(file)) {
|
|
6321
|
+
return {
|
|
6322
|
+
src: file,
|
|
6323
|
+
filename,
|
|
6324
|
+
originName: filename
|
|
6325
|
+
};
|
|
6326
|
+
}
|
|
6327
|
+
return {
|
|
6328
|
+
filename,
|
|
6329
|
+
originName: filename
|
|
6330
|
+
};
|
|
6331
|
+
}
|
|
6332
|
+
if (typeof file !== 'object') {
|
|
6333
|
+
return null;
|
|
6334
|
+
}
|
|
6335
|
+
const filename = file.filename || file.name || file.originName || file.originFileObj?.name;
|
|
6336
|
+
const src = file.src || file.url || file.path || file.thumbUrl;
|
|
6337
|
+
const id = file.id || file.uuid || file.fileId;
|
|
6338
|
+
if (!src && !id && !filename) {
|
|
6339
|
+
return null;
|
|
6340
|
+
}
|
|
6341
|
+
return {
|
|
6342
|
+
...(src ? {
|
|
6343
|
+
src
|
|
6344
|
+
} : {}),
|
|
6345
|
+
...(id ? {
|
|
6346
|
+
id
|
|
6347
|
+
} : {}),
|
|
6348
|
+
filename,
|
|
6349
|
+
originName: file.originName || filename,
|
|
6350
|
+
mimetype: file.mimetype || file.type || file.originFileObj?.type
|
|
6351
|
+
};
|
|
6352
|
+
};
|
|
6353
|
+
const isImageFile = (item, field) => {
|
|
6354
|
+
const type = field?.type;
|
|
6355
|
+
if (type === 'Avatar' || type === 'Signature') {
|
|
6356
|
+
return true;
|
|
6357
|
+
}
|
|
6358
|
+
const mime = item?.mimetype;
|
|
6359
|
+
if (typeof mime === 'string' && mime.startsWith('image/')) {
|
|
6360
|
+
return true;
|
|
6361
|
+
}
|
|
6362
|
+
return IMAGE_EXT.test(String(item?.filename || item?.originName || item?.src || ''));
|
|
6363
|
+
};
|
|
6364
|
+
const FileFieldPreview = remoteLoader.createWithRemoteLoader({
|
|
6365
|
+
modules: ['components-core:File@FileLink', 'components-core:Image']
|
|
6366
|
+
})(_ref => {
|
|
6367
|
+
let {
|
|
6368
|
+
remoteModules,
|
|
6369
|
+
value,
|
|
6370
|
+
field
|
|
6371
|
+
} = _ref;
|
|
6372
|
+
const [FileLink, Image] = remoteModules;
|
|
6373
|
+
const files = toFileList(value).map(pickFilePreviewProps).filter(Boolean);
|
|
6374
|
+
if (!files.length) {
|
|
6375
|
+
return null;
|
|
6376
|
+
}
|
|
6377
|
+
return /*#__PURE__*/jsxRuntime.jsx(antd.Flex, {
|
|
6378
|
+
vertical: true,
|
|
6379
|
+
gap: 8,
|
|
6380
|
+
className: style['schema-content-file-list'],
|
|
6381
|
+
children: files.map((item, index) => {
|
|
6382
|
+
const key = item.id || item.src || item.filename || String(index);
|
|
6383
|
+
const filename = item.filename || item.originName || '';
|
|
6384
|
+
const canPreview = !!(item.id || item.src);
|
|
6385
|
+
const asImage = isImageFile(item, field);
|
|
6386
|
+
if (!canPreview) {
|
|
6387
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
6388
|
+
className: style['schema-content-file-name'],
|
|
6389
|
+
children: filename
|
|
6390
|
+
}, key);
|
|
6391
|
+
}
|
|
6392
|
+
const linkProps = {
|
|
6393
|
+
id: item.id,
|
|
6394
|
+
src: item.src,
|
|
6395
|
+
url: item.src,
|
|
6396
|
+
filename,
|
|
6397
|
+
originName: item.originName || filename
|
|
6398
|
+
};
|
|
6399
|
+
if (asImage) {
|
|
6400
|
+
const preview = field?.type === 'Avatar' ? /*#__PURE__*/jsxRuntime.jsx(Image.Avatar, {
|
|
6401
|
+
id: item.id,
|
|
6402
|
+
src: item.src,
|
|
6403
|
+
size: 64,
|
|
6404
|
+
shape: "square",
|
|
6405
|
+
alt: filename
|
|
6406
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(Image, {
|
|
6407
|
+
id: item.id,
|
|
6408
|
+
src: item.src,
|
|
6409
|
+
alt: filename,
|
|
6410
|
+
className: style['schema-content-file-image']
|
|
6411
|
+
});
|
|
6412
|
+
return /*#__PURE__*/jsxRuntime.jsx(FileLink, {
|
|
6413
|
+
className: style['schema-content-file'],
|
|
6414
|
+
icon: null,
|
|
6415
|
+
...linkProps,
|
|
6416
|
+
children: preview
|
|
6417
|
+
}, key);
|
|
6418
|
+
}
|
|
6419
|
+
return /*#__PURE__*/jsxRuntime.jsx(FileLink, {
|
|
6420
|
+
className: style['schema-content-file'],
|
|
6421
|
+
...linkProps,
|
|
6422
|
+
children: filename
|
|
6423
|
+
}, key);
|
|
6424
|
+
})
|
|
6425
|
+
});
|
|
6426
|
+
});
|
|
6427
|
+
var FileFieldPreview$1 = FileFieldPreview;
|
|
6428
|
+
|
|
6429
|
+
const TEMPORAL_PATTERN = {
|
|
6430
|
+
date: 'YYYY-MM-DD',
|
|
6431
|
+
month: 'YYYY-MM',
|
|
6432
|
+
time: 'HH:mm:ss',
|
|
6433
|
+
'date-time': 'YYYY-MM-DD HH:mm:ss',
|
|
6434
|
+
year: 'YYYY'
|
|
6435
|
+
};
|
|
6436
|
+
const TYPE_TO_TEMPORAL = {
|
|
6437
|
+
date: 'date',
|
|
6438
|
+
month: 'month',
|
|
6439
|
+
week: 'week',
|
|
6440
|
+
time: 'time',
|
|
6441
|
+
year: 'year',
|
|
6442
|
+
quarter: 'quarter',
|
|
6443
|
+
datetime: 'date-time',
|
|
6444
|
+
'date-time': 'date-time'
|
|
6445
|
+
};
|
|
6446
|
+
const pad = n => String(n).padStart(2, '0');
|
|
6447
|
+
const isEmptyValue = value => {
|
|
6448
|
+
if (value == null || value === '') {
|
|
6449
|
+
return true;
|
|
6450
|
+
}
|
|
6451
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
6452
|
+
return true;
|
|
6453
|
+
}
|
|
6454
|
+
return false;
|
|
6455
|
+
};
|
|
6456
|
+
const toDate = value => {
|
|
6457
|
+
if (value == null || value === '') {
|
|
6458
|
+
return null;
|
|
6459
|
+
}
|
|
6460
|
+
if (value instanceof Date) {
|
|
6461
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
6462
|
+
}
|
|
6463
|
+
if (typeof value.toDate === 'function') {
|
|
6464
|
+
const next = value.toDate();
|
|
6465
|
+
return next instanceof Date && !Number.isNaN(next.getTime()) ? next : null;
|
|
6466
|
+
}
|
|
6467
|
+
if (typeof value.format === 'function' && typeof value.valueOf === 'function') {
|
|
6468
|
+
const next = new Date(value.valueOf());
|
|
6469
|
+
return Number.isNaN(next.getTime()) ? null : next;
|
|
6470
|
+
}
|
|
6471
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
6472
|
+
const next = new Date(value);
|
|
6473
|
+
return Number.isNaN(next.getTime()) ? null : next;
|
|
6474
|
+
}
|
|
6475
|
+
return null;
|
|
6476
|
+
};
|
|
6477
|
+
const isoWeek = date => {
|
|
6478
|
+
const tmp = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
6479
|
+
const day = tmp.getUTCDay() || 7;
|
|
6480
|
+
tmp.setUTCDate(tmp.getUTCDate() + 4 - day);
|
|
6481
|
+
const yearStart = new Date(Date.UTC(tmp.getUTCFullYear(), 0, 1));
|
|
6482
|
+
const week = Math.ceil(((tmp - yearStart) / 86400000 + 1) / 7);
|
|
6483
|
+
return {
|
|
6484
|
+
year: tmp.getUTCFullYear(),
|
|
6485
|
+
week
|
|
6486
|
+
};
|
|
6487
|
+
};
|
|
6488
|
+
const applyPattern = (date, pattern) => {
|
|
6489
|
+
const year = date.getFullYear();
|
|
6490
|
+
const month = date.getMonth() + 1;
|
|
6491
|
+
const quarter = Math.ceil(month / 3);
|
|
6492
|
+
return pattern.replace(/YYYY/g, String(year)).replace(/MM/g, pad(month)).replace(/DD/g, pad(date.getDate())).replace(/HH/g, pad(date.getHours())).replace(/mm/g, pad(date.getMinutes())).replace(/ss/g, pad(date.getSeconds())).replace(/Q/g, String(quarter));
|
|
6493
|
+
};
|
|
6494
|
+
const formatTemporal = (value, formatKey, patternOverride) => {
|
|
6495
|
+
if (Array.isArray(value)) {
|
|
6496
|
+
return value.map(item => formatTemporal(item, formatKey, patternOverride)).filter(item => item !== '').join(' ~ ');
|
|
6497
|
+
}
|
|
6498
|
+
const date = toDate(value);
|
|
6499
|
+
if (!date) {
|
|
6500
|
+
return value == null || value === '' ? '' : String(value);
|
|
6501
|
+
}
|
|
6502
|
+
if (formatKey === 'week') {
|
|
6503
|
+
const {
|
|
6504
|
+
year,
|
|
6505
|
+
week
|
|
6506
|
+
} = isoWeek(date);
|
|
6507
|
+
return `${year}-W${pad(week)}`;
|
|
6508
|
+
}
|
|
6509
|
+
if (formatKey === 'quarter') {
|
|
6510
|
+
return `${date.getFullYear()}-Q${Math.ceil((date.getMonth() + 1) / 3)}`;
|
|
6511
|
+
}
|
|
6512
|
+
const pattern = patternOverride || TEMPORAL_PATTERN[formatKey] || TEMPORAL_PATTERN.date;
|
|
6513
|
+
if (value && typeof value.format === 'function' && patternOverride) {
|
|
6514
|
+
try {
|
|
6515
|
+
return value.format(patternOverride);
|
|
6516
|
+
} catch {
|
|
6517
|
+
// fall through to Date formatting
|
|
6518
|
+
}
|
|
6519
|
+
}
|
|
6520
|
+
return applyPattern(date, pattern);
|
|
6521
|
+
};
|
|
6522
|
+
const isTemporalKey = key => !!(key && (TEMPORAL_PATTERN[key] || key === 'week' || key === 'quarter'));
|
|
6523
|
+
const pickObjectLabel = function (item, labelKey, valueKey) {
|
|
6524
|
+
if (labelKey === void 0) {
|
|
6525
|
+
labelKey = 'label';
|
|
6526
|
+
}
|
|
6527
|
+
if (valueKey === void 0) {
|
|
6528
|
+
valueKey = 'value';
|
|
6529
|
+
}
|
|
6530
|
+
if (item == null) {
|
|
6531
|
+
return '';
|
|
6532
|
+
}
|
|
6533
|
+
if (typeof item !== 'object') {
|
|
6534
|
+
return item;
|
|
6535
|
+
}
|
|
6536
|
+
const label = item[labelKey] ?? item.label ?? item.name;
|
|
6537
|
+
if (label != null && typeof label !== 'object' && label !== '') {
|
|
6538
|
+
return label;
|
|
6539
|
+
}
|
|
6540
|
+
const raw = item[valueKey] ?? item.value ?? item.id ?? item.code;
|
|
6541
|
+
if (raw != null && typeof raw !== 'object') {
|
|
6542
|
+
return raw;
|
|
6543
|
+
}
|
|
6544
|
+
return '';
|
|
6545
|
+
};
|
|
6546
|
+
const mapOptionLabel = function (value, options, labelKey, valueKey) {
|
|
6547
|
+
if (labelKey === void 0) {
|
|
6548
|
+
labelKey = 'label';
|
|
6549
|
+
}
|
|
6550
|
+
if (valueKey === void 0) {
|
|
6551
|
+
valueKey = 'value';
|
|
6552
|
+
}
|
|
6553
|
+
if (value && typeof value === 'object') {
|
|
6554
|
+
return pickObjectLabel(value, labelKey, valueKey);
|
|
6555
|
+
}
|
|
6556
|
+
if (!Array.isArray(options) || !options.length) {
|
|
6557
|
+
return value == null ? '' : value;
|
|
6558
|
+
}
|
|
6559
|
+
const match = options.find(item => item && (item[valueKey] === value || item.value === value));
|
|
6560
|
+
return match?.[labelKey] ?? match?.label ?? value;
|
|
6561
|
+
};
|
|
6562
|
+
const formatOption = (value, field) => {
|
|
6563
|
+
const props = field?.props || {};
|
|
6564
|
+
const labelKey = props.labelKey || 'label';
|
|
6565
|
+
const valueKey = props.valueKey || 'value';
|
|
6566
|
+
const pick = item => {
|
|
6567
|
+
if (item && typeof item === 'object') {
|
|
6568
|
+
return pickObjectLabel(item, labelKey, valueKey);
|
|
6569
|
+
}
|
|
6570
|
+
return mapOptionLabel(item, props.options, labelKey, valueKey);
|
|
6571
|
+
};
|
|
6572
|
+
if (Array.isArray(value)) {
|
|
6573
|
+
return value.map(pick).filter(item => item != null && item !== '').join('、');
|
|
6574
|
+
}
|
|
6575
|
+
const label = pick(value);
|
|
6576
|
+
return label == null ? '' : label;
|
|
6577
|
+
};
|
|
6578
|
+
const formatPhone = value => {
|
|
6579
|
+
if (value == null || value === '') {
|
|
6580
|
+
return '';
|
|
6581
|
+
}
|
|
6582
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
6583
|
+
const trimmed = String(value).trim().replace(/\s+/g, ' ');
|
|
6584
|
+
return trimmed;
|
|
6585
|
+
}
|
|
6586
|
+
if (typeof value !== 'object') {
|
|
6587
|
+
return String(value);
|
|
6588
|
+
}
|
|
6589
|
+
const number = String(value.value ?? value.phone ?? value.number ?? '').replace(/\s+/g, '');
|
|
6590
|
+
const rawCode = value.code ?? value.countryCallingCode;
|
|
6591
|
+
const code = rawCode == null || rawCode === '' ? '' : String(rawCode).replace(/^\+/, '');
|
|
6592
|
+
if (!number) {
|
|
6593
|
+
return '';
|
|
6594
|
+
}
|
|
6595
|
+
if (!code) {
|
|
6596
|
+
return number;
|
|
6597
|
+
}
|
|
6598
|
+
return `+${code} ${number}`;
|
|
6599
|
+
};
|
|
6600
|
+
const formatFile = value => {
|
|
6601
|
+
if (Array.isArray(value)) {
|
|
6602
|
+
return value.map(item => formatFile(item)).filter(Boolean).join('、');
|
|
6603
|
+
}
|
|
6604
|
+
if (typeof value === 'string') {
|
|
6605
|
+
return value;
|
|
6606
|
+
}
|
|
6607
|
+
if (!value || typeof value !== 'object') {
|
|
6608
|
+
return value == null ? '' : String(value);
|
|
6609
|
+
}
|
|
6610
|
+
return value.filename || value.name || value.originName || value.originFileObj?.name || value.id || '';
|
|
6611
|
+
};
|
|
6612
|
+
const formatTypedDateRange = (value, ctx) => {
|
|
6613
|
+
if (!value || typeof value !== 'object') {
|
|
6614
|
+
return value == null ? '' : String(value);
|
|
6615
|
+
}
|
|
6616
|
+
const formatKey = TYPE_TO_TEMPORAL[value.type] || 'date';
|
|
6617
|
+
const range = formatTemporal(value.value, formatKey, ctx.field?.props?.format);
|
|
6618
|
+
const typeLabel = value.type ? String(value.type) : '';
|
|
6619
|
+
return [typeLabel, range].filter(Boolean).join(' ');
|
|
6620
|
+
};
|
|
6621
|
+
const formatDateToToday = (value, itemSchema, ctx) => {
|
|
6622
|
+
const items = Array.isArray(value) ? value : [value];
|
|
6623
|
+
const start = formatByValueSchema(items[0], itemSchema, ctx);
|
|
6624
|
+
if (items[1] == null || items[1] === '' || items[1] === true) {
|
|
6625
|
+
const until = ctx.formatMessage?.({
|
|
6626
|
+
id: 'schemaContentUntilToday'
|
|
6627
|
+
}) || '至今';
|
|
6628
|
+
return [start, until].filter(Boolean).join(' ~ ');
|
|
6629
|
+
}
|
|
6630
|
+
const end = formatByValueSchema(items[1], itemSchema, ctx);
|
|
6631
|
+
return [start, end].filter(Boolean).join(' ~ ');
|
|
6632
|
+
};
|
|
6633
|
+
const formatJson = value => {
|
|
6634
|
+
if (typeof value === 'string') {
|
|
6635
|
+
try {
|
|
6636
|
+
return JSON.stringify(JSON.parse(value), null, 2);
|
|
6637
|
+
} catch {
|
|
6638
|
+
return value;
|
|
6639
|
+
}
|
|
6640
|
+
}
|
|
6641
|
+
if (value && typeof value === 'object') {
|
|
6642
|
+
return JSON.stringify(value, null, 2);
|
|
6643
|
+
}
|
|
6644
|
+
return value == null ? '' : String(value);
|
|
6645
|
+
};
|
|
6646
|
+
const formatHtml = value => String(value ?? '').replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
|
|
6647
|
+
const formatMoney = value => {
|
|
6648
|
+
const num = Number(value);
|
|
6649
|
+
if (Number.isNaN(num)) {
|
|
6650
|
+
return value == null ? '' : String(value);
|
|
6651
|
+
}
|
|
6652
|
+
return num.toLocaleString();
|
|
6653
|
+
};
|
|
6654
|
+
const formatColor = value => {
|
|
6655
|
+
if (value == null) {
|
|
6656
|
+
return '';
|
|
6657
|
+
}
|
|
6658
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
6659
|
+
return String(value);
|
|
6660
|
+
}
|
|
6661
|
+
if (typeof value === 'object') {
|
|
6662
|
+
if (typeof value.toHexString === 'function') {
|
|
6663
|
+
return value.toHexString();
|
|
6664
|
+
}
|
|
6665
|
+
return value.hex || value.metaColor || pickObjectLabel(value) || '';
|
|
6666
|
+
}
|
|
6667
|
+
return String(value);
|
|
6668
|
+
};
|
|
6669
|
+
const formatPassword = (value, ctx) => {
|
|
6670
|
+
if (isEmptyValue(value)) {
|
|
6671
|
+
return '';
|
|
6672
|
+
}
|
|
6673
|
+
return ctx.formatMessage?.({
|
|
6674
|
+
id: 'schemaContentPasswordMasked'
|
|
6675
|
+
}) || '••••••';
|
|
6676
|
+
};
|
|
6677
|
+
const formatBoolean = (value, field, ctx) => {
|
|
6678
|
+
const props = field?.props || {};
|
|
6679
|
+
if (value) {
|
|
6680
|
+
return props.checkedChildren || ctx.formatMessage?.({
|
|
6681
|
+
id: 'schemaContentYes'
|
|
6682
|
+
}) || '是';
|
|
6683
|
+
}
|
|
6684
|
+
return props.unCheckedChildren || ctx.formatMessage?.({
|
|
6685
|
+
id: 'schemaContentNo'
|
|
6686
|
+
}) || '否';
|
|
6687
|
+
};
|
|
6688
|
+
const stringifyFallback = value => {
|
|
6689
|
+
if (value == null) {
|
|
6690
|
+
return '';
|
|
6691
|
+
}
|
|
6692
|
+
if (typeof value !== 'object') {
|
|
6693
|
+
return String(value);
|
|
6694
|
+
}
|
|
6695
|
+
if (toDate(value)) {
|
|
6696
|
+
return formatTemporal(value, 'date-time');
|
|
6697
|
+
}
|
|
6698
|
+
if (Array.isArray(value)) {
|
|
6699
|
+
return value.map(item => item && typeof item === 'object' ? stringifyFallback(item) : String(item ?? '')).filter(Boolean).join('、');
|
|
6700
|
+
}
|
|
6701
|
+
if (value.label != null || value.name != null) {
|
|
6702
|
+
return pickObjectLabel(value);
|
|
6703
|
+
}
|
|
6704
|
+
if (value.filename || value.mimetype || value.storageType) {
|
|
6705
|
+
return formatFile(value);
|
|
6706
|
+
}
|
|
6707
|
+
if (value.code != null && value.value != null && value.label == null) {
|
|
6708
|
+
return formatPhone(value);
|
|
6709
|
+
}
|
|
6710
|
+
if (value.type != null && Array.isArray(value.value)) {
|
|
6711
|
+
return formatTypedDateRange(value, {
|
|
6712
|
+
field: {}
|
|
6713
|
+
});
|
|
6714
|
+
}
|
|
6715
|
+
try {
|
|
6716
|
+
return JSON.stringify(value);
|
|
6717
|
+
} catch {
|
|
6718
|
+
return '';
|
|
6719
|
+
}
|
|
6720
|
+
};
|
|
6721
|
+
const formatByValueSchema = function (value, schema, ctx) {
|
|
6722
|
+
if (ctx === void 0) {
|
|
6723
|
+
ctx = {};
|
|
6724
|
+
}
|
|
6725
|
+
if (isEmptyValue(value)) {
|
|
6726
|
+
return '';
|
|
6727
|
+
}
|
|
6728
|
+
const resolved = schema && typeof schema === 'object' ? schema : {};
|
|
6729
|
+
const type = resolved.type;
|
|
6730
|
+
const format = resolved.format;
|
|
6731
|
+
const display = resolved.display;
|
|
6732
|
+
const field = ctx.field;
|
|
6733
|
+
const patternOverride = field?.props?.format;
|
|
6734
|
+
if (display === 'option') {
|
|
6735
|
+
return formatOption(value, field);
|
|
6736
|
+
}
|
|
6737
|
+
if (display === 'phone') {
|
|
6738
|
+
return formatPhone(value);
|
|
6739
|
+
}
|
|
6740
|
+
if (display === 'file') {
|
|
6741
|
+
return /*#__PURE__*/react.createElement(FileFieldPreview$1, {
|
|
6742
|
+
value,
|
|
6743
|
+
field
|
|
6744
|
+
});
|
|
6745
|
+
}
|
|
6746
|
+
if (display === 'typed-date-range') {
|
|
6747
|
+
return formatTypedDateRange(value, ctx);
|
|
6748
|
+
}
|
|
6749
|
+
if (display === 'date-to-today') {
|
|
6750
|
+
return formatDateToToday(value, resolved.items || {
|
|
6751
|
+
type: 'string',
|
|
6752
|
+
format: 'date'
|
|
6753
|
+
}, ctx);
|
|
6754
|
+
}
|
|
6755
|
+
if (display === 'html' || format === 'html') {
|
|
6756
|
+
return formatHtml(value);
|
|
6757
|
+
}
|
|
6758
|
+
if (display === 'money') {
|
|
6759
|
+
return formatMoney(value);
|
|
6760
|
+
}
|
|
6761
|
+
if (format === 'password') {
|
|
6762
|
+
return formatPassword(value, ctx);
|
|
6763
|
+
}
|
|
6764
|
+
if (format === 'json') {
|
|
6765
|
+
return formatJson(value);
|
|
6766
|
+
}
|
|
6767
|
+
if (format === 'color') {
|
|
6768
|
+
return formatColor(value);
|
|
6769
|
+
}
|
|
6770
|
+
if (type === 'boolean') {
|
|
6771
|
+
return formatBoolean(value, field, ctx);
|
|
6772
|
+
}
|
|
6773
|
+
if (isTemporalKey(format)) {
|
|
6774
|
+
return formatTemporal(value, format, patternOverride);
|
|
6775
|
+
}
|
|
6776
|
+
if (type === 'array') {
|
|
6777
|
+
const items = Array.isArray(value) ? value : [value];
|
|
6778
|
+
const itemSchema = resolved.items || {};
|
|
6779
|
+
if (itemSchema.display === 'file') {
|
|
6780
|
+
return /*#__PURE__*/react.createElement(FileFieldPreview$1, {
|
|
6781
|
+
value: items,
|
|
6782
|
+
field
|
|
6783
|
+
});
|
|
6784
|
+
}
|
|
6785
|
+
const joiner = isTemporalKey(itemSchema.format) || itemSchema.display === 'date-to-today' ? ' ~ ' : '、';
|
|
6786
|
+
return items.map(item => formatByValueSchema(item, itemSchema, ctx)).filter(item => item != null && item !== '').join(joiner);
|
|
6787
|
+
}
|
|
6788
|
+
if (Array.isArray(value)) {
|
|
6789
|
+
const itemSchema = resolved.items || {
|
|
6790
|
+
...resolved,
|
|
6791
|
+
type: undefined
|
|
6792
|
+
};
|
|
6793
|
+
if (itemSchema.display === 'file' || resolved.display === 'file') {
|
|
6794
|
+
return /*#__PURE__*/react.createElement(FileFieldPreview$1, {
|
|
6795
|
+
value,
|
|
6796
|
+
field
|
|
6797
|
+
});
|
|
6798
|
+
}
|
|
6799
|
+
const joiner = isTemporalKey(itemSchema.format) ? ' ~ ' : '、';
|
|
6800
|
+
return value.map(item => formatByValueSchema(item, itemSchema, ctx)).filter(item => item != null && item !== '').join(joiner);
|
|
6801
|
+
}
|
|
6802
|
+
if (Array.isArray(resolved.enum) || Array.isArray(field?.props?.options) && field.props.options.length) {
|
|
6803
|
+
const mapped = formatOption(value, field);
|
|
6804
|
+
if (mapped != null && mapped !== '') {
|
|
6805
|
+
return mapped;
|
|
6806
|
+
}
|
|
6807
|
+
}
|
|
6808
|
+
if (type === 'object') {
|
|
6809
|
+
return stringifyFallback(value);
|
|
6810
|
+
}
|
|
6811
|
+
if (typeof value === 'object') {
|
|
6812
|
+
return stringifyFallback(value);
|
|
6813
|
+
}
|
|
6814
|
+
return String(value);
|
|
6815
|
+
};
|
|
6816
|
+
const formatFieldDisplayValue = function (field, value, _temp) {
|
|
6817
|
+
let {
|
|
6818
|
+
formatMessage
|
|
6819
|
+
} = _temp === void 0 ? {} : _temp;
|
|
6820
|
+
const emptyText = formatMessage?.({
|
|
6821
|
+
id: 'schemaContentEmptyValue'
|
|
6822
|
+
}) || '-';
|
|
6823
|
+
if (isEmptyValue(value)) {
|
|
6824
|
+
return emptyText;
|
|
6825
|
+
}
|
|
6826
|
+
const definition = getFieldDefinition(field?.type);
|
|
6827
|
+
if (typeof definition?.formatDisplayValue === 'function') {
|
|
6828
|
+
const custom = definition.formatDisplayValue(value, field, {
|
|
6829
|
+
formatMessage
|
|
6830
|
+
});
|
|
6831
|
+
if (custom != null && custom !== '') {
|
|
6832
|
+
return custom;
|
|
6833
|
+
}
|
|
6834
|
+
}
|
|
6835
|
+
const schema = resolveFieldValueSchema(field);
|
|
6836
|
+
const text = formatByValueSchema(value, schema, {
|
|
6837
|
+
field,
|
|
6838
|
+
formatMessage
|
|
6839
|
+
});
|
|
6840
|
+
return text == null || text === '' ? emptyText : text;
|
|
6841
|
+
};
|
|
6842
|
+
|
|
6137
6843
|
/**
|
|
6138
6844
|
* 统一注册扩展规则与填写项:运行时校验 + 编辑器规则面板 + 字段类型 registry。
|
|
6139
6845
|
* 应用入口调用一次即可,FormCreator / SchemaRenderer 共用。
|
|
@@ -6485,15 +7191,6 @@ const getByPath = (data, path) => {
|
|
|
6485
7191
|
}
|
|
6486
7192
|
return String(path).split('.').reduce((acc, key) => acc == null ? acc : acc[key], data);
|
|
6487
7193
|
};
|
|
6488
|
-
const isEmptyValue = value => {
|
|
6489
|
-
if (value == null || value === '') {
|
|
6490
|
-
return true;
|
|
6491
|
-
}
|
|
6492
|
-
if (Array.isArray(value) && value.length === 0) {
|
|
6493
|
-
return true;
|
|
6494
|
-
}
|
|
6495
|
-
return false;
|
|
6496
|
-
};
|
|
6497
7194
|
const resolveChoiceSelectorName = block => {
|
|
6498
7195
|
if (block.selectorName != null && String(block.selectorName).trim()) {
|
|
6499
7196
|
return String(block.selectorName).trim();
|
|
@@ -6503,86 +7200,9 @@ const resolveChoiceSelectorName = block => {
|
|
|
6503
7200
|
}
|
|
6504
7201
|
return `__choice_${block.id}`;
|
|
6505
7202
|
};
|
|
6506
|
-
const
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
return value.map(item => formatDateValue(item, format)).filter(item => item !== '').join(' ~ ');
|
|
6510
|
-
}
|
|
6511
|
-
if (value && typeof value.format === 'function') {
|
|
6512
|
-
return value.format(pattern);
|
|
6513
|
-
}
|
|
6514
|
-
return value == null ? '' : String(value);
|
|
6515
|
-
};
|
|
6516
|
-
const mapOptionLabel = (value, options) => {
|
|
6517
|
-
if (!Array.isArray(options) || !options.length) {
|
|
6518
|
-
return value;
|
|
6519
|
-
}
|
|
6520
|
-
const match = options.find(item => item && item.value === value);
|
|
6521
|
-
return match?.label ?? value;
|
|
6522
|
-
};
|
|
6523
|
-
const formatFieldValue = (field, value, formatMessage) => {
|
|
6524
|
-
if (isEmptyValue(value)) {
|
|
6525
|
-
return formatMessage({
|
|
6526
|
-
id: 'schemaContentEmptyValue'
|
|
6527
|
-
});
|
|
6528
|
-
}
|
|
6529
|
-
const definition = getFieldDefinition(field.type);
|
|
6530
|
-
const props = field.props || {};
|
|
6531
|
-
const valueSchema = resolveFieldValueSchema(field);
|
|
6532
|
-
const schemaType = valueSchema?.type;
|
|
6533
|
-
if (schemaType === 'boolean' || field.type === 'Switch' || field.type === 'Checkbox') {
|
|
6534
|
-
if (value) {
|
|
6535
|
-
return props.checkedChildren || formatMessage({
|
|
6536
|
-
id: 'schemaContentYes'
|
|
6537
|
-
});
|
|
6538
|
-
}
|
|
6539
|
-
return props.unCheckedChildren || formatMessage({
|
|
6540
|
-
id: 'schemaContentNo'
|
|
6541
|
-
});
|
|
6542
|
-
}
|
|
6543
|
-
if (field.type === 'DatePicker') {
|
|
6544
|
-
const formatted = formatDateValue(value, props.format);
|
|
6545
|
-
return formatted || formatMessage({
|
|
6546
|
-
id: 'schemaContentEmptyValue'
|
|
6547
|
-
});
|
|
6548
|
-
}
|
|
6549
|
-
if (Array.isArray(props.options) && props.options.length) {
|
|
6550
|
-
if (Array.isArray(value)) {
|
|
6551
|
-
const labels = value.map(item => mapOptionLabel(item, props.options)).filter(item => item != null && item !== '');
|
|
6552
|
-
return labels.length ? labels.join('、') : formatMessage({
|
|
6553
|
-
id: 'schemaContentEmptyValue'
|
|
6554
|
-
});
|
|
6555
|
-
}
|
|
6556
|
-
return mapOptionLabel(value, props.options);
|
|
6557
|
-
}
|
|
6558
|
-
if (definition?.isSuperSelect) {
|
|
6559
|
-
const labelKey = props.labelKey || 'label';
|
|
6560
|
-
const pickLabel = item => {
|
|
6561
|
-
if (item && typeof item === 'object') {
|
|
6562
|
-
return item[labelKey] ?? item.label ?? item.value;
|
|
6563
|
-
}
|
|
6564
|
-
return item;
|
|
6565
|
-
};
|
|
6566
|
-
if (Array.isArray(value)) {
|
|
6567
|
-
const labels = value.map(pickLabel).filter(item => item != null && item !== '');
|
|
6568
|
-
return labels.length ? labels.join('、') : formatMessage({
|
|
6569
|
-
id: 'schemaContentEmptyValue'
|
|
6570
|
-
});
|
|
6571
|
-
}
|
|
6572
|
-
if (value && typeof value === 'object') {
|
|
6573
|
-
return pickLabel(value) ?? formatMessage({
|
|
6574
|
-
id: 'schemaContentEmptyValue'
|
|
6575
|
-
});
|
|
6576
|
-
}
|
|
6577
|
-
}
|
|
6578
|
-
if (Array.isArray(value)) {
|
|
6579
|
-
return value.map(item => item && typeof item === 'object' ? JSON.stringify(item) : String(item)).join('、');
|
|
6580
|
-
}
|
|
6581
|
-
if (typeof value === 'object') {
|
|
6582
|
-
return JSON.stringify(value);
|
|
6583
|
-
}
|
|
6584
|
-
return String(value);
|
|
6585
|
-
};
|
|
7203
|
+
const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValue(field, value, {
|
|
7204
|
+
formatMessage
|
|
7205
|
+
});
|
|
6586
7206
|
const renderFieldsContent = (fields, data, formatMessage, column) => {
|
|
6587
7207
|
const list = (fields || []).filter(field => field && !field.hidden && field.name).map(field => ({
|
|
6588
7208
|
label: field.label || field.name,
|
|
@@ -6794,6 +7414,8 @@ exports.findBlock = findBlock;
|
|
|
6794
7414
|
exports.findBlockInTree = findBlockInTree;
|
|
6795
7415
|
exports.formValuesToBlock = formValuesToBlock;
|
|
6796
7416
|
exports.formValuesToField = formValuesToField;
|
|
7417
|
+
exports.formatByValueSchema = formatByValueSchema;
|
|
7418
|
+
exports.formatFieldDisplayValue = formatFieldDisplayValue;
|
|
6797
7419
|
exports.getBlockDefinition = getBlockDefinition;
|
|
6798
7420
|
exports.getBlockKindOptions = getBlockKindOptions;
|
|
6799
7421
|
exports.getFieldComponent = getFieldComponent;
|