@kne/form-creator 0.1.23 → 0.1.25

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
@@ -23,7 +23,7 @@ var SelectList__default = /*#__PURE__*/_interopDefaultLegacy(SelectList);
23
23
  var FormInfo__default = /*#__PURE__*/_interopDefaultLegacy(FormInfo);
24
24
  var InfoPage__default = /*#__PURE__*/_interopDefaultLegacy(InfoPage);
25
25
 
26
- var style = {"kne-responsive-boundary":"kne-form-creator_gh14z","kne-responsive-scroll":"kne-form-creator_Kfn6L","option-group-stack":"kne-form-creator_TgBT-","form-info-show-index":"kne-form-creator_rqCos","field-label-index":"kne-form-creator_MLY0O","field-label-main":"kne-form-creator_UOUb4","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-fields":"kne-form-creator_EmRDV","schema-content-field":"kne-form-creator_0Lanz","schema-content-field-block":"kne-form-creator_TQd-w","schema-content-field-label":"kne-form-creator_czEK3","schema-content-field-value":"kne-form-creator_YFKTK","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-editableList":"kne-form-creator_JzwrQ","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","option-group-stack":"kne-form-creator_TgBT-","form-info-show-index":"kne-form-creator_rqCos","field-label-index":"kne-form-creator_MLY0O","field-label-main":"kne-form-creator_UOUb4","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-fields":"kne-form-creator_EmRDV","schema-content-field":"kne-form-creator_0Lanz","schema-content-field-block":"kne-form-creator_TQd-w","schema-content-field-label":"kne-form-creator_czEK3","schema-content-field-value":"kne-form-creator_YFKTK","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-editableList":"kne-form-creator_JzwrQ","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-summary-type":"kne-form-creator_0iyhP","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","field-row-label":"kne-form-creator_XAxbE","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","visible-when-editor":"kne-form-creator_ttGnB","visible-when-hint":"kne-form-creator_hPtdv","visible-when-list":"kne-form-creator_aoAt6","visible-when-row":"kne-form-creator_phRgr","visible-when-row-main":"kne-form-creator_l-J7d","visible-when-field":"kne-form-creator_YRh5W","visible-when-operator":"kne-form-creator_DIqFq","visible-when-value":"kne-form-creator_CHcia","visible-when-regex":"kne-form-creator_lKpVo","visible-when-flags":"kne-form-creator_Ps-cu","visible-when-regex-tester":"kne-form-creator_Wf4eG","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","locale-text":"kne-form-creator_hMXkE","is-compact":"kne-form-creator_jBFpL","locale-text-item":"kne-form-creator_NqCQD","locale-text-prefix":"kne-form-creator_BQl2X","options-locale-text":"kne-form-creator_7-99l","locale-text-tag":"kne-form-creator_65OWA","is-mobile":"kne-form-creator_LtgJz"};
27
27
 
