@kne/form-creator 0.1.12 → 0.1.14

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,6 +13,7 @@ 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');
16
18
 
17
19
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -20,7 +22,7 @@ var SelectList__default = /*#__PURE__*/_interopDefaultLegacy(SelectList);
20
22
  var FormInfo__default = /*#__PURE__*/_interopDefaultLegacy(FormInfo);
21
23
  var InfoPage__default = /*#__PURE__*/_interopDefaultLegacy(InfoPage);
22
24
 
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"};
25
+ var style = {"kne-responsive-boundary":"kne-form-creator_gh14z","kne-responsive-scroll":"kne-form-creator_Kfn6L","form-creator":"kne-form-creator_Xrjrk","editor-pane":"kne-form-creator_Skfuv","preview-pane":"kne-form-creator_v4Lsp","editor-header":"kne-form-creator_WaSS-","block-list-panel":"kne-form-creator_lx8An","form-actions-setting-btn":"kne-form-creator_NekU2","panel-toolbar":"kne-form-creator_t0WxZ","panel-toolbar-extra":"kne-form-creator_O22ZM","schema-content":"kne-form-creator_9bWOD","add-block-btn":"kne-form-creator_16Zre","add-inline-btn":"kne-form-creator_iCYdB","ant-btn-disabled":"kne-form-creator_LdGtv","block-list":"kne-form-creator_wK5eK","block-section":"kne-form-creator_15IiK","block-kind-formInfo":"kne-form-creator_D0hoK","block-kind-list":"kne-form-creator_JdPhy","block-kind-tableList":"kne-form-creator_gzd64","block-kind-multiField":"kne-form-creator_t0iOJ","block-kind-steps":"kne-form-creator_QNF9W","step-section":"kne-form-creator_22ajp","block-section-header":"kne-form-creator_wS4rL","block-header-left":"kne-form-creator_t4awC","block-title":"kne-form-creator_wSVJf","block-summary":"kne-form-creator_GzeW8","block-header-actions":"kne-form-creator_Ue-nT","block-body":"kne-form-creator_je1H0","item-blocks-section":"kne-form-creator_wq4bT","nested-block-list":"kne-form-creator_4NWH4","block-section-nested":"kne-form-creator_mUKom","add-field-dropdown":"kne-form-creator_9JS0d","add-field-dropdown-item":"kne-form-creator_Ql1z3","add-field-dropdown-item-icon":"kne-form-creator_ZHB5O","add-field-dropdown-item-desc":"kne-form-creator_dcsOS","add-field-dropdown-divider":"kne-form-creator_CUK0H","add-field-dropdown-label":"kne-form-creator_bPJ-2","section-toolbar":"kne-form-creator_LUO8S","section-toolbar-label":"kne-form-creator_7KQ79","field-list":"kne-form-creator_-B7WZ","step-list":"kne-form-creator_kc1pH","step-section-header":"kne-form-creator_wkhEX","step-section-title":"kne-form-creator_NBinE","step-section-actions":"kne-form-creator_es-FC","step-index":"kne-form-creator_CCKZZ","field-row":"kne-form-creator_XMkdt","field-row-index":"kne-form-creator_a-cDo","field-row-main":"kne-form-creator_ftlwp","inline-empty":"kne-form-creator_yP-RF","action-group":"kne-form-creator_773yo","hover-reveal":"kne-form-creator_S234h","hover-reveal-active":"kne-form-creator_AE-6r","action-btn":"kne-form-creator_mLgqh","add-block-dropdown":"kne-form-creator_vmS-e","add-block-option":"kne-form-creator_gjg2Y","add-block-option-icon":"kne-form-creator_qh1hh","add-block-option-text":"kne-form-creator_G8iJO","add-block-option-title":"kne-form-creator_ETSvm","add-block-option-desc":"kne-form-creator_O0C3l","field-empty":"kne-form-creator_Nmpfl","field-label-tips-icon":"kne-form-creator_0VVaO","preview-header":"kne-form-creator_c4BT0","preview-title":"kne-form-creator_fPkK4","preview-body":"kne-form-creator_6JntQ","schema-form":"kne-form-creator_MxCWP","schema-body":"kne-form-creator_q9ydz","schema-actions":"kne-form-creator_Y4eEH","schema-actions-inner":"kne-form-creator_FT9Zf","choice-block":"kne-form-creator_RllJe","choice-selector":"kne-form-creator_5A1eM","choice-panels":"kne-form-creator_IO0MY","choice-panels-empty":"kne-form-creator_T0nND","choice-option-panel":"kne-form-creator_FQixN","choice-option-panel-title":"kne-form-creator_ofRo2","choice-option-summary":"kne-form-creator_pksH8","field-editor-form":"kne-form-creator_PGPHL","form-actions-editor":"kne-form-creator_fchMy","form-actions-switch-field":"kne-form-creator_6JE9x","form-actions-layout-panel":"kne-form-creator_rtm9D","form-actions-align-group":"kne-form-creator_51ZsV","form-actions-layout-title":"kne-form-creator_hFeiC","form-actions-gap-slider":"kne-form-creator_Gq0bk","editor-section":"kne-form-creator_jJy85","section-divider":"kne-form-creator_zA7L-","rule-editor":"kne-form-creator_bAlGU","options-editor":"kne-form-creator_AK4yO","super-select-props":"kne-form-creator_Iawhh","field-props-editor":"kne-form-creator_Gabf2","columns-editor":"kne-form-creator_DQW1N","prop-row":"kne-form-creator_7K54P","prop-label":"kne-form-creator_HAAyH","options-item":"kne-form-creator_dnOd2","table-row-card":"kne-form-creator_cwCYp","tree-options-editor":"kne-form-creator_s3nHO","tree-options-list":"kne-form-creator_Djs-E","tree-option-node":"kne-form-creator_XAcut","tree-option-row":"kne-form-creator_4K4Rj","tree-option-fields":"kne-form-creator_-4cjc","tree-option-actions":"kne-form-creator_IjCNI","tree-option-children":"kne-form-creator_pVPGJ","tree-add-sibling":"kne-form-creator_bl46P","rule-checkbox-group":"kne-form-creator_tDgVP","rule-len-row":"kne-form-creator_ATsae","rule-len-input":"kne-form-creator_jY4Ld","rule-len-sep":"kne-form-creator_jBDC8","options-list":"kne-form-creator_GUBNS","options-row":"kne-form-creator_uohD0","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","is-mobile":"kne-form-creator_LtgJz"};
24
26
 
