@kne/form-creator 0.1.13 → 0.1.15
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 +260 -3
- package/dist/index.css +38 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +968 -48
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +945 -61
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +8 -1
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +8 -1
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +8 -1
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +8 -1
- package/dist/locale/zh-CN.modern.js.map +1 -1
- package/package.json +8 -5
package/dist/index.modern.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import '@kne/form-info/dist/index.css';
|
|
2
2
|
import '@kne/info-page/dist/index.css';
|
|
3
|
+
import '@kne/button-group/dist/index.css';
|
|
3
4
|
import { useState, useRef, useMemo, useEffect, useCallback, createElement, Fragment } from 'react';
|
|
4
5
|
import { Space, Tag, Button, Typography, Flex, Dropdown, Empty, message, Checkbox as Checkbox$1, Input as Input$1, InputNumber as InputNumber$1, Card, Tooltip } from 'antd';
|
|
5
6
|
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
@@ -12,9 +13,11 @@ import '@kne/super-select/dist/index.css';
|
|
|
12
13
|
import '@kne/super-select-plus/dist/index.css';
|
|
13
14
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
14
15
|
import FormInfo, { FormModal, Form, Steps, MultiField, TableList, List } from '@kne/form-info';
|
|
15
|
-
import
|
|
16
|
+
import { ButtonFooter } from '@kne/button-group';
|
|
17
|
+
import InfoPage, { Content } from '@kne/info-page';
|
|
18
|
+
import { createWithRemoteLoader } from '@kne/remote-loader';
|
|
16
19
|
|
|
17
|
-
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","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"};
|
|
18
21
|
|
|
19
22
|
function _extends() {
|
|
20
23
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -227,7 +230,14 @@ const locale$1 = {
|
|
|
227
230
|
formSettingsTitle: '表单设置',
|
|
228
231
|
formTitlePlaceholder: '表单标题(可选)',
|
|
229
232
|
formSubtitlePlaceholder: '表单副标题(可选)',
|
|
230
|
-
formColumnPlaceholder: '每行显示列数'
|
|
233
|
+
formColumnPlaceholder: '每行显示列数',
|
|
234
|
+
schemaContentEmpty: '暂无数据',
|
|
235
|
+
schemaContentEmptyValue: '-',
|
|
236
|
+
schemaContentYes: '是',
|
|
237
|
+
schemaContentNo: '否',
|
|
238
|
+
schemaContentItemIndex: '第 {index} 项',
|
|
239
|
+
schemaContentUntilToday: '至今',
|
|
240
|
+
schemaContentPasswordMasked: '••••••'
|
|
231
241
|
};
|
|
232
242
|
var zhCN = locale$1;
|
|
233
243
|
|
|
@@ -423,7 +433,14 @@ const locale = {
|
|
|
423
433
|
formSettingsTitle: 'Form Settings',
|
|
424
434
|
formTitlePlaceholder: 'Form title (optional)',
|
|
425
435
|
formSubtitlePlaceholder: 'Form subtitle (optional)',
|
|
426
|
-
formColumnPlaceholder: 'Columns per row'
|
|
436
|
+
formColumnPlaceholder: 'Columns per row',
|
|
437
|
+
schemaContentEmpty: 'No data',
|
|
438
|
+
schemaContentEmptyValue: '-',
|
|
439
|
+
schemaContentYes: 'Yes',
|
|
440
|
+
schemaContentNo: 'No',
|
|
441
|
+
schemaContentItemIndex: 'Item {index}',
|
|
442
|
+
schemaContentUntilToday: 'Present',
|
|
443
|
+
schemaContentPasswordMasked: '••••••'
|
|
427
444
|
};
|
|
428
445
|
var enUS = locale;
|
|
429
446
|
|
|
@@ -1237,6 +1254,81 @@ const mapOptionItem = item => {
|
|
|
1237
1254
|
}
|
|
1238
1255
|
return next;
|
|
1239
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
|
+
};
|
|
1240
1332
|
const createApiFromOptions = (options = []) => ({
|
|
1241
1333
|
loader: () => ({
|
|
1242
1334
|
pageData: options.map(mapOptionItem)
|
|
@@ -1250,6 +1342,7 @@ const {
|
|
|
1250
1342
|
const hasNestedOptions = options => Array.isArray(options) && options.some(item => Array.isArray(item == null ? void 0 : item.children) && item.children.length);
|
|
1251
1343
|
const createField = (Component, {
|
|
1252
1344
|
preferOptions: _preferOptions = false,
|
|
1345
|
+
flattenTree: _flattenTree = false,
|
|
1253
1346
|
placeholderPrefix: _placeholderPrefix = '请选择'
|
|
1254
1347
|
} = {}) => {
|
|
1255
1348
|
const Field = props => {
|
|
@@ -1259,14 +1352,28 @@ const createField = (Component, {
|
|
|
1259
1352
|
placeholder
|
|
1260
1353
|
} = props,
|
|
1261
1354
|
rest = _objectWithoutPropertiesLoose(props, _excluded$3);
|
|
1262
|
-
const
|
|
1263
|
-
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);
|
|
1264
1368
|
const resolvedPlaceholder = placeholder != null && String(placeholder).trim() ? placeholder : `${_placeholderPrefix}${props.label || ''}`;
|
|
1265
1369
|
const render = useOnChange$1(Object.assign({}, {
|
|
1266
1370
|
isPopup: true,
|
|
1267
1371
|
placeholder: resolvedPlaceholder
|
|
1268
|
-
}, rest,
|
|
1269
|
-
|
|
1372
|
+
}, rest, {
|
|
1373
|
+
valueKey,
|
|
1374
|
+
labelKey
|
|
1375
|
+
}, useOptionsDirectly && Array.isArray(resolvedOptions) ? {
|
|
1376
|
+
options: resolvedOptions
|
|
1270
1377
|
} : {}, mergedApi ? {
|
|
1271
1378
|
api: mergedApi
|
|
1272
1379
|
} : {}));
|
|
@@ -1280,7 +1387,8 @@ const SuperSelectTableList = createField(SelectTableList, {
|
|
|
1280
1387
|
preferOptions: true
|
|
1281
1388
|
});
|
|
1282
1389
|
const SuperSelectTree = createField(SelectTree, {
|
|
1283
|
-
preferOptions: true
|
|
1390
|
+
preferOptions: true,
|
|
1391
|
+
flattenTree: true
|
|
1284
1392
|
});
|
|
1285
1393
|
const SuperSelectCascader = createField(SelectCascader, {
|
|
1286
1394
|
preferOptions: true
|
|
@@ -1398,20 +1506,45 @@ const stringWithEnumSchema = field => {
|
|
|
1398
1506
|
}
|
|
1399
1507
|
return schema;
|
|
1400
1508
|
};
|
|
1509
|
+
const optionValueSchema = {
|
|
1510
|
+
type: 'object',
|
|
1511
|
+
display: 'option'
|
|
1512
|
+
};
|
|
1401
1513
|
const superSelectValueSchema = field => {
|
|
1402
1514
|
var _field$props2;
|
|
1403
1515
|
if (field != null && (_field$props2 = field.props) != null && _field$props2.single) {
|
|
1404
|
-
return {
|
|
1405
|
-
type: 'object'
|
|
1406
|
-
};
|
|
1516
|
+
return _extends({}, optionValueSchema);
|
|
1407
1517
|
}
|
|
1408
1518
|
return {
|
|
1409
1519
|
type: 'array',
|
|
1410
|
-
items: {
|
|
1411
|
-
type: 'object'
|
|
1412
|
-
}
|
|
1520
|
+
items: _extends({}, optionValueSchema)
|
|
1413
1521
|
};
|
|
1414
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
|
+
};
|
|
1415
1548
|
defineField('Input', {
|
|
1416
1549
|
label: '单行文本',
|
|
1417
1550
|
group: '基础字段',
|
|
@@ -1633,19 +1766,7 @@ defineField('DatePicker', {
|
|
|
1633
1766
|
},
|
|
1634
1767
|
hasFieldProps: true,
|
|
1635
1768
|
resolveComponent: props => props != null && props.range ? DatePicker.RangePicker || DatePicker : DatePicker,
|
|
1636
|
-
valueSchema:
|
|
1637
|
-
var _field$props3;
|
|
1638
|
-
return field != null && (_field$props3 = field.props) != null && _field$props3.range ? {
|
|
1639
|
-
type: 'array',
|
|
1640
|
-
items: {
|
|
1641
|
-
type: 'string'
|
|
1642
|
-
},
|
|
1643
|
-
minItems: 2,
|
|
1644
|
-
maxItems: 2
|
|
1645
|
-
} : {
|
|
1646
|
-
type: 'string'
|
|
1647
|
-
};
|
|
1648
|
-
}
|
|
1769
|
+
valueSchema: datePickerValueSchema
|
|
1649
1770
|
});
|
|
1650
1771
|
|
|
1651
1772
|
/**
|
|
@@ -1661,6 +1782,8 @@ defineField('DatePicker', {
|
|
|
1661
1782
|
* preset({ type, definition }) 的 fields 项还可传:
|
|
1662
1783
|
* - groupName?: string 自定义类型下拉分组名;不传则归入「扩展字段」
|
|
1663
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 默认预览
|
|
1664
1787
|
*/
|
|
1665
1788
|
const registerField = (type, definition) => {
|
|
1666
1789
|
var _definition$hasFieldP;
|
|
@@ -2069,16 +2192,16 @@ const applyFieldProps = (props, values, definition) => {
|
|
|
2069
2192
|
}
|
|
2070
2193
|
};
|
|
2071
2194
|
const fieldToFormValues = field => {
|
|
2072
|
-
var _field$
|
|
2195
|
+
var _field$props6, _field$props7, _field$props8;
|
|
2073
2196
|
const definition = getFieldDefinition(field.type);
|
|
2074
2197
|
const ruleConfig = parseRuleString(field.rule);
|
|
2075
2198
|
const allowChildren = !!(definition != null && definition.optionsAllowChildren);
|
|
2076
|
-
const columns = definition != null && definition.hasColumns ? normalizeColumns((_field$
|
|
2077
|
-
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, {
|
|
2078
2201
|
allowChildren,
|
|
2079
2202
|
columns
|
|
2080
2203
|
});
|
|
2081
|
-
const rawPlaceholder = (_field$
|
|
2204
|
+
const rawPlaceholder = (_field$props8 = field.props) == null ? void 0 : _field$props8.placeholder;
|
|
2082
2205
|
const placeholder = Array.isArray(rawPlaceholder) ? rawPlaceholder[0] || '' : rawPlaceholder || '';
|
|
2083
2206
|
return {
|
|
2084
2207
|
type: field.type,
|
|
@@ -2319,7 +2442,8 @@ const BlockListPanel = ({
|
|
|
2319
2442
|
onEditChoiceOption,
|
|
2320
2443
|
onDeleteChoiceOption,
|
|
2321
2444
|
onMoveChoiceOption,
|
|
2322
|
-
onOpenFormActions
|
|
2445
|
+
onOpenFormActions,
|
|
2446
|
+
extraToolbar
|
|
2323
2447
|
}) => {
|
|
2324
2448
|
const {
|
|
2325
2449
|
formatMessage
|
|
@@ -2907,7 +3031,10 @@ const BlockListPanel = ({
|
|
|
2907
3031
|
id: 'formActionsSection'
|
|
2908
3032
|
}),
|
|
2909
3033
|
onClick: onOpenFormActions
|
|
2910
|
-
})
|
|
3034
|
+
}), extraToolbar ? /*#__PURE__*/jsx("div", {
|
|
3035
|
+
className: style['panel-toolbar-extra'],
|
|
3036
|
+
children: extraToolbar
|
|
3037
|
+
}) : null]
|
|
2911
3038
|
}), !blocks.length ? /*#__PURE__*/jsx(Empty, {
|
|
2912
3039
|
className: style['field-empty'],
|
|
2913
3040
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
@@ -4731,7 +4858,7 @@ const FormActionsEditor = ({
|
|
|
4731
4858
|
};
|
|
4732
4859
|
var FormActionsEditor$1 = FormActionsEditor;
|
|
4733
4860
|
|
|
4734
|
-
const getByPath = (obj, path) => {
|
|
4861
|
+
const getByPath$1 = (obj, path) => {
|
|
4735
4862
|
if (obj == null || path == null || path === '') {
|
|
4736
4863
|
return undefined;
|
|
4737
4864
|
}
|
|
@@ -4775,7 +4902,7 @@ const clearUnselectedOptionFields = (openApi, formData, keepIds, allOptions) =>
|
|
|
4775
4902
|
if (!(field != null && field.name)) {
|
|
4776
4903
|
return;
|
|
4777
4904
|
}
|
|
4778
|
-
const current = getByPath(formData, field.name);
|
|
4905
|
+
const current = getByPath$1(formData, field.name);
|
|
4779
4906
|
if (current !== undefined) {
|
|
4780
4907
|
entries.push({
|
|
4781
4908
|
name: field.name,
|
|
@@ -4784,7 +4911,7 @@ const clearUnselectedOptionFields = (openApi, formData, keepIds, allOptions) =>
|
|
|
4784
4911
|
}
|
|
4785
4912
|
});
|
|
4786
4913
|
collectBlockFieldNames(option.blocks || []).forEach(name => {
|
|
4787
|
-
const current = getByPath(formData, name);
|
|
4914
|
+
const current = getByPath$1(formData, name);
|
|
4788
4915
|
if (current !== undefined) {
|
|
4789
4916
|
entries.push({
|
|
4790
4917
|
name,
|
|
@@ -4867,7 +4994,7 @@ const ChoiceBlock = ({
|
|
|
4867
4994
|
maxLength
|
|
4868
4995
|
} = mode === 'multiple' ? resolveSelectLimits(block) : {};
|
|
4869
4996
|
const firstOptionId = options[0] != null ? String(options[0].id) : undefined;
|
|
4870
|
-
const rawValue = getByPath(formData || {}, selectorName);
|
|
4997
|
+
const rawValue = getByPath$1(formData || {}, selectorName);
|
|
4871
4998
|
// 仅随 selector 值变化;勿依赖整个 formData,否则清空未选支字段会触发 options 重算 → CheckboxGroup 死循环
|
|
4872
4999
|
const selectorValueKey = mode === 'multiple' ? Array.isArray(rawValue) ? rawValue.map(String).join('\0') : String(rawValue != null ? rawValue : '') : String(rawValue != null ? rawValue : '');
|
|
4873
5000
|
|
|
@@ -5025,7 +5152,7 @@ const renderFieldElements = (fields = [], preview = false, {
|
|
|
5025
5152
|
return null;
|
|
5026
5153
|
}
|
|
5027
5154
|
const definition = getFieldDefinition(field.type);
|
|
5028
|
-
const props = _extends({}, field.props || {});
|
|
5155
|
+
const props = _extends({}, (definition == null ? void 0 : definition.defaultProps) || {}, field.props || {});
|
|
5029
5156
|
if (definition != null && definition.optionsAllowDescription && (_props$options = props.options) != null && _props$options.length && !props.api && !definition.optionsAllowChildren) {
|
|
5030
5157
|
props.api = createApiFromOptions(props.options);
|
|
5031
5158
|
}
|
|
@@ -5249,6 +5376,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5249
5376
|
const renderSchemaInner = (schema, {
|
|
5250
5377
|
preview: _preview = false,
|
|
5251
5378
|
className,
|
|
5379
|
+
bodyClassName,
|
|
5252
5380
|
isMobile: _isMobile = false,
|
|
5253
5381
|
formatMessage,
|
|
5254
5382
|
children,
|
|
@@ -5263,15 +5391,19 @@ const renderSchemaInner = (schema, {
|
|
|
5263
5391
|
if (!contentChildren.length && !children && !actionNode) {
|
|
5264
5392
|
return null;
|
|
5265
5393
|
}
|
|
5266
|
-
const body = /*#__PURE__*/createElement(
|
|
5394
|
+
const body = /*#__PURE__*/createElement('div', {
|
|
5395
|
+
className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
|
|
5396
|
+
}, ...contentChildren, children);
|
|
5397
|
+
const content = /*#__PURE__*/createElement(Fragment, null, body, actionNode || null);
|
|
5267
5398
|
return className ? /*#__PURE__*/createElement('div', {
|
|
5268
5399
|
className
|
|
5269
|
-
},
|
|
5400
|
+
}, content) : content;
|
|
5270
5401
|
};
|
|
5271
5402
|
const renderSchemaContent = (schema, {
|
|
5272
5403
|
preview: _preview2 = false,
|
|
5273
5404
|
formProps: _formProps = {},
|
|
5274
5405
|
className,
|
|
5406
|
+
bodyClassName,
|
|
5275
5407
|
isMobile: _isMobile2 = false,
|
|
5276
5408
|
formatMessage,
|
|
5277
5409
|
children,
|
|
@@ -5290,11 +5422,12 @@ const renderSchemaContent = (schema, {
|
|
|
5290
5422
|
return /*#__PURE__*/createElement(Form, _extends({}, _formProps, {
|
|
5291
5423
|
className: formClassName
|
|
5292
5424
|
}), /*#__PURE__*/createElement('div', {
|
|
5293
|
-
className: style['schema-body']
|
|
5425
|
+
className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
|
|
5294
5426
|
}, ...contentChildren, children), actionNode || null);
|
|
5295
5427
|
};
|
|
5296
5428
|
var renderSchemaContent$1 = renderSchemaContent;
|
|
5297
5429
|
|
|
5430
|
+
const joinClass = (...names) => names.filter(Boolean).join(' ');
|
|
5298
5431
|
const resolveActionNode = ({
|
|
5299
5432
|
schema,
|
|
5300
5433
|
formatMessage,
|
|
@@ -5310,7 +5443,10 @@ const resolveActionNode = ({
|
|
|
5310
5443
|
showReset,
|
|
5311
5444
|
showCancel,
|
|
5312
5445
|
actionsAlign,
|
|
5313
|
-
actionsGap
|
|
5446
|
+
actionsGap,
|
|
5447
|
+
footerClassName,
|
|
5448
|
+
buttonFooter: _buttonFooter = false,
|
|
5449
|
+
buttonFooterProps
|
|
5314
5450
|
}) => {
|
|
5315
5451
|
if (_showActions === false || actions === false || actions === null) {
|
|
5316
5452
|
return null;
|
|
@@ -5340,19 +5476,26 @@ const resolveActionNode = ({
|
|
|
5340
5476
|
gap: resolvedGap != null ? resolvedGap : 16,
|
|
5341
5477
|
wrap: 'wrap'
|
|
5342
5478
|
};
|
|
5479
|
+
let actionsEl = null;
|
|
5343
5480
|
if (actions !== undefined) {
|
|
5344
|
-
|
|
5345
|
-
className: style['schema-actions']
|
|
5481
|
+
actionsEl = /*#__PURE__*/createElement('div', {
|
|
5482
|
+
className: joinClass(style['schema-actions'], footerClassName)
|
|
5346
5483
|
}, /*#__PURE__*/createElement(Flex, flexProps, actions));
|
|
5347
|
-
}
|
|
5348
|
-
|
|
5484
|
+
} else if (resolvedShowSubmit || resolvedShowReset || resolvedShowCancel) {
|
|
5485
|
+
actionsEl = /*#__PURE__*/createElement('div', {
|
|
5486
|
+
className: joinClass(style['schema-actions'], footerClassName)
|
|
5487
|
+
}, /*#__PURE__*/createElement(Flex, flexProps, resolvedShowSubmit ? /*#__PURE__*/createElement(SubmitButton, _extends({
|
|
5488
|
+
type: 'primary'
|
|
5489
|
+
}, resolvedSubmitButtonProps), resolvedSubmitText) : null, resolvedShowReset ? /*#__PURE__*/createElement(ResetButton, resolvedResetButtonProps, resolvedResetText) : null, resolvedShowCancel ? /*#__PURE__*/createElement(CancelButton, resolvedCancelButtonProps, resolvedCancelText) : null));
|
|
5490
|
+
}
|
|
5491
|
+
if (!actionsEl) {
|
|
5349
5492
|
return null;
|
|
5350
5493
|
}
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
}
|
|
5354
|
-
|
|
5355
|
-
|
|
5494
|
+
if (!_buttonFooter) {
|
|
5495
|
+
return actionsEl;
|
|
5496
|
+
}
|
|
5497
|
+
const footerProps = buttonFooterProps || {};
|
|
5498
|
+
return /*#__PURE__*/createElement(ButtonFooter, footerProps, actionsEl);
|
|
5356
5499
|
};
|
|
5357
5500
|
const SchemaRendererInner = withLocale$1(props => {
|
|
5358
5501
|
const {
|
|
@@ -5372,7 +5515,11 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5372
5515
|
showReset,
|
|
5373
5516
|
showCancel,
|
|
5374
5517
|
actionsAlign,
|
|
5375
|
-
actionsGap
|
|
5518
|
+
actionsGap,
|
|
5519
|
+
bodyClassName,
|
|
5520
|
+
footerClassName,
|
|
5521
|
+
buttonFooter = false,
|
|
5522
|
+
buttonFooterProps
|
|
5376
5523
|
} = props;
|
|
5377
5524
|
const {
|
|
5378
5525
|
formatMessage
|
|
@@ -5397,11 +5544,15 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5397
5544
|
showReset,
|
|
5398
5545
|
showCancel,
|
|
5399
5546
|
actionsAlign,
|
|
5400
|
-
actionsGap
|
|
5547
|
+
actionsGap,
|
|
5548
|
+
footerClassName,
|
|
5549
|
+
buttonFooter,
|
|
5550
|
+
buttonFooterProps
|
|
5401
5551
|
});
|
|
5402
5552
|
return renderSchemaInner(normalized, {
|
|
5403
5553
|
preview,
|
|
5404
5554
|
className,
|
|
5555
|
+
bodyClassName,
|
|
5405
5556
|
isMobile,
|
|
5406
5557
|
formatMessage,
|
|
5407
5558
|
children,
|
|
@@ -5427,7 +5578,11 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5427
5578
|
showReset,
|
|
5428
5579
|
showCancel,
|
|
5429
5580
|
actionsAlign,
|
|
5430
|
-
actionsGap
|
|
5581
|
+
actionsGap,
|
|
5582
|
+
bodyClassName,
|
|
5583
|
+
footerClassName,
|
|
5584
|
+
buttonFooter = false,
|
|
5585
|
+
buttonFooterProps
|
|
5431
5586
|
} = props;
|
|
5432
5587
|
const {
|
|
5433
5588
|
formatMessage
|
|
@@ -5452,12 +5607,16 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5452
5607
|
showReset,
|
|
5453
5608
|
showCancel,
|
|
5454
5609
|
actionsAlign,
|
|
5455
|
-
actionsGap
|
|
5610
|
+
actionsGap,
|
|
5611
|
+
footerClassName,
|
|
5612
|
+
buttonFooter,
|
|
5613
|
+
buttonFooterProps
|
|
5456
5614
|
});
|
|
5457
5615
|
return renderSchemaContent$1(normalized, {
|
|
5458
5616
|
preview,
|
|
5459
5617
|
formProps,
|
|
5460
5618
|
className,
|
|
5619
|
+
bodyClassName,
|
|
5461
5620
|
isMobile,
|
|
5462
5621
|
formatMessage,
|
|
5463
5622
|
children,
|
|
@@ -5473,7 +5632,8 @@ const FormCreator = withLocale$1(({
|
|
|
5473
5632
|
showPreview: _showPreview = true,
|
|
5474
5633
|
className,
|
|
5475
5634
|
formProps,
|
|
5476
|
-
renderModal
|
|
5635
|
+
renderModal,
|
|
5636
|
+
extraToolbar
|
|
5477
5637
|
}) => {
|
|
5478
5638
|
const {
|
|
5479
5639
|
formatMessage
|
|
@@ -5759,6 +5919,9 @@ const FormCreator = withLocale$1(({
|
|
|
5759
5919
|
stepId: fieldContext.stepId,
|
|
5760
5920
|
optionId: fieldContext.optionId
|
|
5761
5921
|
}) : [];
|
|
5922
|
+
const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
|
|
5923
|
+
schema
|
|
5924
|
+
}) : extraToolbar;
|
|
5762
5925
|
return /*#__PURE__*/jsxs("div", {
|
|
5763
5926
|
className: [style['form-creator'], RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
|
|
5764
5927
|
children: [/*#__PURE__*/jsx("div", {
|
|
@@ -5781,7 +5944,8 @@ const FormCreator = withLocale$1(({
|
|
|
5781
5944
|
onEditChoiceOption: handleEditChoiceOption,
|
|
5782
5945
|
onDeleteChoiceOption: handleDeleteChoiceOption,
|
|
5783
5946
|
onMoveChoiceOption: handleMoveChoiceOption,
|
|
5784
|
-
onOpenFormActions: () => setFormActionsOpen(true)
|
|
5947
|
+
onOpenFormActions: () => setFormActionsOpen(true),
|
|
5948
|
+
extraToolbar: toolbarExtra
|
|
5785
5949
|
})
|
|
5786
5950
|
}), _showPreview ? /*#__PURE__*/jsx("div", {
|
|
5787
5951
|
className: style['preview-pane'],
|
|
@@ -5849,6 +6013,530 @@ const FormCreator = withLocale$1(({
|
|
|
5849
6013
|
});
|
|
5850
6014
|
var FormCreator$1 = FormCreator;
|
|
5851
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
|
+
|
|
5852
6540
|
const _excluded = ["label", "validator"];
|
|
5853
6541
|
|
|
5854
6542
|
/**
|
|
@@ -5903,7 +6591,7 @@ const createObjectLayer = () => ({
|
|
|
5903
6591
|
composites: []
|
|
5904
6592
|
});
|
|
5905
6593
|
const isReq = rule => parseRuleString(rule).presets.includes('REQ');
|
|
5906
|
-
const resolveChoiceSelectorName = block => {
|
|
6594
|
+
const resolveChoiceSelectorName$1 = block => {
|
|
5907
6595
|
var _block$discriminator;
|
|
5908
6596
|
if (block.selectorName != null && String(block.selectorName).trim()) {
|
|
5909
6597
|
return String(block.selectorName).trim();
|
|
@@ -6077,7 +6765,7 @@ const walkBlock = (block, layer, depth = 0) => {
|
|
|
6077
6765
|
const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
6078
6766
|
const mode = block.mode === 'multiple' ? 'multiple' : 'single';
|
|
6079
6767
|
const selectorInData = block.selectorInData !== false;
|
|
6080
|
-
const selectorName = resolveChoiceSelectorName(block);
|
|
6768
|
+
const selectorName = resolveChoiceSelectorName$1(block);
|
|
6081
6769
|
const options = block.options || [];
|
|
6082
6770
|
const optionIds = options.map(option => String(option.id));
|
|
6083
6771
|
const branches = options.map((option, index) => {
|
|
@@ -6184,5 +6872,201 @@ const schemaToDataSchema = (schema, options = {}) => {
|
|
|
6184
6872
|
return root;
|
|
6185
6873
|
};
|
|
6186
6874
|
|
|
6187
|
-
|
|
6875
|
+
const getByPath = (data, path) => {
|
|
6876
|
+
if (data == null || path == null || path === '') {
|
|
6877
|
+
return data;
|
|
6878
|
+
}
|
|
6879
|
+
return String(path).split('.').reduce((acc, key) => acc == null ? acc : acc[key], data);
|
|
6880
|
+
};
|
|
6881
|
+
const resolveChoiceSelectorName = block => {
|
|
6882
|
+
var _block$discriminator;
|
|
6883
|
+
if (block.selectorName != null && String(block.selectorName).trim()) {
|
|
6884
|
+
return String(block.selectorName).trim();
|
|
6885
|
+
}
|
|
6886
|
+
if ((_block$discriminator = block.discriminator) != null && _block$discriminator.propertyName) {
|
|
6887
|
+
return String(block.discriminator.propertyName).trim();
|
|
6888
|
+
}
|
|
6889
|
+
return `__choice_${block.id}`;
|
|
6890
|
+
};
|
|
6891
|
+
const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValue(field, value, {
|
|
6892
|
+
formatMessage
|
|
6893
|
+
});
|
|
6894
|
+
const renderFieldsContent = (fields, data, formatMessage, column) => {
|
|
6895
|
+
const list = (fields || []).filter(field => field && !field.hidden && field.name).map(field => ({
|
|
6896
|
+
label: field.label || field.name,
|
|
6897
|
+
content: formatFieldValue(field, getByPath(data, field.name), formatMessage),
|
|
6898
|
+
block: field.block || undefined
|
|
6899
|
+
}));
|
|
6900
|
+
if (!list.length) {
|
|
6901
|
+
return null;
|
|
6902
|
+
}
|
|
6903
|
+
return /*#__PURE__*/jsx(Content, {
|
|
6904
|
+
col: column || 2,
|
|
6905
|
+
list: list
|
|
6906
|
+
});
|
|
6907
|
+
};
|
|
6908
|
+
const renderBlockList = (blocks, data, ctx) => (blocks || []).map(block => renderBlock(block, data, ctx)).filter(Boolean);
|
|
6909
|
+
const renderBlock = (block, data, ctx) => {
|
|
6910
|
+
const {
|
|
6911
|
+
formatMessage,
|
|
6912
|
+
isMobile,
|
|
6913
|
+
depth = 0
|
|
6914
|
+
} = ctx;
|
|
6915
|
+
if (!block || depth > MAX_BLOCK_DEPTH) {
|
|
6916
|
+
return null;
|
|
6917
|
+
}
|
|
6918
|
+
const nextCtx = _extends({}, ctx, {
|
|
6919
|
+
depth: depth + 1
|
|
6920
|
+
});
|
|
6921
|
+
const bordered = isMobile ? false : block.bordered || undefined;
|
|
6922
|
+
const partProps = {
|
|
6923
|
+
key: block.id,
|
|
6924
|
+
title: block.title || block.label || undefined,
|
|
6925
|
+
subtitle: block.subtitle || undefined,
|
|
6926
|
+
bordered
|
|
6927
|
+
};
|
|
6928
|
+
switch (block.kind) {
|
|
6929
|
+
case 'formInfo':
|
|
6930
|
+
{
|
|
6931
|
+
return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
|
|
6932
|
+
children: [renderFieldsContent(block.list, data, formatMessage, block.column), renderBlockList(block.blocks, data, nextCtx)]
|
|
6933
|
+
}));
|
|
6934
|
+
}
|
|
6935
|
+
case 'object':
|
|
6936
|
+
{
|
|
6937
|
+
const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
|
|
6938
|
+
const nestedData = name ? getByPath(data, name) || {} : data;
|
|
6939
|
+
return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
|
|
6940
|
+
children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column), renderBlockList(block.blocks, nestedData, nextCtx)]
|
|
6941
|
+
}));
|
|
6942
|
+
}
|
|
6943
|
+
case 'list':
|
|
6944
|
+
case 'tableList':
|
|
6945
|
+
{
|
|
6946
|
+
const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
|
|
6947
|
+
const items = name ? getByPath(data, name) : null;
|
|
6948
|
+
const rows = Array.isArray(items) ? items : [];
|
|
6949
|
+
return /*#__PURE__*/jsx(InfoPage.Part, _extends({}, partProps, {
|
|
6950
|
+
children: rows.length ? rows.map((item, index) => /*#__PURE__*/jsxs(InfoPage.Part, {
|
|
6951
|
+
title: formatMessage({
|
|
6952
|
+
id: 'schemaContentItemIndex'
|
|
6953
|
+
}, {
|
|
6954
|
+
index: index + 1
|
|
6955
|
+
}),
|
|
6956
|
+
bordered: false,
|
|
6957
|
+
children: [renderFieldsContent(block.list, item || {}, formatMessage, 2), block.kind === 'list' ? renderBlockList(block.itemBlocks, item || {}, nextCtx) : null]
|
|
6958
|
+
}, `${block.id}-${index}`)) : formatMessage({
|
|
6959
|
+
id: 'schemaContentEmptyValue'
|
|
6960
|
+
})
|
|
6961
|
+
}));
|
|
6962
|
+
}
|
|
6963
|
+
case 'multiField':
|
|
6964
|
+
{
|
|
6965
|
+
const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
|
|
6966
|
+
const values = name ? getByPath(data, name) : null;
|
|
6967
|
+
const itemField = {
|
|
6968
|
+
type: block.fieldType || 'Input',
|
|
6969
|
+
label: block.label,
|
|
6970
|
+
props: {}
|
|
6971
|
+
};
|
|
6972
|
+
const content = Array.isArray(values) ? values.map(item => formatFieldValue(itemField, item, formatMessage)).join('、') : formatFieldValue(itemField, values, formatMessage);
|
|
6973
|
+
return /*#__PURE__*/jsx(InfoPage.Part, _extends({}, partProps, {
|
|
6974
|
+
children: /*#__PURE__*/jsx(Content, {
|
|
6975
|
+
col: 1,
|
|
6976
|
+
list: [{
|
|
6977
|
+
label: block.label || block.name,
|
|
6978
|
+
content,
|
|
6979
|
+
block: true
|
|
6980
|
+
}]
|
|
6981
|
+
})
|
|
6982
|
+
}));
|
|
6983
|
+
}
|
|
6984
|
+
case 'steps':
|
|
6985
|
+
{
|
|
6986
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
6987
|
+
children: (block.items || []).map(step => /*#__PURE__*/jsxs(InfoPage.Part, {
|
|
6988
|
+
title: step.title || undefined,
|
|
6989
|
+
bordered: bordered,
|
|
6990
|
+
children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2), renderBlockList(step.blocks, data, nextCtx)]
|
|
6991
|
+
}, step.id))
|
|
6992
|
+
}, block.id);
|
|
6993
|
+
}
|
|
6994
|
+
case 'choice':
|
|
6995
|
+
{
|
|
6996
|
+
const selectorName = resolveChoiceSelectorName(block);
|
|
6997
|
+
const selectorValue = block.selectorInData === false ? undefined : getByPath(data, selectorName);
|
|
6998
|
+
const selectedIds = block.mode === 'multiple' ? Array.isArray(selectorValue) ? selectorValue.map(String) : [] : selectorValue != null && selectorValue !== '' ? [String(selectorValue)] : [];
|
|
6999
|
+
const options = block.options || [];
|
|
7000
|
+
const visibleOptions = selectedIds.length ? options.filter(option => selectedIds.includes(String(option.id))) : [];
|
|
7001
|
+
return /*#__PURE__*/jsx(InfoPage.Part, _extends({}, partProps, {
|
|
7002
|
+
children: visibleOptions.map(option => /*#__PURE__*/jsxs(InfoPage.Part, {
|
|
7003
|
+
title: option.title || undefined,
|
|
7004
|
+
bordered: false,
|
|
7005
|
+
children: [renderFieldsContent(option.list, data, formatMessage, block.column), renderBlockList(option.blocks, data, nextCtx)]
|
|
7006
|
+
}, option.id))
|
|
7007
|
+
}));
|
|
7008
|
+
}
|
|
7009
|
+
default:
|
|
7010
|
+
return null;
|
|
7011
|
+
}
|
|
7012
|
+
};
|
|
7013
|
+
const SchemaContentInnerView = ({
|
|
7014
|
+
schema,
|
|
7015
|
+
data,
|
|
7016
|
+
className
|
|
7017
|
+
}) => {
|
|
7018
|
+
const {
|
|
7019
|
+
formatMessage
|
|
7020
|
+
} = useIntl();
|
|
7021
|
+
const isMobile = useIsMobile();
|
|
7022
|
+
const normalized = normalizeSchema(schema);
|
|
7023
|
+
const children = renderBlockList(normalized.blocks, data || {}, {
|
|
7024
|
+
formatMessage,
|
|
7025
|
+
isMobile,
|
|
7026
|
+
depth: 0
|
|
7027
|
+
});
|
|
7028
|
+
if (!children.length) {
|
|
7029
|
+
return null;
|
|
7030
|
+
}
|
|
7031
|
+
if (className) {
|
|
7032
|
+
return /*#__PURE__*/jsx("div", {
|
|
7033
|
+
className: className,
|
|
7034
|
+
children: children
|
|
7035
|
+
});
|
|
7036
|
+
}
|
|
7037
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
7038
|
+
children: children
|
|
7039
|
+
});
|
|
7040
|
+
};
|
|
7041
|
+
const SchemaContentInner = withLocale$1(SchemaContentInnerView);
|
|
7042
|
+
const SchemaContent = withLocale$1(({
|
|
7043
|
+
schema,
|
|
7044
|
+
data,
|
|
7045
|
+
className,
|
|
7046
|
+
empty
|
|
7047
|
+
}) => {
|
|
7048
|
+
const {
|
|
7049
|
+
formatMessage
|
|
7050
|
+
} = useIntl();
|
|
7051
|
+
const normalized = normalizeSchema(schema);
|
|
7052
|
+
const emptyNode = empty !== undefined ? empty : /*#__PURE__*/jsx(Empty, {
|
|
7053
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
7054
|
+
description: formatMessage({
|
|
7055
|
+
id: 'schemaContentEmpty'
|
|
7056
|
+
})
|
|
7057
|
+
});
|
|
7058
|
+
if (data == null || !hasRenderableContent(normalized)) {
|
|
7059
|
+
return emptyNode;
|
|
7060
|
+
}
|
|
7061
|
+
return /*#__PURE__*/jsx(InfoPage, {
|
|
7062
|
+
className: [style['schema-content'], className].filter(Boolean).join(' '),
|
|
7063
|
+
children: /*#__PURE__*/jsx(SchemaContentInnerView, {
|
|
7064
|
+
schema: normalized,
|
|
7065
|
+
data: data
|
|
7066
|
+
})
|
|
7067
|
+
});
|
|
7068
|
+
});
|
|
7069
|
+
var SchemaContent$1 = SchemaContent;
|
|
7070
|
+
|
|
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 };
|
|
6188
7072
|
//# sourceMappingURL=index.modern.js.map
|