@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.modern.js
CHANGED
|
@@ -15,8 +15,9 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
15
15
|
import FormInfo, { FormModal, Form, Steps, MultiField, TableList, List } from '@kne/form-info';
|
|
16
16
|
import { ButtonFooter } from '@kne/button-group';
|
|
17
17
|
import InfoPage, { Content } from '@kne/info-page';
|
|
18
|
+
import { createWithRemoteLoader } from '@kne/remote-loader';
|
|
18
19
|
|
|
19
|
-
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"};
|
|
20
|
+
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"};
|
|
20
21
|
|
|
21
22
|
function _extends() {
|
|
22
23
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -234,7 +235,9 @@ const locale$1 = {
|
|
|
234
235
|
schemaContentEmptyValue: '-',
|
|
235
236
|
schemaContentYes: '是',
|
|
236
237
|
schemaContentNo: '否',
|
|
237
|
-
schemaContentItemIndex: '第 {index} 项'
|
|
238
|
+
schemaContentItemIndex: '第 {index} 项',
|
|
239
|
+
schemaContentUntilToday: '至今',
|
|
240
|
+
schemaContentPasswordMasked: '••••••'
|
|
238
241
|
};
|
|
239
242
|
var zhCN = locale$1;
|
|
240
243
|
|
|
@@ -435,7 +438,9 @@ const locale = {
|
|
|
435
438
|
schemaContentEmptyValue: '-',
|
|
436
439
|
schemaContentYes: 'Yes',
|
|
437
440
|
schemaContentNo: 'No',
|
|
438
|
-
schemaContentItemIndex: 'Item {index}'
|
|
441
|
+
schemaContentItemIndex: 'Item {index}',
|
|
442
|
+
schemaContentUntilToday: 'Present',
|
|
443
|
+
schemaContentPasswordMasked: '••••••'
|
|
439
444
|
};
|
|
440
445
|
var enUS = locale;
|
|
441
446
|
|
|
@@ -1249,6 +1254,81 @@ const mapOptionItem = item => {
|
|
|
1249
1254
|
}
|
|
1250
1255
|
return next;
|
|
1251
1256
|
};
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* 搭建器选项是 { label, value, children };SelectCascader 默认 valueKey='id'、示例用 id/name。
|
|
1260
|
+
* 补齐两边的 key,避免 mapping 全部落到 undefined 导致下拉空白。
|
|
1261
|
+
*/
|
|
1262
|
+
const alignOptionKeys = (options = [], {
|
|
1263
|
+
valueKey: _valueKey = 'value',
|
|
1264
|
+
labelKey: _labelKey = 'label'
|
|
1265
|
+
} = {}) => {
|
|
1266
|
+
if (!Array.isArray(options)) {
|
|
1267
|
+
return options;
|
|
1268
|
+
}
|
|
1269
|
+
return options.map(item => {
|
|
1270
|
+
var _ref, _ref2, _item$_valueKey, _ref3, _item$_labelKey;
|
|
1271
|
+
if (!item || typeof item !== 'object') {
|
|
1272
|
+
return item;
|
|
1273
|
+
}
|
|
1274
|
+
const rawValue = (_ref = (_ref2 = (_item$_valueKey = item[_valueKey]) != null ? _item$_valueKey : item.value) != null ? _ref2 : item.id) != null ? _ref : item.code;
|
|
1275
|
+
const rawLabel = (_ref3 = (_item$_labelKey = item[_labelKey]) != null ? _item$_labelKey : item.label) != null ? _ref3 : item.name;
|
|
1276
|
+
const next = _extends({}, item);
|
|
1277
|
+
if (rawValue != null && next[_valueKey] == null) {
|
|
1278
|
+
next[_valueKey] = rawValue;
|
|
1279
|
+
}
|
|
1280
|
+
if (rawLabel != null && (next[_labelKey] == null || next[_labelKey] === '')) {
|
|
1281
|
+
next[_labelKey] = rawLabel;
|
|
1282
|
+
}
|
|
1283
|
+
if (next.id == null && rawValue != null) {
|
|
1284
|
+
next.id = rawValue;
|
|
1285
|
+
}
|
|
1286
|
+
if ((next.name == null || next.name === '') && rawLabel != null) {
|
|
1287
|
+
next.name = rawLabel;
|
|
1288
|
+
}
|
|
1289
|
+
if (Array.isArray(next.children) && next.children.length) {
|
|
1290
|
+
next.children = alignOptionKeys(next.children, {
|
|
1291
|
+
valueKey: _valueKey,
|
|
1292
|
+
labelKey: _labelKey
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
return next;
|
|
1296
|
+
});
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* SelectTree 按扁平 parentId 组树,会覆盖节点上已有的 children。
|
|
1301
|
+
* 搭建器存的是嵌套 children,交给 SelectTree 前先拍平。
|
|
1302
|
+
*/
|
|
1303
|
+
const flattenTreeOptions = (options = [], {
|
|
1304
|
+
valueKey: _valueKey2 = 'value',
|
|
1305
|
+
parentKey: _parentKey = 'parentId',
|
|
1306
|
+
childrenKey: _childrenKey = 'children',
|
|
1307
|
+
parentId
|
|
1308
|
+
} = {}) => {
|
|
1309
|
+
const result = [];
|
|
1310
|
+
(Array.isArray(options) ? options : []).forEach(item => {
|
|
1311
|
+
if (!item || typeof item !== 'object') {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
const nested = item[_childrenKey];
|
|
1315
|
+
const node = _extends({}, item);
|
|
1316
|
+
delete node[_childrenKey];
|
|
1317
|
+
if (parentId !== undefined) {
|
|
1318
|
+
node[_parentKey] = parentId;
|
|
1319
|
+
}
|
|
1320
|
+
result.push(node);
|
|
1321
|
+
if (Array.isArray(nested) && nested.length) {
|
|
1322
|
+
result.push(...flattenTreeOptions(nested, {
|
|
1323
|
+
valueKey: _valueKey2,
|
|
1324
|
+
parentKey: _parentKey,
|
|
1325
|
+
childrenKey: _childrenKey,
|
|
1326
|
+
parentId: node[_valueKey2]
|
|
1327
|
+
}));
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
return result;
|
|
1331
|
+
};
|
|
1252
1332
|
const createApiFromOptions = (options = []) => ({
|
|
1253
1333
|
loader: () => ({
|
|
1254
1334
|
pageData: options.map(mapOptionItem)
|
|
@@ -1262,6 +1342,7 @@ const {
|
|
|
1262
1342
|
const hasNestedOptions = options => Array.isArray(options) && options.some(item => Array.isArray(item == null ? void 0 : item.children) && item.children.length);
|
|
1263
1343
|
const createField = (Component, {
|
|
1264
1344
|
preferOptions: _preferOptions = false,
|
|
1345
|
+
flattenTree: _flattenTree = false,
|
|
1265
1346
|
placeholderPrefix: _placeholderPrefix = '请选择'
|
|
1266
1347
|
} = {}) => {
|
|
1267
1348
|
const Field = props => {
|
|
@@ -1271,14 +1352,28 @@ const createField = (Component, {
|
|
|
1271
1352
|
placeholder
|
|
1272
1353
|
} = props,
|
|
1273
1354
|
rest = _objectWithoutPropertiesLoose(props, _excluded$3);
|
|
1274
|
-
const
|
|
1275
|
-
const
|
|
1355
|
+
const valueKey = rest.valueKey || 'value';
|
|
1356
|
+
const labelKey = rest.labelKey || 'label';
|
|
1357
|
+
const parentKey = rest.parentKey || 'parentId';
|
|
1358
|
+
const flattened = _flattenTree && Array.isArray(options) ? flattenTreeOptions(options, {
|
|
1359
|
+
valueKey,
|
|
1360
|
+
parentKey
|
|
1361
|
+
}) : options;
|
|
1362
|
+
const resolvedOptions = Array.isArray(flattened) ? alignOptionKeys(flattened, {
|
|
1363
|
+
valueKey,
|
|
1364
|
+
labelKey
|
|
1365
|
+
}) : flattened;
|
|
1366
|
+
const useOptionsDirectly = _preferOptions || hasNestedOptions(resolvedOptions);
|
|
1367
|
+
const mergedApi = api || (!useOptionsDirectly && Array.isArray(resolvedOptions) && resolvedOptions.length ? createApiFromOptions(resolvedOptions) : undefined);
|
|
1276
1368
|
const resolvedPlaceholder = placeholder != null && String(placeholder).trim() ? placeholder : `${_placeholderPrefix}${props.label || ''}`;
|
|
1277
1369
|
const render = useOnChange$1(Object.assign({}, {
|
|
1278
1370
|
isPopup: true,
|
|
1279
1371
|
placeholder: resolvedPlaceholder
|
|
1280
|
-
}, rest,
|
|
1281
|
-
|
|
1372
|
+
}, rest, {
|
|
1373
|
+
valueKey,
|
|
1374
|
+
labelKey
|
|
1375
|
+
}, useOptionsDirectly && Array.isArray(resolvedOptions) ? {
|
|
1376
|
+
options: resolvedOptions
|
|
1282
1377
|
} : {}, mergedApi ? {
|
|
1283
1378
|
api: mergedApi
|
|
1284
1379
|
} : {}));
|
|
@@ -1292,7 +1387,8 @@ const SuperSelectTableList = createField(SelectTableList, {
|
|
|
1292
1387
|
preferOptions: true
|
|
1293
1388
|
});
|
|
1294
1389
|
const SuperSelectTree = createField(SelectTree, {
|
|
1295
|
-
preferOptions: true
|
|
1390
|
+
preferOptions: true,
|
|
1391
|
+
flattenTree: true
|
|
1296
1392
|
});
|
|
1297
1393
|
const SuperSelectCascader = createField(SelectCascader, {
|
|
1298
1394
|
preferOptions: true
|
|
@@ -1410,20 +1506,45 @@ const stringWithEnumSchema = field => {
|
|
|
1410
1506
|
}
|
|
1411
1507
|
return schema;
|
|
1412
1508
|
};
|
|
1509
|
+
const optionValueSchema = {
|
|
1510
|
+
type: 'object',
|
|
1511
|
+
display: 'option'
|
|
1512
|
+
};
|
|
1413
1513
|
const superSelectValueSchema = field => {
|
|
1414
1514
|
var _field$props2;
|
|
1415
1515
|
if (field != null && (_field$props2 = field.props) != null && _field$props2.single) {
|
|
1416
|
-
return {
|
|
1417
|
-
type: 'object'
|
|
1418
|
-
};
|
|
1516
|
+
return _extends({}, optionValueSchema);
|
|
1419
1517
|
}
|
|
1420
1518
|
return {
|
|
1421
1519
|
type: 'array',
|
|
1422
|
-
items: {
|
|
1423
|
-
type: 'object'
|
|
1424
|
-
}
|
|
1520
|
+
items: _extends({}, optionValueSchema)
|
|
1425
1521
|
};
|
|
1426
1522
|
};
|
|
1523
|
+
const PICKER_TO_FORMAT = {
|
|
1524
|
+
date: 'date',
|
|
1525
|
+
week: 'week',
|
|
1526
|
+
month: 'month',
|
|
1527
|
+
quarter: 'quarter',
|
|
1528
|
+
year: 'year'
|
|
1529
|
+
};
|
|
1530
|
+
const datePickerValueSchema = field => {
|
|
1531
|
+
var _field$props3, _field$props4, _field$props5;
|
|
1532
|
+
const picker = (field == null || (_field$props3 = field.props) == null ? void 0 : _field$props3.picker) || 'date';
|
|
1533
|
+
const format = field != null && (_field$props4 = field.props) != null && _field$props4.showTime ? 'date-time' : PICKER_TO_FORMAT[picker] || 'date';
|
|
1534
|
+
const item = {
|
|
1535
|
+
type: 'string',
|
|
1536
|
+
format
|
|
1537
|
+
};
|
|
1538
|
+
if (field != null && (_field$props5 = field.props) != null && _field$props5.range) {
|
|
1539
|
+
return {
|
|
1540
|
+
type: 'array',
|
|
1541
|
+
items: item,
|
|
1542
|
+
minItems: 2,
|
|
1543
|
+
maxItems: 2
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
return item;
|
|
1547
|
+
};
|
|
1427
1548
|
defineField('Input', {
|
|
1428
1549
|
label: '单行文本',
|
|
1429
1550
|
group: '基础字段',
|
|
@@ -1645,19 +1766,7 @@ defineField('DatePicker', {
|
|
|
1645
1766
|
},
|
|
1646
1767
|
hasFieldProps: true,
|
|
1647
1768
|
resolveComponent: props => props != null && props.range ? DatePicker.RangePicker || DatePicker : DatePicker,
|
|
1648
|
-
valueSchema:
|
|
1649
|
-
var _field$props3;
|
|
1650
|
-
return field != null && (_field$props3 = field.props) != null && _field$props3.range ? {
|
|
1651
|
-
type: 'array',
|
|
1652
|
-
items: {
|
|
1653
|
-
type: 'string'
|
|
1654
|
-
},
|
|
1655
|
-
minItems: 2,
|
|
1656
|
-
maxItems: 2
|
|
1657
|
-
} : {
|
|
1658
|
-
type: 'string'
|
|
1659
|
-
};
|
|
1660
|
-
}
|
|
1769
|
+
valueSchema: datePickerValueSchema
|
|
1661
1770
|
});
|
|
1662
1771
|
|
|
1663
1772
|
/**
|
|
@@ -1673,6 +1782,8 @@ defineField('DatePicker', {
|
|
|
1673
1782
|
* preset({ type, definition }) 的 fields 项还可传:
|
|
1674
1783
|
* - groupName?: string 自定义类型下拉分组名;不传则归入「扩展字段」
|
|
1675
1784
|
* - valueSchema?: object | (field) => object 提交值的 JSON Schema 片段;缺省回退 { type: 'string' }
|
|
1785
|
+
* 可含 format(date/month/week/time/date-time/password/color/json)与 display(option/phone/file/typed-date-range/date-to-today/html/money),供 SchemaContent 预览
|
|
1786
|
+
* - formatDisplayValue?: (value, field, ctx) => string 覆盖 valueSchema 默认预览
|
|
1676
1787
|
*/
|
|
1677
1788
|
const registerField = (type, definition) => {
|
|
1678
1789
|
var _definition$hasFieldP;
|
|
@@ -2081,16 +2192,16 @@ const applyFieldProps = (props, values, definition) => {
|
|
|
2081
2192
|
}
|
|
2082
2193
|
};
|
|
2083
2194
|
const fieldToFormValues = field => {
|
|
2084
|
-
var _field$
|
|
2195
|
+
var _field$props6, _field$props7, _field$props8;
|
|
2085
2196
|
const definition = getFieldDefinition(field.type);
|
|
2086
2197
|
const ruleConfig = parseRuleString(field.rule);
|
|
2087
2198
|
const allowChildren = !!(definition != null && definition.optionsAllowChildren);
|
|
2088
|
-
const columns = definition != null && definition.hasColumns ? normalizeColumns((_field$
|
|
2089
|
-
const options = normalizeOptions((_field$
|
|
2199
|
+
const columns = definition != null && definition.hasColumns ? normalizeColumns((_field$props6 = field.props) == null ? void 0 : _field$props6.columns) : [];
|
|
2200
|
+
const options = normalizeOptions((_field$props7 = field.props) == null ? void 0 : _field$props7.options, {
|
|
2090
2201
|
allowChildren,
|
|
2091
2202
|
columns
|
|
2092
2203
|
});
|
|
2093
|
-
const rawPlaceholder = (_field$
|
|
2204
|
+
const rawPlaceholder = (_field$props8 = field.props) == null ? void 0 : _field$props8.placeholder;
|
|
2094
2205
|
const placeholder = Array.isArray(rawPlaceholder) ? rawPlaceholder[0] || '' : rawPlaceholder || '';
|
|
2095
2206
|
return {
|
|
2096
2207
|
type: field.type,
|
|
@@ -5041,7 +5152,7 @@ const renderFieldElements = (fields = [], preview = false, {
|
|
|
5041
5152
|
return null;
|
|
5042
5153
|
}
|
|
5043
5154
|
const definition = getFieldDefinition(field.type);
|
|
5044
|
-
const props = _extends({}, field.props || {});
|
|
5155
|
+
const props = _extends({}, (definition == null ? void 0 : definition.defaultProps) || {}, field.props || {});
|
|
5045
5156
|
if (definition != null && definition.optionsAllowDescription && (_props$options = props.options) != null && _props$options.length && !props.api && !definition.optionsAllowChildren) {
|
|
5046
5157
|
props.api = createApiFromOptions(props.options);
|
|
5047
5158
|
}
|
|
@@ -5902,6 +6013,530 @@ const FormCreator = withLocale$1(({
|
|
|
5902
6013
|
});
|
|
5903
6014
|
var FormCreator$1 = FormCreator;
|
|
5904
6015
|
|
|
6016
|
+
const IMAGE_EXT = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(?:[?#].*)?$/i;
|
|
6017
|
+
const toFileList = value => {
|
|
6018
|
+
if (value == null || value === '') {
|
|
6019
|
+
return [];
|
|
6020
|
+
}
|
|
6021
|
+
return Array.isArray(value) ? value : [value];
|
|
6022
|
+
};
|
|
6023
|
+
const isHttpLike = value => typeof value === 'string' && /^(https?:|blob:|data:)/i.test(value);
|
|
6024
|
+
const pickFilePreviewProps = file => {
|
|
6025
|
+
var _file$originFileObj, _file$originFileObj2;
|
|
6026
|
+
if (file == null || file === '') {
|
|
6027
|
+
return null;
|
|
6028
|
+
}
|
|
6029
|
+
if (typeof file === 'string') {
|
|
6030
|
+
const _filename = file.split('/').pop() || file;
|
|
6031
|
+
if (isHttpLike(file)) {
|
|
6032
|
+
return {
|
|
6033
|
+
src: file,
|
|
6034
|
+
filename: _filename,
|
|
6035
|
+
originName: _filename
|
|
6036
|
+
};
|
|
6037
|
+
}
|
|
6038
|
+
return {
|
|
6039
|
+
filename: _filename,
|
|
6040
|
+
originName: _filename
|
|
6041
|
+
};
|
|
6042
|
+
}
|
|
6043
|
+
if (typeof file !== 'object') {
|
|
6044
|
+
return null;
|
|
6045
|
+
}
|
|
6046
|
+
const filename = file.filename || file.name || file.originName || ((_file$originFileObj = file.originFileObj) == null ? void 0 : _file$originFileObj.name);
|
|
6047
|
+
const src = file.src || file.url || file.path || file.thumbUrl;
|
|
6048
|
+
const id = file.id || file.uuid || file.fileId;
|
|
6049
|
+
if (!src && !id && !filename) {
|
|
6050
|
+
return null;
|
|
6051
|
+
}
|
|
6052
|
+
return _extends({}, src ? {
|
|
6053
|
+
src
|
|
6054
|
+
} : {}, id ? {
|
|
6055
|
+
id
|
|
6056
|
+
} : {}, {
|
|
6057
|
+
filename,
|
|
6058
|
+
originName: file.originName || filename,
|
|
6059
|
+
mimetype: file.mimetype || file.type || ((_file$originFileObj2 = file.originFileObj) == null ? void 0 : _file$originFileObj2.type)
|
|
6060
|
+
});
|
|
6061
|
+
};
|
|
6062
|
+
const isImageFile = (item, field) => {
|
|
6063
|
+
const type = field == null ? void 0 : field.type;
|
|
6064
|
+
if (type === 'Avatar' || type === 'Signature') {
|
|
6065
|
+
return true;
|
|
6066
|
+
}
|
|
6067
|
+
const mime = item == null ? void 0 : item.mimetype;
|
|
6068
|
+
if (typeof mime === 'string' && mime.startsWith('image/')) {
|
|
6069
|
+
return true;
|
|
6070
|
+
}
|
|
6071
|
+
return IMAGE_EXT.test(String((item == null ? void 0 : item.filename) || (item == null ? void 0 : item.originName) || (item == null ? void 0 : item.src) || ''));
|
|
6072
|
+
};
|
|
6073
|
+
const FileFieldPreview = createWithRemoteLoader({
|
|
6074
|
+
modules: ['components-core:File@FileLink', 'components-core:Image']
|
|
6075
|
+
})(({
|
|
6076
|
+
remoteModules,
|
|
6077
|
+
value,
|
|
6078
|
+
field
|
|
6079
|
+
}) => {
|
|
6080
|
+
const [FileLink, Image] = remoteModules;
|
|
6081
|
+
const files = toFileList(value).map(pickFilePreviewProps).filter(Boolean);
|
|
6082
|
+
if (!files.length) {
|
|
6083
|
+
return null;
|
|
6084
|
+
}
|
|
6085
|
+
return /*#__PURE__*/jsx(Flex, {
|
|
6086
|
+
vertical: true,
|
|
6087
|
+
gap: 8,
|
|
6088
|
+
className: style['schema-content-file-list'],
|
|
6089
|
+
children: files.map((item, index) => {
|
|
6090
|
+
const key = item.id || item.src || item.filename || String(index);
|
|
6091
|
+
const filename = item.filename || item.originName || '';
|
|
6092
|
+
const canPreview = !!(item.id || item.src);
|
|
6093
|
+
const asImage = isImageFile(item, field);
|
|
6094
|
+
if (!canPreview) {
|
|
6095
|
+
return /*#__PURE__*/jsx("span", {
|
|
6096
|
+
className: style['schema-content-file-name'],
|
|
6097
|
+
children: filename
|
|
6098
|
+
}, key);
|
|
6099
|
+
}
|
|
6100
|
+
const linkProps = {
|
|
6101
|
+
id: item.id,
|
|
6102
|
+
src: item.src,
|
|
6103
|
+
url: item.src,
|
|
6104
|
+
filename,
|
|
6105
|
+
originName: item.originName || filename
|
|
6106
|
+
};
|
|
6107
|
+
if (asImage) {
|
|
6108
|
+
const preview = (field == null ? void 0 : field.type) === 'Avatar' ? /*#__PURE__*/jsx(Image.Avatar, {
|
|
6109
|
+
id: item.id,
|
|
6110
|
+
src: item.src,
|
|
6111
|
+
size: 64,
|
|
6112
|
+
shape: "square",
|
|
6113
|
+
alt: filename
|
|
6114
|
+
}) : /*#__PURE__*/jsx(Image, {
|
|
6115
|
+
id: item.id,
|
|
6116
|
+
src: item.src,
|
|
6117
|
+
alt: filename,
|
|
6118
|
+
className: style['schema-content-file-image']
|
|
6119
|
+
});
|
|
6120
|
+
return /*#__PURE__*/jsx(FileLink, _extends({
|
|
6121
|
+
className: style['schema-content-file'],
|
|
6122
|
+
icon: null
|
|
6123
|
+
}, linkProps, {
|
|
6124
|
+
children: preview
|
|
6125
|
+
}), key);
|
|
6126
|
+
}
|
|
6127
|
+
return /*#__PURE__*/jsx(FileLink, _extends({
|
|
6128
|
+
className: style['schema-content-file']
|
|
6129
|
+
}, linkProps, {
|
|
6130
|
+
children: filename
|
|
6131
|
+
}), key);
|
|
6132
|
+
})
|
|
6133
|
+
});
|
|
6134
|
+
});
|
|
6135
|
+
var FileFieldPreview$1 = FileFieldPreview;
|
|
6136
|
+
|
|
6137
|
+
const TEMPORAL_PATTERN = {
|
|
6138
|
+
date: 'YYYY-MM-DD',
|
|
6139
|
+
month: 'YYYY-MM',
|
|
6140
|
+
time: 'HH:mm:ss',
|
|
6141
|
+
'date-time': 'YYYY-MM-DD HH:mm:ss',
|
|
6142
|
+
year: 'YYYY'
|
|
6143
|
+
};
|
|
6144
|
+
const TYPE_TO_TEMPORAL = {
|
|
6145
|
+
date: 'date',
|
|
6146
|
+
month: 'month',
|
|
6147
|
+
week: 'week',
|
|
6148
|
+
time: 'time',
|
|
6149
|
+
year: 'year',
|
|
6150
|
+
quarter: 'quarter',
|
|
6151
|
+
datetime: 'date-time',
|
|
6152
|
+
'date-time': 'date-time'
|
|
6153
|
+
};
|
|
6154
|
+
const pad = n => String(n).padStart(2, '0');
|
|
6155
|
+
const isEmptyValue = value => {
|
|
6156
|
+
if (value == null || value === '') {
|
|
6157
|
+
return true;
|
|
6158
|
+
}
|
|
6159
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
6160
|
+
return true;
|
|
6161
|
+
}
|
|
6162
|
+
return false;
|
|
6163
|
+
};
|
|
6164
|
+
const toDate = value => {
|
|
6165
|
+
if (value == null || value === '') {
|
|
6166
|
+
return null;
|
|
6167
|
+
}
|
|
6168
|
+
if (value instanceof Date) {
|
|
6169
|
+
return Number.isNaN(value.getTime()) ? null : value;
|
|
6170
|
+
}
|
|
6171
|
+
if (typeof value.toDate === 'function') {
|
|
6172
|
+
const next = value.toDate();
|
|
6173
|
+
return next instanceof Date && !Number.isNaN(next.getTime()) ? next : null;
|
|
6174
|
+
}
|
|
6175
|
+
if (typeof value.format === 'function' && typeof value.valueOf === 'function') {
|
|
6176
|
+
const next = new Date(value.valueOf());
|
|
6177
|
+
return Number.isNaN(next.getTime()) ? null : next;
|
|
6178
|
+
}
|
|
6179
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
6180
|
+
const next = new Date(value);
|
|
6181
|
+
return Number.isNaN(next.getTime()) ? null : next;
|
|
6182
|
+
}
|
|
6183
|
+
return null;
|
|
6184
|
+
};
|
|
6185
|
+
const isoWeek = date => {
|
|
6186
|
+
const tmp = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
6187
|
+
const day = tmp.getUTCDay() || 7;
|
|
6188
|
+
tmp.setUTCDate(tmp.getUTCDate() + 4 - day);
|
|
6189
|
+
const yearStart = new Date(Date.UTC(tmp.getUTCFullYear(), 0, 1));
|
|
6190
|
+
const week = Math.ceil(((tmp - yearStart) / 86400000 + 1) / 7);
|
|
6191
|
+
return {
|
|
6192
|
+
year: tmp.getUTCFullYear(),
|
|
6193
|
+
week
|
|
6194
|
+
};
|
|
6195
|
+
};
|
|
6196
|
+
const applyPattern = (date, pattern) => {
|
|
6197
|
+
const year = date.getFullYear();
|
|
6198
|
+
const month = date.getMonth() + 1;
|
|
6199
|
+
const quarter = Math.ceil(month / 3);
|
|
6200
|
+
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));
|
|
6201
|
+
};
|
|
6202
|
+
const formatTemporal = (value, formatKey, patternOverride) => {
|
|
6203
|
+
if (Array.isArray(value)) {
|
|
6204
|
+
return value.map(item => formatTemporal(item, formatKey, patternOverride)).filter(item => item !== '').join(' ~ ');
|
|
6205
|
+
}
|
|
6206
|
+
const date = toDate(value);
|
|
6207
|
+
if (!date) {
|
|
6208
|
+
return value == null || value === '' ? '' : String(value);
|
|
6209
|
+
}
|
|
6210
|
+
if (formatKey === 'week') {
|
|
6211
|
+
const {
|
|
6212
|
+
year,
|
|
6213
|
+
week
|
|
6214
|
+
} = isoWeek(date);
|
|
6215
|
+
return `${year}-W${pad(week)}`;
|
|
6216
|
+
}
|
|
6217
|
+
if (formatKey === 'quarter') {
|
|
6218
|
+
return `${date.getFullYear()}-Q${Math.ceil((date.getMonth() + 1) / 3)}`;
|
|
6219
|
+
}
|
|
6220
|
+
const pattern = patternOverride || TEMPORAL_PATTERN[formatKey] || TEMPORAL_PATTERN.date;
|
|
6221
|
+
if (value && typeof value.format === 'function' && patternOverride) {
|
|
6222
|
+
try {
|
|
6223
|
+
return value.format(patternOverride);
|
|
6224
|
+
} catch (_unused) {
|
|
6225
|
+
// fall through to Date formatting
|
|
6226
|
+
}
|
|
6227
|
+
}
|
|
6228
|
+
return applyPattern(date, pattern);
|
|
6229
|
+
};
|
|
6230
|
+
const isTemporalKey = key => !!(key && (TEMPORAL_PATTERN[key] || key === 'week' || key === 'quarter'));
|
|
6231
|
+
const pickObjectLabel = (item, labelKey = 'label', valueKey = 'value') => {
|
|
6232
|
+
var _ref, _item$labelKey, _ref2, _ref3, _item$valueKey;
|
|
6233
|
+
if (item == null) {
|
|
6234
|
+
return '';
|
|
6235
|
+
}
|
|
6236
|
+
if (typeof item !== 'object') {
|
|
6237
|
+
return item;
|
|
6238
|
+
}
|
|
6239
|
+
const label = (_ref = (_item$labelKey = item[labelKey]) != null ? _item$labelKey : item.label) != null ? _ref : item.name;
|
|
6240
|
+
if (label != null && typeof label !== 'object' && label !== '') {
|
|
6241
|
+
return label;
|
|
6242
|
+
}
|
|
6243
|
+
const raw = (_ref2 = (_ref3 = (_item$valueKey = item[valueKey]) != null ? _item$valueKey : item.value) != null ? _ref3 : item.id) != null ? _ref2 : item.code;
|
|
6244
|
+
if (raw != null && typeof raw !== 'object') {
|
|
6245
|
+
return raw;
|
|
6246
|
+
}
|
|
6247
|
+
return '';
|
|
6248
|
+
};
|
|
6249
|
+
const mapOptionLabel = (value, options, labelKey = 'label', valueKey = 'value') => {
|
|
6250
|
+
var _ref4, _match$labelKey;
|
|
6251
|
+
if (value && typeof value === 'object') {
|
|
6252
|
+
return pickObjectLabel(value, labelKey, valueKey);
|
|
6253
|
+
}
|
|
6254
|
+
if (!Array.isArray(options) || !options.length) {
|
|
6255
|
+
return value == null ? '' : value;
|
|
6256
|
+
}
|
|
6257
|
+
const match = options.find(item => item && (item[valueKey] === value || item.value === value));
|
|
6258
|
+
return (_ref4 = (_match$labelKey = match == null ? void 0 : match[labelKey]) != null ? _match$labelKey : match == null ? void 0 : match.label) != null ? _ref4 : value;
|
|
6259
|
+
};
|
|
6260
|
+
const formatOption = (value, field) => {
|
|
6261
|
+
const props = (field == null ? void 0 : field.props) || {};
|
|
6262
|
+
const labelKey = props.labelKey || 'label';
|
|
6263
|
+
const valueKey = props.valueKey || 'value';
|
|
6264
|
+
const pick = item => {
|
|
6265
|
+
if (item && typeof item === 'object') {
|
|
6266
|
+
return pickObjectLabel(item, labelKey, valueKey);
|
|
6267
|
+
}
|
|
6268
|
+
return mapOptionLabel(item, props.options, labelKey, valueKey);
|
|
6269
|
+
};
|
|
6270
|
+
if (Array.isArray(value)) {
|
|
6271
|
+
return value.map(pick).filter(item => item != null && item !== '').join('、');
|
|
6272
|
+
}
|
|
6273
|
+
const label = pick(value);
|
|
6274
|
+
return label == null ? '' : label;
|
|
6275
|
+
};
|
|
6276
|
+
const formatPhone = value => {
|
|
6277
|
+
var _ref5, _ref6, _value$value, _value$code;
|
|
6278
|
+
if (value == null || value === '') {
|
|
6279
|
+
return '';
|
|
6280
|
+
}
|
|
6281
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
6282
|
+
const trimmed = String(value).trim().replace(/\s+/g, ' ');
|
|
6283
|
+
return trimmed;
|
|
6284
|
+
}
|
|
6285
|
+
if (typeof value !== 'object') {
|
|
6286
|
+
return String(value);
|
|
6287
|
+
}
|
|
6288
|
+
const number = String((_ref5 = (_ref6 = (_value$value = value.value) != null ? _value$value : value.phone) != null ? _ref6 : value.number) != null ? _ref5 : '').replace(/\s+/g, '');
|
|
6289
|
+
const rawCode = (_value$code = value.code) != null ? _value$code : value.countryCallingCode;
|
|
6290
|
+
const code = rawCode == null || rawCode === '' ? '' : String(rawCode).replace(/^\+/, '');
|
|
6291
|
+
if (!number) {
|
|
6292
|
+
return '';
|
|
6293
|
+
}
|
|
6294
|
+
if (!code) {
|
|
6295
|
+
return number;
|
|
6296
|
+
}
|
|
6297
|
+
return `+${code} ${number}`;
|
|
6298
|
+
};
|
|
6299
|
+
const formatFile = value => {
|
|
6300
|
+
var _value$originFileObj;
|
|
6301
|
+
if (Array.isArray(value)) {
|
|
6302
|
+
return value.map(item => formatFile(item)).filter(Boolean).join('、');
|
|
6303
|
+
}
|
|
6304
|
+
if (typeof value === 'string') {
|
|
6305
|
+
return value;
|
|
6306
|
+
}
|
|
6307
|
+
if (!value || typeof value !== 'object') {
|
|
6308
|
+
return value == null ? '' : String(value);
|
|
6309
|
+
}
|
|
6310
|
+
return value.filename || value.name || value.originName || ((_value$originFileObj = value.originFileObj) == null ? void 0 : _value$originFileObj.name) || value.id || '';
|
|
6311
|
+
};
|
|
6312
|
+
const formatTypedDateRange = (value, ctx) => {
|
|
6313
|
+
var _ctx$field;
|
|
6314
|
+
if (!value || typeof value !== 'object') {
|
|
6315
|
+
return value == null ? '' : String(value);
|
|
6316
|
+
}
|
|
6317
|
+
const formatKey = TYPE_TO_TEMPORAL[value.type] || 'date';
|
|
6318
|
+
const range = formatTemporal(value.value, formatKey, (_ctx$field = ctx.field) == null || (_ctx$field = _ctx$field.props) == null ? void 0 : _ctx$field.format);
|
|
6319
|
+
const typeLabel = value.type ? String(value.type) : '';
|
|
6320
|
+
return [typeLabel, range].filter(Boolean).join(' ');
|
|
6321
|
+
};
|
|
6322
|
+
const formatDateToToday = (value, itemSchema, ctx) => {
|
|
6323
|
+
const items = Array.isArray(value) ? value : [value];
|
|
6324
|
+
const start = formatByValueSchema(items[0], itemSchema, ctx);
|
|
6325
|
+
if (items[1] == null || items[1] === '' || items[1] === true) {
|
|
6326
|
+
const until = (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6327
|
+
id: 'schemaContentUntilToday'
|
|
6328
|
+
})) || '至今';
|
|
6329
|
+
return [start, until].filter(Boolean).join(' ~ ');
|
|
6330
|
+
}
|
|
6331
|
+
const end = formatByValueSchema(items[1], itemSchema, ctx);
|
|
6332
|
+
return [start, end].filter(Boolean).join(' ~ ');
|
|
6333
|
+
};
|
|
6334
|
+
const formatJson = value => {
|
|
6335
|
+
if (typeof value === 'string') {
|
|
6336
|
+
try {
|
|
6337
|
+
return JSON.stringify(JSON.parse(value), null, 2);
|
|
6338
|
+
} catch (_unused2) {
|
|
6339
|
+
return value;
|
|
6340
|
+
}
|
|
6341
|
+
}
|
|
6342
|
+
if (value && typeof value === 'object') {
|
|
6343
|
+
return JSON.stringify(value, null, 2);
|
|
6344
|
+
}
|
|
6345
|
+
return value == null ? '' : String(value);
|
|
6346
|
+
};
|
|
6347
|
+
const formatHtml = value => String(value != null ? value : '').replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
|
|
6348
|
+
const formatMoney = value => {
|
|
6349
|
+
const num = Number(value);
|
|
6350
|
+
if (Number.isNaN(num)) {
|
|
6351
|
+
return value == null ? '' : String(value);
|
|
6352
|
+
}
|
|
6353
|
+
return num.toLocaleString();
|
|
6354
|
+
};
|
|
6355
|
+
const formatColor = value => {
|
|
6356
|
+
if (value == null) {
|
|
6357
|
+
return '';
|
|
6358
|
+
}
|
|
6359
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
6360
|
+
return String(value);
|
|
6361
|
+
}
|
|
6362
|
+
if (typeof value === 'object') {
|
|
6363
|
+
if (typeof value.toHexString === 'function') {
|
|
6364
|
+
return value.toHexString();
|
|
6365
|
+
}
|
|
6366
|
+
return value.hex || value.metaColor || pickObjectLabel(value) || '';
|
|
6367
|
+
}
|
|
6368
|
+
return String(value);
|
|
6369
|
+
};
|
|
6370
|
+
const formatPassword = (value, ctx) => {
|
|
6371
|
+
if (isEmptyValue(value)) {
|
|
6372
|
+
return '';
|
|
6373
|
+
}
|
|
6374
|
+
return (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6375
|
+
id: 'schemaContentPasswordMasked'
|
|
6376
|
+
})) || '••••••';
|
|
6377
|
+
};
|
|
6378
|
+
const formatBoolean = (value, field, ctx) => {
|
|
6379
|
+
const props = (field == null ? void 0 : field.props) || {};
|
|
6380
|
+
if (value) {
|
|
6381
|
+
return props.checkedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6382
|
+
id: 'schemaContentYes'
|
|
6383
|
+
})) || '是';
|
|
6384
|
+
}
|
|
6385
|
+
return props.unCheckedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6386
|
+
id: 'schemaContentNo'
|
|
6387
|
+
})) || '否';
|
|
6388
|
+
};
|
|
6389
|
+
const stringifyFallback = value => {
|
|
6390
|
+
if (value == null) {
|
|
6391
|
+
return '';
|
|
6392
|
+
}
|
|
6393
|
+
if (typeof value !== 'object') {
|
|
6394
|
+
return String(value);
|
|
6395
|
+
}
|
|
6396
|
+
if (toDate(value)) {
|
|
6397
|
+
return formatTemporal(value, 'date-time');
|
|
6398
|
+
}
|
|
6399
|
+
if (Array.isArray(value)) {
|
|
6400
|
+
return value.map(item => item && typeof item === 'object' ? stringifyFallback(item) : String(item != null ? item : '')).filter(Boolean).join('、');
|
|
6401
|
+
}
|
|
6402
|
+
if (value.label != null || value.name != null) {
|
|
6403
|
+
return pickObjectLabel(value);
|
|
6404
|
+
}
|
|
6405
|
+
if (value.filename || value.mimetype || value.storageType) {
|
|
6406
|
+
return formatFile(value);
|
|
6407
|
+
}
|
|
6408
|
+
if (value.code != null && value.value != null && value.label == null) {
|
|
6409
|
+
return formatPhone(value);
|
|
6410
|
+
}
|
|
6411
|
+
if (value.type != null && Array.isArray(value.value)) {
|
|
6412
|
+
return formatTypedDateRange(value, {
|
|
6413
|
+
field: {}
|
|
6414
|
+
});
|
|
6415
|
+
}
|
|
6416
|
+
try {
|
|
6417
|
+
return JSON.stringify(value);
|
|
6418
|
+
} catch (_unused3) {
|
|
6419
|
+
return '';
|
|
6420
|
+
}
|
|
6421
|
+
};
|
|
6422
|
+
const formatByValueSchema = (value, schema, ctx = {}) => {
|
|
6423
|
+
var _field$props, _field$props2;
|
|
6424
|
+
if (isEmptyValue(value)) {
|
|
6425
|
+
return '';
|
|
6426
|
+
}
|
|
6427
|
+
const resolved = schema && typeof schema === 'object' ? schema : {};
|
|
6428
|
+
const type = resolved.type;
|
|
6429
|
+
const format = resolved.format;
|
|
6430
|
+
const display = resolved.display;
|
|
6431
|
+
const field = ctx.field;
|
|
6432
|
+
const patternOverride = field == null || (_field$props = field.props) == null ? void 0 : _field$props.format;
|
|
6433
|
+
if (display === 'option') {
|
|
6434
|
+
return formatOption(value, field);
|
|
6435
|
+
}
|
|
6436
|
+
if (display === 'phone') {
|
|
6437
|
+
return formatPhone(value);
|
|
6438
|
+
}
|
|
6439
|
+
if (display === 'file') {
|
|
6440
|
+
return /*#__PURE__*/createElement(FileFieldPreview$1, {
|
|
6441
|
+
value,
|
|
6442
|
+
field
|
|
6443
|
+
});
|
|
6444
|
+
}
|
|
6445
|
+
if (display === 'typed-date-range') {
|
|
6446
|
+
return formatTypedDateRange(value, ctx);
|
|
6447
|
+
}
|
|
6448
|
+
if (display === 'date-to-today') {
|
|
6449
|
+
return formatDateToToday(value, resolved.items || {
|
|
6450
|
+
type: 'string',
|
|
6451
|
+
format: 'date'
|
|
6452
|
+
}, ctx);
|
|
6453
|
+
}
|
|
6454
|
+
if (display === 'html' || format === 'html') {
|
|
6455
|
+
return formatHtml(value);
|
|
6456
|
+
}
|
|
6457
|
+
if (display === 'money') {
|
|
6458
|
+
return formatMoney(value);
|
|
6459
|
+
}
|
|
6460
|
+
if (format === 'password') {
|
|
6461
|
+
return formatPassword(value, ctx);
|
|
6462
|
+
}
|
|
6463
|
+
if (format === 'json') {
|
|
6464
|
+
return formatJson(value);
|
|
6465
|
+
}
|
|
6466
|
+
if (format === 'color') {
|
|
6467
|
+
return formatColor(value);
|
|
6468
|
+
}
|
|
6469
|
+
if (type === 'boolean') {
|
|
6470
|
+
return formatBoolean(value, field, ctx);
|
|
6471
|
+
}
|
|
6472
|
+
if (isTemporalKey(format)) {
|
|
6473
|
+
return formatTemporal(value, format, patternOverride);
|
|
6474
|
+
}
|
|
6475
|
+
if (type === 'array') {
|
|
6476
|
+
const items = Array.isArray(value) ? value : [value];
|
|
6477
|
+
const itemSchema = resolved.items || {};
|
|
6478
|
+
if (itemSchema.display === 'file') {
|
|
6479
|
+
return /*#__PURE__*/createElement(FileFieldPreview$1, {
|
|
6480
|
+
value: items,
|
|
6481
|
+
field
|
|
6482
|
+
});
|
|
6483
|
+
}
|
|
6484
|
+
const joiner = isTemporalKey(itemSchema.format) || itemSchema.display === 'date-to-today' ? ' ~ ' : '、';
|
|
6485
|
+
return items.map(item => formatByValueSchema(item, itemSchema, ctx)).filter(item => item != null && item !== '').join(joiner);
|
|
6486
|
+
}
|
|
6487
|
+
if (Array.isArray(value)) {
|
|
6488
|
+
const itemSchema = resolved.items || _extends({}, resolved, {
|
|
6489
|
+
type: undefined
|
|
6490
|
+
});
|
|
6491
|
+
if (itemSchema.display === 'file' || resolved.display === 'file') {
|
|
6492
|
+
return /*#__PURE__*/createElement(FileFieldPreview$1, {
|
|
6493
|
+
value,
|
|
6494
|
+
field
|
|
6495
|
+
});
|
|
6496
|
+
}
|
|
6497
|
+
const joiner = isTemporalKey(itemSchema.format) ? ' ~ ' : '、';
|
|
6498
|
+
return value.map(item => formatByValueSchema(item, itemSchema, ctx)).filter(item => item != null && item !== '').join(joiner);
|
|
6499
|
+
}
|
|
6500
|
+
if (Array.isArray(resolved.enum) || Array.isArray(field == null || (_field$props2 = field.props) == null ? void 0 : _field$props2.options) && field.props.options.length) {
|
|
6501
|
+
const mapped = formatOption(value, field);
|
|
6502
|
+
if (mapped != null && mapped !== '') {
|
|
6503
|
+
return mapped;
|
|
6504
|
+
}
|
|
6505
|
+
}
|
|
6506
|
+
if (type === 'object') {
|
|
6507
|
+
return stringifyFallback(value);
|
|
6508
|
+
}
|
|
6509
|
+
if (typeof value === 'object') {
|
|
6510
|
+
return stringifyFallback(value);
|
|
6511
|
+
}
|
|
6512
|
+
return String(value);
|
|
6513
|
+
};
|
|
6514
|
+
const formatFieldDisplayValue = (field, value, {
|
|
6515
|
+
formatMessage
|
|
6516
|
+
} = {}) => {
|
|
6517
|
+
const emptyText = (formatMessage == null ? void 0 : formatMessage({
|
|
6518
|
+
id: 'schemaContentEmptyValue'
|
|
6519
|
+
})) || '-';
|
|
6520
|
+
if (isEmptyValue(value)) {
|
|
6521
|
+
return emptyText;
|
|
6522
|
+
}
|
|
6523
|
+
const definition = getFieldDefinition(field == null ? void 0 : field.type);
|
|
6524
|
+
if (typeof (definition == null ? void 0 : definition.formatDisplayValue) === 'function') {
|
|
6525
|
+
const custom = definition.formatDisplayValue(value, field, {
|
|
6526
|
+
formatMessage
|
|
6527
|
+
});
|
|
6528
|
+
if (custom != null && custom !== '') {
|
|
6529
|
+
return custom;
|
|
6530
|
+
}
|
|
6531
|
+
}
|
|
6532
|
+
const schema = resolveFieldValueSchema(field);
|
|
6533
|
+
const text = formatByValueSchema(value, schema, {
|
|
6534
|
+
field,
|
|
6535
|
+
formatMessage
|
|
6536
|
+
});
|
|
6537
|
+
return text == null || text === '' ? emptyText : text;
|
|
6538
|
+
};
|
|
6539
|
+
|
|
5905
6540
|
const _excluded = ["label", "validator"];
|
|
5906
6541
|
|
|
5907
6542
|
/**
|
|
@@ -6243,15 +6878,6 @@ const getByPath = (data, path) => {
|
|
|
6243
6878
|
}
|
|
6244
6879
|
return String(path).split('.').reduce((acc, key) => acc == null ? acc : acc[key], data);
|
|
6245
6880
|
};
|
|
6246
|
-
const isEmptyValue = value => {
|
|
6247
|
-
if (value == null || value === '') {
|
|
6248
|
-
return true;
|
|
6249
|
-
}
|
|
6250
|
-
if (Array.isArray(value) && value.length === 0) {
|
|
6251
|
-
return true;
|
|
6252
|
-
}
|
|
6253
|
-
return false;
|
|
6254
|
-
};
|
|
6255
6881
|
const resolveChoiceSelectorName = block => {
|
|
6256
6882
|
var _block$discriminator;
|
|
6257
6883
|
if (block.selectorName != null && String(block.selectorName).trim()) {
|
|
@@ -6262,89 +6888,9 @@ const resolveChoiceSelectorName = block => {
|
|
|
6262
6888
|
}
|
|
6263
6889
|
return `__choice_${block.id}`;
|
|
6264
6890
|
};
|
|
6265
|
-
const
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
return value.map(item => formatDateValue(item, format)).filter(item => item !== '').join(' ~ ');
|
|
6269
|
-
}
|
|
6270
|
-
if (value && typeof value.format === 'function') {
|
|
6271
|
-
return value.format(pattern);
|
|
6272
|
-
}
|
|
6273
|
-
return value == null ? '' : String(value);
|
|
6274
|
-
};
|
|
6275
|
-
const mapOptionLabel = (value, options) => {
|
|
6276
|
-
var _match$label;
|
|
6277
|
-
if (!Array.isArray(options) || !options.length) {
|
|
6278
|
-
return value;
|
|
6279
|
-
}
|
|
6280
|
-
const match = options.find(item => item && item.value === value);
|
|
6281
|
-
return (_match$label = match == null ? void 0 : match.label) != null ? _match$label : value;
|
|
6282
|
-
};
|
|
6283
|
-
const formatFieldValue = (field, value, formatMessage) => {
|
|
6284
|
-
if (isEmptyValue(value)) {
|
|
6285
|
-
return formatMessage({
|
|
6286
|
-
id: 'schemaContentEmptyValue'
|
|
6287
|
-
});
|
|
6288
|
-
}
|
|
6289
|
-
const definition = getFieldDefinition(field.type);
|
|
6290
|
-
const props = field.props || {};
|
|
6291
|
-
const valueSchema = resolveFieldValueSchema(field);
|
|
6292
|
-
const schemaType = valueSchema == null ? void 0 : valueSchema.type;
|
|
6293
|
-
if (schemaType === 'boolean' || field.type === 'Switch' || field.type === 'Checkbox') {
|
|
6294
|
-
if (value) {
|
|
6295
|
-
return props.checkedChildren || formatMessage({
|
|
6296
|
-
id: 'schemaContentYes'
|
|
6297
|
-
});
|
|
6298
|
-
}
|
|
6299
|
-
return props.unCheckedChildren || formatMessage({
|
|
6300
|
-
id: 'schemaContentNo'
|
|
6301
|
-
});
|
|
6302
|
-
}
|
|
6303
|
-
if (field.type === 'DatePicker') {
|
|
6304
|
-
const formatted = formatDateValue(value, props.format);
|
|
6305
|
-
return formatted || formatMessage({
|
|
6306
|
-
id: 'schemaContentEmptyValue'
|
|
6307
|
-
});
|
|
6308
|
-
}
|
|
6309
|
-
if (Array.isArray(props.options) && props.options.length) {
|
|
6310
|
-
if (Array.isArray(value)) {
|
|
6311
|
-
const labels = value.map(item => mapOptionLabel(item, props.options)).filter(item => item != null && item !== '');
|
|
6312
|
-
return labels.length ? labels.join('、') : formatMessage({
|
|
6313
|
-
id: 'schemaContentEmptyValue'
|
|
6314
|
-
});
|
|
6315
|
-
}
|
|
6316
|
-
return mapOptionLabel(value, props.options);
|
|
6317
|
-
}
|
|
6318
|
-
if (definition != null && definition.isSuperSelect) {
|
|
6319
|
-
const labelKey = props.labelKey || 'label';
|
|
6320
|
-
const pickLabel = item => {
|
|
6321
|
-
if (item && typeof item === 'object') {
|
|
6322
|
-
var _ref, _item$labelKey;
|
|
6323
|
-
return (_ref = (_item$labelKey = item[labelKey]) != null ? _item$labelKey : item.label) != null ? _ref : item.value;
|
|
6324
|
-
}
|
|
6325
|
-
return item;
|
|
6326
|
-
};
|
|
6327
|
-
if (Array.isArray(value)) {
|
|
6328
|
-
const labels = value.map(pickLabel).filter(item => item != null && item !== '');
|
|
6329
|
-
return labels.length ? labels.join('、') : formatMessage({
|
|
6330
|
-
id: 'schemaContentEmptyValue'
|
|
6331
|
-
});
|
|
6332
|
-
}
|
|
6333
|
-
if (value && typeof value === 'object') {
|
|
6334
|
-
var _pickLabel;
|
|
6335
|
-
return (_pickLabel = pickLabel(value)) != null ? _pickLabel : formatMessage({
|
|
6336
|
-
id: 'schemaContentEmptyValue'
|
|
6337
|
-
});
|
|
6338
|
-
}
|
|
6339
|
-
}
|
|
6340
|
-
if (Array.isArray(value)) {
|
|
6341
|
-
return value.map(item => item && typeof item === 'object' ? JSON.stringify(item) : String(item)).join('、');
|
|
6342
|
-
}
|
|
6343
|
-
if (typeof value === 'object') {
|
|
6344
|
-
return JSON.stringify(value);
|
|
6345
|
-
}
|
|
6346
|
-
return String(value);
|
|
6347
|
-
};
|
|
6891
|
+
const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValue(field, value, {
|
|
6892
|
+
formatMessage
|
|
6893
|
+
});
|
|
6348
6894
|
const renderFieldsContent = (fields, data, formatMessage, column) => {
|
|
6349
6895
|
const list = (fields || []).filter(field => field && !field.hidden && field.name).map(field => ({
|
|
6350
6896
|
label: field.label || field.name,
|
|
@@ -6522,5 +7068,5 @@ const SchemaContent = withLocale$1(({
|
|
|
6522
7068
|
});
|
|
6523
7069
|
var SchemaContent$1 = SchemaContent;
|
|
6524
7070
|
|
|
6525
|
-
export { FormCreator$1 as FormCreator, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaContent$1 as SchemaContent, SchemaContentInner, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectBlockFieldNames, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, findBlockInTree, formValuesToBlock, formValuesToField, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasRenderableContent, isFieldNameUnique, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, removeBlockInTree, resolveFieldValueSchema, schemaToDataSchema, updateBlocks };
|
|
7071
|
+
export { FormCreator$1 as FormCreator, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaContent$1 as SchemaContent, SchemaContentInner, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectBlockFieldNames, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, findBlockInTree, formValuesToBlock, formValuesToField, formatByValueSchema, formatFieldDisplayValue, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasRenderableContent, isFieldNameUnique, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, removeBlockInTree, resolveFieldValueSchema, schemaToDataSchema, updateBlocks };
|
|
6526
7072
|
//# sourceMappingURL=index.modern.js.map
|