25
27
  const locale$1 = {
26
28
  addField: '添加填写项',
@@ -214,7 +216,12 @@ const locale$1 = {
214
216
  formSettingsTitle: '表单设置',
215
217
  formTitlePlaceholder: '表单标题(可选)',
216
218
  formSubtitlePlaceholder: '表单副标题(可选)',
217
- formColumnPlaceholder: '每行显示列数'
219
+ formColumnPlaceholder: '每行显示列数',
220
+ schemaContentEmpty: '暂无数据',
221
+ schemaContentEmptyValue: '-',
222
+ schemaContentYes: '是',
223
+ schemaContentNo: '否',
224
+ schemaContentItemIndex: '第 {index} 项'
218
225
  };
219
226
  var zhCN = locale$1;
220
227
 
@@ -410,7 +417,12 @@ const locale = {
410
417
  formSettingsTitle: 'Form Settings',
411
418
  formTitlePlaceholder: 'Form title (optional)',
412
419
  formSubtitlePlaceholder: 'Form subtitle (optional)',
413
- formColumnPlaceholder: 'Columns per row'
420
+ formColumnPlaceholder: 'Columns per row',
421
+ schemaContentEmpty: 'No data',
422
+ schemaContentEmptyValue: '-',
423
+ schemaContentYes: 'Yes',
424
+ schemaContentNo: 'No',
425
+ schemaContentItemIndex: 'Item {index}'
414
426
  };
415
427
  var enUS = locale;
416
428
 
@@ -2448,7 +2460,8 @@ const BlockListPanel = _ref3 => {
2448
2460
  onEditChoiceOption,
2449
2461
  onDeleteChoiceOption,
2450
2462
  onMoveChoiceOption,
2451
- onOpenFormActions
2463
+ onOpenFormActions,
2464
+ extraToolbar
2452
2465
  } = _ref3;
2453
2466
  const {
2454
2467
  formatMessage
@@ -3037,7 +3050,10 @@ const BlockListPanel = _ref3 => {
3037
3050
  id: 'formActionsSection'
3038
3051
  }),
3039
3052
  onClick: onOpenFormActions
3040
- })]
3053
+ }), extraToolbar ? /*#__PURE__*/jsxRuntime.jsx("div", {
3054
+ className: style['panel-toolbar-extra'],
3055
+ children: extraToolbar
3056
+ }) : null]
3041
3057
  }), !blocks.length ? /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
