@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.
@@ -1,23 +1,23 @@
1
1
  import '@kne/form-info/dist/index.css';
2
2
  import '@kne/info-page/dist/index.css';
3
3
  import '@kne/button-group/dist/index.css';
4
- import { createContext, useContext, useState, useRef, useMemo, useEffect, useCallback, createElement, Fragment } from 'react';
5
- import { Input as Input$1, Space, Tag, Button, Typography, Flex, Dropdown, Empty, message, Checkbox as Checkbox$1, InputNumber as InputNumber$1, Card, Tooltip } from 'antd';
4
+ import { createContext, useContext, useState, useRef, useMemo, createElement, useEffect, useCallback, Fragment as Fragment$1 } from 'react';
5
+ import { Input as Input$1, Space, Tag, Tooltip, Button, Typography, Flex, Dropdown, Empty, message, Checkbox as Checkbox$1, InputNumber as InputNumber$1, Card, Switch as Switch$1, Radio, Select as Select$1 } from 'antd';
6
6
  import { createWithIntlProvider, useIntl } from '@kne/react-intl';
7
7
  import { useIsMobile, RESPONSIVE_BOUNDARY_CLASS } from '@kne/responsive-utils';
8
- import { ArrowUpOutlined, ArrowDownOutlined, EditOutlined, DeleteOutlined, PlusOutlined, SettingOutlined, FormOutlined, UnorderedListOutlined, TableOutlined, ProfileOutlined, ClusterOutlined, PartitionOutlined, AppstoreOutlined, OrderedListOutlined, SelectOutlined, ApartmentOutlined, ArrowLeftOutlined, ArrowRightOutlined, QuestionCircleOutlined } from '@ant-design/icons';
8
+ import { FormOutlined, FontSizeOutlined, AlignLeftOutlined, NumberOutlined, DownSquareOutlined, CheckCircleOutlined, CheckSquareOutlined, AppstoreOutlined, ApartmentOutlined, ShopOutlined, EnvironmentOutlined, SwapOutlined, CalendarOutlined, LockOutlined, EyeInvisibleOutlined, BranchesOutlined, WarningOutlined, ColumnWidthOutlined, ArrowUpOutlined, ArrowDownOutlined, EditOutlined, DeleteOutlined, PlusOutlined, SettingOutlined, UnorderedListOutlined, TableOutlined, ProfileOutlined, ClusterOutlined, PartitionOutlined, OrderedListOutlined, SelectOutlined, ArrowLeftOutlined, ArrowRightOutlined, QuestionCircleOutlined } from '@ant-design/icons';
9
9
  import { hooks, Input, TextArea, InputNumber, Select, RadioGroup, CheckboxGroup, Switch, Checkbox, DatePicker, useFormContext, Slider, RULES, SubmitButton, ResetButton, CancelButton, preset as preset$1 } from '@kne/react-form-antd';
10
10
  import SelectList, { SelectTableList, SelectTree, SelectCascader } from '@kne/super-select';
11
11
  import { SelectFunction, SelectIndustry, SelectAddress } from '@kne/super-select-plus';
12
12
  import '@kne/super-select/dist/index.css';
13
13
  import '@kne/super-select-plus/dist/index.css';
14
- import { jsx, jsxs } from 'react/jsx-runtime';
14
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
15
15
  import FormInfo, { FormModal, Form, Steps, MultiField, EditableList, TableList, List } from '@kne/form-info';
16
16
  import { ButtonFooter } from '@kne/button-group';
17
17
  import InfoPage from '@kne/info-page';
18
18
  import { createWithRemoteLoader } from '@kne/remote-loader';
19
19
 
20
- 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"};
20
+ 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"};
21
21
 
