@kne/form-creator 0.1.24 → 0.1.26

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","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"};
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","options-header":"kne-form-creator_As4L6","options-locale-text":"kne-form-creator_7-99l","options-header-label":"kne-form-creator_UhnVH","options-header-value":"kne-form-creator_2c35V","options-header-description":"kne-form-creator_ibWvX","icon-square-btn-sm":"kne-form-creator_GAh-t","options-header-action":"kne-form-creator_nTN1E","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","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","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: '未命名填写项',
@@ -187,6 +189,9 @@ const locale$1 = {
187
189
  formActionsGapHint: '默认 16',
188
190
  formActionsLayoutSection: '布局',
189
191
  fieldBasicSection: '基本设置',
192
+ optionLabelColumn: '选项名称',
193
+ optionValueColumn: '选项值',
194
+ optionDescColumn: '选项描述',
190
195
  optionLabelPlaceholder: '显示文字',
191
196
  optionValuePlaceholder: '对应值',
192
197
  optionDescPlaceholder: '补充说明(可选)',
@@ -271,9 +276,51 @@ const locale$1 = {
271
276
  ruleErrorLenEqual: '%s长度必须等于{end}',
272
277
  ruleErrorLenMin: '%s长度必须大于{start}',
273
278
  ruleErrorLenMax: '%s长度必须小于{end}',
274
- localeTextFallback: '留空时使用{language}'
275
- };
276
- var defaultLocale = locale$1;
279
+ localeTextFallback: '留空时使用{language}',
280
+ visibleWhenTitle: '条件显示',
281
+ visibleWhenEnable: '满足条件时才显示',
282
+ visibleWhenEnableTips: '不满足条件时隐藏该填写项,并清空其已填写的值',
283
+ visibleWhenLogic: '满足方式',
284
+ conditionLogic_and: '全部满足',
285
+ conditionLogic_or: '满足任一',
286
+ visibleWhenAddCondition: '添加条件',
287
+ visibleWhenField: '触发填写项',
288
+ visibleWhenOperator: '判断',
289
+ visibleWhenValue: '值',
290
+ visibleWhenNoTrigger: '暂无可作为条件的填写项(列表类模块中的填写项不支持)',
291
+ visibleWhenListUnsupported: '列表类模块中的填写项不支持条件显示',
292
+ visibleWhenRegexInvalid: '正则表达式无效',
293
+ visibleWhenRegexFlags: '修饰符',
294
+ visibleWhenRegexFlag_i: 'i 忽略大小写',
295
+ visibleWhenRegexFlag_m: 'm 多行',
296
+ visibleWhenRegexFlag_s: 's 点号匹配换行',
297
+ visibleWhenRegexFlag_u: 'u Unicode',
298
+ visibleWhenRegexTester: '测试文本',
299
+ visibleWhenRegexMatched: '匹配',
300
+ visibleWhenRegexNotMatched: '不匹配',
301
+ visibleWhenConditionRequired: '请完善条件:选择触发填写项并填写值',
302
+ visibleWhenCycle: '条件形成循环依赖:{path}',
303
+ fieldConditionTag: '条件显示',
304
+ fieldConditionInvalidTag: '条件失效',
305
+ fieldConditionInvalidTips: '条件引用的填写项已不存在或不可用,该条件被忽略',
306
+ conditionOperator_eq: '等于',
307
+ conditionOperator_neq: '不等于',
308
+ conditionOperator_in: '属于其一',
309
+ conditionOperator_includesAny: '包含任一',
310
+ conditionOperator_empty: '为空',
311
+ conditionOperator_notEmpty: '不为空',
312
+ conditionOperator_gt: '大于',
313
+ conditionOperator_gte: '大于等于',
314
+ conditionOperator_lt: '小于',
315
+ conditionOperator_lte: '小于等于',
316
+ conditionOperator_regex: '匹配正则',
317
+ conditionJoinAnd: ' 且 ',
318
+ conditionJoinOr: ' 或 ',
319
+ conditionValueTrue: '是',
320
+ conditionValueFalse: '否',
321
+ conditionDescription: '满足条件时显示:{condition}'
322
+ };
323
+ var zhCN = locale$1;
277
324
 
