@kne/form-creator 0.1.13 → 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.
@@ -1,5 +1,6 @@
1
1
  import '@kne/form-info/dist/index.css';
2
2
  import '@kne/info-page/dist/index.css';
3
+ import '@kne/button-group/dist/index.css';
3
4
  import { useState, useRef, useMemo, useEffect, useCallback, createElement, Fragment } from 'react';
4
5
  import { Space, Tag, Button, Typography, Flex, Dropdown, Empty, message, Checkbox as Checkbox$1, Input as Input$1, InputNumber as InputNumber$1, Card, Tooltip } from 'antd';
5
6
  import { createWithIntlProvider, useIntl } from '@kne/react-intl';
@@ -12,9 +13,10 @@ import '@kne/super-select/dist/index.css';
12
13
  import '@kne/super-select-plus/dist/index.css';
13
14
  import { jsxs, jsx } from 'react/jsx-runtime';
14
15
  import FormInfo, { FormModal, Form, Steps, MultiField, TableList, List } from '@kne/form-info';
15
- import InfoPage from '@kne/info-page';
16
+ import { ButtonFooter } from '@kne/button-group';
17
+ import InfoPage, { Content } from '@kne/info-page';
16
18
 
17
- var style = {"kne-responsive-boundary":"kne-form-creator_gh14z","kne-responsive-scroll":"kne-form-creator_Kfn6L","form-creator":"kne-form-creator_Xrjrk","editor-pane":"kne-form-creator_Skfuv","preview-pane":"kne-form-creator_v4Lsp","editor-header":"kne-form-creator_WaSS-","block-list-panel":"kne-form-creator_lx8An","form-actions-setting-btn":"kne-form-creator_NekU2","panel-toolbar":"kne-form-creator_t0WxZ","add-block-btn":"kne-form-creator_16Zre","add-inline-btn":"kne-form-creator_iCYdB","ant-btn-disabled":"kne-form-creator_LdGtv","block-list":"kne-form-creator_wK5eK","block-section":"kne-form-creator_15IiK","block-kind-formInfo":"kne-form-creator_D0hoK","block-kind-list":"kne-form-creator_JdPhy","block-kind-tableList":"kne-form-creator_gzd64","block-kind-multiField":"kne-form-creator_t0iOJ","block-kind-steps":"kne-form-creator_QNF9W","step-section":"kne-form-creator_22ajp","block-section-header":"kne-form-creator_wS4rL","block-header-left":"kne-form-creator_t4awC","block-title":"kne-form-creator_wSVJf","block-summary":"kne-form-creator_GzeW8","block-header-actions":"kne-form-creator_Ue-nT","block-body":"kne-form-creator_je1H0","item-blocks-section":"kne-form-creator_wq4bT","nested-block-list":"kne-form-creator_4NWH4","block-section-nested":"kne-form-creator_mUKom","add-field-dropdown":"kne-form-creator_9JS0d","add-field-dropdown-item":"kne-form-creator_Ql1z3","add-field-dropdown-item-icon":"kne-form-creator_ZHB5O","add-field-dropdown-item-desc":"kne-form-creator_dcsOS","add-field-dropdown-divider":"kne-form-creator_CUK0H","add-field-dropdown-label":"kne-form-creator_bPJ-2","section-toolbar":"kne-form-creator_LUO8S","section-toolbar-label":"kne-form-creator_7KQ79","field-list":"kne-form-creator_-B7WZ","step-list":"kne-form-creator_kc1pH","step-section-header":"kne-form-creator_wkhEX","step-section-title":"kne-form-creator_NBinE","step-section-actions":"kne-form-creator_es-FC","step-index":"kne-form-creator_CCKZZ","field-row":"kne-form-creator_XMkdt","field-row-index":"kne-form-creator_a-cDo","field-row-main":"kne-form-creator_ftlwp","inline-empty":"kne-form-creator_yP-RF","action-group":"kne-form-creator_773yo","hover-reveal":"kne-form-creator_S234h","hover-reveal-active":"kne-form-creator_AE-6r","action-btn":"kne-form-creator_mLgqh","add-block-dropdown":"kne-form-creator_vmS-e","add-block-option":"kne-form-creator_gjg2Y","add-block-option-icon":"kne-form-creator_qh1hh","add-block-option-text":"kne-form-creator_G8iJO","add-block-option-title":"kne-form-creator_ETSvm","add-block-option-desc":"kne-form-creator_O0C3l","field-empty":"kne-form-creator_Nmpfl","field-label-tips-icon":"kne-form-creator_0VVaO","preview-header":"kne-form-creator_c4BT0","preview-title":"kne-form-creator_fPkK4","preview-body":"kne-form-creator_6JntQ","schema-form":"kne-form-creator_MxCWP","schema-body":"kne-form-creator_q9ydz","schema-actions":"kne-form-creator_Y4eEH","schema-actions-inner":"kne-form-creator_FT9Zf","choice-block":"kne-form-creator_RllJe","choice-selector":"kne-form-creator_5A1eM","choice-panels":"kne-form-creator_IO0MY","choice-panels-empty":"kne-form-creator_T0nND","choice-option-panel":"kne-form-creator_FQixN","choice-option-panel-title":"kne-form-creator_ofRo2","choice-option-summary":"kne-form-creator_pksH8","field-editor-form":"kne-form-creator_PGPHL","form-actions-editor":"kne-form-creator_fchMy","form-actions-switch-field":"kne-form-creator_6JE9x","form-actions-layout-panel":"kne-form-creator_rtm9D","form-actions-align-group":"kne-form-creator_51ZsV","form-actions-layout-title":"kne-form-creator_hFeiC","form-actions-gap-slider":"kne-form-creator_Gq0bk","editor-section":"kne-form-creator_jJy85","section-divider":"kne-form-creator_zA7L-","rule-editor":"kne-form-creator_bAlGU","options-editor":"kne-form-creator_AK4yO","super-select-props":"kne-form-creator_Iawhh","field-props-editor":"kne-form-creator_Gabf2","columns-editor":"kne-form-creator_DQW1N","prop-row":"kne-form-creator_7K54P","prop-label":"kne-form-creator_HAAyH","options-item":"kne-form-creator_dnOd2","table-row-card":"kne-form-creator_cwCYp","tree-options-editor":"kne-form-creator_s3nHO","tree-options-list":"kne-form-creator_Djs-E","tree-option-node":"kne-form-creator_XAcut","tree-option-row":"kne-form-creator_4K4Rj","tree-option-fields":"kne-form-creator_-4cjc","tree-option-actions":"kne-form-creator_IjCNI","tree-option-children":"kne-form-creator_pVPGJ","tree-add-sibling":"kne-form-creator_bl46P","rule-checkbox-group":"kne-form-creator_tDgVP","rule-len-row":"kne-form-creator_ATsae","rule-len-input":"kne-form-creator_jY4Ld","rule-len-sep":"kne-form-creator_jBDC8","options-list":"kne-form-creator_GUBNS","options-row":"kne-form-creator_uohD0","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","is-mobile":"kne-form-creator_LtgJz"};
19
+ var style = {"kne-responsive-boundary":"kne-form-creator_gh14z","kne-responsive-scroll":"kne-form-creator_Kfn6L","form-creator":"kne-form-creator_Xrjrk","editor-pane":"kne-form-creator_Skfuv","preview-pane":"kne-form-creator_v4Lsp","editor-header":"kne-form-creator_WaSS-","block-list-panel":"kne-form-creator_lx8An","form-actions-setting-btn":"kne-form-creator_NekU2","panel-toolbar":"kne-form-creator_t0WxZ","panel-toolbar-extra":"kne-form-creator_O22ZM","schema-content":"kne-form-creator_9bWOD","add-block-btn":"kne-form-creator_16Zre","add-inline-btn":"kne-form-creator_iCYdB","ant-btn-disabled":"kne-form-creator_LdGtv","block-list":"kne-form-creator_wK5eK","block-section":"kne-form-creator_15IiK","block-kind-formInfo":"kne-form-creator_D0hoK","block-kind-list":"kne-form-creator_JdPhy","block-kind-tableList":"kne-form-creator_gzd64","block-kind-multiField":"kne-form-creator_t0iOJ","block-kind-steps":"kne-form-creator_QNF9W","step-section":"kne-form-creator_22ajp","block-section-header":"kne-form-creator_wS4rL","block-header-left":"kne-form-creator_t4awC","block-title":"kne-form-creator_wSVJf","block-summary":"kne-form-creator_GzeW8","block-header-actions":"kne-form-creator_Ue-nT","block-body":"kne-form-creator_je1H0","item-blocks-section":"kne-form-creator_wq4bT","nested-block-list":"kne-form-creator_4NWH4","block-section-nested":"kne-form-creator_mUKom","add-field-dropdown":"kne-form-creator_9JS0d","add-field-dropdown-item":"kne-form-creator_Ql1z3","add-field-dropdown-item-icon":"kne-form-creator_ZHB5O","add-field-dropdown-item-desc":"kne-form-creator_dcsOS","add-field-dropdown-divider":"kne-form-creator_CUK0H","add-field-dropdown-label":"kne-form-creator_bPJ-2","section-toolbar":"kne-form-creator_LUO8S","section-toolbar-label":"kne-form-creator_7KQ79","field-list":"kne-form-creator_-B7WZ","step-list":"kne-form-creator_kc1pH","step-section-header":"kne-form-creator_wkhEX","step-section-title":"kne-form-creator_NBinE","step-section-actions":"kne-form-creator_es-FC","step-index":"kne-form-creator_CCKZZ","field-row":"kne-form-creator_XMkdt","field-row-index":"kne-form-creator_a-cDo","field-row-main":"kne-form-creator_ftlwp","inline-empty":"kne-form-creator_yP-RF","action-group":"kne-form-creator_773yo","hover-reveal":"kne-form-creator_S234h","hover-reveal-active":"kne-form-creator_AE-6r","action-btn":"kne-form-creator_mLgqh","add-block-dropdown":"kne-form-creator_vmS-e","add-block-option":"kne-form-creator_gjg2Y","add-block-option-icon":"kne-form-creator_qh1hh","add-block-option-text":"kne-form-creator_G8iJO","add-block-option-title":"kne-form-creator_ETSvm","add-block-option-desc":"kne-form-creator_O0C3l","field-empty":"kne-form-creator_Nmpfl","field-label-tips-icon":"kne-form-creator_0VVaO","preview-header":"kne-form-creator_c4BT0","preview-title":"kne-form-creator_fPkK4","preview-body":"kne-form-creator_6JntQ","schema-form":"kne-form-creator_MxCWP","schema-body":"kne-form-creator_q9ydz","schema-actions":"kne-form-creator_Y4eEH","schema-actions-inner":"kne-form-creator_FT9Zf","choice-block":"kne-form-creator_RllJe","choice-selector":"kne-form-creator_5A1eM","choice-panels":"kne-form-creator_IO0MY","choice-panels-empty":"kne-form-creator_T0nND","choice-option-panel":"kne-form-creator_FQixN","choice-option-panel-title":"kne-form-creator_ofRo2","choice-option-summary":"kne-form-creator_pksH8","field-editor-form":"kne-form-creator_PGPHL","form-actions-editor":"kne-form-creator_fchMy","form-actions-switch-field":"kne-form-creator_6JE9x","form-actions-layout-panel":"kne-form-creator_rtm9D","form-actions-align-group":"kne-form-creator_51ZsV","form-actions-layout-title":"kne-form-creator_hFeiC","form-actions-gap-slider":"kne-form-creator_Gq0bk","editor-section":"kne-form-creator_jJy85","section-divider":"kne-form-creator_zA7L-","rule-editor":"kne-form-creator_bAlGU","options-editor":"kne-form-creator_AK4yO","super-select-props":"kne-form-creator_Iawhh","field-props-editor":"kne-form-creator_Gabf2","columns-editor":"kne-form-creator_DQW1N","prop-row":"kne-form-creator_7K54P","prop-label":"kne-form-creator_HAAyH","options-item":"kne-form-creator_dnOd2","table-row-card":"kne-form-creator_cwCYp","tree-options-editor":"kne-form-creator_s3nHO","tree-options-list":"kne-form-creator_Djs-E","tree-option-node":"kne-form-creator_XAcut","tree-option-row":"kne-form-creator_4K4Rj","tree-option-fields":"kne-form-creator_-4cjc","tree-option-actions":"kne-form-creator_IjCNI","tree-option-children":"kne-form-creator_pVPGJ","tree-add-sibling":"kne-form-creator_bl46P","rule-checkbox-group":"kne-form-creator_tDgVP","rule-len-row":"kne-form-creator_ATsae","rule-len-input":"kne-form-creator_jY4Ld","rule-len-sep":"kne-form-creator_jBDC8","options-list":"kne-form-creator_GUBNS","options-row":"kne-form-creator_uohD0","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","is-mobile":"kne-form-creator_LtgJz"};
18
20
 
