@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/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  require('@kne/form-info/dist/index.css');
2
2
  require('@kne/info-page/dist/index.css');
3
+ require('@kne/button-group/dist/index.css');
3
4
  var react = require('react');
4
5
  var antd = require('antd');
5
6
  var reactIntl = require('@kne/react-intl');
@@ -12,7 +13,9 @@ require('@kne/super-select/dist/index.css');
12
13
  require('@kne/super-select-plus/dist/index.css');
13
14
  var jsxRuntime = require('react/jsx-runtime');
14
15
  var FormInfo = require('@kne/form-info');
16
+ var buttonGroup = require('@kne/button-group');
15
17
  var InfoPage = require('@kne/info-page');
18
+ var remoteLoader = require('@kne/remote-loader');
16
19
 
17
20
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
21
 
@@ -20,7 +23,7 @@ var SelectList__default = /*#__PURE__*/_interopDefaultLegacy(SelectList);
20
23
  var FormInfo__default = /*#__PURE__*/_interopDefaultLegacy(FormInfo);
21
24
  var InfoPage__default = /*#__PURE__*/_interopDefaultLegacy(InfoPage);
22
25
 
23
- 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"};
26
+ var style = {"kne-responsive-boundary":"kne-form-creator_gh14z","kne-responsive-scroll":"kne-form-creator_Kfn6L","form-creator":"kne-form-creator_Xrjrk","editor-pane":"kne-form-creator_Skfuv","preview-pane":"kne-form-creator_v4Lsp","editor-header":"kne-form-creator_WaSS-","block-list-panel":"kne-form-creator_lx8An","form-actions-setting-btn":"kne-form-creator_NekU2","panel-toolbar":"kne-form-creator_t0WxZ","panel-toolbar-extra":"kne-form-creator_O22ZM","schema-content":"kne-form-creator_9bWOD","schema-content-file-list":"kne-form-creator_UGdXA","schema-content-file":"kne-form-creator_75EtE","schema-content-file-image":"kne-form-creator_P-be6","schema-content-file-name":"kne-form-creator_NXpTS","add-block-btn":"kne-form-creator_16Zre","add-inline-btn":"kne-form-creator_iCYdB","ant-btn-disabled":"kne-form-creator_LdGtv","block-list":"kne-form-creator_wK5eK","block-section":"kne-form-creator_15IiK","block-kind-formInfo":"kne-form-creator_D0hoK","block-kind-list":"kne-form-creator_JdPhy","block-kind-tableList":"kne-form-creator_gzd64","block-kind-multiField":"kne-form-creator_t0iOJ","block-kind-steps":"kne-form-creator_QNF9W","step-section":"kne-form-creator_22ajp","block-section-header":"kne-form-creator_wS4rL","block-header-left":"kne-form-creator_t4awC","block-title":"kne-form-creator_wSVJf","block-summary":"kne-form-creator_GzeW8","block-header-actions":"kne-form-creator_Ue-nT","block-body":"kne-form-creator_je1H0","item-blocks-section":"kne-form-creator_wq4bT","nested-block-list":"kne-form-creator_4NWH4","block-section-nested":"kne-form-creator_mUKom","add-field-dropdown":"kne-form-creator_9JS0d","add-field-dropdown-item":"kne-form-creator_Ql1z3","add-field-dropdown-item-icon":"kne-form-creator_ZHB5O","add-field-dropdown-item-desc":"kne-form-creator_dcsOS","add-field-dropdown-divider":"kne-form-creator_CUK0H","add-field-dropdown-label":"kne-form-creator_bPJ-2","section-toolbar":"kne-form-creator_LUO8S","section-toolbar-label":"kne-form-creator_7KQ79","field-list":"kne-form-creator_-B7WZ","step-list":"kne-form-creator_kc1pH","step-section-header":"kne-form-creator_wkhEX","step-section-title":"kne-form-creator_NBinE","step-section-actions":"kne-form-creator_es-FC","step-index":"kne-form-creator_CCKZZ","field-row":"kne-form-creator_XMkdt","field-row-index":"kne-form-creator_a-cDo","field-row-main":"kne-form-creator_ftlwp","inline-empty":"kne-form-creator_yP-RF","action-group":"kne-form-creator_773yo","hover-reveal":"kne-form-creator_S234h","hover-reveal-active":"kne-form-creator_AE-6r","action-btn":"kne-form-creator_mLgqh","add-block-dropdown":"kne-form-creator_vmS-e","add-block-option":"kne-form-creator_gjg2Y","add-block-option-icon":"kne-form-creator_qh1hh","add-block-option-text":"kne-form-creator_G8iJO","add-block-option-title":"kne-form-creator_ETSvm","add-block-option-desc":"kne-form-creator_O0C3l","field-empty":"kne-form-creator_Nmpfl","field-label-tips-icon":"kne-form-creator_0VVaO","preview-header":"kne-form-creator_c4BT0","preview-title":"kne-form-creator_fPkK4","preview-body":"kne-form-creator_6JntQ","schema-form":"kne-form-creator_MxCWP","schema-body":"kne-form-creator_q9ydz","schema-actions":"kne-form-creator_Y4eEH","schema-actions-inner":"kne-form-creator_FT9Zf","choice-block":"kne-form-creator_RllJe","choice-selector":"kne-form-creator_5A1eM","choice-panels":"kne-form-creator_IO0MY","choice-panels-empty":"kne-form-creator_T0nND","choice-option-panel":"kne-form-creator_FQixN","choice-option-panel-title":"kne-form-creator_ofRo2","choice-option-summary":"kne-form-creator_pksH8","field-editor-form":"kne-form-creator_PGPHL","form-actions-editor":"kne-form-creator_fchMy","form-actions-switch-field":"kne-form-creator_6JE9x","form-actions-layout-panel":"kne-form-creator_rtm9D","form-actions-align-group":"kne-form-creator_51ZsV","form-actions-layout-title":"kne-form-creator_hFeiC","form-actions-gap-slider":"kne-form-creator_Gq0bk","editor-section":"kne-form-creator_jJy85","section-divider":"kne-form-creator_zA7L-","rule-editor":"kne-form-creator_bAlGU","options-editor":"kne-form-creator_AK4yO","super-select-props":"kne-form-creator_Iawhh","field-props-editor":"kne-form-creator_Gabf2","columns-editor":"kne-form-creator_DQW1N","prop-row":"kne-form-creator_7K54P","prop-label":"kne-form-creator_HAAyH","options-item":"kne-form-creator_dnOd2","table-row-card":"kne-form-creator_cwCYp","tree-options-editor":"kne-form-creator_s3nHO","tree-options-list":"kne-form-creator_Djs-E","tree-option-node":"kne-form-creator_XAcut","tree-option-row":"kne-form-creator_4K4Rj","tree-option-fields":"kne-form-creator_-4cjc","tree-option-actions":"kne-form-creator_IjCNI","tree-option-children":"kne-form-creator_pVPGJ","tree-add-sibling":"kne-form-creator_bl46P","rule-checkbox-group":"kne-form-creator_tDgVP","rule-len-row":"kne-form-creator_ATsae","rule-len-input":"kne-form-creator_jY4Ld","rule-len-sep":"kne-form-creator_jBDC8","options-list":"kne-form-creator_GUBNS","options-row":"kne-form-creator_uohD0","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","is-mobile":"kne-form-creator_LtgJz"};
24
27
 