278
325
  const locale = {
279
326
  addField: 'Add Field',
@@ -410,6 +457,8 @@ const locale = {
410
457
  fieldBlock: 'Full Width',
411
458
  fieldHidden: 'Hidden',
412
459
  fieldHiddenTag: 'Hidden',
460
+ fieldLockedTag: 'Locked',
461
+ fieldLockedTips: 'Locked field: cannot be edited, deleted or moved',
413
462
  fieldBlockTag: 'Full Width',
414
463
  fieldNameDuplicate: 'This name is already in use, please choose another',
415
464
  untitledField: 'Untitled Field',
@@ -437,6 +486,9 @@ const locale = {
437
486
  formActionsGapHint: 'Default: 16',
438
487
  formActionsLayoutSection: 'Layout',
439
488
  fieldBasicSection: 'Basic Settings',
489
+ optionLabelColumn: 'Option Label',
490
+ optionValueColumn: 'Option Value',
491
+ optionDescColumn: 'Option Description',
440
492
  optionLabelPlaceholder: 'Display text',
441
493
  optionValuePlaceholder: 'Value',
442
494
  optionDescPlaceholder: 'Description (optional)',
@@ -521,14 +573,56 @@ const locale = {
521
573
  ruleErrorLenEqual: '%s must be exactly {end} characters',
522
574
  ruleErrorLenMin: '%s must be at least {start} characters',
523
575
  ruleErrorLenMax: '%s must be at most {end} characters',
524
- localeTextFallback: 'Falls back to {language} when empty'
576
+ localeTextFallback: 'Falls back to {language} when empty',
577
+ visibleWhenTitle: 'Conditional display',
578
+ visibleWhenEnable: 'Show only when conditions are met',
579
+ visibleWhenEnableTips: 'The field is hidden and its value cleared when conditions are not met',
580
+ visibleWhenLogic: 'Match',
581
+ conditionLogic_and: 'All conditions',
582
+ conditionLogic_or: 'Any condition',
583
+ visibleWhenAddCondition: 'Add condition',
584
+ visibleWhenField: 'Trigger field',
585
+ visibleWhenOperator: 'Operator',
586
+ visibleWhenValue: 'Value',
587
+ visibleWhenNoTrigger: 'No field can be used as a condition (fields inside list blocks are not supported)',
588
+ visibleWhenListUnsupported: 'Fields inside list blocks do not support conditional display',
589
+ visibleWhenRegexInvalid: 'Invalid regular expression',
590
+ visibleWhenRegexFlags: 'Flags',
591
+ visibleWhenRegexFlag_i: 'i ignore case',
592
+ visibleWhenRegexFlag_m: 'm multiline',
593
+ visibleWhenRegexFlag_s: 's dot matches newline',
594
+ visibleWhenRegexFlag_u: 'u Unicode',
595
+ visibleWhenRegexTester: 'Test text',
596
+ visibleWhenRegexMatched: 'Matched',
597
+ visibleWhenRegexNotMatched: 'Not matched',
598
+ visibleWhenConditionRequired: 'Complete each condition: choose a trigger field and fill in the value',
599
+ visibleWhenCycle: 'Conditions form a circular dependency: {path}',
600
+ fieldConditionTag: 'Conditional',
601
+ fieldConditionInvalidTag: 'Condition invalid',
602
+ fieldConditionInvalidTips: 'A referenced field no longer exists or is unavailable; that condition is ignored',
603
+ conditionOperator_eq: 'equals',
604
+ conditionOperator_neq: 'does not equal',
605
+ conditionOperator_in: 'is one of',
606
+ conditionOperator_includesAny: 'includes any of',
607
+ conditionOperator_empty: 'is empty',
608
+ conditionOperator_notEmpty: 'is not empty',
609
+ conditionOperator_gt: '>',
610
+ conditionOperator_gte: '>=',
611
+ conditionOperator_lt: '<',
612
+ conditionOperator_lte: '<=',
613
+ conditionOperator_regex: 'matches',
614
+ conditionJoinAnd: ' and ',
615
+ conditionJoinOr: ' or ',
616
+ conditionValueTrue: 'Yes',
617
+ conditionValueFalse: 'No',
618
+ conditionDescription: 'Shown when: {condition}'
525
619
  };
526
620
  var enUS = locale;
527
621
 
528
622
  const withLocale = reactIntl.createWithIntlProvider({
529
623
  defaultLocale: 'zh-CN',
530
624
  messages: {
531
- 'zh-CN': defaultLocale,
625
+ 'zh-CN': zhCN,
532
626
  'en-US': enUS
533
627
  },
534
628
  namespace: 'form-creator'
@@ -1000,7 +1094,23 @@ const normalizeSchema = (schema = {}) => {
1000
1094
  blocks: []
1001
1095
  };
1002
1096
  };
1003
- const moveItem = (list, id, direction) => {
1097
+ const isFieldLocked = field => !!field?.locked;
1098
+ const blockHasLockedField = block => {
1099
+ if (!block) {
1100
+ return false;
1101
+ }
1102
+ if ((block.list || []).some(isFieldLocked)) {
1103
+ return true;
1104
+ }
1105
+ const groups = [...(block.items || []), ...(block.options || [])];
1106
+ if (groups.some(group => (group.list || []).some(isFieldLocked) || (group.blocks || []).some(blockHasLockedField))) {
1107
+ return true;
1108
+ }
1109
+ return [...(block.blocks || []), ...(block.itemBlocks || [])].some(blockHasLockedField);
1110
+ };
1111
+
1112
+ // 锁定项(locked 字段 / 含锁定字段的模块)位置固定:自身不能移动,其他项也不能与其交换位置
1113
+ const moveItem = (list, id, direction, isFixed = isFieldLocked) => {
1004
1114
  const index = list.findIndex(item => item.id === id);
1005
1115
  if (index < 0) {
1006
1116
  return list;
@@ -1009,6 +1119,9 @@ const moveItem = (list, id, direction) => {
1009
1119
  if (targetIndex < 0 || targetIndex >= list.length) {
1010
1120
  return list;
1011
1121
  }
1122
+ if (isFixed(list[index]) || isFixed(list[targetIndex])) {
1123
+ return list;
1124
+ }
1012
1125
  const next = [...list];
1013
1126
  const [item] = next.splice(index, 1);
1014
1127
  next.splice(targetIndex, 0, item);
@@ -1320,7 +1433,7 @@ const removeBlockInTree = (blocks, blockId) => {
1320
1433
  };
1321
1434
  const moveBlockInTree = (blocks, blockId, direction) => {
1322
1435
  if ((blocks || []).some(block => block?.id === blockId)) {
1323
- return moveItem(blocks, blockId, direction);
1436
+ return moveItem(blocks, blockId, direction, blockHasLockedField);
1324
1437
  }
1325
1438
  let changed = false;
1326
1439
  const next = (blocks || []).map(block => {
@@ -1735,6 +1848,440 @@ const buildRuleString = ({
1735
1848
  return parts.join(' ') || undefined;
1736
1849
  };
1737
1850
 
1851
+ const CONDITION_OPERATORS = ['eq', 'neq', 'in', 'includesAny', 'empty', 'notEmpty', 'gt', 'gte', 'lt', 'lte', 'regex'];
1852
+ const NO_VALUE_OPERATORS = ['empty', 'notEmpty'];
1853
+ const ALLOWED_REGEX_FLAGS = ['i', 'm', 's', 'u'];
1854
+
1855
+ // 列表类模块内的字段会重复出现,单个 name 定位不到具体条目,不参与条件
1856
+ const LIST_BLOCK_KINDS = ['list', 'tableList', 'editableList', 'multiField'];
1857
+ const getByPath$2 = (data, path) => {
1858
+ if (data == null || path == null || path === '') {
1859
+ return undefined;
1860
+ }
1861
+ return String(path).split('.').reduce((current, key) => current == null ? undefined : current[key], data);
1862
+ };
1863
+ const isEmptyValue$1 = value => value === undefined || value === null || value === '' || Array.isArray(value) && value.length === 0;
1864
+
1865
+ // SuperSelect 等字段的值是 { label, value } 对象,比较时统一取 value
1866
+ const toComparable = item => {
1867
+ if (item && typeof item === 'object' && !Array.isArray(item)) {
1868
+ return item.value ?? item.id ?? item.key ?? item;
1869
+ }
1870
+ return item;
1871
+ };
1872
+ const toArray = value => Array.isArray(value) ? value : isEmptyValue$1(value) ? [] : [value];
1873
+ const sameValue = (a, b) => String(toComparable(a)) === String(toComparable(b));
1874
+ const sanitizeRegexFlags = flags => Array.from(new Set(String(flags || '').split(''))).filter(flag => ALLOWED_REGEX_FLAGS.includes(flag)).join('');
1875
+ const regexCache = new Map();
1876
+
1877
+ /** 编译失败返回 null;以「源码 + flags」缓存 */
1878
+ const compileConditionRegex = (source, flags) => {
1879
+ if (source == null || String(source) === '') {
1880
+ return null;
1881
+ }
1882
+ const safeFlags = sanitizeRegexFlags(flags);
1883
+ const key = `${safeFlags}/${source}`;
1884
+ if (regexCache.has(key)) {
1885
+ return regexCache.get(key);
1886
+ }
1887
+ let regex = null;
1888
+ try {
1889
+ regex = new RegExp(String(source), safeFlags);
1890
+ } catch (error) {
1891
+ regex = null;
1892
+ }
1893
+ regexCache.set(key, regex);
1894
+ return regex;
1895
+ };
1896
+ const toNumber = value => {
1897
+ if (isEmptyValue$1(value) || typeof value === 'boolean') {
1898
+ return NaN;
1899
+ }
1900
+ return Number(value);
1901
+ };
1902
+
1903
+ /**
1904
+ * 返回 true / false;条件本身无效(未知运算符、正则无法编译)时返回 null,由调用方忽略
1905
+ */
1906
+ const evaluateCondition = (condition, formData) => {
1907
+ if (!condition?.field || !CONDITION_OPERATORS.includes(condition.operator)) {
1908
+ return null;
1909
+ }
1910
+ const actual = getByPath$2(formData, condition.field);
1911
+ const expected = condition.value;
1912
+ switch (condition.operator) {
1913
+ case 'empty':
1914
+ return isEmptyValue$1(actual);
1915
+ case 'notEmpty':
1916
+ return !isEmptyValue$1(actual);
1917
+ case 'eq':
1918
+ return !isEmptyValue$1(actual) && !Array.isArray(actual) && sameValue(actual, expected);
1919
+ case 'neq':
1920
+ return isEmptyValue$1(actual) || Array.isArray(actual) || !sameValue(actual, expected);
1921
+ case 'in':
1922
+ return !isEmptyValue$1(actual) && toArray(expected).some(item => sameValue(actual, item));
1923
+ case 'includesAny':
1924
+ {
1925
+ const expectedList = toArray(expected);
1926
+ return toArray(actual).some(item => expectedList.some(target => sameValue(item, target)));
1927
+ }
1928
+ case 'gt':
1929
+ case 'gte':
1930
+ case 'lt':
1931
+ case 'lte':
1932
+ {
1933
+ const a = toNumber(actual);
1934
+ const b = toNumber(expected);
1935
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
1936
+ return false;
1937
+ }
1938
+ return {
1939
+ gt: a > b,
1940
+ gte: a >= b,
1941
+ lt: a < b,
1942
+ lte: a <= b
1943
+ }[condition.operator];
1944
+ }
1945
+ case 'regex':
1946
+ {
1947
+ const regex = compileConditionRegex(expected, condition.flags);
1948
+ if (!regex) {
1949
+ return null;
1950
+ }
1951
+ if (isEmptyValue$1(actual)) {
1952
+ return false;
1953
+ }
1954
+ return toArray(actual).some(item => regex.test(String(toComparable(item))));
1955
+ }
1956
+ default:
1957
+ return null;
1958
+ }
1959
+ };
1960
+ const hasVisibleWhen = field => Array.isArray(field?.visibleWhen?.conditions) && field.visibleWhen.conditions.length > 0;
1961
+
1962
+ /**
1963
+ * knownNames:可作为触发字段的完整路径集合;传入时引用未知字段的条件视为失效
1964
+ * 全部条件失效时返回 true(照常显示)
1965
+ */
1966
+ const evaluateVisibleWhen = (visibleWhen, formData, knownNames) => {
1967
+ const conditions = visibleWhen?.conditions;
1968
+ if (!Array.isArray(conditions) || !conditions.length) {
1969
+ return true;
1970
+ }
1971
+ const results = conditions.map(condition => {
1972
+ if (knownNames && !knownNames.has(condition?.field)) {
1973
+ return null;
1974
+ }
1975
+ return evaluateCondition(condition, formData || {});
1976
+ }).filter(result => result !== null);
1977
+ if (!results.length) {
1978
+ return true;
1979
+ }
1980
+ return visibleWhen.logic === 'or' ? results.some(Boolean) : results.every(Boolean);
1981
+ };
1982
+ const joinPath = (prefix, name) => prefix ? `${prefix}.${name}` : name;
1983
+
1984
+ /**
1985
+ * 收集 schema 中所有字段:{ id, path, field, inList }
1986
+ * path 为提交数据中的完整路径(object 模块带前缀);inList 表示位于列表类模块内
1987
+ */
1988
+ const collectConditionFields = schema => {
1989
+ const result = [];
1990
+ const pushFields = (list, prefix, inList) => {
1991
+ (list || []).forEach(field => {
1992
+ if (field?.name) {
1993
+ result.push({
1994
+ id: field.id,
1995
+ path: joinPath(prefix, field.name),
1996
+ field,
1997
+ inList
1998
+ });
1999
+ }
2000
+ });
2001
+ };
2002
+ // 与 renderSchema 一致:仅 object 模块自身字段带 block.name 前缀,子模块不累加
2003
+ const walk = (blocks, inList) => {
2004
+ (blocks || []).forEach(block => {
2005
+ if (!block) {
2006
+ return;
2007
+ }
2008
+ const blockInList = inList || LIST_BLOCK_KINDS.includes(block.kind);
2009
+ pushFields(block.list, block.kind === 'object' ? block.name || '' : '', blockInList);
2010
+ (block.items || []).forEach(step => {
2011
+ pushFields(step.list, '', blockInList);
2012
+ walk(step.blocks, blockInList);
2013
+ });
2014
+ (block.options || []).forEach(option => {
2015
+ pushFields(option.list, '', blockInList);
2016
+ walk(option.blocks, blockInList);
2017
+ });
2018
+ walk(block.blocks, blockInList);
2019
+ walk(block.itemBlocks, true);
2020
+ });
2021
+ };
2022
+ walk(schema?.blocks, false);
2023
+ return result;
2024
+ };
2025
+
2026
+ /** 字段所在模块的路径前缀与是否位于列表类模块内;找不到返回 null */
2027
+ const getBlockConditionScope = (schema, blockId) => {
2028
+ let found = null;
2029
+ const walk = (blocks, inList) => {
2030
+ (blocks || []).forEach(block => {
2031
+ if (!block || found) {
2032
+ return;
2033
+ }
2034
+ const blockInList = inList || LIST_BLOCK_KINDS.includes(block.kind);
2035
+ if (block.id === blockId) {
2036
+ found = {
2037
+ prefix: block.kind === 'object' ? block.name || '' : '',
2038
+ inList: blockInList
2039
+ };
2040
+ return;
2041
+ }
2042
+ (block.items || []).forEach(step => walk(step.blocks, blockInList));
2043
+ (block.options || []).forEach(option => walk(option.blocks, blockInList));
2044
+ walk(block.blocks, blockInList);
2045
+ walk(block.itemBlocks, true);
2046
+ });
2047
+ };
2048
+ walk(schema?.blocks, false);
2049
+ return found;
2050
+ };
2051
+ const getFieldConditionPath = (scope, name) => name ? joinPath(scope?.prefix || '', name) : '';
2052
+
2053
+ /** 可作为触发字段的路径集合(排除列表类模块内字段) */
2054
+ const collectTriggerNames = schema => new Set(collectConditionFields(schema).filter(item => !item.inList).map(item => item.path));
2055
+
2056
+ /** 某字段的条件里引用了不存在 / 不可用的触发字段 */
2057
+ const hasInvalidCondition = (field, triggerNames) => hasVisibleWhen(field) && field.visibleWhen.conditions.some(condition => !triggerNames.has(condition?.field) || condition.operator === 'regex' && !compileConditionRegex(condition.value, condition.flags));
2058
+ const buildDependencyGraph = schema => {
2059
+ const graph = new Map();
2060
+ collectConditionFields(schema).forEach(({
2061
+ path,
2062
+ field
2063
+ }) => {
2064
+ if (hasVisibleWhen(field)) {
2065
+ graph.set(path, field.visibleWhen.conditions.map(condition => condition?.field).filter(Boolean));
2066
+ }
2067
+ });
2068
+ return graph;
2069
+ };
2070
+
2071
+ /** 返回循环链路(路径数组,首尾相同);无循环返回 null */
2072
+ const findConditionCycle = schema => {
2073
+ const graph = buildDependencyGraph(schema);
2074
+ const state = new Map();
2075
+ const stack = [];
2076
+ const visit = node => {
2077
+ if (state.get(node) === 'done') {
2078
+ return null;
2079
+ }
2080
+ if (state.get(node) === 'visiting') {
2081
+ return [...stack.slice(stack.indexOf(node)), node];
2082
+ }
2083
+ state.set(node, 'visiting');
2084
+ stack.push(node);
2085
+ for (const next of graph.get(node) || []) {
2086
+ const cycle = visit(next);
2087
+ if (cycle) {
2088
+ return cycle;
2089
+ }
2090
+ }
2091
+ stack.pop();
2092
+ state.set(node, 'done');
2093
+ return null;
2094
+ };
2095
+ for (const node of graph.keys()) {
2096
+ const cycle = visit(node);
2097
+ if (cycle) {
2098
+ return cycle;
2099
+ }
2100
+ }
2101
+ return null;
2102
+ };
2103
+
2104
+ /** 选中 candidate 作为 fieldPath 的触发字段是否会形成循环 */
2105
+ const wouldCreateCycle = (schema, fieldPath, candidatePath) => {
2106
+ if (fieldPath === candidatePath) {
2107
+ return true;
2108
+ }
2109
+ const graph = buildDependencyGraph(schema);
2110
+ const seen = new Set();
2111
+ const queue = [candidatePath];
2112
+ while (queue.length) {
2113
+ const node = queue.shift();
2114
+ if (node === fieldPath) {
2115
+ return true;
2116
+ }
2117
+ if (seen.has(node)) {
2118
+ continue;
2119
+ }
2120
+ seen.add(node);
2121
+ (graph.get(node) || []).forEach(next => queue.push(next));
2122
+ }
2123
+ return false;
2124
+ };
2125
+ const mapFieldList = (list, mapper) => Array.isArray(list) ? list.map(mapper) : list;
2126
+ const mapBlockFields = (block, mapper) => {
2127
+ if (!block) {
2128
+ return block;
2129
+ }
2130
+ const next = {
2131
+ ...block,
2132
+ list: mapFieldList(block.list, mapper)
2133
+ };
2134
+ if (Array.isArray(block.items)) {
2135
+ next.items = block.items.map(step => ({
2136
+ ...step,
2137
+ list: mapFieldList(step.list, mapper),
2138
+ blocks: mapBlocksFields(step.blocks, mapper)
2139
+ }));
2140
+ }
2141
+ if (Array.isArray(block.options)) {
2142
+ next.options = block.options.map(option => ({
2143
+ ...option,
2144
+ list: mapFieldList(option.list, mapper),
2145
+ blocks: mapBlocksFields(option.blocks, mapper)
2146
+ }));
2147
+ }
2148
+ if (Array.isArray(block.blocks)) {
2149
+ next.blocks = mapBlocksFields(block.blocks, mapper);
2150
+ }
2151
+ if (Array.isArray(block.itemBlocks)) {
2152
+ next.itemBlocks = mapBlocksFields(block.itemBlocks, mapper);
2153
+ }
2154
+ return next;
2155
+ };
2156
+ const mapBlocksFields = (blocks, mapper) => Array.isArray(blocks) ? blocks.map(block => mapBlockFields(block, mapper)) : blocks;
2157
+
2158
+ /** 触发字段改名后,同步所有条件中的引用 */
2159
+ const renameConditionReferences = (schema, oldPath, newPath) => {
2160
+ if (!oldPath || !newPath || oldPath === newPath) {
2161
+ return schema;
2162
+ }
2163
+ return {
2164
+ ...schema,
2165
+ blocks: mapBlocksFields(schema?.blocks, field => {
2166
+ if (!hasVisibleWhen(field) || !field.visibleWhen.conditions.some(condition => condition?.field === oldPath)) {
2167
+ return field;
2168
+ }
2169
+ return {
2170
+ ...field,
2171
+ visibleWhen: {
2172
+ ...field.visibleWhen,
2173
+ conditions: field.visibleWhen.conditions.map(condition => condition?.field === oldPath ? {
2174
+ ...condition,
2175
+ field: newPath
2176
+ } : condition)
2177
+ }
2178
+ };
2179
+ })
2180
+ };
2181
+ };
2182
+
2183
+ /**
2184
+ * 触发字段的值类型,决定可用运算符与值输入方式:
2185
+ * options(单值选项)/ multiOptions(多值选项)/ number / boolean / text
2186
+ * definition 为字段注册定义(getFieldDefinition(field.type)),由调用方传入
2187
+ */
2188
+ const getConditionValueKind = (field, definition) => {
2189
+ const props = field?.props || {};
2190
+ if (field?.type === 'CheckboxGroup' || definition?.isSuperSelect || field?.type === 'Select' && (props.mode === 'multiple' || props.mode === 'tags')) {
2191
+ return 'multiOptions';
2192
+ }
2193
+ if (definition?.hasOptions) {
2194
+ return 'options';
2195
+ }
2196
+ if (field?.type === 'Switch' || field?.type === 'Checkbox') {
2197
+ return 'boolean';
2198
+ }
2199
+ const valueSchema = typeof definition?.valueSchema === 'function' ? definition.valueSchema(field) : definition?.valueSchema;
2200
+ if (valueSchema?.type === 'number' || valueSchema?.type === 'integer') {
2201
+ return 'number';
2202
+ }
2203
+ return 'text';
2204
+ };
2205
+ const OPERATORS_BY_KIND = {
2206
+ options: ['eq', 'neq', 'in', 'empty', 'notEmpty'],
2207
+ multiOptions: ['includesAny', 'empty', 'notEmpty', 'regex'],
2208
+ number: ['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'empty', 'notEmpty', 'regex'],
2209
+ boolean: ['eq', 'neq'],
2210
+ text: ['eq', 'neq', 'empty', 'notEmpty', 'regex']
2211
+ };
2212
+ const getConditionOperators = (field, definition) => OPERATORS_BY_KIND[getConditionValueKind(field, definition)] || OPERATORS_BY_KIND.text;
2213
+
2214
+ /** 去掉空条件,规范 logic / flags;无有效条件返回 undefined(不写入 schema) */
2215
+ const normalizeVisibleWhen = visibleWhen => {
2216
+ const conditions = (visibleWhen?.conditions || []).filter(condition => condition?.field && CONDITION_OPERATORS.includes(condition.operator)).map(condition => {
2217
+ const next = {
2218
+ field: condition.field,
2219
+ operator: condition.operator
2220
+ };
2221
+ if (!NO_VALUE_OPERATORS.includes(condition.operator)) {
2222
+ next.value = condition.value;
2223
+ }
2224
+ if (condition.operator === 'regex') {
2225
+ const flags = sanitizeRegexFlags(condition.flags);
2226
+ if (flags) {
2227
+ next.flags = flags;
2228
+ }
2229
+ }
2230
+ return next;
2231
+ });
2232
+ if (!conditions.length) {
2233
+ return undefined;
2234
+ }
2235
+ return {
2236
+ logic: visibleWhen.logic === 'or' ? 'or' : 'and',
2237
+ conditions
2238
+ };
2239
+ };
2240
+ const formatConditionValue = (condition, optionLabelOf) => {
2241
+ if (condition.operator === 'regex') {
2242
+ return `/${condition.value ?? ''}/${sanitizeRegexFlags(condition.flags)}`;
2243
+ }
2244
+ return toArray(condition.value).map(item => optionLabelOf(item)).join(', ');
2245
+ };
2246
+
2247
+ /**
2248
+ * 条件的可读摘要,如「是否通过 等于 不通过」
2249
+ * formatMessage 需含 conditionOperator_* / conditionLogic_* 文案;fieldLookup 为 path → field
2250
+ */
2251
+ const formatVisibleWhen = (visibleWhen, {
2252
+ formatMessage,
2253
+ fieldLookup = new Map(),
2254
+ resolveText = text => text
2255
+ } = {}) => {
2256
+ const conditions = visibleWhen?.conditions || [];
2257
+ const parts = conditions.map(condition => {
2258
+ const trigger = fieldLookup.get(condition.field);
2259
+ const fieldLabel = trigger && resolveText(trigger.label) || condition.field;
2260
+ const optionLabelOf = value => {
2261
+ const option = (trigger?.props?.options || []).find(item => sameValue(item?.value, value));
2262
+ if (option) {
2263
+ return resolveText(option.label);
2264
+ }
2265
+ if (typeof value === 'boolean') {
2266
+ return formatMessage({
2267
+ id: value ? 'conditionValueTrue' : 'conditionValueFalse'
2268
+ });
2269
+ }
2270
+ return String(toComparable(value));
2271
+ };
2272
+ const operatorText = formatMessage({
2273
+ id: `conditionOperator_${condition.operator}`
2274
+ });
2275
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
2276
+ return `${fieldLabel} ${operatorText}`;
2277
+ }
2278
+ return `${fieldLabel} ${operatorText} ${formatConditionValue(condition, optionLabelOf)}`;
2279
+ });
2280
+ return parts.join(formatMessage({
2281
+ id: visibleWhen?.logic === 'or' ? 'conditionJoinOr' : 'conditionJoinAnd'
2282
+ }));
2283
+ };
2284
+
1738
2285
  const registry = new Map();
1739
2286
  const defineField = (type, definition) => {
1740
2287
  registry.set(type, {
@@ -2516,6 +3063,7 @@ const fieldToFormValues = field => {
2516
3063
  description: field.description || '',
2517
3064
  block: !!field.block,
2518
3065
  hidden: !!field.hidden,
3066
+ visibleWhen: field.visibleWhen,
2519
3067
  placeholder,
2520
3068
  options: options.length ? options : [{
2521
3069
  label: '',
@@ -2554,6 +3102,7 @@ const formValuesToField = (values, existingField = {}) => {
2554
3102
  props.children = values.label;
2555
3103
  }
2556
3104
  const rule = buildRuleString(values.ruleConfig);
3105
+ const visibleWhen = normalizeVisibleWhen(values.visibleWhen);
2557
3106
  return {
2558
3107
  id: existingField.id,
2559
3108
  type: values.type,
@@ -2564,6 +3113,9 @@ const formValuesToField = (values, existingField = {}) => {
2564
3113
  rule,
2565
3114
  block: values.block ?? definition.defaults?.block ?? false,
2566
3115
  hidden: !!values.hidden,
3116
+ ...(visibleWhen ? {
3117
+ visibleWhen
3118
+ } : {}),
2567
3119
  props
2568
3120
  };
2569
3121
  };
@@ -2668,7 +3220,7 @@ const LocaleTextArea = props => {
2668
3220
  LocaleTextArea.field = LocaleTextAreaControl;
2669
3221
 
2670
3222
  const {
2671
- Text: Text$4
3223
+ Text: Text$5
2672
3224
  } = antd.Typography;
2673
3225
  const TYPE_TAG_COLORS = {
2674
3226
  Input: 'blue',
@@ -2688,13 +3240,35 @@ const TYPE_TAG_COLORS = {
2688
3240
  Checkbox: 'green',
2689
3241
  DatePicker: 'lime'
2690
3242
  };
3243
+ const TYPE_TAG_ICONS = {
3244
+ Input: icons.FontSizeOutlined,
3245
+ TextArea: icons.AlignLeftOutlined,
3246
+ InputNumber: icons.NumberOutlined,
3247
+ Select: icons.DownSquareOutlined,
3248
+ RadioGroup: icons.CheckCircleOutlined,
3249
+ CheckboxGroup: icons.CheckSquareOutlined,
3250
+ SuperSelectList: icons.AppstoreOutlined,
3251
+ SuperSelectTableList: icons.AppstoreOutlined,
3252
+ SuperSelectTree: icons.AppstoreOutlined,
3253
+ SuperSelectCascader: icons.AppstoreOutlined,
3254
+ SelectFunction: icons.ApartmentOutlined,
3255
+ SelectIndustry: icons.ShopOutlined,
3256
+ SelectAddress: icons.EnvironmentOutlined,
3257
+ Switch: icons.SwapOutlined,
3258
+ Checkbox: icons.CheckSquareOutlined,
3259
+ DatePicker: icons.CalendarOutlined
3260
+ };
3261
+ const getFieldTypeIcon = type => TYPE_TAG_ICONS[type] || icons.FormOutlined;
2691
3262
  const FieldRow = ({
2692
3263
  field,
2693
3264
  index,
2694
3265
  total,
2695
3266
  onEdit,
2696
3267
  onDelete,
2697
- onMove
3268
+ onMove,
3269
+ prevLocked,
3270
+ nextLocked,
3271
+ conditionContext
2698
3272
  }) => {
2699
3273
  const {
2700
3274
  formatMessage,
@@ -2702,40 +3276,81 @@ const FieldRow = ({
2702
3276
  } = reactIntl.useIntl();
2703
3277
  const languages = useLocaleTextLanguages();
2704
3278
  const definition = getFieldDefinition(field.type);
3279
+ const conditional = hasVisibleWhen(field);
3280
+ const conditionInvalid = conditional && conditionContext && hasInvalidCondition(field, conditionContext.triggerNames);
3281
+ const TypeIcon = getFieldTypeIcon(field.type);
2705
3282
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
2706
3283
  className: style['field-row'],
2707
3284
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
2708
3285
  className: style['field-row-index'],
2709
3286
  children: index + 1
2710
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
3287
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
2711
3288
  className: style['field-row-main'],
2712
- children: /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
3289
+ children: [/*#__PURE__*/jsxRuntime.jsx(Text$5, {
3290
+ strong: true,
3291
+ className: style['field-row-label'],
3292
+ children: resolveLocaleText(field.label, locale, languages) || formatMessage({
3293
+ id: 'untitledField'
3294
+ })
3295
+ }), /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
2713
3296
  size: 6,
2714
3297
  wrap: true,
2715
- children: [/*#__PURE__*/jsxRuntime.jsx(Text$4, {
2716
- strong: true,
2717
- ellipsis: true,
2718
- children: resolveLocaleText(field.label, locale, languages) || formatMessage({
2719
- id: 'untitledField'
2720
- })
2721
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3298
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
2722
3299
  bordered: false,
2723
3300
  color: TYPE_TAG_COLORS[field.type] || 'default',
3301
+ icon: /*#__PURE__*/jsxRuntime.jsx(TypeIcon, {}),
2724
3302
  children: resolveFieldTypeLabel(definition || field.type, formatMessage)
2725
- }), field.hidden ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3303
+ }), field.locked ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3304
+ bordered: false,
3305
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.LockOutlined, {}),
3306
+ title: formatMessage({
3307
+ id: 'fieldLockedTips'
3308
+ }),
3309
+ children: formatMessage({
3310
+ id: 'fieldLockedTag'
3311
+ })
3312
+ }) : null, field.hidden ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
2726
3313
  bordered: false,
3314
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.EyeInvisibleOutlined, {}),
2727
3315
  children: formatMessage({
2728
3316
  id: 'fieldHiddenTag'
2729
3317
  })
3318
+ }) : null, conditional ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
3319
+ title: formatVisibleWhen(field.visibleWhen, {
3320
+ formatMessage,
3321
+ fieldLookup: conditionContext?.fieldLookup,
3322
+ resolveText: value => resolveLocaleText(value, locale, languages)
3323
+ }),
3324
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3325
+ bordered: false,
3326
+ color: "magenta",
3327
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.BranchesOutlined, {}),
3328
+ children: formatMessage({
3329
+ id: 'fieldConditionTag'
3330
+ })
3331
+ })
3332
+ }) : null, conditionInvalid ? /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
3333
+ title: formatMessage({
3334
+ id: 'fieldConditionInvalidTips'
3335
+ }),
3336
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3337
+ bordered: false,
3338
+ color: "error",
3339
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.WarningOutlined, {}),
3340
+ children: formatMessage({
3341
+ id: 'fieldConditionInvalidTag'
3342
+ })
3343
+ })
2730
3344
  }) : null, field.block ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
2731
3345
  bordered: false,
2732
3346
  color: "processing",
3347
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.ColumnWidthOutlined, {}),
2733
3348
  children: formatMessage({
2734
3349
  id: 'fieldBlockTag'
2735
3350
  })
2736
3351
  }) : null]
2737
- })
2738
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
3352
+ })]
3353
+ }), field.locked ? null : /*#__PURE__*/jsxRuntime.jsxs("div", {
2739
3354
  className: style['action-group'],
2740
3355
  children: [/*#__PURE__*/jsxRuntime.jsx(antd.Button, {
2741
3356
  type: "text",
@@ -2745,7 +3360,7 @@ const FieldRow = ({
2745
3360
  id: 'moveUp'
2746
3361
  }),
2747
3362
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowUpOutlined, {}),
2748
- disabled: index === 0,
3363
+ disabled: index === 0 || prevLocked,
2749
3364
  onClick: () => onMove(field.id, 'up')
2750
3365
  }), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
2751
3366
  type: "text",
@@ -2755,7 +3370,7 @@ const FieldRow = ({
2755
3370
  id: 'moveDown'
2756
3371
  }),
2757
3372
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowDownOutlined, {}),
2758
- disabled: index === total - 1,
3373
+ disabled: index === total - 1 || nextLocked,
2759
3374
  onClick: () => onMove(field.id, 'down')
2760
3375
  }), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