28
28
  const locale$1 = {
29
29
  addField: '添加填写项',
@@ -160,6 +160,8 @@ const locale$1 = {
160
160
  fieldBlock: '占满整行',
161
161
  fieldHidden: '隐藏该项',
162
162
  fieldHiddenTag: '已隐藏',
163
+ fieldLockedTag: '固定',
164
+ fieldLockedTips: '固定填写项,不可编辑、删除或移动',
163
165
  fieldBlockTag: '整行',
164
166
  fieldNameDuplicate: '该名称已被使用,请换一个',
165
167
  untitledField: '未命名填写项',
@@ -265,9 +267,57 @@ const locale$1 = {
265
267
  schemaContentNo: '否',
266
268
  schemaContentItemIndex: '第 {index} 项',
267
269
  schemaContentUntilToday: '至今',
268
- schemaContentPasswordMasked: '••••••'
269
- };
270
- var defaultLocale = locale$1;
270
+ schemaContentPasswordMasked: '••••••',
271
+ ruleErrorTEL: '请输入有效的手机号',
272
+ ruleErrorEMAIL: '请输入有效的邮箱',
273
+ ruleErrorLenEqual: '%s长度必须等于{end}',
274
+ ruleErrorLenMin: '%s长度必须大于{start}',
275
+ ruleErrorLenMax: '%s长度必须小于{end}',
276
+ localeTextFallback: '留空时使用{language}',
277
+ visibleWhenTitle: '条件显示',
278
+ visibleWhenEnable: '满足条件时才显示',
279
+ visibleWhenEnableTips: '不满足条件时隐藏该填写项,并清空其已填写的值',
280
+ visibleWhenLogic: '满足方式',
281
+ conditionLogic_and: '全部满足',
282
+ conditionLogic_or: '满足任一',
283
+ visibleWhenAddCondition: '添加条件',
284
+ visibleWhenField: '触发填写项',
285
+ visibleWhenOperator: '判断',
286
+ visibleWhenValue: '值',
287
+ visibleWhenNoTrigger: '暂无可作为条件的填写项(列表类模块中的填写项不支持)',
288
+ visibleWhenListUnsupported: '列表类模块中的填写项不支持条件显示',
289
+ visibleWhenRegexInvalid: '正则表达式无效',
290
+ visibleWhenRegexFlags: '修饰符',
291
+ visibleWhenRegexFlag_i: 'i 忽略大小写',
292
+ visibleWhenRegexFlag_m: 'm 多行',
293
+ visibleWhenRegexFlag_s: 's 点号匹配换行',
294
+ visibleWhenRegexFlag_u: 'u Unicode',
295
+ visibleWhenRegexTester: '测试文本',
296
+ visibleWhenRegexMatched: '匹配',
297
+ visibleWhenRegexNotMatched: '不匹配',
298
+ visibleWhenConditionRequired: '请完善条件:选择触发填写项并填写值',
299
+ visibleWhenCycle: '条件形成循环依赖:{path}',
300
+ fieldConditionTag: '条件显示',
301
+ fieldConditionInvalidTag: '条件失效',
302
+ fieldConditionInvalidTips: '条件引用的填写项已不存在或不可用,该条件被忽略',
303
+ conditionOperator_eq: '等于',
304
+ conditionOperator_neq: '不等于',
305
+ conditionOperator_in: '属于其一',
306
+ conditionOperator_includesAny: '包含任一',
307
+ conditionOperator_empty: '为空',
308
+ conditionOperator_notEmpty: '不为空',
309
+ conditionOperator_gt: '大于',
310
+ conditionOperator_gte: '大于等于',
311
+ conditionOperator_lt: '小于',
312
+ conditionOperator_lte: '小于等于',
313
+ conditionOperator_regex: '匹配正则',
314
+ conditionJoinAnd: ' 且 ',
315
+ conditionJoinOr: ' 或 ',
316
+ conditionValueTrue: '是',
317
+ conditionValueFalse: '否',
318
+ conditionDescription: '满足条件时显示:{condition}'
319
+ };
320
+ var zhCN = locale$1;
271
321
 
272
322
  const locale = {
273
323
  addField: 'Add Field',
@@ -404,6 +454,8 @@ const locale = {
404
454
  fieldBlock: 'Full Width',
405
455
  fieldHidden: 'Hidden',
406
456
  fieldHiddenTag: 'Hidden',
457
+ fieldLockedTag: 'Locked',
458
+ fieldLockedTips: 'Locked field: cannot be edited, deleted or moved',
407
459
  fieldBlockTag: 'Full Width',
408
460
  fieldNameDuplicate: 'This name is already in use, please choose another',
409
461
  untitledField: 'Untitled Field',
@@ -509,20 +561,177 @@ const locale = {
509
561
  schemaContentNo: 'No',
510
562
  schemaContentItemIndex: 'Item {index}',
511
563
  schemaContentUntilToday: 'Present',
512
- schemaContentPasswordMasked: '••••••'
564
+ schemaContentPasswordMasked: '••••••',
565
+ ruleErrorTEL: 'Please enter a valid mobile number',
566
+ ruleErrorEMAIL: 'Please enter a valid email address',
567
+ ruleErrorLenEqual: '%s must be exactly {end} characters',
568
+ ruleErrorLenMin: '%s must be at least {start} characters',
569
+ ruleErrorLenMax: '%s must be at most {end} characters',
570
+ localeTextFallback: 'Falls back to {language} when empty',
571
+ visibleWhenTitle: 'Conditional display',
572
+ visibleWhenEnable: 'Show only when conditions are met',
573
+ visibleWhenEnableTips: 'The field is hidden and its value cleared when conditions are not met',
574
+ visibleWhenLogic: 'Match',
575
+ conditionLogic_and: 'All conditions',
576
+ conditionLogic_or: 'Any condition',
577
+ visibleWhenAddCondition: 'Add condition',
578
+ visibleWhenField: 'Trigger field',
579
+ visibleWhenOperator: 'Operator',
580
+ visibleWhenValue: 'Value',
581
+ visibleWhenNoTrigger: 'No field can be used as a condition (fields inside list blocks are not supported)',
582
+ visibleWhenListUnsupported: 'Fields inside list blocks do not support conditional display',
583
+ visibleWhenRegexInvalid: 'Invalid regular expression',
584
+ visibleWhenRegexFlags: 'Flags',
585
+ visibleWhenRegexFlag_i: 'i ignore case',
586
+ visibleWhenRegexFlag_m: 'm multiline',
587
+ visibleWhenRegexFlag_s: 's dot matches newline',
588
+ visibleWhenRegexFlag_u: 'u Unicode',
589
+ visibleWhenRegexTester: 'Test text',
590
+ visibleWhenRegexMatched: 'Matched',
591
+ visibleWhenRegexNotMatched: 'Not matched',
592
+ visibleWhenConditionRequired: 'Complete each condition: choose a trigger field and fill in the value',
593
+ visibleWhenCycle: 'Conditions form a circular dependency: {path}',
594
+ fieldConditionTag: 'Conditional',
595
+ fieldConditionInvalidTag: 'Condition invalid',
596
+ fieldConditionInvalidTips: 'A referenced field no longer exists or is unavailable; that condition is ignored',
597
+ conditionOperator_eq: 'equals',
598
+ conditionOperator_neq: 'does not equal',
599
+ conditionOperator_in: 'is one of',
600
+ conditionOperator_includesAny: 'includes any of',
601
+ conditionOperator_empty: 'is empty',
602
+ conditionOperator_notEmpty: 'is not empty',
603
+ conditionOperator_gt: '>',
604
+ conditionOperator_gte: '>=',
605
+ conditionOperator_lt: '<',
606
+ conditionOperator_lte: '<=',
607
+ conditionOperator_regex: 'matches',
608
+ conditionJoinAnd: ' and ',
609
+ conditionJoinOr: ' or ',
610
+ conditionValueTrue: 'Yes',
611
+ conditionValueFalse: 'No',
612
+ conditionDescription: 'Shown when: {condition}'
513
613
  };
514
614
  var enUS = locale;
515
615
 
516
616
  const withLocale = reactIntl.createWithIntlProvider({
517
617
  defaultLocale: 'zh-CN',
518
618
  messages: {
519
- 'zh-CN': defaultLocale,
619
+ 'zh-CN': zhCN,
520
620
  'en-US': enUS
521
621
  },
522
622
  namespace: 'form-creator'
523
623
  });
524
624
  var withLocale$1 = withLocale;
525
625
 
626
+ /** 未传 languages 时,多语言文案按此顺序回退 */
627
+ const DEFAULT_FALLBACK_LANGUAGES = ['zh-CN', 'en-US'];
628
+ const LOCALE_KEY = /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/;
629
+ const isPlainObject = value => {
630
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
631
+ return false;
632
+ }
633
+ const proto = Object.getPrototypeOf(value);
634
+ return proto === Object.prototype || proto === null;
635
+ };
636
+
637
+ /** 多语言文案:键全为语言代码、值全为字符串,如 { 'zh-CN': '姓名', 'en-US': 'Name' } */
638
+ const isLocaleText = value => {
639
+ if (!isPlainObject(value)) {
640
+ return false;
641
+ }
642
+ const keys = Object.keys(value);
643
+ return keys.length > 0 && keys.every(key => LOCALE_KEY.test(key) && (value[key] == null || typeof value[key] === 'string'));
644
+ };
645
+ const hasText = value => typeof value === 'string' && value.trim() !== '';
646
+
647
+ /** 规范调用方传入的语言列表 [{ value, label }],丢弃无 value 的项 */
648
+ const normalizeLanguages = languages => (Array.isArray(languages) ? languages : []).filter(item => item && typeof item.value === 'string' && item.value).map(item => ({
649
+ value: item.value,
650
+ label: item.label || item.value
651
+ }));
652
+ const getFallbackLanguages = languages => {
653
+ const list = normalizeLanguages(languages);
654
+ return list.length ? list.map(item => item.value) : DEFAULT_FALLBACK_LANGUAGES;
655
+ };
656
+
657
+ /** 普通字符串原样返回;多语言按 locale → languages 顺序(未传为 zh-CN → en-US)取第一个有内容的 */
658
+ const resolveLocaleText = (value, locale, languages) => {
659
+ if (!isLocaleText(value)) {
660
+ return value;
661
+ }
662
+ const language = [locale, ...getFallbackLanguages(languages)].find(key => key && hasText(value[key]));
663
+ return language ? value[language] : '';
664
+ };
665
+
666
+ /** 深度解析 schema(或任意片段)中的多语言文案,返回新对象 */
667
+ const localizeSchema = (value, locale, languages) => {
668
+ if (Array.isArray(value)) {
669
+ return value.map(item => localizeSchema(item, locale, languages));
670
+ }
671
+ if (isLocaleText(value)) {
672
+ return resolveLocaleText(value, locale, languages);
673
+ }
674
+ if (!isPlainObject(value)) {
675
+ return value;
676
+ }
677
+ return Object.keys(value).reduce((result, key) => {
678
+ result[key] = localizeSchema(value[key], locale, languages);
679
+ return result;
680
+ }, {});
681
+ };
682
+
683
+ /** 取某个语言的原始输入值;普通字符串视为基础语言 */
684
+ const getLocaleTextValue = (value, language, baseLanguage) => {
685
+ if (isLocaleText(value)) {
686
+ return value[language] || '';
687
+ }
688
+ if (value == null || typeof value === 'object') {
689
+ return '';
690
+ }
691
+ return language === baseLanguage ? String(value) : '';
692
+ };
693
+
694
+ /** 只有基础语言时存为字符串,保持与单语言 schema 兼容 */
695
+ const toLocaleText = (map = {}, baseLanguage) => {
696
+ const entries = Object.keys(map).filter(key => hasText(map[key])).map(key => [key, map[key]]);
697
+ if (!entries.length) {
698
+ return '';
699
+ }
700
+ if (entries.length === 1 && entries[0][0] === baseLanguage) {
701
+ return entries[0][1];
702
+ }
703
+ return Object.fromEntries(entries);
704
+ };
705
+ const setLocaleTextValue = (value, language, text, baseLanguage) => {
706
+ const map = isLocaleText(value) ? {
707
+ ...value
708
+ } : {
709
+ [baseLanguage]: getLocaleTextValue(value, baseLanguage, baseLanguage)
710
+ };
711
+ map[language] = text;
712
+ return toLocaleText(map, baseLanguage);
713
+ };
714
+
715
+ /** 判断文案(字符串或多语言)是否有内容 */
716
+ const hasLocaleText = value => isLocaleText(value) ? Object.values(value).some(hasText) : value != null && String(value).trim() !== '';
717
+
718
+ /** 去除首尾空白;多语言文案逐项处理 */
719
+ const trimLocaleText = (value, baseLanguage) => {
720
+ if (isLocaleText(value)) {
721
+ return toLocaleText(Object.fromEntries(Object.keys(value).map(key => [key, (value[key] || '').trim()])), baseLanguage);
722
+ }
723
+ return String(value ?? '').trim();
724
+ };
725
+
726
+ /** 由文案派生数据值时用基础语言,保证各语言下值一致;基础语言为空时取第一个有内容的语言 */
727
+ const localeTextToValue = (value, baseLanguage) => {
728
+ if (!isLocaleText(value)) {
729
+ return String(value ?? '').trim();
730
+ }
731
+ const text = resolveLocaleText(value, baseLanguage) || Object.values(value).find(hasText) || '';
732
+ return String(text).trim();
733
+ };
734
+
526
735
  const createFieldId = () => `field_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
527
736
 
528
737
  /** 生成可编辑的默认数据标识,如 field_xxxx / col_xxxx */
@@ -559,6 +768,9 @@ const defaultFormActions = () => ({
559
768
  gap: 16
560
769
  });
561
770
  const FORM_ACTIONS_ALIGN = ['center', 'start', 'end'];
771
+ const normalizeActionText = value => value == null ? '' : isLocaleText(value) ? {
772
+ ...value
773
+ } : String(value);
562
774
  const normalizeFormActions = (actions = {}) => {
563
775
  const base = defaultFormActions();
564
776
  if (!actions || typeof actions !== 'object') {
@@ -571,9 +783,9 @@ const normalizeFormActions = (actions = {}) => {
571
783
  showSubmit: actions.showSubmit !== false,
572
784
  showReset: actions.showReset !== false,
573
785
  showCancel: !!actions.showCancel,
574
- submitText: actions.submitText != null ? String(actions.submitText) : '',
575
- resetText: actions.resetText != null ? String(actions.resetText) : '',
576
- cancelText: actions.cancelText != null ? String(actions.cancelText) : '',
786
+ submitText: normalizeActionText(actions.submitText),
787
+ resetText: normalizeActionText(actions.resetText),
788
+ cancelText: normalizeActionText(actions.cancelText),
577
789
  align,
578
790
  gap,
579
791
  ...(actions.submitButtonProps && typeof actions.submitButtonProps === 'object' ? {
@@ -876,7 +1088,23 @@ const normalizeSchema = (schema = {}) => {
876
1088
  blocks: []
877
1089
  };
878
1090
  };
879
- const moveItem = (list, id, direction) => {
1091
+ const isFieldLocked = field => !!field?.locked;
1092
+ const blockHasLockedField = block => {
1093
+ if (!block) {
1094
+ return false;
1095
+ }
1096
+ if ((block.list || []).some(isFieldLocked)) {
1097
+ return true;
1098
+ }
1099
+ const groups = [...(block.items || []), ...(block.options || [])];
1100
+ if (groups.some(group => (group.list || []).some(isFieldLocked) || (group.blocks || []).some(blockHasLockedField))) {
1101
+ return true;
1102
+ }
1103
+ return [...(block.blocks || []), ...(block.itemBlocks || [])].some(blockHasLockedField);
1104
+ };
1105
+
1106
+ // 锁定项(locked 字段 / 含锁定字段的模块)位置固定:自身不能移动,其他项也不能与其交换位置
1107
+ const moveItem = (list, id, direction, isFixed = isFieldLocked) => {
880
1108
  const index = list.findIndex(item => item.id === id);
881
1109
  if (index < 0) {
882
1110
  return list;
@@ -885,6 +1113,9 @@ const moveItem = (list, id, direction) => {
885
1113
  if (targetIndex < 0 || targetIndex >= list.length) {
886
1114
  return list;
887
1115
  }
1116
+ if (isFixed(list[index]) || isFixed(list[targetIndex])) {
1117
+ return list;
1118
+ }
888
1119
  const next = [...list];
889
1120
  const [item] = next.splice(index, 1);
890
1121
  next.splice(targetIndex, 0, item);
@@ -1196,7 +1427,7 @@ const removeBlockInTree = (blocks, blockId) => {
1196
1427
  };
1197
1428
  const moveBlockInTree = (blocks, blockId, direction) => {
1198
1429
  if ((blocks || []).some(block => block?.id === blockId)) {
1199
- return moveItem(blocks, blockId, direction);
1430
+ return moveItem(blocks, blockId, direction, blockHasLockedField);
1200
1431
  }
1201
1432
  let changed = false;
1202
1433
  const next = (blocks || []).map(block => {
@@ -1471,7 +1702,7 @@ const createApiFromOptions = (options = []) => ({
1471
1702
  });
1472
1703
 
1473
1704
  const {
1474
- useOnChange: useOnChange$1
1705
+ useOnChange: useOnChange$2
1475
1706
  } = reactFormAntd.hooks;
1476
1707
  const hasNestedOptions = options => Array.isArray(options) && options.some(item => Array.isArray(item?.children) && item.children.length);
1477
1708
  const createField = (Component, {
@@ -1507,7 +1738,7 @@ const createField = (Component, {
1507
1738
  }, {
1508
1739
  label: props.label || ''
1509
1740
  }).trim();
1510
- const render = useOnChange$1(Object.assign({}, {
1741
+ const render = useOnChange$2(Object.assign({}, {
1511
1742
  isPopup: true,
1512
1743
  placeholder: resolvedPlaceholder
1513
1744
  }, rest, {
@@ -1611,6 +1842,440 @@ const buildRuleString = ({
1611
1842
  return parts.join(' ') || undefined;
1612
1843
  };
1613
1844
 
1845
+ const CONDITION_OPERATORS = ['eq', 'neq', 'in', 'includesAny', 'empty', 'notEmpty', 'gt', 'gte', 'lt', 'lte', 'regex'];
1846
+ const NO_VALUE_OPERATORS = ['empty', 'notEmpty'];
1847
+ const ALLOWED_REGEX_FLAGS = ['i', 'm', 's', 'u'];
1848
+
1849
+ // 列表类模块内的字段会重复出现,单个 name 定位不到具体条目,不参与条件
1850
+ const LIST_BLOCK_KINDS = ['list', 'tableList', 'editableList', 'multiField'];
1851
+ const getByPath$2 = (data, path) => {
1852
+ if (data == null || path == null || path === '') {
1853
+ return undefined;
1854
+ }
1855
+ return String(path).split('.').reduce((current, key) => current == null ? undefined : current[key], data);
1856
+ };
1857
+ const isEmptyValue$1 = value => value === undefined || value === null || value === '' || Array.isArray(value) && value.length === 0;
1858
+
1859
+ // SuperSelect 等字段的值是 { label, value } 对象,比较时统一取 value
1860
+ const toComparable = item => {
1861
+ if (item && typeof item === 'object' && !Array.isArray(item)) {
1862
+ return item.value ?? item.id ?? item.key ?? item;
1863
+ }
1864
+ return item;
1865
+ };
1866
+ const toArray = value => Array.isArray(value) ? value : isEmptyValue$1(value) ? [] : [value];
1867
+ const sameValue = (a, b) => String(toComparable(a)) === String(toComparable(b));
1868
+ const sanitizeRegexFlags = flags => Array.from(new Set(String(flags || '').split(''))).filter(flag => ALLOWED_REGEX_FLAGS.includes(flag)).join('');
1869
+ const regexCache = new Map();
1870
+
1871
+ /** 编译失败返回 null;以「源码 + flags」缓存 */
1872
+ const compileConditionRegex = (source, flags) => {
1873
+ if (source == null || String(source) === '') {
1874
+ return null;
1875
+ }
1876
+ const safeFlags = sanitizeRegexFlags(flags);
1877
+ const key = `${safeFlags}/${source}`;
1878
+ if (regexCache.has(key)) {
1879
+ return regexCache.get(key);
1880
+ }
1881
+ let regex = null;
1882
+ try {
1883
+ regex = new RegExp(String(source), safeFlags);
1884
+ } catch (error) {
1885
+ regex = null;
1886
+ }
1887
+ regexCache.set(key, regex);
1888
+ return regex;
1889
+ };
1890
+ const toNumber = value => {
1891
+ if (isEmptyValue$1(value) || typeof value === 'boolean') {
1892
+ return NaN;
1893
+ }
1894
+ return Number(value);
1895
+ };
1896
+
1897
+ /**
1898
+ * 返回 true / false;条件本身无效(未知运算符、正则无法编译)时返回 null,由调用方忽略
1899
+ */
1900
+ const evaluateCondition = (condition, formData) => {
1901
+ if (!condition?.field || !CONDITION_OPERATORS.includes(condition.operator)) {
1902
+ return null;
1903
+ }
1904
+ const actual = getByPath$2(formData, condition.field);
1905
+ const expected = condition.value;
1906
+ switch (condition.operator) {
1907
+ case 'empty':
1908
+ return isEmptyValue$1(actual);
1909
+ case 'notEmpty':
1910
+ return !isEmptyValue$1(actual);
1911
+ case 'eq':
1912
+ return !isEmptyValue$1(actual) && !Array.isArray(actual) && sameValue(actual, expected);
1913
+ case 'neq':
1914
+ return isEmptyValue$1(actual) || Array.isArray(actual) || !sameValue(actual, expected);
1915
+ case 'in':
1916
+ return !isEmptyValue$1(actual) && toArray(expected).some(item => sameValue(actual, item));
1917
+ case 'includesAny':
1918
+ {
1919
+ const expectedList = toArray(expected);
1920
+ return toArray(actual).some(item => expectedList.some(target => sameValue(item, target)));
1921
+ }
1922
+ case 'gt':
1923
+ case 'gte':
1924
+ case 'lt':
1925
+ case 'lte':
1926
+ {
1927
+ const a = toNumber(actual);
1928
+ const b = toNumber(expected);
1929
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
1930
+ return false;
1931
+ }
1932
+ return {
1933
+ gt: a > b,
1934
+ gte: a >= b,
1935
+ lt: a < b,
1936
+ lte: a <= b
1937
+ }[condition.operator];
1938
+ }
1939
+ case 'regex':
1940
+ {
1941
+ const regex = compileConditionRegex(expected, condition.flags);
1942
+ if (!regex) {
1943
+ return null;
1944
+ }
1945
+ if (isEmptyValue$1(actual)) {
1946
+ return false;
1947
+ }
1948
+ return toArray(actual).some(item => regex.test(String(toComparable(item))));
1949
+ }
1950
+ default:
1951
+ return null;
1952
+ }
1953
+ };
1954
+ const hasVisibleWhen = field => Array.isArray(field?.visibleWhen?.conditions) && field.visibleWhen.conditions.length > 0;
1955
+
1956
+ /**
1957
+ * knownNames:可作为触发字段的完整路径集合;传入时引用未知字段的条件视为失效
1958
+ * 全部条件失效时返回 true(照常显示)
1959
+ */
1960
+ const evaluateVisibleWhen = (visibleWhen, formData, knownNames) => {
1961
+ const conditions = visibleWhen?.conditions;
1962
+ if (!Array.isArray(conditions) || !conditions.length) {
1963
+ return true;
1964
+ }
1965
+ const results = conditions.map(condition => {
1966
+ if (knownNames && !knownNames.has(condition?.field)) {
1967
+ return null;
1968
+ }
1969
+ return evaluateCondition(condition, formData || {});
1970
+ }).filter(result => result !== null);
1971
+ if (!results.length) {
1972
+ return true;
1973
+ }
1974
+ return visibleWhen.logic === 'or' ? results.some(Boolean) : results.every(Boolean);
1975
+ };
1976
+ const joinPath = (prefix, name) => prefix ? `${prefix}.${name}` : name;
1977
+
1978
+ /**
1979
+ * 收集 schema 中所有字段:{ id, path, field, inList }
1980
+ * path 为提交数据中的完整路径(object 模块带前缀);inList 表示位于列表类模块内
1981
+ */
1982
+ const collectConditionFields = schema => {
1983
+ const result = [];
1984
+ const pushFields = (list, prefix, inList) => {
1985
+ (list || []).forEach(field => {
1986
+ if (field?.name) {
1987
+ result.push({
1988
+ id: field.id,
1989
+ path: joinPath(prefix, field.name),
1990
+ field,
1991
+ inList
1992
+ });
1993
+ }
1994
+ });
1995
+ };
1996
+ // 与 renderSchema 一致:仅 object 模块自身字段带 block.name 前缀,子模块不累加
1997
+ const walk = (blocks, inList) => {
1998
+ (blocks || []).forEach(block => {
1999
+ if (!block) {
2000
+ return;
2001
+ }
2002
+ const blockInList = inList || LIST_BLOCK_KINDS.includes(block.kind);
2003
+ pushFields(block.list, block.kind === 'object' ? block.name || '' : '', blockInList);
2004
+ (block.items || []).forEach(step => {
2005
+ pushFields(step.list, '', blockInList);
2006
+ walk(step.blocks, blockInList);
2007
+ });
2008
+ (block.options || []).forEach(option => {
2009
+ pushFields(option.list, '', blockInList);
2010
+ walk(option.blocks, blockInList);
2011
+ });
2012
+ walk(block.blocks, blockInList);
2013
+ walk(block.itemBlocks, true);
2014
+ });
2015
+ };
2016
+ walk(schema?.blocks, false);
2017
+ return result;
2018
+ };
2019
+
2020
+ /** 字段所在模块的路径前缀与是否位于列表类模块内;找不到返回 null */
2021
+ const getBlockConditionScope = (schema, blockId) => {
2022
+ let found = null;
2023
+ const walk = (blocks, inList) => {
2024
+ (blocks || []).forEach(block => {
2025
+ if (!block || found) {
2026
+ return;
2027
+ }
2028
+ const blockInList = inList || LIST_BLOCK_KINDS.includes(block.kind);
2029
+ if (block.id === blockId) {
2030
+ found = {
2031
+ prefix: block.kind === 'object' ? block.name || '' : '',
2032
+ inList: blockInList
2033
+ };
2034
+ return;
2035
+ }
2036
+ (block.items || []).forEach(step => walk(step.blocks, blockInList));
2037
+ (block.options || []).forEach(option => walk(option.blocks, blockInList));
2038
+ walk(block.blocks, blockInList);
2039
+ walk(block.itemBlocks, true);
2040
+ });
2041
+ };
2042
+ walk(schema?.blocks, false);
2043
+ return found;
2044
+ };
2045
+ const getFieldConditionPath = (scope, name) => name ? joinPath(scope?.prefix || '', name) : '';
2046
+
2047
+ /** 可作为触发字段的路径集合(排除列表类模块内字段) */
2048
+ const collectTriggerNames = schema => new Set(collectConditionFields(schema).filter(item => !item.inList).map(item => item.path));
2049
+
2050
+ /** 某字段的条件里引用了不存在 / 不可用的触发字段 */
2051
+ const hasInvalidCondition = (field, triggerNames) => hasVisibleWhen(field) && field.visibleWhen.conditions.some(condition => !triggerNames.has(condition?.field) || condition.operator === 'regex' && !compileConditionRegex(condition.value, condition.flags));
2052
+ const buildDependencyGraph = schema => {
2053
+ const graph = new Map();
2054
+ collectConditionFields(schema).forEach(({
2055
+ path,
2056
+ field
2057
+ }) => {
2058
+ if (hasVisibleWhen(field)) {
2059
+ graph.set(path, field.visibleWhen.conditions.map(condition => condition?.field).filter(Boolean));
2060
+ }
2061
+ });
2062
+ return graph;
2063
+ };
2064
+
2065
+ /** 返回循环链路(路径数组,首尾相同);无循环返回 null */
2066
+ const findConditionCycle = schema => {
2067
+ const graph = buildDependencyGraph(schema);
2068
+ const state = new Map();
2069
+ const stack = [];
2070
+ const visit = node => {
2071
+ if (state.get(node) === 'done') {
2072
+ return null;
2073
+ }
2074
+ if (state.get(node) === 'visiting') {
2075
+ return [...stack.slice(stack.indexOf(node)), node];
2076
+ }
2077
+ state.set(node, 'visiting');
2078
+ stack.push(node);
2079
+ for (const next of graph.get(node) || []) {
2080
+ const cycle = visit(next);
2081
+ if (cycle) {
2082
+ return cycle;
2083
+ }
2084
+ }
2085
+ stack.pop();
2086
+ state.set(node, 'done');
2087
+ return null;
2088
+ };
2089
+ for (const node of graph.keys()) {
2090
+ const cycle = visit(node);
2091
+ if (cycle) {
2092
+ return cycle;
2093
+ }
2094
+ }
2095
+ return null;
2096
+ };
2097
+
2098
+ /** 选中 candidate 作为 fieldPath 的触发字段是否会形成循环 */
2099
+ const wouldCreateCycle = (schema, fieldPath, candidatePath) => {
2100
+ if (fieldPath === candidatePath) {
2101
+ return true;
2102
+ }
2103
+ const graph = buildDependencyGraph(schema);
2104
+ const seen = new Set();
2105
+ const queue = [candidatePath];
2106
+ while (queue.length) {
2107
+ const node = queue.shift();
2108
+ if (node === fieldPath) {
2109
+ return true;
2110
+ }
2111
+ if (seen.has(node)) {
2112
+ continue;
2113
+ }
2114
+ seen.add(node);
2115
+ (graph.get(node) || []).forEach(next => queue.push(next));
2116
+ }
2117
+ return false;
2118
+ };
2119
+ const mapFieldList = (list, mapper) => Array.isArray(list) ? list.map(mapper) : list;
2120
+ const mapBlockFields = (block, mapper) => {
2121
+ if (!block) {
2122
+ return block;
2123
+ }
2124
+ const next = {
2125
+ ...block,
2126
+ list: mapFieldList(block.list, mapper)
2127
+ };
2128
+ if (Array.isArray(block.items)) {
2129
+ next.items = block.items.map(step => ({
2130
+ ...step,
2131
+ list: mapFieldList(step.list, mapper),
2132
+ blocks: mapBlocksFields(step.blocks, mapper)
2133
+ }));
2134
+ }
2135
+ if (Array.isArray(block.options)) {
2136
+ next.options = block.options.map(option => ({
2137
+ ...option,
2138
+ list: mapFieldList(option.list, mapper),
2139
+ blocks: mapBlocksFields(option.blocks, mapper)
2140
+ }));
2141
+ }
2142
+ if (Array.isArray(block.blocks)) {
2143
+ next.blocks = mapBlocksFields(block.blocks, mapper);
2144
+ }
2145
+ if (Array.isArray(block.itemBlocks)) {
2146
+ next.itemBlocks = mapBlocksFields(block.itemBlocks, mapper);
2147
+ }
2148
+ return next;
2149
+ };
2150
+ const mapBlocksFields = (blocks, mapper) => Array.isArray(blocks) ? blocks.map(block => mapBlockFields(block, mapper)) : blocks;
2151
+
2152
+ /** 触发字段改名后,同步所有条件中的引用 */
2153
+ const renameConditionReferences = (schema, oldPath, newPath) => {
2154
+ if (!oldPath || !newPath || oldPath === newPath) {
2155
+ return schema;
2156
+ }
2157
+ return {
2158
+ ...schema,
2159
+ blocks: mapBlocksFields(schema?.blocks, field => {
2160
+ if (!hasVisibleWhen(field) || !field.visibleWhen.conditions.some(condition => condition?.field === oldPath)) {
2161
+ return field;
2162
+ }
2163
+ return {
2164
+ ...field,
2165
+ visibleWhen: {
2166
+ ...field.visibleWhen,
2167
+ conditions: field.visibleWhen.conditions.map(condition => condition?.field === oldPath ? {
2168
+ ...condition,
2169
+ field: newPath
2170
+ } : condition)
2171
+ }
2172
+ };
2173
+ })
2174
+ };
2175
+ };
2176
+
2177
+ /**
2178
+ * 触发字段的值类型,决定可用运算符与值输入方式:
2179
+ * options(单值选项)/ multiOptions(多值选项)/ number / boolean / text
2180
+ * definition 为字段注册定义(getFieldDefinition(field.type)),由调用方传入
2181
+ */
2182
+ const getConditionValueKind = (field, definition) => {
2183
+ const props = field?.props || {};
2184
+ if (field?.type === 'CheckboxGroup' || definition?.isSuperSelect || field?.type === 'Select' && (props.mode === 'multiple' || props.mode === 'tags')) {
2185
+ return 'multiOptions';
2186
+ }
2187
+ if (definition?.hasOptions) {
2188
+ return 'options';
2189
+ }
2190
+ if (field?.type === 'Switch' || field?.type === 'Checkbox') {
2191
+ return 'boolean';
2192
+ }
2193
+ const valueSchema = typeof definition?.valueSchema === 'function' ? definition.valueSchema(field) : definition?.valueSchema;
2194
+ if (valueSchema?.type === 'number' || valueSchema?.type === 'integer') {
2195
+ return 'number';
2196
+ }
2197
+ return 'text';
2198
+ };
2199
+ const OPERATORS_BY_KIND = {
2200
+ options: ['eq', 'neq', 'in', 'empty', 'notEmpty'],
2201
+ multiOptions: ['includesAny', 'empty', 'notEmpty', 'regex'],
2202
+ number: ['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'empty', 'notEmpty', 'regex'],
2203
+ boolean: ['eq', 'neq'],
2204
+ text: ['eq', 'neq', 'empty', 'notEmpty', 'regex']
2205
+ };
2206
+ const getConditionOperators = (field, definition) => OPERATORS_BY_KIND[getConditionValueKind(field, definition)] || OPERATORS_BY_KIND.text;
2207
+
2208
+ /** 去掉空条件,规范 logic / flags;无有效条件返回 undefined(不写入 schema) */
2209
+ const normalizeVisibleWhen = visibleWhen => {
2210
+ const conditions = (visibleWhen?.conditions || []).filter(condition => condition?.field && CONDITION_OPERATORS.includes(condition.operator)).map(condition => {
2211
+ const next = {
2212
+ field: condition.field,
2213
+ operator: condition.operator
2214
+ };
2215
+ if (!NO_VALUE_OPERATORS.includes(condition.operator)) {
2216
+ next.value = condition.value;
2217
+ }
2218
+ if (condition.operator === 'regex') {
2219
+ const flags = sanitizeRegexFlags(condition.flags);
2220
+ if (flags) {
2221
+ next.flags = flags;
2222
+ }
2223
+ }
2224
+ return next;
2225
+ });
2226
+ if (!conditions.length) {
2227
+ return undefined;
2228
+ }
2229
+ return {
2230
+ logic: visibleWhen.logic === 'or' ? 'or' : 'and',
2231
+ conditions
2232
+ };
2233
+ };
2234
+ const formatConditionValue = (condition, optionLabelOf) => {
2235
+ if (condition.operator === 'regex') {
2236
+ return `/${condition.value ?? ''}/${sanitizeRegexFlags(condition.flags)}`;
2237
+ }
2238
+ return toArray(condition.value).map(item => optionLabelOf(item)).join(', ');
2239
+ };
2240
+
2241
+ /**
2242
+ * 条件的可读摘要,如「是否通过 等于 不通过」
2243
+ * formatMessage 需含 conditionOperator_* / conditionLogic_* 文案;fieldLookup 为 path → field
2244
+ */
2245
+ const formatVisibleWhen = (visibleWhen, {
2246
+ formatMessage,
2247
+ fieldLookup = new Map(),
2248
+ resolveText = text => text
2249
+ } = {}) => {
2250
+ const conditions = visibleWhen?.conditions || [];
2251
+ const parts = conditions.map(condition => {
2252
+ const trigger = fieldLookup.get(condition.field);
2253
+ const fieldLabel = trigger && resolveText(trigger.label) || condition.field;
2254
+ const optionLabelOf = value => {
2255
+ const option = (trigger?.props?.options || []).find(item => sameValue(item?.value, value));
2256
+ if (option) {
2257
+ return resolveText(option.label);
2258
+ }
2259
+ if (typeof value === 'boolean') {
2260
+ return formatMessage({
2261
+ id: value ? 'conditionValueTrue' : 'conditionValueFalse'
2262
+ });
2263
+ }
2264
+ return String(toComparable(value));
2265
+ };
2266
+ const operatorText = formatMessage({
2267
+ id: `conditionOperator_${condition.operator}`
2268
+ });
2269
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
2270
+ return `${fieldLabel} ${operatorText}`;
2271
+ }
2272
+ return `${fieldLabel} ${operatorText} ${formatConditionValue(condition, optionLabelOf)}`;
2273
+ });
2274
+ return parts.join(formatMessage({
2275
+ id: visibleWhen?.logic === 'or' ? 'conditionJoinOr' : 'conditionJoinAnd'
2276
+ }));
2277
+ };
2278
+
1614
2279
  const registry = new Map();
1615
2280
  const defineField = (type, definition) => {
1616
2281
  registry.set(type, {
@@ -2040,8 +2705,10 @@ const resolveFieldValueSchema = field => {
2040
2705
  ...schema
2041
2706
  };
2042
2707
  }
2043
- const title = field.label != null && String(field.label).trim() ? String(field.label).trim() : undefined;
2044
- const description = field.description != null && String(field.description).trim() ? String(field.description).trim() : undefined;
2708
+ const label = resolveLocaleText(field.label);
2709
+ const fieldDescription = resolveLocaleText(field.description);
2710
+ const title = label != null && String(label).trim() ? String(label).trim() : undefined;
2711
+ const description = fieldDescription != null && String(fieldDescription).trim() ? String(fieldDescription).trim() : undefined;
2045
2712
  if (title && schema.title == null) {
2046
2713
  schema.title = title;
2047
2714
  }
@@ -2118,24 +2785,24 @@ const normalizeOptions = (options, {
2118
2785
  }
2119
2786
  const columnNames = (columns || []).map(item => item?.name).filter(Boolean);
2120
2787
  return options.map(item => {
2121
- const label = String(item?.label ?? '').trim();
2788
+ const label = trimLocaleText(item?.label);
2122
2789
  let value = String(item?.value ?? '').trim();
2123
2790
  if (!value && label) {
2124
- value = label;
2791
+ value = localeTextToValue(label);
2125
2792
  }
2126
2793
  const next = {
2127
2794
  label,
2128
2795
  value,
2129
- description: String(item?.description ?? '').trim()
2796
+ description: trimLocaleText(item?.description)
2130
2797
  };
2131
2798
  columnNames.forEach(name => {
2132
2799
  next[name] = item?.[name] ?? '';
2133
2800
  });
2134
- if (!String(next.label).trim() && columnNames[0] && String(next[columnNames[0]] || '').trim()) {
2801
+ if (!hasLocaleText(next.label) && columnNames[0] && String(next[columnNames[0]] || '').trim()) {
2135
2802
  next.label = String(next[columnNames[0]]).trim();
2136
2803
  }
2137
- if (!String(next.value).trim() && String(next.label).trim()) {
2138
- next.value = next.label;
2804
+ if (!String(next.value).trim() && hasLocaleText(next.label)) {
2805
+ next.value = localeTextToValue(next.label);
2139
2806
  }
2140
2807
  if (allowChildren && Array.isArray(item?.children) && item.children.length) {
2141
2808
  next.children = normalizeOptions(item.children, {
@@ -2390,6 +3057,7 @@ const fieldToFormValues = field => {
2390
3057
  description: field.description || '',
2391
3058
  block: !!field.block,
2392
3059
  hidden: !!field.hidden,
3060
+ visibleWhen: field.visibleWhen,
2393
3061
  placeholder,
2394
3062
  options: options.length ? options : [{
2395
3063
  label: '',
@@ -2428,6 +3096,7 @@ const formValuesToField = (values, existingField = {}) => {
2428
3096
  props.children = values.label;
2429
3097
  }
2430
3098
  const rule = buildRuleString(values.ruleConfig);
3099
+ const visibleWhen = normalizeVisibleWhen(values.visibleWhen);
2431
3100
  return {
2432
3101
  id: existingField.id,
2433
3102
  type: values.type,
@@ -2438,12 +3107,114 @@ const formValuesToField = (values, existingField = {}) => {
2438
3107
  rule,
2439
3108
  block: values.block ?? definition.defaults?.block ?? false,
2440
3109
  hidden: !!values.hidden,
3110
+ ...(visibleWhen ? {
3111
+ visibleWhen
3112
+ } : {}),
2441
3113
  props
2442
3114
  };
2443
3115
  };
2444
3116
 
2445
3117
  const {
2446
- Text: Text$4
3118
+ useOnChange: useOnChange$1
3119
+ } = reactFormAntd.hooks;
3120
+ const LocaleTextContext = /*#__PURE__*/react.createContext([]);
3121
+
3122
+ /** 向编辑器内的文案输入下发语言列表 [{ value, label }] */
3123
+ const LocaleTextProvider = ({
3124
+ languages,
3125
+ children
3126
+ }) => /*#__PURE__*/jsxRuntime.jsx(LocaleTextContext.Provider, {
3127
+ value: normalizeLanguages(languages),
3128
+ children: children
3129
+ });
3130
+
3131
+ /** 当前语言列表:组件 languages 优先,否则取 LocaleTextProvider */
3132
+ const useLocaleTextLanguages = languages => {
3133
+ const contextLanguages = react.useContext(LocaleTextContext);
3134
+ return languages ? normalizeLanguages(languages) : contextLanguages;
3135
+ };
3136
+
3137
+ /** 文案输入:未配置多语言时为单个输入框;配置后每种语言一个输入框,只填基础语言(首项)时存为字符串 */
3138
+ const LocaleTextControl = ({
3139
+ value,
3140
+ onChange,
3141
+ onBlur,
3142
+ placeholder,
3143
+ multiline = false,
3144
+ compact = false,
3145
+ rows = 2,
3146
+ disabled,
3147
+ className,
3148
+ languages: languagesProp
3149
+ }) => {
3150
+ const {
3151
+ formatMessage,
3152
+ locale
3153
+ } = reactIntl.useIntl();
3154
+ const languages = useLocaleTextLanguages(languagesProp);
3155
+ const Control = multiline ? antd.Input.TextArea : antd.Input;
3156
+ const controlProps = {
3157
+ disabled,
3158
+ onBlur,
3159
+ ...(multiline ? {
3160
+ rows
3161
+ } : {})
3162
+ };
3163
+ if (languages.length < 2) {
3164
+ const baseLanguage = languages[0]?.value;
3165
+ const editLanguage = isLocaleText(value) ? baseLanguage || Object.keys(value).find(key => value[key] === resolveLocaleText(value, locale)) || Object.keys(value)[0] : null;
3166
+ return /*#__PURE__*/jsxRuntime.jsx(Control, {
3167
+ ...controlProps,
3168
+ className: className,
3169
+ value: editLanguage ? value[editLanguage] || '' : value ?? '',
3170
+ placeholder: placeholder,
3171
+ onChange: e => onChange?.(editLanguage ? setLocaleTextValue(value, editLanguage, e.target.value, editLanguage) : e.target.value)
3172
+ });
3173
+ }
3174
+ const baseLanguage = languages[0];
3175
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
3176
+ className: [style['locale-text'], compact ? style['is-compact'] : null, className].filter(Boolean).join(' '),
3177
+ children: languages.map(language => /*#__PURE__*/jsxRuntime.jsxs("div", {
3178
+ className: style['locale-text-item'],
3179
+ children: [compact ? null : /*#__PURE__*/jsxRuntime.jsx("span", {
3180
+ className: style['locale-text-tag'],
3181
+ children: language.label
3182
+ }), /*#__PURE__*/jsxRuntime.jsx(Control, {
3183
+ ...controlProps,
3184
+ value: getLocaleTextValue(value, language.value, baseLanguage.value),
3185
+ placeholder: language.value === baseLanguage.value ? placeholder : formatMessage({
3186
+ id: 'localeTextFallback'
3187
+ }, {
3188
+ language: baseLanguage.label
3189
+ }),
3190
+ ...(compact && !multiline ? {
3191
+ prefix: /*#__PURE__*/jsxRuntime.jsx("span", {
3192
+ className: style['locale-text-prefix'],
3193
+ children: language.label
3194
+ })
3195
+ } : {}),
3196
+ onChange: e => onChange?.(setLocaleTextValue(value, language.value, e.target.value, baseLanguage.value))
3197
+ })]
3198
+ }, language.value))
3199
+ });
3200
+ };
3201
+ const LocaleInput = props => {
3202
+ const render = useOnChange$1(props);
3203
+ return render(LocaleTextControl);
3204
+ };
3205
+ LocaleInput.field = LocaleTextControl;
3206
+ const LocaleTextAreaControl = props => /*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
3207
+ ...props,
3208
+ multiline: true
3209
+ });
3210
+ const LocaleTextArea = props => {
3211
+ const render = useOnChange$1(props);
3212
+ return render(LocaleTextAreaControl);
3213
+ };
3214
+ LocaleTextArea.field = LocaleTextAreaControl;
3215
+
3216
+ const {
3217
+ Text: Text$5
2447
3218
  } = antd.Typography;
2448
3219
  const TYPE_TAG_COLORS = {
2449
3220
  Input: 'blue',
@@ -2463,52 +3234,117 @@ const TYPE_TAG_COLORS = {
2463
3234
  Checkbox: 'green',
2464
3235
  DatePicker: 'lime'
2465
3236
  };
3237
+ const TYPE_TAG_ICONS = {
3238
+ Input: icons.FontSizeOutlined,
3239
+ TextArea: icons.AlignLeftOutlined,
3240
+ InputNumber: icons.NumberOutlined,
3241
+ Select: icons.DownSquareOutlined,
3242
+ RadioGroup: icons.CheckCircleOutlined,
3243
+ CheckboxGroup: icons.CheckSquareOutlined,
3244
+ SuperSelectList: icons.AppstoreOutlined,
3245
+ SuperSelectTableList: icons.AppstoreOutlined,
3246
+ SuperSelectTree: icons.AppstoreOutlined,
3247
+ SuperSelectCascader: icons.AppstoreOutlined,
3248
+ SelectFunction: icons.ApartmentOutlined,
3249
+ SelectIndustry: icons.ShopOutlined,
3250
+ SelectAddress: icons.EnvironmentOutlined,
3251
+ Switch: icons.SwapOutlined,
3252
+ Checkbox: icons.CheckSquareOutlined,
3253
+ DatePicker: icons.CalendarOutlined
3254
+ };
3255
+ const getFieldTypeIcon = type => TYPE_TAG_ICONS[type] || icons.FormOutlined;
2466
3256
  const FieldRow = ({
2467
3257
  field,
2468
3258
  index,
2469
3259
  total,
2470
3260
  onEdit,
2471
3261
  onDelete,
2472
- onMove
3262
+ onMove,
3263
+ prevLocked,
3264
+ nextLocked,
3265
+ conditionContext
2473
3266
  }) => {
2474
3267
  const {
2475
- formatMessage
3268
+ formatMessage,
3269
+ locale
2476
3270
  } = reactIntl.useIntl();
3271
+ const languages = useLocaleTextLanguages();
2477
3272
  const definition = getFieldDefinition(field.type);
3273
+ const conditional = hasVisibleWhen(field);
3274
+ const conditionInvalid = conditional && conditionContext && hasInvalidCondition(field, conditionContext.triggerNames);
3275
+ const TypeIcon = getFieldTypeIcon(field.type);
2478
3276
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
2479
3277
  className: style['field-row'],
2480
3278
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
2481
3279
  className: style['field-row-index'],
2482
3280
  children: index + 1
2483
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
3281
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
2484
3282
  className: style['field-row-main'],
2485
- children: /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
3283
+ children: [/*#__PURE__*/jsxRuntime.jsx(Text$5, {
3284
+ strong: true,
3285
+ className: style['field-row-label'],
3286
+ children: resolveLocaleText(field.label, locale, languages) || formatMessage({
3287
+ id: 'untitledField'
3288
+ })
3289
+ }), /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
2486
3290
  size: 6,
2487
3291
  wrap: true,
2488
- children: [/*#__PURE__*/jsxRuntime.jsx(Text$4, {
2489
- strong: true,
2490
- ellipsis: true,
2491
- children: field.label || formatMessage({
2492
- id: 'untitledField'
2493
- })
2494
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3292
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
2495
3293
  bordered: false,
2496
3294
  color: TYPE_TAG_COLORS[field.type] || 'default',
3295
+ icon: /*#__PURE__*/jsxRuntime.jsx(TypeIcon, {}),
2497
3296
  children: resolveFieldTypeLabel(definition || field.type, formatMessage)
2498
- }), field.hidden ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3297
+ }), field.locked ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3298
+ bordered: false,
3299
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.LockOutlined, {}),
3300
+ title: formatMessage({
3301
+ id: 'fieldLockedTips'
3302
+ }),
3303
+ children: formatMessage({
3304
+ id: 'fieldLockedTag'
3305
+ })
3306
+ }) : null, field.hidden ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
2499
3307
  bordered: false,
3308
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.EyeInvisibleOutlined, {}),
2500
3309
  children: formatMessage({
2501
3310
  id: 'fieldHiddenTag'
2502
3311
  })
3312
+ }) : null, conditional ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
3313
+ title: formatVisibleWhen(field.visibleWhen, {
3314
+ formatMessage,
3315
+ fieldLookup: conditionContext?.fieldLookup,
3316
+ resolveText: value => resolveLocaleText(value, locale, languages)
3317
+ }),
3318
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3319
+ bordered: false,
3320
+ color: "magenta",
3321
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.BranchesOutlined, {}),
3322
+ children: formatMessage({
3323
+ id: 'fieldConditionTag'
3324
+ })
3325
+ })
3326
+ }) : null, conditionInvalid ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
3327
+ title: formatMessage({
3328
+ id: 'fieldConditionInvalidTips'
3329
+ }),
3330
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3331
+ bordered: false,
3332
+ color: "error",
3333
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.WarningOutlined, {}),
3334
+ children: formatMessage({
3335
+ id: 'fieldConditionInvalidTag'
3336
+ })
3337
+ })
2503
3338
  }) : null, field.block ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
2504
3339
  bordered: false,
2505
3340
  color: "processing",
3341
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.ColumnWidthOutlined, {}),
2506
3342
  children: formatMessage({
2507
3343
  id: 'fieldBlockTag'
2508
3344
  })
2509
3345
  }) : null]
2510
- })
2511
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
3346
+ })]
3347
+ }), field.locked ? null : /*#__PURE__*/jsxRuntime.jsxs("div", {
2512
3348
  className: style['action-group'],
2513
3349
  children: [/*#__PURE__*/jsxRuntime.jsx(antd.Button, {
2514
3350
  type: "text",
@@ -2518,7 +3354,7 @@ const FieldRow = ({
2518
3354
  id: 'moveUp'
2519
3355
  }),
2520
3356
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowUpOutlined, {}),
2521
- disabled: index === 0,
3357
+ disabled: index === 0 || prevLocked,
2522
3358
  onClick: () => onMove(field.id, 'up')
2523
3359
  }), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
2524
3360
  type: "text",
@@ -2528,7 +3364,7 @@ const FieldRow = ({
2528
3364
  id: 'moveDown'
2529
3365
  }),
2530
3366
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowDownOutlined, {}),
2531
- disabled: index === total - 1,
3367
+ disabled: index === total - 1 || nextLocked,
2532
3368
  onClick: () => onMove(field.id, 'down')
2533
3369
  }), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
2534
3370
  type: "text",
@@ -2553,10 +3389,9 @@ const FieldRow = ({
2553
3389
  })]
2554
3390
  });
2555
3391
  };
2556
- var FieldRow$1 = FieldRow;
2557
3392
 
2558
3393
  const {
2559
- Text: Text$3
3394
+ Text: Text$4
2560
3395
  } = antd.Typography;
2561
3396
  const ActionGroup = ({
2562
3397
  children
@@ -2601,6 +3436,10 @@ const ROOT_ADD_OPTIONS = [{
2601
3436
  key: 'steps',
2602
3437
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.OrderedListOutlined, {})
2603
3438
  }];
3439
+ const BLOCK_KIND_ICONS = Object.fromEntries(ROOT_ADD_OPTIONS.map(({
3440
+ key,
3441
+ icon
3442
+ }) => [key, icon]));
2604
3443
 
2605
3444
  /** 可挂子模块的容器;表格列表 / 同类多值本身不支持子模块 */
2606
3445
  const NESTED_ADD_OPTIONS = ROOT_ADD_OPTIONS.filter(opt => opt.key !== 'steps');
@@ -2626,11 +3465,23 @@ const BlockListPanel = ({
2626
3465
  extraToolbar
2627
3466
  }) => {
2628
3467
  const {
2629
- formatMessage
3468
+ formatMessage,
3469
+ locale
2630
3470
  } = reactIntl.useIntl();
3471
+ const languages = useLocaleTextLanguages();
3472
+ const text = value => resolveLocaleText(value, locale, languages);
2631
3473
  const [addMenuOpen, setAddMenuOpen] = react.useState(false);
2632
3474
  const [addFieldMenuId, setAddFieldMenuId] = react.useState(null);
2633
3475
  const keepAddFieldMenuOpenRef = react.useRef(false);
3476
+ const conditionContext = react.useMemo(() => {
3477
+ const triggerFields = collectConditionFields({
3478
+ blocks
3479
+ }).filter(item => !item.inList);
3480
+ return {
3481
+ triggerNames: new Set(triggerFields.map(item => item.path)),
3482
+ fieldLookup: new Map(triggerFields.map(item => [item.path, item.field]))
3483
+ };
3484
+ }, [blocks]);
2634
3485
  const renderAddBlockMenu = (options, {
2635
3486
  onSelect,
2636
3487
  className
@@ -2792,7 +3643,7 @@ const BlockListPanel = ({
2792
3643
  optionId
2793
3644
  } = {}) => {
2794
3645
  if (!(fields || []).length) {
2795
- return /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3646
+ return /*#__PURE__*/jsxRuntime.jsx(Text$4, {
2796
3647
  type: "secondary",
2797
3648
  className: style['inline-empty'],
2798
3649
  children: formatMessage({
@@ -2802,10 +3653,13 @@ const BlockListPanel = ({
2802
3653
  }
2803
3654
  return /*#__PURE__*/jsxRuntime.jsx("div", {
2804
3655
  className: style['field-list'],
2805
- children: fields.map((field, fieldIndex) => /*#__PURE__*/jsxRuntime.jsx(FieldRow$1, {
3656
+ children: fields.map((field, fieldIndex) => /*#__PURE__*/jsxRuntime.jsx(FieldRow, {
2806
3657
  field: field,
2807
3658
  index: fieldIndex,
2808
3659
  total: fields.length,
3660
+ prevLocked: isFieldLocked(fields[fieldIndex - 1]),
3661
+ nextLocked: isFieldLocked(fields[fieldIndex + 1]),
3662
+ conditionContext: conditionContext,
2809
3663
  onEdit: fieldItem => onEditField(blockId, fieldItem, {
2810
3664
  stepId,
2811
3665
  optionId
@@ -2829,7 +3683,7 @@ const BlockListPanel = ({
2829
3683
  className: style['item-blocks-section'],
2830
3684
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
2831
3685
  className: style['nested-block-list'],
2832
- children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks.length, depth + 1))
3686
+ children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks, depth + 1))
2833
3687
  })
2834
3688
  });
2835
3689
  };
@@ -2840,7 +3694,7 @@ const BlockListPanel = ({
2840
3694
  className: style['block-body'],
2841
3695
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
2842
3696
  className: style['section-toolbar'],
2843
- children: [/*#__PURE__*/jsxRuntime.jsx(Text$3, {
3697
+ children: [/*#__PURE__*/jsxRuntime.jsx(Text$4, {
2844
3698
  type: "secondary",
2845
3699
  className: style['section-toolbar-label'],
2846
3700
  children: formatMessage({
@@ -2869,14 +3723,14 @@ const BlockListPanel = ({
2869
3723
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
2870
3724
  className: style['step-index'],
2871
3725
  children: stepIndex + 1
2872
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3726
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
2873
3727
  strong: true,
2874
- children: step.title || formatMessage({
3728
+ children: text(step.title) || formatMessage({
2875
3729
  id: 'untitledStep'
2876
3730
  }, {
2877
3731
  index: stepIndex + 1
2878
3732
  })
2879
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3733
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
2880
3734
  type: "secondary",
2881
3735
  children: (step.blocks || []).length ? formatMessage({
2882
3736
  id: 'fieldAndItemBlockCount'
@@ -2899,14 +3753,14 @@ const BlockListPanel = ({
2899
3753
  id: 'moveUp'
2900
3754
  }),
2901
3755
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowUpOutlined, {}),
2902
- disabled: stepIndex === 0,
3756
+ disabled: stepIndex === 0 || blockHasLockedField(step) || blockHasLockedField(block.items[stepIndex - 1]),
2903
3757
  onClick: () => onMoveStep(block.id, step.id, 'up')
2904
3758
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
2905
3759
  title: formatMessage({
2906
3760
  id: 'moveDown'
2907
3761
  }),
2908
3762
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowDownOutlined, {}),
2909
- disabled: stepIndex === (block.items?.length || 0) - 1,
3763
+ disabled: stepIndex === (block.items?.length || 0) - 1 || blockHasLockedField(step) || blockHasLockedField(block.items[stepIndex + 1]),
2910
3764
  onClick: () => onMoveStep(block.id, step.id, 'down')
2911
3765
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
2912
3766
  title: formatMessage({
@@ -2914,7 +3768,7 @@ const BlockListPanel = ({
2914
3768
  }),
2915
3769
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.EditOutlined, {}),
2916
3770
  onClick: () => onEditStep(block.id, step)
2917
- }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3771
+ }), blockHasLockedField(step) ? null : /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
2918
3772
  title: formatMessage({
2919
3773
  id: 'deleteStep'
2920
3774
  }),
@@ -2938,7 +3792,7 @@ const BlockListPanel = ({
2938
3792
  stepId: step.id
2939
3793
  }), renderNestedBlocks(step.blocks, depth)]
2940
3794
  }, step.id))
2941
- }) : /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3795
+ }) : /*#__PURE__*/jsxRuntime.jsx(Text$4, {
2942
3796
  type: "secondary",
2943
3797
  className: style['inline-empty'],
2944
3798
  children: formatMessage({
@@ -2950,7 +3804,7 @@ const BlockListPanel = ({
2950
3804
  if (block.kind === 'multiField') {
2951
3805
  return /*#__PURE__*/jsxRuntime.jsx("div", {
2952
3806
  className: style['block-body'],
2953
- children: /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3807
+ children: /*#__PURE__*/jsxRuntime.jsx(Text$4, {
2954
3808
  type: "secondary",
2955
3809
  children: formatMessage({
2956
3810
  id: 'multiFieldEditorHint'
@@ -2963,7 +3817,7 @@ const BlockListPanel = ({
2963
3817
  className: style['block-body'],
2964
3818
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
2965
3819
  className: style['section-toolbar'],
2966
- children: [/*#__PURE__*/jsxRuntime.jsx(Text$3, {
3820
+ children: [/*#__PURE__*/jsxRuntime.jsx(Text$4, {
2967
3821
  type: "secondary",
2968
3822
  className: style['section-toolbar-label'],
2969
3823
  children: formatMessage({
@@ -2992,14 +3846,14 @@ const BlockListPanel = ({
2992
3846
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
2993
3847
  className: style['step-index'],
2994
3848
  children: optionIndex + 1
2995
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3849
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
2996
3850
  strong: true,
2997
- children: option.title || formatMessage({
3851
+ children: text(option.title) || formatMessage({
2998
3852
  id: 'choiceOptionFallback'
2999
3853
  }, {
3000
3854
  index: optionIndex + 1
3001
3855
  })
3002
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3856
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3003
3857
  type: "secondary",
3004
3858
  children: (option.blocks || []).length ? formatMessage({
3005
3859
  id: 'fieldAndItemBlockCount'
@@ -3022,14 +3876,14 @@ const BlockListPanel = ({
3022
3876
  id: 'moveUp'
3023
3877
  }),
3024
3878
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowUpOutlined, {}),
3025
- disabled: optionIndex === 0,
3879
+ disabled: optionIndex === 0 || blockHasLockedField(option) || blockHasLockedField(block.options[optionIndex - 1]),
3026
3880
  onClick: () => onMoveChoiceOption(block.id, option.id, 'up')
3027
3881
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3028
3882
  title: formatMessage({
3029
3883
  id: 'moveDown'
3030
3884
  }),
3031
3885
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowDownOutlined, {}),
3032
- disabled: optionIndex === (block.options?.length || 0) - 1,
3886
+ disabled: optionIndex === (block.options?.length || 0) - 1 || blockHasLockedField(option) || blockHasLockedField(block.options[optionIndex + 1]),
3033
3887
  onClick: () => onMoveChoiceOption(block.id, option.id, 'down')
3034
3888
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3035
3889
  title: formatMessage({
@@ -3037,7 +3891,7 @@ const BlockListPanel = ({
3037
3891
  }),
3038
3892
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.EditOutlined, {}),
3039
3893
  onClick: () => onEditChoiceOption(block.id, option)
3040
- }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3894
+ }), blockHasLockedField(option) ? null : /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3041
3895
  title: formatMessage({
3042
3896
  id: 'deleteChoiceOption'
3043
3897
  }),
@@ -3061,7 +3915,7 @@ const BlockListPanel = ({
3061
3915
  optionId: option.id
3062
3916
  }), renderNestedBlocks(option.blocks, depth)]
3063
3917
  }, option.id))
3064
- }) : /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3918
+ }) : /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3065
3919
  type: "secondary",
3066
3920
  className: style['inline-empty'],
3067
3921
  children: formatMessage({
@@ -3077,7 +3931,9 @@ const BlockListPanel = ({
3077
3931
  children: [renderFieldList(block.list, block.id), supportsItemBlocks$1 ? renderItemBlocks(block, depth) : null, supportsBlocks ? renderNestedBlocks(block.blocks, depth) : null]
3078
3932
  });
3079
3933
  };
3080
- const renderBlockSection = (block, blockIndex, total, depth = 0) => {
3934
+ const renderBlockSection = (block, blockIndex, siblings, depth = 0) => {
3935
+ const total = siblings.length;
3936
+ const locked = blockHasLockedField(block);
3081
3937
  const definition = getBlockDefinition(block.kind);
3082
3938
  const canAddField = block.kind !== 'steps' && block.kind !== 'multiField' && block.kind !== 'choice';
3083
3939
  const supportsItemBlocks$1 = supportsItemBlocks(block.kind);
@@ -3091,7 +3947,10 @@ const BlockListPanel = ({
3091
3947
  }) : block.kind === 'multiField' ? formatMessage({
3092
3948
  id: 'multiFieldSummary'
3093
3949
  }, {
3094
- type: resolveFieldTypeLabel(block.fieldType, formatMessage)
3950
+ type: /*#__PURE__*/jsxRuntime.jsxs("span", {
3951
+ className: style['block-summary-type'],
3952
+ children: [/*#__PURE__*/react.createElement(getFieldTypeIcon(block.fieldType || 'Input')), resolveFieldTypeLabel(block.fieldType, formatMessage)]
3953
+ })
3095
3954
  }) : block.kind === 'choice' ? formatMessage({
3096
3955
  id: 'choiceOptionCount'
3097
3956
  }, {
@@ -3115,14 +3974,15 @@ const BlockListPanel = ({
3115
3974
  children: [/*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3116
3975
  bordered: false,
3117
3976
  color: definition?.color || 'default',
3977
+ icon: BLOCK_KIND_ICONS[block.kind],
3118
3978
  children: formatMessage({
3119
3979
  id: `blockKind_${block.kind}`
3120
3980
  })
3121
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3981
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3122
3982
  strong: true,
3123
3983
  ellipsis: true,
3124
3984
  className: style['block-title'],
3125
- children: block.title || block.label || block.name || formatMessage({
3985
+ children: text(block.title) || text(block.label) || block.name || formatMessage({
3126
3986
  id: 'untitledBlock'
3127
3987
  })
3128
3988
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
@@ -3139,14 +3999,14 @@ const BlockListPanel = ({
3139
3999
  id: 'moveUp'
3140
4000
  }),
3141
4001
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowUpOutlined, {}),
3142
- disabled: blockIndex === 0,
4002
+ disabled: blockIndex === 0 || locked || blockHasLockedField(siblings[blockIndex - 1]),
3143
4003
  onClick: () => onMoveBlock(block.id, 'up')
3144
4004
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3145
4005
  title: formatMessage({
3146
4006
  id: 'moveDown'
3147
4007
  }),
3148
4008
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowDownOutlined, {}),
3149
- disabled: blockIndex === total - 1,
4009
+ disabled: blockIndex === total - 1 || locked || blockHasLockedField(siblings[blockIndex + 1]),
3150
4010
  onClick: () => onMoveBlock(block.id, 'down')
3151
4011
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3152
4012
  title: formatMessage({
@@ -3154,7 +4014,7 @@ const BlockListPanel = ({
3154
4014
  }),
3155
4015
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.SettingOutlined, {}),
3156
4016
  onClick: () => onEditBlock(block)
3157
- }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
4017
+ }), locked ? null : /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3158
4018
  title: formatMessage({
3159
4019
  id: 'deleteBlock'
3160
4020
  }),
@@ -3222,7 +4082,7 @@ const BlockListPanel = ({
3222
4082
  })
3223
4083
  }) : /*#__PURE__*/jsxRuntime.jsx("div", {
3224
4084
  className: style['block-list'],
3225
- children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks.length, 0))
4085
+ children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks, 0))
3226
4086
  })]
3227
4087
  });
3228
4088
  };
@@ -3239,7 +4099,7 @@ const BlockConfigFields = ({
3239
4099
  const list = [];
3240
4100
  const isListKind = kind === 'list' || kind === 'tableList' || kind === 'editableList';
3241
4101
  if (kind === 'formInfo' || kind === 'list' || kind === 'tableList' || kind === 'editableList' || kind === 'object') {
3242
- list.push(/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4102
+ list.push(/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3243
4103
  name: "title",
3244
4104
  label: formatMessage({
3245
4105
  id: 'blockTitle'
@@ -3247,7 +4107,7 @@ const BlockConfigFields = ({
3247
4107
  placeholder: formatMessage({
3248
4108
  id: 'blockTitlePlaceholder'
3249
4109
  })
3250
- }, "title"), kind === 'formInfo' ? /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4110
+ }, "title"), kind === 'formInfo' ? /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3251
4111
  name: "subtitle",
3252
4112
  label: formatMessage({
3253
4113
  id: 'blockSubtitle'
@@ -3293,7 +4153,7 @@ const BlockConfigFields = ({
3293
4153
  children: formatMessage({
3294
4154
  id: 'blockImportant'
3295
4155
  })
3296
- }, "important") : null, isListKind ? /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4156
+ }, "important") : null, isListKind ? /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3297
4157
  name: "addText",
3298
4158
  label: formatMessage({
3299
4159
  id: 'blockAddText'
@@ -3327,7 +4187,7 @@ const BlockConfigFields = ({
3327
4187
  }, "minLength") : null);
3328
4188
  }
3329
4189
  if (kind === 'choice') {
3330
- list.push(/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4190
+ list.push(/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3331
4191
  name: "title",
3332
4192
  label: formatMessage({
3333
4193
  id: 'blockTitle'
@@ -3404,7 +4264,7 @@ const BlockConfigFields = ({
3404
4264
  placeholder: formatMessage({
3405
4265
  id: 'fieldNamePlaceholder'
3406
4266
  })
3407
- }, "name"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4267
+ }, "name"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3408
4268
  name: "label",
3409
4269
  label: formatMessage({
3410
4270
  id: 'fieldLabel'
@@ -3420,7 +4280,7 @@ const BlockConfigFields = ({
3420
4280
  }),
3421
4281
  rule: "REQ",
3422
4282
  options: fieldTypeOptions
3423
- }, "fieldType"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4283
+ }, "fieldType"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3424
4284
  name: "addText",
3425
4285
  label: formatMessage({
3426
4286
  id: 'blockAddText'
@@ -3431,7 +4291,7 @@ const BlockConfigFields = ({
3431
4291
  }, "addText"));
3432
4292
  }
3433
4293
  if (kind === 'steps') {
3434
- list.push(/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4294
+ list.push(/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3435
4295
  name: "title",
3436
4296
  label: formatMessage({
3437
4297
  id: 'blockTitle'
@@ -3439,7 +4299,7 @@ const BlockConfigFields = ({
3439
4299
  placeholder: formatMessage({
3440
4300
  id: 'blockTitlePlaceholder'
3441
4301
  })
3442
- }, "title"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4302
+ }, "title"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3443
4303
  name: "subtitle",
3444
4304
  label: formatMessage({
3445
4305
  id: 'blockSubtitle'
@@ -3567,7 +4427,7 @@ const StepEditorModal = ({
3567
4427
  }),
3568
4428
  children: /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
3569
4429
  column: 1,
3570
- list: [/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4430
+ list: [/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3571
4431
  name: "title",
3572
4432
  label: formatMessage({
3573
4433
  id: 'stepTitle'
@@ -3627,7 +4487,7 @@ const ChoiceOptionEditorModal = ({
3627
4487
  }),
3628
4488
  children: /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
3629
4489
  column: 1,
3630
- list: [/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4490
+ list: [/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
3631
4491
  name: "title",
3632
4492
  label: formatMessage({
3633
4493
  id: 'choiceOptionTitle'
@@ -3643,7 +4503,7 @@ const ChoiceOptionEditorModal = ({
3643
4503
  var ChoiceOptionEditorModal$1 = ChoiceOptionEditorModal;
3644
4504
 
3645
4505
  const {
3646
- Text: Text$2
4506
+ Text: Text$3
3647
4507
  } = antd.Typography;
3648
4508
  const {
3649
4509
  useOnChange
@@ -3692,7 +4552,7 @@ const RulePresetEditor = () => {
3692
4552
  }) => (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET)
3693
4553
  }, "lenMax"), /*#__PURE__*/jsxRuntime.jsx("div", {
3694
4554
  block: true,
3695
- children: /*#__PURE__*/jsxRuntime.jsx(Text$2, {
4555
+ children: /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3696
4556
  type: "secondary",
3697
4557
  children: formatMessage({
3698
4558
  id: 'ruleEditorHint'
@@ -3710,7 +4570,7 @@ const RulePresetEditor = () => {
3710
4570
  var RulePresetEditor$1 = RulePresetEditor;
3711
4571
 
3712
4572
  const {
3713
- Text: Text$1
4573
+ Text: Text$2
3714
4574
  } = antd.Typography;
3715
4575
  const createOptionKey = () => createDataKey('opt');
3716
4576
  const EMPTY_OPTION = () => ({
@@ -3720,27 +4580,28 @@ const EMPTY_OPTION = () => ({
3720
4580
  });
3721
4581
 
3722
4582
  /** value 为空或仍等于当前 label 时视为联动中,改 label 会同步 value */
3723
- const isOptionValueLinked = (label, value) => {
3724
- const labelText = label == null ? '' : String(label);
4583
+ const isOptionValueLinked = (label, value, baseLanguage) => {
4584
+ const labelText = localeTextToValue(label, baseLanguage);
3725
4585
  const valueText = value == null ? '' : String(value);
3726
4586
  return valueText === '' || valueText === labelText;
3727
4587
  };
3728
- const patchOptionLabelChange = (item, nextLabel) => {
4588
+ const patchOptionLabelChange = (item, nextLabel, baseLanguage) => {
3729
4589
  const patch = {
3730
4590
  label: nextLabel
3731
4591
  };
3732
- if (isOptionValueLinked(item.label, item.value)) {
3733
- patch.value = nextLabel;
4592
+ if (isOptionValueLinked(item.label, item.value, baseLanguage)) {
4593
+ patch.value = localeTextToValue(nextLabel, baseLanguage);
3734
4594
  }
3735
4595
  return patch;
3736
4596
  };
3737
- const trimOptionLabelValue = item => {
3738
- const label = String(item?.label ?? '').trim();
4597
+ const trimOptionLabelValue = (item, baseLanguage) => {
4598
+ const label = trimLocaleText(item?.label, baseLanguage);
4599
+ const labelValue = localeTextToValue(label, baseLanguage);
3739
4600
  const rawValue = String(item?.value ?? '').trim();
3740
- const linked = isOptionValueLinked(item?.label, item?.value) || rawValue === '' || rawValue === label;
4601
+ const linked = isOptionValueLinked(item?.label, item?.value, baseLanguage) || rawValue === '' || rawValue === labelValue;
3741
4602
  return {
3742
4603
  label,
3743
- value: linked ? label : rawValue
4604
+ value: linked ? labelValue : rawValue
3744
4605
  };
3745
4606
  };
3746
4607
  const createEmptyTableRow = columns => {
@@ -3771,6 +4632,7 @@ const FlatOptionRows = ({
3771
4632
  const {
3772
4633
  formatMessage
3773
4634
  } = reactIntl.useIntl();
4635
+ const baseLanguage = useLocaleTextLanguages()[0]?.value;
3774
4636
  const rows = list.length ? ensureOptionKeys(list) : [EMPTY_OPTION()];
3775
4637
  const commit = next => onChange(next);
3776
4638
  const updateItem = (index, patch) => {
@@ -3785,13 +4647,15 @@ const FlatOptionRows = ({
3785
4647
  gap: 8,
3786
4648
  align: "start",
3787
4649
  className: style['options-row'],
3788
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Input, {
4650
+ children: [/*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
4651
+ compact: true,
4652
+ className: style['options-locale-text'],
3789
4653
  value: item.label,
3790
4654
  placeholder: formatMessage({
3791
4655
  id: 'optionLabelPlaceholder'
3792
4656
  }),
3793
- onChange: event => updateItem(index, patchOptionLabelChange(item, event.target.value)),
3794
- onBlur: () => updateItem(index, trimOptionLabelValue(item))
4657
+ onChange: nextLabel => updateItem(index, patchOptionLabelChange(item, nextLabel, baseLanguage)),
4658
+ onBlur: () => updateItem(index, trimOptionLabelValue(item, baseLanguage))
3795
4659
  }), /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
3796
4660
  value: item.value,
3797
4661
  placeholder: formatMessage({
@@ -3803,16 +4667,18 @@ const FlatOptionRows = ({
3803
4667
  onBlur: () => updateItem(index, {
3804
4668
  value: String(item.value ?? '').trim()
3805
4669
  })
3806
- }), allowDescription ? /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
4670
+ }), allowDescription ? /*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
4671
+ compact: true,
4672
+ className: style['options-locale-text'],
3807
4673
  value: item.description || '',
3808
4674
  placeholder: formatMessage({
3809
4675
  id: 'optionDescPlaceholder'
3810
4676
  }),
3811
- onChange: event => updateItem(index, {
3812
- description: event.target.value
4677
+ onChange: description => updateItem(index, {
4678
+ description
3813
4679
  }),
3814
4680
  onBlur: () => updateItem(index, {
3815
- description: String(item.description ?? '').trim()
4681
+ description: trimLocaleText(item.description, baseLanguage)
3816
4682
  })
3817
4683
  }) : null, /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
3818
4684
  type: "text",
@@ -3850,6 +4716,7 @@ const TreeOptionNode = ({
3850
4716
  const {
3851
4717
  formatMessage
3852
4718
  } = reactIntl.useIntl();
4719
+ const baseLanguage = useLocaleTextLanguages()[0]?.value;
3853
4720
  const children = Array.isArray(item.children) ? item.children : [];
3854
4721
  const canAddChild = depth < maxDepth;
3855
4722
  const updateSelf = patch => {
@@ -3884,13 +4751,14 @@ const TreeOptionNode = ({
3884
4751
  className: style['tree-option-row'],
3885
4752
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
3886
4753
  className: style['tree-option-fields'],
3887
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Input, {
4754
+ children: [/*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
4755
+ compact: true,
3888
4756
  value: item.label,
3889
4757
  placeholder: formatMessage({
3890
4758
  id: 'optionLabelPlaceholder'
3891
4759
  }),
3892
- onChange: e => updateSelf(patchOptionLabelChange(item, e.target.value)),
3893
- onBlur: () => updateSelf(trimOptionLabelValue(item))
4760
+ onChange: nextLabel => updateSelf(patchOptionLabelChange(item, nextLabel, baseLanguage)),
4761
+ onBlur: () => updateSelf(trimOptionLabelValue(item, baseLanguage))
3894
4762
  }), /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
3895
4763
  value: item.value,
3896
4764
  placeholder: formatMessage({
@@ -3902,16 +4770,17 @@ const TreeOptionNode = ({
3902
4770
  onBlur: () => updateSelf({
3903
4771
  value: String(item.value ?? '').trim()
3904
4772
  })
3905
- }), allowDescription ? /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
4773
+ }), allowDescription ? /*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
4774
+ compact: true,
3906
4775
  value: item.description || '',
3907
4776
  placeholder: formatMessage({
3908
4777
  id: 'optionDescPlaceholder'
3909
4778
  }),
3910
- onChange: e => updateSelf({
3911
- description: e.target.value
4779
+ onChange: description => updateSelf({
4780
+ description
3912
4781
  }),
3913
4782
  onBlur: () => updateSelf({
3914
- description: String(item.description ?? '').trim()
4783
+ description: trimLocaleText(item.description, baseLanguage)
3915
4784
  })
3916
4785
  }) : null]
3917
4786
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -4019,13 +4888,14 @@ const ColumnsEditor = ({
4019
4888
  gap: 8,
4020
4889
  align: "start",
4021
4890
  className: style['options-row'],
4022
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Input, {
4891
+ children: [/*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
4892
+ compact: true,
4893
+ className: style['options-locale-text'],
4023
4894
  value: item.title || '',
4024
4895
  placeholder: formatMessage({
4025
4896
  id: 'columnTitlePlaceholder'
4026
4897
  }),
4027
- onChange: e => {
4028
- const title = e.target.value;
4898
+ onChange: title => {
4029
4899
  const patch = {
4030
4900
  title
4031
4901
  };
@@ -4095,8 +4965,10 @@ const TableRowsEditor = ({
4095
4965
  onChange
4096
4966
  }) => {
4097
4967
  const {
4098
- formatMessage
4968
+ formatMessage,
4969
+ locale
4099
4970
  } = reactIntl.useIntl();
4971
+ const languages = useLocaleTextLanguages();
4100
4972
  const usableColumns = columns.filter(column => column?.name && String(column.name).trim());
4101
4973
  const list = value.length ? value : [createEmptyTableRow(usableColumns)];
4102
4974
  const updateItem = (index, patch) => {
@@ -4113,7 +4985,7 @@ const TableRowsEditor = ({
4113
4985
  column: 1,
4114
4986
  list: [/*#__PURE__*/jsxRuntime.jsx("div", {
4115
4987
  block: true,
4116
- children: /*#__PURE__*/jsxRuntime.jsx(Text$1, {
4988
+ children: /*#__PURE__*/jsxRuntime.jsx(Text$2, {
4117
4989
  type: "secondary",
4118
4990
  children: formatMessage({
4119
4991
  id: 'tableRowsNeedColumnsHint'
@@ -4171,13 +5043,15 @@ const TableRowsEditor = ({
4171
5043
  onChange: e => updateItem(index, {
4172
5044
  value: e.target.value
4173
5045
  })
4174
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
5046
+ }), /*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
5047
+ compact: true,
5048
+ className: style['options-locale-text'],
4175
5049
  value: item.label || '',
4176
5050
  placeholder: formatMessage({
4177
5051
  id: 'tableRowLabelPlaceholder'
4178
5052
  }),
4179
- onChange: e => updateItem(index, {
4180
- label: e.target.value
5053
+ onChange: label => updateItem(index, {
5054
+ label
4181
5055
  })
4182
5056
  })]
4183
5057
  }), /*#__PURE__*/jsxRuntime.jsx(antd.Flex, {
@@ -4189,7 +5063,7 @@ const TableRowsEditor = ({
4189
5063
  flex: 1
4190
5064
  },
4191
5065
  value: item[column.name] || '',
4192
- placeholder: column.title || column.name,
5066
+ placeholder: resolveLocaleText(column.title, locale, languages) || column.name,
4193
5067
  onChange: e => updateItem(index, {
4194
5068
  [column.name]: e.target.value
4195
5069
  })
@@ -4360,7 +5234,7 @@ const SuperSelectPropsEditor = ({
4360
5234
  display: ({
4361
5235
  openApi
4362
5236
  }) => !openApi?.data?.single
4363
- }, "maxLength"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
5237
+ }, "maxLength"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
4364
5238
  name: "placeholder",
4365
5239
  label: formatMessage({
4366
5240
  id: 'fieldPlaceholder'
@@ -4368,7 +5242,7 @@ const SuperSelectPropsEditor = ({
4368
5242
  placeholder: formatMessage({
4369
5243
  id: 'superSelectPlaceholderHint'
4370
5244
  })
4371
- }, "placeholder"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
5245
+ }, "placeholder"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
4372
5246
  name: "searchPlaceholder",
4373
5247
  label: formatMessage({
4374
5248
  id: 'superSelectSearchPlaceholder'
@@ -4424,7 +5298,7 @@ const buildPropsSchemaList = (schema, formatMessage) => (schema || []).filter(it
4424
5298
  }, item.name);
4425
5299
  });
4426
5300
  const buildBuiltinList = (type, formatMessage) => {
4427
- const placeholder = /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
5301
+ const placeholder = /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
4428
5302
  name: "placeholder",
4429
5303
  label: formatMessage({
4430
5304
  id: 'fieldPlaceholder'
@@ -4604,71 +5478,456 @@ const buildBuiltinList = (type, formatMessage) => {
4604
5478
  })
4605
5479
  }, "showTime")];
4606
5480
  case 'Switch':
4607
- return [/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
5481
+ return [/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
4608
5482
  name: "checkedChildren",
4609
5483
  label: formatMessage({
4610
- id: 'propSwitchOnText'
4611
- }),
4612
- placeholder: formatMessage({
4613
- id: 'propSwitchOnTextHint'
5484
+ id: 'propSwitchOnText'
5485
+ }),
5486
+ placeholder: formatMessage({
5487
+ id: 'propSwitchOnTextHint'
5488
+ })
5489
+ }, "checkedChildren"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
5490
+ name: "unCheckedChildren",
5491
+ label: formatMessage({
5492
+ id: 'propSwitchOffText'
5493
+ }),
5494
+ placeholder: formatMessage({
5495
+ id: 'propSwitchOffTextHint'
5496
+ })
5497
+ }, "unCheckedChildren")];
5498
+ case 'RadioGroup':
5499
+ case 'CheckboxGroup':
5500
+ return [/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Checkbox, {
5501
+ name: "inline",
5502
+ children: formatMessage({
5503
+ id: 'propOptionsInline'
5504
+ })
5505
+ }, "inline")];
5506
+ default:
5507
+ return [];
5508
+ }
5509
+ };
5510
+ const FieldPropsEditor = ({
5511
+ type,
5512
+ definition: definitionProp
5513
+ }) => {
5514
+ const {
5515
+ formatMessage
5516
+ } = reactIntl.useIntl();
5517
+ const definition = definitionProp || getFieldDefinition(type);
5518
+ const list = react.useMemo(() => {
5519
+ if (!type) {
5520
+ return [];
5521
+ }
5522
+ if (definition?.propsSchema?.length) {
5523
+ return buildPropsSchemaList(definition.propsSchema, formatMessage);
5524
+ }
5525
+ return buildBuiltinList(type, formatMessage);
5526
+ }, [type, definition, formatMessage]);
5527
+ if (!list.length) {
5528
+ return null;
5529
+ }
5530
+ return /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
5531
+ title: formatMessage({
5532
+ id: 'fieldPropsSection'
5533
+ }),
5534
+ column: 1,
5535
+ list: list
5536
+ });
5537
+ };
5538
+ const hasFieldPropsEditor = (type, definition) => {
5539
+ const def = definition || getFieldDefinition(type);
5540
+ if (def?.propsSchema?.length) {
5541
+ return true;
5542
+ }
5543
+ return BUILTIN_PROP_TYPES.includes(type);
5544
+ };
5545
+ var FieldPropsEditor$1 = FieldPropsEditor;
5546
+
5547
+ const {
5548
+ Text: Text$1
5549
+ } = antd.Typography;
5550
+ const MULTI_VALUE_OPERATORS = ['in', 'includesAny'];
5551
+ const createCondition = () => ({
5552
+ field: undefined,
5553
+ operator: undefined,
5554
+ value: undefined
5555
+ });
5556
+
5557
+ /** 编辑器提交前校验:返回错误文案 id,通过返回 null */
5558
+ const validateVisibleWhenDraft = visibleWhen => {
5559
+ if (!visibleWhen) {
5560
+ return null;
5561
+ }
5562
+ const incomplete = (visibleWhen.conditions || []).some(condition => {
5563
+ if (!condition?.field || !condition.operator) {
5564
+ return true;
5565
+ }
5566
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
5567
+ return false;
5568
+ }
5569
+ const value = condition.value;
5570
+ return value === undefined || value === null || value === '' || Array.isArray(value) && !value.length;
5571
+ });
5572
+ if (incomplete || !(visibleWhen.conditions || []).length) {
5573
+ return 'visibleWhenConditionRequired';
5574
+ }
5575
+ if (visibleWhen.conditions.some(condition => condition.operator === 'regex' && !compileConditionRegex(condition.value, condition.flags))) {
5576
+ return 'visibleWhenRegexInvalid';
5577
+ }
5578
+ return null;
5579
+ };
5580
+ const RegexTester = ({
5581
+ condition
5582
+ }) => {
5583
+ const {
5584
+ formatMessage
5585
+ } = reactIntl.useIntl();
5586
+ const [text, setText] = react.useState('');
5587
+ const regex = compileConditionRegex(condition.value, condition.flags);
5588
+ const status = regex && text !== '' ? regex.test(text) : null;
5589
+ return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5590
+ gap: 8,
5591
+ align: "center",
5592
+ className: style['visible-when-regex-tester'],
5593
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Input, {
5594
+ size: "small",
5595
+ value: text,
5596
+ placeholder: formatMessage({
5597
+ id: 'visibleWhenRegexTester'
5598
+ }),
5599
+ onChange: e => setText(e.target.value)
5600
+ }), status === null ? null : /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5601
+ type: status ? 'success' : 'warning',
5602
+ children: formatMessage({
5603
+ id: status ? 'visibleWhenRegexMatched' : 'visibleWhenRegexNotMatched'
5604
+ })
5605
+ })]
5606
+ });
5607
+ };
5608
+ const ConditionValueInput = ({
5609
+ condition,
5610
+ trigger,
5611
+ onChange
5612
+ }) => {
5613
+ const {
5614
+ formatMessage,
5615
+ locale
5616
+ } = reactIntl.useIntl();
5617
+ const definition = getFieldDefinition(trigger?.type);
5618
+ const kind = getConditionValueKind(trigger, definition);
5619
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
5620
+ return null;
5621
+ }
5622
+ if (condition.operator === 'regex') {
5623
+ const regexInvalid = condition.value != null && condition.value !== '' && !compileConditionRegex(condition.value, condition.flags);
5624
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
5625
+ className: style['visible-when-regex'],
5626
+ children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5627
+ gap: 8,
5628
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Input, {
5629
+ prefix: "/",
5630
+ suffix: "/",
5631
+ status: regexInvalid ? 'error' : undefined,
5632
+ value: condition.value ?? '',
5633
+ placeholder: formatMessage({
5634
+ id: 'visibleWhenValue'
5635
+ }),
5636
+ onChange: e => onChange({
5637
+ value: e.target.value
5638
+ })
5639
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5640
+ mode: "multiple",
5641
+ className: style['visible-when-flags'],
5642
+ placeholder: formatMessage({
5643
+ id: 'visibleWhenRegexFlags'
5644
+ }),
5645
+ value: String(condition.flags || '').split('').filter(Boolean),
5646
+ options: ALLOWED_REGEX_FLAGS.map(flag => ({
5647
+ value: flag,
5648
+ label: formatMessage({
5649
+ id: `visibleWhenRegexFlag_${flag}`
5650
+ })
5651
+ })),
5652
+ optionLabelProp: "value",
5653
+ onChange: flags => onChange({
5654
+ flags: flags.join('')
5655
+ })
5656
+ })]
5657
+ }), regexInvalid ? /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5658
+ type: "danger",
5659
+ children: formatMessage({
5660
+ id: 'visibleWhenRegexInvalid'
5661
+ })
5662
+ }) : null, /*#__PURE__*/jsxRuntime.jsx(RegexTester, {
5663
+ condition: condition
5664
+ })]
5665
+ });
5666
+ }
5667
+ if (kind === 'boolean') {
5668
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5669
+ className: style['visible-when-value'],
5670
+ value: condition.value,
5671
+ placeholder: formatMessage({
5672
+ id: 'visibleWhenValue'
5673
+ }),
5674
+ options: [{
5675
+ value: true,
5676
+ label: formatMessage({
5677
+ id: 'conditionValueTrue'
4614
5678
  })
4615
- }, "checkedChildren"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4616
- name: "unCheckedChildren",
5679
+ }, {
5680
+ value: false,
4617
5681
  label: formatMessage({
4618
- id: 'propSwitchOffText'
4619
- }),
4620
- placeholder: formatMessage({
4621
- id: 'propSwitchOffTextHint'
4622
- })
4623
- }, "unCheckedChildren")];
4624
- case 'RadioGroup':
4625
- case 'CheckboxGroup':
4626
- return [/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Checkbox, {
4627
- name: "inline",
4628
- children: formatMessage({
4629
- id: 'propOptionsInline'
5682
+ id: 'conditionValueFalse'
4630
5683
  })
4631
- }, "inline")];
4632
- default:
4633
- return [];
5684
+ }],
5685
+ onChange: value => onChange({
5686
+ value
5687
+ })
5688
+ });
5689
+ }
5690
+ if (kind === 'options' || kind === 'multiOptions') {
5691
+ const multiple = MULTI_VALUE_OPERATORS.includes(condition.operator);
5692
+ const options = (trigger?.props?.options || []).filter(item => item?.value != null && item.value !== '').map(item => ({
5693
+ value: item.value,
5694
+ label: resolveLocaleText(item.label, locale) || String(item.value)
5695
+ }));
5696
+ const value = multiple ? Array.isArray(condition.value) ? condition.value : condition.value != null ? [condition.value] : [] : Array.isArray(condition.value) ? condition.value[0] : condition.value;
5697
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5698
+ className: style['visible-when-value']
5699
+ // 远程数据源没有静态选项时允许手动输入值
5700
+ ,
5701
+ mode: options.length ? multiple ? 'multiple' : undefined : 'tags',
5702
+ value: value,
5703
+ placeholder: formatMessage({
5704
+ id: 'visibleWhenValue'
5705
+ }),
5706
+ options: options,
5707
+ onChange: next => onChange({
5708
+ value: !options.length && !multiple && Array.isArray(next) ? next[next.length - 1] : next
5709
+ })
5710
+ });
5711
+ }
5712
+ if (kind === 'number') {
5713
+ return /*#__PURE__*/jsxRuntime.jsx(antd.InputNumber, {
5714
+ className: style['visible-when-value'],
5715
+ value: condition.value ?? null,
5716
+ placeholder: formatMessage({
5717
+ id: 'visibleWhenValue'
5718
+ }),
5719
+ onChange: value => onChange({
5720
+ value: value ?? undefined
5721
+ })
5722
+ });
4634
5723
  }
5724
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
5725
+ className: style['visible-when-value'],
5726
+ value: condition.value ?? '',
5727
+ placeholder: formatMessage({
5728
+ id: 'visibleWhenValue'
5729
+ }),
5730
+ onChange: e => onChange({
5731
+ value: e.target.value
5732
+ })
5733
+ });
4635
5734
  };
4636
- const FieldPropsEditor = ({
4637
- type,
4638
- definition: definitionProp
5735
+
5736
+ /**
5737
+ * 条件显示配置(受控):value 为 visibleWhen 草稿或 undefined
5738
+ * triggerFields:collectConditionFields 中可作为触发项的字段;scope:当前字段所在模块
5739
+ */
5740
+ const VisibleWhenEditor = ({
5741
+ value,
5742
+ onChange,
5743
+ schema,
5744
+ triggerFields = [],
5745
+ scope,
5746
+ fieldId
4639
5747
  }) => {
4640
5748
  const {
4641
- formatMessage
5749
+ formatMessage,
5750
+ locale
4642
5751
  } = reactIntl.useIntl();
4643
- const definition = definitionProp || getFieldDefinition(type);
4644
- const list = react.useMemo(() => {
4645
- if (!type) {
4646
- return [];
4647
- }
4648
- if (definition?.propsSchema?.length) {
4649
- return buildPropsSchemaList(definition.propsSchema, formatMessage);
4650
- }
4651
- return buildBuiltinList(type, formatMessage);
4652
- }, [type, definition, formatMessage]);
4653
- if (!list.length) {
4654
- return null;
5752
+ const {
5753
+ formData
5754
+ } = reactFormAntd.useFormContext() || {};
5755
+ const selfPath = getFieldConditionPath(scope, formData?.name ? String(formData.name).trim() : '');
5756
+ const candidates = react.useMemo(() => triggerFields.filter(item => item.id !== fieldId && item.path !== selfPath).map(item => ({
5757
+ ...item,
5758
+ disabled: selfPath ? wouldCreateCycle(schema, selfPath, item.path) : false
5759
+ })), [triggerFields, fieldId, selfPath, schema]);
5760
+ if (scope?.inList) {
5761
+ return /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
5762
+ title: formatMessage({
5763
+ id: 'visibleWhenTitle'
5764
+ }),
5765
+ column: 1,
5766
+ list: [/*#__PURE__*/jsxRuntime.jsx("div", {
5767
+ block: true,
5768
+ children: /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5769
+ type: "secondary",
5770
+ children: formatMessage({
5771
+ id: 'visibleWhenListUnsupported'
5772
+ })
5773
+ })
5774
+ }, "unsupported")]
5775
+ });
4655
5776
  }
5777
+ const enabled = !!value;
5778
+ const conditions = value?.conditions || [];
5779
+ const updateConditions = next => onChange({
5780
+ ...value,
5781
+ conditions: next
5782
+ });
5783
+ const updateCondition = (index, patch) => updateConditions(conditions.map((item, itemIndex) => itemIndex === index ? {
5784
+ ...item,
5785
+ ...patch
5786
+ } : item));
5787
+ const body = /*#__PURE__*/jsxRuntime.jsxs("div", {
5788
+ block: true,
5789
+ className: style['visible-when-editor'],
5790
+ children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5791
+ gap: 8,
5792
+ align: "center",
5793
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Switch, {
5794
+ size: "small",
5795
+ checked: enabled,
5796
+ disabled: !enabled && !candidates.length,
5797
+ onChange: checked => onChange(checked ? {
5798
+ logic: 'and',
5799
+ conditions: [createCondition()]
5800
+ } : undefined)
5801
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5802
+ children: formatMessage({
5803
+ id: 'visibleWhenEnable'
5804
+ })
5805
+ })]
5806
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5807
+ type: "secondary",
5808
+ className: style['visible-when-hint'],
5809
+ children: formatMessage({
5810
+ id: candidates.length || enabled ? 'visibleWhenEnableTips' : 'visibleWhenNoTrigger'
5811
+ })
5812
+ }), enabled ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5813
+ children: [conditions.length > 1 ? /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5814
+ gap: 8,
5815
+ align: "center",
5816
+ children: [/*#__PURE__*/jsxRuntime.jsx(Text$1, {
5817
+ children: formatMessage({
5818
+ id: 'visibleWhenLogic'
5819
+ })
5820
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Radio.Group, {
5821
+ size: "small",
5822
+ value: value.logic === 'or' ? 'or' : 'and',
5823
+ options: ['and', 'or'].map(logic => ({
5824
+ value: logic,
5825
+ label: formatMessage({
5826
+ id: `conditionLogic_${logic}`
5827
+ })
5828
+ })),
5829
+ onChange: e => onChange({
5830
+ ...value,
5831
+ logic: e.target.value
5832
+ })
5833
+ })]
5834
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5835
+ className: style['visible-when-list'],
5836
+ children: conditions.map((condition, index) => {
5837
+ const trigger = triggerFields.find(item => item.path === condition.field)?.field;
5838
+ const operators = trigger ? getConditionOperators(trigger, getFieldDefinition(trigger.type)) : [];
5839
+ return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5840
+ gap: 8,
5841
+ align: "start",
5842
+ className: style['visible-when-row'],
5843
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
5844
+ className: style['visible-when-row-main'],
5845
+ children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5846
+ gap: 8,
5847
+ wrap: true,
5848
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5849
+ showSearch: true,
5850
+ optionFilterProp: "label",
5851
+ className: style['visible-when-field'],
5852
+ status: condition.field && !trigger ? 'error' : undefined,
5853
+ value: condition.field,
5854
+ placeholder: formatMessage({
5855
+ id: 'visibleWhenField'
5856
+ }),
5857
+ options: candidates.map(item => ({
5858
+ value: item.path,
5859
+ disabled: item.disabled,
5860
+ label: `${resolveLocaleText(item.field.label, locale) || item.field.name}(${item.path})`
5861
+ })),
5862
+ onChange: path => {
5863
+ const nextTrigger = triggerFields.find(item => item.path === path)?.field;
5864
+ const nextOperators = getConditionOperators(nextTrigger, getFieldDefinition(nextTrigger?.type));
5865
+ updateCondition(index, {
5866
+ field: path,
5867
+ operator: nextOperators[0],
5868
+ value: undefined,
5869
+ flags: undefined
5870
+ });
5871
+ }
5872
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5873
+ className: style['visible-when-operator'],
5874
+ value: condition.operator,
5875
+ disabled: !trigger,
5876
+ placeholder: formatMessage({
5877
+ id: 'visibleWhenOperator'
5878
+ }),
5879
+ options: operators.map(operator => ({
5880
+ value: operator,
5881
+ label: formatMessage({
5882
+ id: `conditionOperator_${operator}`
5883
+ })
5884
+ })),
5885
+ onChange: operator => updateCondition(index, {
5886
+ operator,
5887
+ value: undefined,
5888
+ flags: undefined
5889
+ })
5890
+ })]
5891
+ }), trigger && condition.operator ? /*#__PURE__*/jsxRuntime.jsx(ConditionValueInput, {
5892
+ condition: condition,
5893
+ trigger: trigger,
5894
+ onChange: patch => updateCondition(index, patch)
5895
+ }) : null]
5896
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
5897
+ type: "text",
5898
+ danger: true,
5899
+ className: style['icon-square-btn-sm'],
5900
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.DeleteOutlined, {}),
5901
+ onClick: () => {
5902
+ const next = conditions.filter((_, itemIndex) => itemIndex !== index);
5903
+ onChange(next.length ? {
5904
+ ...value,
5905
+ conditions: next
5906
+ } : undefined);
5907
+ }
5908
+ })]
5909
+ }, index);
5910
+ })
5911
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
5912
+ type: "dashed",
5913
+ block: true,
5914
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.PlusOutlined, {}),
5915
+ onClick: () => updateConditions([...conditions, createCondition()]),
5916
+ children: formatMessage({
5917
+ id: 'visibleWhenAddCondition'
5918
+ })
5919
+ })]
5920
+ }) : null]
5921
+ }, "visible-when");
4656
5922
  return /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
4657
5923
  title: formatMessage({
4658
- id: 'fieldPropsSection'
5924
+ id: 'visibleWhenTitle'
4659
5925
  }),
4660
5926
  column: 1,
4661
- list: list
5927
+ list: [body]
4662
5928
  });
4663
5929
  };
4664
- const hasFieldPropsEditor = (type, definition) => {
4665
- const def = definition || getFieldDefinition(type);
4666
- if (def?.propsSchema?.length) {
4667
- return true;
4668
- }
4669
- return BUILTIN_PROP_TYPES.includes(type);
4670
- };
4671
- var FieldPropsEditor$1 = FieldPropsEditor;
5930
+ var VisibleWhenEditor$1 = VisibleWhenEditor;
4672
5931
 
4673
5932
  const {
4674
5933
  Text
@@ -4693,7 +5952,10 @@ const FieldConfigFields = ({
4693
5952
  options,
4694
5953
  onOptionsChange,
4695
5954
  columns,
4696
- onColumnsChange
5955
+ onColumnsChange,
5956
+ visibleWhen,
5957
+ onVisibleWhenChange,
5958
+ conditionProps
4697
5959
  }) => {
4698
5960
  const {
4699
5961
  formatMessage
@@ -4752,7 +6014,7 @@ const FieldConfigFields = ({
4752
6014
  placeholder: formatMessage({
4753
6015
  id: 'fieldNamePlaceholder'
4754
6016
  })
4755
- }, "name"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
6017
+ }, "name"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
4756
6018
  name: "label",
4757
6019
  label: formatMessage({
4758
6020
  id: 'fieldLabel'
@@ -4761,7 +6023,7 @@ const FieldConfigFields = ({
4761
6023
  placeholder: formatMessage({
4762
6024
  id: 'fieldLabelPlaceholder'
4763
6025
  })
4764
- }, "label"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
6026
+ }, "label"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
4765
6027
  name: "tips",
4766
6028
  label: formatMessage({
4767
6029
  id: 'fieldTips'
@@ -4769,7 +6031,7 @@ const FieldConfigFields = ({
4769
6031
  placeholder: formatMessage({
4770
6032
  id: 'fieldTipsPlaceholder'
4771
6033
  })
4772
- }, "tips"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.TextArea, {
6034
+ }, "tips"), /*#__PURE__*/jsxRuntime.jsx(LocaleTextArea, {
4773
6035
  name: "description",
4774
6036
  label: formatMessage({
4775
6037
  id: 'fieldDescription'
@@ -4816,6 +6078,10 @@ const FieldConfigFields = ({
4816
6078
  hasColumns: definition.hasColumns,
4817
6079
  columns: columns,
4818
6080
  onColumnsChange: onColumnsChange
6081
+ }) : null, conditionProps ? /*#__PURE__*/jsxRuntime.jsx(VisibleWhenEditor$1, {
6082
+ ...conditionProps,
6083
+ value: visibleWhen,
6084
+ onChange: onVisibleWhenChange
4819
6085
  }) : null]
4820
6086
  });
4821
6087
  };
@@ -4823,6 +6089,7 @@ const FieldEditorModal = ({
4823
6089
  open,
4824
6090
  field,
4825
6091
  fieldList,
6092
+ conditionProps,
4826
6093
  onCancel,
4827
6094
  onSave,
4828
6095
  renderModal
@@ -4859,6 +6126,7 @@ const FieldEditorModal = ({
4859
6126
  value: ''
4860
6127
  }]);
4861
6128
  const [columns, setColumns] = react.useState(() => [createEmptyColumn()]);
6129
+ const [visibleWhen, setVisibleWhen] = react.useState(undefined);
4862
6130
  react.useEffect(() => {
4863
6131
  if (!open) {
4864
6132
  return;
@@ -4868,6 +6136,7 @@ const FieldEditorModal = ({
4868
6136
  value: ''
4869
6137
  }]);
4870
6138
  setColumns(editorValues.selectProps?.columns?.length ? editorValues.selectProps.columns : [createEmptyColumn()]);
6139
+ setVisibleWhen(editorValues.visibleWhen);
4871
6140
  }, [open, editorValues]);
4872
6141
  const handleSubmit = function (values) {
4873
6142
  try {
@@ -4877,6 +6146,13 @@ const FieldEditorModal = ({
4877
6146
  }));
4878
6147
  return Promise.resolve(false);
4879
6148
  }
6149
+ const conditionError = conditionProps && !conditionProps.scope?.inList ? validateVisibleWhenDraft(visibleWhen) : null;
6150
+ if (conditionError) {
6151
+ antd.message.error(formatMessage({
6152
+ id: conditionError
6153
+ }));
6154
+ return Promise.resolve(false);
6155
+ }
4880
6156
  const definition = getFieldDefinition(values.type);
4881
6157
  const normalizedColumns = definition?.hasColumns ? normalizeColumns(columns) : [];
4882
6158
  const nextField = formValuesToField({
@@ -4894,13 +6170,13 @@ const FieldEditorModal = ({
4894
6170
  ...values,
4895
6171
  columns: normalizedColumns
4896
6172
  },
4897
- fieldProps: values
6173
+ fieldProps: values,
6174
+ visibleWhen
4898
6175
  }, field || createField$1());
4899
6176
  if (!nextField.id) {
4900
6177
  nextField.id = createField$1().id;
4901
6178
  }
4902
- onSave(nextField);
4903
- return Promise.resolve();
6179
+ return Promise.resolve(onSave(nextField));
4904
6180
  } catch (e) {
4905
6181
  return Promise.reject(e);
4906
6182
  }
@@ -4933,7 +6209,13 @@ const FieldEditorModal = ({
4933
6209
  options: options,
4934
6210
  onOptionsChange: setOptions,
4935
6211
  columns: columns,
4936
- onColumnsChange: setColumns
6212
+ onColumnsChange: setColumns,
6213
+ visibleWhen: visibleWhen,
6214
+ onVisibleWhenChange: setVisibleWhen,
6215
+ conditionProps: conditionProps ? {
6216
+ ...conditionProps,
6217
+ fieldId: field?.id
6218
+ } : null
4937
6219
  })
4938
6220
  }, modalKey);
4939
6221
  };
@@ -5008,7 +6290,7 @@ const FormActionsEditor = ({
5008
6290
  id: 'formActionsShowSubmit'
5009
6291
  }),
5010
6292
  className: style['form-actions-switch-field']
5011
- }, "showSubmit"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
6293
+ }, "showSubmit"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
5012
6294
  name: "submitText",
5013
6295
  label: formatMessage({
5014
6296
  id: 'formActionsSubmitText'
@@ -5028,7 +6310,7 @@ const FormActionsEditor = ({
5028
6310
  id: 'formActionsShowReset'
5029
6311
  }),
5030
6312
  className: style['form-actions-switch-field']
5031
- }, "showReset"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
6313
+ }, "showReset"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
5032
6314
  name: "resetText",
5033
6315
  label: formatMessage({
5034
6316
  id: 'formActionsResetText'
@@ -5048,7 +6330,7 @@ const FormActionsEditor = ({
5048
6330
  id: 'formActionsShowCancel'
5049
6331
  }),
5050
6332
  className: style['form-actions-switch-field']
5051
- }, "showCancel"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
6333
+ }, "showCancel"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
5052
6334
  name: "cancelText",
5053
6335
  label: formatMessage({
5054
6336
  id: 'formActionsCancelText'
@@ -5383,6 +6665,100 @@ const ChoiceBlock = ({
5383
6665
  };
5384
6666
  var ChoiceBlock$1 = ChoiceBlock;
5385
6667
 
6668
+ /**
6669
+ * 按 visibleWhen 过滤字段的 FormInfo:
6670
+ * entries 为 [{ element, path, visibleWhen }],不满足条件的字段从 list 中移除(卸载即不参与校验),
6671
+ * 已有值的隐藏字段清空,避免提交残留
6672
+ */
6673
+ const ConditionalFormInfo = ({
6674
+ entries,
6675
+ nested = [],
6676
+ knownNames,
6677
+ ...formInfoProps
6678
+ }) => {
6679
+ const {
6680
+ formData,
6681
+ openApi
6682
+ } = reactFormAntd.useFormContext() || {};
6683
+ const hasForm = !!openApi;
6684
+ const hiddenPaths = react.useMemo(() => {
6685
+ if (!hasForm) {
6686
+ return [];
6687
+ }
6688
+ return entries.filter(entry => entry.visibleWhen && !evaluateVisibleWhen(entry.visibleWhen, formData, knownNames)).map(entry => entry.path);
6689
+ }, [entries, formData, knownNames, hasForm]);
6690
+ react.useEffect(() => {
6691
+ if (!hasForm) {
6692
+ return;
6693
+ }
6694
+ const toClear = hiddenPaths.filter(path => !isEmptyValue$1(getByPath$2(formData, path)));
6695
+ if (toClear.length) {
6696
+ openApi.setFields(toClear.map(name => ({
6697
+ name,
6698
+ value: undefined
6699
+ })), {
6700
+ runValidate: false
6701
+ });
6702
+ }
6703
+ }, [hiddenPaths, formData, openApi, hasForm]);
6704
+ const list = entries.filter(entry => !hiddenPaths.includes(entry.path)).map(entry => entry.element);
6705
+ return /*#__PURE__*/react.createElement(FormInfo__default["default"], {
6706
+ ...formInfoProps,
6707
+ list: [...list, ...nested]
6708
+ });
6709
+ };
6710
+ var ConditionalFormInfo$1 = ConditionalFormInfo;
6711
+
6712
+ // @kne/react-form 内置规则的错误提示写死中文;在 preset 覆盖前记下原函数,只替换未被业务覆盖的规则
6713
+ const BUILTIN_RULES = {
6714
+ TEL: reactFormAntd.RULES.TEL,
6715
+ EMAIL: reactFormAntd.RULES.EMAIL,
6716
+ LEN: reactFormAntd.RULES.LEN
6717
+ };
6718
+ const isBuiltin = name => reactFormAntd.RULES[name] === BUILTIN_RULES[name];
6719
+ const lenMessageId = (value, start, end) => {
6720
+ if (end === start) {
6721
+ return 'ruleErrorLenEqual';
6722
+ }
6723
+ return String(value ?? '').length < start ? 'ruleErrorLenMin' : 'ruleErrorLenMax';
6724
+ };
6725
+
6726
+ /** 按当前语言生成表单级 rules,传给 Form 覆盖全局同名规则 */
6727
+ const createLocalizedRules = formatMessage => {
6728
+ if (typeof formatMessage !== 'function') {
6729
+ return {};
6730
+ }
6731
+ const rules = {};
6732
+ ['TEL', 'EMAIL'].forEach(name => {
6733
+ if (isBuiltin(name)) {
6734
+ rules[name] = function () {
6735
+ const res = BUILTIN_RULES[name](...[].slice.call(arguments));
6736
+ return res.result ? res : {
6737
+ ...res,
6738
+ errMsg: formatMessage({
6739
+ id: `ruleError${name}`
6740
+ })
6741
+ };
6742
+ };
6743
+ }
6744
+ });
6745
+ if (isBuiltin('LEN')) {
6746
+ rules.LEN = (value, start, end) => {
6747
+ const res = BUILTIN_RULES.LEN(value, start, end);
6748
+ return res.result ? res : {
6749
+ ...res,
6750
+ errMsg: formatMessage({
6751
+ id: lenMessageId(value, start, end)
6752
+ }, {
6753
+ start,
6754
+ end
6755
+ })
6756
+ };
6757
+ };
6758
+ }
6759
+ return rules;
6760
+ };
6761
+
5386
6762
  const buildLabelTips = tips => {
5387
6763
  if (tips == null || !String(tips).trim()) {
5388
6764
  return undefined;
@@ -5414,11 +6790,11 @@ const buildIndexedLabelRender = index => {
5414
6790
  }, text) : null);
5415
6791
  };
5416
6792
  };
5417
- const renderFieldElements = (fields = [], preview = false, {
6793
+ const renderFieldEntries = (fields = [], preview = false, {
5418
6794
  namePrefix,
5419
6795
  locale,
5420
6796
  showIndex = false
5421
- } = {}) => fields.filter(field => !field.hidden).map((field, index) => {
6797
+ } = {}) => (fields || []).filter(field => !field.hidden).map((field, index) => {
5422
6798
  const Component = getFieldComponent(field.type, field);
5423
6799
  if (!Component) {
5424
6800
  return null;
@@ -5454,7 +6830,7 @@ const renderFieldElements = (fields = [], preview = false, {
5454
6830
  locale
5455
6831
  } : {};
5456
6832
  const label = buildFieldLabel(field);
5457
- return /*#__PURE__*/react.createElement(Component, {
6833
+ const element = /*#__PURE__*/react.createElement(Component, {
5458
6834
  key: field.id,
5459
6835
  name: fieldName,
5460
6836
  label: showIndex ? label || '\u200b' : label,
@@ -5468,7 +6844,29 @@ const renderFieldElements = (fields = [], preview = false, {
5468
6844
  labelTips: buildLabelTips(field.tips),
5469
6845
  description
5470
6846
  });
6847
+ return {
6848
+ element,
6849
+ path: fieldName,
6850
+ visibleWhen: hasVisibleWhen(field) ? field.visibleWhen : null
6851
+ };
5471
6852
  }).filter(Boolean);
6853
+ const renderFieldElements = (fields, preview, opts) => renderFieldEntries(fields, preview, opts).map(entry => entry.element);
6854
+
6855
+ /** 字段含 visibleWhen 时换成 ConditionalFormInfo,否则保持普通 FormInfo */
6856
+ const createFieldsFormInfo = (formInfoProps, entries, nested = [], knownNames) => {
6857
+ if (entries.some(entry => entry.visibleWhen)) {
6858
+ return /*#__PURE__*/react.createElement(ConditionalFormInfo$1, {
6859
+ ...formInfoProps,
6860
+ entries,
6861
+ nested,
6862
+ knownNames
6863
+ });
6864
+ }
6865
+ return /*#__PURE__*/react.createElement(FormInfo__default["default"], {
6866
+ ...formInfoProps,
6867
+ list: [...entries.map(entry => entry.element), ...nested]
6868
+ });
6869
+ };
5472
6870
  const withBlockLayout = (element, forceBlock) => {
5473
6871
  if (!element || !forceBlock) {
5474
6872
  return element;
@@ -5505,7 +6903,8 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5505
6903
  formatMessage,
5506
6904
  depth = 0,
5507
6905
  asListItem = false,
5508
- locale
6906
+ locale,
6907
+ knownNames
5509
6908
  } = ctx;
5510
6909
  if (!block || depth > MAX_BLOCK_DEPTH) {
5511
6910
  return null;
@@ -5535,41 +6934,39 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5535
6934
  case 'formInfo':
5536
6935
  {
5537
6936
  const showIndex = !!block.showIndex;
5538
- const fields = renderFieldElements(block.list, preview, {
6937
+ const entries = renderFieldEntries(block.list, preview, {
5539
6938
  ...fieldRenderOpts,
5540
6939
  showIndex
5541
6940
  });
5542
6941
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
5543
- return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo__default["default"], {
6942
+ return withBlockLayout(createFieldsFormInfo({
5544
6943
  key: block.id,
5545
6944
  title: block.title || undefined,
5546
6945
  subtitle: block.subtitle || undefined,
5547
6946
  column: block.column,
5548
6947
  gap: block.gap,
5549
6948
  bordered,
5550
- list: [...fields, ...nested],
5551
6949
  ...(listItemPartProps || {}),
5552
6950
  className: resolvePartRootClassName(depth, showIndex ? style['form-info-show-index'] : null)
5553
- }), asListItem);
6951
+ }, entries, nested, knownNames), asListItem);
5554
6952
  }
5555
6953
  case 'object':
5556
6954
  {
5557
- const fields = renderFieldElements(block.list, preview, {
6955
+ const entries = renderFieldEntries(block.list, preview, {
5558
6956
  ...fieldRenderOpts,
5559
6957
  namePrefix: block.name || ''
5560
6958
  });
5561
6959
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
5562
- return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo__default["default"], {
6960
+ return withBlockLayout(createFieldsFormInfo({
5563
6961
  key: block.id,
5564
6962
  title: block.title || undefined,
5565
6963
  subtitle: block.subtitle || undefined,
5566
6964
  column: block.column,
5567
6965
  gap: block.gap,
5568
6966
  bordered,
5569
- list: [...fields, ...nested],
5570
6967
  ...(listItemPartProps || {}),
5571
6968
  className: resolvePartRootClassName(depth)
5572
- }), asListItem);
6969
+ }, entries, nested, knownNames), asListItem);
5573
6970
  }
5574
6971
  case 'list':
5575
6972
  {
@@ -5664,10 +7061,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5664
7061
  prevIcon: /*#__PURE__*/react.createElement(icons.ArrowLeftOutlined),
5665
7062
  nextIcon: /*#__PURE__*/react.createElement(icons.ArrowRightOutlined),
5666
7063
  items: (block.items || []).map(step => {
5667
- const fields = renderFieldElements(step.list, preview, fieldRenderOpts);
7064
+ const entries = renderFieldEntries(step.list, preview, fieldRenderOpts);
5668
7065
  const nested = renderChildBlocks(step.blocks || [], nextCtx);
5669
7066
  const fieldNames = [...(step.list || []).filter(field => field && !field.hidden && field.name).map(field => field.name), ...collectBlockFieldNames(step.blocks || [])];
5670
- if (nested.length) {
7067
+ const hasConditional = entries.some(entry => entry.visibleWhen);
7068
+ if (nested.length || hasConditional) {
5671
7069
  return {
5672
7070
  key: step.id,
5673
7071
  title: step.title,
@@ -5676,12 +7074,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5676
7074
  fieldNames,
5677
7075
  children: /*#__PURE__*/react.createElement(react.Fragment, {
5678
7076
  key: `${step.id}-body`
5679
- }, fields.length ? /*#__PURE__*/react.createElement(FormInfo__default["default"], {
7077
+ }, entries.length ? createFieldsFormInfo({
5680
7078
  key: `${step.id}-fields`,
5681
7079
  column: step.column,
5682
- gap: block.gap,
5683
- list: fields
5684
- }) : null, ...nested)
7080
+ gap: block.gap
7081
+ }, entries, [], knownNames) : null, ...nested)
5685
7082
  };
5686
7083
  }
5687
7084
  return {
@@ -5689,7 +7086,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5689
7086
  title: step.title,
5690
7087
  column: step.column,
5691
7088
  gap: block.gap,
5692
- list: fields,
7089
+ list: entries.map(entry => entry.element),
5693
7090
  fieldNames
5694
7091
  };
5695
7092
  })
@@ -5706,12 +7103,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5706
7103
  renderOptionContent: option => {
5707
7104
  const nodes = [];
5708
7105
  if ((option.list || []).length) {
5709
- nodes.push(/*#__PURE__*/react.createElement(FormInfo__default["default"], {
7106
+ nodes.push(createFieldsFormInfo({
5710
7107
  key: `${option.id}-fields`,
5711
7108
  column: block.column || 2,
5712
- gap: block.gap,
5713
- list: renderFieldElements(option.list, preview)
5714
- }));
7109
+ gap: block.gap
7110
+ }, renderFieldEntries(option.list, preview), [], knownNames));
5715
7111
  }
5716
7112
  nodes.push(...renderChildBlocks(option.blocks || [], nextCtx));
5717
7113
  return nodes.filter(Boolean);
@@ -5733,10 +7129,12 @@ const renderSchemaInner = (schema, {
5733
7129
  } = {}) => {
5734
7130
  const normalized = normalizeSchema(schema);
5735
7131
  const blocks = normalized.blocks || [];
7132
+ const knownNames = collectTriggerNames(normalized);
5736
7133
  const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
5737
7134
  isMobile,
5738
7135
  formatMessage,
5739
- locale
7136
+ locale,
7137
+ knownNames
5740
7138
  })).filter(Boolean);
5741
7139
  if (!contentChildren.length && !children && !actionNode) {
5742
7140
  return null;
@@ -5762,10 +7160,12 @@ const renderSchemaContent = (schema, {
5762
7160
  } = {}) => {
5763
7161
  const normalized = normalizeSchema(schema);
5764
7162
  const blocks = normalized.blocks || [];
7163
+ const knownNames = collectTriggerNames(normalized);
5765
7164
  const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
5766
7165
  isMobile,
5767
7166
  formatMessage,
5768
- locale
7167
+ locale,
7168
+ knownNames
5769
7169
  })).filter(Boolean);
5770
7170
  if (!contentChildren.length && !children) {
5771
7171
  return null;
@@ -5773,6 +7173,10 @@ const renderSchemaContent = (schema, {
5773
7173
  const formClassName = [style['schema-form'], formProps.className, className].filter(Boolean).join(' ');
5774
7174
  return /*#__PURE__*/react.createElement(FormInfo.Form, {
5775
7175
  ...formProps,
7176
+ rules: {
7177
+ ...createLocalizedRules(formatMessage),
7178
+ ...formProps.rules
7179
+ },
5776
7180
  className: formClassName
5777
7181
  }, /*#__PURE__*/react.createElement('div', {
5778
7182
  className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
@@ -5884,14 +7288,15 @@ const SchemaRendererInner = withLocale$1(props => {
5884
7288
  bodyClassName,
5885
7289
  footerClassName,
5886
7290
  buttonFooter = false,
5887
- buttonFooterProps
7291
+ buttonFooterProps,
7292
+ languages
5888
7293
  } = props;
5889
7294
  const {
5890
7295
  formatMessage,
5891
7296
  locale
5892
7297
  } = reactIntl.useIntl();
5893
7298
  const isMobile = responsiveUtils.useIsMobile();
5894
- const normalized = normalizeSchema(schema);
7299
+ const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
5895
7300
  if (!hasRenderableContent(normalized)) {
5896
7301
  return null;
5897
7302
  }
@@ -5949,14 +7354,15 @@ const SchemaRenderer = withLocale$1(props => {
5949
7354
  bodyClassName,
5950
7355
  footerClassName,
5951
7356
  buttonFooter = false,
5952
- buttonFooterProps
7357
+ buttonFooterProps,
7358
+ languages
5953
7359
  } = props;
5954
7360
  const {
5955
7361
  formatMessage,
5956
7362
  locale
5957
7363
  } = reactIntl.useIntl();
5958
7364
  const isMobile = responsiveUtils.useIsMobile();
5959
- const normalized = normalizeSchema(schema);
7365
+ const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
5960
7366
  if (!hasRenderableContent(normalized)) {
5961
7367
  return null;
5962
7368
  }
@@ -6002,7 +7408,8 @@ const FormCreator = withLocale$1(({
6002
7408
  className,
6003
7409
  formProps,
6004
7410
  renderModal,
6005
- extraToolbar
7411
+ extraToolbar,
7412
+ languages
6006
7413
  }) => {
6007
7414
  const {
6008
7415
  formatMessage,
@@ -6106,6 +7513,9 @@ const FormCreator = withLocale$1(({
6106
7513
  clearBlockEditor();
6107
7514
  };
6108
7515
  const handleDeleteBlock = blockId => {
7516
+ if (blockHasLockedField(findBlock(schema, blockId))) {
7517
+ return;
7518
+ }
6109
7519
  updateSchema(updateBlocks(schema, blocks => removeBlockInTree(blocks, blockId)));
6110
7520
  };
6111
7521
  const handleMoveBlock = (blockId, direction) => {
@@ -6142,13 +7552,13 @@ const FormCreator = withLocale$1(({
6142
7552
  const handleDeleteStep = (blockId, stepId) => {
6143
7553
  updateSchema(mapBlocks(schema, blockId, block => ({
6144
7554
  ...block,
6145
- items: (block.items || []).filter(item => item.id !== stepId)
7555
+ items: (block.items || []).filter(item => item.id !== stepId || blockHasLockedField(item))
6146
7556
  })));
6147
7557
  };
6148
7558
  const handleMoveStep = (blockId, stepId, direction) => {
6149
7559
  updateSchema(mapBlocks(schema, blockId, block => ({
6150
7560
  ...block,
6151
- items: moveItem(block.items || [], stepId, direction)
7561
+ items: moveItem(block.items || [], stepId, direction, blockHasLockedField)
6152
7562
  })));
6153
7563
  };
6154
7564
  const handleAddChoiceOption = blockId => {
@@ -6182,13 +7592,13 @@ const FormCreator = withLocale$1(({
6182
7592
  const handleDeleteChoiceOption = (blockId, optionId) => {
6183
7593
  updateSchema(mapBlocks(schema, blockId, block => ({
6184
7594
  ...block,
6185
- options: (block.options || []).filter(item => item.id !== optionId)
7595
+ options: (block.options || []).filter(item => item.id !== optionId || blockHasLockedField(item))
6186
7596
  })));
6187
7597
  };
6188
7598
  const handleMoveChoiceOption = (blockId, optionId, direction) => {
6189
7599
  updateSchema(mapBlocks(schema, blockId, block => ({
6190
7600
  ...block,
6191
- options: moveItem(block.options || [], optionId, direction)
7601
+ options: moveItem(block.options || [], optionId, direction, blockHasLockedField)
6192
7602
  })));
6193
7603
  };
6194
7604
  const normalizeFieldScope = scope => {
@@ -6208,6 +7618,9 @@ const FormCreator = withLocale$1(({
6208
7618
  setFieldEditorOpen(true);
6209
7619
  };
6210
7620
  const handleEditField = (blockId, field, scope) => {
7621
+ if (isFieldLocked(field)) {
7622
+ return;
7623
+ }
6211
7624
  setFieldContext({
6212
7625
  blockId,
6213
7626
  ...normalizeFieldScope(scope)
@@ -6221,7 +7634,7 @@ const FormCreator = withLocale$1(({
6221
7634
  stepId,
6222
7635
  optionId
6223
7636
  } = fieldContext || {};
6224
- updateSchema(mapBlocks(schema, blockId, block => {
7637
+ let nextSchema = mapBlocks(schema, blockId, block => {
6225
7638
  if (block.kind === 'steps') {
6226
7639
  return {
6227
7640
  ...block,
@@ -6257,7 +7670,21 @@ const FormCreator = withLocale$1(({
6257
7670
  ...block,
6258
7671
  list: exists ? block.list.map(item => item.id === field.id ? field : item) : [...(block.list || []), field]
6259
7672
  };
6260
- }));
7673
+ });
7674
+ if (editingField?.name && editingField.name !== field.name) {
7675
+ const scope = getBlockConditionScope(schema, blockId);
7676
+ nextSchema = renameConditionReferences(nextSchema, getFieldConditionPath(scope, editingField.name), getFieldConditionPath(scope, field.name));
7677
+ }
7678
+ const cycle = findConditionCycle(nextSchema);
7679
+ if (cycle) {
7680
+ antd.message.error(formatMessage({
7681
+ id: 'visibleWhenCycle'
7682
+ }, {
7683
+ path: cycle.join(' → ')
7684
+ }));
7685
+ return false;
7686
+ }
7687
+ updateSchema(nextSchema);
6261
7688
  setFieldEditorOpen(false);
6262
7689
  setFieldContext(null);
6263
7690
  setEditingField(null);
@@ -6273,7 +7700,7 @@ const FormCreator = withLocale$1(({
6273
7700
  ...block,
6274
7701
  items: (block.items || []).map(step => step.id === stepId ? {
6275
7702
  ...step,
6276
- list: (step.list || []).filter(item => item.id !== fieldId)
7703
+ list: (step.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6277
7704
  } : step)
6278
7705
  };
6279
7706
  }
@@ -6282,13 +7709,13 @@ const FormCreator = withLocale$1(({
6282
7709
  ...block,
6283
7710
  options: (block.options || []).map(option => option.id === optionId ? {
6284
7711
  ...option,
6285
- list: (option.list || []).filter(item => item.id !== fieldId)
7712
+ list: (option.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6286
7713
  } : option)
6287
7714
  };
6288
7715
  }
6289
7716
  return {
6290
7717
  ...block,
6291
- list: (block.list || []).filter(item => item.id !== fieldId)
7718
+ list: (block.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6292
7719
  };
6293
7720
  }));
6294
7721
  };
@@ -6327,98 +7754,108 @@ const FormCreator = withLocale$1(({
6327
7754
  stepId: fieldContext.stepId,
6328
7755
  optionId: fieldContext.optionId
6329
7756
  }) : [];
7757
+ const conditionProps = react.useMemo(() => fieldContext ? {
7758
+ schema,
7759
+ scope: getBlockConditionScope(schema, fieldContext.blockId),
7760
+ triggerFields: collectConditionFields(schema).filter(item => !item.inList)
7761
+ } : null, [schema, fieldContext]);
6330
7762
  const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
6331
7763
  schema
6332
7764
  }) : extraToolbar;
6333
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
6334
- className: [style['form-creator'], responsiveUtils.RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
6335
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
6336
- className: style['editor-pane'],
6337
- children: /*#__PURE__*/jsxRuntime.jsx(BlockListPanel$1, {
6338
- blocks: schema.blocks,
6339
- onAddBlock: handleAddBlock,
6340
- onEditBlock: handleEditBlock,
6341
- onDeleteBlock: handleDeleteBlock,
6342
- onMoveBlock: handleMoveBlock,
6343
- onAddField: handleAddField,
6344
- onEditField: handleEditField,
6345
- onDeleteField: handleDeleteField,
6346
- onMoveField: handleMoveField,
6347
- onAddStep: handleAddStep,
6348
- onEditStep: handleEditStep,
6349
- onDeleteStep: handleDeleteStep,
6350
- onMoveStep: handleMoveStep,
6351
- onAddChoiceOption: handleAddChoiceOption,
6352
- onEditChoiceOption: handleEditChoiceOption,
6353
- onDeleteChoiceOption: handleDeleteChoiceOption,
6354
- onMoveChoiceOption: handleMoveChoiceOption,
6355
- onOpenFormActions: () => setFormActionsOpen(true),
6356
- extraToolbar: toolbarExtra
6357
- })
6358
- }), showPreview ? /*#__PURE__*/jsxRuntime.jsx("div", {
6359
- className: style['preview-pane'],
6360
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
6361
- className: style['preview-body'],
6362
- children: hasRenderableContent(schema) ? /*#__PURE__*/jsxRuntime.jsx(SchemaRenderer$1, {
6363
- schema: schema,
6364
- preview: true,
6365
- formProps: formProps,
6366
- locale: locale
6367
- }) : /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
6368
- image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
6369
- description: formatMessage({
6370
- id: 'emptyBlockList'
7765
+ return /*#__PURE__*/jsxRuntime.jsx(LocaleTextProvider, {
7766
+ languages: languages,
7767
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
7768
+ className: [style['form-creator'], responsiveUtils.RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
7769
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
7770
+ className: style['editor-pane'],
7771
+ children: /*#__PURE__*/jsxRuntime.jsx(BlockListPanel$1, {
7772
+ blocks: schema.blocks,
7773
+ onAddBlock: handleAddBlock,
7774
+ onEditBlock: handleEditBlock,
7775
+ onDeleteBlock: handleDeleteBlock,
7776
+ onMoveBlock: handleMoveBlock,
7777
+ onAddField: handleAddField,
7778
+ onEditField: handleEditField,
7779
+ onDeleteField: handleDeleteField,
7780
+ onMoveField: handleMoveField,
7781
+ onAddStep: handleAddStep,
7782
+ onEditStep: handleEditStep,
7783
+ onDeleteStep: handleDeleteStep,
7784
+ onMoveStep: handleMoveStep,
7785
+ onAddChoiceOption: handleAddChoiceOption,
7786
+ onEditChoiceOption: handleEditChoiceOption,
7787
+ onDeleteChoiceOption: handleDeleteChoiceOption,
7788
+ onMoveChoiceOption: handleMoveChoiceOption,
7789
+ onOpenFormActions: () => setFormActionsOpen(true),
7790
+ extraToolbar: toolbarExtra
7791
+ })
7792
+ }), showPreview ? /*#__PURE__*/jsxRuntime.jsx("div", {
7793
+ className: style['preview-pane'],
7794
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
7795
+ className: style['preview-body'],
7796
+ children: hasRenderableContent(schema) ? /*#__PURE__*/jsxRuntime.jsx(SchemaRenderer$1, {
7797
+ schema: schema,
7798
+ preview: true,
7799
+ formProps: formProps,
7800
+ locale: locale,
7801
+ languages: languages
7802
+ }) : /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
7803
+ image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
7804
+ description: formatMessage({
7805
+ id: 'emptyBlockList'
7806
+ })
6371
7807
  })
6372
7808
  })
6373
- })
6374
- }) : null, /*#__PURE__*/jsxRuntime.jsx(BlockEditorModal$1, {
6375
- open: blockEditorOpen,
6376
- block: editingBlock,
6377
- renderModal: renderModal,
6378
- onCancel: clearBlockEditor,
6379
- onSave: handleSaveBlock
6380
- }), /*#__PURE__*/jsxRuntime.jsx(StepEditorModal$1, {
6381
- open: stepEditorOpen,
6382
- step: stepContext?.step,
6383
- renderModal: renderModal,
6384
- onCancel: () => {
6385
- setStepEditorOpen(false);
6386
- setStepContext(null);
6387
- },
6388
- onSave: handleSaveStep
6389
- }), /*#__PURE__*/jsxRuntime.jsx(ChoiceOptionEditorModal$1, {
6390
- open: choiceOptionEditorOpen,
6391
- option: choiceOptionContext?.option,
6392
- renderModal: renderModal,
6393
- onCancel: () => {
6394
- setChoiceOptionEditorOpen(false);
6395
- setChoiceOptionContext(null);
6396
- },
6397
- onSave: handleSaveChoiceOption
6398
- }), /*#__PURE__*/jsxRuntime.jsx(FieldEditorModal$1, {
6399
- open: fieldEditorOpen,
6400
- field: editingField,
6401
- fieldList: currentFieldScope,
6402
- renderModal: renderModal,
6403
- onCancel: () => {
6404
- setFieldEditorOpen(false);
6405
- setFieldContext(null);
6406
- setEditingField(null);
6407
- },
6408
- onSave: handleSaveField
6409
- }), /*#__PURE__*/jsxRuntime.jsx(FormActionsEditor$1, {
6410
- open: formActionsOpen,
6411
- value: schema.actions,
6412
- renderModal: renderModal,
6413
- onCancel: () => setFormActionsOpen(false),
6414
- onSave: actions => {
6415
- updateSchema({
6416
- ...schema,
6417
- actions
6418
- });
6419
- setFormActionsOpen(false);
6420
- }
6421
- })]
7809
+ }) : null, /*#__PURE__*/jsxRuntime.jsx(BlockEditorModal$1, {
7810
+ open: blockEditorOpen,
7811
+ block: editingBlock,
7812
+ renderModal: renderModal,
7813
+ onCancel: clearBlockEditor,
7814
+ onSave: handleSaveBlock
7815
+ }), /*#__PURE__*/jsxRuntime.jsx(StepEditorModal$1, {
7816
+ open: stepEditorOpen,
7817
+ step: stepContext?.step,
7818
+ renderModal: renderModal,
7819
+ onCancel: () => {
7820
+ setStepEditorOpen(false);
7821
+ setStepContext(null);
7822
+ },
7823
+ onSave: handleSaveStep
7824
+ }), /*#__PURE__*/jsxRuntime.jsx(ChoiceOptionEditorModal$1, {
7825
+ open: choiceOptionEditorOpen,
7826
+ option: choiceOptionContext?.option,
7827
+ renderModal: renderModal,
7828
+ onCancel: () => {
7829
+ setChoiceOptionEditorOpen(false);
7830
+ setChoiceOptionContext(null);
7831
+ },
7832
+ onSave: handleSaveChoiceOption
7833
+ }), /*#__PURE__*/jsxRuntime.jsx(FieldEditorModal$1, {
7834
+ open: fieldEditorOpen,
7835
+ field: editingField,
7836
+ fieldList: currentFieldScope,
7837
+ conditionProps: conditionProps,
7838
+ renderModal: renderModal,
7839
+ onCancel: () => {
7840
+ setFieldEditorOpen(false);
7841
+ setFieldContext(null);
7842
+ setEditingField(null);
7843
+ },
7844
+ onSave: handleSaveField
7845
+ }), /*#__PURE__*/jsxRuntime.jsx(FormActionsEditor$1, {
7846
+ open: formActionsOpen,
7847
+ value: schema.actions,
7848
+ renderModal: renderModal,
7849
+ onCancel: () => setFormActionsOpen(false),
7850
+ onSave: actions => {
7851
+ updateSchema({
7852
+ ...schema,
7853
+ actions
7854
+ });
7855
+ setFormActionsOpen(false);
7856
+ }
7857
+ })]
7858
+ })
6422
7859
  });
6423
7860
  });
6424
7861
  var FormCreator$1 = FormCreator;
@@ -6731,7 +8168,7 @@ const formatDateToToday = (value, itemSchema, ctx) => {
6731
8168
  if (items[1] == null || items[1] === '' || items[1] === true) {
6732
8169
  const until = ctx.formatMessage?.({
6733
8170
  id: 'schemaContentUntilToday'
6734
- }) || defaultLocale.schemaContentUntilToday;
8171
+ }) || zhCN.schemaContentUntilToday;
6735
8172
  return [start, until].filter(Boolean).join(' ~ ');
6736
8173
  }
6737
8174
  const end = formatByValueSchema(items[1], itemSchema, ctx);
@@ -6786,11 +8223,11 @@ const formatBoolean = (value, field, ctx) => {
6786
8223
  if (value) {
6787
8224
  return props.checkedChildren || ctx.formatMessage?.({
6788
8225
  id: 'schemaContentYes'
6789
- }) || defaultLocale.schemaContentYes;
8226
+ }) || zhCN.schemaContentYes;
6790
8227
  }
6791
8228
  return props.unCheckedChildren || ctx.formatMessage?.({
6792
8229
  id: 'schemaContentNo'
6793
- }) || defaultLocale.schemaContentNo;
8230
+ }) || zhCN.schemaContentNo;
6794
8231
  };
6795
8232
  const stringifyFallback = value => {
6796
8233
  if (value == null) {
@@ -6917,9 +8354,12 @@ const formatByValueSchema = (value, schema, ctx = {}) => {
6917
8354
  }
6918
8355
  return String(value);
6919
8356
  };
6920
- const formatFieldDisplayValue = (field, value, {
6921
- formatMessage
8357
+ const formatFieldDisplayValue = (rawField, value, {
8358
+ formatMessage,
8359
+ locale,
8360
+ languages
6922
8361
  } = {}) => {
8362
+ const field = localizeSchema(rawField, locale, languages);
6923
8363
  const emptyText = formatMessage?.({
6924
8364
  id: 'schemaContentEmptyValue'
6925
8365
  }) || '-';
@@ -7006,8 +8446,41 @@ const resolveChoiceSelectorName$1 = block => {
7006
8446
  }
7007
8447
  return `__choice_${block.id}`;
7008
8448
  };
8449
+
8450
+ /** 条件说明文案:按 options.locale 取包内语言包,英文以外回退中文 */
8451
+ const createConditionContext = (normalized, locale) => {
8452
+ const messages = String(locale || '').startsWith('en') ? enUS : zhCN;
8453
+ const formatMessage = ({
8454
+ id
8455
+ }, values = {}) => String(messages[id] ?? id).replace(/\{(\w+)\}/g, (match, key) => values[key] != null ? values[key] : match);
8456
+ const conditionFields = collectConditionFields(normalized).filter(item => !item.inList);
8457
+ return {
8458
+ formatMessage,
8459
+ knownNames: new Set(conditionFields.map(item => item.path)),
8460
+ fieldLookup: new Map(conditionFields.map(item => [item.path, item.field]))
8461
+ };
8462
+ };
8463
+ const describeVisibleWhen = (field, ctx) => {
8464
+ const visibleWhen = {
8465
+ ...field.visibleWhen,
8466
+ conditions: field.visibleWhen.conditions.filter(condition => ctx.knownNames.has(condition?.field))
8467
+ };
8468
+ if (!visibleWhen.conditions.length) {
8469
+ return '';
8470
+ }
8471
+ const condition = formatVisibleWhen(visibleWhen, {
8472
+ formatMessage: ctx.formatMessage,
8473
+ fieldLookup: ctx.fieldLookup
8474
+ });
8475
+ return ctx.formatMessage({
8476
+ id: 'conditionDescription'
8477
+ }, {
8478
+ condition
8479
+ });
8480
+ };
7009
8481
  const mergeFieldIntoLayer = (layer, field, {
7010
- allowRequired = true
8482
+ allowRequired = true,
8483
+ ctx
7011
8484
  } = {}) => {
7012
8485
  if (!field?.name) {
7013
8486
  return;
@@ -7016,8 +8489,14 @@ const mergeFieldIntoLayer = (layer, field, {
7016
8489
  if (!name) {
7017
8490
  return;
7018
8491
  }
7019
- layer.properties[name] = resolveFieldValueSchema(field);
7020
- if (allowRequired && isReq(field.rule) && !layer.required.includes(name)) {
8492
+ const valueSchema = resolveFieldValueSchema(field);
8493
+ const conditionText = ctx?.formatMessage && hasVisibleWhen(field) ? describeVisibleWhen(field, ctx) : '';
8494
+ if (conditionText) {
8495
+ valueSchema.description = valueSchema.description ? `${valueSchema.description}\n${conditionText}` : conditionText;
8496
+ }
8497
+ layer.properties[name] = valueSchema;
8498
+ // 条件显示字段可能不出现在提交数据中,不进 required
8499
+ if (allowRequired && !conditionText && isReq(field.rule) && !layer.required.includes(name)) {
7021
8500
  layer.required.push(name);
7022
8501
  }
7023
8502
  };
@@ -7061,33 +8540,39 @@ const finalizeObjectSchema = (layer, {
7061
8540
  }
7062
8541
  return schema;
7063
8542
  };
7064
- const walkBlocks = (blocks, layer, depth = 0) => {
8543
+ const walkBlocks = (blocks, layer, depth = 0, ctx = {}) => {
7065
8544
  (blocks || []).forEach(block => {
7066
8545
  if (!block) {
7067
8546
  return;
7068
8547
  }
7069
- walkBlock(block, layer, depth);
8548
+ walkBlock(block, layer, depth, ctx);
7070
8549
  });
7071
8550
  };
7072
- const walkBlock = (block, layer, depth = 0) => {
8551
+ const walkBlock = (block, layer, depth = 0, ctx = {}) => {
7073
8552
  switch (block.kind) {
7074
8553
  case 'formInfo':
7075
8554
  {
7076
- mergeFieldsIntoLayer(layer, block.list);
7077
- walkBlocks(block.blocks, layer, depth + 1);
8555
+ mergeFieldsIntoLayer(layer, block.list, {
8556
+ ctx
8557
+ });
8558
+ walkBlocks(block.blocks, layer, depth + 1, ctx);
7078
8559
  return;
7079
8560
  }
7080
8561
  case 'object':
7081
8562
  {
7082
8563
  const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
7083
8564
  if (!name) {
7084
- mergeFieldsIntoLayer(layer, block.list);
7085
- walkBlocks(block.blocks, layer, depth + 1);
8565
+ mergeFieldsIntoLayer(layer, block.list, {
8566
+ ctx
8567
+ });
8568
+ walkBlocks(block.blocks, layer, depth + 1, ctx);
7086
8569
  return;
7087
8570
  }
7088
8571
  const nested = createObjectLayer();
7089
- mergeFieldsIntoLayer(nested, block.list);
7090
- walkBlocks(block.blocks, nested, depth + 1);
8572
+ mergeFieldsIntoLayer(nested, block.list, {
8573
+ ctx
8574
+ });
8575
+ walkBlocks(block.blocks, nested, depth + 1, ctx);
7091
8576
  layer.properties[name] = finalizeObjectSchema(nested, {
7092
8577
  title: block.title || undefined,
7093
8578
  description: block.subtitle || undefined
@@ -7150,14 +8635,16 @@ const walkBlock = (block, layer, depth = 0) => {
7150
8635
  case 'steps':
7151
8636
  {
7152
8637
  (block.items || []).forEach(step => {
7153
- mergeFieldsIntoLayer(layer, step?.list);
7154
- walkBlocks(step?.blocks, layer, depth + 1);
8638
+ mergeFieldsIntoLayer(layer, step?.list, {
8639
+ ctx
8640
+ });
8641
+ walkBlocks(step?.blocks, layer, depth + 1, ctx);
7155
8642
  });
7156
8643
  return;
7157
8644
  }
7158
8645
  case 'choice':
7159
8646
  {
7160
- mergeChoiceIntoLayer(layer, block, depth);
8647
+ mergeChoiceIntoLayer(layer, block, depth, ctx);
7161
8648
  return;
7162
8649
  }
7163
8650
  default:
@@ -7170,7 +8657,7 @@ const walkBlock = (block, layer, depth = 0) => {
7170
8657
  * 每支为 object:单选支含 selector const;多选支为该 option 字段,selector 数组放在当前层。
7171
8658
  * 支内 REQ 可进 required;hidden 字段仍进入 schema。
7172
8659
  */
7173
- const mergeChoiceIntoLayer = (layer, block, depth) => {
8660
+ const mergeChoiceIntoLayer = (layer, block, depth, ctx) => {
7174
8661
  const mode = block.mode === 'multiple' ? 'multiple' : 'single';
7175
8662
  const selectorInData = block.selectorInData !== false;
7176
8663
  const selectorName = resolveChoiceSelectorName$1(block);
@@ -7189,9 +8676,10 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
7189
8676
  branch.required.push(selectorName);
7190
8677
  }
7191
8678
  mergeFieldsIntoLayer(branch, option.list, {
7192
- allowRequired: true
8679
+ allowRequired: true,
8680
+ ctx
7193
8681
  });
7194
- walkBlocks(option.blocks, branch, depth + 1);
8682
+ walkBlocks(option.blocks, branch, depth + 1, ctx);
7195
8683
  return finalizeObjectSchema(branch, {
7196
8684
  title: optionTitle
7197
8685
  });
@@ -7268,11 +8756,12 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
7268
8756
  * - 扩展字段:registerField / preset 的 valueSchema;缺省 { type: 'string' }
7269
8757
  * - hidden 字段仍进入 data schema(可提交)
7270
8758
  * - choice:single → oneOf,multiple → anyOf
8759
+ * - options.locale / options.languages:多语言文案取该语言,取不到按 languages 顺序回退(未传为 zh-CN → en-US)
7271
8760
  */
7272
8761
  const schemaToDataSchema = (schema, options = {}) => {
7273
- const normalized = normalizeSchema(schema || {});
8762
+ const normalized = normalizeSchema(localizeSchema(schema || {}, options.locale, options.languages));
7274
8763
  const layer = createObjectLayer();
7275
- walkBlocks(normalized.blocks, layer, 0);
8764
+ walkBlocks(normalized.blocks, layer, 0, createConditionContext(normalized, options.locale));
7276
8765
  const root = finalizeObjectSchema(layer, {
7277
8766
  title: normalized.title || undefined,
7278
8767
  description: options.description
@@ -7307,9 +8796,10 @@ const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValu
7307
8796
  * 改为 label 在上、值在下,避免窄栏(如弹窗双栏预览)被撑乱。
7308
8797
  */
7309
8798
  const renderFieldsContent = (fields, data, formatMessage, column, {
7310
- showIndex = false
8799
+ showIndex = false,
8800
+ isFieldVisible
7311
8801
  } = {}) => {
7312
- const list = (fields || []).filter(field => field && !field.hidden && field.name).map((field, index) => {
8802
+ const list = (fields || []).filter(field => field && !field.hidden && field.name && (!isFieldVisible || isFieldVisible(field))).map((field, index) => {
7313
8803
  const baseLabel = field.label || field.name;
7314
8804
  const label = showIndex ? `${index + 1}. ${baseLabel}` : baseLabel;
7315
8805
  return {
@@ -7344,7 +8834,8 @@ const renderBlock = (block, data, ctx) => {
7344
8834
  const {
7345
8835
  formatMessage,
7346
8836
  isMobile,
7347
- depth = 0
8837
+ depth = 0,
8838
+ isFieldVisible
7348
8839
  } = ctx;
7349
8840
  if (!block || depth > MAX_BLOCK_DEPTH) {
7350
8841
  return null;
@@ -7367,7 +8858,8 @@ const renderBlock = (block, data, ctx) => {
7367
8858
  return /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7368
8859
  ...partProps,
7369
8860
  children: [renderFieldsContent(block.list, data, formatMessage, block.column, {
7370
- showIndex: !!block.showIndex
8861
+ showIndex: !!block.showIndex,
8862
+ isFieldVisible
7371
8863
  }), renderBlockList(block.blocks, data, nextCtx)]
7372
8864
  });
7373
8865
  }
@@ -7377,7 +8869,9 @@ const renderBlock = (block, data, ctx) => {
7377
8869
  const nestedData = name ? getByPath(data, name) || {} : data;
7378
8870
  return /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7379
8871
  ...partProps,
7380
- children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column), renderBlockList(block.blocks, nestedData, nextCtx)]
8872
+ children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column, {
8873
+ isFieldVisible
8874
+ }), renderBlockList(block.blocks, nestedData, nextCtx)]
7381
8875
  });
7382
8876
  }
7383
8877
  case 'list':
@@ -7438,7 +8932,9 @@ const renderBlock = (block, data, ctx) => {
7438
8932
  children: (block.items || []).map(step => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7439
8933
  title: step.title || undefined,
7440
8934
  bordered: bordered,
7441
- children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2), renderBlockList(step.blocks, data, nextCtx)]
8935
+ children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2, {
8936
+ isFieldVisible
8937
+ }), renderBlockList(step.blocks, data, nextCtx)]
7442
8938
  }, step.id))
7443
8939
  }, block.id);
7444
8940
  }
@@ -7454,7 +8950,9 @@ const renderBlock = (block, data, ctx) => {
7454
8950
  children: visibleOptions.map(option => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7455
8951
  title: option.title || undefined,
7456
8952
  bordered: false,
7457
- children: [renderFieldsContent(option.list, data, formatMessage, block.column), renderBlockList(option.blocks, data, nextCtx)]
8953
+ children: [renderFieldsContent(option.list, data, formatMessage, block.column, {
8954
+ isFieldVisible
8955
+ }), renderBlockList(option.blocks, data, nextCtx)]
7458
8956
  }, option.id))
7459
8957
  });
7460
8958
  }
@@ -7465,17 +8963,24 @@ const renderBlock = (block, data, ctx) => {
7465
8963
  const SchemaContentInnerView = ({
7466
8964
  schema,
7467
8965
  data,
7468
- className
8966
+ className,
8967
+ languages
7469
8968
  }) => {
7470
8969
  const {
7471
- formatMessage
8970
+ formatMessage,
8971
+ locale
7472
8972
  } = reactIntl.useIntl();
7473
8973
  const isMobile = responsiveUtils.useIsMobile();
7474
- const normalized = normalizeSchema(schema);
7475
- const children = renderBlockList(normalized.blocks, data || {}, {
8974
+ const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
8975
+ const rootData = data || {};
8976
+ const knownNames = collectTriggerNames(normalized);
8977
+ // 条件按提交数据根路径判断(object 内字段同样用完整路径)
8978
+ const isFieldVisible = field => evaluateVisibleWhen(field.visibleWhen, rootData, knownNames);
8979
+ const children = renderBlockList(normalized.blocks, rootData, {
7476
8980
  formatMessage,
7477
8981
  isMobile,
7478
- depth: 0
8982
+ depth: 0,
8983
+ isFieldVisible
7479
8984
  });
7480
8985
  if (!children.length) {
7481
8986
  return null;
@@ -7495,12 +9000,14 @@ const SchemaContent = withLocale$1(({
7495
9000
  schema,
7496
9001
  data,
7497
9002
  className,
7498
- empty
9003
+ empty,
9004
+ languages
7499
9005
  }) => {
7500
9006
  const {
7501
- formatMessage
9007
+ formatMessage,
9008
+ locale
7502
9009
  } = reactIntl.useIntl();
7503
- const normalized = normalizeSchema(schema);
9010
+ const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
7504
9011
  const emptyNode = empty !== undefined ? empty : /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
7505
9012
  image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
7506
9013
  description: formatMessage({
@@ -7520,7 +9027,12 @@ const SchemaContent = withLocale$1(({
7520
9027
  });
7521
9028
  var SchemaContent$1 = SchemaContent;
7522
9029
 
9030
+ exports.CONDITION_OPERATORS = CONDITION_OPERATORS;
7523
9031
  exports.FormCreator = FormCreator$1;
9032
+ exports.LocaleInput = LocaleInput;
9033
+ exports.LocaleTextArea = LocaleTextArea;
9034
+ exports.LocaleTextControl = LocaleTextControl;
9035
+ exports.LocaleTextProvider = LocaleTextProvider;
7524
9036
  exports.MAX_BLOCK_DEPTH = MAX_BLOCK_DEPTH;
7525
9037
  exports.RULE_LEN_PRESET = RULE_LEN_PRESET;
7526
9038
  exports.RULE_PRESET_ITEMS = RULE_PRESET_ITEMS;
@@ -7529,9 +9041,11 @@ exports.SchemaContentInner = SchemaContentInner;
7529
9041
  exports.SchemaRenderer = SchemaRenderer$1;
7530
9042
  exports.SchemaRendererInner = SchemaRendererInner;
7531
9043
  exports.applyFromPropsSchema = applyFromPropsSchema;
9044
+ exports.blockHasLockedField = blockHasLockedField;
7532
9045
  exports.blockToFormValues = blockToFormValues;
7533
9046
  exports.buildRuleString = buildRuleString;
7534
9047
  exports.collectBlockFieldNames = collectBlockFieldNames;
9048
+ exports.collectConditionFields = collectConditionFields;
7535
9049
  exports.collectSchemaFields = collectSchemaFields;
7536
9050
  exports.createBlock = createBlock;
7537
9051
  exports.createChoiceOption = createChoiceOption;
@@ -7541,9 +9055,12 @@ exports.createStep = createStep;
7541
9055
  exports["default"] = FormCreator$1;
7542
9056
  exports.defaultFormActions = defaultFormActions;
7543
9057
  exports.defaultSchema = defaultSchema;
9058
+ exports.evaluateCondition = evaluateCondition;
9059
+ exports.evaluateVisibleWhen = evaluateVisibleWhen;
7544
9060
  exports.fieldToFormValues = fieldToFormValues;
7545
9061
  exports.findBlock = findBlock;
7546
9062
  exports.findBlockInTree = findBlockInTree;
9063
+ exports.findConditionCycle = findConditionCycle;
7547
9064
  exports.formValuesToBlock = formValuesToBlock;
7548
9065
  exports.formValuesToField = formValuesToField;
7549
9066
  exports.formatByValueSchema = formatByValueSchema;
@@ -7554,8 +9071,13 @@ exports.getFieldComponent = getFieldComponent;
7554
9071
  exports.getFieldDefinition = getFieldDefinition;
7555
9072
  exports.getFieldTypes = getFieldTypes;
7556
9073
  exports.getRulePresetItems = getRulePresetItems;
9074
+ exports.hasLocaleText = hasLocaleText;
7557
9075
  exports.hasRenderableContent = hasRenderableContent;
9076
+ exports.hasVisibleWhen = hasVisibleWhen;
9077
+ exports.isFieldLocked = isFieldLocked;
7558
9078
  exports.isFieldNameUnique = isFieldNameUnique;
9079
+ exports.isLocaleText = isLocaleText;
9080
+ exports.localizeSchema = localizeSchema;
7559
9081
  exports.mapBlocks = mapBlocks;
7560
9082
  exports.moveBlockInTree = moveBlockInTree;
7561
9083
  exports.moveItem = moveItem;
@@ -7569,8 +9091,10 @@ exports.pickFromPropsSchema = pickFromPropsSchema;
7569
9091
  exports.preset = preset;
7570
9092
  exports.registerField = registerField;
7571
9093
  exports.removeBlockInTree = removeBlockInTree;
9094
+ exports.renameConditionReferences = renameConditionReferences;
7572
9095
  exports.resolveFieldTypeLabel = resolveFieldTypeLabel;
7573
9096
  exports.resolveFieldValueSchema = resolveFieldValueSchema;
9097
+ exports.resolveLocaleText = resolveLocaleText;
7574
9098
  exports.schemaToDataSchema = schemaToDataSchema;
7575
9099
  exports.updateBlocks = updateBlocks;
7576
9100
  //# sourceMappingURL=index.js.map