25
28
  const locale$1 = {
26
29
  addField: '添加填写项',
@@ -214,7 +217,14 @@ const locale$1 = {
214
217
  formSettingsTitle: '表单设置',
215
218
  formTitlePlaceholder: '表单标题(可选)',
216
219
  formSubtitlePlaceholder: '表单副标题(可选)',
217
- formColumnPlaceholder: '每行显示列数'
220
+ formColumnPlaceholder: '每行显示列数',
221
+ schemaContentEmpty: '暂无数据',
222
+ schemaContentEmptyValue: '-',
223
+ schemaContentYes: '是',
224
+ schemaContentNo: '否',
225
+ schemaContentItemIndex: '第 {index} 项',
226
+ schemaContentUntilToday: '至今',
227
+ schemaContentPasswordMasked: '••••••'
218
228
  };
219
229
  var zhCN = locale$1;
220
230
 
@@ -410,7 +420,14 @@ const locale = {
410
420
  formSettingsTitle: 'Form Settings',
411
421
  formTitlePlaceholder: 'Form title (optional)',
412
422
  formSubtitlePlaceholder: 'Form subtitle (optional)',
413
- formColumnPlaceholder: 'Columns per row'
423
+ formColumnPlaceholder: 'Columns per row',
424
+ schemaContentEmpty: 'No data',
425
+ schemaContentEmptyValue: '-',
426
+ schemaContentYes: 'Yes',
427
+ schemaContentNo: 'No',
428
+ schemaContentItemIndex: 'Item {index}',
429
+ schemaContentUntilToday: 'Present',
430
+ schemaContentPasswordMasked: '••••••'
414
431
  };
415
432
  var enUS = locale;
416
433
 
@@ -1345,6 +1362,84 @@ const mapOptionItem = item => {
1345
1362
  }
1346
1363
  return next;
1347
1364
  };