3042
3058
  className: style['field-empty'],
3043
3059
  image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
@@ -4878,7 +4894,7 @@ const FormActionsEditor = _ref => {
4878
4894
  };
4879
4895
  var FormActionsEditor$1 = FormActionsEditor;
4880
4896
 
4881
- const getByPath = (obj, path) => {
4897
+ const getByPath$1 = (obj, path) => {
4882
4898
  if (obj == null || path == null || path === '') {
4883
4899
  return undefined;
4884
4900
  }
@@ -4921,7 +4937,7 @@ const clearUnselectedOptionFields = (openApi, formData, keepIds, allOptions) =>
4921
4937
  if (!field?.name) {
4922
4938
  return;
4923
4939
  }
4924
- const current = getByPath(formData, field.name);
4940
+ const current = getByPath$1(formData, field.name);
4925
4941
  if (current !== undefined) {
4926
4942
  entries.push({
4927
4943
  name: field.name,
@@ -4930,7 +4946,7 @@ const clearUnselectedOptionFields = (openApi, formData, keepIds, allOptions) =>
4930
4946
  }
4931
4947
  });
4932
4948
  collectBlockFieldNames(option.blocks || []).forEach(name => {
4933
- const current = getByPath(formData, name);
4949
+ const current = getByPath$1(formData, name);
4934
4950
  if (current !== undefined) {
4935
4951
  entries.push({
4936
4952
  name,
@@ -5013,7 +5029,7 @@ const ChoiceBlock = ({
5013
5029
  maxLength
5014
5030
  } = mode === 'multiple' ? resolveSelectLimits(block) : {};
5015
5031
  const firstOptionId = options[0] != null ? String(options[0].id) : undefined;
5016
- const rawValue = getByPath(formData || {}, selectorName);
5032
+ const rawValue = getByPath$1(formData || {}, selectorName);
5017
5033
  // 仅随 selector 值变化;勿依赖整个 formData,否则清空未选支字段会触发 options 重算 → CheckboxGroup 死循环
5018
5034
  const selectorValueKey = mode === 'multiple' ? Array.isArray(rawValue) ? rawValue.map(String).join('\0') : String(rawValue ?? '') : String(rawValue ?? '');
5019
5035
 
@@ -5433,6 +5449,7 @@ const renderSchemaInner = function (schema, _temp2) {
5433
5449
  let {
5434
5450
  preview = false,
5435
5451
  className,
5452
+ bodyClassName,
5436
5453
  isMobile = false,
5437
5454
  formatMessage,
5438
5455
  children,
@@ -5447,16 +5464,20 @@ const renderSchemaInner = function (schema, _temp2) {
5447
5464
  if (!contentChildren.length && !children && !actionNode) {
5448
5465
  return null;
5449
5466
  }
5450
- const body = /*#__PURE__*/react.createElement(react.Fragment, null, ...contentChildren, children, actionNode || null);
5467
+ const body = /*#__PURE__*/react.createElement('div', {
5468
+ className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
5469
+ }, ...contentChildren, children);
5470
+ const content = /*#__PURE__*/react.createElement(react.Fragment, null, body, actionNode || null);
5451
5471
  return className ? /*#__PURE__*/react.createElement('div', {
5452
5472
  className
5453
- }, body) : body;
5473
+ }, content) : content;
5454
5474
  };
5455
5475
  const renderSchemaContent = function (schema, _temp3) {
5456
5476
  let {
5457
5477
  preview = false,
5458
5478
  formProps = {},
5459
5479
  className,
5480
+ bodyClassName,
5460
5481
  isMobile = false,
5461
5482
  formatMessage,
5462
5483
  children,
@@ -5476,11 +5497,14 @@ const renderSchemaContent = function (schema, _temp3) {
5476
5497
  ...formProps,
5477
5498
  className: formClassName
5478
5499
  }, /*#__PURE__*/react.createElement('div', {
5479
- className: style['schema-body']
5500
+ className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
5480
5501
  }, ...contentChildren, children), actionNode || null);
5481
5502
  };
5482
5503
  var renderSchemaContent$1 = renderSchemaContent;
5483
5504
 
5505
+ const joinClass = function () {
5506
+ return [].slice.call(arguments).filter(Boolean).join(' ');
5507
+ };
5484
5508
  const resolveActionNode = _ref => {
5485
5509
  let {
5486
5510
  schema,
@@ -5497,7 +5521,10 @@ const resolveActionNode = _ref => {
5497
5521
  showReset,
5498
5522
  showCancel,
5499
5523
  actionsAlign,
5500
- actionsGap
5524
+ actionsGap,
5525
+ footerClassName,
5526
+ buttonFooter = false,
5527
+ buttonFooterProps
5501
5528
  } = _ref;
5502
5529
  if (showActions === false || actions === false || actions === null) {
5503
5530
  return null;
@@ -5536,20 +5563,27 @@ const resolveActionNode = _ref => {
5536
5563
  gap: resolvedGap ?? 16,
5537
5564
  wrap: 'wrap'
5538
5565
  };
5566
+ let actionsEl = null;
5539
5567
  if (actions !== undefined) {
5540
- return /*#__PURE__*/react.createElement('div', {
5541
- className: style['schema-actions']
5568
+ actionsEl = /*#__PURE__*/react.createElement('div', {
5569
+ className: joinClass(style['schema-actions'], footerClassName)
5542
5570
  }, /*#__PURE__*/react.createElement(antd.Flex, flexProps, actions));
5543
- }
5544
- if (!resolvedShowSubmit && !resolvedShowReset && !resolvedShowCancel) {
5571
+ } else if (resolvedShowSubmit || resolvedShowReset || resolvedShowCancel) {
5572
+ actionsEl = /*#__PURE__*/react.createElement('div', {
5573
+ className: joinClass(style['schema-actions'], footerClassName)
5574
+ }, /*#__PURE__*/react.createElement(antd.Flex, flexProps, resolvedShowSubmit ? /*#__PURE__*/react.createElement(reactFormAntd.SubmitButton, {
5575
+ type: 'primary',
5576
+ ...resolvedSubmitButtonProps
5577
+ }, resolvedSubmitText) : null, resolvedShowReset ? /*#__PURE__*/react.createElement(reactFormAntd.ResetButton, resolvedResetButtonProps, resolvedResetText) : null, resolvedShowCancel ? /*#__PURE__*/react.createElement(reactFormAntd.CancelButton, resolvedCancelButtonProps, resolvedCancelText) : null));
5578
+ }
5579
+ if (!actionsEl) {
5545
5580
  return null;
5546
5581
  }
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));
5582
+ if (!buttonFooter) {
5583
+ return actionsEl;
5584
+ }
5585
+ const footerProps = buttonFooterProps || {};
5586
+ return /*#__PURE__*/react.createElement(buttonGroup.ButtonFooter, footerProps, actionsEl);
5553
5587
  };
5554
5588
  const SchemaRendererInner = withLocale$1(props => {
5555
5589
  const {
@@ -5569,7 +5603,11 @@ const SchemaRendererInner = withLocale$1(props => {
5569
5603
  showReset,
5570
5604
  showCancel,
5571
5605
  actionsAlign,
5572
- actionsGap
5606
+ actionsGap,
5607
+ bodyClassName,
5608
+ footerClassName,
5609
+ buttonFooter = false,
5610
+ buttonFooterProps
5573
5611
  } = props;
5574
5612
  const {
5575
5613
  formatMessage
@@ -5594,11 +5632,15 @@ const SchemaRendererInner = withLocale$1(props => {
5594
5632
  showReset,
5595
5633
  showCancel,
5596
5634
  actionsAlign,
5597
- actionsGap
5635
+ actionsGap,
5636
+ footerClassName,
5637
+ buttonFooter,
5638
+ buttonFooterProps
5598
5639
  });
5599
5640
  return renderSchemaInner(normalized, {
5600
5641
  preview,
5601
5642
  className,
5643
+ bodyClassName,
5602
5644
  isMobile,
5603
5645
  formatMessage,
5604
5646
  children,
@@ -5624,7 +5666,11 @@ const SchemaRenderer = withLocale$1(props => {
5624
5666
  showReset,
5625
5667
  showCancel,
5626
5668
  actionsAlign,
5627
- actionsGap
5669
+ actionsGap,
5670
+ bodyClassName,
5671
+ footerClassName,
5672
+ buttonFooter = false,
5673
+ buttonFooterProps
5628
5674
  } = props;
5629
5675
  const {
5630
5676
  formatMessage
@@ -5649,12 +5695,16 @@ const SchemaRenderer = withLocale$1(props => {
5649
5695
  showReset,
5650
5696
  showCancel,
5651
5697
  actionsAlign,
5652
- actionsGap
5698
+ actionsGap,
5699
+ footerClassName,
5700
+ buttonFooter,
5701
+ buttonFooterProps
5653
5702
  });
5654
5703
  return renderSchemaContent$1(normalized, {
5655
5704
  preview,
5656
5705
  formProps,
5657
5706
  className,
5707
+ bodyClassName,
5658
5708
  isMobile,
5659
5709
  formatMessage,
5660
5710
  children,
@@ -5671,7 +5721,8 @@ const FormCreator = withLocale$1(_ref => {
5671
5721
  showPreview = true,
5672
5722
  className,
5673
5723
  formProps,
5674
- renderModal
5724
+ renderModal,
5725
+ extraToolbar
5675
5726
  } = _ref;
5676
5727
  const {
5677
5728
  formatMessage
@@ -5988,6 +6039,9 @@ const FormCreator = withLocale$1(_ref => {
5988
6039
  stepId: fieldContext.stepId,
5989
6040
  optionId: fieldContext.optionId
5990
6041
  }) : [];
6042
+ const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
6043
+ schema
6044
+ }) : extraToolbar;
5991
6045
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
5992
6046
  className: [style['form-creator'], responsiveUtils.RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
5993
6047
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
@@ -6010,7 +6064,8 @@ const FormCreator = withLocale$1(_ref => {
6010
6064
  onEditChoiceOption: handleEditChoiceOption,
6011
6065
  onDeleteChoiceOption: handleDeleteChoiceOption,
6012
6066
  onMoveChoiceOption: handleMoveChoiceOption,
6013
- onOpenFormActions: () => setFormActionsOpen(true)
6067
+ onOpenFormActions: () => setFormActionsOpen(true),
6068
+ extraToolbar: toolbarExtra
6014
6069
  })
6015
6070
  }), showPreview ? /*#__PURE__*/jsxRuntime.jsx("div", {
6016
6071
  className: style['preview-pane'],
@@ -6136,7 +6191,7 @@ const createObjectLayer = () => ({
6136
6191
  composites: []
6137
6192
  });
6138
6193
  const isReq = rule => parseRuleString(rule).presets.includes('REQ');
6139
- const resolveChoiceSelectorName = block => {
6194
+ const resolveChoiceSelectorName$1 = block => {
6140
6195
  if (block.selectorName != null && String(block.selectorName).trim()) {
6141
6196
  return String(block.selectorName).trim();
6142
6197
  }
@@ -6313,7 +6368,7 @@ const walkBlock = function (block, layer, depth) {
6313
6368
  const mergeChoiceIntoLayer = (layer, block, depth) => {
6314
6369
  const mode = block.mode === 'multiple' ? 'multiple' : 'single';
6315
6370
  const selectorInData = block.selectorInData !== false;
6316
- const selectorName = resolveChoiceSelectorName(block);
6371
+ const selectorName = resolveChoiceSelectorName$1(block);
6317
6372
  const options = block.options || [];
6318
6373
  const optionIds = options.map(option => String(option.id));
6319
6374
  const branches = options.map((option, index) => {
@@ -6424,10 +6479,301 @@ const schemaToDataSchema = function (schema, options) {
6424
6479
  return root;
6425
6480
  };
6426
6481
 
6482
+ const getByPath = (data, path) => {
6483
+ if (data == null || path == null || path === '') {
6484
+ return data;
6485
+ }
6486
+ return String(path).split('.').reduce((acc, key) => acc == null ? acc : acc[key], data);
6487
+ };
6488
+ const isEmptyValue = value => {
6489
+ if (value == null || value === '') {
6490
+ return true;
6491
+ }
6492
+ if (Array.isArray(value) && value.length === 0) {
6493
+ return true;
6494
+ }
6495
+ return false;
6496
+ };
6497
+ const resolveChoiceSelectorName = block => {
6498
+ if (block.selectorName != null && String(block.selectorName).trim()) {
6499
+ return String(block.selectorName).trim();
6500
+ }
6501
+ if (block.discriminator?.propertyName) {
6502
+ return String(block.discriminator.propertyName).trim();
6503
+ }
6504
+ return `__choice_${block.id}`;
6505
+ };
6506
+ const formatDateValue = (value, format) => {
6507
+ const pattern = format || 'YYYY-MM-DD';
6508
+ if (Array.isArray(value)) {
6509
+ return value.map(item => formatDateValue(item, format)).filter(item => item !== '').join(' ~ ');
6510
+ }
6511
+ if (value && typeof value.format === 'function') {
6512
+ return value.format(pattern);
6513
+ }
6514
+ return value == null ? '' : String(value);
6515
+ };
6516
+ const mapOptionLabel = (value, options) => {
6517
+ if (!Array.isArray(options) || !options.length) {
6518
+ return value;
6519
+ }
6520
+ const match = options.find(item => item && item.value === value);
6521
+ return match?.label ?? value;
6522
+ };
6523
+ const formatFieldValue = (field, value, formatMessage) => {
6524
+ if (isEmptyValue(value)) {
6525
+ return formatMessage({
6526
+ id: 'schemaContentEmptyValue'
6527
+ });
6528
+ }
6529
+ const definition = getFieldDefinition(field.type);
6530
+ const props = field.props || {};
6531
+ const valueSchema = resolveFieldValueSchema(field);
6532
+ const schemaType = valueSchema?.type;
6533
+ if (schemaType === 'boolean' || field.type === 'Switch' || field.type === 'Checkbox') {
6534
+ if (value) {
6535
+ return props.checkedChildren || formatMessage({
6536
+ id: 'schemaContentYes'
6537
+ });
6538
+ }
6539
+ return props.unCheckedChildren || formatMessage({
6540
+ id: 'schemaContentNo'
6541
+ });
6542
+ }
6543
+ if (field.type === 'DatePicker') {
6544
+ const formatted = formatDateValue(value, props.format);
6545
+ return formatted || formatMessage({
6546
+ id: 'schemaContentEmptyValue'
6547
+ });
6548
+ }
6549
+ if (Array.isArray(props.options) && props.options.length) {
6550
+ if (Array.isArray(value)) {
6551
+ const labels = value.map(item => mapOptionLabel(item, props.options)).filter(item => item != null && item !== '');
6552
+ return labels.length ? labels.join('、') : formatMessage({
6553
+ id: 'schemaContentEmptyValue'
6554
+ });
6555
+ }
6556
+ return mapOptionLabel(value, props.options);
6557
+ }
6558
+ if (definition?.isSuperSelect) {
6559
+ const labelKey = props.labelKey || 'label';
6560
+ const pickLabel = item => {
6561
+ if (item && typeof item === 'object') {
6562
+ return item[labelKey] ?? item.label ?? item.value;
6563
+ }
6564
+ return item;
6565
+ };
6566
+ if (Array.isArray(value)) {
6567
+ const labels = value.map(pickLabel).filter(item => item != null && item !== '');
6568
+ return labels.length ? labels.join('、') : formatMessage({
6569
+ id: 'schemaContentEmptyValue'
6570
+ });
6571
+ }
6572
+ if (value && typeof value === 'object') {
6573
+ return pickLabel(value) ?? formatMessage({
6574
+ id: 'schemaContentEmptyValue'
6575
+ });
6576
+ }
6577
+ }
6578
+ if (Array.isArray(value)) {
6579
+ return value.map(item => item && typeof item === 'object' ? JSON.stringify(item) : String(item)).join('、');
6580
+ }
6581
+ if (typeof value === 'object') {
6582
+ return JSON.stringify(value);
6583
+ }
6584
+ return String(value);
6585
+ };
6586
+ const renderFieldsContent = (fields, data, formatMessage, column) => {
6587
+ const list = (fields || []).filter(field => field && !field.hidden && field.name).map(field => ({
6588
+ label: field.label || field.name,
6589
+ content: formatFieldValue(field, getByPath(data, field.name), formatMessage),
6590
+ block: field.block || undefined
6591
+ }));
6592
+ if (!list.length) {
6593
+ return null;
6594
+ }
6595
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage.Content, {
6596
+ col: column || 2,
6597
+ list: list
6598
+ });
6599
+ };
6600
+ const renderBlockList = (blocks, data, ctx) => (blocks || []).map(block => renderBlock(block, data, ctx)).filter(Boolean);
6601
+ const renderBlock = (block, data, ctx) => {
6602
+ const {
6603
+ formatMessage,
6604
+ isMobile,
6605
+ depth = 0
6606
+ } = ctx;
6607
+ if (!block || depth > MAX_BLOCK_DEPTH) {
6608
+ return null;
6609
+ }
6610
+ const nextCtx = {
6611
+ ...ctx,
6612
+ depth: depth + 1
6613
+ };
6614
+ const bordered = isMobile ? false : block.bordered || undefined;
6615
+ const partProps = {
6616
+ key: block.id,
6617
+ title: block.title || block.label || undefined,
6618
+ subtitle: block.subtitle || undefined,
6619
+ bordered
6620
+ };
6621
+ switch (block.kind) {
6622
+ case 'formInfo':
6623
+ {
6624
+ return /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
6625
+ ...partProps,
6626
+ children: [renderFieldsContent(block.list, data, formatMessage, block.column), renderBlockList(block.blocks, data, nextCtx)]
6627
+ });
6628
+ }
6629
+ case 'object':
6630
+ {
6631
+ const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
6632
+ const nestedData = name ? getByPath(data, name) || {} : data;
6633
+ return /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
6634
+ ...partProps,
6635
+ children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column), renderBlockList(block.blocks, nestedData, nextCtx)]
6636
+ });
6637
+ }
6638
+ case 'list':
6639
+ case 'tableList':
6640
+ {
6641
+ const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
6642
+ const items = name ? getByPath(data, name) : null;
6643
+ const rows = Array.isArray(items) ? items : [];
6644
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage__default["default"].Part, {
6645
+ ...partProps,
6646
+ children: rows.length ? rows.map((item, index) => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
6647
+ title: formatMessage({
6648
+ id: 'schemaContentItemIndex'
6649
+ }, {
6650
+ index: index + 1
6651
+ }),
6652
+ bordered: false,
6653
+ children: [renderFieldsContent(block.list, item || {}, formatMessage, 2), block.kind === 'list' ? renderBlockList(block.itemBlocks, item || {}, nextCtx) : null]
6654
+ }, `${block.id}-${index}`)) : formatMessage({
6655
+ id: 'schemaContentEmptyValue'
6656
+ })
6657
+ });
6658
+ }
6659
+ case 'multiField':
6660
+ {
6661
+ const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
6662
+ const values = name ? getByPath(data, name) : null;
6663
+ const itemField = {
6664
+ type: block.fieldType || 'Input',
6665
+ label: block.label,
6666
+ props: {}
6667
+ };
6668
+ const content = Array.isArray(values) ? values.map(item => formatFieldValue(itemField, item, formatMessage)).join('、') : formatFieldValue(itemField, values, formatMessage);
6669
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage__default["default"].Part, {
6670
+ ...partProps,
6671
+ children: /*#__PURE__*/jsxRuntime.jsx(InfoPage.Content, {
6672
+ col: 1,
6673
+ list: [{
6674
+ label: block.label || block.name,
6675
+ content,
6676
+ block: true
6677
+ }]
6678
+ })
6679
+ });
6680
+ }
6681
+ case 'steps':
6682
+ {
6683
+ return /*#__PURE__*/jsxRuntime.jsx(react.Fragment, {
6684
+ children: (block.items || []).map(step => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
6685
+ title: step.title || undefined,
6686
+ bordered: bordered,
6687
+ children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2), renderBlockList(step.blocks, data, nextCtx)]
6688
+ }, step.id))
6689
+ }, block.id);
6690
+ }
6691
+ case 'choice':
6692
+ {
6693
+ const selectorName = resolveChoiceSelectorName(block);
6694
+ const selectorValue = block.selectorInData === false ? undefined : getByPath(data, selectorName);
6695
+ const selectedIds = block.mode === 'multiple' ? Array.isArray(selectorValue) ? selectorValue.map(String) : [] : selectorValue != null && selectorValue !== '' ? [String(selectorValue)] : [];
6696
+ const options = block.options || [];
6697
+ const visibleOptions = selectedIds.length ? options.filter(option => selectedIds.includes(String(option.id))) : [];
6698
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage__default["default"].Part, {
6699
+ ...partProps,
6700
+ children: visibleOptions.map(option => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
6701
+ title: option.title || undefined,
6702
+ bordered: false,
6703
+ children: [renderFieldsContent(option.list, data, formatMessage, block.column), renderBlockList(option.blocks, data, nextCtx)]
6704
+ }, option.id))
6705
+ });
6706
+ }
6707
+ default:
6708
+ return null;
6709
+ }
6710
+ };
6711
+ const SchemaContentInnerView = _ref => {
6712
+ let {
6713
+ schema,
6714
+ data,
6715
+ className
6716
+ } = _ref;
6717
+ const {
6718
+ formatMessage
6719
+ } = reactIntl.useIntl();
6720
+ const isMobile = responsiveUtils.useIsMobile();
6721
+ const normalized = normalizeSchema(schema);
6722
+ const children = renderBlockList(normalized.blocks, data || {}, {
6723
+ formatMessage,
6724
+ isMobile,
6725
+ depth: 0
6726
+ });
6727
+ if (!children.length) {
6728
+ return null;
6729
+ }
6730
+ if (className) {
6731
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
6732
+ className: className,
6733
+ children: children
6734
+ });
6735
+ }
6736
+ return /*#__PURE__*/jsxRuntime.jsx(react.Fragment, {
6737
+ children: children
6738
+ });
6739
+ };
6740
+ const SchemaContentInner = withLocale$1(SchemaContentInnerView);
6741
+ const SchemaContent = withLocale$1(_ref2 => {
6742
+ let {
6743
+ schema,
6744
+ data,
6745
+ className,
6746
+ empty
6747
+ } = _ref2;
6748
+ const {
6749
+ formatMessage
6750
+ } = reactIntl.useIntl();
6751
+ const normalized = normalizeSchema(schema);
6752
+ const emptyNode = empty !== undefined ? empty : /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
6753
+ image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
6754
+ description: formatMessage({
6755
+ id: 'schemaContentEmpty'
6756
+ })
6757
+ });
6758
+ if (data == null || !hasRenderableContent(normalized)) {
6759
+ return emptyNode;
6760
+ }
6761
+ return /*#__PURE__*/jsxRuntime.jsx(InfoPage__default["default"], {
6762
+ className: [style['schema-content'], className].filter(Boolean).join(' '),
6763
+ children: /*#__PURE__*/jsxRuntime.jsx(SchemaContentInnerView, {
6764
+ schema: normalized,
6765
+ data: data
6766
+ })
6767
+ });
6768
+ });
6769
+ var SchemaContent$1 = SchemaContent;
6770
+
6427
6771
  exports.FormCreator = FormCreator$1;
6428
6772
  exports.MAX_BLOCK_DEPTH = MAX_BLOCK_DEPTH;
6429
6773
  exports.RULE_LEN_PRESET = RULE_LEN_PRESET;
6430
6774
  exports.RULE_PRESET_ITEMS = RULE_PRESET_ITEMS;
6775
+ exports.SchemaContent = SchemaContent$1;
6776
+ exports.SchemaContentInner = SchemaContentInner;
6431
6777
  exports.SchemaRenderer = SchemaRenderer$1;
6432
6778
  exports.SchemaRendererInner = SchemaRendererInner;
6433
6779
  exports.applyFromPropsSchema = applyFromPropsSchema;