2761
3376
  type: "text",
@@ -2780,10 +3395,9 @@ const FieldRow = ({
2780
3395
  })]
2781
3396
  });
2782
3397
  };
2783
- var FieldRow$1 = FieldRow;
2784
3398
 
2785
3399
  const {
2786
- Text: Text$3
3400
+ Text: Text$4
2787
3401
  } = antd.Typography;
2788
3402
  const ActionGroup = ({
2789
3403
  children
@@ -2828,6 +3442,10 @@ const ROOT_ADD_OPTIONS = [{
2828
3442
  key: 'steps',
2829
3443
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.OrderedListOutlined, {})
2830
3444
  }];
3445
+ const BLOCK_KIND_ICONS = Object.fromEntries(ROOT_ADD_OPTIONS.map(({
3446
+ key,
3447
+ icon
3448
+ }) => [key, icon]));
2831
3449
 
2832
3450
  /** 可挂子模块的容器;表格列表 / 同类多值本身不支持子模块 */
2833
3451
  const NESTED_ADD_OPTIONS = ROOT_ADD_OPTIONS.filter(opt => opt.key !== 'steps');
@@ -2861,6 +3479,15 @@ const BlockListPanel = ({
2861
3479
  const [addMenuOpen, setAddMenuOpen] = react.useState(false);
2862
3480
  const [addFieldMenuId, setAddFieldMenuId] = react.useState(null);
2863
3481
  const keepAddFieldMenuOpenRef = react.useRef(false);
3482
+ const conditionContext = react.useMemo(() => {
3483
+ const triggerFields = collectConditionFields({
3484
+ blocks
3485
+ }).filter(item => !item.inList);
3486
+ return {
3487
+ triggerNames: new Set(triggerFields.map(item => item.path)),
3488
+ fieldLookup: new Map(triggerFields.map(item => [item.path, item.field]))
3489
+ };
3490
+ }, [blocks]);
2864
3491
  const renderAddBlockMenu = (options, {
2865
3492
  onSelect,
2866
3493
  className
@@ -3022,7 +3649,7 @@ const BlockListPanel = ({
3022
3649
  optionId
3023
3650
  } = {}) => {
3024
3651
  if (!(fields || []).length) {
3025
- return /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3652
+ return /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3026
3653
  type: "secondary",
3027
3654
  className: style['inline-empty'],
3028
3655
  children: formatMessage({
@@ -3032,10 +3659,13 @@ const BlockListPanel = ({
3032
3659
  }
3033
3660
  return /*#__PURE__*/jsxRuntime.jsx("div", {
3034
3661
  className: style['field-list'],
3035
- children: fields.map((field, fieldIndex) => /*#__PURE__*/jsxRuntime.jsx(FieldRow$1, {
3662
+ children: fields.map((field, fieldIndex) => /*#__PURE__*/jsxRuntime.jsx(FieldRow, {
3036
3663
  field: field,
3037
3664
  index: fieldIndex,
3038
3665
  total: fields.length,
3666
+ prevLocked: isFieldLocked(fields[fieldIndex - 1]),
3667
+ nextLocked: isFieldLocked(fields[fieldIndex + 1]),
3668
+ conditionContext: conditionContext,
3039
3669
  onEdit: fieldItem => onEditField(blockId, fieldItem, {
3040
3670
  stepId,
3041
3671
  optionId
@@ -3059,7 +3689,7 @@ const BlockListPanel = ({
3059
3689
  className: style['item-blocks-section'],
3060
3690
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
3061
3691
  className: style['nested-block-list'],
3062
- children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks.length, depth + 1))
3692
+ children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks, depth + 1))
3063
3693
  })
3064
3694
  });
3065
3695
  };
@@ -3070,7 +3700,7 @@ const BlockListPanel = ({
3070
3700
  className: style['block-body'],
3071
3701
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
3072
3702
  className: style['section-toolbar'],
3073
- children: [/*#__PURE__*/jsxRuntime.jsx(Text$3, {
3703
+ children: [/*#__PURE__*/jsxRuntime.jsx(Text$4, {
3074
3704
  type: "secondary",
3075
3705
  className: style['section-toolbar-label'],
3076
3706
  children: formatMessage({
@@ -3099,14 +3729,14 @@ const BlockListPanel = ({
3099
3729
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
3100
3730
  className: style['step-index'],
3101
3731
  children: stepIndex + 1
3102
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3732
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3103
3733
  strong: true,
3104
3734
  children: text(step.title) || formatMessage({
3105
3735
  id: 'untitledStep'
3106
3736
  }, {
3107
3737
  index: stepIndex + 1
3108
3738
  })
3109
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3739
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3110
3740
  type: "secondary",
3111
3741
  children: (step.blocks || []).length ? formatMessage({
3112
3742
  id: 'fieldAndItemBlockCount'
@@ -3129,14 +3759,14 @@ const BlockListPanel = ({
3129
3759
  id: 'moveUp'
3130
3760
  }),
3131
3761
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowUpOutlined, {}),
3132
- disabled: stepIndex === 0,
3762
+ disabled: stepIndex === 0 || blockHasLockedField(step) || blockHasLockedField(block.items[stepIndex - 1]),
3133
3763
  onClick: () => onMoveStep(block.id, step.id, 'up')
3134
3764
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3135
3765
  title: formatMessage({
3136
3766
  id: 'moveDown'
3137
3767
  }),
3138
3768
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowDownOutlined, {}),
3139
- disabled: stepIndex === (block.items?.length || 0) - 1,
3769
+ disabled: stepIndex === (block.items?.length || 0) - 1 || blockHasLockedField(step) || blockHasLockedField(block.items[stepIndex + 1]),
3140
3770
  onClick: () => onMoveStep(block.id, step.id, 'down')
3141
3771
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3142
3772
  title: formatMessage({
@@ -3144,7 +3774,7 @@ const BlockListPanel = ({
3144
3774
  }),
3145
3775
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.EditOutlined, {}),
3146
3776
  onClick: () => onEditStep(block.id, step)
3147
- }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3777
+ }), blockHasLockedField(step) ? null : /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3148
3778
  title: formatMessage({
3149
3779
  id: 'deleteStep'
3150
3780
  }),
@@ -3168,7 +3798,7 @@ const BlockListPanel = ({
3168
3798
  stepId: step.id
3169
3799
  }), renderNestedBlocks(step.blocks, depth)]
3170
3800
  }, step.id))
3171
- }) : /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3801
+ }) : /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3172
3802
  type: "secondary",
3173
3803
  className: style['inline-empty'],
3174
3804
  children: formatMessage({
@@ -3180,7 +3810,7 @@ const BlockListPanel = ({
3180
3810
  if (block.kind === 'multiField') {
3181
3811
  return /*#__PURE__*/jsxRuntime.jsx("div", {
3182
3812
  className: style['block-body'],
3183
- children: /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3813
+ children: /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3184
3814
  type: "secondary",
3185
3815
  children: formatMessage({
3186
3816
  id: 'multiFieldEditorHint'
@@ -3193,7 +3823,7 @@ const BlockListPanel = ({
3193
3823
  className: style['block-body'],
3194
3824
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
3195
3825
  className: style['section-toolbar'],
3196
- children: [/*#__PURE__*/jsxRuntime.jsx(Text$3, {
3826
+ children: [/*#__PURE__*/jsxRuntime.jsx(Text$4, {
3197
3827
  type: "secondary",
3198
3828
  className: style['section-toolbar-label'],
3199
3829
  children: formatMessage({
@@ -3222,14 +3852,14 @@ const BlockListPanel = ({
3222
3852
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
3223
3853
  className: style['step-index'],
3224
3854
  children: optionIndex + 1
3225
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3855
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3226
3856
  strong: true,
3227
3857
  children: text(option.title) || formatMessage({
3228
3858
  id: 'choiceOptionFallback'
3229
3859
  }, {
3230
3860
  index: optionIndex + 1
3231
3861
  })
3232
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3862
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3233
3863
  type: "secondary",
3234
3864
  children: (option.blocks || []).length ? formatMessage({
3235
3865
  id: 'fieldAndItemBlockCount'
@@ -3252,14 +3882,14 @@ const BlockListPanel = ({
3252
3882
  id: 'moveUp'
3253
3883
  }),
3254
3884
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowUpOutlined, {}),
3255
- disabled: optionIndex === 0,
3885
+ disabled: optionIndex === 0 || blockHasLockedField(option) || blockHasLockedField(block.options[optionIndex - 1]),
3256
3886
  onClick: () => onMoveChoiceOption(block.id, option.id, 'up')
3257
3887
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3258
3888
  title: formatMessage({
3259
3889
  id: 'moveDown'
3260
3890
  }),
3261
3891
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowDownOutlined, {}),
3262
- disabled: optionIndex === (block.options?.length || 0) - 1,
3892
+ disabled: optionIndex === (block.options?.length || 0) - 1 || blockHasLockedField(option) || blockHasLockedField(block.options[optionIndex + 1]),
3263
3893
  onClick: () => onMoveChoiceOption(block.id, option.id, 'down')
3264
3894
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3265
3895
  title: formatMessage({
@@ -3267,7 +3897,7 @@ const BlockListPanel = ({
3267
3897
  }),
3268
3898
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.EditOutlined, {}),
3269
3899
  onClick: () => onEditChoiceOption(block.id, option)
3270
- }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3900
+ }), blockHasLockedField(option) ? null : /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3271
3901
  title: formatMessage({
3272
3902
  id: 'deleteChoiceOption'
3273
3903
  }),
@@ -3291,7 +3921,7 @@ const BlockListPanel = ({
3291
3921
  optionId: option.id
3292
3922
  }), renderNestedBlocks(option.blocks, depth)]
3293
3923
  }, option.id))
3294
- }) : /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3924
+ }) : /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3295
3925
  type: "secondary",
3296
3926
  className: style['inline-empty'],
3297
3927
  children: formatMessage({
@@ -3307,7 +3937,9 @@ const BlockListPanel = ({
3307
3937
  children: [renderFieldList(block.list, block.id), supportsItemBlocks$1 ? renderItemBlocks(block, depth) : null, supportsBlocks ? renderNestedBlocks(block.blocks, depth) : null]
3308
3938
  });
3309
3939
  };
3310
- const renderBlockSection = (block, blockIndex, total, depth = 0) => {
3940
+ const renderBlockSection = (block, blockIndex, siblings, depth = 0) => {
3941
+ const total = siblings.length;
3942
+ const locked = blockHasLockedField(block);
3311
3943
  const definition = getBlockDefinition(block.kind);
3312
3944
  const canAddField = block.kind !== 'steps' && block.kind !== 'multiField' && block.kind !== 'choice';
3313
3945
  const supportsItemBlocks$1 = supportsItemBlocks(block.kind);
@@ -3321,7 +3953,10 @@ const BlockListPanel = ({
3321
3953
  }) : block.kind === 'multiField' ? formatMessage({
3322
3954
  id: 'multiFieldSummary'
3323
3955
  }, {
3324
- type: resolveFieldTypeLabel(block.fieldType, formatMessage)
3956
+ type: /*#__PURE__*/jsxRuntime.jsxs("span", {
3957
+ className: style['block-summary-type'],
3958
+ children: [/*#__PURE__*/react.createElement(getFieldTypeIcon(block.fieldType || 'Input')), resolveFieldTypeLabel(block.fieldType, formatMessage)]
3959
+ })
3325
3960
  }) : block.kind === 'choice' ? formatMessage({
3326
3961
  id: 'choiceOptionCount'
3327
3962
  }, {
@@ -3345,10 +3980,11 @@ const BlockListPanel = ({
3345
3980
  children: [/*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3346
3981
  bordered: false,
3347
3982
  color: definition?.color || 'default',
3983
+ icon: BLOCK_KIND_ICONS[block.kind],
3348
3984
  children: formatMessage({
3349
3985
  id: `blockKind_${block.kind}`
3350
3986
  })
3351
- }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3987
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$4, {
3352
3988
  strong: true,
3353
3989
  ellipsis: true,
3354
3990
  className: style['block-title'],
@@ -3369,14 +4005,14 @@ const BlockListPanel = ({
3369
4005
  id: 'moveUp'
3370
4006
  }),
3371
4007
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowUpOutlined, {}),
3372
- disabled: blockIndex === 0,
4008
+ disabled: blockIndex === 0 || locked || blockHasLockedField(siblings[blockIndex - 1]),
3373
4009
  onClick: () => onMoveBlock(block.id, 'up')
3374
4010
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3375
4011
  title: formatMessage({
3376
4012
  id: 'moveDown'
3377
4013
  }),
3378
4014
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowDownOutlined, {}),
3379
- disabled: blockIndex === total - 1,
4015
+ disabled: blockIndex === total - 1 || locked || blockHasLockedField(siblings[blockIndex + 1]),
3380
4016
  onClick: () => onMoveBlock(block.id, 'down')
3381
4017
  }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3382
4018
  title: formatMessage({
@@ -3384,7 +4020,7 @@ const BlockListPanel = ({
3384
4020
  }),
3385
4021
  icon: /*#__PURE__*/jsxRuntime.jsx(icons.SettingOutlined, {}),
3386
4022
  onClick: () => onEditBlock(block)
3387
- }), /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
4023
+ }), locked ? null : /*#__PURE__*/jsxRuntime.jsx(IconBtn, {
3388
4024
  title: formatMessage({
3389
4025
  id: 'deleteBlock'
3390
4026
  }),
@@ -3452,7 +4088,7 @@ const BlockListPanel = ({
3452
4088
  })
3453
4089
  }) : /*#__PURE__*/jsxRuntime.jsx("div", {
3454
4090
  className: style['block-list'],
3455
- children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks.length, 0))
4091
+ children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks, 0))
3456
4092
  })]
3457
4093
  });
3458
4094
  };
@@ -3873,7 +4509,7 @@ const ChoiceOptionEditorModal = ({
3873
4509
  var ChoiceOptionEditorModal$1 = ChoiceOptionEditorModal;
3874
4510
 
3875
4511
  const {
3876
- Text: Text$2
4512
+ Text: Text$3
3877
4513
  } = antd.Typography;
3878
4514
  const {
3879
4515
  useOnChange
@@ -3922,7 +4558,7 @@ const RulePresetEditor = () => {
3922
4558
  }) => (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET)
3923
4559
  }, "lenMax"), /*#__PURE__*/jsxRuntime.jsx("div", {
3924
4560
  block: true,
3925
- children: /*#__PURE__*/jsxRuntime.jsx(Text$2, {
4561
+ children: /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3926
4562
  type: "secondary",
3927
4563
  children: formatMessage({
3928
4564
  id: 'ruleEditorHint'
@@ -3940,7 +4576,7 @@ const RulePresetEditor = () => {
3940
4576
  var RulePresetEditor$1 = RulePresetEditor;
3941
4577
 
3942
4578
  const {
3943
- Text: Text$1
4579
+ Text: Text$2
3944
4580
  } = antd.Typography;
3945
4581
  const createOptionKey = () => createDataKey('opt');
3946
4582
  const EMPTY_OPTION = () => ({
@@ -4013,7 +4649,28 @@ const FlatOptionRows = ({
4013
4649
  };
4014
4650
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
4015
4651
  className: style['options-list'],
4016
- children: [rows.map((item, index) => /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
4652
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
4653
+ className: style['options-header'],
4654
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
4655
+ className: style['options-header-label'],
4656
+ children: formatMessage({
4657
+ id: 'optionLabelColumn'
4658
+ })
4659
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
4660
+ className: style['options-header-value'],
4661
+ children: formatMessage({
4662
+ id: 'optionValueColumn'
4663
+ })
4664
+ }), allowDescription ? /*#__PURE__*/jsxRuntime.jsx("span", {
4665
+ className: style['options-header-description'],
4666
+ children: formatMessage({
4667
+ id: 'optionDescColumn'
4668
+ })
4669
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("span", {
4670
+ className: style['options-header-action'],
4671
+ "aria-hidden": "true"
4672
+ })]
4673
+ }), rows.map((item, index) => /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
4017
4674
  gap: 8,
4018
4675
  align: "start",
4019
4676
  className: style['options-row'],
@@ -4355,7 +5012,7 @@ const TableRowsEditor = ({
4355
5012
  column: 1,
4356
5013
  list: [/*#__PURE__*/jsxRuntime.jsx("div", {
4357
5014
  block: true,
4358
- children: /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5015
+ children: /*#__PURE__*/jsxRuntime.jsx(Text$2, {
4359
5016
  type: "secondary",
4360
5017
  children: formatMessage({
4361
5018
  id: 'tableRowsNeedColumnsHint'
@@ -4405,6 +5062,7 @@ const TableRowsEditor = ({
4405
5062
  },
4406
5063
  children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
4407
5064
  gap: 8,
5065
+ className: style['options-row'],
4408
5066
  children: [/*#__PURE__*/jsxRuntime.jsx(antd.Input, {
4409
5067
  value: item.value || '',
4410
5068
  placeholder: formatMessage({
@@ -4914,6 +5572,391 @@ const hasFieldPropsEditor = (type, definition) => {
4914
5572
  };
4915
5573
  var FieldPropsEditor$1 = FieldPropsEditor;
4916
5574
 
5575
+ const {
5576
+ Text: Text$1
5577
+ } = antd.Typography;
5578
+ const MULTI_VALUE_OPERATORS = ['in', 'includesAny'];
5579
+ const createCondition = () => ({
5580
+ field: undefined,
5581
+ operator: undefined,
5582
+ value: undefined
5583
+ });
5584
+
5585
+ /** 编辑器提交前校验:返回错误文案 id,通过返回 null */
5586
+ const validateVisibleWhenDraft = visibleWhen => {
5587
+ if (!visibleWhen) {
5588
+ return null;
5589
+ }
5590
+ const incomplete = (visibleWhen.conditions || []).some(condition => {
5591
+ if (!condition?.field || !condition.operator) {
5592
+ return true;
5593
+ }
5594
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
5595
+ return false;
5596
+ }
5597
+ const value = condition.value;
5598
+ return value === undefined || value === null || value === '' || Array.isArray(value) && !value.length;
5599
+ });
5600
+ if (incomplete || !(visibleWhen.conditions || []).length) {
5601
+ return 'visibleWhenConditionRequired';
5602
+ }
5603
+ if (visibleWhen.conditions.some(condition => condition.operator === 'regex' && !compileConditionRegex(condition.value, condition.flags))) {
5604
+ return 'visibleWhenRegexInvalid';
5605
+ }
5606
+ return null;
5607
+ };
5608
+ const RegexTester = ({
5609
+ condition
5610
+ }) => {
5611
+ const {
5612
+ formatMessage
5613
+ } = reactIntl.useIntl();
5614
+ const [text, setText] = react.useState('');
5615
+ const regex = compileConditionRegex(condition.value, condition.flags);
5616
+ const status = regex && text !== '' ? regex.test(text) : null;
5617
+ return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5618
+ gap: 8,
5619
+ align: "center",
5620
+ className: style['visible-when-regex-tester'],
5621
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Input, {
5622
+ size: "small",
5623
+ value: text,
5624
+ placeholder: formatMessage({
5625
+ id: 'visibleWhenRegexTester'
5626
+ }),
5627
+ onChange: e => setText(e.target.value)
5628
+ }), status === null ? null : /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5629
+ type: status ? 'success' : 'warning',
5630
+ children: formatMessage({
5631
+ id: status ? 'visibleWhenRegexMatched' : 'visibleWhenRegexNotMatched'
5632
+ })
5633
+ })]
5634
+ });
5635
+ };
5636
+ const ConditionValueInput = ({
5637
+ condition,
5638
+ trigger,
5639
+ onChange
5640
+ }) => {
5641
+ const {
5642
+ formatMessage,
5643
+ locale
5644
+ } = reactIntl.useIntl();
5645
+ const definition = getFieldDefinition(trigger?.type);
5646
+ const kind = getConditionValueKind(trigger, definition);
5647
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
5648
+ return null;
5649
+ }
5650
+ if (condition.operator === 'regex') {
5651
+ const regexInvalid = condition.value != null && condition.value !== '' && !compileConditionRegex(condition.value, condition.flags);
5652
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
5653
+ className: style['visible-when-regex'],
5654
+ children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5655
+ gap: 8,
5656
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Input, {
5657
+ prefix: "/",
5658
+ suffix: "/",
5659
+ status: regexInvalid ? 'error' : undefined,
5660
+ value: condition.value ?? '',
5661
+ placeholder: formatMessage({
5662
+ id: 'visibleWhenValue'
5663
+ }),
5664
+ onChange: e => onChange({
5665
+ value: e.target.value
5666
+ })
5667
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5668
+ mode: "multiple",
5669
+ className: style['visible-when-flags'],
5670
+ placeholder: formatMessage({
5671
+ id: 'visibleWhenRegexFlags'
5672
+ }),
5673
+ value: String(condition.flags || '').split('').filter(Boolean),
5674
+ options: ALLOWED_REGEX_FLAGS.map(flag => ({
5675
+ value: flag,
5676
+ label: formatMessage({
5677
+ id: `visibleWhenRegexFlag_${flag}`
5678
+ })
5679
+ })),
5680
+ optionLabelProp: "value",
5681
+ onChange: flags => onChange({
5682
+ flags: flags.join('')
5683
+ })
5684
+ })]
5685
+ }), regexInvalid ? /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5686
+ type: "danger",
5687
+ children: formatMessage({
5688
+ id: 'visibleWhenRegexInvalid'
5689
+ })
5690
+ }) : null, /*#__PURE__*/jsxRuntime.jsx(RegexTester, {
5691
+ condition: condition
5692
+ })]
5693
+ });
5694
+ }
5695
+ if (kind === 'boolean') {
5696
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5697
+ className: style['visible-when-value'],
5698
+ value: condition.value,
5699
+ placeholder: formatMessage({
5700
+ id: 'visibleWhenValue'
5701
+ }),
5702
+ options: [{
5703
+ value: true,
5704
+ label: formatMessage({
5705
+ id: 'conditionValueTrue'
5706
+ })
5707
+ }, {
5708
+ value: false,
5709
+ label: formatMessage({
5710
+ id: 'conditionValueFalse'
5711
+ })
5712
+ }],
5713
+ onChange: value => onChange({
5714
+ value
5715
+ })
5716
+ });
5717
+ }
5718
+ if (kind === 'options' || kind === 'multiOptions') {
5719
+ const multiple = MULTI_VALUE_OPERATORS.includes(condition.operator);
5720
+ const options = (trigger?.props?.options || []).filter(item => item?.value != null && item.value !== '').map(item => ({
5721
+ value: item.value,
5722
+ label: resolveLocaleText(item.label, locale) || String(item.value)
5723
+ }));
5724
+ const value = multiple ? Array.isArray(condition.value) ? condition.value : condition.value != null ? [condition.value] : [] : Array.isArray(condition.value) ? condition.value[0] : condition.value;
5725
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5726
+ className: style['visible-when-value']
5727
+ // 远程数据源没有静态选项时允许手动输入值
5728
+ ,
5729
+ mode: options.length ? multiple ? 'multiple' : undefined : 'tags',
5730
+ value: value,
5731
+ placeholder: formatMessage({
5732
+ id: 'visibleWhenValue'
5733
+ }),
5734
+ options: options,
5735
+ onChange: next => onChange({
5736
+ value: !options.length && !multiple && Array.isArray(next) ? next[next.length - 1] : next
5737
+ })
5738
+ });
5739
+ }
5740
+ if (kind === 'number') {
5741
+ return /*#__PURE__*/jsxRuntime.jsx(antd.InputNumber, {
5742
+ className: style['visible-when-value'],
5743
+ value: condition.value ?? null,
5744
+ placeholder: formatMessage({
5745
+ id: 'visibleWhenValue'
5746
+ }),
5747
+ onChange: value => onChange({
5748
+ value: value ?? undefined
5749
+ })
5750
+ });
5751
+ }
5752
+ return /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
5753
+ className: style['visible-when-value'],
5754
+ value: condition.value ?? '',
5755
+ placeholder: formatMessage({
5756
+ id: 'visibleWhenValue'
5757
+ }),
5758
+ onChange: e => onChange({
5759
+ value: e.target.value
5760
+ })
5761
+ });
5762
+ };
5763
+
5764
+ /**
5765
+ * 条件显示配置(受控):value 为 visibleWhen 草稿或 undefined
5766
+ * triggerFields:collectConditionFields 中可作为触发项的字段;scope:当前字段所在模块
5767
+ */
5768
+ const VisibleWhenEditor = ({
5769
+ value,
5770
+ onChange,
5771
+ schema,
5772
+ triggerFields = [],
5773
+ scope,
5774
+ fieldId
5775
+ }) => {
5776
+ const {
5777
+ formatMessage,
5778
+ locale
5779
+ } = reactIntl.useIntl();
5780
+ const {
5781
+ formData
5782
+ } = reactFormAntd.useFormContext() || {};
5783
+ const selfPath = getFieldConditionPath(scope, formData?.name ? String(formData.name).trim() : '');
5784
+ const candidates = react.useMemo(() => triggerFields.filter(item => item.id !== fieldId && item.path !== selfPath).map(item => ({
5785
+ ...item,
5786
+ disabled: selfPath ? wouldCreateCycle(schema, selfPath, item.path) : false
5787
+ })), [triggerFields, fieldId, selfPath, schema]);
5788
+ if (scope?.inList) {
5789
+ return /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
5790
+ title: formatMessage({
5791
+ id: 'visibleWhenTitle'
5792
+ }),
5793
+ column: 1,
5794
+ list: [/*#__PURE__*/jsxRuntime.jsx("div", {
5795
+ block: true,
5796
+ children: /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5797
+ type: "secondary",
5798
+ children: formatMessage({
5799
+ id: 'visibleWhenListUnsupported'
5800
+ })
5801
+ })
5802
+ }, "unsupported")]
5803
+ });
5804
+ }
5805
+ const enabled = !!value;
5806
+ const conditions = value?.conditions || [];
5807
+ const updateConditions = next => onChange({
5808
+ ...value,
5809
+ conditions: next
5810
+ });
5811
+ const updateCondition = (index, patch) => updateConditions(conditions.map((item, itemIndex) => itemIndex === index ? {
5812
+ ...item,
5813
+ ...patch
5814
+ } : item));
5815
+ const body = /*#__PURE__*/jsxRuntime.jsxs("div", {
5816
+ block: true,
5817
+ className: style['visible-when-editor'],
5818
+ children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5819
+ gap: 8,
5820
+ align: "center",
5821
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Switch, {
5822
+ size: "small",
5823
+ checked: enabled,
5824
+ disabled: !enabled && !candidates.length,
5825
+ onChange: checked => onChange(checked ? {
5826
+ logic: 'and',
5827
+ conditions: [createCondition()]
5828
+ } : undefined)
5829
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5830
+ children: formatMessage({
5831
+ id: 'visibleWhenEnable'
5832
+ })
5833
+ })]
5834
+ }), /*#__PURE__*/jsxRuntime.jsx(Text$1, {
5835
+ type: "secondary",
5836
+ className: style['visible-when-hint'],
5837
+ children: formatMessage({
5838
+ id: candidates.length || enabled ? 'visibleWhenEnableTips' : 'visibleWhenNoTrigger'
5839
+ })
5840
+ }), enabled ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5841
+ children: [conditions.length > 1 ? /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5842
+ gap: 8,
5843
+ align: "center",
5844
+ children: [/*#__PURE__*/jsxRuntime.jsx(Text$1, {
5845
+ children: formatMessage({
5846
+ id: 'visibleWhenLogic'
5847
+ })
5848
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Radio.Group, {
5849
+ size: "small",
5850
+ value: value.logic === 'or' ? 'or' : 'and',
5851
+ options: ['and', 'or'].map(logic => ({
5852
+ value: logic,
5853
+ label: formatMessage({
5854
+ id: `conditionLogic_${logic}`
5855
+ })
5856
+ })),
5857
+ onChange: e => onChange({
5858
+ ...value,
5859
+ logic: e.target.value
5860
+ })
5861
+ })]
5862
+ }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
5863
+ className: style['visible-when-list'],
5864
+ children: conditions.map((condition, index) => {
5865
+ const trigger = triggerFields.find(item => item.path === condition.field)?.field;
5866
+ const operators = trigger ? getConditionOperators(trigger, getFieldDefinition(trigger.type)) : [];
5867
+ return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5868
+ gap: 8,
5869
+ align: "start",
5870
+ className: style['visible-when-row'],
5871
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
5872
+ className: style['visible-when-row-main'],
5873
+ children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
5874
+ gap: 8,
5875
+ wrap: true,
5876
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5877
+ showSearch: true,
5878
+ optionFilterProp: "label",
5879
+ className: style['visible-when-field'],
5880
+ status: condition.field && !trigger ? 'error' : undefined,
5881
+ value: condition.field,
5882
+ placeholder: formatMessage({
5883
+ id: 'visibleWhenField'
5884
+ }),
5885
+ options: candidates.map(item => ({
5886
+ value: item.path,
5887
+ disabled: item.disabled,
5888
+ label: `${resolveLocaleText(item.field.label, locale) || item.field.name}(${item.path})`
5889
+ })),
5890
+ onChange: path => {
5891
+ const nextTrigger = triggerFields.find(item => item.path === path)?.field;
5892
+ const nextOperators = getConditionOperators(nextTrigger, getFieldDefinition(nextTrigger?.type));
5893
+ updateCondition(index, {
5894
+ field: path,
5895
+ operator: nextOperators[0],
5896
+ value: undefined,
5897
+ flags: undefined
5898
+ });
5899
+ }
5900
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
5901
+ className: style['visible-when-operator'],
5902
+ value: condition.operator,
5903
+ disabled: !trigger,
5904
+ placeholder: formatMessage({
5905
+ id: 'visibleWhenOperator'
5906
+ }),
5907
+ options: operators.map(operator => ({
5908
+ value: operator,
5909
+ label: formatMessage({
5910
+ id: `conditionOperator_${operator}`
5911
+ })
5912
+ })),
5913
+ onChange: operator => updateCondition(index, {
5914
+ operator,
5915
+ value: undefined,
5916
+ flags: undefined
5917
+ })
5918
+ })]
5919
+ }), trigger && condition.operator ? /*#__PURE__*/jsxRuntime.jsx(ConditionValueInput, {
5920
+ condition: condition,
5921
+ trigger: trigger,
5922
+ onChange: patch => updateCondition(index, patch)
5923
+ }) : null]
5924
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
5925
+ type: "text",
5926
+ danger: true,
5927
+ className: style['icon-square-btn-sm'],
5928
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.DeleteOutlined, {}),
5929
+ onClick: () => {
5930
+ const next = conditions.filter((_, itemIndex) => itemIndex !== index);
5931
+ onChange(next.length ? {
5932
+ ...value,
5933
+ conditions: next
5934
+ } : undefined);
5935
+ }
5936
+ })]
5937
+ }, index);
5938
+ })
5939
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
5940
+ type: "dashed",
5941
+ block: true,
5942
+ icon: /*#__PURE__*/jsxRuntime.jsx(icons.PlusOutlined, {}),
5943
+ onClick: () => updateConditions([...conditions, createCondition()]),
5944
+ children: formatMessage({
5945
+ id: 'visibleWhenAddCondition'
5946
+ })
5947
+ })]
5948
+ }) : null]
5949
+ }, "visible-when");
5950
+ return /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
5951
+ title: formatMessage({
5952
+ id: 'visibleWhenTitle'
5953
+ }),
5954
+ column: 1,
5955
+ list: [body]
5956
+ });
5957
+ };
5958
+ var VisibleWhenEditor$1 = VisibleWhenEditor;
5959
+
4917
5960
  const {
4918
5961
  Text
4919
5962
  } = antd.Typography;