1365
+
1366
+ /**
1367
+ * 搭建器选项是 { label, value, children };SelectCascader 默认 valueKey='id'、示例用 id/name。
1368
+ * 补齐两边的 key,避免 mapping 全部落到 undefined 导致下拉空白。
1369
+ */
1370
+ const alignOptionKeys = (options = [], {
1371
+ valueKey = 'value',
1372
+ labelKey = 'label'
1373
+ } = {}) => {
1374
+ if (!Array.isArray(options)) {
1375
+ return options;
1376
+ }
1377
+ return options.map(item => {
1378
+ if (!item || typeof item !== 'object') {
1379
+ return item;
1380
+ }
1381
+ const rawValue = item[valueKey] ?? item.value ?? item.id ?? item.code;
1382
+ const rawLabel = item[labelKey] ?? item.label ?? item.name;
1383
+ const next = {
1384
+ ...item
1385
+ };
1386
+ if (rawValue != null && next[valueKey] == null) {
1387
+ next[valueKey] = rawValue;
1388
+ }
1389
+ if (rawLabel != null && (next[labelKey] == null || next[labelKey] === '')) {
1390
+ next[labelKey] = rawLabel;
1391
+ }
1392
+ if (next.id == null && rawValue != null) {
1393
+ next.id = rawValue;
1394
+ }
1395
+ if ((next.name == null || next.name === '') && rawLabel != null) {
1396
+ next.name = rawLabel;
1397
+ }
1398
+ if (Array.isArray(next.children) && next.children.length) {
1399
+ next.children = alignOptionKeys(next.children, {
1400
+ valueKey,
1401
+ labelKey
1402
+ });
1403
+ }
1404
+ return next;
1405
+ });
1406
+ };
1407
+
1408
+ /**
1409
+ * SelectTree 按扁平 parentId 组树,会覆盖节点上已有的 children。
1410
+ * 搭建器存的是嵌套 children,交给 SelectTree 前先拍平。
1411
+ */
1412
+ const flattenTreeOptions = (options = [], {
1413
+ valueKey = 'value',
1414
+ parentKey = 'parentId',
1415
+ childrenKey = 'children',
1416
+ parentId
1417
+ } = {}) => {
1418
+ const result = [];
1419
+ (Array.isArray(options) ? options : []).forEach(item => {
1420
+ if (!item || typeof item !== 'object') {
1421
+ return;
1422
+ }
1423
+ const nested = item[childrenKey];
1424
+ const node = {
1425
+ ...item
1426
+ };
1427
+ delete node[childrenKey];
1428
+ if (parentId !== undefined) {
1429
+ node[parentKey] = parentId;
1430
+ }
1431
+ result.push(node);
1432
+ if (Array.isArray(nested) && nested.length) {
1433
+ result.push(...flattenTreeOptions(nested, {
1434
+ valueKey,
1435
+ parentKey,
1436
+ childrenKey,
1437
+ parentId: node[valueKey]
1438
+ }));
1439
+ }
1440
+ });
1441
+ return result;
1442
+ };
1348
1443
  const createApiFromOptions = (options = []) => ({
1349
1444
  loader: () => ({
1350
1445
  pageData: options.map(mapOptionItem)
@@ -1358,6 +1453,7 @@ const hasNestedOptions = options => Array.isArray(options) && options.some(item
1358
1453
  const createField = function (Component, _temp) {
1359
1454
  let {
1360
1455
  preferOptions = false,
1456
+ flattenTree = false,
1361
1457
  placeholderPrefix = '请选择'
1362
1458
  } = _temp === void 0 ? {} : _temp;
1363
1459
  const Field = props => {
@@ -1367,14 +1463,28 @@ const createField = function (Component, _temp) {
1367
1463
  placeholder,
1368
1464
  ...rest
1369
1465
  } = props;
1370
- const useOptionsDirectly = preferOptions || hasNestedOptions(options);
1371
- const mergedApi = api || (!useOptionsDirectly && Array.isArray(options) && options.length ? createApiFromOptions(options) : undefined);
1466
+ const valueKey = rest.valueKey || 'value';
1467
+ const labelKey = rest.labelKey || 'label';
1468
+ const parentKey = rest.parentKey || 'parentId';
1469
+ const flattened = flattenTree && Array.isArray(options) ? flattenTreeOptions(options, {
1470
+ valueKey,
1471
+ parentKey
1472
+ }) : options;
1473
+ const resolvedOptions = Array.isArray(flattened) ? alignOptionKeys(flattened, {
1474
+ valueKey,
1475
+ labelKey
1476
+ }) : flattened;
1477
+ const useOptionsDirectly = preferOptions || hasNestedOptions(resolvedOptions);
1478
+ const mergedApi = api || (!useOptionsDirectly && Array.isArray(resolvedOptions) && resolvedOptions.length ? createApiFromOptions(resolvedOptions) : undefined);
1372
1479
  const resolvedPlaceholder = placeholder != null && String(placeholder).trim() ? placeholder : `${placeholderPrefix}${props.label || ''}`;
1373
1480
  const render = useOnChange$1(Object.assign({}, {
1374
1481
  isPopup: true,
1375
1482
  placeholder: resolvedPlaceholder
1376
- }, rest, useOptionsDirectly && Array.isArray(options) ? {
1377
- options
1483
+ }, rest, {
1484
+ valueKey,
1485
+ labelKey
1486
+ }, useOptionsDirectly && Array.isArray(resolvedOptions) ? {
1487
+ options: resolvedOptions
1378
1488
  } : {}, mergedApi ? {
1379
1489
  api: mergedApi
1380
1490
  } : {}));
@@ -1388,7 +1498,8 @@ const SuperSelectTableList = createField(SelectList.SelectTableList, {
1388
1498
  preferOptions: true
1389
1499
  });
1390
1500
  const SuperSelectTree = createField(SelectList.SelectTree, {
1391
- preferOptions: true
1501
+ preferOptions: true,
1502
+ flattenTree: true
1392
1503
  });
1393
1504
  const SuperSelectCascader = createField(SelectList.SelectCascader, {
1394
1505
  preferOptions: true
@@ -1507,19 +1618,47 @@ const stringWithEnumSchema = field => {
1507
1618
  }
1508
1619
  return schema;
1509
1620
  };
1621
+ const optionValueSchema = {
1622
+ type: 'object',
1623
+ display: 'option'
1624
+ };
1510
1625
  const superSelectValueSchema = field => {
1511
1626
  if (field?.props?.single) {
1512
1627
  return {
1513
- type: 'object'
1628
+ ...optionValueSchema
1514
1629
  };
1515
1630
  }
1516
1631
  return {
1517
1632
  type: 'array',
1518
1633
  items: {
1519
- type: 'object'
1634
+ ...optionValueSchema
1520
1635
  }
1521
1636
  };
1522
1637
  };
1638
+ const PICKER_TO_FORMAT = {
1639
+ date: 'date',
1640
+ week: 'week',
1641
+ month: 'month',
1642
+ quarter: 'quarter',
1643
+ year: 'year'
1644
+ };
1645
+ const datePickerValueSchema = field => {
1646
+ const picker = field?.props?.picker || 'date';
1647
+ const format = field?.props?.showTime ? 'date-time' : PICKER_TO_FORMAT[picker] || 'date';
1648
+ const item = {
1649
+ type: 'string',
1650
+ format
1651
+ };
1652
+ if (field?.props?.range) {
1653
+ return {
1654
+ type: 'array',
1655
+ items: item,
1656
+ minItems: 2,
1657
+ maxItems: 2
1658
+ };
1659
+ }
1660
+ return item;
1661
+ };
1523
1662
  defineField('Input', {
1524
1663
  label: '单行文本',
1525
1664
  group: '基础字段',
@@ -1741,16 +1880,7 @@ defineField('DatePicker', {
1741
1880
  },
1742
1881
  hasFieldProps: true,
1743
1882
  resolveComponent: props => props?.range ? reactFormAntd.DatePicker.RangePicker || reactFormAntd.DatePicker : reactFormAntd.DatePicker,
1744
- valueSchema: field => field?.props?.range ? {
1745
- type: 'array',
1746
- items: {
1747
- type: 'string'
1748
- },
1749
- minItems: 2,
1750
- maxItems: 2
1751
- } : {
1752
- type: 'string'
1753
- }
1883
+ valueSchema: datePickerValueSchema
1754
1884
  });
1755
1885
 
1756
1886
  /**
@@ -1766,6 +1896,8 @@ defineField('DatePicker', {
1766
1896
  * preset({ type, definition }) 的 fields 项还可传:
1767
1897
  * - groupName?: string 自定义类型下拉分组名;不传则归入「扩展字段」
1768
1898
  * - valueSchema?: object | (field) => object 提交值的 JSON Schema 片段;缺省回退 { type: 'string' }
1899
+ * 可含 format(date/month/week/time/date-time/password/color/json)与 display(option/phone/file/typed-date-range/date-to-today/html/money),供 SchemaContent 预览
1900
+ * - formatDisplayValue?: (value, field, ctx) => string 覆盖 valueSchema 默认预览
1769
1901
  */
1770
1902
  const registerField = (type, definition) => {
1771
1903
  const propsSchema = Array.isArray(definition?.propsSchema) ? definition.propsSchema : undefined;
@@ -2448,7 +2580,8 @@ const BlockListPanel = _ref3 => {
2448
2580
  onEditChoiceOption,
2449
2581
  onDeleteChoiceOption,
2450
2582
  onMoveChoiceOption,
2451
- onOpenFormActions
2583
+ onOpenFormActions,
2584
+ extraToolbar
2452
2585
  } = _ref3;
2453
2586
  const {
2454
2587
  formatMessage
@@ -3037,7 +3170,10 @@ const BlockListPanel = _ref3 => {
3037
3170
  id: 'formActionsSection'
3038
3171
  }),
3039
3172
  onClick: onOpenFormActions
3040
- })]
3173
+ }), extraToolbar ? /*#__PURE__*/jsxRuntime.jsx("div", {
3174
+ className: style['panel-toolbar-extra'],
3175
+ children: extraToolbar
3176
+ }) : null]
3041
3177
  }), !blocks.length ? /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
3042
3178
  className: style['field-empty'],
3043
3179
  image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
@@ -4878,7 +5014,7 @@ const FormActionsEditor = _ref => {
4878
5014
  };
4879
5015
  var FormActionsEditor$1 = FormActionsEditor;
4880
5016
 
4881
- const getByPath = (obj, path) => {
5017
+ const getByPath$1 = (obj, path) => {
4882
5018
  if (obj == null || path == null || path === '') {
4883
5019
  return undefined;
4884
5020
  }
@@ -4921,7 +5057,7 @@ const clearUnselectedOptionFields = (openApi, formData, keepIds, allOptions) =>
4921
5057
  if (!field?.name) {
4922
5058
  return;
4923
5059
  }
4924
- const current = getByPath(formData, field.name);
5060
+ const current = getByPath$1(formData, field.name);
4925
5061
  if (current !== undefined) {
4926
5062
  entries.push({
4927
5063
  name: field.name,
@@ -4930,7 +5066,7 @@ const clearUnselectedOptionFields = (openApi, formData, keepIds, allOptions) =>
4930
5066
  }
4931
5067
  });
4932
5068
  collectBlockFieldNames(option.blocks || []).forEach(name => {
4933
- const current = getByPath(formData, name);
5069
+ const current = getByPath$1(formData, name);
4934
5070
  if (current !== undefined) {
4935
5071
  entries.push({
4936
5072
  name,
@@ -5013,7 +5149,7 @@ const ChoiceBlock = ({
5013
5149
  maxLength
5014
5150
  } = mode === 'multiple' ? resolveSelectLimits(block) : {};
5015
5151
  const firstOptionId = options[0] != null ? String(options[0].id) : undefined;
5016
- const rawValue = getByPath(formData || {}, selectorName);
5152
+ const rawValue = getByPath$1(formData || {}, selectorName);
5017
5153
  // 仅随 selector 值变化;勿依赖整个 formData,否则清空未选支字段会触发 options 重算 → CheckboxGroup 死循环
5018
5154
  const selectorValueKey = mode === 'multiple' ? Array.isArray(rawValue) ? rawValue.map(String).join('\0') : String(rawValue ?? '') : String(rawValue ?? '');
5019
5155
 
@@ -5179,6 +5315,7 @@ const renderFieldElements = function (fields, preview, _temp) {
5179
5315
  }
5180
5316
  const definition = getFieldDefinition(field.type);
5181
5317
  const props = {
5318
+ ...(definition?.defaultProps || {}),
5182
5319
  ...(field.props || {})
5183
5320
  };
5184
5321
  if (definition?.optionsAllowDescription && props.options?.length && !props.api && !definition.optionsAllowChildren) {
@@ -5433,6 +5570,7 @@ const renderSchemaInner = function (schema, _temp2) {
5433
5570
  let {
5434
5571
  preview = false,
5435
5572
  className,
5573
+ bodyClassName,
5436
5574
  isMobile = false,
5437
5575
  formatMessage,
5438
5576
  children,
@@ -5447,16 +5585,20 @@ const renderSchemaInner = function (schema, _temp2) {
5447
5585
  if (!contentChildren.length && !children && !actionNode) {
5448
5586
  return null;
5449
5587
  }
5450
- const body = /*#__PURE__*/react.createElement(react.Fragment, null, ...contentChildren, children, actionNode || null);
5588
+ const body = /*#__PURE__*/react.createElement('div', {
5589
+ className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
5590
+ }, ...contentChildren, children);
5591
+ const content = /*#__PURE__*/react.createElement(react.Fragment, null, body, actionNode || null);
5451
5592
  return className ? /*#__PURE__*/react.createElement('div', {
5452
5593
  className
5453
- }, body) : body;
5594
+ }, content) : content;
5454
5595
  };
5455
5596
  const renderSchemaContent = function (schema, _temp3) {
5456
5597
  let {
5457
5598
  preview = false,
5458
5599
  formProps = {},
5459
5600
  className,
5601
+ bodyClassName,
5460
5602
  isMobile = false,
5461
5603
  formatMessage,
5462
5604
  children,
@@ -5476,11 +5618,14 @@ const renderSchemaContent = function (schema, _temp3) {
5476
5618
  ...formProps,
5477
5619
  className: formClassName
5478
5620
  }, /*#__PURE__*/react.createElement('div', {
5479
- className: style['schema-body']
5621
+ className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
5480
5622
  }, ...contentChildren, children), actionNode || null);
5481
5623
  };
5482
5624
  var renderSchemaContent$1 = renderSchemaContent;
5483
5625
 
5626
+ const joinClass = function () {
5627
+ return [].slice.call(arguments).filter(Boolean).join(' ');
5628
+ };
5484
5629
  const resolveActionNode = _ref => {
5485
5630
  let {
5486
5631
  schema,
@@ -5497,7 +5642,10 @@ const resolveActionNode = _ref => {
5497
5642
  showReset,
5498
5643
  showCancel,
5499
5644
  actionsAlign,
5500
- actionsGap
5645
+ actionsGap,
5646
+ footerClassName,
5647
+ buttonFooter = false,
5648
+ buttonFooterProps
5501
5649
  } = _ref;
5502
5650
  if (showActions === false || actions === false || actions === null) {
5503
5651
  return null;
@@ -5536,20 +5684,27 @@ const resolveActionNode = _ref => {
5536
5684
  gap: resolvedGap ?? 16,
5537
5685
  wrap: 'wrap'
5538
5686
  };
5687
+ let actionsEl = null;
5539
5688
  if (actions !== undefined) {
5540
- return /*#__PURE__*/react.createElement('div', {
5541
- className: style['schema-actions']
5689
+ actionsEl = /*#__PURE__*/react.createElement('div', {
5690
+ className: joinClass(style['schema-actions'], footerClassName)
5542
5691
  }, /*#__PURE__*/react.createElement(antd.Flex, flexProps, actions));
5543
- }
5544
- if (!resolvedShowSubmit && !resolvedShowReset && !resolvedShowCancel) {
5692
+ } else if (resolvedShowSubmit || resolvedShowReset || resolvedShowCancel) {
5693
+ actionsEl = /*#__PURE__*/react.createElement('div', {
5694
+ className: joinClass(style['schema-actions'], footerClassName)
5695
+ }, /*#__PURE__*/react.createElement(antd.Flex, flexProps, resolvedShowSubmit ? /*#__PURE__*/react.createElement(reactFormAntd.SubmitButton, {
5696
+ type: 'primary',
5697
+ ...resolvedSubmitButtonProps
5698
+ }, resolvedSubmitText) : null, resolvedShowReset ? /*#__PURE__*/react.createElement(reactFormAntd.ResetButton, resolvedResetButtonProps, resolvedResetText) : null, resolvedShowCancel ? /*#__PURE__*/react.createElement(reactFormAntd.CancelButton, resolvedCancelButtonProps, resolvedCancelText) : null));
5699
+ }
5700
+ if (!actionsEl) {
5545
5701
  return null;
5546
5702
  }
5547
- return /*#__PURE__*/react.createElement('div', {
5548
- className: style['schema-actions']
5549
- }, /*#__PURE__*/react.createElement(antd.Flex, flexProps, resolvedShowSubmit ? /*#__PURE__*/react.createElement(reactFormAntd.SubmitButton, {
5550
- type: 'primary',
5551
- ...resolvedSubmitButtonProps
5552
- }, resolvedSubmitText) : null, resolvedShowReset ? /*#__PURE__*/react.createElement(reactFormAntd.ResetButton, resolvedResetButtonProps, resolvedResetText) : null, resolvedShowCancel ? /*#__PURE__*/react.createElement(reactFormAntd.CancelButton, resolvedCancelButtonProps, resolvedCancelText) : null));
5703
+ if (!buttonFooter) {
5704
+ return actionsEl;
5705
+ }
5706
+ const footerProps = buttonFooterProps || {};
5707
+ return /*#__PURE__*/react.createElement(buttonGroup.ButtonFooter, footerProps, actionsEl);
5553
5708
  };
5554
5709
  const SchemaRendererInner = withLocale$1(props => {
5555
5710
  const {
@@ -5569,7 +5724,11 @@ const SchemaRendererInner = withLocale$1(props => {
5569
5724
  showReset,
5570
5725
  showCancel,
5571
5726
  actionsAlign,
5572
- actionsGap
5727
+ actionsGap,
5728
+ bodyClassName,
5729
+ footerClassName,
5730
+ buttonFooter = false,
5731
+ buttonFooterProps
5573
5732
  } = props;
5574
5733
  const {
5575
5734
  formatMessage
@@ -5594,11 +5753,15 @@ const SchemaRendererInner = withLocale$1(props => {
5594
5753
  showReset,
5595
5754
  showCancel,
5596
5755
  actionsAlign,
5597
- actionsGap
5756
+ actionsGap,
5757
+ footerClassName,
5758
+ buttonFooter,
5759
+ buttonFooterProps
5598
5760
  });
5599
5761
  return renderSchemaInner(normalized, {
5600
5762
  preview,
5601
5763
  className,
5764
+ bodyClassName,
5602
5765
  isMobile,
5603
5766
  formatMessage,
5604
5767
  children,
@@ -5624,7 +5787,11 @@ const SchemaRenderer = withLocale$1(props => {
5624
5787
  showReset,
5625
5788
  showCancel,
5626
5789
  actionsAlign,
5627
- actionsGap
5790
+ actionsGap,
5791
+ bodyClassName,
5792
+ footerClassName,
5793
+ buttonFooter = false,
5794
+ buttonFooterProps
5628
5795
  } = props;
5629
5796
  const {
5630
5797
  formatMessage
@@ -5649,12 +5816,16 @@ const SchemaRenderer = withLocale$1(props => {
5649
5816
  showReset,
5650
5817
  showCancel,
5651
5818
  actionsAlign,
5652
- actionsGap
5819
+ actionsGap,
5820
+ footerClassName,
5821
+ buttonFooter,
5822
+ buttonFooterProps
5653
5823
  });
5654
5824
  return renderSchemaContent$1(normalized, {
5655
5825
  preview,
5656
5826
  formProps,
5657
5827
  className,
5828
+ bodyClassName,
5658
5829
  isMobile,
5659
5830
  formatMessage,
5660
5831
  children,
@@ -5671,7 +5842,8 @@ const FormCreator = withLocale$1(_ref => {
5671
5842
  showPreview = true,
5672
5843
  className,
5673
5844
  formProps,
5674
- renderModal
5845
+ renderModal,
5846
+ extraToolbar
5675
5847
  } = _ref;
5676
5848
  const {
5677
5849
  formatMessage
@@ -5988,6 +6160,9 @@ const FormCreator = withLocale$1(_ref => {
5988
6160
  stepId: fieldContext.stepId,
5989
6161
  optionId: fieldContext.optionId
5990
6162
  }) : [];
6163
+ const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
6164
+ schema
6165
+ }) : extraToolbar;
5991
6166
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
5992
6167
  className: [style['form-creator'], responsiveUtils.RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
5993
6168
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
@@ -6010,7 +6185,8 @@ const FormCreator = withLocale$1(_ref => {
6010
6185
  onEditChoiceOption: handleEditChoiceOption,
6011
6186
  onDeleteChoiceOption: handleDeleteChoiceOption,
6012
6187
  onMoveChoiceOption: handleMoveChoiceOption,
6013
- onOpenFormActions: () => setFormActionsOpen(true)
6188
+ onOpenFormActions: () => setFormActionsOpen(true),
6189
+ extraToolbar: toolbarExtra
6014
6190
  })
6015
6191
  }), showPreview ? /*#__PURE__*/jsxRuntime.jsx("div", {
6016
6192
  className: style['preview-pane'],
@@ -6079,6 +6255,543 @@ const FormCreator = withLocale$1(_ref => {
6079
6255
  });
6080
6256
  var FormCreator$1 = FormCreator;
6081
6257
 
6258
+ const IMAGE_EXT = /\.(png|jpe?g|gif|webp|bmp|svg|avif)(?:[?#].*)?$/i;
6259
+ const toFileList = value => {
6260
+ if (value == null || value === '') {
6261
+ return [];
6262
+ }
6263
+ return Array.isArray(value) ? value : [value];
6264
+ };
6265
+ const isHttpLike = value => typeof value === 'string' && /^(https?:|blob:|data:)/i.test(value);
6266
+ const pickFilePreviewProps = file => {
6267
+ if (file == null || file === '') {
6268
+ return null;
6269
+ }
6270
+ if (typeof file === 'string') {
6271
+ const filename = file.split('/').pop() || file;
6272
+ if (isHttpLike(file)) {
6273
+ return {
6274
+ src: file,
6275
+ filename,
6276
+ originName: filename
6277
+ };
6278
+ }
6279
+ return {
6280
+ filename,
6281
+ originName: filename
6282
+ };
6283
+ }
6284
+ if (typeof file !== 'object') {
6285
+ return null;
6286
+ }
6287
+ const filename = file.filename || file.name || file.originName || file.originFileObj?.name;
6288
+ const src = file.src || file.url || file.path || file.thumbUrl;
6289
+ const id = file.id || file.uuid || file.fileId;
6290
+ if (!src && !id && !filename) {
6291
+ return null;
6292
+ }
6293
+ return {
6294
+ ...(src ? {
6295
+ src
6296
+ } : {}),
6297
+ ...(id ? {
6298
+ id
6299
+ } : {}),
6300
+ filename,
6301
+ originName: file.originName || filename,
6302
+ mimetype: file.mimetype || file.type || file.originFileObj?.type
6303
+ };
6304
+ };
6305
+ const isImageFile = (item, field) => {
6306
+ const type = field?.type;
6307
+ if (type === 'Avatar' || type === 'Signature') {
6308
+ return true;
6309
+ }
6310
+ const mime = item?.mimetype;
6311
+ if (typeof mime === 'string' && mime.startsWith('image/')) {
6312
+ return true;
6313
+ }
6314
+ return IMAGE_EXT.test(String(item?.filename || item?.originName || item?.src || ''));
6315
+ };
6316
+ const FileFieldPreview = remoteLoader.createWithRemoteLoader({
6317
+ modules: ['components-core:File@FileLink', 'components-core:Image']
6318
+ })(_ref => {
6319
+ let {
6320
+ remoteModules,
6321
+ value,
6322
+ field
6323
+ } = _ref;
6324
+ const [FileLink, Image] = remoteModules;
6325
+ const files = toFileList(value).map(pickFilePreviewProps).filter(Boolean);
6326
+ if (!files.length) {
6327
+ return null;
6328
+ }
6329
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Flex, {
6330
+ vertical: true,
6331
+ gap: 8,
6332
+ className: style['schema-content-file-list'],
6333
+ children: files.map((item, index) => {
6334
+ const key = item.id || item.src || item.filename || String(index);
6335
+ const filename = item.filename || item.originName || '';
6336
+ const canPreview = !!(item.id || item.src);
6337
+ const asImage = isImageFile(item, field);
6338
+ if (!canPreview) {
6339
+ return /*#__PURE__*/jsxRuntime.jsx("span", {
6340
+ className: style['schema-content-file-name'],
6341
+ children: filename
6342
+ }, key);
6343
+ }
6344
+ const linkProps = {
6345
+ id: item.id,
6346
+ src: item.src,
6347
+ url: item.src,
6348
+ filename,
6349
+ originName: item.originName || filename
6350
+ };
6351
+ if (asImage) {
6352
+ const preview = field?.type === 'Avatar' ? /*#__PURE__*/jsxRuntime.jsx(Image.Avatar, {
6353
+ id: item.id,
6354
+ src: item.src,
6355
+ size: 64,
6356
+ shape: "square",
6357
+ alt: filename
6358
+ }) : /*#__PURE__*/jsxRuntime.jsx(Image, {
6359
+ id: item.id,
6360
+ src: item.src,
6361
+ alt: filename,
6362
+ className: style['schema-content-file-image']
6363
+ });
6364
+ return /*#__PURE__*/jsxRuntime.jsx(FileLink, {
6365
+ className: style['schema-content-file'],
6366
+ icon: null,
6367
+ ...linkProps,
6368
+ children: preview
6369
+ }, key);
6370
+ }
6371
+ return /*#__PURE__*/jsxRuntime.jsx(FileLink, {
6372
+ className: style['schema-content-file'],
6373
+ ...linkProps,
6374
+ children: filename
6375
+ }, key);
6376
+ })
6377
+ });
6378
+ });
6379
+ var FileFieldPreview$1 = FileFieldPreview;
6380
+
6381
+ const TEMPORAL_PATTERN = {
6382
+ date: 'YYYY-MM-DD',
6383
+ month: 'YYYY-MM',
6384
+ time: 'HH:mm:ss',
6385
+ 'date-time': 'YYYY-MM-DD HH:mm:ss',
6386
+ year: 'YYYY'
6387
+ };
6388
+ const TYPE_TO_TEMPORAL = {
6389
+ date: 'date',
6390
+ month: 'month',
6391
+ week: 'week',
6392
+ time: 'time',
6393
+ year: 'year',
6394
+ quarter: 'quarter',
6395
+ datetime: 'date-time',
6396
+ 'date-time': 'date-time'
6397
+ };
6398
+ const pad = n => String(n).padStart(2, '0');
6399
+ const isEmptyValue = value => {
6400
+ if (value == null || value === '') {
6401
+ return true;
6402
+ }
6403
+ if (Array.isArray(value) && value.length === 0) {
6404
+ return true;
6405
+ }
6406
+ return false;
6407
+ };
6408
+ const toDate = value => {
6409
+ if (value == null || value === '') {
6410
+ return null;
6411
+ }
6412
+ if (value instanceof Date) {
6413
+ return Number.isNaN(value.getTime()) ? null : value;
6414
+ }
6415
+ if (typeof value.toDate === 'function') {
6416
+ const next = value.toDate();
6417
+ return next instanceof Date && !Number.isNaN(next.getTime()) ? next : null;
6418
+ }
6419
+ if (typeof value.format === 'function' && typeof value.valueOf === 'function') {
6420
+ const next = new Date(value.valueOf());
6421
+ return Number.isNaN(next.getTime()) ? null : next;
6422
+ }
6423
+ if (typeof value === 'string' || typeof value === 'number') {
6424
+ const next = new Date(value);
6425
+ return Number.isNaN(next.getTime()) ? null : next;
6426
+ }
6427
+ return null;
6428
+ };
6429
+ const isoWeek = date => {
6430
+ const tmp = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6431
+ const day = tmp.getUTCDay() || 7;
6432
+ tmp.setUTCDate(tmp.getUTCDate() + 4 - day);
6433
+ const yearStart = new Date(Date.UTC(tmp.getUTCFullYear(), 0, 1));
6434
+ const week = Math.ceil(((tmp - yearStart) / 86400000 + 1) / 7);
6435
+ return {
6436
+ year: tmp.getUTCFullYear(),
6437
+ week
6438
+ };
6439
+ };
6440
+ const applyPattern = (date, pattern) => {
6441
+ const year = date.getFullYear();
6442
+ const month = date.getMonth() + 1;
6443
+ const quarter = Math.ceil(month / 3);
6444
+ 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));
6445
+ };
6446
+ const formatTemporal = (value, formatKey, patternOverride) => {
6447
+ if (Array.isArray(value)) {
6448
+ return value.map(item => formatTemporal(item, formatKey, patternOverride)).filter(item => item !== '').join(' ~ ');
6449
+ }
6450
+ const date = toDate(value);
6451
+ if (!date) {
6452
+ return value == null || value === '' ? '' : String(value);
6453
+ }
6454
+ if (formatKey === 'week') {
6455
+ const {
6456
+ year,
6457
+ week
6458
+ } = isoWeek(date);
6459
+ return `${year}-W${pad(week)}`;
6460
+ }
6461
+ if (formatKey === 'quarter') {
6462
+ return `${date.getFullYear()}-Q${Math.ceil((date.getMonth() + 1) / 3)}`;
6463
+ }
6464
+ const pattern = patternOverride || TEMPORAL_PATTERN[formatKey] || TEMPORAL_PATTERN.date;
6465
+ if (value && typeof value.format === 'function' && patternOverride) {
6466
+ try {
6467
+ return value.format(patternOverride);
6468
+ } catch {
6469
+ // fall through to Date formatting
6470
+ }
6471
+ }
6472
+ return applyPattern(date, pattern);
6473
+ };
6474
+ const isTemporalKey = key => !!(key && (TEMPORAL_PATTERN[key] || key === 'week' || key === 'quarter'));
6475
+ const pickObjectLabel = function (item, labelKey, valueKey) {
6476
+ if (labelKey === void 0) {
6477
+ labelKey = 'label';
6478
+ }
6479
+ if (valueKey === void 0) {
6480
+ valueKey = 'value';
6481
+ }
6482
+ if (item == null) {
6483
+ return '';
6484
+ }
6485
+ if (typeof item !== 'object') {
6486
+ return item;
6487
+ }
6488
+ const label = item[labelKey] ?? item.label ?? item.name;
6489
+ if (label != null && typeof label !== 'object' && label !== '') {
6490
+ return label;
6491
+ }
6492
+ const raw = item[valueKey] ?? item.value ?? item.id ?? item.code;
6493
+ if (raw != null && typeof raw !== 'object') {
6494
+ return raw;
6495
+ }
6496
+ return '';
6497
+ };
6498
+ const mapOptionLabel = function (value, options, labelKey, valueKey) {
6499
+ if (labelKey === void 0) {
6500
+ labelKey = 'label';
6501
+ }
6502
+ if (valueKey === void 0) {
6503
+ valueKey = 'value';
6504
+ }
6505
+ if (value && typeof value === 'object') {
6506
+ return pickObjectLabel(value, labelKey, valueKey);
6507
+ }
6508
+ if (!Array.isArray(options) || !options.length) {
6509
+ return value == null ? '' : value;
6510
+ }
6511
+ const match = options.find(item => item && (item[valueKey] === value || item.value === value));
6512
+ return match?.[labelKey] ?? match?.label ?? value;
6513
+ };
6514
+ const formatOption = (value, field) => {
6515
+ const props = field?.props || {};
6516
+ const labelKey = props.labelKey || 'label';
6517
+ const valueKey = props.valueKey || 'value';
6518
+ const pick = item => {
6519
+ if (item && typeof item === 'object') {
6520
+ return pickObjectLabel(item, labelKey, valueKey);
6521
+ }
6522
+ return mapOptionLabel(item, props.options, labelKey, valueKey);
6523
+ };
6524
+ if (Array.isArray(value)) {
6525
+ return value.map(pick).filter(item => item != null && item !== '').join('、');
6526
+ }
6527
+ const label = pick(value);
6528
+ return label == null ? '' : label;
6529
+ };
6530
+ const formatPhone = value => {
6531
+ if (value == null || value === '') {
6532
+ return '';
6533
+ }
6534
+ if (typeof value === 'string' || typeof value === 'number') {
6535
+ const trimmed = String(value).trim().replace(/\s+/g, ' ');
6536
+ return trimmed;
6537
+ }
6538
+ if (typeof value !== 'object') {
6539
+ return String(value);
6540
+ }
6541
+ const number = String(value.value ?? value.phone ?? value.number ?? '').replace(/\s+/g, '');
6542
+ const rawCode = value.code ?? value.countryCallingCode;
6543
+ const code = rawCode == null || rawCode === '' ? '' : String(rawCode).replace(/^\+/, '');
6544
+ if (!number) {
6545
+ return '';
6546
+ }
6547
+ if (!code) {
6548
+ return number;
6549
+ }
6550
+ return `+${code} ${number}`;
6551
+ };
6552
+ const formatFile = value => {
6553
+ if (Array.isArray(value)) {
6554
+ return value.map(item => formatFile(item)).filter(Boolean).join('、');
6555
+ }
6556
+ if (typeof value === 'string') {
6557
+ return value;
6558
+ }
6559
+ if (!value || typeof value !== 'object') {
6560
+ return value == null ? '' : String(value);
6561
+ }
6562
+ return value.filename || value.name || value.originName || value.originFileObj?.name || value.id || '';
6563
+ };
6564
+ const formatTypedDateRange = (value, ctx) => {
6565
+ if (!value || typeof value !== 'object') {
6566
+ return value == null ? '' : String(value);
6567
+ }
6568
+ const formatKey = TYPE_TO_TEMPORAL[value.type] || 'date';
6569
+ const range = formatTemporal(value.value, formatKey, ctx.field?.props?.format);
6570
+ const typeLabel = value.type ? String(value.type) : '';
6571
+ return [typeLabel, range].filter(Boolean).join(' ');
6572
+ };
6573
+ const formatDateToToday = (value, itemSchema, ctx) => {
6574
+ const items = Array.isArray(value) ? value : [value];
6575
+ const start = formatByValueSchema(items[0], itemSchema, ctx);
6576
+ if (items[1] == null || items[1] === '' || items[1] === true) {
6577
+ const until = ctx.formatMessage?.({
6578
+ id: 'schemaContentUntilToday'
6579
+ }) || '至今';
6580
+ return [start, until].filter(Boolean).join(' ~ ');
6581
+ }
6582
+ const end = formatByValueSchema(items[1], itemSchema, ctx);
6583
+ return [start, end].filter(Boolean).join(' ~ ');
6584
+ };
6585
+ const formatJson = value => {
6586
+ if (typeof value === 'string') {
6587
+ try {
6588
+ return JSON.stringify(JSON.parse(value), null, 2);
6589
+ } catch {
6590
+ return value;
6591
+ }
6592
+ }
6593
+ if (value && typeof value === 'object') {
6594
+ return JSON.stringify(value, null, 2);
6595
+ }
6596
+ return value == null ? '' : String(value);
6597
+ };
6598
+ const formatHtml = value => String(value ?? '').replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
6599
+ const formatMoney = value => {
6600
+ const num = Number(value);
6601
+ if (Number.isNaN(num)) {
6602
+ return value == null ? '' : String(value);
6603
+ }
6604
+ return num.toLocaleString();
6605
+ };
6606
+ const formatColor = value => {
6607
+ if (value == null) {
6608
+ return '';
6609
+ }
6610
+ if (typeof value === 'string' || typeof value === 'number') {
6611
+ return String(value);
6612
+ }
6613
+ if (typeof value === 'object') {
6614
+ if (typeof value.toHexString === 'function') {
6615
+ return value.toHexString();
6616
+ }
6617
+ return value.hex || value.metaColor || pickObjectLabel(value) || '';
6618
+ }
6619
+ return String(value);
6620
+ };
6621
+ const formatPassword = (value, ctx) => {
6622
+ if (isEmptyValue(value)) {
6623
+ return '';
6624
+ }
6625
+ return ctx.formatMessage?.({
6626
+ id: 'schemaContentPasswordMasked'
6627
+ }) || '••••••';
6628
+ };
6629
+ const formatBoolean = (value, field, ctx) => {
6630
+ const props = field?.props || {};
6631
+ if (value) {
6632
+ return props.checkedChildren || ctx.formatMessage?.({
6633
+ id: 'schemaContentYes'
6634
+ }) || '是';
6635
+ }
6636
+ return props.unCheckedChildren || ctx.formatMessage?.({
6637
+ id: 'schemaContentNo'
6638
+ }) || '否';
6639
+ };
6640
+ const stringifyFallback = value => {
6641
+ if (value == null) {
6642
+ return '';
6643
+ }
6644
+ if (typeof value !== 'object') {
6645
+ return String(value);
6646
+ }
6647
+ if (toDate(value)) {
6648
+ return formatTemporal(value, 'date-time');
6649
+ }
6650
+ if (Array.isArray(value)) {
6651
+ return value.map(item => item && typeof item === 'object' ? stringifyFallback(item) : String(item ?? '')).filter(Boolean).join('、');
6652
+ }
6653
+ if (value.label != null || value.name != null) {
6654
+ return pickObjectLabel(value);
6655
+ }
6656
+ if (value.filename || value.mimetype || value.storageType) {
6657
+ return formatFile(value);
6658
+ }
6659
+ if (value.code != null && value.value != null && value.label == null) {
6660
+ return formatPhone(value);
6661
+ }
6662
+ if (value.type != null && Array.isArray(value.value)) {
6663
+ return formatTypedDateRange(value, {
6664
+ field: {}
6665
+ });
6666
+ }
6667
+ try {
6668
+ return JSON.stringify(value);
6669
+ } catch {
6670
+ return '';
6671
+ }
6672
+ };
6673
+ const formatByValueSchema = function (value, schema, ctx) {
6674
+ if (ctx === void 0) {
6675
+ ctx = {};
6676
+ }
6677
+ if (isEmptyValue(value)) {
6678
+ return '';
6679
+ }
6680
+ const resolved = schema && typeof schema === 'object' ? schema : {};
6681
+ const type = resolved.type;
6682
+ const format = resolved.format;
6683
+ const display = resolved.display;
6684
+ const field = ctx.field;
6685
+ const patternOverride = field?.props?.format;
6686
+ if (display === 'option') {
6687
+ return formatOption(value, field);
6688
+ }
6689
+ if (display === 'phone') {
6690
+ return formatPhone(value);
6691
+ }
6692
+ if (display === 'file') {
6693
+ return /*#__PURE__*/react.createElement(FileFieldPreview$1, {
6694
+ value,
6695
+ field
6696
+ });
6697
+ }
6698
+ if (display === 'typed-date-range') {
6699
+ return formatTypedDateRange(value, ctx);
6700
+ }
6701
+ if (display === 'date-to-today') {
6702
+ return formatDateToToday(value, resolved.items || {
6703
+ type: 'string',
6704
+ format: 'date'
6705
+ }, ctx);
6706
+ }
6707
+ if (display === 'html' || format === 'html') {
6708
+ return formatHtml(value);
6709
+ }
6710
+ if (display === 'money') {
6711
+ return formatMoney(value);
6712
+ }
6713
+ if (format === 'password') {
6714
+ return formatPassword(value, ctx);
6715
+ }
6716
+ if (format === 'json') {
6717
+ return formatJson(value);
6718
+ }
6719
+ if (format === 'color') {
6720
+ return formatColor(value);
6721
+ }
6722
+ if (type === 'boolean') {
6723
+ return formatBoolean(value, field, ctx);
6724
+ }
6725
+ if (isTemporalKey(format)) {
6726
+ return formatTemporal(value, format, patternOverride);
6727
+ }
6728
+ if (type === 'array') {
6729
+ const items = Array.isArray(value) ? value : [value];
6730
+ const itemSchema = resolved.items || {};
6731
+ if (itemSchema.display === 'file') {
6732
+ return /*#__PURE__*/react.createElement(FileFieldPreview$1, {
6733
+ value: items,
6734
+ field
6735
+ });
6736
+ }
6737
+ const joiner = isTemporalKey(itemSchema.format) || itemSchema.display === 'date-to-today' ? ' ~ ' : '、';
6738
+ return items.map(item => formatByValueSchema(item, itemSchema, ctx)).filter(item => item != null && item !== '').join(joiner);
6739
+ }
6740
+ if (Array.isArray(value)) {
6741
+ const itemSchema = resolved.items || {
6742
+ ...resolved,
6743
+ type: undefined
6744
+ };
6745
+ if (itemSchema.display === 'file' || resolved.display === 'file') {
6746
+ return /*#__PURE__*/react.createElement(FileFieldPreview$1, {
6747
+ value,
6748
+ field
6749
+ });
6750
+ }
6751
+ const joiner = isTemporalKey(itemSchema.format) ? ' ~ ' : '、';
6752
+ return value.map(item => formatByValueSchema(item, itemSchema, ctx)).filter(item => item != null && item !== '').join(joiner);
6753
+ }
6754
+ if (Array.isArray(resolved.enum) || Array.isArray(field?.props?.options) && field.props.options.length) {
6755
+ const mapped = formatOption(value, field);
6756
+ if (mapped != null && mapped !== '') {
6757
+ return mapped;
6758
+ }
6759
+ }
6760
+ if (type === 'object') {
6761
+ return stringifyFallback(value);
6762
+ }
6763
+ if (typeof value === 'object') {
6764
+ return stringifyFallback(value);
6765
+ }
6766
+ return String(value);
6767
+ };
6768
+ const formatFieldDisplayValue = function (field, value, _temp) {
6769
+ let {
6770
+ formatMessage
6771
+ } = _temp === void 0 ? {} : _temp;
6772
+ const emptyText = formatMessage?.({
6773
+ id: 'schemaContentEmptyValue'
6774
+ }) || '-';
6775
+ if (isEmptyValue(value)) {
6776
+ return emptyText;
6777
+ }
6778
+ const definition = getFieldDefinition(field?.type);
6779
+ if (typeof definition?.formatDisplayValue === 'function') {
6780
+ const custom = definition.formatDisplayValue(value, field, {
6781
+ formatMessage
6782
+ });
6783
+ if (custom != null && custom !== '') {
6784
+ return custom;
6785
+ }
6786
+ }
6787
+ const schema = resolveFieldValueSchema(field);
6788
+ const text = formatByValueSchema(value, schema, {
6789
+ field,
6790
+ formatMessage
6791
+ });
6792
+ return text == null || text === '' ? emptyText : text;
6793
+ };
6794
+
6082
6795
  /**
6083
6796
  * 统一注册扩展规则与填写项:运行时校验 + 编辑器规则面板 + 字段类型 registry。
6084
6797
  * 应用入口调用一次即可,FormCreator / SchemaRenderer 共用。
@@ -6136,7 +6849,7 @@ const createObjectLayer = () => ({
6136
6849
  composites: []
6137
6850
  });
6138
6851
  const isReq = rule => parseRuleString(rule).presets.includes('REQ');
6139
- const resolveChoiceSelectorName = block => {
6852
+ const resolveChoiceSelectorName$1 = block => {
6140
6853
  if (block.selectorName != null && String(block.selectorName).trim()) {
6141
6854
  return String(block.selectorName).trim();
6142
6855
  }
@@ -6313,7 +7026,7 @@ const walkBlock = function (block, layer, depth) {
6313
7026
  const mergeChoiceIntoLayer = (layer, block, depth) => {
6314
7027
  const mode = block.mode === 'multiple' ? 'multiple' : 'single';
6315
7028
  const selectorInData = block.selectorInData !== false;
6316
- const selectorName = resolveChoiceSelectorName(block);
7029
+ const selectorName = resolveChoiceSelectorName$1(block);
6317
7030
  const options = block.options || [];
6318
7031
  const optionIds = options.map(option => String(option.id));
6319
7032
  const branches = options.map((option, index) => {
@@ -6424,10 +7137,215 @@ const schemaToDataSchema = function (schema, options) {
6424
7137
  return root;
6425
7138
  };
6426
7139
 
7140
+ const getByPath = (data, path) => {
7141
+ if (data == null || path == null || path === '') {
7142
+ return data;
7143
+ }
7144
+ return String(path).split('.').reduce((acc, key) => acc == null ? acc : acc[key], data);
7145
+ };
7146
+ const resolveChoiceSelectorName = block => {
7147
+ if (block.selectorName != null && String(block.selectorName).trim()) {
7148
+ return String(block.selectorName).trim();
7149
+ }
7150
+ if (block.discriminator?.propertyName) {
7151
+ return String(block.discriminator.propertyName).trim();
7152
+ }
7153
+ return `__choice_${block.id}`;
7154
+ };
7155
+ const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValue(field, value, {
7156
+ formatMessage
7157
+ });
7158
+ const renderFieldsContent = (fields, data, formatMessage, column) => {
7159
+ const list = (fields || []).filter(field => field && !field.hidden && field.name).map(field => ({
7160
+ label: field.label || field.name,
7161
+ content: formatFieldValue(field, getByPath(data, field.name), formatMessage),
7162
+ block: field.block || undefined
7163
+ }));
7164
+ if (!list.length) {
7165
+ return null;
7166
+ }
7167
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage.Content, {
7168
+ col: column || 2,
7169
+ list: list
7170
+ });
7171
+ };
7172
+ const renderBlockList = (blocks, data, ctx) => (blocks || []).map(block => renderBlock(block, data, ctx)).filter(Boolean);
7173
+ const renderBlock = (block, data, ctx) => {
7174
+ const {
7175
+ formatMessage,
7176
+ isMobile,
7177
+ depth = 0
7178
+ } = ctx;
7179
+ if (!block || depth > MAX_BLOCK_DEPTH) {
7180
+ return null;
7181
+ }
7182
+ const nextCtx = {
7183
+ ...ctx,
7184
+ depth: depth + 1
7185
+ };
7186
+ const bordered = isMobile ? false : block.bordered || undefined;
7187
+ const partProps = {
7188
+ key: block.id,
7189
+ title: block.title || block.label || undefined,
7190
+ subtitle: block.subtitle || undefined,
7191
+ bordered
7192
+ };
7193
+ switch (block.kind) {
7194
+ case 'formInfo':
7195
+ {
7196
+ return /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7197
+ ...partProps,
7198
+ children: [renderFieldsContent(block.list, data, formatMessage, block.column), renderBlockList(block.blocks, data, nextCtx)]
7199
+ });
7200
+ }
7201
+ case 'object':
7202
+ {
7203
+ const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
7204
+ const nestedData = name ? getByPath(data, name) || {} : data;
7205
+ return /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7206
+ ...partProps,
7207
+ children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column), renderBlockList(block.blocks, nestedData, nextCtx)]
7208
+ });
7209
+ }
7210
+ case 'list':
7211
+ case 'tableList':
7212
+ {
7213
+ const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
7214
+ const items = name ? getByPath(data, name) : null;
7215
+ const rows = Array.isArray(items) ? items : [];
7216
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage__default["default"].Part, {
7217
+ ...partProps,
7218
+ children: rows.length ? rows.map((item, index) => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7219
+ title: formatMessage({
7220
+ id: 'schemaContentItemIndex'
7221
+ }, {
7222
+ index: index + 1
7223
+ }),
7224
+ bordered: false,
7225
+ children: [renderFieldsContent(block.list, item || {}, formatMessage, 2), block.kind === 'list' ? renderBlockList(block.itemBlocks, item || {}, nextCtx) : null]
7226
+ }, `${block.id}-${index}`)) : formatMessage({
7227
+ id: 'schemaContentEmptyValue'
7228
+ })
7229
+ });
7230
+ }
7231
+ case 'multiField':
7232
+ {
7233
+ const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
7234
+ const values = name ? getByPath(data, name) : null;
7235
+ const itemField = {
7236
+ type: block.fieldType || 'Input',
7237
+ label: block.label,
7238
+ props: {}
7239
+ };
7240
+ const content = Array.isArray(values) ? values.map(item => formatFieldValue(itemField, item, formatMessage)).join('、') : formatFieldValue(itemField, values, formatMessage);
7241
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage__default["default"].Part, {
7242
+ ...partProps,
7243
+ children: /*#__PURE__*/jsxRuntime.jsx(InfoPage.Content, {
7244
+ col: 1,
7245
+ list: [{
7246
+ label: block.label || block.name,
7247
+ content,
7248
+ block: true
7249
+ }]
7250
+ })
7251
+ });
7252
+ }
7253
+ case 'steps':
7254
+ {
7255
+ return /*#__PURE__*/jsxRuntime.jsx(react.Fragment, {
7256
+ children: (block.items || []).map(step => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7257
+ title: step.title || undefined,
7258
+ bordered: bordered,
7259
+ children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2), renderBlockList(step.blocks, data, nextCtx)]
7260
+ }, step.id))
7261
+ }, block.id);
7262
+ }
7263
+ case 'choice':
7264
+ {
7265
+ const selectorName = resolveChoiceSelectorName(block);
7266
+ const selectorValue = block.selectorInData === false ? undefined : getByPath(data, selectorName);
7267
+ const selectedIds = block.mode === 'multiple' ? Array.isArray(selectorValue) ? selectorValue.map(String) : [] : selectorValue != null && selectorValue !== '' ? [String(selectorValue)] : [];
7268
+ const options = block.options || [];
7269
+ const visibleOptions = selectedIds.length ? options.filter(option => selectedIds.includes(String(option.id))) : [];
7270
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage__default["default"].Part, {
7271
+ ...partProps,
7272
+ children: visibleOptions.map(option => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7273
+ title: option.title || undefined,
7274
+ bordered: false,
7275
+ children: [renderFieldsContent(option.list, data, formatMessage, block.column), renderBlockList(option.blocks, data, nextCtx)]
7276
+ }, option.id))
7277
+ });
7278
+ }
7279
+ default:
7280
+ return null;
7281
+ }
7282
+ };
7283
+ const SchemaContentInnerView = _ref => {
7284
+ let {
7285
+ schema,
7286
+ data,
7287
+ className
7288
+ } = _ref;
7289
+ const {
7290
+ formatMessage
7291
+ } = reactIntl.useIntl();
7292
+ const isMobile = responsiveUtils.useIsMobile();
7293
+ const normalized = normalizeSchema(schema);
7294
+ const children = renderBlockList(normalized.blocks, data || {}, {
7295
+ formatMessage,
7296
+ isMobile,
7297
+ depth: 0
7298
+ });
7299
+ if (!children.length) {
7300
+ return null;
7301
+ }
7302
+ if (className) {
7303
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
7304
+ className: className,
7305
+ children: children
7306
+ });
7307
+ }
7308
+ return /*#__PURE__*/jsxRuntime.jsx(react.Fragment, {
7309
+ children: children
7310
+ });
7311
+ };
7312
+ const SchemaContentInner = withLocale$1(SchemaContentInnerView);
7313
+ const SchemaContent = withLocale$1(_ref2 => {
7314
+ let {
7315
+ schema,
7316
+ data,
7317
+ className,
7318
+ empty
7319
+ } = _ref2;
7320
+ const {
7321
+ formatMessage
7322
+ } = reactIntl.useIntl();
7323
+ const normalized = normalizeSchema(schema);
7324
+ const emptyNode = empty !== undefined ? empty : /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
7325
+ image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
7326
+ description: formatMessage({
7327
+ id: 'schemaContentEmpty'
7328
+ })
7329
+ });
7330
+ if (data == null || !hasRenderableContent(normalized)) {
7331
+ return emptyNode;
7332
+ }
7333
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage__default["default"], {
7334
+ className: [style['schema-content'], className].filter(Boolean).join(' '),
7335
+ children: /*#__PURE__*/jsxRuntime.jsx(SchemaContentInnerView, {
7336
+ schema: normalized,
7337
+ data: data
7338
+ })
7339
+ });
7340
+ });
7341
+ var SchemaContent$1 = SchemaContent;
7342
+
6427
7343
  exports.FormCreator = FormCreator$1;
6428
7344
  exports.MAX_BLOCK_DEPTH = MAX_BLOCK_DEPTH;
6429
7345
  exports.RULE_LEN_PRESET = RULE_LEN_PRESET;
6430
7346
  exports.RULE_PRESET_ITEMS = RULE_PRESET_ITEMS;
7347
+ exports.SchemaContent = SchemaContent$1;
7348
+ exports.SchemaContentInner = SchemaContentInner;
6431
7349
  exports.SchemaRenderer = SchemaRenderer$1;
6432
7350
  exports.SchemaRendererInner = SchemaRendererInner;
6433
7351
  exports.applyFromPropsSchema = applyFromPropsSchema;
@@ -6448,6 +7366,8 @@ exports.findBlock = findBlock;
6448
7366
  exports.findBlockInTree = findBlockInTree;
6449
7367
  exports.formValuesToBlock = formValuesToBlock;
6450
7368
  exports.formValuesToField = formValuesToField;
7369
+ exports.formatByValueSchema = formatByValueSchema;
7370
+ exports.formatFieldDisplayValue = formatFieldDisplayValue;
6451
7371
  exports.getBlockDefinition = getBlockDefinition;
6452
7372
  exports.getBlockKindOptions = getBlockKindOptions;
6453
7373
  exports.getFieldComponent = getFieldComponent;