19
21
  function _extends() {
20
22
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -227,7 +229,12 @@ const locale$1 = {
227
229
  formSettingsTitle: '表单设置',
228
230
  formTitlePlaceholder: '表单标题(可选)',
229
231
  formSubtitlePlaceholder: '表单副标题(可选)',
230
- formColumnPlaceholder: '每行显示列数'
232
+ formColumnPlaceholder: '每行显示列数',
233
+ schemaContentEmpty: '暂无数据',
234
+ schemaContentEmptyValue: '-',
235
+ schemaContentYes: '是',
236
+ schemaContentNo: '否',
237
+ schemaContentItemIndex: '第 {index} 项'
231
238
  };
232
239
  var zhCN = locale$1;
233
240
 
@@ -423,7 +430,12 @@ const locale = {
423
430
  formSettingsTitle: 'Form Settings',
424
431
  formTitlePlaceholder: 'Form title (optional)',
425
432
  formSubtitlePlaceholder: 'Form subtitle (optional)',
426
- formColumnPlaceholder: 'Columns per row'
433
+ formColumnPlaceholder: 'Columns per row',
434
+ schemaContentEmpty: 'No data',
435
+ schemaContentEmptyValue: '-',
436
+ schemaContentYes: 'Yes',
437
+ schemaContentNo: 'No',
438
+ schemaContentItemIndex: 'Item {index}'
427
439
  };
428
440
  var enUS = locale;
429
441
 
@@ -2319,7 +2331,8 @@ const BlockListPanel = ({
2319
2331
  onEditChoiceOption,
2320
2332
  onDeleteChoiceOption,
2321
2333
  onMoveChoiceOption,
2322
- onOpenFormActions
2334
+ onOpenFormActions,
2335
+ extraToolbar
2323
2336
  }) => {
2324
2337
  const {
2325
2338
  formatMessage
@@ -2907,7 +2920,10 @@ const BlockListPanel = ({
2907
2920
  id: 'formActionsSection'
2908
2921
  }),
2909
2922
  onClick: onOpenFormActions
2910
- })]
2923
+ }), extraToolbar ? /*#__PURE__*/jsx("div", {
2924
+ className: style['panel-toolbar-extra'],
2925
+ children: extraToolbar
2926
+ }) : null]
2911
2927
  }), !blocks.length ? /*#__PURE__*/jsx(Empty, {
2912
2928
  className: style['field-empty'],
2913
2929
  image: Empty.PRESENTED_IMAGE_SIMPLE,
@@ -4731,7 +4747,7 @@ const FormActionsEditor = ({
4731
4747
  };
4732
4748
  var FormActionsEditor$1 = FormActionsEditor;
4733
4749
 
4734
- const getByPath = (obj, path) => {
4750
+ const getByPath$1 = (obj, path) => {
4735
4751
  if (obj == null || path == null || path === '') {
4736
4752
  return undefined;
4737
4753
  }
@@ -4775,7 +4791,7 @@ const clearUnselectedOptionFields = (openApi, formData, keepIds, allOptions) =>
4775
4791
  if (!(field != null && field.name)) {
4776
4792
  return;
4777
4793
  }
4778
- const current = getByPath(formData, field.name);
4794
+ const current = getByPath$1(formData, field.name);
4779
4795
  if (current !== undefined) {
4780
4796
  entries.push({
4781
4797
  name: field.name,
@@ -4784,7 +4800,7 @@ const clearUnselectedOptionFields = (openApi, formData, keepIds, allOptions) =>
4784
4800
  }
4785
4801
  });
4786
4802
  collectBlockFieldNames(option.blocks || []).forEach(name => {
4787
- const current = getByPath(formData, name);
4803
+ const current = getByPath$1(formData, name);
4788
4804
  if (current !== undefined) {
4789
4805
  entries.push({
4790
4806
  name,
@@ -4867,7 +4883,7 @@ const ChoiceBlock = ({
4867
4883
  maxLength
4868
4884
  } = mode === 'multiple' ? resolveSelectLimits(block) : {};
4869
4885
  const firstOptionId = options[0] != null ? String(options[0].id) : undefined;
4870
- const rawValue = getByPath(formData || {}, selectorName);
4886
+ const rawValue = getByPath$1(formData || {}, selectorName);
4871
4887
  // 仅随 selector 值变化;勿依赖整个 formData,否则清空未选支字段会触发 options 重算 → CheckboxGroup 死循环
4872
4888
  const selectorValueKey = mode === 'multiple' ? Array.isArray(rawValue) ? rawValue.map(String).join('\0') : String(rawValue != null ? rawValue : '') : String(rawValue != null ? rawValue : '');
4873
4889
 
@@ -5249,6 +5265,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5249
5265
  const renderSchemaInner = (schema, {
5250
5266
  preview: _preview = false,
5251
5267
  className,
5268
+ bodyClassName,
5252
5269
  isMobile: _isMobile = false,
5253
5270
  formatMessage,
5254
5271
  children,
@@ -5263,15 +5280,19 @@ const renderSchemaInner = (schema, {
5263
5280
  if (!contentChildren.length && !children && !actionNode) {
5264
5281
  return null;
5265
5282
  }
5266
- const body = /*#__PURE__*/createElement(Fragment, null, ...contentChildren, children, actionNode || null);
5283
+ const body = /*#__PURE__*/createElement('div', {
5284
+ className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
5285
+ }, ...contentChildren, children);
5286
+ const content = /*#__PURE__*/createElement(Fragment, null, body, actionNode || null);
5267
5287
  return className ? /*#__PURE__*/createElement('div', {
5268
5288
  className
5269
- }, body) : body;
5289
+ }, content) : content;
5270
5290
  };
5271
5291
  const renderSchemaContent = (schema, {
5272
5292
  preview: _preview2 = false,
5273
5293
  formProps: _formProps = {},
5274
5294
  className,
5295
+ bodyClassName,
5275
5296
  isMobile: _isMobile2 = false,
5276
5297
  formatMessage,
5277
5298
  children,
@@ -5290,11 +5311,12 @@ const renderSchemaContent = (schema, {
5290
5311
  return /*#__PURE__*/createElement(Form, _extends({}, _formProps, {
5291
5312
  className: formClassName
5292
5313
  }), /*#__PURE__*/createElement('div', {
5293
- className: style['schema-body']
5314
+ className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
5294
5315
  }, ...contentChildren, children), actionNode || null);
5295
5316
  };
5296
5317
  var renderSchemaContent$1 = renderSchemaContent;
5297
5318
 
5319
+ const joinClass = (...names) => names.filter(Boolean).join(' ');
5298
5320
  const resolveActionNode = ({
5299
5321
  schema,
5300
5322
  formatMessage,
@@ -5310,7 +5332,10 @@ const resolveActionNode = ({
5310
5332
  showReset,
5311
5333
  showCancel,
5312
5334
  actionsAlign,
5313
- actionsGap
5335
+ actionsGap,
5336
+ footerClassName,
5337
+ buttonFooter: _buttonFooter = false,
5338
+ buttonFooterProps
5314
5339
  }) => {
5315
5340
  if (_showActions === false || actions === false || actions === null) {
5316
5341
  return null;
@@ -5340,19 +5365,26 @@ const resolveActionNode = ({
5340
5365
  gap: resolvedGap != null ? resolvedGap : 16,
5341
5366
  wrap: 'wrap'
5342
5367
  };
5368
+ let actionsEl = null;
5343
5369
  if (actions !== undefined) {
5344
- return /*#__PURE__*/createElement('div', {
5345
- className: style['schema-actions']
5370
+ actionsEl = /*#__PURE__*/createElement('div', {
5371
+ className: joinClass(style['schema-actions'], footerClassName)
5346
5372
  }, /*#__PURE__*/createElement(Flex, flexProps, actions));
5347
- }
5348
- if (!resolvedShowSubmit && !resolvedShowReset && !resolvedShowCancel) {
5373
+ } else if (resolvedShowSubmit || resolvedShowReset || resolvedShowCancel) {
5374
+ actionsEl = /*#__PURE__*/createElement('div', {
5375
+ className: joinClass(style['schema-actions'], footerClassName)
5376
+ }, /*#__PURE__*/createElement(Flex, flexProps, resolvedShowSubmit ? /*#__PURE__*/createElement(SubmitButton, _extends({
5377
+ type: 'primary'
5378
+ }, resolvedSubmitButtonProps), resolvedSubmitText) : null, resolvedShowReset ? /*#__PURE__*/createElement(ResetButton, resolvedResetButtonProps, resolvedResetText) : null, resolvedShowCancel ? /*#__PURE__*/createElement(CancelButton, resolvedCancelButtonProps, resolvedCancelText) : null));
5379
+ }
5380
+ if (!actionsEl) {
5349
5381
  return null;
5350
5382
  }
5351
- return /*#__PURE__*/createElement('div', {
5352
- className: style['schema-actions']
5353
- }, /*#__PURE__*/createElement(Flex, flexProps, resolvedShowSubmit ? /*#__PURE__*/createElement(SubmitButton, _extends({
5354
- type: 'primary'
5355
- }, resolvedSubmitButtonProps), resolvedSubmitText) : null, resolvedShowReset ? /*#__PURE__*/createElement(ResetButton, resolvedResetButtonProps, resolvedResetText) : null, resolvedShowCancel ? /*#__PURE__*/createElement(CancelButton, resolvedCancelButtonProps, resolvedCancelText) : null));
5383
+ if (!_buttonFooter) {
5384
+ return actionsEl;
5385
+ }
5386
+ const footerProps = buttonFooterProps || {};
5387
+ return /*#__PURE__*/createElement(ButtonFooter, footerProps, actionsEl);
5356
5388
  };
5357
5389
  const SchemaRendererInner = withLocale$1(props => {
5358
5390
  const {
@@ -5372,7 +5404,11 @@ const SchemaRendererInner = withLocale$1(props => {
5372
5404
  showReset,
5373
5405
  showCancel,
5374
5406
  actionsAlign,
5375
- actionsGap
5407
+ actionsGap,
5408
+ bodyClassName,
5409
+ footerClassName,
5410
+ buttonFooter = false,
5411
+ buttonFooterProps
5376
5412
  } = props;
5377
5413
  const {
5378
5414
  formatMessage
@@ -5397,11 +5433,15 @@ const SchemaRendererInner = withLocale$1(props => {
5397
5433
  showReset,
5398
5434
  showCancel,
5399
5435
  actionsAlign,
5400
- actionsGap
5436
+ actionsGap,
5437
+ footerClassName,
5438
+ buttonFooter,
5439
+ buttonFooterProps
5401
5440
  });
5402
5441
  return renderSchemaInner(normalized, {
5403
5442
  preview,
5404
5443
  className,
5444
+ bodyClassName,
5405
5445
  isMobile,
5406
5446
  formatMessage,
5407
5447
  children,
@@ -5427,7 +5467,11 @@ const SchemaRenderer = withLocale$1(props => {
5427
5467
  showReset,
5428
5468
  showCancel,
5429
5469
  actionsAlign,
5430
- actionsGap
5470
+ actionsGap,
5471
+ bodyClassName,
5472
+ footerClassName,
5473
+ buttonFooter = false,
5474
+ buttonFooterProps
5431
5475
  } = props;
5432
5476
  const {
5433
5477
  formatMessage
@@ -5452,12 +5496,16 @@ const SchemaRenderer = withLocale$1(props => {
5452
5496
  showReset,
5453
5497
  showCancel,
5454
5498
  actionsAlign,
5455
- actionsGap
5499
+ actionsGap,
5500
+ footerClassName,
5501
+ buttonFooter,
5502
+ buttonFooterProps
5456
5503
  });
5457
5504
  return renderSchemaContent$1(normalized, {
5458
5505
  preview,
5459
5506
  formProps,
5460
5507
  className,
5508
+ bodyClassName,
5461
5509
  isMobile,
5462
5510
  formatMessage,
5463
5511
  children,
@@ -5473,7 +5521,8 @@ const FormCreator = withLocale$1(({
5473
5521
  showPreview: _showPreview = true,
5474
5522
  className,
5475
5523
  formProps,
5476
- renderModal
5524
+ renderModal,
5525
+ extraToolbar
5477
5526
  }) => {
5478
5527
  const {
5479
5528
  formatMessage
@@ -5759,6 +5808,9 @@ const FormCreator = withLocale$1(({
5759
5808
  stepId: fieldContext.stepId,
5760
5809
  optionId: fieldContext.optionId
5761
5810
  }) : [];
5811
+ const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
5812
+ schema
5813
+ }) : extraToolbar;
5762
5814
  return /*#__PURE__*/jsxs("div", {
5763
5815
  className: [style['form-creator'], RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
5764
5816
  children: [/*#__PURE__*/jsx("div", {
@@ -5781,7 +5833,8 @@ const FormCreator = withLocale$1(({
5781
5833
  onEditChoiceOption: handleEditChoiceOption,
5782
5834
  onDeleteChoiceOption: handleDeleteChoiceOption,
5783
5835
  onMoveChoiceOption: handleMoveChoiceOption,
5784
- onOpenFormActions: () => setFormActionsOpen(true)
5836
+ onOpenFormActions: () => setFormActionsOpen(true),
5837
+ extraToolbar: toolbarExtra
5785
5838
  })
5786
5839
  }), _showPreview ? /*#__PURE__*/jsx("div", {
5787
5840
  className: style['preview-pane'],
@@ -5903,7 +5956,7 @@ const createObjectLayer = () => ({
5903
5956
  composites: []
5904
5957
  });
5905
5958
  const isReq = rule => parseRuleString(rule).presets.includes('REQ');
5906
- const resolveChoiceSelectorName = block => {
5959
+ const resolveChoiceSelectorName$1 = block => {
5907
5960
  var _block$discriminator;
5908
5961
  if (block.selectorName != null && String(block.selectorName).trim()) {
5909
5962
  return String(block.selectorName).trim();
@@ -6077,7 +6130,7 @@ const walkBlock = (block, layer, depth = 0) => {
6077
6130
  const mergeChoiceIntoLayer = (layer, block, depth) => {
6078
6131
  const mode = block.mode === 'multiple' ? 'multiple' : 'single';
6079
6132
  const selectorInData = block.selectorInData !== false;
6080
- const selectorName = resolveChoiceSelectorName(block);
6133
+ const selectorName = resolveChoiceSelectorName$1(block);
6081
6134
  const options = block.options || [];
6082
6135
  const optionIds = options.map(option => String(option.id));
6083
6136
  const branches = options.map((option, index) => {
@@ -6184,5 +6237,290 @@ const schemaToDataSchema = (schema, options = {}) => {
6184
6237
  return root;
6185
6238
  };
6186
6239
 
6187
- export { FormCreator$1 as FormCreator, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectBlockFieldNames, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, findBlockInTree, formValuesToBlock, formValuesToField, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasRenderableContent, isFieldNameUnique, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, removeBlockInTree, resolveFieldValueSchema, schemaToDataSchema, updateBlocks };
6240
+ const getByPath = (data, path) => {
6241
+ if (data == null || path == null || path === '') {
6242
+ return data;
6243
+ }
6244
+ return String(path).split('.').reduce((acc, key) => acc == null ? acc : acc[key], data);
6245
+ };
6246
+ const isEmptyValue = value => {
6247
+ if (value == null || value === '') {
6248
+ return true;
6249
+ }
6250
+ if (Array.isArray(value) && value.length === 0) {
6251
+ return true;
6252
+ }
6253
+ return false;
6254
+ };
6255
+ const resolveChoiceSelectorName = block => {
6256
+ var _block$discriminator;
6257
+ if (block.selectorName != null && String(block.selectorName).trim()) {
6258
+ return String(block.selectorName).trim();
6259
+ }
6260
+ if ((_block$discriminator = block.discriminator) != null && _block$discriminator.propertyName) {
6261
+ return String(block.discriminator.propertyName).trim();
6262
+ }
6263
+ return `__choice_${block.id}`;
6264
+ };
6265
+ const formatDateValue = (value, format) => {
6266
+ const pattern = format || 'YYYY-MM-DD';
6267
+ if (Array.isArray(value)) {
6268
+ return value.map(item => formatDateValue(item, format)).filter(item => item !== '').join(' ~ ');
6269
+ }
6270
+ if (value && typeof value.format === 'function') {
6271
+ return value.format(pattern);
6272
+ }
6273
+ return value == null ? '' : String(value);
6274
+ };
6275
+ const mapOptionLabel = (value, options) => {
6276
+ var _match$label;
6277
+ if (!Array.isArray(options) || !options.length) {
6278
+ return value;
6279
+ }
6280
+ const match = options.find(item => item && item.value === value);
6281
+ return (_match$label = match == null ? void 0 : match.label) != null ? _match$label : value;
6282
+ };
6283
+ const formatFieldValue = (field, value, formatMessage) => {
6284
+ if (isEmptyValue(value)) {
6285
+ return formatMessage({
6286
+ id: 'schemaContentEmptyValue'
6287
+ });
6288
+ }
6289
+ const definition = getFieldDefinition(field.type);
6290
+ const props = field.props || {};
6291
+ const valueSchema = resolveFieldValueSchema(field);
6292
+ const schemaType = valueSchema == null ? void 0 : valueSchema.type;
6293
+ if (schemaType === 'boolean' || field.type === 'Switch' || field.type === 'Checkbox') {
6294
+ if (value) {
6295
+ return props.checkedChildren || formatMessage({
6296
+ id: 'schemaContentYes'
6297
+ });
6298
+ }
6299
+ return props.unCheckedChildren || formatMessage({
6300
+ id: 'schemaContentNo'
6301
+ });
6302
+ }
6303
+ if (field.type === 'DatePicker') {
6304
+ const formatted = formatDateValue(value, props.format);
6305
+ return formatted || formatMessage({
6306
+ id: 'schemaContentEmptyValue'
6307
+ });
6308
+ }
6309
+ if (Array.isArray(props.options) && props.options.length) {
6310
+ if (Array.isArray(value)) {
6311
+ const labels = value.map(item => mapOptionLabel(item, props.options)).filter(item => item != null && item !== '');
6312
+ return labels.length ? labels.join('、') : formatMessage({
6313
+ id: 'schemaContentEmptyValue'
6314
+ });
6315
+ }
6316
+ return mapOptionLabel(value, props.options);
6317
+ }
6318
+ if (definition != null && definition.isSuperSelect) {
6319
+ const labelKey = props.labelKey || 'label';
6320
+ const pickLabel = item => {
6321
+ if (item && typeof item === 'object') {
6322
+ var _ref, _item$labelKey;
6323
+ return (_ref = (_item$labelKey = item[labelKey]) != null ? _item$labelKey : item.label) != null ? _ref : item.value;
6324
+ }
6325
+ return item;
6326
+ };
6327
+ if (Array.isArray(value)) {
6328
+ const labels = value.map(pickLabel).filter(item => item != null && item !== '');
6329
+ return labels.length ? labels.join('、') : formatMessage({
6330
+ id: 'schemaContentEmptyValue'
6331
+ });
6332
+ }
6333
+ if (value && typeof value === 'object') {
6334
+ var _pickLabel;
6335
+ return (_pickLabel = pickLabel(value)) != null ? _pickLabel : formatMessage({
6336
+ id: 'schemaContentEmptyValue'
6337
+ });
6338
+ }
6339
+ }
6340
+ if (Array.isArray(value)) {
6341
+ return value.map(item => item && typeof item === 'object' ? JSON.stringify(item) : String(item)).join('、');
6342
+ }
6343
+ if (typeof value === 'object') {
6344
+ return JSON.stringify(value);
6345
+ }
6346
+ return String(value);
6347
+ };
6348
+ const renderFieldsContent = (fields, data, formatMessage, column) => {
6349
+ const list = (fields || []).filter(field => field && !field.hidden && field.name).map(field => ({
6350
+ label: field.label || field.name,
6351
+ content: formatFieldValue(field, getByPath(data, field.name), formatMessage),
6352
+ block: field.block || undefined
6353
+ }));
6354
+ if (!list.length) {
6355
+ return null;
6356
+ }
6357
+ return /*#__PURE__*/jsx(Content, {
6358
+ col: column || 2,
6359
+ list: list
6360
+ });
6361
+ };
6362
+ const renderBlockList = (blocks, data, ctx) => (blocks || []).map(block => renderBlock(block, data, ctx)).filter(Boolean);
6363
+ const renderBlock = (block, data, ctx) => {
6364
+ const {
6365
+ formatMessage,
6366
+ isMobile,
6367
+ depth = 0
6368
+ } = ctx;
6369
+ if (!block || depth > MAX_BLOCK_DEPTH) {
6370
+ return null;
6371
+ }
6372
+ const nextCtx = _extends({}, ctx, {
6373
+ depth: depth + 1
6374
+ });
6375
+ const bordered = isMobile ? false : block.bordered || undefined;
6376
+ const partProps = {
6377
+ key: block.id,
6378
+ title: block.title || block.label || undefined,
6379
+ subtitle: block.subtitle || undefined,
6380
+ bordered
6381
+ };
6382
+ switch (block.kind) {
6383
+ case 'formInfo':
6384
+ {
6385
+ return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
6386
+ children: [renderFieldsContent(block.list, data, formatMessage, block.column), renderBlockList(block.blocks, data, nextCtx)]
6387
+ }));
6388
+ }
6389
+ case 'object':
6390
+ {
6391
+ const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
6392
+ const nestedData = name ? getByPath(data, name) || {} : data;
6393
+ return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
6394
+ children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column), renderBlockList(block.blocks, nestedData, nextCtx)]
6395
+ }));
6396
+ }
6397
+ case 'list':
6398
+ case 'tableList':
6399
+ {
6400
+ const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
6401
+ const items = name ? getByPath(data, name) : null;
6402
+ const rows = Array.isArray(items) ? items : [];
6403
+ return /*#__PURE__*/jsx(InfoPage.Part, _extends({}, partProps, {
6404
+ children: rows.length ? rows.map((item, index) => /*#__PURE__*/jsxs(InfoPage.Part, {
6405
+ title: formatMessage({
6406
+ id: 'schemaContentItemIndex'
6407
+ }, {
6408
+ index: index + 1
6409
+ }),
6410
+ bordered: false,
6411
+ children: [renderFieldsContent(block.list, item || {}, formatMessage, 2), block.kind === 'list' ? renderBlockList(block.itemBlocks, item || {}, nextCtx) : null]
6412
+ }, `${block.id}-${index}`)) : formatMessage({
6413
+ id: 'schemaContentEmptyValue'
6414
+ })
6415
+ }));
6416
+ }
6417
+ case 'multiField':
6418
+ {
6419
+ const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
6420
+ const values = name ? getByPath(data, name) : null;
6421
+ const itemField = {
6422
+ type: block.fieldType || 'Input',
6423
+ label: block.label,
6424
+ props: {}
6425
+ };
6426
+ const content = Array.isArray(values) ? values.map(item => formatFieldValue(itemField, item, formatMessage)).join('、') : formatFieldValue(itemField, values, formatMessage);
6427
+ return /*#__PURE__*/jsx(InfoPage.Part, _extends({}, partProps, {
6428
+ children: /*#__PURE__*/jsx(Content, {
6429
+ col: 1,
6430
+ list: [{
6431
+ label: block.label || block.name,
6432
+ content,
6433
+ block: true
6434
+ }]
6435
+ })
6436
+ }));
6437
+ }
6438
+ case 'steps':
6439
+ {
6440
+ return /*#__PURE__*/jsx(Fragment, {
6441
+ children: (block.items || []).map(step => /*#__PURE__*/jsxs(InfoPage.Part, {
6442
+ title: step.title || undefined,
6443
+ bordered: bordered,
6444
+ children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2), renderBlockList(step.blocks, data, nextCtx)]
6445
+ }, step.id))
6446
+ }, block.id);
6447
+ }
6448
+ case 'choice':
6449
+ {
6450
+ const selectorName = resolveChoiceSelectorName(block);
6451
+ const selectorValue = block.selectorInData === false ? undefined : getByPath(data, selectorName);
6452
+ const selectedIds = block.mode === 'multiple' ? Array.isArray(selectorValue) ? selectorValue.map(String) : [] : selectorValue != null && selectorValue !== '' ? [String(selectorValue)] : [];
6453
+ const options = block.options || [];
6454
+ const visibleOptions = selectedIds.length ? options.filter(option => selectedIds.includes(String(option.id))) : [];
6455
+ return /*#__PURE__*/jsx(InfoPage.Part, _extends({}, partProps, {
6456
+ children: visibleOptions.map(option => /*#__PURE__*/jsxs(InfoPage.Part, {
6457
+ title: option.title || undefined,
6458
+ bordered: false,
6459
+ children: [renderFieldsContent(option.list, data, formatMessage, block.column), renderBlockList(option.blocks, data, nextCtx)]
6460
+ }, option.id))
6461
+ }));
6462
+ }
6463
+ default:
6464
+ return null;
6465
+ }
6466
+ };
6467
+ const SchemaContentInnerView = ({
6468
+ schema,
6469
+ data,
6470
+ className
6471
+ }) => {
6472
+ const {
6473
+ formatMessage
6474
+ } = useIntl();
6475
+ const isMobile = useIsMobile();
6476
+ const normalized = normalizeSchema(schema);
6477
+ const children = renderBlockList(normalized.blocks, data || {}, {
6478
+ formatMessage,
6479
+ isMobile,
6480
+ depth: 0
6481
+ });
6482
+ if (!children.length) {
6483
+ return null;
6484
+ }
6485
+ if (className) {
6486
+ return /*#__PURE__*/jsx("div", {
6487
+ className: className,
6488
+ children: children
6489
+ });
6490
+ }
6491
+ return /*#__PURE__*/jsx(Fragment, {
6492
+ children: children
6493
+ });
6494
+ };
6495
+ const SchemaContentInner = withLocale$1(SchemaContentInnerView);
6496
+ const SchemaContent = withLocale$1(({
6497
+ schema,
6498
+ data,
6499
+ className,
6500
+ empty
6501
+ }) => {
6502
+ const {
6503
+ formatMessage
6504
+ } = useIntl();
6505
+ const normalized = normalizeSchema(schema);
6506
+ const emptyNode = empty !== undefined ? empty : /*#__PURE__*/jsx(Empty, {
6507
+ image: Empty.PRESENTED_IMAGE_SIMPLE,
6508
+ description: formatMessage({
6509
+ id: 'schemaContentEmpty'
6510
+ })
6511
+ });
6512
+ if (data == null || !hasRenderableContent(normalized)) {
6513
+ return emptyNode;
6514
+ }
6515
+ return /*#__PURE__*/jsx(InfoPage, {
6516
+ className: [style['schema-content'], className].filter(Boolean).join(' '),
6517
+ children: /*#__PURE__*/jsx(SchemaContentInnerView, {
6518
+ schema: normalized,
6519
+ data: data
6520
+ })
6521
+ });
6522
+ });
6523
+ var SchemaContent$1 = SchemaContent;
6524
+
6525
+ export { FormCreator$1 as FormCreator, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaContent$1 as SchemaContent, SchemaContentInner, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectBlockFieldNames, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, findBlockInTree, formValuesToBlock, formValuesToField, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasRenderableContent, isFieldNameUnique, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, removeBlockInTree, resolveFieldValueSchema, schemaToDataSchema, updateBlocks };
6188
6526
  //# sourceMappingURL=index.modern.js.map