22
22
  function _extends() {
23
23
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -173,6 +173,8 @@ const locale$1 = {
173
173
  fieldBlock: '占满整行',
174
174
  fieldHidden: '隐藏该项',
175
175
  fieldHiddenTag: '已隐藏',
176
+ fieldLockedTag: '固定',
177
+ fieldLockedTips: '固定填写项,不可编辑、删除或移动',
176
178
  fieldBlockTag: '整行',
177
179
  fieldNameDuplicate: '该名称已被使用,请换一个',
178
180
  untitledField: '未命名填写项',
@@ -200,6 +202,9 @@ const locale$1 = {
200
202
  formActionsGapHint: '默认 16',
201
203
  formActionsLayoutSection: '布局',
202
204
  fieldBasicSection: '基本设置',
205
+ optionLabelColumn: '选项名称',
206
+ optionValueColumn: '选项值',
207
+ optionDescColumn: '选项描述',
203
208
  optionLabelPlaceholder: '显示文字',
204
209
  optionValuePlaceholder: '对应值',
205
210
  optionDescPlaceholder: '补充说明(可选)',
@@ -284,9 +289,51 @@ const locale$1 = {
284
289
  ruleErrorLenEqual: '%s长度必须等于{end}',
285
290
  ruleErrorLenMin: '%s长度必须大于{start}',
286
291
  ruleErrorLenMax: '%s长度必须小于{end}',
287
- localeTextFallback: '留空时使用{language}'
288
- };
289
- var defaultLocale = locale$1;
292
+ localeTextFallback: '留空时使用{language}',
293
+ visibleWhenTitle: '条件显示',
294
+ visibleWhenEnable: '满足条件时才显示',
295
+ visibleWhenEnableTips: '不满足条件时隐藏该填写项,并清空其已填写的值',
296
+ visibleWhenLogic: '满足方式',
297
+ conditionLogic_and: '全部满足',
298
+ conditionLogic_or: '满足任一',
299
+ visibleWhenAddCondition: '添加条件',
300
+ visibleWhenField: '触发填写项',
301
+ visibleWhenOperator: '判断',
302
+ visibleWhenValue: '值',
303
+ visibleWhenNoTrigger: '暂无可作为条件的填写项(列表类模块中的填写项不支持)',
304
+ visibleWhenListUnsupported: '列表类模块中的填写项不支持条件显示',
305
+ visibleWhenRegexInvalid: '正则表达式无效',
306
+ visibleWhenRegexFlags: '修饰符',
307
+ visibleWhenRegexFlag_i: 'i 忽略大小写',
308
+ visibleWhenRegexFlag_m: 'm 多行',
309
+ visibleWhenRegexFlag_s: 's 点号匹配换行',
310
+ visibleWhenRegexFlag_u: 'u Unicode',
311
+ visibleWhenRegexTester: '测试文本',
312
+ visibleWhenRegexMatched: '匹配',
313
+ visibleWhenRegexNotMatched: '不匹配',
314
+ visibleWhenConditionRequired: '请完善条件:选择触发填写项并填写值',
315
+ visibleWhenCycle: '条件形成循环依赖:{path}',
316
+ fieldConditionTag: '条件显示',
317
+ fieldConditionInvalidTag: '条件失效',
318
+ fieldConditionInvalidTips: '条件引用的填写项已不存在或不可用,该条件被忽略',
319
+ conditionOperator_eq: '等于',
320
+ conditionOperator_neq: '不等于',
321
+ conditionOperator_in: '属于其一',
322
+ conditionOperator_includesAny: '包含任一',
323
+ conditionOperator_empty: '为空',
324
+ conditionOperator_notEmpty: '不为空',
325
+ conditionOperator_gt: '大于',
326
+ conditionOperator_gte: '大于等于',
327
+ conditionOperator_lt: '小于',
328
+ conditionOperator_lte: '小于等于',
329
+ conditionOperator_regex: '匹配正则',
330
+ conditionJoinAnd: ' 且 ',
331
+ conditionJoinOr: ' 或 ',
332
+ conditionValueTrue: '是',
333
+ conditionValueFalse: '否',
334
+ conditionDescription: '满足条件时显示:{condition}'
335
+ };
336
+ var zhCN = locale$1;
290
337
 
291
338
  const locale = {
292
339
  addField: 'Add Field',
@@ -423,6 +470,8 @@ const locale = {
423
470
  fieldBlock: 'Full Width',
424
471
  fieldHidden: 'Hidden',
425
472
  fieldHiddenTag: 'Hidden',
473
+ fieldLockedTag: 'Locked',
474
+ fieldLockedTips: 'Locked field: cannot be edited, deleted or moved',
426
475
  fieldBlockTag: 'Full Width',
427
476
  fieldNameDuplicate: 'This name is already in use, please choose another',
428
477
  untitledField: 'Untitled Field',
@@ -450,6 +499,9 @@ const locale = {
450
499
  formActionsGapHint: 'Default: 16',
451
500
  formActionsLayoutSection: 'Layout',
452
501
  fieldBasicSection: 'Basic Settings',
502
+ optionLabelColumn: 'Option Label',
503
+ optionValueColumn: 'Option Value',
504
+ optionDescColumn: 'Option Description',
453
505
  optionLabelPlaceholder: 'Display text',
454
506
  optionValuePlaceholder: 'Value',
455
507
  optionDescPlaceholder: 'Description (optional)',
@@ -534,14 +586,56 @@ const locale = {
534
586
  ruleErrorLenEqual: '%s must be exactly {end} characters',
535
587
  ruleErrorLenMin: '%s must be at least {start} characters',
536
588
  ruleErrorLenMax: '%s must be at most {end} characters',
537
- localeTextFallback: 'Falls back to {language} when empty'
589
+ localeTextFallback: 'Falls back to {language} when empty',
590
+ visibleWhenTitle: 'Conditional display',
591
+ visibleWhenEnable: 'Show only when conditions are met',
592
+ visibleWhenEnableTips: 'The field is hidden and its value cleared when conditions are not met',
593
+ visibleWhenLogic: 'Match',
594
+ conditionLogic_and: 'All conditions',
595
+ conditionLogic_or: 'Any condition',
596
+ visibleWhenAddCondition: 'Add condition',
597
+ visibleWhenField: 'Trigger field',
598
+ visibleWhenOperator: 'Operator',
599
+ visibleWhenValue: 'Value',
600
+ visibleWhenNoTrigger: 'No field can be used as a condition (fields inside list blocks are not supported)',
601
+ visibleWhenListUnsupported: 'Fields inside list blocks do not support conditional display',
602
+ visibleWhenRegexInvalid: 'Invalid regular expression',
603
+ visibleWhenRegexFlags: 'Flags',
604
+ visibleWhenRegexFlag_i: 'i ignore case',
605
+ visibleWhenRegexFlag_m: 'm multiline',
606
+ visibleWhenRegexFlag_s: 's dot matches newline',
607
+ visibleWhenRegexFlag_u: 'u Unicode',
608
+ visibleWhenRegexTester: 'Test text',
609
+ visibleWhenRegexMatched: 'Matched',
610
+ visibleWhenRegexNotMatched: 'Not matched',
611
+ visibleWhenConditionRequired: 'Complete each condition: choose a trigger field and fill in the value',
612
+ visibleWhenCycle: 'Conditions form a circular dependency: {path}',
613
+ fieldConditionTag: 'Conditional',
614
+ fieldConditionInvalidTag: 'Condition invalid',
615
+ fieldConditionInvalidTips: 'A referenced field no longer exists or is unavailable; that condition is ignored',
616
+ conditionOperator_eq: 'equals',
617
+ conditionOperator_neq: 'does not equal',
618
+ conditionOperator_in: 'is one of',
619
+ conditionOperator_includesAny: 'includes any of',
620
+ conditionOperator_empty: 'is empty',
621
+ conditionOperator_notEmpty: 'is not empty',
622
+ conditionOperator_gt: '>',
623
+ conditionOperator_gte: '>=',
624
+ conditionOperator_lt: '<',
625
+ conditionOperator_lte: '<=',
626
+ conditionOperator_regex: 'matches',
627
+ conditionJoinAnd: ' and ',
628
+ conditionJoinOr: ' or ',
629
+ conditionValueTrue: 'Yes',
630
+ conditionValueFalse: 'No',
631
+ conditionDescription: 'Shown when: {condition}'
538
632
  };
539
633
  var enUS = locale;
540
634
 
541
635
  const withLocale = createWithIntlProvider({
542
636
  defaultLocale: 'zh-CN',
543
637
  messages: {
544
- 'zh-CN': defaultLocale,
638
+ 'zh-CN': zhCN,
545
639
  'en-US': enUS
546
640
  },
547
641
  namespace: 'form-creator'
@@ -964,7 +1058,23 @@ const normalizeSchema = (schema = {}) => {
964
1058
  blocks: []
965
1059
  });
966
1060
  };
967
- const moveItem = (list, id, direction) => {
1061
+ const isFieldLocked = field => !!(field != null && field.locked);
1062
+ const blockHasLockedField = block => {
1063
+ if (!block) {
1064
+ return false;
1065
+ }
1066
+ if ((block.list || []).some(isFieldLocked)) {
1067
+ return true;
1068
+ }
1069
+ const groups = [...(block.items || []), ...(block.options || [])];
1070
+ if (groups.some(group => (group.list || []).some(isFieldLocked) || (group.blocks || []).some(blockHasLockedField))) {
1071
+ return true;
1072
+ }
1073
+ return [...(block.blocks || []), ...(block.itemBlocks || [])].some(blockHasLockedField);
1074
+ };
1075
+
1076
+ // 锁定项(locked 字段 / 含锁定字段的模块)位置固定:自身不能移动,其他项也不能与其交换位置
1077
+ const moveItem = (list, id, direction, isFixed = isFieldLocked) => {
968
1078
  const index = list.findIndex(item => item.id === id);
969
1079
  if (index < 0) {
970
1080
  return list;
@@ -973,6 +1083,9 @@ const moveItem = (list, id, direction) => {
973
1083
  if (targetIndex < 0 || targetIndex >= list.length) {
974
1084
  return list;
975
1085
  }
1086
+ if (isFixed(list[index]) || isFixed(list[targetIndex])) {
1087
+ return list;
1088
+ }
976
1089
  const next = [...list];
977
1090
  const [item] = next.splice(index, 1);
978
1091
  next.splice(targetIndex, 0, item);
@@ -1277,7 +1390,7 @@ const removeBlockInTree = (blocks, blockId) => {
1277
1390
  };
1278
1391
  const moveBlockInTree = (blocks, blockId, direction) => {
1279
1392
  if ((blocks || []).some(block => (block == null ? void 0 : block.id) === blockId)) {
1280
- return moveItem(blocks, blockId, direction);
1393
+ return moveItem(blocks, blockId, direction, blockHasLockedField);
1281
1394
  }
1282
1395
  let changed = false;
1283
1396
  const next = (blocks || []).map(block => {
@@ -1458,7 +1571,7 @@ const formValuesToChoiceOption = (values, existingOption = {}) => _extends({}, e
1458
1571
  title: values.title
1459
1572
  });
1460
1573
 
1461
- const _excluded$4 = ["children"];
1574
+ const _excluded$5 = ["children"];
1462
1575
  const mapOptionItem = item => {
1463
1576
  if (!item || typeof item !== 'object') {
1464
1577
  return item;
@@ -1466,7 +1579,7 @@ const mapOptionItem = item => {
1466
1579
  const {
1467
1580
  children
1468
1581
  } = item,
1469
- rest = _objectWithoutPropertiesLoose(item, _excluded$4);
1582
+ rest = _objectWithoutPropertiesLoose(item, _excluded$5);
1470
1583
  const next = _extends({}, rest);
1471
1584
  if (Array.isArray(children) && children.length) {
1472
1585
  next.children = children.map(mapOptionItem);
@@ -1554,7 +1667,7 @@ const createApiFromOptions = (options = []) => ({
1554
1667
  })
1555
1668
  });
1556
1669
 
1557
- const _excluded$3 = ["options", "api", "placeholder"];
1670
+ const _excluded$4 = ["options", "api", "placeholder"];
1558
1671
  const {
1559
1672
  useOnChange: useOnChange$2
1560
1673
  } = hooks;
@@ -1573,7 +1686,7 @@ const createField = (Component, {
1573
1686
  api,
1574
1687
  placeholder
1575
1688
  } = props,
1576
- rest = _objectWithoutPropertiesLoose(props, _excluded$3);
1689
+ rest = _objectWithoutPropertiesLoose(props, _excluded$4);
1577
1690
  const valueKey = rest.valueKey || 'value';
1578
1691
  const labelKey = rest.labelKey || 'label';
1579
1692
  const parentKey = rest.parentKey || 'parentId';
@@ -1696,6 +1809,439 @@ const buildRuleString = ({
1696
1809
  return parts.join(' ') || undefined;
1697
1810
  };
1698
1811
 
1812
+ const CONDITION_OPERATORS = ['eq', 'neq', 'in', 'includesAny', 'empty', 'notEmpty', 'gt', 'gte', 'lt', 'lte', 'regex'];
1813
+ const NO_VALUE_OPERATORS = ['empty', 'notEmpty'];
1814
+ const ALLOWED_REGEX_FLAGS = ['i', 'm', 's', 'u'];
1815
+
1816
+ // 列表类模块内的字段会重复出现,单个 name 定位不到具体条目,不参与条件
1817
+ const LIST_BLOCK_KINDS = ['list', 'tableList', 'editableList', 'multiField'];
1818
+ const getByPath$2 = (data, path) => {
1819
+ if (data == null || path == null || path === '') {
1820
+ return undefined;
1821
+ }
1822
+ return String(path).split('.').reduce((current, key) => current == null ? undefined : current[key], data);
1823
+ };
1824
+ const isEmptyValue$1 = value => value === undefined || value === null || value === '' || Array.isArray(value) && value.length === 0;
1825
+
1826
+ // SuperSelect 等字段的值是 { label, value } 对象,比较时统一取 value
1827
+ const toComparable = item => {
1828
+ if (item && typeof item === 'object' && !Array.isArray(item)) {
1829
+ var _ref, _ref2, _item$value;
1830
+ return (_ref = (_ref2 = (_item$value = item.value) != null ? _item$value : item.id) != null ? _ref2 : item.key) != null ? _ref : item;
1831
+ }
1832
+ return item;
1833
+ };
1834
+ const toArray = value => Array.isArray(value) ? value : isEmptyValue$1(value) ? [] : [value];
1835
+ const sameValue = (a, b) => String(toComparable(a)) === String(toComparable(b));
1836
+ const sanitizeRegexFlags = flags => Array.from(new Set(String(flags || '').split(''))).filter(flag => ALLOWED_REGEX_FLAGS.includes(flag)).join('');
1837
+ const regexCache = new Map();
1838
+
1839
+ /** 编译失败返回 null;以「源码 + flags」缓存 */
1840
+ const compileConditionRegex = (source, flags) => {
1841
+ if (source == null || String(source) === '') {
1842
+ return null;
1843
+ }
1844
+ const safeFlags = sanitizeRegexFlags(flags);
1845
+ const key = `${safeFlags}/${source}`;
1846
+ if (regexCache.has(key)) {
1847
+ return regexCache.get(key);
1848
+ }
1849
+ let regex = null;
1850
+ try {
1851
+ regex = new RegExp(String(source), safeFlags);
1852
+ } catch (error) {
1853
+ regex = null;
1854
+ }
1855
+ regexCache.set(key, regex);
1856
+ return regex;
1857
+ };
1858
+ const toNumber = value => {
1859
+ if (isEmptyValue$1(value) || typeof value === 'boolean') {
1860
+ return NaN;
1861
+ }
1862
+ return Number(value);
1863
+ };
1864
+
1865
+ /**
1866
+ * 返回 true / false;条件本身无效(未知运算符、正则无法编译)时返回 null,由调用方忽略
1867
+ */
1868
+ const evaluateCondition = (condition, formData) => {
1869
+ if (!(condition != null && condition.field) || !CONDITION_OPERATORS.includes(condition.operator)) {
1870
+ return null;
1871
+ }
1872
+ const actual = getByPath$2(formData, condition.field);
1873
+ const expected = condition.value;
1874
+ switch (condition.operator) {
1875
+ case 'empty':
1876
+ return isEmptyValue$1(actual);
1877
+ case 'notEmpty':
1878
+ return !isEmptyValue$1(actual);
1879
+ case 'eq':
1880
+ return !isEmptyValue$1(actual) && !Array.isArray(actual) && sameValue(actual, expected);
1881
+ case 'neq':
1882
+ return isEmptyValue$1(actual) || Array.isArray(actual) || !sameValue(actual, expected);
1883
+ case 'in':
1884
+ return !isEmptyValue$1(actual) && toArray(expected).some(item => sameValue(actual, item));
1885
+ case 'includesAny':
1886
+ {
1887
+ const expectedList = toArray(expected);
1888
+ return toArray(actual).some(item => expectedList.some(target => sameValue(item, target)));
1889
+ }
1890
+ case 'gt':
1891
+ case 'gte':
1892
+ case 'lt':
1893
+ case 'lte':
1894
+ {
1895
+ const a = toNumber(actual);
1896
+ const b = toNumber(expected);
1897
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
1898
+ return false;
1899
+ }
1900
+ return {
1901
+ gt: a > b,
1902
+ gte: a >= b,
1903
+ lt: a < b,
1904
+ lte: a <= b
1905
+ }[condition.operator];
1906
+ }
1907
+ case 'regex':
1908
+ {
1909
+ const regex = compileConditionRegex(expected, condition.flags);
1910
+ if (!regex) {
1911
+ return null;
1912
+ }
1913
+ if (isEmptyValue$1(actual)) {
1914
+ return false;
1915
+ }
1916
+ return toArray(actual).some(item => regex.test(String(toComparable(item))));
1917
+ }
1918
+ default:
1919
+ return null;
1920
+ }
1921
+ };
1922
+ const hasVisibleWhen = field => {
1923
+ var _field$visibleWhen;
1924
+ return Array.isArray(field == null || (_field$visibleWhen = field.visibleWhen) == null ? void 0 : _field$visibleWhen.conditions) && field.visibleWhen.conditions.length > 0;
1925
+ };
1926
+
1927
+ /**
1928
+ * knownNames:可作为触发字段的完整路径集合;传入时引用未知字段的条件视为失效
1929
+ * 全部条件失效时返回 true(照常显示)
1930
+ */
1931
+ const evaluateVisibleWhen = (visibleWhen, formData, knownNames) => {
1932
+ const conditions = visibleWhen == null ? void 0 : visibleWhen.conditions;
1933
+ if (!Array.isArray(conditions) || !conditions.length) {
1934
+ return true;
1935
+ }
1936
+ const results = conditions.map(condition => {
1937
+ if (knownNames && !knownNames.has(condition == null ? void 0 : condition.field)) {
1938
+ return null;
1939
+ }
1940
+ return evaluateCondition(condition, formData || {});
1941
+ }).filter(result => result !== null);
1942
+ if (!results.length) {
1943
+ return true;
1944
+ }
1945
+ return visibleWhen.logic === 'or' ? results.some(Boolean) : results.every(Boolean);
1946
+ };
1947
+ const joinPath = (prefix, name) => prefix ? `${prefix}.${name}` : name;
1948
+
1949
+ /**
1950
+ * 收集 schema 中所有字段:{ id, path, field, inList }
1951
+ * path 为提交数据中的完整路径(object 模块带前缀);inList 表示位于列表类模块内
1952
+ */
1953
+ const collectConditionFields = schema => {
1954
+ const result = [];
1955
+ const pushFields = (list, prefix, inList) => {
1956
+ (list || []).forEach(field => {
1957
+ if (field != null && field.name) {
1958
+ result.push({
1959
+ id: field.id,
1960
+ path: joinPath(prefix, field.name),
1961
+ field,
1962
+ inList
1963
+ });
1964
+ }
1965
+ });
1966
+ };
1967
+ // 与 renderSchema 一致:仅 object 模块自身字段带 block.name 前缀,子模块不累加
1968
+ const walk = (blocks, inList) => {
1969
+ (blocks || []).forEach(block => {
1970
+ if (!block) {
1971
+ return;
1972
+ }
1973
+ const blockInList = inList || LIST_BLOCK_KINDS.includes(block.kind);
1974
+ pushFields(block.list, block.kind === 'object' ? block.name || '' : '', blockInList);
1975
+ (block.items || []).forEach(step => {
1976
+ pushFields(step.list, '', blockInList);
1977
+ walk(step.blocks, blockInList);
1978
+ });
1979
+ (block.options || []).forEach(option => {
1980
+ pushFields(option.list, '', blockInList);
1981
+ walk(option.blocks, blockInList);
1982
+ });
1983
+ walk(block.blocks, blockInList);
1984
+ walk(block.itemBlocks, true);
1985
+ });
1986
+ };
1987
+ walk(schema == null ? void 0 : schema.blocks, false);
1988
+ return result;
1989
+ };
1990
+
1991
+ /** 字段所在模块的路径前缀与是否位于列表类模块内;找不到返回 null */
1992
+ const getBlockConditionScope = (schema, blockId) => {
1993
+ let found = null;
1994
+ const walk = (blocks, inList) => {
1995
+ (blocks || []).forEach(block => {
1996
+ if (!block || found) {
1997
+ return;
1998
+ }
1999
+ const blockInList = inList || LIST_BLOCK_KINDS.includes(block.kind);
2000
+ if (block.id === blockId) {
2001
+ found = {
2002
+ prefix: block.kind === 'object' ? block.name || '' : '',
2003
+ inList: blockInList
2004
+ };
2005
+ return;
2006
+ }
2007
+ (block.items || []).forEach(step => walk(step.blocks, blockInList));
2008
+ (block.options || []).forEach(option => walk(option.blocks, blockInList));
2009
+ walk(block.blocks, blockInList);
2010
+ walk(block.itemBlocks, true);
2011
+ });
2012
+ };
2013
+ walk(schema == null ? void 0 : schema.blocks, false);
2014
+ return found;
2015
+ };
2016
+ const getFieldConditionPath = (scope, name) => name ? joinPath((scope == null ? void 0 : scope.prefix) || '', name) : '';
2017
+
2018
+ /** 可作为触发字段的路径集合(排除列表类模块内字段) */
2019
+ const collectTriggerNames = schema => new Set(collectConditionFields(schema).filter(item => !item.inList).map(item => item.path));
2020
+
2021
+ /** 某字段的条件里引用了不存在 / 不可用的触发字段 */
2022
+ const hasInvalidCondition = (field, triggerNames) => hasVisibleWhen(field) && field.visibleWhen.conditions.some(condition => !triggerNames.has(condition == null ? void 0 : condition.field) || condition.operator === 'regex' && !compileConditionRegex(condition.value, condition.flags));
2023
+ const buildDependencyGraph = schema => {
2024
+ const graph = new Map();
2025
+ collectConditionFields(schema).forEach(({
2026
+ path,
2027
+ field
2028
+ }) => {
2029
+ if (hasVisibleWhen(field)) {
2030
+ graph.set(path, field.visibleWhen.conditions.map(condition => condition == null ? void 0 : condition.field).filter(Boolean));
2031
+ }
2032
+ });
2033
+ return graph;
2034
+ };
2035
+
2036
+ /** 返回循环链路(路径数组,首尾相同);无循环返回 null */
2037
+ const findConditionCycle = schema => {
2038
+ const graph = buildDependencyGraph(schema);
2039
+ const state = new Map();
2040
+ const stack = [];
2041
+ const visit = node => {
2042
+ if (state.get(node) === 'done') {
2043
+ return null;
2044
+ }
2045
+ if (state.get(node) === 'visiting') {
2046
+ return [...stack.slice(stack.indexOf(node)), node];
2047
+ }
2048
+ state.set(node, 'visiting');
2049
+ stack.push(node);
2050
+ for (const next of graph.get(node) || []) {
2051
+ const cycle = visit(next);
2052
+ if (cycle) {
2053
+ return cycle;
2054
+ }
2055
+ }
2056
+ stack.pop();
2057
+ state.set(node, 'done');
2058
+ return null;
2059
+ };
2060
+ for (const node of graph.keys()) {
2061
+ const cycle = visit(node);
2062
+ if (cycle) {
2063
+ return cycle;
2064
+ }
2065
+ }
2066
+ return null;
2067
+ };
2068
+
2069
+ /** 选中 candidate 作为 fieldPath 的触发字段是否会形成循环 */
2070
+ const wouldCreateCycle = (schema, fieldPath, candidatePath) => {
2071
+ if (fieldPath === candidatePath) {
2072
+ return true;
2073
+ }
2074
+ const graph = buildDependencyGraph(schema);
2075
+ const seen = new Set();
2076
+ const queue = [candidatePath];
2077
+ while (queue.length) {
2078
+ const node = queue.shift();
2079
+ if (node === fieldPath) {
2080
+ return true;
2081
+ }
2082
+ if (seen.has(node)) {
2083
+ continue;
2084
+ }
2085
+ seen.add(node);
2086
+ (graph.get(node) || []).forEach(next => queue.push(next));
2087
+ }
2088
+ return false;
2089
+ };
2090
+ const mapFieldList = (list, mapper) => Array.isArray(list) ? list.map(mapper) : list;
2091
+ const mapBlockFields = (block, mapper) => {
2092
+ if (!block) {
2093
+ return block;
2094
+ }
2095
+ const next = _extends({}, block, {
2096
+ list: mapFieldList(block.list, mapper)
2097
+ });
2098
+ if (Array.isArray(block.items)) {
2099
+ next.items = block.items.map(step => _extends({}, step, {
2100
+ list: mapFieldList(step.list, mapper),
2101
+ blocks: mapBlocksFields(step.blocks, mapper)
2102
+ }));
2103
+ }
2104
+ if (Array.isArray(block.options)) {
2105
+ next.options = block.options.map(option => _extends({}, option, {
2106
+ list: mapFieldList(option.list, mapper),
2107
+ blocks: mapBlocksFields(option.blocks, mapper)
2108
+ }));
2109
+ }
2110
+ if (Array.isArray(block.blocks)) {
2111
+ next.blocks = mapBlocksFields(block.blocks, mapper);
2112
+ }
2113
+ if (Array.isArray(block.itemBlocks)) {
2114
+ next.itemBlocks = mapBlocksFields(block.itemBlocks, mapper);
2115
+ }
2116
+ return next;
2117
+ };
2118
+ const mapBlocksFields = (blocks, mapper) => Array.isArray(blocks) ? blocks.map(block => mapBlockFields(block, mapper)) : blocks;
2119
+
2120
+ /** 触发字段改名后,同步所有条件中的引用 */
2121
+ const renameConditionReferences = (schema, oldPath, newPath) => {
2122
+ if (!oldPath || !newPath || oldPath === newPath) {
2123
+ return schema;
2124
+ }
2125
+ return _extends({}, schema, {
2126
+ blocks: mapBlocksFields(schema == null ? void 0 : schema.blocks, field => {
2127
+ if (!hasVisibleWhen(field) || !field.visibleWhen.conditions.some(condition => (condition == null ? void 0 : condition.field) === oldPath)) {
2128
+ return field;
2129
+ }
2130
+ return _extends({}, field, {
2131
+ visibleWhen: _extends({}, field.visibleWhen, {
2132
+ conditions: field.visibleWhen.conditions.map(condition => (condition == null ? void 0 : condition.field) === oldPath ? _extends({}, condition, {
2133
+ field: newPath
2134
+ }) : condition)
2135
+ })
2136
+ });
2137
+ })
2138
+ });
2139
+ };
2140
+
2141
+ /**
2142
+ * 触发字段的值类型,决定可用运算符与值输入方式:
2143
+ * options(单值选项)/ multiOptions(多值选项)/ number / boolean / text
2144
+ * definition 为字段注册定义(getFieldDefinition(field.type)),由调用方传入
2145
+ */
2146
+ const getConditionValueKind = (field, definition) => {
2147
+ const props = (field == null ? void 0 : field.props) || {};
2148
+ if ((field == null ? void 0 : field.type) === 'CheckboxGroup' || definition != null && definition.isSuperSelect || (field == null ? void 0 : field.type) === 'Select' && (props.mode === 'multiple' || props.mode === 'tags')) {
2149
+ return 'multiOptions';
2150
+ }
2151
+ if (definition != null && definition.hasOptions) {
2152
+ return 'options';
2153
+ }
2154
+ if ((field == null ? void 0 : field.type) === 'Switch' || (field == null ? void 0 : field.type) === 'Checkbox') {
2155
+ return 'boolean';
2156
+ }
2157
+ const valueSchema = typeof (definition == null ? void 0 : definition.valueSchema) === 'function' ? definition.valueSchema(field) : definition == null ? void 0 : definition.valueSchema;
2158
+ if ((valueSchema == null ? void 0 : valueSchema.type) === 'number' || (valueSchema == null ? void 0 : valueSchema.type) === 'integer') {
2159
+ return 'number';
2160
+ }
2161
+ return 'text';
2162
+ };
2163
+ const OPERATORS_BY_KIND = {
2164
+ options: ['eq', 'neq', 'in', 'empty', 'notEmpty'],
2165
+ multiOptions: ['includesAny', 'empty', 'notEmpty', 'regex'],
2166
+ number: ['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'empty', 'notEmpty', 'regex'],
2167
+ boolean: ['eq', 'neq'],
2168
+ text: ['eq', 'neq', 'empty', 'notEmpty', 'regex']
2169
+ };
2170
+ const getConditionOperators = (field, definition) => OPERATORS_BY_KIND[getConditionValueKind(field, definition)] || OPERATORS_BY_KIND.text;
2171
+
2172
+ /** 去掉空条件,规范 logic / flags;无有效条件返回 undefined(不写入 schema) */
2173
+ const normalizeVisibleWhen = visibleWhen => {
2174
+ const conditions = ((visibleWhen == null ? void 0 : visibleWhen.conditions) || []).filter(condition => (condition == null ? void 0 : condition.field) && CONDITION_OPERATORS.includes(condition.operator)).map(condition => {
2175
+ const next = {
2176
+ field: condition.field,
2177
+ operator: condition.operator
2178
+ };
2179
+ if (!NO_VALUE_OPERATORS.includes(condition.operator)) {
2180
+ next.value = condition.value;
2181
+ }
2182
+ if (condition.operator === 'regex') {
2183
+ const flags = sanitizeRegexFlags(condition.flags);
2184
+ if (flags) {
2185
+ next.flags = flags;
2186
+ }
2187
+ }
2188
+ return next;
2189
+ });
2190
+ if (!conditions.length) {
2191
+ return undefined;
2192
+ }
2193
+ return {
2194
+ logic: visibleWhen.logic === 'or' ? 'or' : 'and',
2195
+ conditions
2196
+ };
2197
+ };
2198
+ const formatConditionValue = (condition, optionLabelOf) => {
2199
+ if (condition.operator === 'regex') {
2200
+ var _condition$value;
2201
+ return `/${(_condition$value = condition.value) != null ? _condition$value : ''}/${sanitizeRegexFlags(condition.flags)}`;
2202
+ }
2203
+ return toArray(condition.value).map(item => optionLabelOf(item)).join(', ');
2204
+ };
2205
+
2206
+ /**
2207
+ * 条件的可读摘要,如「是否通过 等于 不通过」
2208
+ * formatMessage 需含 conditionOperator_* / conditionLogic_* 文案;fieldLookup 为 path → field
2209
+ */
2210
+ const formatVisibleWhen = (visibleWhen, {
2211
+ formatMessage,
2212
+ fieldLookup: _fieldLookup = new Map(),
2213
+ resolveText: _resolveText = text => text
2214
+ } = {}) => {
2215
+ const conditions = (visibleWhen == null ? void 0 : visibleWhen.conditions) || [];
2216
+ const parts = conditions.map(condition => {
2217
+ const trigger = _fieldLookup.get(condition.field);
2218
+ const fieldLabel = trigger && _resolveText(trigger.label) || condition.field;
2219
+ const optionLabelOf = value => {
2220
+ var _trigger$props;
2221
+ const option = ((trigger == null || (_trigger$props = trigger.props) == null ? void 0 : _trigger$props.options) || []).find(item => sameValue(item == null ? void 0 : item.value, value));
2222
+ if (option) {
2223
+ return _resolveText(option.label);
2224
+ }
2225
+ if (typeof value === 'boolean') {
2226
+ return formatMessage({
2227
+ id: value ? 'conditionValueTrue' : 'conditionValueFalse'
2228
+ });
2229
+ }
2230
+ return String(toComparable(value));
2231
+ };
2232
+ const operatorText = formatMessage({
2233
+ id: `conditionOperator_${condition.operator}`
2234
+ });
2235
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
2236
+ return `${fieldLabel} ${operatorText}`;
2237
+ }
2238
+ return `${fieldLabel} ${operatorText} ${formatConditionValue(condition, optionLabelOf)}`;
2239
+ });
2240
+ return parts.join(formatMessage({
2241
+ id: (visibleWhen == null ? void 0 : visibleWhen.logic) === 'or' ? 'conditionJoinOr' : 'conditionJoinAnd'
2242
+ }));
2243
+ };
2244
+
1699
2245
  const registry = new Map();
1700
2246
  const defineField = (type, definition) => {
1701
2247
  registry.set(type, _extends({
@@ -2478,6 +3024,7 @@ const fieldToFormValues = field => {
2478
3024
  description: field.description || '',
2479
3025
  block: !!field.block,
2480
3026
  hidden: !!field.hidden,
3027
+ visibleWhen: field.visibleWhen,
2481
3028
  placeholder,
2482
3029
  options: options.length ? options : [{
2483
3030
  label: '',
@@ -2515,7 +3062,8 @@ const formValuesToField = (values, existingField = {}) => {
2515
3062
  props.children = values.label;
2516
3063
  }
2517
3064
  const rule = buildRuleString(values.ruleConfig);
2518
- return {
3065
+ const visibleWhen = normalizeVisibleWhen(values.visibleWhen);
3066
+ return _extends({
2519
3067
  id: existingField.id,
2520
3068
  type: values.type,
2521
3069
  name: values.name,
@@ -2524,9 +3072,12 @@ const formValuesToField = (values, existingField = {}) => {
2524
3072
  description: values.description != null && String(values.description).trim() ? values.description : '',
2525
3073
  rule,
2526
3074
  block: (_ref = (_values$block = values.block) != null ? _values$block : (_definition$defaults = definition.defaults) == null ? void 0 : _definition$defaults.block) != null ? _ref : false,
2527
- hidden: !!values.hidden,
3075
+ hidden: !!values.hidden
3076
+ }, visibleWhen ? {
3077
+ visibleWhen
3078
+ } : {}, {
2528
3079
  props
2529
- };
3080
+ });
2530
3081
  };
2531
3082
 
2532
3083
  const {
@@ -2626,7 +3177,7 @@ const LocaleTextArea = props => {
2626
3177
  LocaleTextArea.field = LocaleTextAreaControl;
2627
3178
 
2628
3179
  const {
2629
- Text: Text$4
3180
+ Text: Text$5
2630
3181
  } = Typography;
2631
3182
  const TYPE_TAG_COLORS = {
2632
3183
  Input: 'blue',
@@ -2646,13 +3197,35 @@ const TYPE_TAG_COLORS = {
2646
3197
  Checkbox: 'green',
2647
3198
  DatePicker: 'lime'
2648
3199
  };
3200
+ const TYPE_TAG_ICONS = {
3201
+ Input: FontSizeOutlined,
3202
+ TextArea: AlignLeftOutlined,
3203
+ InputNumber: NumberOutlined,
3204
+ Select: DownSquareOutlined,
3205
+ RadioGroup: CheckCircleOutlined,
3206
+ CheckboxGroup: CheckSquareOutlined,
3207
+ SuperSelectList: AppstoreOutlined,
3208
+ SuperSelectTableList: AppstoreOutlined,
3209
+ SuperSelectTree: AppstoreOutlined,
3210
+ SuperSelectCascader: AppstoreOutlined,
3211
+ SelectFunction: ApartmentOutlined,
3212
+ SelectIndustry: ShopOutlined,
3213
+ SelectAddress: EnvironmentOutlined,
3214
+ Switch: SwapOutlined,
3215
+ Checkbox: CheckSquareOutlined,
3216
+ DatePicker: CalendarOutlined
3217
+ };
3218
+ const getFieldTypeIcon = type => TYPE_TAG_ICONS[type] || FormOutlined;
2649
3219
  const FieldRow = ({
2650
3220
  field,
2651
3221
  index,
2652
3222
  total,
2653
3223
  onEdit,
2654
3224
  onDelete,
2655
- onMove
3225
+ onMove,
3226
+ prevLocked,
3227
+ nextLocked,
3228
+ conditionContext
2656
3229
  }) => {
2657
3230
  const {
2658
3231
  formatMessage,
@@ -2660,40 +3233,81 @@ const FieldRow = ({
2660
3233
  } = useIntl();
2661
3234
  const languages = useLocaleTextLanguages();
2662
3235
  const definition = getFieldDefinition(field.type);
3236
+ const conditional = hasVisibleWhen(field);
3237
+ const conditionInvalid = conditional && conditionContext && hasInvalidCondition(field, conditionContext.triggerNames);
3238
+ const TypeIcon = getFieldTypeIcon(field.type);
2663
3239
  return /*#__PURE__*/jsxs("div", {
2664
3240
  className: style['field-row'],
2665
3241
  children: [/*#__PURE__*/jsx("span", {
2666
3242
  className: style['field-row-index'],
2667
3243
  children: index + 1
2668
- }), /*#__PURE__*/jsx("div", {
3244
+ }), /*#__PURE__*/jsxs("div", {
2669
3245
  className: style['field-row-main'],
2670
- children: /*#__PURE__*/jsxs(Space, {
3246
+ children: [/*#__PURE__*/jsx(Text$5, {
3247
+ strong: true,
3248
+ className: style['field-row-label'],
3249
+ children: resolveLocaleText(field.label, locale, languages) || formatMessage({
3250
+ id: 'untitledField'
3251
+ })
3252
+ }), /*#__PURE__*/jsxs(Space, {
2671
3253
  size: 6,
2672
3254
  wrap: true,
2673
- children: [/*#__PURE__*/jsx(Text$4, {
2674
- strong: true,
2675
- ellipsis: true,
2676
- children: resolveLocaleText(field.label, locale, languages) || formatMessage({
2677
- id: 'untitledField'
2678
- })
2679
- }), /*#__PURE__*/jsx(Tag, {
3255
+ children: [/*#__PURE__*/jsx(Tag, {
2680
3256
  bordered: false,
2681
3257
  color: TYPE_TAG_COLORS[field.type] || 'default',
3258
+ icon: /*#__PURE__*/jsx(TypeIcon, {}),
2682
3259
  children: resolveFieldTypeLabel(definition || field.type, formatMessage)
2683
- }), field.hidden ? /*#__PURE__*/jsx(Tag, {
3260
+ }), field.locked ? /*#__PURE__*/jsx(Tag, {
2684
3261
  bordered: false,
3262
+ icon: /*#__PURE__*/jsx(LockOutlined, {}),
3263
+ title: formatMessage({
3264
+ id: 'fieldLockedTips'
3265
+ }),
3266
+ children: formatMessage({
3267
+ id: 'fieldLockedTag'
3268
+ })
3269
+ }) : null, field.hidden ? /*#__PURE__*/jsx(Tag, {
3270
+ bordered: false,
3271
+ icon: /*#__PURE__*/jsx(EyeInvisibleOutlined, {}),
2685
3272
  children: formatMessage({
2686
3273
  id: 'fieldHiddenTag'
2687
3274
  })
3275
+ }) : null, conditional ? /*#__PURE__*/jsx(Tooltip, {
3276
+ title: formatVisibleWhen(field.visibleWhen, {
3277
+ formatMessage,
3278
+ fieldLookup: conditionContext == null ? void 0 : conditionContext.fieldLookup,
3279
+ resolveText: value => resolveLocaleText(value, locale, languages)
3280
+ }),
3281
+ children: /*#__PURE__*/jsx(Tag, {
3282
+ bordered: false,
3283
+ color: "magenta",
3284
+ icon: /*#__PURE__*/jsx(BranchesOutlined, {}),
3285
+ children: formatMessage({
3286
+ id: 'fieldConditionTag'
3287
+ })
3288
+ })
3289
+ }) : null, conditionInvalid ? /*#__PURE__*/jsx(Tooltip, {
3290
+ title: formatMessage({
3291
+ id: 'fieldConditionInvalidTips'
3292
+ }),
3293
+ children: /*#__PURE__*/jsx(Tag, {
3294
+ bordered: false,
3295
+ color: "error",
3296
+ icon: /*#__PURE__*/jsx(WarningOutlined, {}),
3297
+ children: formatMessage({
3298
+ id: 'fieldConditionInvalidTag'
3299
+ })
3300
+ })
2688
3301
  }) : null, field.block ? /*#__PURE__*/jsx(Tag, {
2689
3302
  bordered: false,
2690
3303
  color: "processing",
3304
+ icon: /*#__PURE__*/jsx(ColumnWidthOutlined, {}),
2691
3305
  children: formatMessage({
2692
3306
  id: 'fieldBlockTag'
2693
3307
  })
2694
3308
  }) : null]
2695
- })
2696
- }), /*#__PURE__*/jsxs("div", {
3309
+ })]
3310
+ }), field.locked ? null : /*#__PURE__*/jsxs("div", {
2697
3311
  className: style['action-group'],
2698
3312
  children: [/*#__PURE__*/jsx(Button, {
2699
3313
  type: "text",
@@ -2703,7 +3317,7 @@ const FieldRow = ({
2703
3317
  id: 'moveUp'
2704
3318
  }),
2705
3319
  icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
2706
- disabled: index === 0,
3320
+ disabled: index === 0 || prevLocked,
2707
3321
  onClick: () => onMove(field.id, 'up')
2708
3322
  }), /*#__PURE__*/jsx(Button, {
2709
3323
  type: "text",
@@ -2713,7 +3327,7 @@ const FieldRow = ({
2713
3327
  id: 'moveDown'
2714
3328
  }),
2715
3329
  icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
2716
- disabled: index === total - 1,
3330
+ disabled: index === total - 1 || nextLocked,
2717
3331
  onClick: () => onMove(field.id, 'down')
2718
3332
  }), /*#__PURE__*/jsx(Button, {
2719
3333
  type: "text",
@@ -2738,11 +3352,10 @@ const FieldRow = ({
2738
3352
  })]
2739
3353
  });
2740
3354
  };
2741
- var FieldRow$1 = FieldRow;
2742
3355
 
2743
- const _excluded$2 = ["title", "danger"];
3356
+ const _excluded$3 = ["title", "danger"];
2744
3357
  const {
2745
- Text: Text$3
3358
+ Text: Text$4
2746
3359
  } = Typography;
2747
3360
  const ActionGroup = ({
2748
3361
  children
@@ -2755,7 +3368,7 @@ const IconBtn = _ref => {
2755
3368
  title,
2756
3369
  danger
2757
3370
  } = _ref,
2758
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
3371
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
2759
3372
  return /*#__PURE__*/jsx(Button, _extends({
2760
3373
  type: "text",
2761
3374
  size: "small",
@@ -2789,6 +3402,10 @@ const ROOT_ADD_OPTIONS = [{
2789
3402
  key: 'steps',
2790
3403
  icon: /*#__PURE__*/jsx(OrderedListOutlined, {})
2791
3404
  }];
3405
+ const BLOCK_KIND_ICONS = Object.fromEntries(ROOT_ADD_OPTIONS.map(({
3406
+ key,
3407
+ icon
3408
+ }) => [key, icon]));
2792
3409
 
2793
3410
  /** 可挂子模块的容器;表格列表 / 同类多值本身不支持子模块 */
2794
3411
  const NESTED_ADD_OPTIONS = ROOT_ADD_OPTIONS.filter(opt => opt.key !== 'steps');
@@ -2822,6 +3439,15 @@ const BlockListPanel = ({
2822
3439
  const [addMenuOpen, setAddMenuOpen] = useState(false);
2823
3440
  const [addFieldMenuId, setAddFieldMenuId] = useState(null);
2824
3441
  const keepAddFieldMenuOpenRef = useRef(false);
3442
+ const conditionContext = useMemo(() => {
3443
+ const triggerFields = collectConditionFields({
3444
+ blocks
3445
+ }).filter(item => !item.inList);
3446
+ return {
3447
+ triggerNames: new Set(triggerFields.map(item => item.path)),
3448
+ fieldLookup: new Map(triggerFields.map(item => [item.path, item.field]))
3449
+ };
3450
+ }, [blocks]);
2825
3451
  const renderAddBlockMenu = (options, {
2826
3452
  onSelect,
2827
3453
  className
@@ -2983,7 +3609,7 @@ const BlockListPanel = ({
2983
3609
  optionId
2984
3610
  } = {}) => {
2985
3611
  if (!(fields || []).length) {
2986
- return /*#__PURE__*/jsx(Text$3, {
3612
+ return /*#__PURE__*/jsx(Text$4, {
2987
3613
  type: "secondary",
2988
3614
  className: style['inline-empty'],
2989
3615
  children: formatMessage({
@@ -2993,10 +3619,13 @@ const BlockListPanel = ({
2993
3619
  }
2994
3620
  return /*#__PURE__*/jsx("div", {
2995
3621
  className: style['field-list'],
2996
- children: fields.map((field, fieldIndex) => /*#__PURE__*/jsx(FieldRow$1, {
3622
+ children: fields.map((field, fieldIndex) => /*#__PURE__*/jsx(FieldRow, {
2997
3623
  field: field,
2998
3624
  index: fieldIndex,
2999
3625
  total: fields.length,
3626
+ prevLocked: isFieldLocked(fields[fieldIndex - 1]),
3627
+ nextLocked: isFieldLocked(fields[fieldIndex + 1]),
3628
+ conditionContext: conditionContext,
3000
3629
  onEdit: fieldItem => onEditField(blockId, fieldItem, {
3001
3630
  stepId,
3002
3631
  optionId
@@ -3020,7 +3649,7 @@ const BlockListPanel = ({
3020
3649
  className: style['item-blocks-section'],
3021
3650
  children: /*#__PURE__*/jsx("div", {
3022
3651
  className: style['nested-block-list'],
3023
- children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks.length, depth + 1))
3652
+ children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks, depth + 1))
3024
3653
  })
3025
3654
  });
3026
3655
  };
@@ -3031,7 +3660,7 @@ const BlockListPanel = ({
3031
3660
  className: style['block-body'],
3032
3661
  children: [/*#__PURE__*/jsxs("div", {
3033
3662
  className: style['section-toolbar'],
3034
- children: [/*#__PURE__*/jsx(Text$3, {
3663
+ children: [/*#__PURE__*/jsx(Text$4, {
3035
3664
  type: "secondary",
3036
3665
  className: style['section-toolbar-label'],
3037
3666
  children: formatMessage({
@@ -3062,14 +3691,14 @@ const BlockListPanel = ({
3062
3691
  children: [/*#__PURE__*/jsx("span", {
3063
3692
  className: style['step-index'],
3064
3693
  children: stepIndex + 1
3065
- }), /*#__PURE__*/jsx(Text$3, {
3694
+ }), /*#__PURE__*/jsx(Text$4, {
3066
3695
  strong: true,
3067
3696
  children: text(step.title) || formatMessage({
3068
3697
  id: 'untitledStep'
3069
3698
  }, {
3070
3699
  index: stepIndex + 1
3071
3700
  })
3072
- }), /*#__PURE__*/jsx(Text$3, {
3701
+ }), /*#__PURE__*/jsx(Text$4, {
3073
3702
  type: "secondary",
3074
3703
  children: (step.blocks || []).length ? formatMessage({
3075
3704
  id: 'fieldAndItemBlockCount'
@@ -3092,14 +3721,14 @@ const BlockListPanel = ({
3092
3721
  id: 'moveUp'
3093
3722
  }),
3094
3723
  icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
3095
- disabled: stepIndex === 0,
3724
+ disabled: stepIndex === 0 || blockHasLockedField(step) || blockHasLockedField(block.items[stepIndex - 1]),
3096
3725
  onClick: () => onMoveStep(block.id, step.id, 'up')
3097
3726
  }), /*#__PURE__*/jsx(IconBtn, {
3098
3727
  title: formatMessage({
3099
3728
  id: 'moveDown'
3100
3729
  }),
3101
3730
  icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
3102
- disabled: stepIndex === (((_block$items = block.items) == null ? void 0 : _block$items.length) || 0) - 1,
3731
+ disabled: stepIndex === (((_block$items = block.items) == null ? void 0 : _block$items.length) || 0) - 1 || blockHasLockedField(step) || blockHasLockedField(block.items[stepIndex + 1]),
3103
3732
  onClick: () => onMoveStep(block.id, step.id, 'down')
3104
3733
  }), /*#__PURE__*/jsx(IconBtn, {
3105
3734
  title: formatMessage({
@@ -3107,7 +3736,7 @@ const BlockListPanel = ({
3107
3736
  }),
3108
3737
  icon: /*#__PURE__*/jsx(EditOutlined, {}),
3109
3738
  onClick: () => onEditStep(block.id, step)
3110
- }), /*#__PURE__*/jsx(IconBtn, {
3739
+ }), blockHasLockedField(step) ? null : /*#__PURE__*/jsx(IconBtn, {
3111
3740
  title: formatMessage({
3112
3741
  id: 'deleteStep'
3113
3742
  }),
@@ -3132,7 +3761,7 @@ const BlockListPanel = ({
3132
3761
  }), renderNestedBlocks(step.blocks, depth)]
3133
3762
  }, step.id);
3134
3763
  })
3135
- }) : /*#__PURE__*/jsx(Text$3, {
3764
+ }) : /*#__PURE__*/jsx(Text$4, {
3136
3765
  type: "secondary",
3137
3766
  className: style['inline-empty'],
3138
3767
  children: formatMessage({
@@ -3144,7 +3773,7 @@ const BlockListPanel = ({
3144
3773
  if (block.kind === 'multiField') {
3145
3774
  return /*#__PURE__*/jsx("div", {
3146
3775
  className: style['block-body'],
3147
- children: /*#__PURE__*/jsx(Text$3, {
3776
+ children: /*#__PURE__*/jsx(Text$4, {
3148
3777
  type: "secondary",
3149
3778
  children: formatMessage({
3150
3779
  id: 'multiFieldEditorHint'
@@ -3157,7 +3786,7 @@ const BlockListPanel = ({
3157
3786
  className: style['block-body'],
3158
3787
  children: [/*#__PURE__*/jsxs("div", {
3159
3788
  className: style['section-toolbar'],
3160
- children: [/*#__PURE__*/jsx(Text$3, {
3789
+ children: [/*#__PURE__*/jsx(Text$4, {
3161
3790
  type: "secondary",
3162
3791
  className: style['section-toolbar-label'],
3163
3792
  children: formatMessage({
@@ -3188,14 +3817,14 @@ const BlockListPanel = ({
3188
3817
  children: [/*#__PURE__*/jsx("span", {
3189
3818
  className: style['step-index'],
3190
3819
  children: optionIndex + 1
3191
- }), /*#__PURE__*/jsx(Text$3, {
3820
+ }), /*#__PURE__*/jsx(Text$4, {
3192
3821
  strong: true,
3193
3822
  children: text(option.title) || formatMessage({
3194
3823
  id: 'choiceOptionFallback'
3195
3824
  }, {
3196
3825
  index: optionIndex + 1
3197
3826
  })
3198
- }), /*#__PURE__*/jsx(Text$3, {
3827
+ }), /*#__PURE__*/jsx(Text$4, {
3199
3828
  type: "secondary",
3200
3829
  children: (option.blocks || []).length ? formatMessage({
3201
3830
  id: 'fieldAndItemBlockCount'
@@ -3218,14 +3847,14 @@ const BlockListPanel = ({
3218
3847
  id: 'moveUp'
3219
3848
  }),
3220
3849
  icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
3221
- disabled: optionIndex === 0,
3850
+ disabled: optionIndex === 0 || blockHasLockedField(option) || blockHasLockedField(block.options[optionIndex - 1]),
3222
3851
  onClick: () => onMoveChoiceOption(block.id, option.id, 'up')
3223
3852
  }), /*#__PURE__*/jsx(IconBtn, {
3224
3853
  title: formatMessage({
3225
3854
  id: 'moveDown'
3226
3855
  }),
3227
3856
  icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
3228
- disabled: optionIndex === (((_block$options = block.options) == null ? void 0 : _block$options.length) || 0) - 1,
3857
+ disabled: optionIndex === (((_block$options = block.options) == null ? void 0 : _block$options.length) || 0) - 1 || blockHasLockedField(option) || blockHasLockedField(block.options[optionIndex + 1]),
3229
3858
  onClick: () => onMoveChoiceOption(block.id, option.id, 'down')
3230
3859
  }), /*#__PURE__*/jsx(IconBtn, {
3231
3860
  title: formatMessage({
@@ -3233,7 +3862,7 @@ const BlockListPanel = ({
3233
3862
  }),
3234
3863
  icon: /*#__PURE__*/jsx(EditOutlined, {}),
3235
3864
  onClick: () => onEditChoiceOption(block.id, option)
3236
- }), /*#__PURE__*/jsx(IconBtn, {
3865
+ }), blockHasLockedField(option) ? null : /*#__PURE__*/jsx(IconBtn, {
3237
3866
  title: formatMessage({
3238
3867
  id: 'deleteChoiceOption'
3239
3868
  }),
@@ -3258,7 +3887,7 @@ const BlockListPanel = ({
3258
3887
  }), renderNestedBlocks(option.blocks, depth)]
3259
3888
  }, option.id);
3260
3889
  })
3261
- }) : /*#__PURE__*/jsx(Text$3, {
3890
+ }) : /*#__PURE__*/jsx(Text$4, {
3262
3891
  type: "secondary",
3263
3892
  className: style['inline-empty'],
3264
3893
  children: formatMessage({
@@ -3274,8 +3903,10 @@ const BlockListPanel = ({
3274
3903
  children: [renderFieldList(block.list, block.id), supportsItemBlocks$1 ? renderItemBlocks(block, depth) : null, supportsBlocks ? renderNestedBlocks(block.blocks, depth) : null]
3275
3904
  });
3276
3905
  };
3277
- const renderBlockSection = (block, blockIndex, total, depth = 0) => {
3906
+ const renderBlockSection = (block, blockIndex, siblings, depth = 0) => {
3278
3907
  var _block$itemBlocks, _block$blocks, _block$items2, _block$options2, _block$list, _block$list2;
3908
+ const total = siblings.length;
3909
+ const locked = blockHasLockedField(block);
3279
3910
  const definition = getBlockDefinition(block.kind);
3280
3911
  const canAddField = block.kind !== 'steps' && block.kind !== 'multiField' && block.kind !== 'choice';
3281
3912
  const supportsItemBlocks$1 = supportsItemBlocks(block.kind);
@@ -3289,7 +3920,10 @@ const BlockListPanel = ({
3289
3920
  }) : block.kind === 'multiField' ? formatMessage({
3290
3921
  id: 'multiFieldSummary'
3291
3922
  }, {
3292
- type: resolveFieldTypeLabel(block.fieldType, formatMessage)
3923
+ type: /*#__PURE__*/jsxs("span", {
3924
+ className: style['block-summary-type'],
3925
+ children: [/*#__PURE__*/createElement(getFieldTypeIcon(block.fieldType || 'Input')), resolveFieldTypeLabel(block.fieldType, formatMessage)]
3926
+ })
3293
3927
  }) : block.kind === 'choice' ? formatMessage({
3294
3928
  id: 'choiceOptionCount'
3295
3929
  }, {
@@ -3313,10 +3947,11 @@ const BlockListPanel = ({
3313
3947
  children: [/*#__PURE__*/jsx(Tag, {
3314
3948
  bordered: false,
3315
3949
  color: (definition == null ? void 0 : definition.color) || 'default',
3950
+ icon: BLOCK_KIND_ICONS[block.kind],
3316
3951
  children: formatMessage({
3317
3952
  id: `blockKind_${block.kind}`
3318
3953
  })
3319
- }), /*#__PURE__*/jsx(Text$3, {
3954
+ }), /*#__PURE__*/jsx(Text$4, {
3320
3955
  strong: true,
3321
3956
  ellipsis: true,
3322
3957
  className: style['block-title'],
@@ -3337,14 +3972,14 @@ const BlockListPanel = ({
3337
3972
  id: 'moveUp'
3338
3973
  }),
3339
3974
  icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
3340
- disabled: blockIndex === 0,
3975
+ disabled: blockIndex === 0 || locked || blockHasLockedField(siblings[blockIndex - 1]),
3341
3976
  onClick: () => onMoveBlock(block.id, 'up')
3342
3977
  }), /*#__PURE__*/jsx(IconBtn, {
3343
3978
  title: formatMessage({
3344
3979
  id: 'moveDown'
3345
3980
  }),
3346
3981
  icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
3347
- disabled: blockIndex === total - 1,
3982
+ disabled: blockIndex === total - 1 || locked || blockHasLockedField(siblings[blockIndex + 1]),
3348
3983
  onClick: () => onMoveBlock(block.id, 'down')
3349
3984
  }), /*#__PURE__*/jsx(IconBtn, {
3350
3985
  title: formatMessage({
@@ -3352,7 +3987,7 @@ const BlockListPanel = ({
3352
3987
  }),
3353
3988
  icon: /*#__PURE__*/jsx(SettingOutlined, {}),
3354
3989
  onClick: () => onEditBlock(block)
3355
- }), /*#__PURE__*/jsx(IconBtn, {
3990
+ }), locked ? null : /*#__PURE__*/jsx(IconBtn, {
3356
3991
  title: formatMessage({
3357
3992
  id: 'deleteBlock'
3358
3993
  }),
@@ -3420,7 +4055,7 @@ const BlockListPanel = ({
3420
4055
  })
3421
4056
  }) : /*#__PURE__*/jsx("div", {
3422
4057
  className: style['block-list'],
3423
- children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks.length, 0))
4058
+ children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks, 0))
3424
4059
  })]
3425
4060
  });
3426
4061
  };
@@ -3846,7 +4481,7 @@ const ChoiceOptionEditorModal = ({
3846
4481
  var ChoiceOptionEditorModal$1 = ChoiceOptionEditorModal;
3847
4482
 
3848
4483
  const {
3849
- Text: Text$2
4484
+ Text: Text$3
3850
4485
  } = Typography;
3851
4486
  const {
3852
4487
  useOnChange
@@ -3901,7 +4536,7 @@ const RulePresetEditor = () => {
3901
4536
  }
3902
4537
  }, "lenMax"), /*#__PURE__*/jsx("div", {
3903
4538
  block: true,
3904
- children: /*#__PURE__*/jsx(Text$2, {
4539
+ children: /*#__PURE__*/jsx(Text$3, {
3905
4540
  type: "secondary",
3906
4541
  children: formatMessage({
3907
4542
  id: 'ruleEditorHint'
@@ -3919,7 +4554,7 @@ const RulePresetEditor = () => {
3919
4554
  var RulePresetEditor$1 = RulePresetEditor;
3920
4555
 
3921
4556
  const {
3922
- Text: Text$1
4557
+ Text: Text$2
3923
4558
  } = Typography;
3924
4559
  const createOptionKey = () => createDataKey('opt');
3925
4560
  const EMPTY_OPTION = () => ({
@@ -3990,7 +4625,28 @@ const FlatOptionRows = ({
3990
4625
  };
3991
4626
  return /*#__PURE__*/jsxs("div", {
3992
4627
  className: style['options-list'],
3993
- children: [rows.map((item, index) => /*#__PURE__*/jsxs(Flex, {
4628
+ children: [/*#__PURE__*/jsxs("div", {
4629
+ className: style['options-header'],
4630
+ children: [/*#__PURE__*/jsx("span", {
4631
+ className: style['options-header-label'],
4632
+ children: formatMessage({
4633
+ id: 'optionLabelColumn'
4634
+ })
4635
+ }), /*#__PURE__*/jsx("span", {
4636
+ className: style['options-header-value'],
4637
+ children: formatMessage({
4638
+ id: 'optionValueColumn'
4639
+ })
4640
+ }), allowDescription ? /*#__PURE__*/jsx("span", {
4641
+ className: style['options-header-description'],
4642
+ children: formatMessage({
4643
+ id: 'optionDescColumn'
4644
+ })
4645
+ }) : null, /*#__PURE__*/jsx("span", {
4646
+ className: style['options-header-action'],
4647
+ "aria-hidden": "true"
4648
+ })]
4649
+ }), rows.map((item, index) => /*#__PURE__*/jsxs(Flex, {
3994
4650
  gap: 8,
3995
4651
  align: "start",
3996
4652
  className: style['options-row'],
@@ -4333,7 +4989,7 @@ const TableRowsEditor = ({
4333
4989
  column: 1,
4334
4990
  list: [/*#__PURE__*/jsx("div", {
4335
4991
  block: true,
4336
- children: /*#__PURE__*/jsx(Text$1, {
4992
+ children: /*#__PURE__*/jsx(Text$2, {
4337
4993
  type: "secondary",
4338
4994
  children: formatMessage({
4339
4995
  id: 'tableRowsNeedColumnsHint'
@@ -4383,6 +5039,7 @@ const TableRowsEditor = ({
4383
5039
  },
4384
5040
  children: [/*#__PURE__*/jsxs(Flex, {
4385
5041
  gap: 8,
5042
+ className: style['options-row'],
4386
5043
  children: [/*#__PURE__*/jsx(Input$1, {
4387
5044
  value: item.value || '',
4388
5045
  placeholder: formatMessage({
@@ -4901,7 +5558,391 @@ const hasFieldPropsEditor = (type, definition) => {
4901
5558
  };
4902
5559
  var FieldPropsEditor$1 = FieldPropsEditor;
4903
5560
 
4904
- const _excluded$1 = ["columns"];
5561
+ const {
5562
+ Text: Text$1
5563
+ } = Typography;
5564
+ const MULTI_VALUE_OPERATORS = ['in', 'includesAny'];
5565
+ const createCondition = () => ({
5566
+ field: undefined,
5567
+ operator: undefined,
5568
+ value: undefined
5569
+ });
5570
+
5571
+ /** 编辑器提交前校验:返回错误文案 id,通过返回 null */
5572
+ const validateVisibleWhenDraft = visibleWhen => {
5573
+ if (!visibleWhen) {
5574
+ return null;
5575
+ }
5576
+ const incomplete = (visibleWhen.conditions || []).some(condition => {
5577
+ if (!(condition != null && condition.field) || !condition.operator) {
5578
+ return true;
5579
+ }
5580
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
5581
+ return false;
5582
+ }
5583
+ const value = condition.value;
5584
+ return value === undefined || value === null || value === '' || Array.isArray(value) && !value.length;
5585
+ });
5586
+ if (incomplete || !(visibleWhen.conditions || []).length) {
5587
+ return 'visibleWhenConditionRequired';
5588
+ }
5589
+ if (visibleWhen.conditions.some(condition => condition.operator === 'regex' && !compileConditionRegex(condition.value, condition.flags))) {
5590
+ return 'visibleWhenRegexInvalid';
5591
+ }
5592
+ return null;
5593
+ };
5594
+ const RegexTester = ({
5595
+ condition
5596
+ }) => {
5597
+ const {
5598
+ formatMessage
5599
+ } = useIntl();
5600
+ const [text, setText] = useState('');
5601
+ const regex = compileConditionRegex(condition.value, condition.flags);
5602
+ const status = regex && text !== '' ? regex.test(text) : null;
5603
+ return /*#__PURE__*/jsxs(Flex, {
5604
+ gap: 8,
5605
+ align: "center",
5606
+ className: style['visible-when-regex-tester'],
5607
+ children: [/*#__PURE__*/jsx(Input$1, {
5608
+ size: "small",
5609
+ value: text,
5610
+ placeholder: formatMessage({
5611
+ id: 'visibleWhenRegexTester'
5612
+ }),
5613
+ onChange: e => setText(e.target.value)
5614
+ }), status === null ? null : /*#__PURE__*/jsx(Text$1, {
5615
+ type: status ? 'success' : 'warning',
5616
+ children: formatMessage({
5617
+ id: status ? 'visibleWhenRegexMatched' : 'visibleWhenRegexNotMatched'
5618
+ })
5619
+ })]
5620
+ });
5621
+ };
5622
+ const ConditionValueInput = ({
5623
+ condition,
5624
+ trigger,
5625
+ onChange
5626
+ }) => {
5627
+ var _condition$value3;
5628
+ const {
5629
+ formatMessage,
5630
+ locale
5631
+ } = useIntl();
5632
+ const definition = getFieldDefinition(trigger == null ? void 0 : trigger.type);
5633
+ const kind = getConditionValueKind(trigger, definition);
5634
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
5635
+ return null;
5636
+ }
5637
+ if (condition.operator === 'regex') {
5638
+ var _condition$value;
5639
+ const regexInvalid = condition.value != null && condition.value !== '' && !compileConditionRegex(condition.value, condition.flags);
5640
+ return /*#__PURE__*/jsxs("div", {
5641
+ className: style['visible-when-regex'],
5642
+ children: [/*#__PURE__*/jsxs(Flex, {
5643
+ gap: 8,
5644
+ children: [/*#__PURE__*/jsx(Input$1, {
5645
+ prefix: "/",
5646
+ suffix: "/",
5647
+ status: regexInvalid ? 'error' : undefined,
5648
+ value: (_condition$value = condition.value) != null ? _condition$value : '',
5649
+ placeholder: formatMessage({
5650
+ id: 'visibleWhenValue'
5651
+ }),
5652
+ onChange: e => onChange({
5653
+ value: e.target.value
5654
+ })
5655
+ }), /*#__PURE__*/jsx(Select$1, {
5656
+ mode: "multiple",
5657
+ className: style['visible-when-flags'],
5658
+ placeholder: formatMessage({
5659
+ id: 'visibleWhenRegexFlags'
5660
+ }),
5661
+ value: String(condition.flags || '').split('').filter(Boolean),
5662
+ options: ALLOWED_REGEX_FLAGS.map(flag => ({
5663
+ value: flag,
5664
+ label: formatMessage({
5665
+ id: `visibleWhenRegexFlag_${flag}`
5666
+ })
5667
+ })),
5668
+ optionLabelProp: "value",
5669
+ onChange: flags => onChange({
5670
+ flags: flags.join('')
5671
+ })
5672
+ })]
5673
+ }), regexInvalid ? /*#__PURE__*/jsx(Text$1, {
5674
+ type: "danger",
5675
+ children: formatMessage({
5676
+ id: 'visibleWhenRegexInvalid'
5677
+ })
5678
+ }) : null, /*#__PURE__*/jsx(RegexTester, {
5679
+ condition: condition
5680
+ })]
5681
+ });
5682
+ }
5683
+ if (kind === 'boolean') {
5684
+ return /*#__PURE__*/jsx(Select$1, {
5685
+ className: style['visible-when-value'],
5686
+ value: condition.value,
5687
+ placeholder: formatMessage({
5688
+ id: 'visibleWhenValue'
5689
+ }),
5690
+ options: [{
5691
+ value: true,
5692
+ label: formatMessage({
5693
+ id: 'conditionValueTrue'
5694
+ })
5695
+ }, {
5696
+ value: false,
5697
+ label: formatMessage({
5698
+ id: 'conditionValueFalse'
5699
+ })
5700
+ }],
5701
+ onChange: value => onChange({
5702
+ value
5703
+ })
5704
+ });
5705
+ }
5706
+ if (kind === 'options' || kind === 'multiOptions') {
5707
+ var _trigger$props;
5708
+ const multiple = MULTI_VALUE_OPERATORS.includes(condition.operator);
5709
+ const options = ((trigger == null || (_trigger$props = trigger.props) == null ? void 0 : _trigger$props.options) || []).filter(item => (item == null ? void 0 : item.value) != null && item.value !== '').map(item => ({
5710
+ value: item.value,
5711
+ label: resolveLocaleText(item.label, locale) || String(item.value)
5712
+ }));
5713
+ const value = multiple ? Array.isArray(condition.value) ? condition.value : condition.value != null ? [condition.value] : [] : Array.isArray(condition.value) ? condition.value[0] : condition.value;
5714
+ return /*#__PURE__*/jsx(Select$1, {
5715
+ className: style['visible-when-value']
5716
+ // 远程数据源没有静态选项时允许手动输入值
5717
+ ,
5718
+ mode: options.length ? multiple ? 'multiple' : undefined : 'tags',
5719
+ value: value,
5720
+ placeholder: formatMessage({
5721
+ id: 'visibleWhenValue'
5722
+ }),
5723
+ options: options,
5724
+ onChange: next => onChange({
5725
+ value: !options.length && !multiple && Array.isArray(next) ? next[next.length - 1] : next
5726
+ })
5727
+ });
5728
+ }
5729
+ if (kind === 'number') {
5730
+ var _condition$value2;
5731
+ return /*#__PURE__*/jsx(InputNumber$1, {
5732
+ className: style['visible-when-value'],
5733
+ value: (_condition$value2 = condition.value) != null ? _condition$value2 : null,
5734
+ placeholder: formatMessage({
5735
+ id: 'visibleWhenValue'
5736
+ }),
5737
+ onChange: value => onChange({
5738
+ value: value != null ? value : undefined
5739
+ })
5740
+ });
5741
+ }
5742
+ return /*#__PURE__*/jsx(Input$1, {
5743
+ className: style['visible-when-value'],
5744
+ value: (_condition$value3 = condition.value) != null ? _condition$value3 : '',
5745
+ placeholder: formatMessage({
5746
+ id: 'visibleWhenValue'
5747
+ }),
5748
+ onChange: e => onChange({
5749
+ value: e.target.value
5750
+ })
5751
+ });
5752
+ };
5753
+
5754
+ /**
5755
+ * 条件显示配置(受控):value 为 visibleWhen 草稿或 undefined
5756
+ * triggerFields:collectConditionFields 中可作为触发项的字段;scope:当前字段所在模块
5757
+ */
5758
+ const VisibleWhenEditor = ({
5759
+ value,
5760
+ onChange,
5761
+ schema,
5762
+ triggerFields: _triggerFields = [],
5763
+ scope,
5764
+ fieldId
5765
+ }) => {
5766
+ const {
5767
+ formatMessage,
5768
+ locale
5769
+ } = useIntl();
5770
+ const {
5771
+ formData
5772
+ } = useFormContext() || {};
5773
+ const selfPath = getFieldConditionPath(scope, formData != null && formData.name ? String(formData.name).trim() : '');
5774
+ const candidates = useMemo(() => _triggerFields.filter(item => item.id !== fieldId && item.path !== selfPath).map(item => _extends({}, item, {
5775
+ disabled: selfPath ? wouldCreateCycle(schema, selfPath, item.path) : false
5776
+ })), [_triggerFields, fieldId, selfPath, schema]);
5777
+ if (scope != null && scope.inList) {
5778
+ return /*#__PURE__*/jsx(FormInfo, {
5779
+ title: formatMessage({
5780
+ id: 'visibleWhenTitle'
5781
+ }),
5782
+ column: 1,
5783
+ list: [/*#__PURE__*/jsx("div", {
5784
+ block: true,
5785
+ children: /*#__PURE__*/jsx(Text$1, {
5786
+ type: "secondary",
5787
+ children: formatMessage({
5788
+ id: 'visibleWhenListUnsupported'
5789
+ })
5790
+ })
5791
+ }, "unsupported")]
5792
+ });
5793
+ }
5794
+ const enabled = !!value;
5795
+ const conditions = (value == null ? void 0 : value.conditions) || [];
5796
+ const updateConditions = next => onChange(_extends({}, value, {
5797
+ conditions: next
5798
+ }));
5799
+ const updateCondition = (index, patch) => updateConditions(conditions.map((item, itemIndex) => itemIndex === index ? _extends({}, item, patch) : item));
5800
+ const body = /*#__PURE__*/jsxs("div", {
5801
+ block: true,
5802
+ className: style['visible-when-editor'],
5803
+ children: [/*#__PURE__*/jsxs(Flex, {
5804
+ gap: 8,
5805
+ align: "center",
5806
+ children: [/*#__PURE__*/jsx(Switch$1, {
5807
+ size: "small",
5808
+ checked: enabled,
5809
+ disabled: !enabled && !candidates.length,
5810
+ onChange: checked => onChange(checked ? {
5811
+ logic: 'and',
5812
+ conditions: [createCondition()]
5813
+ } : undefined)
5814
+ }), /*#__PURE__*/jsx(Text$1, {
5815
+ children: formatMessage({
5816
+ id: 'visibleWhenEnable'
5817
+ })
5818
+ })]
5819
+ }), /*#__PURE__*/jsx(Text$1, {
5820
+ type: "secondary",
5821
+ className: style['visible-when-hint'],
5822
+ children: formatMessage({
5823
+ id: candidates.length || enabled ? 'visibleWhenEnableTips' : 'visibleWhenNoTrigger'
5824
+ })
5825
+ }), enabled ? /*#__PURE__*/jsxs(Fragment, {
5826
+ children: [conditions.length > 1 ? /*#__PURE__*/jsxs(Flex, {
5827
+ gap: 8,
5828
+ align: "center",
5829
+ children: [/*#__PURE__*/jsx(Text$1, {
5830
+ children: formatMessage({
5831
+ id: 'visibleWhenLogic'
5832
+ })
5833
+ }), /*#__PURE__*/jsx(Radio.Group, {
5834
+ size: "small",
5835
+ value: value.logic === 'or' ? 'or' : 'and',
5836
+ options: ['and', 'or'].map(logic => ({
5837
+ value: logic,
5838
+ label: formatMessage({
5839
+ id: `conditionLogic_${logic}`
5840
+ })
5841
+ })),
5842
+ onChange: e => onChange(_extends({}, value, {
5843
+ logic: e.target.value
5844
+ }))
5845
+ })]
5846
+ }) : null, /*#__PURE__*/jsx("div", {
5847
+ className: style['visible-when-list'],
5848
+ children: conditions.map((condition, index) => {
5849
+ var _triggerFields$find;
5850
+ const trigger = (_triggerFields$find = _triggerFields.find(item => item.path === condition.field)) == null ? void 0 : _triggerFields$find.field;
5851
+ const operators = trigger ? getConditionOperators(trigger, getFieldDefinition(trigger.type)) : [];
5852
+ return /*#__PURE__*/jsxs(Flex, {
5853
+ gap: 8,
5854
+ align: "start",
5855
+ className: style['visible-when-row'],
5856
+ children: [/*#__PURE__*/jsxs("div", {
5857
+ className: style['visible-when-row-main'],
5858
+ children: [/*#__PURE__*/jsxs(Flex, {
5859
+ gap: 8,
5860
+ wrap: true,
5861
+ children: [/*#__PURE__*/jsx(Select$1, {
5862
+ showSearch: true,
5863
+ optionFilterProp: "label",
5864
+ className: style['visible-when-field'],
5865
+ status: condition.field && !trigger ? 'error' : undefined,
5866
+ value: condition.field,
5867
+ placeholder: formatMessage({
5868
+ id: 'visibleWhenField'
5869
+ }),
5870
+ options: candidates.map(item => ({
5871
+ value: item.path,
5872
+ disabled: item.disabled,
5873
+ label: `${resolveLocaleText(item.field.label, locale) || item.field.name}(${item.path})`
5874
+ })),
5875
+ onChange: path => {
5876
+ var _triggerFields$find2;
5877
+ const nextTrigger = (_triggerFields$find2 = _triggerFields.find(item => item.path === path)) == null ? void 0 : _triggerFields$find2.field;
5878
+ const nextOperators = getConditionOperators(nextTrigger, getFieldDefinition(nextTrigger == null ? void 0 : nextTrigger.type));
5879
+ updateCondition(index, {
5880
+ field: path,
5881
+ operator: nextOperators[0],
5882
+ value: undefined,
5883
+ flags: undefined
5884
+ });
5885
+ }
5886
+ }), /*#__PURE__*/jsx(Select$1, {
5887
+ className: style['visible-when-operator'],
5888
+ value: condition.operator,
5889
+ disabled: !trigger,
5890
+ placeholder: formatMessage({
5891
+ id: 'visibleWhenOperator'
5892
+ }),
5893
+ options: operators.map(operator => ({
5894
+ value: operator,
5895
+ label: formatMessage({
5896
+ id: `conditionOperator_${operator}`
5897
+ })
5898
+ })),
5899
+ onChange: operator => updateCondition(index, {
5900
+ operator,
5901
+ value: undefined,
5902
+ flags: undefined
5903
+ })
5904
+ })]
5905
+ }), trigger && condition.operator ? /*#__PURE__*/jsx(ConditionValueInput, {
5906
+ condition: condition,
5907
+ trigger: trigger,
5908
+ onChange: patch => updateCondition(index, patch)
5909
+ }) : null]
5910
+ }), /*#__PURE__*/jsx(Button, {
5911
+ type: "text",
5912
+ danger: true,
5913
+ className: style['icon-square-btn-sm'],
5914
+ icon: /*#__PURE__*/jsx(DeleteOutlined, {}),
5915
+ onClick: () => {
5916
+ const next = conditions.filter((_, itemIndex) => itemIndex !== index);
5917
+ onChange(next.length ? _extends({}, value, {
5918
+ conditions: next
5919
+ }) : undefined);
5920
+ }
5921
+ })]
5922
+ }, index);
5923
+ })
5924
+ }), /*#__PURE__*/jsx(Button, {
5925
+ type: "dashed",
5926
+ block: true,
5927
+ icon: /*#__PURE__*/jsx(PlusOutlined, {}),
5928
+ onClick: () => updateConditions([...conditions, createCondition()]),
5929
+ children: formatMessage({
5930
+ id: 'visibleWhenAddCondition'
5931
+ })
5932
+ })]
5933
+ }) : null]
5934
+ }, "visible-when");
5935
+ return /*#__PURE__*/jsx(FormInfo, {
5936
+ title: formatMessage({
5937
+ id: 'visibleWhenTitle'
5938
+ }),
5939
+ column: 1,
5940
+ list: [body]
5941
+ });
5942
+ };
5943
+ var VisibleWhenEditor$1 = VisibleWhenEditor;
5944
+
5945
+ const _excluded$2 = ["columns"];
4905
5946
  const {
4906
5947
  Text
4907
5948
  } = Typography;
@@ -4917,7 +5958,7 @@ const getDefaultSelectProps = () => ({
4917
5958
  columns: [createEmptyColumn()]
4918
5959
  });
4919
5960
  const omitColumns = (_ref = {}) => {
4920
- let rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
5961
+ let rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
4921
5962
  return rest;
4922
5963
  };
4923
5964
  const FieldConfigFields = ({
@@ -4925,7 +5966,10 @@ const FieldConfigFields = ({
4925
5966
  options,
4926
5967
  onOptionsChange,
4927
5968
  columns,
4928
- onColumnsChange
5969
+ onColumnsChange,
5970
+ visibleWhen,
5971
+ onVisibleWhenChange,
5972
+ conditionProps
4929
5973
  }) => {
4930
5974
  const {
4931
5975
  formatMessage
@@ -5049,13 +6093,17 @@ const FieldConfigFields = ({
5049
6093
  hasColumns: definition.hasColumns,
5050
6094
  columns: columns,
5051
6095
  onColumnsChange: onColumnsChange
5052
- }) : null]
6096
+ }) : null, conditionProps ? /*#__PURE__*/jsx(VisibleWhenEditor$1, _extends({}, conditionProps, {
6097
+ value: visibleWhen,
6098
+ onChange: onVisibleWhenChange
6099
+ })) : null]
5053
6100
  });
5054
6101
  };
5055
6102
  const FieldEditorModal = ({
5056
6103
  open,
5057
6104
  field,
5058
6105
  fieldList,
6106
+ conditionProps,
5059
6107
  onCancel,
5060
6108
  onSave,
5061
6109
  renderModal
@@ -5091,6 +6139,7 @@ const FieldEditorModal = ({
5091
6139
  value: ''
5092
6140
  }]);
5093
6141
  const [columns, setColumns] = useState(() => [createEmptyColumn()]);
6142
+ const [visibleWhen, setVisibleWhen] = useState(undefined);
5094
6143
  useEffect(() => {
5095
6144
  var _editorValues$options, _editorValues$selectP;
5096
6145
  if (!open) {
@@ -5101,15 +6150,23 @@ const FieldEditorModal = ({
5101
6150
  value: ''
5102
6151
  }]);
5103
6152
  setColumns((_editorValues$selectP = editorValues.selectProps) != null && (_editorValues$selectP = _editorValues$selectP.columns) != null && _editorValues$selectP.length ? editorValues.selectProps.columns : [createEmptyColumn()]);
6153
+ setVisibleWhen(editorValues.visibleWhen);
5104
6154
  }, [open, editorValues]);
5105
6155
  const handleSubmit = async values => {
5106
- var _values$lenMin, _values$lenMax;
6156
+ var _conditionProps$scope, _values$lenMin, _values$lenMax;
5107
6157
  if (!isFieldNameUnique(fieldList, values.name, field == null ? void 0 : field.id)) {
5108
6158
  message.error(formatMessage({
5109
6159
  id: 'fieldNameDuplicate'
5110
6160
  }));
5111
6161
  return false;
5112
6162
  }
6163
+ const conditionError = conditionProps && !((_conditionProps$scope = conditionProps.scope) != null && _conditionProps$scope.inList) ? validateVisibleWhenDraft(visibleWhen) : null;
6164
+ if (conditionError) {
6165
+ message.error(formatMessage({
6166
+ id: conditionError
6167
+ }));
6168
+ return false;
6169
+ }
5113
6170
  const definition = getFieldDefinition(values.type);
5114
6171
  const normalizedColumns = definition != null && definition.hasColumns ? normalizeColumns(columns) : [];
5115
6172
  const nextField = formValuesToField(_extends({}, values, {
@@ -5125,12 +6182,13 @@ const FieldEditorModal = ({
5125
6182
  selectProps: _extends({}, values, {
5126
6183
  columns: normalizedColumns
5127
6184
  }),
5128
- fieldProps: values
6185
+ fieldProps: values,
6186
+ visibleWhen
5129
6187
  }), field || createField$1());
5130
6188
  if (!nextField.id) {
5131
6189
  nextField.id = createField$1().id;
5132
6190
  }
5133
- onSave(nextField);
6191
+ return onSave(nextField);
5134
6192
  };
5135
6193
  const modalKey = open ? field != null && field.id ? `edit-${field.id}` : `add-${formData.name}` : 'closed';
5136
6194
  return /*#__PURE__*/jsx(FormModal, _extends({
@@ -5160,7 +6218,12 @@ const FieldEditorModal = ({
5160
6218
  options: options,
5161
6219
  onOptionsChange: setOptions,
5162
6220
  columns: columns,
5163
- onColumnsChange: setColumns
6221
+ onColumnsChange: setColumns,
6222
+ visibleWhen: visibleWhen,
6223
+ onVisibleWhenChange: setVisibleWhen,
6224
+ conditionProps: conditionProps ? _extends({}, conditionProps, {
6225
+ fieldId: field == null ? void 0 : field.id
6226
+ }) : null
5164
6227
  })
5165
6228
  }), modalKey);
5166
6229
  };
@@ -5617,6 +6680,52 @@ const ChoiceBlock = ({
5617
6680
  };
5618
6681
  var ChoiceBlock$1 = ChoiceBlock;
5619
6682
 
6683
+ const _excluded$1 = ["entries", "nested", "knownNames"];
6684
+
6685
+ /**
6686
+ * 按 visibleWhen 过滤字段的 FormInfo:
6687
+ * entries 为 [{ element, path, visibleWhen }],不满足条件的字段从 list 中移除(卸载即不参与校验),
6688
+ * 已有值的隐藏字段清空,避免提交残留
6689
+ */
6690
+ const ConditionalFormInfo = _ref => {
6691
+ let {
6692
+ entries,
6693
+ nested = [],
6694
+ knownNames
6695
+ } = _ref,
6696
+ formInfoProps = _objectWithoutPropertiesLoose(_ref, _excluded$1);
6697
+ const {
6698
+ formData,
6699
+ openApi
6700
+ } = useFormContext() || {};
6701
+ const hasForm = !!openApi;
6702
+ const hiddenPaths = useMemo(() => {
6703
+ if (!hasForm) {
6704
+ return [];
6705
+ }
6706
+ return entries.filter(entry => entry.visibleWhen && !evaluateVisibleWhen(entry.visibleWhen, formData, knownNames)).map(entry => entry.path);
6707
+ }, [entries, formData, knownNames, hasForm]);
6708
+ useEffect(() => {
6709
+ if (!hasForm) {
6710
+ return;
6711
+ }
6712
+ const toClear = hiddenPaths.filter(path => !isEmptyValue$1(getByPath$2(formData, path)));
6713
+ if (toClear.length) {
6714
+ openApi.setFields(toClear.map(name => ({
6715
+ name,
6716
+ value: undefined
6717
+ })), {
6718
+ runValidate: false
6719
+ });
6720
+ }
6721
+ }, [hiddenPaths, formData, openApi, hasForm]);
6722
+ const list = entries.filter(entry => !hiddenPaths.includes(entry.path)).map(entry => entry.element);
6723
+ return /*#__PURE__*/createElement(FormInfo, _extends({}, formInfoProps, {
6724
+ list: [...list, ...nested]
6725
+ }));
6726
+ };
6727
+ var ConditionalFormInfo$1 = ConditionalFormInfo;
6728
+
5620
6729
  // @kne/react-form 内置规则的错误提示写死中文;在 preset 覆盖前记下原函数,只替换未被业务覆盖的规则
5621
6730
  const BUILTIN_RULES = {
5622
6731
  TEL: RULES.TEL,
@@ -5689,18 +6798,18 @@ const buildIndexedLabelRender = index => {
5689
6798
  label
5690
6799
  }) => {
5691
6800
  const text = label != null ? String(label).replace(/\u200b/g, '') : '';
5692
- return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement('span', {
6801
+ return /*#__PURE__*/createElement(Fragment$1, null, /*#__PURE__*/createElement('span', {
5693
6802
  className: style['field-label-index']
5694
6803
  }, `${index + 1}.`), text ? /*#__PURE__*/createElement('span', {
5695
6804
  className: style['field-label-main']
5696
6805
  }, text) : null);
5697
6806
  };
5698
6807
  };
5699
- const renderFieldElements = (fields = [], preview = false, {
6808
+ const renderFieldEntries = (fields = [], preview = false, {
5700
6809
  namePrefix,
5701
6810
  locale,
5702
6811
  showIndex: _showIndex = false
5703
- } = {}) => fields.filter(field => !field.hidden).map((field, index) => {
6812
+ } = {}) => (fields || []).filter(field => !field.hidden).map((field, index) => {
5704
6813
  var _props$options;
5705
6814
  const Component = getFieldComponent(field.type, field);
5706
6815
  if (!Component) {
@@ -5734,7 +6843,7 @@ const renderFieldElements = (fields = [], preview = false, {
5734
6843
  locale
5735
6844
  } : {};
5736
6845
  const label = buildFieldLabel(field);
5737
- return /*#__PURE__*/createElement(Component, _extends({
6846
+ const element = /*#__PURE__*/createElement(Component, _extends({
5738
6847
  key: field.id,
5739
6848
  name: fieldName,
5740
6849
  label: _showIndex ? label || '\u200b' : label
@@ -5747,7 +6856,27 @@ const renderFieldElements = (fields = [], preview = false, {
5747
6856
  labelTips: buildLabelTips(field.tips),
5748
6857
  description
5749
6858
  }));
6859
+ return {
6860
+ element,
6861
+ path: fieldName,
6862
+ visibleWhen: hasVisibleWhen(field) ? field.visibleWhen : null
6863
+ };
5750
6864
  }).filter(Boolean);
6865
+ const renderFieldElements = (fields, preview, opts) => renderFieldEntries(fields, preview, opts).map(entry => entry.element);
6866
+
6867
+ /** 字段含 visibleWhen 时换成 ConditionalFormInfo,否则保持普通 FormInfo */
6868
+ const createFieldsFormInfo = (formInfoProps, entries, nested = [], knownNames) => {
6869
+ if (entries.some(entry => entry.visibleWhen)) {
6870
+ return /*#__PURE__*/createElement(ConditionalFormInfo$1, _extends({}, formInfoProps, {
6871
+ entries,
6872
+ nested,
6873
+ knownNames
6874
+ }));
6875
+ }
6876
+ return /*#__PURE__*/createElement(FormInfo, _extends({}, formInfoProps, {
6877
+ list: [...entries.map(entry => entry.element), ...nested]
6878
+ }));
6879
+ };
5751
6880
  const withBlockLayout = (element, forceBlock) => {
5752
6881
  var _element$props;
5753
6882
  if (!element || !forceBlock) {
@@ -5784,7 +6913,8 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5784
6913
  formatMessage,
5785
6914
  depth = 0,
5786
6915
  asListItem = false,
5787
- locale
6916
+ locale,
6917
+ knownNames
5788
6918
  } = ctx;
5789
6919
  if (!block || depth > MAX_BLOCK_DEPTH) {
5790
6920
  return null;
@@ -5812,39 +6942,37 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5812
6942
  case 'formInfo':
5813
6943
  {
5814
6944
  const showIndex = !!block.showIndex;
5815
- const fields = renderFieldElements(block.list, preview, _extends({}, fieldRenderOpts, {
6945
+ const entries = renderFieldEntries(block.list, preview, _extends({}, fieldRenderOpts, {
5816
6946
  showIndex
5817
6947
  }));
5818
6948
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
5819
- return withBlockLayout(/*#__PURE__*/createElement(FormInfo, _extends({
6949
+ return withBlockLayout(createFieldsFormInfo(_extends({
5820
6950
  key: block.id,
5821
6951
  title: block.title || undefined,
5822
6952
  subtitle: block.subtitle || undefined,
5823
6953
  column: block.column,
5824
6954
  gap: block.gap,
5825
- bordered,
5826
- list: [...fields, ...nested]
6955
+ bordered
5827
6956
  }, listItemPartProps || {}, {
5828
6957
  className: resolvePartRootClassName(depth, showIndex ? style['form-info-show-index'] : null)
5829
- })), asListItem);
6958
+ }), entries, nested, knownNames), asListItem);
5830
6959
  }
5831
6960
  case 'object':
5832
6961
  {
5833
- const fields = renderFieldElements(block.list, preview, _extends({}, fieldRenderOpts, {
6962
+ const entries = renderFieldEntries(block.list, preview, _extends({}, fieldRenderOpts, {
5834
6963
  namePrefix: block.name || ''
5835
6964
  }));
5836
6965
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
5837
- return withBlockLayout(/*#__PURE__*/createElement(FormInfo, _extends({
6966
+ return withBlockLayout(createFieldsFormInfo(_extends({
5838
6967
  key: block.id,
5839
6968
  title: block.title || undefined,
5840
6969
  subtitle: block.subtitle || undefined,
5841
6970
  column: block.column,
5842
6971
  gap: block.gap,
5843
- bordered,
5844
- list: [...fields, ...nested]
6972
+ bordered
5845
6973
  }, listItemPartProps || {}, {
5846
6974
  className: resolvePartRootClassName(depth)
5847
- })), asListItem);
6975
+ }), entries, nested, knownNames), asListItem);
5848
6976
  }
5849
6977
  case 'list':
5850
6978
  {
@@ -5935,24 +7063,24 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5935
7063
  prevIcon: /*#__PURE__*/createElement(ArrowLeftOutlined),
5936
7064
  nextIcon: /*#__PURE__*/createElement(ArrowRightOutlined),
5937
7065
  items: (block.items || []).map(step => {
5938
- const fields = renderFieldElements(step.list, preview, fieldRenderOpts);
7066
+ const entries = renderFieldEntries(step.list, preview, fieldRenderOpts);
5939
7067
  const nested = renderChildBlocks(step.blocks || [], nextCtx);
5940
7068
  const fieldNames = [...(step.list || []).filter(field => field && !field.hidden && field.name).map(field => field.name), ...collectBlockFieldNames(step.blocks || [])];
5941
- if (nested.length) {
7069
+ const hasConditional = entries.some(entry => entry.visibleWhen);
7070
+ if (nested.length || hasConditional) {
5942
7071
  return {
5943
7072
  key: step.id,
5944
7073
  title: step.title,
5945
7074
  column: step.column,
5946
7075
  gap: block.gap,
5947
7076
  fieldNames,
5948
- children: /*#__PURE__*/createElement(Fragment, {
7077
+ children: /*#__PURE__*/createElement(Fragment$1, {
5949
7078
  key: `${step.id}-body`
5950
- }, fields.length ? /*#__PURE__*/createElement(FormInfo, {
7079
+ }, entries.length ? createFieldsFormInfo({
5951
7080
  key: `${step.id}-fields`,
5952
7081
  column: step.column,
5953
- gap: block.gap,
5954
- list: fields
5955
- }) : null, ...nested)
7082
+ gap: block.gap
7083
+ }, entries, [], knownNames) : null, ...nested)
5956
7084
  };
5957
7085
  }
5958
7086
  return {
@@ -5960,7 +7088,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5960
7088
  title: step.title,
5961
7089
  column: step.column,
5962
7090
  gap: block.gap,
5963
- list: fields,
7091
+ list: entries.map(entry => entry.element),
5964
7092
  fieldNames
5965
7093
  };
5966
7094
  })
@@ -5977,12 +7105,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5977
7105
  renderOptionContent: option => {
5978
7106
  const nodes = [];
5979
7107
  if ((option.list || []).length) {
5980
- nodes.push(/*#__PURE__*/createElement(FormInfo, {
7108
+ nodes.push(createFieldsFormInfo({
5981
7109
  key: `${option.id}-fields`,
5982
7110
  column: block.column || 2,
5983
- gap: block.gap,
5984
- list: renderFieldElements(option.list, preview)
5985
- }));
7111
+ gap: block.gap
7112
+ }, renderFieldEntries(option.list, preview), [], knownNames));
5986
7113
  }
5987
7114
  nodes.push(...renderChildBlocks(option.blocks || [], nextCtx));
5988
7115
  return nodes.filter(Boolean);
@@ -6004,10 +7131,12 @@ const renderSchemaInner = (schema, {
6004
7131
  } = {}) => {
6005
7132
  const normalized = normalizeSchema(schema);
6006
7133
  const blocks = normalized.blocks || [];
7134
+ const knownNames = collectTriggerNames(normalized);
6007
7135
  const contentChildren = blocks.map(block => renderBlockElement(block, _preview, {
6008
7136
  isMobile: _isMobile,
6009
7137
  formatMessage,
6010
- locale
7138
+ locale,
7139
+ knownNames
6011
7140
  })).filter(Boolean);
6012
7141
  if (!contentChildren.length && !children && !actionNode) {
6013
7142
  return null;
@@ -6015,7 +7144,7 @@ const renderSchemaInner = (schema, {
6015
7144
  const body = /*#__PURE__*/createElement('div', {
6016
7145
  className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
6017
7146
  }, ...contentChildren, children);
6018
- const content = /*#__PURE__*/createElement(Fragment, null, body, actionNode || null);
7147
+ const content = /*#__PURE__*/createElement(Fragment$1, null, body, actionNode || null);
6019
7148
  return className ? /*#__PURE__*/createElement('div', {
6020
7149
  className
6021
7150
  }, content) : content;
@@ -6033,10 +7162,12 @@ const renderSchemaContent = (schema, {
6033
7162
  } = {}) => {
6034
7163
  const normalized = normalizeSchema(schema);
6035
7164
  const blocks = normalized.blocks || [];
7165
+ const knownNames = collectTriggerNames(normalized);
6036
7166
  const contentChildren = blocks.map(block => renderBlockElement(block, _preview2, {
6037
7167
  isMobile: _isMobile2,
6038
7168
  formatMessage,
6039
- locale
7169
+ locale,
7170
+ knownNames
6040
7171
  })).filter(Boolean);
6041
7172
  if (!contentChildren.length && !children) {
6042
7173
  return null;
@@ -6361,6 +7492,9 @@ const FormCreator = withLocale$1(({
6361
7492
  clearBlockEditor();
6362
7493
  };
6363
7494
  const handleDeleteBlock = blockId => {
7495
+ if (blockHasLockedField(findBlock(schema, blockId))) {
7496
+ return;
7497
+ }
6364
7498
  updateSchema(updateBlocks(schema, blocks => removeBlockInTree(blocks, blockId)));
6365
7499
  };
6366
7500
  const handleMoveBlock = (blockId, direction) => {
@@ -6395,12 +7529,12 @@ const FormCreator = withLocale$1(({
6395
7529
  };
6396
7530
  const handleDeleteStep = (blockId, stepId) => {
6397
7531
  updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
6398
- items: (block.items || []).filter(item => item.id !== stepId)
7532
+ items: (block.items || []).filter(item => item.id !== stepId || blockHasLockedField(item))
6399
7533
  })));
6400
7534
  };
6401
7535
  const handleMoveStep = (blockId, stepId, direction) => {
6402
7536
  updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
6403
- items: moveItem(block.items || [], stepId, direction)
7537
+ items: moveItem(block.items || [], stepId, direction, blockHasLockedField)
6404
7538
  })));
6405
7539
  };
6406
7540
  const handleAddChoiceOption = blockId => {
@@ -6432,12 +7566,12 @@ const FormCreator = withLocale$1(({
6432
7566
  };
6433
7567
  const handleDeleteChoiceOption = (blockId, optionId) => {
6434
7568
  updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
6435
- options: (block.options || []).filter(item => item.id !== optionId)
7569
+ options: (block.options || []).filter(item => item.id !== optionId || blockHasLockedField(item))
6436
7570
  })));
6437
7571
  };
6438
7572
  const handleMoveChoiceOption = (blockId, optionId, direction) => {
6439
7573
  updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
6440
- options: moveItem(block.options || [], optionId, direction)
7574
+ options: moveItem(block.options || [], optionId, direction, blockHasLockedField)
6441
7575
  })));
6442
7576
  };
6443
7577
  const normalizeFieldScope = scope => {
@@ -6456,6 +7590,9 @@ const FormCreator = withLocale$1(({
6456
7590
  setFieldEditorOpen(true);
6457
7591
  };
6458
7592
  const handleEditField = (blockId, field, scope) => {
7593
+ if (isFieldLocked(field)) {
7594
+ return;
7595
+ }
6459
7596
  setFieldContext(_extends({
6460
7597
  blockId
6461
7598
  }, normalizeFieldScope(scope)));
@@ -6468,7 +7605,7 @@ const FormCreator = withLocale$1(({
6468
7605
  stepId,
6469
7606
  optionId
6470
7607
  } = fieldContext || {};
6471
- updateSchema(mapBlocks(schema, blockId, block => {
7608
+ let nextSchema = mapBlocks(schema, blockId, block => {
6472
7609
  if (block.kind === 'steps') {
6473
7610
  return _extends({}, block, {
6474
7611
  items: (block.items || []).map(step => {
@@ -6499,7 +7636,21 @@ const FormCreator = withLocale$1(({
6499
7636
  return _extends({}, block, {
6500
7637
  list: exists ? block.list.map(item => item.id === field.id ? field : item) : [...(block.list || []), field]
6501
7638
  });
6502
- }));
7639
+ });
7640
+ if (editingField != null && editingField.name && editingField.name !== field.name) {
7641
+ const scope = getBlockConditionScope(schema, blockId);
7642
+ nextSchema = renameConditionReferences(nextSchema, getFieldConditionPath(scope, editingField.name), getFieldConditionPath(scope, field.name));
7643
+ }
7644
+ const cycle = findConditionCycle(nextSchema);
7645
+ if (cycle) {
7646
+ message.error(formatMessage({
7647
+ id: 'visibleWhenCycle'
7648
+ }, {
7649
+ path: cycle.join(' → ')
7650
+ }));
7651
+ return false;
7652
+ }
7653
+ updateSchema(nextSchema);
6503
7654
  setFieldEditorOpen(false);
6504
7655
  setFieldContext(null);
6505
7656
  setEditingField(null);
@@ -6513,19 +7664,19 @@ const FormCreator = withLocale$1(({
6513
7664
  if (block.kind === 'steps') {
6514
7665
  return _extends({}, block, {
6515
7666
  items: (block.items || []).map(step => step.id === stepId ? _extends({}, step, {
6516
- list: (step.list || []).filter(item => item.id !== fieldId)
7667
+ list: (step.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6517
7668
  }) : step)
6518
7669
  });
6519
7670
  }
6520
7671
  if (block.kind === 'choice') {
6521
7672
  return _extends({}, block, {
6522
7673
  options: (block.options || []).map(option => option.id === optionId ? _extends({}, option, {
6523
- list: (option.list || []).filter(item => item.id !== fieldId)
7674
+ list: (option.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6524
7675
  }) : option)
6525
7676
  });
6526
7677
  }
6527
7678
  return _extends({}, block, {
6528
- list: (block.list || []).filter(item => item.id !== fieldId)
7679
+ list: (block.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6529
7680
  });
6530
7681
  }));
6531
7682
  };
@@ -6559,6 +7710,11 @@ const FormCreator = withLocale$1(({
6559
7710
  stepId: fieldContext.stepId,
6560
7711
  optionId: fieldContext.optionId
6561
7712
  }) : [];
7713
+ const conditionProps = useMemo(() => fieldContext ? {
7714
+ schema,
7715
+ scope: getBlockConditionScope(schema, fieldContext.blockId),
7716
+ triggerFields: collectConditionFields(schema).filter(item => !item.inList)
7717
+ } : null, [schema, fieldContext]);
6562
7718
  const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
6563
7719
  schema
6564
7720
  }) : extraToolbar;
@@ -6634,6 +7790,7 @@ const FormCreator = withLocale$1(({
6634
7790
  open: fieldEditorOpen,
6635
7791
  field: editingField,
6636
7792
  fieldList: currentFieldScope,
7793
+ conditionProps: conditionProps,
6637
7794
  renderModal: renderModal,
6638
7795
  onCancel: () => {
6639
7796
  setFieldEditorOpen(false);
@@ -6970,7 +8127,7 @@ const formatDateToToday = (value, itemSchema, ctx) => {
6970
8127
  if (items[1] == null || items[1] === '' || items[1] === true) {
6971
8128
  const until = (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
6972
8129
  id: 'schemaContentUntilToday'
6973
- })) || defaultLocale.schemaContentUntilToday;
8130
+ })) || zhCN.schemaContentUntilToday;
6974
8131
  return [start, until].filter(Boolean).join(' ~ ');
6975
8132
  }
6976
8133
  const end = formatByValueSchema(items[1], itemSchema, ctx);
@@ -7025,11 +8182,11 @@ const formatBoolean = (value, field, ctx) => {
7025
8182
  if (value) {
7026
8183
  return props.checkedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
7027
8184
  id: 'schemaContentYes'
7028
- })) || defaultLocale.schemaContentYes;
8185
+ })) || zhCN.schemaContentYes;
7029
8186
  }
7030
8187
  return props.unCheckedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
7031
8188
  id: 'schemaContentNo'
7032
- })) || defaultLocale.schemaContentNo;
8189
+ })) || zhCN.schemaContentNo;
7033
8190
  };
7034
8191
  const stringifyFallback = value => {
7035
8192
  if (value == null) {
@@ -7249,8 +8406,43 @@ const resolveChoiceSelectorName$1 = block => {
7249
8406
  }
7250
8407
  return `__choice_${block.id}`;
7251
8408
  };
8409
+
8410
+ /** 条件说明文案:按 options.locale 取包内语言包,英文以外回退中文 */
8411
+ const createConditionContext = (normalized, locale) => {
8412
+ const messages = String(locale || '').startsWith('en') ? enUS : zhCN;
8413
+ const formatMessage = ({
8414
+ id
8415
+ }, values = {}) => {
8416
+ var _messages$id;
8417
+ return String((_messages$id = messages[id]) != null ? _messages$id : id).replace(/\{(\w+)\}/g, (match, key) => values[key] != null ? values[key] : match);
8418
+ };
8419
+ const conditionFields = collectConditionFields(normalized).filter(item => !item.inList);
8420
+ return {
8421
+ formatMessage,
8422
+ knownNames: new Set(conditionFields.map(item => item.path)),
8423
+ fieldLookup: new Map(conditionFields.map(item => [item.path, item.field]))
8424
+ };
8425
+ };
8426
+ const describeVisibleWhen = (field, ctx) => {
8427
+ const visibleWhen = _extends({}, field.visibleWhen, {
8428
+ conditions: field.visibleWhen.conditions.filter(condition => ctx.knownNames.has(condition == null ? void 0 : condition.field))
8429
+ });
8430
+ if (!visibleWhen.conditions.length) {
8431
+ return '';
8432
+ }
8433
+ const condition = formatVisibleWhen(visibleWhen, {
8434
+ formatMessage: ctx.formatMessage,
8435
+ fieldLookup: ctx.fieldLookup
8436
+ });
8437
+ return ctx.formatMessage({
8438
+ id: 'conditionDescription'
8439
+ }, {
8440
+ condition
8441
+ });
8442
+ };
7252
8443
  const mergeFieldIntoLayer = (layer, field, {
7253
- allowRequired: _allowRequired = true
8444
+ allowRequired: _allowRequired = true,
8445
+ ctx
7254
8446
  } = {}) => {
7255
8447
  if (!(field != null && field.name)) {
7256
8448
  return;
@@ -7259,8 +8451,14 @@ const mergeFieldIntoLayer = (layer, field, {
7259
8451
  if (!name) {
7260
8452
  return;
7261
8453
  }
7262
- layer.properties[name] = resolveFieldValueSchema(field);
7263
- if (_allowRequired && isReq(field.rule) && !layer.required.includes(name)) {
8454
+ const valueSchema = resolveFieldValueSchema(field);
8455
+ const conditionText = ctx != null && ctx.formatMessage && hasVisibleWhen(field) ? describeVisibleWhen(field, ctx) : '';
8456
+ if (conditionText) {
8457
+ valueSchema.description = valueSchema.description ? `${valueSchema.description}\n${conditionText}` : conditionText;
8458
+ }
8459
+ layer.properties[name] = valueSchema;
8460
+ // 条件显示字段可能不出现在提交数据中,不进 required
8461
+ if (_allowRequired && !conditionText && isReq(field.rule) && !layer.required.includes(name)) {
7264
8462
  layer.required.push(name);
7265
8463
  }
7266
8464
  };
@@ -7302,33 +8500,39 @@ const finalizeObjectSchema = (layer, {
7302
8500
  }
7303
8501
  return schema;
7304
8502
  };
7305
- const walkBlocks = (blocks, layer, depth = 0) => {
8503
+ const walkBlocks = (blocks, layer, depth = 0, ctx = {}) => {
7306
8504
  (blocks || []).forEach(block => {
7307
8505
  if (!block) {
7308
8506
  return;
7309
8507
  }
7310
- walkBlock(block, layer, depth);
8508
+ walkBlock(block, layer, depth, ctx);
7311
8509
  });
7312
8510
  };
7313
- const walkBlock = (block, layer, depth = 0) => {
8511
+ const walkBlock = (block, layer, depth = 0, ctx = {}) => {
7314
8512
  switch (block.kind) {
7315
8513
  case 'formInfo':
7316
8514
  {
7317
- mergeFieldsIntoLayer(layer, block.list);
7318
- walkBlocks(block.blocks, layer, depth + 1);
8515
+ mergeFieldsIntoLayer(layer, block.list, {
8516
+ ctx
8517
+ });
8518
+ walkBlocks(block.blocks, layer, depth + 1, ctx);
7319
8519
  return;
7320
8520
  }
7321
8521
  case 'object':
7322
8522
  {
7323
8523
  const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
7324
8524
  if (!name) {
7325
- mergeFieldsIntoLayer(layer, block.list);
7326
- walkBlocks(block.blocks, layer, depth + 1);
8525
+ mergeFieldsIntoLayer(layer, block.list, {
8526
+ ctx
8527
+ });
8528
+ walkBlocks(block.blocks, layer, depth + 1, ctx);
7327
8529
  return;
7328
8530
  }
7329
8531
  const nested = createObjectLayer();
7330
- mergeFieldsIntoLayer(nested, block.list);
7331
- walkBlocks(block.blocks, nested, depth + 1);
8532
+ mergeFieldsIntoLayer(nested, block.list, {
8533
+ ctx
8534
+ });
8535
+ walkBlocks(block.blocks, nested, depth + 1, ctx);
7332
8536
  layer.properties[name] = finalizeObjectSchema(nested, {
7333
8537
  title: block.title || undefined,
7334
8538
  description: block.subtitle || undefined
@@ -7391,14 +8595,16 @@ const walkBlock = (block, layer, depth = 0) => {
7391
8595
  case 'steps':
7392
8596
  {
7393
8597
  (block.items || []).forEach(step => {
7394
- mergeFieldsIntoLayer(layer, step == null ? void 0 : step.list);
7395
- walkBlocks(step == null ? void 0 : step.blocks, layer, depth + 1);
8598
+ mergeFieldsIntoLayer(layer, step == null ? void 0 : step.list, {
8599
+ ctx
8600
+ });
8601
+ walkBlocks(step == null ? void 0 : step.blocks, layer, depth + 1, ctx);
7396
8602
  });
7397
8603
  return;
7398
8604
  }
7399
8605
  case 'choice':
7400
8606
  {
7401
- mergeChoiceIntoLayer(layer, block, depth);
8607
+ mergeChoiceIntoLayer(layer, block, depth, ctx);
7402
8608
  return;
7403
8609
  }
7404
8610
  default:
@@ -7411,7 +8617,7 @@ const walkBlock = (block, layer, depth = 0) => {
7411
8617
  * 每支为 object:单选支含 selector const;多选支为该 option 字段,selector 数组放在当前层。
7412
8618
  * 支内 REQ 可进 required;hidden 字段仍进入 schema。
7413
8619
  */
7414
- const mergeChoiceIntoLayer = (layer, block, depth) => {
8620
+ const mergeChoiceIntoLayer = (layer, block, depth, ctx) => {
7415
8621
  const mode = block.mode === 'multiple' ? 'multiple' : 'single';
7416
8622
  const selectorInData = block.selectorInData !== false;
7417
8623
  const selectorName = resolveChoiceSelectorName$1(block);
@@ -7429,9 +8635,10 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
7429
8635
  branch.required.push(selectorName);
7430
8636
  }
7431
8637
  mergeFieldsIntoLayer(branch, option.list, {
7432
- allowRequired: true
8638
+ allowRequired: true,
8639
+ ctx
7433
8640
  });
7434
- walkBlocks(option.blocks, branch, depth + 1);
8641
+ walkBlocks(option.blocks, branch, depth + 1, ctx);
7435
8642
  return finalizeObjectSchema(branch, {
7436
8643
  title: optionTitle
7437
8644
  });
@@ -7512,7 +8719,7 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
7512
8719
  const schemaToDataSchema = (schema, options = {}) => {
7513
8720
  const normalized = normalizeSchema(localizeSchema(schema || {}, options.locale, options.languages));
7514
8721
  const layer = createObjectLayer();
7515
- walkBlocks(normalized.blocks, layer, 0);
8722
+ walkBlocks(normalized.blocks, layer, 0, createConditionContext(normalized, options.locale));
7516
8723
  const root = finalizeObjectSchema(layer, {
7517
8724
  title: normalized.title || undefined,
7518
8725
  description: options.description
@@ -7548,9 +8755,10 @@ const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValu
7548
8755
  * 改为 label 在上、值在下,避免窄栏(如弹窗双栏预览)被撑乱。
7549
8756
  */
7550
8757
  const renderFieldsContent = (fields, data, formatMessage, column, {
7551
- showIndex: _showIndex = false
8758
+ showIndex: _showIndex = false,
8759
+ isFieldVisible
7552
8760
  } = {}) => {
7553
- const list = (fields || []).filter(field => field && !field.hidden && field.name).map((field, index) => {
8761
+ const list = (fields || []).filter(field => field && !field.hidden && field.name && (!isFieldVisible || isFieldVisible(field))).map((field, index) => {
7554
8762
  const baseLabel = field.label || field.name;
7555
8763
  const label = _showIndex ? `${index + 1}. ${baseLabel}` : baseLabel;
7556
8764
  return {
@@ -7585,7 +8793,8 @@ const renderBlock = (block, data, ctx) => {
7585
8793
  const {
7586
8794
  formatMessage,
7587
8795
  isMobile,
7588
- depth = 0
8796
+ depth = 0,
8797
+ isFieldVisible
7589
8798
  } = ctx;
7590
8799
  if (!block || depth > MAX_BLOCK_DEPTH) {
7591
8800
  return null;
@@ -7606,7 +8815,8 @@ const renderBlock = (block, data, ctx) => {
7606
8815
  {
7607
8816
  return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
7608
8817
  children: [renderFieldsContent(block.list, data, formatMessage, block.column, {
7609
- showIndex: !!block.showIndex
8818
+ showIndex: !!block.showIndex,
8819
+ isFieldVisible
7610
8820
  }), renderBlockList(block.blocks, data, nextCtx)]
7611
8821
  }));
7612
8822
  }
@@ -7615,7 +8825,9 @@ const renderBlock = (block, data, ctx) => {
7615
8825
  const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
7616
8826
  const nestedData = name ? getByPath(data, name) || {} : data;
7617
8827
  return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
7618
- children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column), renderBlockList(block.blocks, nestedData, nextCtx)]
8828
+ children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column, {
8829
+ isFieldVisible
8830
+ }), renderBlockList(block.blocks, nestedData, nextCtx)]
7619
8831
  }));
7620
8832
  }
7621
8833
  case 'list':
@@ -7670,11 +8882,13 @@ const renderBlock = (block, data, ctx) => {
7670
8882
  }
7671
8883
  case 'steps':
7672
8884
  {
7673
- return /*#__PURE__*/jsx(Fragment, {
8885
+ return /*#__PURE__*/jsx(Fragment$1, {
7674
8886
  children: (block.items || []).map(step => /*#__PURE__*/jsxs(InfoPage.Part, {
7675
8887
  title: step.title || undefined,
7676
8888
  bordered: bordered,
7677
- children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2), renderBlockList(step.blocks, data, nextCtx)]
8889
+ children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2, {
8890
+ isFieldVisible
8891
+ }), renderBlockList(step.blocks, data, nextCtx)]
7678
8892
  }, step.id))
7679
8893
  }, block.id);
7680
8894
  }
@@ -7689,7 +8903,9 @@ const renderBlock = (block, data, ctx) => {
7689
8903
  children: visibleOptions.map(option => /*#__PURE__*/jsxs(InfoPage.Part, {
7690
8904
  title: option.title || undefined,
7691
8905
  bordered: false,
7692
- children: [renderFieldsContent(option.list, data, formatMessage, block.column), renderBlockList(option.blocks, data, nextCtx)]
8906
+ children: [renderFieldsContent(option.list, data, formatMessage, block.column, {
8907
+ isFieldVisible
8908
+ }), renderBlockList(option.blocks, data, nextCtx)]
7693
8909
  }, option.id))
7694
8910
  }));
7695
8911
  }
@@ -7709,10 +8925,15 @@ const SchemaContentInnerView = ({
7709
8925
  } = useIntl();
7710
8926
  const isMobile = useIsMobile();
7711
8927
  const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
7712
- const children = renderBlockList(normalized.blocks, data || {}, {
8928
+ const rootData = data || {};
8929
+ const knownNames = collectTriggerNames(normalized);
8930
+ // 条件按提交数据根路径判断(object 内字段同样用完整路径)
8931
+ const isFieldVisible = field => evaluateVisibleWhen(field.visibleWhen, rootData, knownNames);
8932
+ const children = renderBlockList(normalized.blocks, rootData, {
7713
8933
  formatMessage,
7714
8934
  isMobile,
7715
- depth: 0
8935
+ depth: 0,
8936
+ isFieldVisible
7716
8937
  });
7717
8938
  if (!children.length) {
7718
8939
  return null;
@@ -7723,7 +8944,7 @@ const SchemaContentInnerView = ({
7723
8944
  children: children
7724
8945
  });
7725
8946
  }
7726
- return /*#__PURE__*/jsx(Fragment, {
8947
+ return /*#__PURE__*/jsx(Fragment$1, {
7727
8948
  children: children
7728
8949
  });
7729
8950
  };
@@ -7759,5 +8980,5 @@ const SchemaContent = withLocale$1(({
7759
8980
  });
7760
8981
  var SchemaContent$1 = SchemaContent;
7761
8982
 
7762
- export { FormCreator$1 as FormCreator, LocaleInput, LocaleTextArea, LocaleTextControl, LocaleTextProvider, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaContent$1 as SchemaContent, SchemaContentInner, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectBlockFieldNames, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, findBlockInTree, formValuesToBlock, formValuesToField, formatByValueSchema, formatFieldDisplayValue, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasLocaleText, hasRenderableContent, isFieldNameUnique, isLocaleText, localizeSchema, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, registerField, removeBlockInTree, resolveFieldTypeLabel, resolveFieldValueSchema, resolveLocaleText, schemaToDataSchema, updateBlocks };
8983
+ export { CONDITION_OPERATORS, FormCreator$1 as FormCreator, LocaleInput, LocaleTextArea, LocaleTextControl, LocaleTextProvider, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaContent$1 as SchemaContent, SchemaContentInner, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockHasLockedField, blockToFormValues, buildRuleString, collectBlockFieldNames, collectConditionFields, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, evaluateCondition, evaluateVisibleWhen, fieldToFormValues, findBlock, findBlockInTree, findConditionCycle, formValuesToBlock, formValuesToField, formatByValueSchema, formatFieldDisplayValue, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasLocaleText, hasRenderableContent, hasVisibleWhen, isFieldLocked, isFieldNameUnique, isLocaleText, localizeSchema, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, registerField, removeBlockInTree, renameConditionReferences, resolveFieldTypeLabel, resolveFieldValueSchema, resolveLocaleText, schemaToDataSchema, updateBlocks };
7763
8984
  //# sourceMappingURL=index.modern.js.map