@@ -4937,7 +5980,10 @@ const FieldConfigFields = ({
4937
5980
  options,
4938
5981
  onOptionsChange,
4939
5982
  columns,
4940
- onColumnsChange
5983
+ onColumnsChange,
5984
+ visibleWhen,
5985
+ onVisibleWhenChange,
5986
+ conditionProps
4941
5987
  }) => {
4942
5988
  const {
4943
5989
  formatMessage
@@ -5060,6 +6106,10 @@ const FieldConfigFields = ({
5060
6106
  hasColumns: definition.hasColumns,
5061
6107
  columns: columns,
5062
6108
  onColumnsChange: onColumnsChange
6109
+ }) : null, conditionProps ? /*#__PURE__*/jsxRuntime.jsx(VisibleWhenEditor$1, {
6110
+ ...conditionProps,
6111
+ value: visibleWhen,
6112
+ onChange: onVisibleWhenChange
5063
6113
  }) : null]
5064
6114
  });
5065
6115
  };
@@ -5067,6 +6117,7 @@ const FieldEditorModal = ({
5067
6117
  open,
5068
6118
  field,
5069
6119
  fieldList,
6120
+ conditionProps,
5070
6121
  onCancel,
5071
6122
  onSave,
5072
6123
  renderModal
@@ -5103,6 +6154,7 @@ const FieldEditorModal = ({
5103
6154
  value: ''
5104
6155
  }]);
5105
6156
  const [columns, setColumns] = react.useState(() => [createEmptyColumn()]);
6157
+ const [visibleWhen, setVisibleWhen] = react.useState(undefined);
5106
6158
  react.useEffect(() => {
5107
6159
  if (!open) {
5108
6160
  return;
@@ -5112,6 +6164,7 @@ const FieldEditorModal = ({
5112
6164
  value: ''
5113
6165
  }]);
5114
6166
  setColumns(editorValues.selectProps?.columns?.length ? editorValues.selectProps.columns : [createEmptyColumn()]);
6167
+ setVisibleWhen(editorValues.visibleWhen);
5115
6168
  }, [open, editorValues]);
5116
6169
  const handleSubmit = function (values) {
5117
6170
  try {
@@ -5121,6 +6174,13 @@ const FieldEditorModal = ({
5121
6174
  }));
5122
6175
  return Promise.resolve(false);
5123
6176
  }
6177
+ const conditionError = conditionProps && !conditionProps.scope?.inList ? validateVisibleWhenDraft(visibleWhen) : null;
6178
+ if (conditionError) {
6179
+ antd.message.error(formatMessage({
6180
+ id: conditionError
6181
+ }));
6182
+ return Promise.resolve(false);
6183
+ }
5124
6184
  const definition = getFieldDefinition(values.type);
5125
6185
  const normalizedColumns = definition?.hasColumns ? normalizeColumns(columns) : [];
5126
6186
  const nextField = formValuesToField({
@@ -5138,13 +6198,13 @@ const FieldEditorModal = ({
5138
6198
  ...values,
5139
6199
  columns: normalizedColumns
5140
6200
  },
5141
- fieldProps: values
6201
+ fieldProps: values,
6202
+ visibleWhen
5142
6203
  }, field || createField$1());
5143
6204
  if (!nextField.id) {
5144
6205
  nextField.id = createField$1().id;
5145
6206
  }
5146
- onSave(nextField);
5147
- return Promise.resolve();
6207
+ return Promise.resolve(onSave(nextField));
5148
6208
  } catch (e) {
5149
6209
  return Promise.reject(e);
5150
6210
  }
@@ -5177,7 +6237,13 @@ const FieldEditorModal = ({
5177
6237
  options: options,
5178
6238
  onOptionsChange: setOptions,
5179
6239
  columns: columns,
5180
- onColumnsChange: setColumns
6240
+ onColumnsChange: setColumns,
6241
+ visibleWhen: visibleWhen,
6242
+ onVisibleWhenChange: setVisibleWhen,
6243
+ conditionProps: conditionProps ? {
6244
+ ...conditionProps,
6245
+ fieldId: field?.id
6246
+ } : null
5181
6247
  })
5182
6248
  }, modalKey);
5183
6249
  };
@@ -5627,6 +6693,50 @@ const ChoiceBlock = ({
5627
6693
  };
5628
6694
  var ChoiceBlock$1 = ChoiceBlock;
5629
6695
 
6696
+ /**
6697
+ * 按 visibleWhen 过滤字段的 FormInfo:
6698
+ * entries 为 [{ element, path, visibleWhen }],不满足条件的字段从 list 中移除(卸载即不参与校验),
6699
+ * 已有值的隐藏字段清空,避免提交残留
6700
+ */
6701
+ const ConditionalFormInfo = ({
6702
+ entries,
6703
+ nested = [],
6704
+ knownNames,
6705
+ ...formInfoProps
6706
+ }) => {
6707
+ const {
6708
+ formData,
6709
+ openApi
6710
+ } = reactFormAntd.useFormContext() || {};
6711
+ const hasForm = !!openApi;
6712
+ const hiddenPaths = react.useMemo(() => {
6713
+ if (!hasForm) {
6714
+ return [];
6715
+ }
6716
+ return entries.filter(entry => entry.visibleWhen && !evaluateVisibleWhen(entry.visibleWhen, formData, knownNames)).map(entry => entry.path);
6717
+ }, [entries, formData, knownNames, hasForm]);
6718
+ react.useEffect(() => {
6719
+ if (!hasForm) {
6720
+ return;
6721
+ }
6722
+ const toClear = hiddenPaths.filter(path => !isEmptyValue$1(getByPath$2(formData, path)));
6723
+ if (toClear.length) {
6724
+ openApi.setFields(toClear.map(name => ({
6725
+ name,
6726
+ value: undefined
6727
+ })), {
6728
+ runValidate: false
6729
+ });
6730
+ }
6731
+ }, [hiddenPaths, formData, openApi, hasForm]);
6732
+ const list = entries.filter(entry => !hiddenPaths.includes(entry.path)).map(entry => entry.element);
6733
+ return /*#__PURE__*/react.createElement(FormInfo__default["default"], {
6734
+ ...formInfoProps,
6735
+ list: [...list, ...nested]
6736
+ });
6737
+ };
6738
+ var ConditionalFormInfo$1 = ConditionalFormInfo;
6739
+
5630
6740
  // @kne/react-form 内置规则的错误提示写死中文;在 preset 覆盖前记下原函数,只替换未被业务覆盖的规则
5631
6741
  const BUILTIN_RULES = {
5632
6742
  TEL: reactFormAntd.RULES.TEL,
@@ -5708,11 +6818,11 @@ const buildIndexedLabelRender = index => {
5708
6818
  }, text) : null);
5709
6819
  };
5710
6820
  };
5711
- const renderFieldElements = (fields = [], preview = false, {
6821
+ const renderFieldEntries = (fields = [], preview = false, {
5712
6822
  namePrefix,
5713
6823
  locale,
5714
6824
  showIndex = false
5715
- } = {}) => fields.filter(field => !field.hidden).map((field, index) => {
6825
+ } = {}) => (fields || []).filter(field => !field.hidden).map((field, index) => {
5716
6826
  const Component = getFieldComponent(field.type, field);
5717
6827
  if (!Component) {
5718
6828
  return null;
@@ -5748,7 +6858,7 @@ const renderFieldElements = (fields = [], preview = false, {
5748
6858
  locale
5749
6859
  } : {};
5750
6860
  const label = buildFieldLabel(field);
5751
- return /*#__PURE__*/react.createElement(Component, {
6861
+ const element = /*#__PURE__*/react.createElement(Component, {
5752
6862
  key: field.id,
5753
6863
  name: fieldName,
5754
6864
  label: showIndex ? label || '\u200b' : label,
@@ -5762,7 +6872,29 @@ const renderFieldElements = (fields = [], preview = false, {
5762
6872
  labelTips: buildLabelTips(field.tips),
5763
6873
  description
5764
6874
  });
6875
+ return {
6876
+ element,
6877
+ path: fieldName,
6878
+ visibleWhen: hasVisibleWhen(field) ? field.visibleWhen : null
6879
+ };
5765
6880
  }).filter(Boolean);
6881
+ const renderFieldElements = (fields, preview, opts) => renderFieldEntries(fields, preview, opts).map(entry => entry.element);
6882
+
6883
+ /** 字段含 visibleWhen 时换成 ConditionalFormInfo,否则保持普通 FormInfo */
6884
+ const createFieldsFormInfo = (formInfoProps, entries, nested = [], knownNames) => {
6885
+ if (entries.some(entry => entry.visibleWhen)) {
6886
+ return /*#__PURE__*/react.createElement(ConditionalFormInfo$1, {
6887
+ ...formInfoProps,
6888
+ entries,
6889
+ nested,
6890
+ knownNames
6891
+ });
6892
+ }
6893
+ return /*#__PURE__*/react.createElement(FormInfo__default["default"], {
6894
+ ...formInfoProps,
6895
+ list: [...entries.map(entry => entry.element), ...nested]
6896
+ });
6897
+ };
5766
6898
  const withBlockLayout = (element, forceBlock) => {
5767
6899
  if (!element || !forceBlock) {
5768
6900
  return element;
@@ -5799,7 +6931,8 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5799
6931
  formatMessage,
5800
6932
  depth = 0,
5801
6933
  asListItem = false,
5802
- locale
6934
+ locale,
6935
+ knownNames
5803
6936
  } = ctx;
5804
6937
  if (!block || depth > MAX_BLOCK_DEPTH) {
5805
6938
  return null;
@@ -5829,41 +6962,39 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5829
6962
  case 'formInfo':
5830
6963
  {
5831
6964
  const showIndex = !!block.showIndex;
5832
- const fields = renderFieldElements(block.list, preview, {
6965
+ const entries = renderFieldEntries(block.list, preview, {
5833
6966
  ...fieldRenderOpts,
5834
6967
  showIndex
5835
6968
  });
5836
6969
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
5837
- return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo__default["default"], {
6970
+ return withBlockLayout(createFieldsFormInfo({
5838
6971
  key: block.id,
5839
6972
  title: block.title || undefined,
5840
6973
  subtitle: block.subtitle || undefined,
5841
6974
  column: block.column,
5842
6975
  gap: block.gap,
5843
6976
  bordered,
5844
- list: [...fields, ...nested],
5845
6977
  ...(listItemPartProps || {}),
5846
6978
  className: resolvePartRootClassName(depth, showIndex ? style['form-info-show-index'] : null)
5847
- }), asListItem);
6979
+ }, entries, nested, knownNames), asListItem);
5848
6980
  }
5849
6981
  case 'object':
5850
6982
  {
5851
- const fields = renderFieldElements(block.list, preview, {
6983
+ const entries = renderFieldEntries(block.list, preview, {
5852
6984
  ...fieldRenderOpts,
5853
6985
  namePrefix: block.name || ''
5854
6986
  });
5855
6987
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
5856
- return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo__default["default"], {
6988
+ return withBlockLayout(createFieldsFormInfo({
5857
6989
  key: block.id,
5858
6990
  title: block.title || undefined,
5859
6991
  subtitle: block.subtitle || undefined,
5860
6992
  column: block.column,
5861
6993
  gap: block.gap,
5862
6994
  bordered,
5863
- list: [...fields, ...nested],
5864
6995
  ...(listItemPartProps || {}),
5865
6996
  className: resolvePartRootClassName(depth)
5866
- }), asListItem);
6997
+ }, entries, nested, knownNames), asListItem);
5867
6998
  }
5868
6999
  case 'list':
5869
7000
  {
@@ -5958,10 +7089,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5958
7089
  prevIcon: /*#__PURE__*/react.createElement(icons.ArrowLeftOutlined),
5959
7090
  nextIcon: /*#__PURE__*/react.createElement(icons.ArrowRightOutlined),
5960
7091
  items: (block.items || []).map(step => {
5961
- const fields = renderFieldElements(step.list, preview, fieldRenderOpts);
7092
+ const entries = renderFieldEntries(step.list, preview, fieldRenderOpts);
5962
7093
  const nested = renderChildBlocks(step.blocks || [], nextCtx);
5963
7094
  const fieldNames = [...(step.list || []).filter(field => field && !field.hidden && field.name).map(field => field.name), ...collectBlockFieldNames(step.blocks || [])];
5964
- if (nested.length) {
7095
+ const hasConditional = entries.some(entry => entry.visibleWhen);
7096
+ if (nested.length || hasConditional) {
5965
7097
  return {
5966
7098
  key: step.id,
5967
7099
  title: step.title,
@@ -5970,12 +7102,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5970
7102
  fieldNames,
5971
7103
  children: /*#__PURE__*/react.createElement(react.Fragment, {
5972
7104
  key: `${step.id}-body`
5973
- }, fields.length ? /*#__PURE__*/react.createElement(FormInfo__default["default"], {
7105
+ }, entries.length ? createFieldsFormInfo({
5974
7106
  key: `${step.id}-fields`,
5975
7107
  column: step.column,
5976
- gap: block.gap,
5977
- list: fields
5978
- }) : null, ...nested)
7108
+ gap: block.gap
7109
+ }, entries, [], knownNames) : null, ...nested)
5979
7110
  };
5980
7111
  }
5981
7112
  return {
@@ -5983,7 +7114,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5983
7114
  title: step.title,
5984
7115
  column: step.column,
5985
7116
  gap: block.gap,
5986
- list: fields,
7117
+ list: entries.map(entry => entry.element),
5987
7118
  fieldNames
5988
7119
  };
5989
7120
  })
@@ -6000,12 +7131,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
6000
7131
  renderOptionContent: option => {
6001
7132
  const nodes = [];
6002
7133
  if ((option.list || []).length) {
6003
- nodes.push(/*#__PURE__*/react.createElement(FormInfo__default["default"], {
7134
+ nodes.push(createFieldsFormInfo({
6004
7135
  key: `${option.id}-fields`,
6005
7136
  column: block.column || 2,
6006
- gap: block.gap,
6007
- list: renderFieldElements(option.list, preview)
6008
- }));
7137
+ gap: block.gap
7138
+ }, renderFieldEntries(option.list, preview), [], knownNames));
6009
7139
  }
6010
7140
  nodes.push(...renderChildBlocks(option.blocks || [], nextCtx));
6011
7141
  return nodes.filter(Boolean);
@@ -6027,10 +7157,12 @@ const renderSchemaInner = (schema, {
6027
7157
  } = {}) => {
6028
7158
  const normalized = normalizeSchema(schema);
6029
7159
  const blocks = normalized.blocks || [];
7160
+ const knownNames = collectTriggerNames(normalized);
6030
7161
  const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
6031
7162
  isMobile,
6032
7163
  formatMessage,
6033
- locale
7164
+ locale,
7165
+ knownNames
6034
7166
  })).filter(Boolean);
6035
7167
  if (!contentChildren.length && !children && !actionNode) {
6036
7168
  return null;
@@ -6056,10 +7188,12 @@ const renderSchemaContent = (schema, {
6056
7188
  } = {}) => {
6057
7189
  const normalized = normalizeSchema(schema);
6058
7190
  const blocks = normalized.blocks || [];
7191
+ const knownNames = collectTriggerNames(normalized);
6059
7192
  const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
6060
7193
  isMobile,
6061
7194
  formatMessage,
6062
- locale
7195
+ locale,
7196
+ knownNames
6063
7197
  })).filter(Boolean);
6064
7198
  if (!contentChildren.length && !children) {
6065
7199
  return null;
@@ -6407,6 +7541,9 @@ const FormCreator = withLocale$1(({
6407
7541
  clearBlockEditor();
6408
7542
  };
6409
7543
  const handleDeleteBlock = blockId => {
7544
+ if (blockHasLockedField(findBlock(schema, blockId))) {
7545
+ return;
7546
+ }
6410
7547
  updateSchema(updateBlocks(schema, blocks => removeBlockInTree(blocks, blockId)));
6411
7548
  };
6412
7549
  const handleMoveBlock = (blockId, direction) => {
@@ -6443,13 +7580,13 @@ const FormCreator = withLocale$1(({
6443
7580
  const handleDeleteStep = (blockId, stepId) => {
6444
7581
  updateSchema(mapBlocks(schema, blockId, block => ({
6445
7582
  ...block,
6446
- items: (block.items || []).filter(item => item.id !== stepId)
7583
+ items: (block.items || []).filter(item => item.id !== stepId || blockHasLockedField(item))
6447
7584
  })));
6448
7585
  };
6449
7586
  const handleMoveStep = (blockId, stepId, direction) => {
6450
7587
  updateSchema(mapBlocks(schema, blockId, block => ({
6451
7588
  ...block,
6452
- items: moveItem(block.items || [], stepId, direction)
7589
+ items: moveItem(block.items || [], stepId, direction, blockHasLockedField)
6453
7590
  })));
6454
7591
  };
6455
7592
  const handleAddChoiceOption = blockId => {
@@ -6483,13 +7620,13 @@ const FormCreator = withLocale$1(({
6483
7620
  const handleDeleteChoiceOption = (blockId, optionId) => {
6484
7621
  updateSchema(mapBlocks(schema, blockId, block => ({
6485
7622
  ...block,
6486
- options: (block.options || []).filter(item => item.id !== optionId)
7623
+ options: (block.options || []).filter(item => item.id !== optionId || blockHasLockedField(item))
6487
7624
  })));
6488
7625
  };
6489
7626
  const handleMoveChoiceOption = (blockId, optionId, direction) => {
6490
7627
  updateSchema(mapBlocks(schema, blockId, block => ({
6491
7628
  ...block,
6492
- options: moveItem(block.options || [], optionId, direction)
7629
+ options: moveItem(block.options || [], optionId, direction, blockHasLockedField)
6493
7630
  })));
6494
7631
  };
6495
7632
  const normalizeFieldScope = scope => {
@@ -6509,6 +7646,9 @@ const FormCreator = withLocale$1(({
6509
7646
  setFieldEditorOpen(true);
6510
7647
  };
6511
7648
  const handleEditField = (blockId, field, scope) => {
7649
+ if (isFieldLocked(field)) {
7650
+ return;
7651
+ }
6512
7652
  setFieldContext({
6513
7653
  blockId,
6514
7654
  ...normalizeFieldScope(scope)
@@ -6522,7 +7662,7 @@ const FormCreator = withLocale$1(({
6522
7662
  stepId,
6523
7663
  optionId
6524
7664
  } = fieldContext || {};
6525
- updateSchema(mapBlocks(schema, blockId, block => {
7665
+ let nextSchema = mapBlocks(schema, blockId, block => {
6526
7666
  if (block.kind === 'steps') {
6527
7667
  return {
6528
7668
  ...block,
@@ -6558,7 +7698,21 @@ const FormCreator = withLocale$1(({
6558
7698
  ...block,
6559
7699
  list: exists ? block.list.map(item => item.id === field.id ? field : item) : [...(block.list || []), field]
6560
7700
  };
6561
- }));
7701
+ });
7702
+ if (editingField?.name && editingField.name !== field.name) {
7703
+ const scope = getBlockConditionScope(schema, blockId);
7704
+ nextSchema = renameConditionReferences(nextSchema, getFieldConditionPath(scope, editingField.name), getFieldConditionPath(scope, field.name));
7705
+ }
7706
+ const cycle = findConditionCycle(nextSchema);
7707
+ if (cycle) {
7708
+ antd.message.error(formatMessage({
7709
+ id: 'visibleWhenCycle'
7710
+ }, {
7711
+ path: cycle.join(' → ')
7712
+ }));
7713
+ return false;
7714
+ }
7715
+ updateSchema(nextSchema);
6562
7716
  setFieldEditorOpen(false);
6563
7717
  setFieldContext(null);
6564
7718
  setEditingField(null);
@@ -6574,7 +7728,7 @@ const FormCreator = withLocale$1(({
6574
7728
  ...block,
6575
7729
  items: (block.items || []).map(step => step.id === stepId ? {
6576
7730
  ...step,
6577
- list: (step.list || []).filter(item => item.id !== fieldId)
7731
+ list: (step.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6578
7732
  } : step)
6579
7733
  };
6580
7734
  }
@@ -6583,13 +7737,13 @@ const FormCreator = withLocale$1(({
6583
7737
  ...block,
6584
7738
  options: (block.options || []).map(option => option.id === optionId ? {
6585
7739
  ...option,
6586
- list: (option.list || []).filter(item => item.id !== fieldId)
7740
+ list: (option.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6587
7741
  } : option)
6588
7742
  };
6589
7743
  }
6590
7744
  return {
6591
7745
  ...block,
6592
- list: (block.list || []).filter(item => item.id !== fieldId)
7746
+ list: (block.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6593
7747
  };
6594
7748
  }));
6595
7749
  };
@@ -6628,6 +7782,11 @@ const FormCreator = withLocale$1(({
6628
7782
  stepId: fieldContext.stepId,
6629
7783
  optionId: fieldContext.optionId
6630
7784
  }) : [];
7785
+ const conditionProps = react.useMemo(() => fieldContext ? {
7786
+ schema,
7787
+ scope: getBlockConditionScope(schema, fieldContext.blockId),
7788
+ triggerFields: collectConditionFields(schema).filter(item => !item.inList)
7789
+ } : null, [schema, fieldContext]);
6631
7790
  const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
6632
7791
  schema
6633
7792
  }) : extraToolbar;
@@ -6703,6 +7862,7 @@ const FormCreator = withLocale$1(({
6703
7862
  open: fieldEditorOpen,
6704
7863
  field: editingField,
6705
7864
  fieldList: currentFieldScope,
7865
+ conditionProps: conditionProps,
6706
7866
  renderModal: renderModal,
6707
7867
  onCancel: () => {
6708
7868
  setFieldEditorOpen(false);
@@ -7036,7 +8196,7 @@ const formatDateToToday = (value, itemSchema, ctx) => {
7036
8196
  if (items[1] == null || items[1] === '' || items[1] === true) {
7037
8197
  const until = ctx.formatMessage?.({
7038
8198
  id: 'schemaContentUntilToday'
7039
- }) || defaultLocale.schemaContentUntilToday;
8199
+ }) || zhCN.schemaContentUntilToday;
7040
8200
  return [start, until].filter(Boolean).join(' ~ ');
7041
8201
  }
7042
8202
  const end = formatByValueSchema(items[1], itemSchema, ctx);
@@ -7091,11 +8251,11 @@ const formatBoolean = (value, field, ctx) => {
7091
8251
  if (value) {
7092
8252
  return props.checkedChildren || ctx.formatMessage?.({
7093
8253
  id: 'schemaContentYes'
7094
- }) || defaultLocale.schemaContentYes;
8254
+ }) || zhCN.schemaContentYes;
7095
8255
  }
7096
8256
  return props.unCheckedChildren || ctx.formatMessage?.({
7097
8257
  id: 'schemaContentNo'
7098
- }) || defaultLocale.schemaContentNo;
8258
+ }) || zhCN.schemaContentNo;
7099
8259
  };
7100
8260
  const stringifyFallback = value => {
7101
8261
  if (value == null) {
@@ -7314,8 +8474,41 @@ const resolveChoiceSelectorName$1 = block => {
7314
8474
  }
7315
8475
  return `__choice_${block.id}`;
7316
8476
  };
8477
+
8478
+ /** 条件说明文案:按 options.locale 取包内语言包,英文以外回退中文 */
8479
+ const createConditionContext = (normalized, locale) => {
8480
+ const messages = String(locale || '').startsWith('en') ? enUS : zhCN;
8481
+ const formatMessage = ({
8482
+ id
8483
+ }, values = {}) => String(messages[id] ?? id).replace(/\{(\w+)\}/g, (match, key) => values[key] != null ? values[key] : match);
8484
+ const conditionFields = collectConditionFields(normalized).filter(item => !item.inList);
8485
+ return {
8486
+ formatMessage,
8487
+ knownNames: new Set(conditionFields.map(item => item.path)),
8488
+ fieldLookup: new Map(conditionFields.map(item => [item.path, item.field]))
8489
+ };
8490
+ };
8491
+ const describeVisibleWhen = (field, ctx) => {
8492
+ const visibleWhen = {
8493
+ ...field.visibleWhen,
8494
+ conditions: field.visibleWhen.conditions.filter(condition => ctx.knownNames.has(condition?.field))
8495
+ };
8496
+ if (!visibleWhen.conditions.length) {
8497
+ return '';
8498
+ }
8499
+ const condition = formatVisibleWhen(visibleWhen, {
8500
+ formatMessage: ctx.formatMessage,
8501
+ fieldLookup: ctx.fieldLookup
8502
+ });
8503
+ return ctx.formatMessage({
8504
+ id: 'conditionDescription'
8505
+ }, {
8506
+ condition
8507
+ });
8508
+ };
7317
8509
  const mergeFieldIntoLayer = (layer, field, {
7318
- allowRequired = true
8510
+ allowRequired = true,
8511
+ ctx
7319
8512
  } = {}) => {
7320
8513
  if (!field?.name) {
7321
8514
  return;
@@ -7324,8 +8517,14 @@ const mergeFieldIntoLayer = (layer, field, {
7324
8517
  if (!name) {
7325
8518
  return;
7326
8519
  }
7327
- layer.properties[name] = resolveFieldValueSchema(field);
7328
- if (allowRequired && isReq(field.rule) && !layer.required.includes(name)) {
8520
+ const valueSchema = resolveFieldValueSchema(field);
8521
+ const conditionText = ctx?.formatMessage && hasVisibleWhen(field) ? describeVisibleWhen(field, ctx) : '';
8522
+ if (conditionText) {
8523
+ valueSchema.description = valueSchema.description ? `${valueSchema.description}\n${conditionText}` : conditionText;
8524
+ }
8525
+ layer.properties[name] = valueSchema;
8526
+ // 条件显示字段可能不出现在提交数据中,不进 required
8527
+ if (allowRequired && !conditionText && isReq(field.rule) && !layer.required.includes(name)) {
7329
8528
  layer.required.push(name);
7330
8529
  }
7331
8530
  };
@@ -7369,33 +8568,39 @@ const finalizeObjectSchema = (layer, {
7369
8568
  }
7370
8569
  return schema;
7371
8570
  };
7372
- const walkBlocks = (blocks, layer, depth = 0) => {
8571
+ const walkBlocks = (blocks, layer, depth = 0, ctx = {}) => {
7373
8572
  (blocks || []).forEach(block => {
7374
8573
  if (!block) {
7375
8574
  return;
7376
8575
  }
7377
- walkBlock(block, layer, depth);
8576
+ walkBlock(block, layer, depth, ctx);
7378
8577
  });
7379
8578
  };
7380
- const walkBlock = (block, layer, depth = 0) => {
8579
+ const walkBlock = (block, layer, depth = 0, ctx = {}) => {
7381
8580
  switch (block.kind) {
7382
8581
  case 'formInfo':
7383
8582
  {
7384
- mergeFieldsIntoLayer(layer, block.list);
7385
- walkBlocks(block.blocks, layer, depth + 1);
8583
+ mergeFieldsIntoLayer(layer, block.list, {
8584
+ ctx
8585
+ });
8586
+ walkBlocks(block.blocks, layer, depth + 1, ctx);
7386
8587
  return;
7387
8588
  }
7388
8589
  case 'object':
7389
8590
  {
7390
8591
  const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
7391
8592
  if (!name) {
7392
- mergeFieldsIntoLayer(layer, block.list);
7393
- walkBlocks(block.blocks, layer, depth + 1);
8593
+ mergeFieldsIntoLayer(layer, block.list, {
8594
+ ctx
8595
+ });
8596
+ walkBlocks(block.blocks, layer, depth + 1, ctx);
7394
8597
  return;
7395
8598
  }
7396
8599
  const nested = createObjectLayer();
7397
- mergeFieldsIntoLayer(nested, block.list);
7398
- walkBlocks(block.blocks, nested, depth + 1);
8600
+ mergeFieldsIntoLayer(nested, block.list, {
8601
+ ctx
8602
+ });
8603
+ walkBlocks(block.blocks, nested, depth + 1, ctx);
7399
8604
  layer.properties[name] = finalizeObjectSchema(nested, {
7400
8605
  title: block.title || undefined,
7401
8606
  description: block.subtitle || undefined
@@ -7458,14 +8663,16 @@ const walkBlock = (block, layer, depth = 0) => {
7458
8663
  case 'steps':
7459
8664
  {
7460
8665
  (block.items || []).forEach(step => {
7461
- mergeFieldsIntoLayer(layer, step?.list);
7462
- walkBlocks(step?.blocks, layer, depth + 1);
8666
+ mergeFieldsIntoLayer(layer, step?.list, {
8667
+ ctx
8668
+ });
8669
+ walkBlocks(step?.blocks, layer, depth + 1, ctx);
7463
8670
  });
7464
8671
  return;
7465
8672
  }
7466
8673
  case 'choice':
7467
8674
  {
7468
- mergeChoiceIntoLayer(layer, block, depth);
8675
+ mergeChoiceIntoLayer(layer, block, depth, ctx);
7469
8676
  return;
7470
8677
  }
7471
8678
  default:
@@ -7478,7 +8685,7 @@ const walkBlock = (block, layer, depth = 0) => {
7478
8685
  * 每支为 object:单选支含 selector const;多选支为该 option 字段,selector 数组放在当前层。
7479
8686
  * 支内 REQ 可进 required;hidden 字段仍进入 schema。
7480
8687
  */
7481
- const mergeChoiceIntoLayer = (layer, block, depth) => {
8688
+ const mergeChoiceIntoLayer = (layer, block, depth, ctx) => {
7482
8689
  const mode = block.mode === 'multiple' ? 'multiple' : 'single';
7483
8690
  const selectorInData = block.selectorInData !== false;
7484
8691
  const selectorName = resolveChoiceSelectorName$1(block);
@@ -7497,9 +8704,10 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
7497
8704
  branch.required.push(selectorName);
7498
8705
  }
7499
8706
  mergeFieldsIntoLayer(branch, option.list, {
7500
- allowRequired: true
8707
+ allowRequired: true,
8708
+ ctx
7501
8709
  });
7502
- walkBlocks(option.blocks, branch, depth + 1);
8710
+ walkBlocks(option.blocks, branch, depth + 1, ctx);
7503
8711
  return finalizeObjectSchema(branch, {
7504
8712
  title: optionTitle
7505
8713
  });
@@ -7581,7 +8789,7 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
7581
8789
  const schemaToDataSchema = (schema, options = {}) => {
7582
8790
  const normalized = normalizeSchema(localizeSchema(schema || {}, options.locale, options.languages));
7583
8791
  const layer = createObjectLayer();
7584
- walkBlocks(normalized.blocks, layer, 0);
8792
+ walkBlocks(normalized.blocks, layer, 0, createConditionContext(normalized, options.locale));
7585
8793
  const root = finalizeObjectSchema(layer, {
7586
8794
  title: normalized.title || undefined,
7587
8795
  description: options.description
@@ -7616,9 +8824,10 @@ const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValu
7616
8824
  * 改为 label 在上、值在下,避免窄栏(如弹窗双栏预览)被撑乱。
7617
8825
  */
7618
8826
  const renderFieldsContent = (fields, data, formatMessage, column, {
7619
- showIndex = false
8827
+ showIndex = false,
8828
+ isFieldVisible
7620
8829
  } = {}) => {
7621
- const list = (fields || []).filter(field => field && !field.hidden && field.name).map((field, index) => {
8830
+ const list = (fields || []).filter(field => field && !field.hidden && field.name && (!isFieldVisible || isFieldVisible(field))).map((field, index) => {
7622
8831
  const baseLabel = field.label || field.name;
7623
8832
  const label = showIndex ? `${index + 1}. ${baseLabel}` : baseLabel;
7624
8833
  return {
@@ -7653,7 +8862,8 @@ const renderBlock = (block, data, ctx) => {
7653
8862
  const {
7654
8863
  formatMessage,
7655
8864
  isMobile,
7656
- depth = 0
8865
+ depth = 0,
8866
+ isFieldVisible
7657
8867
  } = ctx;
7658
8868
  if (!block || depth > MAX_BLOCK_DEPTH) {
7659
8869
  return null;
@@ -7676,7 +8886,8 @@ const renderBlock = (block, data, ctx) => {
7676
8886
  return /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7677
8887
  ...partProps,
7678
8888
  children: [renderFieldsContent(block.list, data, formatMessage, block.column, {
7679
- showIndex: !!block.showIndex
8889
+ showIndex: !!block.showIndex,
8890
+ isFieldVisible
7680
8891
  }), renderBlockList(block.blocks, data, nextCtx)]
7681
8892
  });
7682
8893
  }
@@ -7686,7 +8897,9 @@ const renderBlock = (block, data, ctx) => {
7686
8897
  const nestedData = name ? getByPath(data, name) || {} : data;
7687
8898
  return /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7688
8899
  ...partProps,
7689
- children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column), renderBlockList(block.blocks, nestedData, nextCtx)]
8900
+ children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column, {
8901
+ isFieldVisible
8902
+ }), renderBlockList(block.blocks, nestedData, nextCtx)]
7690
8903
  });
7691
8904
  }
7692
8905
  case 'list':
@@ -7747,7 +8960,9 @@ const renderBlock = (block, data, ctx) => {
7747
8960
  children: (block.items || []).map(step => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7748
8961
  title: step.title || undefined,
7749
8962
  bordered: bordered,
7750
- children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2), renderBlockList(step.blocks, data, nextCtx)]
8963
+ children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2, {
8964
+ isFieldVisible
8965
+ }), renderBlockList(step.blocks, data, nextCtx)]
7751
8966
  }, step.id))
7752
8967
  }, block.id);
7753
8968
  }
@@ -7763,7 +8978,9 @@ const renderBlock = (block, data, ctx) => {
7763
8978
  children: visibleOptions.map(option => /*#__PURE__*/jsxRuntime.jsxs(InfoPage__default["default"].Part, {
7764
8979
  title: option.title || undefined,
7765
8980
  bordered: false,
7766
- children: [renderFieldsContent(option.list, data, formatMessage, block.column), renderBlockList(option.blocks, data, nextCtx)]
8981
+ children: [renderFieldsContent(option.list, data, formatMessage, block.column, {
8982
+ isFieldVisible
8983
+ }), renderBlockList(option.blocks, data, nextCtx)]
7767
8984
  }, option.id))
7768
8985
  });
7769
8986
  }
@@ -7783,10 +9000,15 @@ const SchemaContentInnerView = ({
7783
9000
  } = reactIntl.useIntl();
7784
9001
  const isMobile = responsiveUtils.useIsMobile();
7785
9002
  const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
7786
- const children = renderBlockList(normalized.blocks, data || {}, {
9003
+ const rootData = data || {};
9004
+ const knownNames = collectTriggerNames(normalized);
9005
+ // 条件按提交数据根路径判断(object 内字段同样用完整路径)
9006
+ const isFieldVisible = field => evaluateVisibleWhen(field.visibleWhen, rootData, knownNames);
9007
+ const children = renderBlockList(normalized.blocks, rootData, {
7787
9008
  formatMessage,
7788
9009
  isMobile,
7789
- depth: 0
9010
+ depth: 0,
9011
+ isFieldVisible
7790
9012
  });
7791
9013
  if (!children.length) {
7792
9014
  return null;
@@ -7833,6 +9055,7 @@ const SchemaContent = withLocale$1(({
7833
9055
  });
7834
9056
  var SchemaContent$1 = SchemaContent;
7835
9057
 
9058
+ exports.CONDITION_OPERATORS = CONDITION_OPERATORS;
7836
9059
  exports.FormCreator = FormCreator$1;
7837
9060
  exports.LocaleInput = LocaleInput;
7838
9061
  exports.LocaleTextArea = LocaleTextArea;
@@ -7846,9 +9069,11 @@ exports.SchemaContentInner = SchemaContentInner;
7846
9069
  exports.SchemaRenderer = SchemaRenderer$1;
7847
9070
  exports.SchemaRendererInner = SchemaRendererInner;
7848
9071
  exports.applyFromPropsSchema = applyFromPropsSchema;
9072
+ exports.blockHasLockedField = blockHasLockedField;
7849
9073
  exports.blockToFormValues = blockToFormValues;
7850
9074
  exports.buildRuleString = buildRuleString;
7851
9075
  exports.collectBlockFieldNames = collectBlockFieldNames;
9076
+ exports.collectConditionFields = collectConditionFields;
7852
9077
  exports.collectSchemaFields = collectSchemaFields;
7853
9078
  exports.createBlock = createBlock;
7854
9079
  exports.createChoiceOption = createChoiceOption;
@@ -7858,9 +9083,12 @@ exports.createStep = createStep;
7858
9083
  exports["default"] = FormCreator$1;
7859
9084
  exports.defaultFormActions = defaultFormActions;
7860
9085
  exports.defaultSchema = defaultSchema;
9086
+ exports.evaluateCondition = evaluateCondition;
9087
+ exports.evaluateVisibleWhen = evaluateVisibleWhen;
7861
9088
  exports.fieldToFormValues = fieldToFormValues;
7862
9089
  exports.findBlock = findBlock;
7863
9090
  exports.findBlockInTree = findBlockInTree;
9091
+ exports.findConditionCycle = findConditionCycle;
7864
9092
  exports.formValuesToBlock = formValuesToBlock;
7865
9093
  exports.formValuesToField = formValuesToField;
7866
9094
  exports.formatByValueSchema = formatByValueSchema;
@@ -7873,6 +9101,8 @@ exports.getFieldTypes = getFieldTypes;
7873
9101
  exports.getRulePresetItems = getRulePresetItems;
7874
9102
  exports.hasLocaleText = hasLocaleText;
7875
9103
  exports.hasRenderableContent = hasRenderableContent;
9104
+ exports.hasVisibleWhen = hasVisibleWhen;
9105
+ exports.isFieldLocked = isFieldLocked;
7876
9106
  exports.isFieldNameUnique = isFieldNameUnique;
7877
9107
  exports.isLocaleText = isLocaleText;
7878
9108
  exports.localizeSchema = localizeSchema;
@@ -7889,6 +9119,7 @@ exports.pickFromPropsSchema = pickFromPropsSchema;
7889
9119
  exports.preset = preset;
7890
9120
  exports.registerField = registerField;
7891
9121
  exports.removeBlockInTree = removeBlockInTree;
9122
+ exports.renameConditionReferences = renameConditionReferences;
7892
9123
  exports.resolveFieldTypeLabel = resolveFieldTypeLabel;
7893
9124
  exports.resolveFieldValueSchema = resolveFieldValueSchema;
7894
9125
  exports.resolveLocaleText = resolveLocaleText;