@kne/form-creator 0.1.24 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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","visible-when-editor":"kne-form-creator_ttGnB","visible-when-hint":"kne-form-creator_hPtdv","visible-when-list":"kne-form-creator_aoAt6","visible-when-row":"kne-form-creator_phRgr","visible-when-row-main":"kne-form-creator_l-J7d","visible-when-field":"kne-form-creator_YRh5W","visible-when-operator":"kne-form-creator_DIqFq","visible-when-value":"kne-form-creator_CHcia","visible-when-regex":"kne-form-creator_lKpVo","visible-when-flags":"kne-form-creator_Ps-cu","visible-when-regex-tester":"kne-form-creator_Wf4eG","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","locale-text":"kne-form-creator_hMXkE","is-compact":"kne-form-creator_jBFpL","locale-text-item":"kne-form-creator_NqCQD","locale-text-prefix":"kne-form-creator_BQl2X","options-locale-text":"kne-form-creator_7-99l","locale-text-tag":"kne-form-creator_65OWA","is-mobile":"kne-form-creator_LtgJz"};
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: '未命名填写项',
@@ -284,9 +286,51 @@ const locale$1 = {
284
286
  ruleErrorLenEqual: '%s长度必须等于{end}',
285
287
  ruleErrorLenMin: '%s长度必须大于{start}',
286
288
  ruleErrorLenMax: '%s长度必须小于{end}',
287
- localeTextFallback: '留空时使用{language}'
288
- };
289
- var defaultLocale = locale$1;
289
+ localeTextFallback: '留空时使用{language}',
290
+ visibleWhenTitle: '条件显示',
291
+ visibleWhenEnable: '满足条件时才显示',
292
+ visibleWhenEnableTips: '不满足条件时隐藏该填写项,并清空其已填写的值',
293
+ visibleWhenLogic: '满足方式',
294
+ conditionLogic_and: '全部满足',
295
+ conditionLogic_or: '满足任一',
296
+ visibleWhenAddCondition: '添加条件',
297
+ visibleWhenField: '触发填写项',
298
+ visibleWhenOperator: '判断',
299
+ visibleWhenValue: '值',
300
+ visibleWhenNoTrigger: '暂无可作为条件的填写项(列表类模块中的填写项不支持)',
301
+ visibleWhenListUnsupported: '列表类模块中的填写项不支持条件显示',
302
+ visibleWhenRegexInvalid: '正则表达式无效',
303
+ visibleWhenRegexFlags: '修饰符',
304
+ visibleWhenRegexFlag_i: 'i 忽略大小写',
305
+ visibleWhenRegexFlag_m: 'm 多行',
306
+ visibleWhenRegexFlag_s: 's 点号匹配换行',
307
+ visibleWhenRegexFlag_u: 'u Unicode',
308
+ visibleWhenRegexTester: '测试文本',
309
+ visibleWhenRegexMatched: '匹配',
310
+ visibleWhenRegexNotMatched: '不匹配',
311
+ visibleWhenConditionRequired: '请完善条件:选择触发填写项并填写值',
312
+ visibleWhenCycle: '条件形成循环依赖:{path}',
313
+ fieldConditionTag: '条件显示',
314
+ fieldConditionInvalidTag: '条件失效',
315
+ fieldConditionInvalidTips: '条件引用的填写项已不存在或不可用,该条件被忽略',
316
+ conditionOperator_eq: '等于',
317
+ conditionOperator_neq: '不等于',
318
+ conditionOperator_in: '属于其一',
319
+ conditionOperator_includesAny: '包含任一',
320
+ conditionOperator_empty: '为空',
321
+ conditionOperator_notEmpty: '不为空',
322
+ conditionOperator_gt: '大于',
323
+ conditionOperator_gte: '大于等于',
324
+ conditionOperator_lt: '小于',
325
+ conditionOperator_lte: '小于等于',
326
+ conditionOperator_regex: '匹配正则',
327
+ conditionJoinAnd: ' 且 ',
328
+ conditionJoinOr: ' 或 ',
329
+ conditionValueTrue: '是',
330
+ conditionValueFalse: '否',
331
+ conditionDescription: '满足条件时显示:{condition}'
332
+ };
333
+ var zhCN = locale$1;
290
334
 
291
335
  const locale = {
292
336
  addField: 'Add Field',
@@ -423,6 +467,8 @@ const locale = {
423
467
  fieldBlock: 'Full Width',
424
468
  fieldHidden: 'Hidden',
425
469
  fieldHiddenTag: 'Hidden',
470
+ fieldLockedTag: 'Locked',
471
+ fieldLockedTips: 'Locked field: cannot be edited, deleted or moved',
426
472
  fieldBlockTag: 'Full Width',
427
473
  fieldNameDuplicate: 'This name is already in use, please choose another',
428
474
  untitledField: 'Untitled Field',
@@ -534,14 +580,56 @@ const locale = {
534
580
  ruleErrorLenEqual: '%s must be exactly {end} characters',
535
581
  ruleErrorLenMin: '%s must be at least {start} characters',
536
582
  ruleErrorLenMax: '%s must be at most {end} characters',
537
- localeTextFallback: 'Falls back to {language} when empty'
583
+ localeTextFallback: 'Falls back to {language} when empty',
584
+ visibleWhenTitle: 'Conditional display',
585
+ visibleWhenEnable: 'Show only when conditions are met',
586
+ visibleWhenEnableTips: 'The field is hidden and its value cleared when conditions are not met',
587
+ visibleWhenLogic: 'Match',
588
+ conditionLogic_and: 'All conditions',
589
+ conditionLogic_or: 'Any condition',
590
+ visibleWhenAddCondition: 'Add condition',
591
+ visibleWhenField: 'Trigger field',
592
+ visibleWhenOperator: 'Operator',
593
+ visibleWhenValue: 'Value',
594
+ visibleWhenNoTrigger: 'No field can be used as a condition (fields inside list blocks are not supported)',
595
+ visibleWhenListUnsupported: 'Fields inside list blocks do not support conditional display',
596
+ visibleWhenRegexInvalid: 'Invalid regular expression',
597
+ visibleWhenRegexFlags: 'Flags',
598
+ visibleWhenRegexFlag_i: 'i ignore case',
599
+ visibleWhenRegexFlag_m: 'm multiline',
600
+ visibleWhenRegexFlag_s: 's dot matches newline',
601
+ visibleWhenRegexFlag_u: 'u Unicode',
602
+ visibleWhenRegexTester: 'Test text',
603
+ visibleWhenRegexMatched: 'Matched',
604
+ visibleWhenRegexNotMatched: 'Not matched',
605
+ visibleWhenConditionRequired: 'Complete each condition: choose a trigger field and fill in the value',
606
+ visibleWhenCycle: 'Conditions form a circular dependency: {path}',
607
+ fieldConditionTag: 'Conditional',
608
+ fieldConditionInvalidTag: 'Condition invalid',
609
+ fieldConditionInvalidTips: 'A referenced field no longer exists or is unavailable; that condition is ignored',
610
+ conditionOperator_eq: 'equals',
611
+ conditionOperator_neq: 'does not equal',
612
+ conditionOperator_in: 'is one of',
613
+ conditionOperator_includesAny: 'includes any of',
614
+ conditionOperator_empty: 'is empty',
615
+ conditionOperator_notEmpty: 'is not empty',
616
+ conditionOperator_gt: '>',
617
+ conditionOperator_gte: '>=',
618
+ conditionOperator_lt: '<',
619
+ conditionOperator_lte: '<=',
620
+ conditionOperator_regex: 'matches',
621
+ conditionJoinAnd: ' and ',
622
+ conditionJoinOr: ' or ',
623
+ conditionValueTrue: 'Yes',
624
+ conditionValueFalse: 'No',
625
+ conditionDescription: 'Shown when: {condition}'
538
626
  };
539
627
  var enUS = locale;
540
628
 
541
629
  const withLocale = createWithIntlProvider({
542
630
  defaultLocale: 'zh-CN',
543
631
  messages: {
544
- 'zh-CN': defaultLocale,
632
+ 'zh-CN': zhCN,
545
633
  'en-US': enUS
546
634
  },
547
635
  namespace: 'form-creator'
@@ -964,7 +1052,23 @@ const normalizeSchema = (schema = {}) => {
964
1052
  blocks: []
965
1053
  });
966
1054
  };
967
- const moveItem = (list, id, direction) => {
1055
+ const isFieldLocked = field => !!(field != null && field.locked);
1056
+ const blockHasLockedField = block => {
1057
+ if (!block) {
1058
+ return false;
1059
+ }
1060
+ if ((block.list || []).some(isFieldLocked)) {
1061
+ return true;
1062
+ }
1063
+ const groups = [...(block.items || []), ...(block.options || [])];
1064
+ if (groups.some(group => (group.list || []).some(isFieldLocked) || (group.blocks || []).some(blockHasLockedField))) {
1065
+ return true;
1066
+ }
1067
+ return [...(block.blocks || []), ...(block.itemBlocks || [])].some(blockHasLockedField);
1068
+ };
1069
+
1070
+ // 锁定项(locked 字段 / 含锁定字段的模块)位置固定:自身不能移动,其他项也不能与其交换位置
1071
+ const moveItem = (list, id, direction, isFixed = isFieldLocked) => {
968
1072
  const index = list.findIndex(item => item.id === id);
969
1073
  if (index < 0) {
970
1074
  return list;
@@ -973,6 +1077,9 @@ const moveItem = (list, id, direction) => {
973
1077
  if (targetIndex < 0 || targetIndex >= list.length) {
974
1078
  return list;
975
1079
  }
1080
+ if (isFixed(list[index]) || isFixed(list[targetIndex])) {
1081
+ return list;
1082
+ }
976
1083
  const next = [...list];
977
1084
  const [item] = next.splice(index, 1);
978
1085
  next.splice(targetIndex, 0, item);
@@ -1277,7 +1384,7 @@ const removeBlockInTree = (blocks, blockId) => {
1277
1384
  };
1278
1385
  const moveBlockInTree = (blocks, blockId, direction) => {
1279
1386
  if ((blocks || []).some(block => (block == null ? void 0 : block.id) === blockId)) {
1280
- return moveItem(blocks, blockId, direction);
1387
+ return moveItem(blocks, blockId, direction, blockHasLockedField);
1281
1388
  }
1282
1389
  let changed = false;
1283
1390
  const next = (blocks || []).map(block => {
@@ -1458,7 +1565,7 @@ const formValuesToChoiceOption = (values, existingOption = {}) => _extends({}, e
1458
1565
  title: values.title
1459
1566
  });
1460
1567
 
1461
- const _excluded$4 = ["children"];
1568
+ const _excluded$5 = ["children"];
1462
1569
  const mapOptionItem = item => {
1463
1570
  if (!item || typeof item !== 'object') {
1464
1571
  return item;
@@ -1466,7 +1573,7 @@ const mapOptionItem = item => {
1466
1573
  const {
1467
1574
  children
1468
1575
  } = item,
1469
- rest = _objectWithoutPropertiesLoose(item, _excluded$4);
1576
+ rest = _objectWithoutPropertiesLoose(item, _excluded$5);
1470
1577
  const next = _extends({}, rest);
1471
1578
  if (Array.isArray(children) && children.length) {
1472
1579
  next.children = children.map(mapOptionItem);
@@ -1554,7 +1661,7 @@ const createApiFromOptions = (options = []) => ({
1554
1661
  })
1555
1662
  });
1556
1663
 
1557
- const _excluded$3 = ["options", "api", "placeholder"];
1664
+ const _excluded$4 = ["options", "api", "placeholder"];
1558
1665
  const {
1559
1666
  useOnChange: useOnChange$2
1560
1667
  } = hooks;
@@ -1573,7 +1680,7 @@ const createField = (Component, {
1573
1680
  api,
1574
1681
  placeholder
1575
1682
  } = props,
1576
- rest = _objectWithoutPropertiesLoose(props, _excluded$3);
1683
+ rest = _objectWithoutPropertiesLoose(props, _excluded$4);
1577
1684
  const valueKey = rest.valueKey || 'value';
1578
1685
  const labelKey = rest.labelKey || 'label';
1579
1686
  const parentKey = rest.parentKey || 'parentId';
@@ -1696,6 +1803,439 @@ const buildRuleString = ({
1696
1803
  return parts.join(' ') || undefined;
1697
1804
  };
1698
1805
 
1806
+ const CONDITION_OPERATORS = ['eq', 'neq', 'in', 'includesAny', 'empty', 'notEmpty', 'gt', 'gte', 'lt', 'lte', 'regex'];
1807
+ const NO_VALUE_OPERATORS = ['empty', 'notEmpty'];
1808
+ const ALLOWED_REGEX_FLAGS = ['i', 'm', 's', 'u'];
1809
+
1810
+ // 列表类模块内的字段会重复出现,单个 name 定位不到具体条目,不参与条件
1811
+ const LIST_BLOCK_KINDS = ['list', 'tableList', 'editableList', 'multiField'];
1812
+ const getByPath$2 = (data, path) => {
1813
+ if (data == null || path == null || path === '') {
1814
+ return undefined;
1815
+ }
1816
+ return String(path).split('.').reduce((current, key) => current == null ? undefined : current[key], data);
1817
+ };
1818
+ const isEmptyValue$1 = value => value === undefined || value === null || value === '' || Array.isArray(value) && value.length === 0;
1819
+
1820
+ // SuperSelect 等字段的值是 { label, value } 对象,比较时统一取 value
1821
+ const toComparable = item => {
1822
+ if (item && typeof item === 'object' && !Array.isArray(item)) {
1823
+ var _ref, _ref2, _item$value;
1824
+ return (_ref = (_ref2 = (_item$value = item.value) != null ? _item$value : item.id) != null ? _ref2 : item.key) != null ? _ref : item;
1825
+ }
1826
+ return item;
1827
+ };
1828
+ const toArray = value => Array.isArray(value) ? value : isEmptyValue$1(value) ? [] : [value];
1829
+ const sameValue = (a, b) => String(toComparable(a)) === String(toComparable(b));
1830
+ const sanitizeRegexFlags = flags => Array.from(new Set(String(flags || '').split(''))).filter(flag => ALLOWED_REGEX_FLAGS.includes(flag)).join('');
1831
+ const regexCache = new Map();
1832
+
1833
+ /** 编译失败返回 null;以「源码 + flags」缓存 */
1834
+ const compileConditionRegex = (source, flags) => {
1835
+ if (source == null || String(source) === '') {
1836
+ return null;
1837
+ }
1838
+ const safeFlags = sanitizeRegexFlags(flags);
1839
+ const key = `${safeFlags}/${source}`;
1840
+ if (regexCache.has(key)) {
1841
+ return regexCache.get(key);
1842
+ }
1843
+ let regex = null;
1844
+ try {
1845
+ regex = new RegExp(String(source), safeFlags);
1846
+ } catch (error) {
1847
+ regex = null;
1848
+ }
1849
+ regexCache.set(key, regex);
1850
+ return regex;
1851
+ };
1852
+ const toNumber = value => {
1853
+ if (isEmptyValue$1(value) || typeof value === 'boolean') {
1854
+ return NaN;
1855
+ }
1856
+ return Number(value);
1857
+ };
1858
+
1859
+ /**
1860
+ * 返回 true / false;条件本身无效(未知运算符、正则无法编译)时返回 null,由调用方忽略
1861
+ */
1862
+ const evaluateCondition = (condition, formData) => {
1863
+ if (!(condition != null && condition.field) || !CONDITION_OPERATORS.includes(condition.operator)) {
1864
+ return null;
1865
+ }
1866
+ const actual = getByPath$2(formData, condition.field);
1867
+ const expected = condition.value;
1868
+ switch (condition.operator) {
1869
+ case 'empty':
1870
+ return isEmptyValue$1(actual);
1871
+ case 'notEmpty':
1872
+ return !isEmptyValue$1(actual);
1873
+ case 'eq':
1874
+ return !isEmptyValue$1(actual) && !Array.isArray(actual) && sameValue(actual, expected);
1875
+ case 'neq':
1876
+ return isEmptyValue$1(actual) || Array.isArray(actual) || !sameValue(actual, expected);
1877
+ case 'in':
1878
+ return !isEmptyValue$1(actual) && toArray(expected).some(item => sameValue(actual, item));
1879
+ case 'includesAny':
1880
+ {
1881
+ const expectedList = toArray(expected);
1882
+ return toArray(actual).some(item => expectedList.some(target => sameValue(item, target)));
1883
+ }
1884
+ case 'gt':
1885
+ case 'gte':
1886
+ case 'lt':
1887
+ case 'lte':
1888
+ {
1889
+ const a = toNumber(actual);
1890
+ const b = toNumber(expected);
1891
+ if (!Number.isFinite(a) || !Number.isFinite(b)) {
1892
+ return false;
1893
+ }
1894
+ return {
1895
+ gt: a > b,
1896
+ gte: a >= b,
1897
+ lt: a < b,
1898
+ lte: a <= b
1899
+ }[condition.operator];
1900
+ }
1901
+ case 'regex':
1902
+ {
1903
+ const regex = compileConditionRegex(expected, condition.flags);
1904
+ if (!regex) {
1905
+ return null;
1906
+ }
1907
+ if (isEmptyValue$1(actual)) {
1908
+ return false;
1909
+ }
1910
+ return toArray(actual).some(item => regex.test(String(toComparable(item))));
1911
+ }
1912
+ default:
1913
+ return null;
1914
+ }
1915
+ };
1916
+ const hasVisibleWhen = field => {
1917
+ var _field$visibleWhen;
1918
+ return Array.isArray(field == null || (_field$visibleWhen = field.visibleWhen) == null ? void 0 : _field$visibleWhen.conditions) && field.visibleWhen.conditions.length > 0;
1919
+ };
1920
+
1921
+ /**
1922
+ * knownNames:可作为触发字段的完整路径集合;传入时引用未知字段的条件视为失效
1923
+ * 全部条件失效时返回 true(照常显示)
1924
+ */
1925
+ const evaluateVisibleWhen = (visibleWhen, formData, knownNames) => {
1926
+ const conditions = visibleWhen == null ? void 0 : visibleWhen.conditions;
1927
+ if (!Array.isArray(conditions) || !conditions.length) {
1928
+ return true;
1929
+ }
1930
+ const results = conditions.map(condition => {
1931
+ if (knownNames && !knownNames.has(condition == null ? void 0 : condition.field)) {
1932
+ return null;
1933
+ }
1934
+ return evaluateCondition(condition, formData || {});
1935
+ }).filter(result => result !== null);
1936
+ if (!results.length) {
1937
+ return true;
1938
+ }
1939
+ return visibleWhen.logic === 'or' ? results.some(Boolean) : results.every(Boolean);
1940
+ };
1941
+ const joinPath = (prefix, name) => prefix ? `${prefix}.${name}` : name;
1942
+
1943
+ /**
1944
+ * 收集 schema 中所有字段:{ id, path, field, inList }
1945
+ * path 为提交数据中的完整路径(object 模块带前缀);inList 表示位于列表类模块内
1946
+ */
1947
+ const collectConditionFields = schema => {
1948
+ const result = [];
1949
+ const pushFields = (list, prefix, inList) => {
1950
+ (list || []).forEach(field => {
1951
+ if (field != null && field.name) {
1952
+ result.push({
1953
+ id: field.id,
1954
+ path: joinPath(prefix, field.name),
1955
+ field,
1956
+ inList
1957
+ });
1958
+ }
1959
+ });
1960
+ };
1961
+ // 与 renderSchema 一致:仅 object 模块自身字段带 block.name 前缀,子模块不累加
1962
+ const walk = (blocks, inList) => {
1963
+ (blocks || []).forEach(block => {
1964
+ if (!block) {
1965
+ return;
1966
+ }
1967
+ const blockInList = inList || LIST_BLOCK_KINDS.includes(block.kind);
1968
+ pushFields(block.list, block.kind === 'object' ? block.name || '' : '', blockInList);
1969
+ (block.items || []).forEach(step => {
1970
+ pushFields(step.list, '', blockInList);
1971
+ walk(step.blocks, blockInList);
1972
+ });
1973
+ (block.options || []).forEach(option => {
1974
+ pushFields(option.list, '', blockInList);
1975
+ walk(option.blocks, blockInList);
1976
+ });
1977
+ walk(block.blocks, blockInList);
1978
+ walk(block.itemBlocks, true);
1979
+ });
1980
+ };
1981
+ walk(schema == null ? void 0 : schema.blocks, false);
1982
+ return result;
1983
+ };
1984
+
1985
+ /** 字段所在模块的路径前缀与是否位于列表类模块内;找不到返回 null */
1986
+ const getBlockConditionScope = (schema, blockId) => {
1987
+ let found = null;
1988
+ const walk = (blocks, inList) => {
1989
+ (blocks || []).forEach(block => {
1990
+ if (!block || found) {
1991
+ return;
1992
+ }
1993
+ const blockInList = inList || LIST_BLOCK_KINDS.includes(block.kind);
1994
+ if (block.id === blockId) {
1995
+ found = {
1996
+ prefix: block.kind === 'object' ? block.name || '' : '',
1997
+ inList: blockInList
1998
+ };
1999
+ return;
2000
+ }
2001
+ (block.items || []).forEach(step => walk(step.blocks, blockInList));
2002
+ (block.options || []).forEach(option => walk(option.blocks, blockInList));
2003
+ walk(block.blocks, blockInList);
2004
+ walk(block.itemBlocks, true);
2005
+ });
2006
+ };
2007
+ walk(schema == null ? void 0 : schema.blocks, false);
2008
+ return found;
2009
+ };
2010
+ const getFieldConditionPath = (scope, name) => name ? joinPath((scope == null ? void 0 : scope.prefix) || '', name) : '';
2011
+
2012
+ /** 可作为触发字段的路径集合(排除列表类模块内字段) */
2013
+ const collectTriggerNames = schema => new Set(collectConditionFields(schema).filter(item => !item.inList).map(item => item.path));
2014
+
2015
+ /** 某字段的条件里引用了不存在 / 不可用的触发字段 */
2016
+ 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));
2017
+ const buildDependencyGraph = schema => {
2018
+ const graph = new Map();
2019
+ collectConditionFields(schema).forEach(({
2020
+ path,
2021
+ field
2022
+ }) => {
2023
+ if (hasVisibleWhen(field)) {
2024
+ graph.set(path, field.visibleWhen.conditions.map(condition => condition == null ? void 0 : condition.field).filter(Boolean));
2025
+ }
2026
+ });
2027
+ return graph;
2028
+ };
2029
+
2030
+ /** 返回循环链路(路径数组,首尾相同);无循环返回 null */
2031
+ const findConditionCycle = schema => {
2032
+ const graph = buildDependencyGraph(schema);
2033
+ const state = new Map();
2034
+ const stack = [];
2035
+ const visit = node => {
2036
+ if (state.get(node) === 'done') {
2037
+ return null;
2038
+ }
2039
+ if (state.get(node) === 'visiting') {
2040
+ return [...stack.slice(stack.indexOf(node)), node];
2041
+ }
2042
+ state.set(node, 'visiting');
2043
+ stack.push(node);
2044
+ for (const next of graph.get(node) || []) {
2045
+ const cycle = visit(next);
2046
+ if (cycle) {
2047
+ return cycle;
2048
+ }
2049
+ }
2050
+ stack.pop();
2051
+ state.set(node, 'done');
2052
+ return null;
2053
+ };
2054
+ for (const node of graph.keys()) {
2055
+ const cycle = visit(node);
2056
+ if (cycle) {
2057
+ return cycle;
2058
+ }
2059
+ }
2060
+ return null;
2061
+ };
2062
+
2063
+ /** 选中 candidate 作为 fieldPath 的触发字段是否会形成循环 */
2064
+ const wouldCreateCycle = (schema, fieldPath, candidatePath) => {
2065
+ if (fieldPath === candidatePath) {
2066
+ return true;
2067
+ }
2068
+ const graph = buildDependencyGraph(schema);
2069
+ const seen = new Set();
2070
+ const queue = [candidatePath];
2071
+ while (queue.length) {
2072
+ const node = queue.shift();
2073
+ if (node === fieldPath) {
2074
+ return true;
2075
+ }
2076
+ if (seen.has(node)) {
2077
+ continue;
2078
+ }
2079
+ seen.add(node);
2080
+ (graph.get(node) || []).forEach(next => queue.push(next));
2081
+ }
2082
+ return false;
2083
+ };
2084
+ const mapFieldList = (list, mapper) => Array.isArray(list) ? list.map(mapper) : list;
2085
+ const mapBlockFields = (block, mapper) => {
2086
+ if (!block) {
2087
+ return block;
2088
+ }
2089
+ const next = _extends({}, block, {
2090
+ list: mapFieldList(block.list, mapper)
2091
+ });
2092
+ if (Array.isArray(block.items)) {
2093
+ next.items = block.items.map(step => _extends({}, step, {
2094
+ list: mapFieldList(step.list, mapper),
2095
+ blocks: mapBlocksFields(step.blocks, mapper)
2096
+ }));
2097
+ }
2098
+ if (Array.isArray(block.options)) {
2099
+ next.options = block.options.map(option => _extends({}, option, {
2100
+ list: mapFieldList(option.list, mapper),
2101
+ blocks: mapBlocksFields(option.blocks, mapper)
2102
+ }));
2103
+ }
2104
+ if (Array.isArray(block.blocks)) {
2105
+ next.blocks = mapBlocksFields(block.blocks, mapper);
2106
+ }
2107
+ if (Array.isArray(block.itemBlocks)) {
2108
+ next.itemBlocks = mapBlocksFields(block.itemBlocks, mapper);
2109
+ }
2110
+ return next;
2111
+ };
2112
+ const mapBlocksFields = (blocks, mapper) => Array.isArray(blocks) ? blocks.map(block => mapBlockFields(block, mapper)) : blocks;
2113
+
2114
+ /** 触发字段改名后,同步所有条件中的引用 */
2115
+ const renameConditionReferences = (schema, oldPath, newPath) => {
2116
+ if (!oldPath || !newPath || oldPath === newPath) {
2117
+ return schema;
2118
+ }
2119
+ return _extends({}, schema, {
2120
+ blocks: mapBlocksFields(schema == null ? void 0 : schema.blocks, field => {
2121
+ if (!hasVisibleWhen(field) || !field.visibleWhen.conditions.some(condition => (condition == null ? void 0 : condition.field) === oldPath)) {
2122
+ return field;
2123
+ }
2124
+ return _extends({}, field, {
2125
+ visibleWhen: _extends({}, field.visibleWhen, {
2126
+ conditions: field.visibleWhen.conditions.map(condition => (condition == null ? void 0 : condition.field) === oldPath ? _extends({}, condition, {
2127
+ field: newPath
2128
+ }) : condition)
2129
+ })
2130
+ });
2131
+ })
2132
+ });
2133
+ };
2134
+
2135
+ /**
2136
+ * 触发字段的值类型,决定可用运算符与值输入方式:
2137
+ * options(单值选项)/ multiOptions(多值选项)/ number / boolean / text
2138
+ * definition 为字段注册定义(getFieldDefinition(field.type)),由调用方传入
2139
+ */
2140
+ const getConditionValueKind = (field, definition) => {
2141
+ const props = (field == null ? void 0 : field.props) || {};
2142
+ 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')) {
2143
+ return 'multiOptions';
2144
+ }
2145
+ if (definition != null && definition.hasOptions) {
2146
+ return 'options';
2147
+ }
2148
+ if ((field == null ? void 0 : field.type) === 'Switch' || (field == null ? void 0 : field.type) === 'Checkbox') {
2149
+ return 'boolean';
2150
+ }
2151
+ const valueSchema = typeof (definition == null ? void 0 : definition.valueSchema) === 'function' ? definition.valueSchema(field) : definition == null ? void 0 : definition.valueSchema;
2152
+ if ((valueSchema == null ? void 0 : valueSchema.type) === 'number' || (valueSchema == null ? void 0 : valueSchema.type) === 'integer') {
2153
+ return 'number';
2154
+ }
2155
+ return 'text';
2156
+ };
2157
+ const OPERATORS_BY_KIND = {
2158
+ options: ['eq', 'neq', 'in', 'empty', 'notEmpty'],
2159
+ multiOptions: ['includesAny', 'empty', 'notEmpty', 'regex'],
2160
+ number: ['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'empty', 'notEmpty', 'regex'],
2161
+ boolean: ['eq', 'neq'],
2162
+ text: ['eq', 'neq', 'empty', 'notEmpty', 'regex']
2163
+ };
2164
+ const getConditionOperators = (field, definition) => OPERATORS_BY_KIND[getConditionValueKind(field, definition)] || OPERATORS_BY_KIND.text;
2165
+
2166
+ /** 去掉空条件,规范 logic / flags;无有效条件返回 undefined(不写入 schema) */
2167
+ const normalizeVisibleWhen = visibleWhen => {
2168
+ const conditions = ((visibleWhen == null ? void 0 : visibleWhen.conditions) || []).filter(condition => (condition == null ? void 0 : condition.field) && CONDITION_OPERATORS.includes(condition.operator)).map(condition => {
2169
+ const next = {
2170
+ field: condition.field,
2171
+ operator: condition.operator
2172
+ };
2173
+ if (!NO_VALUE_OPERATORS.includes(condition.operator)) {
2174
+ next.value = condition.value;
2175
+ }
2176
+ if (condition.operator === 'regex') {
2177
+ const flags = sanitizeRegexFlags(condition.flags);
2178
+ if (flags) {
2179
+ next.flags = flags;
2180
+ }
2181
+ }
2182
+ return next;
2183
+ });
2184
+ if (!conditions.length) {
2185
+ return undefined;
2186
+ }
2187
+ return {
2188
+ logic: visibleWhen.logic === 'or' ? 'or' : 'and',
2189
+ conditions
2190
+ };
2191
+ };
2192
+ const formatConditionValue = (condition, optionLabelOf) => {
2193
+ if (condition.operator === 'regex') {
2194
+ var _condition$value;
2195
+ return `/${(_condition$value = condition.value) != null ? _condition$value : ''}/${sanitizeRegexFlags(condition.flags)}`;
2196
+ }
2197
+ return toArray(condition.value).map(item => optionLabelOf(item)).join(', ');
2198
+ };
2199
+
2200
+ /**
2201
+ * 条件的可读摘要,如「是否通过 等于 不通过」
2202
+ * formatMessage 需含 conditionOperator_* / conditionLogic_* 文案;fieldLookup 为 path → field
2203
+ */
2204
+ const formatVisibleWhen = (visibleWhen, {
2205
+ formatMessage,
2206
+ fieldLookup: _fieldLookup = new Map(),
2207
+ resolveText: _resolveText = text => text
2208
+ } = {}) => {
2209
+ const conditions = (visibleWhen == null ? void 0 : visibleWhen.conditions) || [];
2210
+ const parts = conditions.map(condition => {
2211
+ const trigger = _fieldLookup.get(condition.field);
2212
+ const fieldLabel = trigger && _resolveText(trigger.label) || condition.field;
2213
+ const optionLabelOf = value => {
2214
+ var _trigger$props;
2215
+ const option = ((trigger == null || (_trigger$props = trigger.props) == null ? void 0 : _trigger$props.options) || []).find(item => sameValue(item == null ? void 0 : item.value, value));
2216
+ if (option) {
2217
+ return _resolveText(option.label);
2218
+ }
2219
+ if (typeof value === 'boolean') {
2220
+ return formatMessage({
2221
+ id: value ? 'conditionValueTrue' : 'conditionValueFalse'
2222
+ });
2223
+ }
2224
+ return String(toComparable(value));
2225
+ };
2226
+ const operatorText = formatMessage({
2227
+ id: `conditionOperator_${condition.operator}`
2228
+ });
2229
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
2230
+ return `${fieldLabel} ${operatorText}`;
2231
+ }
2232
+ return `${fieldLabel} ${operatorText} ${formatConditionValue(condition, optionLabelOf)}`;
2233
+ });
2234
+ return parts.join(formatMessage({
2235
+ id: (visibleWhen == null ? void 0 : visibleWhen.logic) === 'or' ? 'conditionJoinOr' : 'conditionJoinAnd'
2236
+ }));
2237
+ };
2238
+
1699
2239
  const registry = new Map();
1700
2240
  const defineField = (type, definition) => {
1701
2241
  registry.set(type, _extends({
@@ -2478,6 +3018,7 @@ const fieldToFormValues = field => {
2478
3018
  description: field.description || '',
2479
3019
  block: !!field.block,
2480
3020
  hidden: !!field.hidden,
3021
+ visibleWhen: field.visibleWhen,
2481
3022
  placeholder,
2482
3023
  options: options.length ? options : [{
2483
3024
  label: '',
@@ -2515,7 +3056,8 @@ const formValuesToField = (values, existingField = {}) => {
2515
3056
  props.children = values.label;
2516
3057
  }
2517
3058
  const rule = buildRuleString(values.ruleConfig);
2518
- return {
3059
+ const visibleWhen = normalizeVisibleWhen(values.visibleWhen);
3060
+ return _extends({
2519
3061
  id: existingField.id,
2520
3062
  type: values.type,
2521
3063
  name: values.name,
@@ -2524,9 +3066,12 @@ const formValuesToField = (values, existingField = {}) => {
2524
3066
  description: values.description != null && String(values.description).trim() ? values.description : '',
2525
3067
  rule,
2526
3068
  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,
3069
+ hidden: !!values.hidden
3070
+ }, visibleWhen ? {
3071
+ visibleWhen
3072
+ } : {}, {
2528
3073
  props
2529
- };
3074
+ });
2530
3075
  };
2531
3076
 
2532
3077
  const {
@@ -2626,7 +3171,7 @@ const LocaleTextArea = props => {
2626
3171
  LocaleTextArea.field = LocaleTextAreaControl;
2627
3172
 
2628
3173
  const {
2629
- Text: Text$4
3174
+ Text: Text$5
2630
3175
  } = Typography;
2631
3176
  const TYPE_TAG_COLORS = {
2632
3177
  Input: 'blue',
@@ -2646,13 +3191,35 @@ const TYPE_TAG_COLORS = {
2646
3191
  Checkbox: 'green',
2647
3192
  DatePicker: 'lime'
2648
3193
  };
3194
+ const TYPE_TAG_ICONS = {
3195
+ Input: FontSizeOutlined,
3196
+ TextArea: AlignLeftOutlined,
3197
+ InputNumber: NumberOutlined,
3198
+ Select: DownSquareOutlined,
3199
+ RadioGroup: CheckCircleOutlined,
3200
+ CheckboxGroup: CheckSquareOutlined,
3201
+ SuperSelectList: AppstoreOutlined,
3202
+ SuperSelectTableList: AppstoreOutlined,
3203
+ SuperSelectTree: AppstoreOutlined,
3204
+ SuperSelectCascader: AppstoreOutlined,
3205
+ SelectFunction: ApartmentOutlined,
3206
+ SelectIndustry: ShopOutlined,
3207
+ SelectAddress: EnvironmentOutlined,
3208
+ Switch: SwapOutlined,
3209
+ Checkbox: CheckSquareOutlined,
3210
+ DatePicker: CalendarOutlined
3211
+ };
3212
+ const getFieldTypeIcon = type => TYPE_TAG_ICONS[type] || FormOutlined;
2649
3213
  const FieldRow = ({
2650
3214
  field,
2651
3215
  index,
2652
3216
  total,
2653
3217
  onEdit,
2654
3218
  onDelete,
2655
- onMove
3219
+ onMove,
3220
+ prevLocked,
3221
+ nextLocked,
3222
+ conditionContext
2656
3223
  }) => {
2657
3224
  const {
2658
3225
  formatMessage,
@@ -2660,40 +3227,81 @@ const FieldRow = ({
2660
3227
  } = useIntl();
2661
3228
  const languages = useLocaleTextLanguages();
2662
3229
  const definition = getFieldDefinition(field.type);
3230
+ const conditional = hasVisibleWhen(field);
3231
+ const conditionInvalid = conditional && conditionContext && hasInvalidCondition(field, conditionContext.triggerNames);
3232
+ const TypeIcon = getFieldTypeIcon(field.type);
2663
3233
  return /*#__PURE__*/jsxs("div", {
2664
3234
  className: style['field-row'],
2665
3235
  children: [/*#__PURE__*/jsx("span", {
2666
3236
  className: style['field-row-index'],
2667
3237
  children: index + 1
2668
- }), /*#__PURE__*/jsx("div", {
3238
+ }), /*#__PURE__*/jsxs("div", {
2669
3239
  className: style['field-row-main'],
2670
- children: /*#__PURE__*/jsxs(Space, {
3240
+ children: [/*#__PURE__*/jsx(Text$5, {
3241
+ strong: true,
3242
+ className: style['field-row-label'],
3243
+ children: resolveLocaleText(field.label, locale, languages) || formatMessage({
3244
+ id: 'untitledField'
3245
+ })
3246
+ }), /*#__PURE__*/jsxs(Space, {
2671
3247
  size: 6,
2672
3248
  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, {
3249
+ children: [/*#__PURE__*/jsx(Tag, {
2680
3250
  bordered: false,
2681
3251
  color: TYPE_TAG_COLORS[field.type] || 'default',
3252
+ icon: /*#__PURE__*/jsx(TypeIcon, {}),
2682
3253
  children: resolveFieldTypeLabel(definition || field.type, formatMessage)
2683
- }), field.hidden ? /*#__PURE__*/jsx(Tag, {
3254
+ }), field.locked ? /*#__PURE__*/jsx(Tag, {
2684
3255
  bordered: false,
3256
+ icon: /*#__PURE__*/jsx(LockOutlined, {}),
3257
+ title: formatMessage({
3258
+ id: 'fieldLockedTips'
3259
+ }),
3260
+ children: formatMessage({
3261
+ id: 'fieldLockedTag'
3262
+ })
3263
+ }) : null, field.hidden ? /*#__PURE__*/jsx(Tag, {
3264
+ bordered: false,
3265
+ icon: /*#__PURE__*/jsx(EyeInvisibleOutlined, {}),
2685
3266
  children: formatMessage({
2686
3267
  id: 'fieldHiddenTag'
2687
3268
  })
3269
+ }) : null, conditional ? /*#__PURE__*/jsx(Tooltip, {
3270
+ title: formatVisibleWhen(field.visibleWhen, {
3271
+ formatMessage,
3272
+ fieldLookup: conditionContext == null ? void 0 : conditionContext.fieldLookup,
3273
+ resolveText: value => resolveLocaleText(value, locale, languages)
3274
+ }),
3275
+ children: /*#__PURE__*/jsx(Tag, {
3276
+ bordered: false,
3277
+ color: "magenta",
3278
+ icon: /*#__PURE__*/jsx(BranchesOutlined, {}),
3279
+ children: formatMessage({
3280
+ id: 'fieldConditionTag'
3281
+ })
3282
+ })
3283
+ }) : null, conditionInvalid ? /*#__PURE__*/jsx(Tooltip, {
3284
+ title: formatMessage({
3285
+ id: 'fieldConditionInvalidTips'
3286
+ }),
3287
+ children: /*#__PURE__*/jsx(Tag, {
3288
+ bordered: false,
3289
+ color: "error",
3290
+ icon: /*#__PURE__*/jsx(WarningOutlined, {}),
3291
+ children: formatMessage({
3292
+ id: 'fieldConditionInvalidTag'
3293
+ })
3294
+ })
2688
3295
  }) : null, field.block ? /*#__PURE__*/jsx(Tag, {
2689
3296
  bordered: false,
2690
3297
  color: "processing",
3298
+ icon: /*#__PURE__*/jsx(ColumnWidthOutlined, {}),
2691
3299
  children: formatMessage({
2692
3300
  id: 'fieldBlockTag'
2693
3301
  })
2694
3302
  }) : null]
2695
- })
2696
- }), /*#__PURE__*/jsxs("div", {
3303
+ })]
3304
+ }), field.locked ? null : /*#__PURE__*/jsxs("div", {
2697
3305
  className: style['action-group'],
2698
3306
  children: [/*#__PURE__*/jsx(Button, {
2699
3307
  type: "text",
@@ -2703,7 +3311,7 @@ const FieldRow = ({
2703
3311
  id: 'moveUp'
2704
3312
  }),
2705
3313
  icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
2706
- disabled: index === 0,
3314
+ disabled: index === 0 || prevLocked,
2707
3315
  onClick: () => onMove(field.id, 'up')
2708
3316
  }), /*#__PURE__*/jsx(Button, {
2709
3317
  type: "text",
@@ -2713,7 +3321,7 @@ const FieldRow = ({
2713
3321
  id: 'moveDown'
2714
3322
  }),
2715
3323
  icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
2716
- disabled: index === total - 1,
3324
+ disabled: index === total - 1 || nextLocked,
2717
3325
  onClick: () => onMove(field.id, 'down')
2718
3326
  }), /*#__PURE__*/jsx(Button, {
2719
3327
  type: "text",
@@ -2738,11 +3346,10 @@ const FieldRow = ({
2738
3346
  })]
2739
3347
  });
2740
3348
  };
2741
- var FieldRow$1 = FieldRow;
2742
3349
 
2743
- const _excluded$2 = ["title", "danger"];
3350
+ const _excluded$3 = ["title", "danger"];
2744
3351
  const {
2745
- Text: Text$3
3352
+ Text: Text$4
2746
3353
  } = Typography;
2747
3354
  const ActionGroup = ({
2748
3355
  children
@@ -2755,7 +3362,7 @@ const IconBtn = _ref => {
2755
3362
  title,
2756
3363
  danger
2757
3364
  } = _ref,
2758
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
3365
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
2759
3366
  return /*#__PURE__*/jsx(Button, _extends({
2760
3367
  type: "text",
2761
3368
  size: "small",
@@ -2789,6 +3396,10 @@ const ROOT_ADD_OPTIONS = [{
2789
3396
  key: 'steps',
2790
3397
  icon: /*#__PURE__*/jsx(OrderedListOutlined, {})
2791
3398
  }];
3399
+ const BLOCK_KIND_ICONS = Object.fromEntries(ROOT_ADD_OPTIONS.map(({
3400
+ key,
3401
+ icon
3402
+ }) => [key, icon]));
2792
3403
 
2793
3404
  /** 可挂子模块的容器;表格列表 / 同类多值本身不支持子模块 */
2794
3405
  const NESTED_ADD_OPTIONS = ROOT_ADD_OPTIONS.filter(opt => opt.key !== 'steps');
@@ -2822,6 +3433,15 @@ const BlockListPanel = ({
2822
3433
  const [addMenuOpen, setAddMenuOpen] = useState(false);
2823
3434
  const [addFieldMenuId, setAddFieldMenuId] = useState(null);
2824
3435
  const keepAddFieldMenuOpenRef = useRef(false);
3436
+ const conditionContext = useMemo(() => {
3437
+ const triggerFields = collectConditionFields({
3438
+ blocks
3439
+ }).filter(item => !item.inList);
3440
+ return {
3441
+ triggerNames: new Set(triggerFields.map(item => item.path)),
3442
+ fieldLookup: new Map(triggerFields.map(item => [item.path, item.field]))
3443
+ };
3444
+ }, [blocks]);
2825
3445
  const renderAddBlockMenu = (options, {
2826
3446
  onSelect,
2827
3447
  className
@@ -2983,7 +3603,7 @@ const BlockListPanel = ({
2983
3603
  optionId
2984
3604
  } = {}) => {
2985
3605
  if (!(fields || []).length) {
2986
- return /*#__PURE__*/jsx(Text$3, {
3606
+ return /*#__PURE__*/jsx(Text$4, {
2987
3607
  type: "secondary",
2988
3608
  className: style['inline-empty'],
2989
3609
  children: formatMessage({
@@ -2993,10 +3613,13 @@ const BlockListPanel = ({
2993
3613
  }
2994
3614
  return /*#__PURE__*/jsx("div", {
2995
3615
  className: style['field-list'],
2996
- children: fields.map((field, fieldIndex) => /*#__PURE__*/jsx(FieldRow$1, {
3616
+ children: fields.map((field, fieldIndex) => /*#__PURE__*/jsx(FieldRow, {
2997
3617
  field: field,
2998
3618
  index: fieldIndex,
2999
3619
  total: fields.length,
3620
+ prevLocked: isFieldLocked(fields[fieldIndex - 1]),
3621
+ nextLocked: isFieldLocked(fields[fieldIndex + 1]),
3622
+ conditionContext: conditionContext,
3000
3623
  onEdit: fieldItem => onEditField(blockId, fieldItem, {
3001
3624
  stepId,
3002
3625
  optionId
@@ -3020,7 +3643,7 @@ const BlockListPanel = ({
3020
3643
  className: style['item-blocks-section'],
3021
3644
  children: /*#__PURE__*/jsx("div", {
3022
3645
  className: style['nested-block-list'],
3023
- children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks.length, depth + 1))
3646
+ children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks, depth + 1))
3024
3647
  })
3025
3648
  });
3026
3649
  };
@@ -3031,7 +3654,7 @@ const BlockListPanel = ({
3031
3654
  className: style['block-body'],
3032
3655
  children: [/*#__PURE__*/jsxs("div", {
3033
3656
  className: style['section-toolbar'],
3034
- children: [/*#__PURE__*/jsx(Text$3, {
3657
+ children: [/*#__PURE__*/jsx(Text$4, {
3035
3658
  type: "secondary",
3036
3659
  className: style['section-toolbar-label'],
3037
3660
  children: formatMessage({
@@ -3062,14 +3685,14 @@ const BlockListPanel = ({
3062
3685
  children: [/*#__PURE__*/jsx("span", {
3063
3686
  className: style['step-index'],
3064
3687
  children: stepIndex + 1
3065
- }), /*#__PURE__*/jsx(Text$3, {
3688
+ }), /*#__PURE__*/jsx(Text$4, {
3066
3689
  strong: true,
3067
3690
  children: text(step.title) || formatMessage({
3068
3691
  id: 'untitledStep'
3069
3692
  }, {
3070
3693
  index: stepIndex + 1
3071
3694
  })
3072
- }), /*#__PURE__*/jsx(Text$3, {
3695
+ }), /*#__PURE__*/jsx(Text$4, {
3073
3696
  type: "secondary",
3074
3697
  children: (step.blocks || []).length ? formatMessage({
3075
3698
  id: 'fieldAndItemBlockCount'
@@ -3092,14 +3715,14 @@ const BlockListPanel = ({
3092
3715
  id: 'moveUp'
3093
3716
  }),
3094
3717
  icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
3095
- disabled: stepIndex === 0,
3718
+ disabled: stepIndex === 0 || blockHasLockedField(step) || blockHasLockedField(block.items[stepIndex - 1]),
3096
3719
  onClick: () => onMoveStep(block.id, step.id, 'up')
3097
3720
  }), /*#__PURE__*/jsx(IconBtn, {
3098
3721
  title: formatMessage({
3099
3722
  id: 'moveDown'
3100
3723
  }),
3101
3724
  icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
3102
- disabled: stepIndex === (((_block$items = block.items) == null ? void 0 : _block$items.length) || 0) - 1,
3725
+ disabled: stepIndex === (((_block$items = block.items) == null ? void 0 : _block$items.length) || 0) - 1 || blockHasLockedField(step) || blockHasLockedField(block.items[stepIndex + 1]),
3103
3726
  onClick: () => onMoveStep(block.id, step.id, 'down')
3104
3727
  }), /*#__PURE__*/jsx(IconBtn, {
3105
3728
  title: formatMessage({
@@ -3107,7 +3730,7 @@ const BlockListPanel = ({
3107
3730
  }),
3108
3731
  icon: /*#__PURE__*/jsx(EditOutlined, {}),
3109
3732
  onClick: () => onEditStep(block.id, step)
3110
- }), /*#__PURE__*/jsx(IconBtn, {
3733
+ }), blockHasLockedField(step) ? null : /*#__PURE__*/jsx(IconBtn, {
3111
3734
  title: formatMessage({
3112
3735
  id: 'deleteStep'
3113
3736
  }),
@@ -3132,7 +3755,7 @@ const BlockListPanel = ({
3132
3755
  }), renderNestedBlocks(step.blocks, depth)]
3133
3756
  }, step.id);
3134
3757
  })
3135
- }) : /*#__PURE__*/jsx(Text$3, {
3758
+ }) : /*#__PURE__*/jsx(Text$4, {
3136
3759
  type: "secondary",
3137
3760
  className: style['inline-empty'],
3138
3761
  children: formatMessage({
@@ -3144,7 +3767,7 @@ const BlockListPanel = ({
3144
3767
  if (block.kind === 'multiField') {
3145
3768
  return /*#__PURE__*/jsx("div", {
3146
3769
  className: style['block-body'],
3147
- children: /*#__PURE__*/jsx(Text$3, {
3770
+ children: /*#__PURE__*/jsx(Text$4, {
3148
3771
  type: "secondary",
3149
3772
  children: formatMessage({
3150
3773
  id: 'multiFieldEditorHint'
@@ -3157,7 +3780,7 @@ const BlockListPanel = ({
3157
3780
  className: style['block-body'],
3158
3781
  children: [/*#__PURE__*/jsxs("div", {
3159
3782
  className: style['section-toolbar'],
3160
- children: [/*#__PURE__*/jsx(Text$3, {
3783
+ children: [/*#__PURE__*/jsx(Text$4, {
3161
3784
  type: "secondary",
3162
3785
  className: style['section-toolbar-label'],
3163
3786
  children: formatMessage({
@@ -3188,14 +3811,14 @@ const BlockListPanel = ({
3188
3811
  children: [/*#__PURE__*/jsx("span", {
3189
3812
  className: style['step-index'],
3190
3813
  children: optionIndex + 1
3191
- }), /*#__PURE__*/jsx(Text$3, {
3814
+ }), /*#__PURE__*/jsx(Text$4, {
3192
3815
  strong: true,
3193
3816
  children: text(option.title) || formatMessage({
3194
3817
  id: 'choiceOptionFallback'
3195
3818
  }, {
3196
3819
  index: optionIndex + 1
3197
3820
  })
3198
- }), /*#__PURE__*/jsx(Text$3, {
3821
+ }), /*#__PURE__*/jsx(Text$4, {
3199
3822
  type: "secondary",
3200
3823
  children: (option.blocks || []).length ? formatMessage({
3201
3824
  id: 'fieldAndItemBlockCount'
@@ -3218,14 +3841,14 @@ const BlockListPanel = ({
3218
3841
  id: 'moveUp'
3219
3842
  }),
3220
3843
  icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
3221
- disabled: optionIndex === 0,
3844
+ disabled: optionIndex === 0 || blockHasLockedField(option) || blockHasLockedField(block.options[optionIndex - 1]),
3222
3845
  onClick: () => onMoveChoiceOption(block.id, option.id, 'up')
3223
3846
  }), /*#__PURE__*/jsx(IconBtn, {
3224
3847
  title: formatMessage({
3225
3848
  id: 'moveDown'
3226
3849
  }),
3227
3850
  icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
3228
- disabled: optionIndex === (((_block$options = block.options) == null ? void 0 : _block$options.length) || 0) - 1,
3851
+ disabled: optionIndex === (((_block$options = block.options) == null ? void 0 : _block$options.length) || 0) - 1 || blockHasLockedField(option) || blockHasLockedField(block.options[optionIndex + 1]),
3229
3852
  onClick: () => onMoveChoiceOption(block.id, option.id, 'down')
3230
3853
  }), /*#__PURE__*/jsx(IconBtn, {
3231
3854
  title: formatMessage({
@@ -3233,7 +3856,7 @@ const BlockListPanel = ({
3233
3856
  }),
3234
3857
  icon: /*#__PURE__*/jsx(EditOutlined, {}),
3235
3858
  onClick: () => onEditChoiceOption(block.id, option)
3236
- }), /*#__PURE__*/jsx(IconBtn, {
3859
+ }), blockHasLockedField(option) ? null : /*#__PURE__*/jsx(IconBtn, {
3237
3860
  title: formatMessage({
3238
3861
  id: 'deleteChoiceOption'
3239
3862
  }),
@@ -3258,7 +3881,7 @@ const BlockListPanel = ({
3258
3881
  }), renderNestedBlocks(option.blocks, depth)]
3259
3882
  }, option.id);
3260
3883
  })
3261
- }) : /*#__PURE__*/jsx(Text$3, {
3884
+ }) : /*#__PURE__*/jsx(Text$4, {
3262
3885
  type: "secondary",
3263
3886
  className: style['inline-empty'],
3264
3887
  children: formatMessage({
@@ -3274,8 +3897,10 @@ const BlockListPanel = ({
3274
3897
  children: [renderFieldList(block.list, block.id), supportsItemBlocks$1 ? renderItemBlocks(block, depth) : null, supportsBlocks ? renderNestedBlocks(block.blocks, depth) : null]
3275
3898
  });
3276
3899
  };
3277
- const renderBlockSection = (block, blockIndex, total, depth = 0) => {
3900
+ const renderBlockSection = (block, blockIndex, siblings, depth = 0) => {
3278
3901
  var _block$itemBlocks, _block$blocks, _block$items2, _block$options2, _block$list, _block$list2;
3902
+ const total = siblings.length;
3903
+ const locked = blockHasLockedField(block);
3279
3904
  const definition = getBlockDefinition(block.kind);
3280
3905
  const canAddField = block.kind !== 'steps' && block.kind !== 'multiField' && block.kind !== 'choice';
3281
3906
  const supportsItemBlocks$1 = supportsItemBlocks(block.kind);
@@ -3289,7 +3914,10 @@ const BlockListPanel = ({
3289
3914
  }) : block.kind === 'multiField' ? formatMessage({
3290
3915
  id: 'multiFieldSummary'
3291
3916
  }, {
3292
- type: resolveFieldTypeLabel(block.fieldType, formatMessage)
3917
+ type: /*#__PURE__*/jsxs("span", {
3918
+ className: style['block-summary-type'],
3919
+ children: [/*#__PURE__*/createElement(getFieldTypeIcon(block.fieldType || 'Input')), resolveFieldTypeLabel(block.fieldType, formatMessage)]
3920
+ })
3293
3921
  }) : block.kind === 'choice' ? formatMessage({
3294
3922
  id: 'choiceOptionCount'
3295
3923
  }, {
@@ -3313,10 +3941,11 @@ const BlockListPanel = ({
3313
3941
  children: [/*#__PURE__*/jsx(Tag, {
3314
3942
  bordered: false,
3315
3943
  color: (definition == null ? void 0 : definition.color) || 'default',
3944
+ icon: BLOCK_KIND_ICONS[block.kind],
3316
3945
  children: formatMessage({
3317
3946
  id: `blockKind_${block.kind}`
3318
3947
  })
3319
- }), /*#__PURE__*/jsx(Text$3, {
3948
+ }), /*#__PURE__*/jsx(Text$4, {
3320
3949
  strong: true,
3321
3950
  ellipsis: true,
3322
3951
  className: style['block-title'],
@@ -3337,14 +3966,14 @@ const BlockListPanel = ({
3337
3966
  id: 'moveUp'
3338
3967
  }),
3339
3968
  icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
3340
- disabled: blockIndex === 0,
3969
+ disabled: blockIndex === 0 || locked || blockHasLockedField(siblings[blockIndex - 1]),
3341
3970
  onClick: () => onMoveBlock(block.id, 'up')
3342
3971
  }), /*#__PURE__*/jsx(IconBtn, {
3343
3972
  title: formatMessage({
3344
3973
  id: 'moveDown'
3345
3974
  }),
3346
3975
  icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
3347
- disabled: blockIndex === total - 1,
3976
+ disabled: blockIndex === total - 1 || locked || blockHasLockedField(siblings[blockIndex + 1]),
3348
3977
  onClick: () => onMoveBlock(block.id, 'down')
3349
3978
  }), /*#__PURE__*/jsx(IconBtn, {
3350
3979
  title: formatMessage({
@@ -3352,7 +3981,7 @@ const BlockListPanel = ({
3352
3981
  }),
3353
3982
  icon: /*#__PURE__*/jsx(SettingOutlined, {}),
3354
3983
  onClick: () => onEditBlock(block)
3355
- }), /*#__PURE__*/jsx(IconBtn, {
3984
+ }), locked ? null : /*#__PURE__*/jsx(IconBtn, {
3356
3985
  title: formatMessage({
3357
3986
  id: 'deleteBlock'
3358
3987
  }),
@@ -3420,7 +4049,7 @@ const BlockListPanel = ({
3420
4049
  })
3421
4050
  }) : /*#__PURE__*/jsx("div", {
3422
4051
  className: style['block-list'],
3423
- children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks.length, 0))
4052
+ children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks, 0))
3424
4053
  })]
3425
4054
  });
3426
4055
  };
@@ -3846,7 +4475,7 @@ const ChoiceOptionEditorModal = ({
3846
4475
  var ChoiceOptionEditorModal$1 = ChoiceOptionEditorModal;
3847
4476
 
3848
4477
  const {
3849
- Text: Text$2
4478
+ Text: Text$3
3850
4479
  } = Typography;
3851
4480
  const {
3852
4481
  useOnChange
@@ -3901,7 +4530,7 @@ const RulePresetEditor = () => {
3901
4530
  }
3902
4531
  }, "lenMax"), /*#__PURE__*/jsx("div", {
3903
4532
  block: true,
3904
- children: /*#__PURE__*/jsx(Text$2, {
4533
+ children: /*#__PURE__*/jsx(Text$3, {
3905
4534
  type: "secondary",
3906
4535
  children: formatMessage({
3907
4536
  id: 'ruleEditorHint'
@@ -3919,7 +4548,7 @@ const RulePresetEditor = () => {
3919
4548
  var RulePresetEditor$1 = RulePresetEditor;
3920
4549
 
3921
4550
  const {
3922
- Text: Text$1
4551
+ Text: Text$2
3923
4552
  } = Typography;
3924
4553
  const createOptionKey = () => createDataKey('opt');
3925
4554
  const EMPTY_OPTION = () => ({
@@ -4333,7 +4962,7 @@ const TableRowsEditor = ({
4333
4962
  column: 1,
4334
4963
  list: [/*#__PURE__*/jsx("div", {
4335
4964
  block: true,
4336
- children: /*#__PURE__*/jsx(Text$1, {
4965
+ children: /*#__PURE__*/jsx(Text$2, {
4337
4966
  type: "secondary",
4338
4967
  children: formatMessage({
4339
4968
  id: 'tableRowsNeedColumnsHint'
@@ -4901,7 +5530,391 @@ const hasFieldPropsEditor = (type, definition) => {
4901
5530
  };
4902
5531
  var FieldPropsEditor$1 = FieldPropsEditor;
4903
5532
 
4904
- const _excluded$1 = ["columns"];
5533
+ const {
5534
+ Text: Text$1
5535
+ } = Typography;
5536
+ const MULTI_VALUE_OPERATORS = ['in', 'includesAny'];
5537
+ const createCondition = () => ({
5538
+ field: undefined,
5539
+ operator: undefined,
5540
+ value: undefined
5541
+ });
5542
+
5543
+ /** 编辑器提交前校验:返回错误文案 id,通过返回 null */
5544
+ const validateVisibleWhenDraft = visibleWhen => {
5545
+ if (!visibleWhen) {
5546
+ return null;
5547
+ }
5548
+ const incomplete = (visibleWhen.conditions || []).some(condition => {
5549
+ if (!(condition != null && condition.field) || !condition.operator) {
5550
+ return true;
5551
+ }
5552
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
5553
+ return false;
5554
+ }
5555
+ const value = condition.value;
5556
+ return value === undefined || value === null || value === '' || Array.isArray(value) && !value.length;
5557
+ });
5558
+ if (incomplete || !(visibleWhen.conditions || []).length) {
5559
+ return 'visibleWhenConditionRequired';
5560
+ }
5561
+ if (visibleWhen.conditions.some(condition => condition.operator === 'regex' && !compileConditionRegex(condition.value, condition.flags))) {
5562
+ return 'visibleWhenRegexInvalid';
5563
+ }
5564
+ return null;
5565
+ };
5566
+ const RegexTester = ({
5567
+ condition
5568
+ }) => {
5569
+ const {
5570
+ formatMessage
5571
+ } = useIntl();
5572
+ const [text, setText] = useState('');
5573
+ const regex = compileConditionRegex(condition.value, condition.flags);
5574
+ const status = regex && text !== '' ? regex.test(text) : null;
5575
+ return /*#__PURE__*/jsxs(Flex, {
5576
+ gap: 8,
5577
+ align: "center",
5578
+ className: style['visible-when-regex-tester'],
5579
+ children: [/*#__PURE__*/jsx(Input$1, {
5580
+ size: "small",
5581
+ value: text,
5582
+ placeholder: formatMessage({
5583
+ id: 'visibleWhenRegexTester'
5584
+ }),
5585
+ onChange: e => setText(e.target.value)
5586
+ }), status === null ? null : /*#__PURE__*/jsx(Text$1, {
5587
+ type: status ? 'success' : 'warning',
5588
+ children: formatMessage({
5589
+ id: status ? 'visibleWhenRegexMatched' : 'visibleWhenRegexNotMatched'
5590
+ })
5591
+ })]
5592
+ });
5593
+ };
5594
+ const ConditionValueInput = ({
5595
+ condition,
5596
+ trigger,
5597
+ onChange
5598
+ }) => {
5599
+ var _condition$value3;
5600
+ const {
5601
+ formatMessage,
5602
+ locale
5603
+ } = useIntl();
5604
+ const definition = getFieldDefinition(trigger == null ? void 0 : trigger.type);
5605
+ const kind = getConditionValueKind(trigger, definition);
5606
+ if (NO_VALUE_OPERATORS.includes(condition.operator)) {
5607
+ return null;
5608
+ }
5609
+ if (condition.operator === 'regex') {
5610
+ var _condition$value;
5611
+ const regexInvalid = condition.value != null && condition.value !== '' && !compileConditionRegex(condition.value, condition.flags);
5612
+ return /*#__PURE__*/jsxs("div", {
5613
+ className: style['visible-when-regex'],
5614
+ children: [/*#__PURE__*/jsxs(Flex, {
5615
+ gap: 8,
5616
+ children: [/*#__PURE__*/jsx(Input$1, {
5617
+ prefix: "/",
5618
+ suffix: "/",
5619
+ status: regexInvalid ? 'error' : undefined,
5620
+ value: (_condition$value = condition.value) != null ? _condition$value : '',
5621
+ placeholder: formatMessage({
5622
+ id: 'visibleWhenValue'
5623
+ }),
5624
+ onChange: e => onChange({
5625
+ value: e.target.value
5626
+ })
5627
+ }), /*#__PURE__*/jsx(Select$1, {
5628
+ mode: "multiple",
5629
+ className: style['visible-when-flags'],
5630
+ placeholder: formatMessage({
5631
+ id: 'visibleWhenRegexFlags'
5632
+ }),
5633
+ value: String(condition.flags || '').split('').filter(Boolean),
5634
+ options: ALLOWED_REGEX_FLAGS.map(flag => ({
5635
+ value: flag,
5636
+ label: formatMessage({
5637
+ id: `visibleWhenRegexFlag_${flag}`
5638
+ })
5639
+ })),
5640
+ optionLabelProp: "value",
5641
+ onChange: flags => onChange({
5642
+ flags: flags.join('')
5643
+ })
5644
+ })]
5645
+ }), regexInvalid ? /*#__PURE__*/jsx(Text$1, {
5646
+ type: "danger",
5647
+ children: formatMessage({
5648
+ id: 'visibleWhenRegexInvalid'
5649
+ })
5650
+ }) : null, /*#__PURE__*/jsx(RegexTester, {
5651
+ condition: condition
5652
+ })]
5653
+ });
5654
+ }
5655
+ if (kind === 'boolean') {
5656
+ return /*#__PURE__*/jsx(Select$1, {
5657
+ className: style['visible-when-value'],
5658
+ value: condition.value,
5659
+ placeholder: formatMessage({
5660
+ id: 'visibleWhenValue'
5661
+ }),
5662
+ options: [{
5663
+ value: true,
5664
+ label: formatMessage({
5665
+ id: 'conditionValueTrue'
5666
+ })
5667
+ }, {
5668
+ value: false,
5669
+ label: formatMessage({
5670
+ id: 'conditionValueFalse'
5671
+ })
5672
+ }],
5673
+ onChange: value => onChange({
5674
+ value
5675
+ })
5676
+ });
5677
+ }
5678
+ if (kind === 'options' || kind === 'multiOptions') {
5679
+ var _trigger$props;
5680
+ const multiple = MULTI_VALUE_OPERATORS.includes(condition.operator);
5681
+ 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 => ({
5682
+ value: item.value,
5683
+ label: resolveLocaleText(item.label, locale) || String(item.value)
5684
+ }));
5685
+ const value = multiple ? Array.isArray(condition.value) ? condition.value : condition.value != null ? [condition.value] : [] : Array.isArray(condition.value) ? condition.value[0] : condition.value;
5686
+ return /*#__PURE__*/jsx(Select$1, {
5687
+ className: style['visible-when-value']
5688
+ // 远程数据源没有静态选项时允许手动输入值
5689
+ ,
5690
+ mode: options.length ? multiple ? 'multiple' : undefined : 'tags',
5691
+ value: value,
5692
+ placeholder: formatMessage({
5693
+ id: 'visibleWhenValue'
5694
+ }),
5695
+ options: options,
5696
+ onChange: next => onChange({
5697
+ value: !options.length && !multiple && Array.isArray(next) ? next[next.length - 1] : next
5698
+ })
5699
+ });
5700
+ }
5701
+ if (kind === 'number') {
5702
+ var _condition$value2;
5703
+ return /*#__PURE__*/jsx(InputNumber$1, {
5704
+ className: style['visible-when-value'],
5705
+ value: (_condition$value2 = condition.value) != null ? _condition$value2 : null,
5706
+ placeholder: formatMessage({
5707
+ id: 'visibleWhenValue'
5708
+ }),
5709
+ onChange: value => onChange({
5710
+ value: value != null ? value : undefined
5711
+ })
5712
+ });
5713
+ }
5714
+ return /*#__PURE__*/jsx(Input$1, {
5715
+ className: style['visible-when-value'],
5716
+ value: (_condition$value3 = condition.value) != null ? _condition$value3 : '',
5717
+ placeholder: formatMessage({
5718
+ id: 'visibleWhenValue'
5719
+ }),
5720
+ onChange: e => onChange({
5721
+ value: e.target.value
5722
+ })
5723
+ });
5724
+ };
5725
+
5726
+ /**
5727
+ * 条件显示配置(受控):value 为 visibleWhen 草稿或 undefined
5728
+ * triggerFields:collectConditionFields 中可作为触发项的字段;scope:当前字段所在模块
5729
+ */
5730
+ const VisibleWhenEditor = ({
5731
+ value,
5732
+ onChange,
5733
+ schema,
5734
+ triggerFields: _triggerFields = [],
5735
+ scope,
5736
+ fieldId
5737
+ }) => {
5738
+ const {
5739
+ formatMessage,
5740
+ locale
5741
+ } = useIntl();
5742
+ const {
5743
+ formData
5744
+ } = useFormContext() || {};
5745
+ const selfPath = getFieldConditionPath(scope, formData != null && formData.name ? String(formData.name).trim() : '');
5746
+ const candidates = useMemo(() => _triggerFields.filter(item => item.id !== fieldId && item.path !== selfPath).map(item => _extends({}, item, {
5747
+ disabled: selfPath ? wouldCreateCycle(schema, selfPath, item.path) : false
5748
+ })), [_triggerFields, fieldId, selfPath, schema]);
5749
+ if (scope != null && scope.inList) {
5750
+ return /*#__PURE__*/jsx(FormInfo, {
5751
+ title: formatMessage({
5752
+ id: 'visibleWhenTitle'
5753
+ }),
5754
+ column: 1,
5755
+ list: [/*#__PURE__*/jsx("div", {
5756
+ block: true,
5757
+ children: /*#__PURE__*/jsx(Text$1, {
5758
+ type: "secondary",
5759
+ children: formatMessage({
5760
+ id: 'visibleWhenListUnsupported'
5761
+ })
5762
+ })
5763
+ }, "unsupported")]
5764
+ });
5765
+ }
5766
+ const enabled = !!value;
5767
+ const conditions = (value == null ? void 0 : value.conditions) || [];
5768
+ const updateConditions = next => onChange(_extends({}, value, {
5769
+ conditions: next
5770
+ }));
5771
+ const updateCondition = (index, patch) => updateConditions(conditions.map((item, itemIndex) => itemIndex === index ? _extends({}, item, patch) : item));
5772
+ const body = /*#__PURE__*/jsxs("div", {
5773
+ block: true,
5774
+ className: style['visible-when-editor'],
5775
+ children: [/*#__PURE__*/jsxs(Flex, {
5776
+ gap: 8,
5777
+ align: "center",
5778
+ children: [/*#__PURE__*/jsx(Switch$1, {
5779
+ size: "small",
5780
+ checked: enabled,
5781
+ disabled: !enabled && !candidates.length,
5782
+ onChange: checked => onChange(checked ? {
5783
+ logic: 'and',
5784
+ conditions: [createCondition()]
5785
+ } : undefined)
5786
+ }), /*#__PURE__*/jsx(Text$1, {
5787
+ children: formatMessage({
5788
+ id: 'visibleWhenEnable'
5789
+ })
5790
+ })]
5791
+ }), /*#__PURE__*/jsx(Text$1, {
5792
+ type: "secondary",
5793
+ className: style['visible-when-hint'],
5794
+ children: formatMessage({
5795
+ id: candidates.length || enabled ? 'visibleWhenEnableTips' : 'visibleWhenNoTrigger'
5796
+ })
5797
+ }), enabled ? /*#__PURE__*/jsxs(Fragment, {
5798
+ children: [conditions.length > 1 ? /*#__PURE__*/jsxs(Flex, {
5799
+ gap: 8,
5800
+ align: "center",
5801
+ children: [/*#__PURE__*/jsx(Text$1, {
5802
+ children: formatMessage({
5803
+ id: 'visibleWhenLogic'
5804
+ })
5805
+ }), /*#__PURE__*/jsx(Radio.Group, {
5806
+ size: "small",
5807
+ value: value.logic === 'or' ? 'or' : 'and',
5808
+ options: ['and', 'or'].map(logic => ({
5809
+ value: logic,
5810
+ label: formatMessage({
5811
+ id: `conditionLogic_${logic}`
5812
+ })
5813
+ })),
5814
+ onChange: e => onChange(_extends({}, value, {
5815
+ logic: e.target.value
5816
+ }))
5817
+ })]
5818
+ }) : null, /*#__PURE__*/jsx("div", {
5819
+ className: style['visible-when-list'],
5820
+ children: conditions.map((condition, index) => {
5821
+ var _triggerFields$find;
5822
+ const trigger = (_triggerFields$find = _triggerFields.find(item => item.path === condition.field)) == null ? void 0 : _triggerFields$find.field;
5823
+ const operators = trigger ? getConditionOperators(trigger, getFieldDefinition(trigger.type)) : [];
5824
+ return /*#__PURE__*/jsxs(Flex, {
5825
+ gap: 8,
5826
+ align: "start",
5827
+ className: style['visible-when-row'],
5828
+ children: [/*#__PURE__*/jsxs("div", {
5829
+ className: style['visible-when-row-main'],
5830
+ children: [/*#__PURE__*/jsxs(Flex, {
5831
+ gap: 8,
5832
+ wrap: true,
5833
+ children: [/*#__PURE__*/jsx(Select$1, {
5834
+ showSearch: true,
5835
+ optionFilterProp: "label",
5836
+ className: style['visible-when-field'],
5837
+ status: condition.field && !trigger ? 'error' : undefined,
5838
+ value: condition.field,
5839
+ placeholder: formatMessage({
5840
+ id: 'visibleWhenField'
5841
+ }),
5842
+ options: candidates.map(item => ({
5843
+ value: item.path,
5844
+ disabled: item.disabled,
5845
+ label: `${resolveLocaleText(item.field.label, locale) || item.field.name}(${item.path})`
5846
+ })),
5847
+ onChange: path => {
5848
+ var _triggerFields$find2;
5849
+ const nextTrigger = (_triggerFields$find2 = _triggerFields.find(item => item.path === path)) == null ? void 0 : _triggerFields$find2.field;
5850
+ const nextOperators = getConditionOperators(nextTrigger, getFieldDefinition(nextTrigger == null ? void 0 : nextTrigger.type));
5851
+ updateCondition(index, {
5852
+ field: path,
5853
+ operator: nextOperators[0],
5854
+ value: undefined,
5855
+ flags: undefined
5856
+ });
5857
+ }
5858
+ }), /*#__PURE__*/jsx(Select$1, {
5859
+ className: style['visible-when-operator'],
5860
+ value: condition.operator,
5861
+ disabled: !trigger,
5862
+ placeholder: formatMessage({
5863
+ id: 'visibleWhenOperator'
5864
+ }),
5865
+ options: operators.map(operator => ({
5866
+ value: operator,
5867
+ label: formatMessage({
5868
+ id: `conditionOperator_${operator}`
5869
+ })
5870
+ })),
5871
+ onChange: operator => updateCondition(index, {
5872
+ operator,
5873
+ value: undefined,
5874
+ flags: undefined
5875
+ })
5876
+ })]
5877
+ }), trigger && condition.operator ? /*#__PURE__*/jsx(ConditionValueInput, {
5878
+ condition: condition,
5879
+ trigger: trigger,
5880
+ onChange: patch => updateCondition(index, patch)
5881
+ }) : null]
5882
+ }), /*#__PURE__*/jsx(Button, {
5883
+ type: "text",
5884
+ danger: true,
5885
+ className: style['icon-square-btn-sm'],
5886
+ icon: /*#__PURE__*/jsx(DeleteOutlined, {}),
5887
+ onClick: () => {
5888
+ const next = conditions.filter((_, itemIndex) => itemIndex !== index);
5889
+ onChange(next.length ? _extends({}, value, {
5890
+ conditions: next
5891
+ }) : undefined);
5892
+ }
5893
+ })]
5894
+ }, index);
5895
+ })
5896
+ }), /*#__PURE__*/jsx(Button, {
5897
+ type: "dashed",
5898
+ block: true,
5899
+ icon: /*#__PURE__*/jsx(PlusOutlined, {}),
5900
+ onClick: () => updateConditions([...conditions, createCondition()]),
5901
+ children: formatMessage({
5902
+ id: 'visibleWhenAddCondition'
5903
+ })
5904
+ })]
5905
+ }) : null]
5906
+ }, "visible-when");
5907
+ return /*#__PURE__*/jsx(FormInfo, {
5908
+ title: formatMessage({
5909
+ id: 'visibleWhenTitle'
5910
+ }),
5911
+ column: 1,
5912
+ list: [body]
5913
+ });
5914
+ };
5915
+ var VisibleWhenEditor$1 = VisibleWhenEditor;
5916
+
5917
+ const _excluded$2 = ["columns"];
4905
5918
  const {
4906
5919
  Text
4907
5920
  } = Typography;
@@ -4917,7 +5930,7 @@ const getDefaultSelectProps = () => ({
4917
5930
  columns: [createEmptyColumn()]
4918
5931
  });
4919
5932
  const omitColumns = (_ref = {}) => {
4920
- let rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
5933
+ let rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
4921
5934
  return rest;
4922
5935
  };
4923
5936
  const FieldConfigFields = ({
@@ -4925,7 +5938,10 @@ const FieldConfigFields = ({
4925
5938
  options,
4926
5939
  onOptionsChange,
4927
5940
  columns,
4928
- onColumnsChange
5941
+ onColumnsChange,
5942
+ visibleWhen,
5943
+ onVisibleWhenChange,
5944
+ conditionProps
4929
5945
  }) => {
4930
5946
  const {
4931
5947
  formatMessage
@@ -5049,13 +6065,17 @@ const FieldConfigFields = ({
5049
6065
  hasColumns: definition.hasColumns,
5050
6066
  columns: columns,
5051
6067
  onColumnsChange: onColumnsChange
5052
- }) : null]
6068
+ }) : null, conditionProps ? /*#__PURE__*/jsx(VisibleWhenEditor$1, _extends({}, conditionProps, {
6069
+ value: visibleWhen,
6070
+ onChange: onVisibleWhenChange
6071
+ })) : null]
5053
6072
  });
5054
6073
  };
5055
6074
  const FieldEditorModal = ({
5056
6075
  open,
5057
6076
  field,
5058
6077
  fieldList,
6078
+ conditionProps,
5059
6079
  onCancel,
5060
6080
  onSave,
5061
6081
  renderModal
@@ -5091,6 +6111,7 @@ const FieldEditorModal = ({
5091
6111
  value: ''
5092
6112
  }]);
5093
6113
  const [columns, setColumns] = useState(() => [createEmptyColumn()]);
6114
+ const [visibleWhen, setVisibleWhen] = useState(undefined);
5094
6115
  useEffect(() => {
5095
6116
  var _editorValues$options, _editorValues$selectP;
5096
6117
  if (!open) {
@@ -5101,15 +6122,23 @@ const FieldEditorModal = ({
5101
6122
  value: ''
5102
6123
  }]);
5103
6124
  setColumns((_editorValues$selectP = editorValues.selectProps) != null && (_editorValues$selectP = _editorValues$selectP.columns) != null && _editorValues$selectP.length ? editorValues.selectProps.columns : [createEmptyColumn()]);
6125
+ setVisibleWhen(editorValues.visibleWhen);
5104
6126
  }, [open, editorValues]);
5105
6127
  const handleSubmit = async values => {
5106
- var _values$lenMin, _values$lenMax;
6128
+ var _conditionProps$scope, _values$lenMin, _values$lenMax;
5107
6129
  if (!isFieldNameUnique(fieldList, values.name, field == null ? void 0 : field.id)) {
5108
6130
  message.error(formatMessage({
5109
6131
  id: 'fieldNameDuplicate'
5110
6132
  }));
5111
6133
  return false;
5112
6134
  }
6135
+ const conditionError = conditionProps && !((_conditionProps$scope = conditionProps.scope) != null && _conditionProps$scope.inList) ? validateVisibleWhenDraft(visibleWhen) : null;
6136
+ if (conditionError) {
6137
+ message.error(formatMessage({
6138
+ id: conditionError
6139
+ }));
6140
+ return false;
6141
+ }
5113
6142
  const definition = getFieldDefinition(values.type);
5114
6143
  const normalizedColumns = definition != null && definition.hasColumns ? normalizeColumns(columns) : [];
5115
6144
  const nextField = formValuesToField(_extends({}, values, {
@@ -5125,12 +6154,13 @@ const FieldEditorModal = ({
5125
6154
  selectProps: _extends({}, values, {
5126
6155
  columns: normalizedColumns
5127
6156
  }),
5128
- fieldProps: values
6157
+ fieldProps: values,
6158
+ visibleWhen
5129
6159
  }), field || createField$1());
5130
6160
  if (!nextField.id) {
5131
6161
  nextField.id = createField$1().id;
5132
6162
  }
5133
- onSave(nextField);
6163
+ return onSave(nextField);
5134
6164
  };
5135
6165
  const modalKey = open ? field != null && field.id ? `edit-${field.id}` : `add-${formData.name}` : 'closed';
5136
6166
  return /*#__PURE__*/jsx(FormModal, _extends({
@@ -5160,7 +6190,12 @@ const FieldEditorModal = ({
5160
6190
  options: options,
5161
6191
  onOptionsChange: setOptions,
5162
6192
  columns: columns,
5163
- onColumnsChange: setColumns
6193
+ onColumnsChange: setColumns,
6194
+ visibleWhen: visibleWhen,
6195
+ onVisibleWhenChange: setVisibleWhen,
6196
+ conditionProps: conditionProps ? _extends({}, conditionProps, {
6197
+ fieldId: field == null ? void 0 : field.id
6198
+ }) : null
5164
6199
  })
5165
6200
  }), modalKey);
5166
6201
  };
@@ -5617,6 +6652,52 @@ const ChoiceBlock = ({
5617
6652
  };
5618
6653
  var ChoiceBlock$1 = ChoiceBlock;
5619
6654
 
6655
+ const _excluded$1 = ["entries", "nested", "knownNames"];
6656
+
6657
+ /**
6658
+ * 按 visibleWhen 过滤字段的 FormInfo:
6659
+ * entries 为 [{ element, path, visibleWhen }],不满足条件的字段从 list 中移除(卸载即不参与校验),
6660
+ * 已有值的隐藏字段清空,避免提交残留
6661
+ */
6662
+ const ConditionalFormInfo = _ref => {
6663
+ let {
6664
+ entries,
6665
+ nested = [],
6666
+ knownNames
6667
+ } = _ref,
6668
+ formInfoProps = _objectWithoutPropertiesLoose(_ref, _excluded$1);
6669
+ const {
6670
+ formData,
6671
+ openApi
6672
+ } = useFormContext() || {};
6673
+ const hasForm = !!openApi;
6674
+ const hiddenPaths = useMemo(() => {
6675
+ if (!hasForm) {
6676
+ return [];
6677
+ }
6678
+ return entries.filter(entry => entry.visibleWhen && !evaluateVisibleWhen(entry.visibleWhen, formData, knownNames)).map(entry => entry.path);
6679
+ }, [entries, formData, knownNames, hasForm]);
6680
+ useEffect(() => {
6681
+ if (!hasForm) {
6682
+ return;
6683
+ }
6684
+ const toClear = hiddenPaths.filter(path => !isEmptyValue$1(getByPath$2(formData, path)));
6685
+ if (toClear.length) {
6686
+ openApi.setFields(toClear.map(name => ({
6687
+ name,
6688
+ value: undefined
6689
+ })), {
6690
+ runValidate: false
6691
+ });
6692
+ }
6693
+ }, [hiddenPaths, formData, openApi, hasForm]);
6694
+ const list = entries.filter(entry => !hiddenPaths.includes(entry.path)).map(entry => entry.element);
6695
+ return /*#__PURE__*/createElement(FormInfo, _extends({}, formInfoProps, {
6696
+ list: [...list, ...nested]
6697
+ }));
6698
+ };
6699
+ var ConditionalFormInfo$1 = ConditionalFormInfo;
6700
+
5620
6701
  // @kne/react-form 内置规则的错误提示写死中文;在 preset 覆盖前记下原函数,只替换未被业务覆盖的规则
5621
6702
  const BUILTIN_RULES = {
5622
6703
  TEL: RULES.TEL,
@@ -5689,18 +6770,18 @@ const buildIndexedLabelRender = index => {
5689
6770
  label
5690
6771
  }) => {
5691
6772
  const text = label != null ? String(label).replace(/\u200b/g, '') : '';
5692
- return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement('span', {
6773
+ return /*#__PURE__*/createElement(Fragment$1, null, /*#__PURE__*/createElement('span', {
5693
6774
  className: style['field-label-index']
5694
6775
  }, `${index + 1}.`), text ? /*#__PURE__*/createElement('span', {
5695
6776
  className: style['field-label-main']
5696
6777
  }, text) : null);
5697
6778
  };
5698
6779
  };
5699
- const renderFieldElements = (fields = [], preview = false, {
6780
+ const renderFieldEntries = (fields = [], preview = false, {
5700
6781
  namePrefix,
5701
6782
  locale,
5702
6783
  showIndex: _showIndex = false
5703
- } = {}) => fields.filter(field => !field.hidden).map((field, index) => {
6784
+ } = {}) => (fields || []).filter(field => !field.hidden).map((field, index) => {
5704
6785
  var _props$options;
5705
6786
  const Component = getFieldComponent(field.type, field);
5706
6787
  if (!Component) {
@@ -5734,7 +6815,7 @@ const renderFieldElements = (fields = [], preview = false, {
5734
6815
  locale
5735
6816
  } : {};
5736
6817
  const label = buildFieldLabel(field);
5737
- return /*#__PURE__*/createElement(Component, _extends({
6818
+ const element = /*#__PURE__*/createElement(Component, _extends({
5738
6819
  key: field.id,
5739
6820
  name: fieldName,
5740
6821
  label: _showIndex ? label || '\u200b' : label
@@ -5747,7 +6828,27 @@ const renderFieldElements = (fields = [], preview = false, {
5747
6828
  labelTips: buildLabelTips(field.tips),
5748
6829
  description
5749
6830
  }));
6831
+ return {
6832
+ element,
6833
+ path: fieldName,
6834
+ visibleWhen: hasVisibleWhen(field) ? field.visibleWhen : null
6835
+ };
5750
6836
  }).filter(Boolean);
6837
+ const renderFieldElements = (fields, preview, opts) => renderFieldEntries(fields, preview, opts).map(entry => entry.element);
6838
+
6839
+ /** 字段含 visibleWhen 时换成 ConditionalFormInfo,否则保持普通 FormInfo */
6840
+ const createFieldsFormInfo = (formInfoProps, entries, nested = [], knownNames) => {
6841
+ if (entries.some(entry => entry.visibleWhen)) {
6842
+ return /*#__PURE__*/createElement(ConditionalFormInfo$1, _extends({}, formInfoProps, {
6843
+ entries,
6844
+ nested,
6845
+ knownNames
6846
+ }));
6847
+ }
6848
+ return /*#__PURE__*/createElement(FormInfo, _extends({}, formInfoProps, {
6849
+ list: [...entries.map(entry => entry.element), ...nested]
6850
+ }));
6851
+ };
5751
6852
  const withBlockLayout = (element, forceBlock) => {
5752
6853
  var _element$props;
5753
6854
  if (!element || !forceBlock) {
@@ -5784,7 +6885,8 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5784
6885
  formatMessage,
5785
6886
  depth = 0,
5786
6887
  asListItem = false,
5787
- locale
6888
+ locale,
6889
+ knownNames
5788
6890
  } = ctx;
5789
6891
  if (!block || depth > MAX_BLOCK_DEPTH) {
5790
6892
  return null;
@@ -5812,39 +6914,37 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5812
6914
  case 'formInfo':
5813
6915
  {
5814
6916
  const showIndex = !!block.showIndex;
5815
- const fields = renderFieldElements(block.list, preview, _extends({}, fieldRenderOpts, {
6917
+ const entries = renderFieldEntries(block.list, preview, _extends({}, fieldRenderOpts, {
5816
6918
  showIndex
5817
6919
  }));
5818
6920
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
5819
- return withBlockLayout(/*#__PURE__*/createElement(FormInfo, _extends({
6921
+ return withBlockLayout(createFieldsFormInfo(_extends({
5820
6922
  key: block.id,
5821
6923
  title: block.title || undefined,
5822
6924
  subtitle: block.subtitle || undefined,
5823
6925
  column: block.column,
5824
6926
  gap: block.gap,
5825
- bordered,
5826
- list: [...fields, ...nested]
6927
+ bordered
5827
6928
  }, listItemPartProps || {}, {
5828
6929
  className: resolvePartRootClassName(depth, showIndex ? style['form-info-show-index'] : null)
5829
- })), asListItem);
6930
+ }), entries, nested, knownNames), asListItem);
5830
6931
  }
5831
6932
  case 'object':
5832
6933
  {
5833
- const fields = renderFieldElements(block.list, preview, _extends({}, fieldRenderOpts, {
6934
+ const entries = renderFieldEntries(block.list, preview, _extends({}, fieldRenderOpts, {
5834
6935
  namePrefix: block.name || ''
5835
6936
  }));
5836
6937
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
5837
- return withBlockLayout(/*#__PURE__*/createElement(FormInfo, _extends({
6938
+ return withBlockLayout(createFieldsFormInfo(_extends({
5838
6939
  key: block.id,
5839
6940
  title: block.title || undefined,
5840
6941
  subtitle: block.subtitle || undefined,
5841
6942
  column: block.column,
5842
6943
  gap: block.gap,
5843
- bordered,
5844
- list: [...fields, ...nested]
6944
+ bordered
5845
6945
  }, listItemPartProps || {}, {
5846
6946
  className: resolvePartRootClassName(depth)
5847
- })), asListItem);
6947
+ }), entries, nested, knownNames), asListItem);
5848
6948
  }
5849
6949
  case 'list':
5850
6950
  {
@@ -5935,24 +7035,24 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5935
7035
  prevIcon: /*#__PURE__*/createElement(ArrowLeftOutlined),
5936
7036
  nextIcon: /*#__PURE__*/createElement(ArrowRightOutlined),
5937
7037
  items: (block.items || []).map(step => {
5938
- const fields = renderFieldElements(step.list, preview, fieldRenderOpts);
7038
+ const entries = renderFieldEntries(step.list, preview, fieldRenderOpts);
5939
7039
  const nested = renderChildBlocks(step.blocks || [], nextCtx);
5940
7040
  const fieldNames = [...(step.list || []).filter(field => field && !field.hidden && field.name).map(field => field.name), ...collectBlockFieldNames(step.blocks || [])];
5941
- if (nested.length) {
7041
+ const hasConditional = entries.some(entry => entry.visibleWhen);
7042
+ if (nested.length || hasConditional) {
5942
7043
  return {
5943
7044
  key: step.id,
5944
7045
  title: step.title,
5945
7046
  column: step.column,
5946
7047
  gap: block.gap,
5947
7048
  fieldNames,
5948
- children: /*#__PURE__*/createElement(Fragment, {
7049
+ children: /*#__PURE__*/createElement(Fragment$1, {
5949
7050
  key: `${step.id}-body`
5950
- }, fields.length ? /*#__PURE__*/createElement(FormInfo, {
7051
+ }, entries.length ? createFieldsFormInfo({
5951
7052
  key: `${step.id}-fields`,
5952
7053
  column: step.column,
5953
- gap: block.gap,
5954
- list: fields
5955
- }) : null, ...nested)
7054
+ gap: block.gap
7055
+ }, entries, [], knownNames) : null, ...nested)
5956
7056
  };
5957
7057
  }
5958
7058
  return {
@@ -5960,7 +7060,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5960
7060
  title: step.title,
5961
7061
  column: step.column,
5962
7062
  gap: block.gap,
5963
- list: fields,
7063
+ list: entries.map(entry => entry.element),
5964
7064
  fieldNames
5965
7065
  };
5966
7066
  })
@@ -5977,12 +7077,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
5977
7077
  renderOptionContent: option => {
5978
7078
  const nodes = [];
5979
7079
  if ((option.list || []).length) {
5980
- nodes.push(/*#__PURE__*/createElement(FormInfo, {
7080
+ nodes.push(createFieldsFormInfo({
5981
7081
  key: `${option.id}-fields`,
5982
7082
  column: block.column || 2,
5983
- gap: block.gap,
5984
- list: renderFieldElements(option.list, preview)
5985
- }));
7083
+ gap: block.gap
7084
+ }, renderFieldEntries(option.list, preview), [], knownNames));
5986
7085
  }
5987
7086
  nodes.push(...renderChildBlocks(option.blocks || [], nextCtx));
5988
7087
  return nodes.filter(Boolean);
@@ -6004,10 +7103,12 @@ const renderSchemaInner = (schema, {
6004
7103
  } = {}) => {
6005
7104
  const normalized = normalizeSchema(schema);
6006
7105
  const blocks = normalized.blocks || [];
7106
+ const knownNames = collectTriggerNames(normalized);
6007
7107
  const contentChildren = blocks.map(block => renderBlockElement(block, _preview, {
6008
7108
  isMobile: _isMobile,
6009
7109
  formatMessage,
6010
- locale
7110
+ locale,
7111
+ knownNames
6011
7112
  })).filter(Boolean);
6012
7113
  if (!contentChildren.length && !children && !actionNode) {
6013
7114
  return null;
@@ -6015,7 +7116,7 @@ const renderSchemaInner = (schema, {
6015
7116
  const body = /*#__PURE__*/createElement('div', {
6016
7117
  className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
6017
7118
  }, ...contentChildren, children);
6018
- const content = /*#__PURE__*/createElement(Fragment, null, body, actionNode || null);
7119
+ const content = /*#__PURE__*/createElement(Fragment$1, null, body, actionNode || null);
6019
7120
  return className ? /*#__PURE__*/createElement('div', {
6020
7121
  className
6021
7122
  }, content) : content;
@@ -6033,10 +7134,12 @@ const renderSchemaContent = (schema, {
6033
7134
  } = {}) => {
6034
7135
  const normalized = normalizeSchema(schema);
6035
7136
  const blocks = normalized.blocks || [];
7137
+ const knownNames = collectTriggerNames(normalized);
6036
7138
  const contentChildren = blocks.map(block => renderBlockElement(block, _preview2, {
6037
7139
  isMobile: _isMobile2,
6038
7140
  formatMessage,
6039
- locale
7141
+ locale,
7142
+ knownNames
6040
7143
  })).filter(Boolean);
6041
7144
  if (!contentChildren.length && !children) {
6042
7145
  return null;
@@ -6361,6 +7464,9 @@ const FormCreator = withLocale$1(({
6361
7464
  clearBlockEditor();
6362
7465
  };
6363
7466
  const handleDeleteBlock = blockId => {
7467
+ if (blockHasLockedField(findBlock(schema, blockId))) {
7468
+ return;
7469
+ }
6364
7470
  updateSchema(updateBlocks(schema, blocks => removeBlockInTree(blocks, blockId)));
6365
7471
  };
6366
7472
  const handleMoveBlock = (blockId, direction) => {
@@ -6395,12 +7501,12 @@ const FormCreator = withLocale$1(({
6395
7501
  };
6396
7502
  const handleDeleteStep = (blockId, stepId) => {
6397
7503
  updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
6398
- items: (block.items || []).filter(item => item.id !== stepId)
7504
+ items: (block.items || []).filter(item => item.id !== stepId || blockHasLockedField(item))
6399
7505
  })));
6400
7506
  };
6401
7507
  const handleMoveStep = (blockId, stepId, direction) => {
6402
7508
  updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
6403
- items: moveItem(block.items || [], stepId, direction)
7509
+ items: moveItem(block.items || [], stepId, direction, blockHasLockedField)
6404
7510
  })));
6405
7511
  };
6406
7512
  const handleAddChoiceOption = blockId => {
@@ -6432,12 +7538,12 @@ const FormCreator = withLocale$1(({
6432
7538
  };
6433
7539
  const handleDeleteChoiceOption = (blockId, optionId) => {
6434
7540
  updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
6435
- options: (block.options || []).filter(item => item.id !== optionId)
7541
+ options: (block.options || []).filter(item => item.id !== optionId || blockHasLockedField(item))
6436
7542
  })));
6437
7543
  };
6438
7544
  const handleMoveChoiceOption = (blockId, optionId, direction) => {
6439
7545
  updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
6440
- options: moveItem(block.options || [], optionId, direction)
7546
+ options: moveItem(block.options || [], optionId, direction, blockHasLockedField)
6441
7547
  })));
6442
7548
  };
6443
7549
  const normalizeFieldScope = scope => {
@@ -6456,6 +7562,9 @@ const FormCreator = withLocale$1(({
6456
7562
  setFieldEditorOpen(true);
6457
7563
  };
6458
7564
  const handleEditField = (blockId, field, scope) => {
7565
+ if (isFieldLocked(field)) {
7566
+ return;
7567
+ }
6459
7568
  setFieldContext(_extends({
6460
7569
  blockId
6461
7570
  }, normalizeFieldScope(scope)));
@@ -6468,7 +7577,7 @@ const FormCreator = withLocale$1(({
6468
7577
  stepId,
6469
7578
  optionId
6470
7579
  } = fieldContext || {};
6471
- updateSchema(mapBlocks(schema, blockId, block => {
7580
+ let nextSchema = mapBlocks(schema, blockId, block => {
6472
7581
  if (block.kind === 'steps') {
6473
7582
  return _extends({}, block, {
6474
7583
  items: (block.items || []).map(step => {
@@ -6499,7 +7608,21 @@ const FormCreator = withLocale$1(({
6499
7608
  return _extends({}, block, {
6500
7609
  list: exists ? block.list.map(item => item.id === field.id ? field : item) : [...(block.list || []), field]
6501
7610
  });
6502
- }));
7611
+ });
7612
+ if (editingField != null && editingField.name && editingField.name !== field.name) {
7613
+ const scope = getBlockConditionScope(schema, blockId);
7614
+ nextSchema = renameConditionReferences(nextSchema, getFieldConditionPath(scope, editingField.name), getFieldConditionPath(scope, field.name));
7615
+ }
7616
+ const cycle = findConditionCycle(nextSchema);
7617
+ if (cycle) {
7618
+ message.error(formatMessage({
7619
+ id: 'visibleWhenCycle'
7620
+ }, {
7621
+ path: cycle.join(' → ')
7622
+ }));
7623
+ return false;
7624
+ }
7625
+ updateSchema(nextSchema);
6503
7626
  setFieldEditorOpen(false);
6504
7627
  setFieldContext(null);
6505
7628
  setEditingField(null);
@@ -6513,19 +7636,19 @@ const FormCreator = withLocale$1(({
6513
7636
  if (block.kind === 'steps') {
6514
7637
  return _extends({}, block, {
6515
7638
  items: (block.items || []).map(step => step.id === stepId ? _extends({}, step, {
6516
- list: (step.list || []).filter(item => item.id !== fieldId)
7639
+ list: (step.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6517
7640
  }) : step)
6518
7641
  });
6519
7642
  }
6520
7643
  if (block.kind === 'choice') {
6521
7644
  return _extends({}, block, {
6522
7645
  options: (block.options || []).map(option => option.id === optionId ? _extends({}, option, {
6523
- list: (option.list || []).filter(item => item.id !== fieldId)
7646
+ list: (option.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6524
7647
  }) : option)
6525
7648
  });
6526
7649
  }
6527
7650
  return _extends({}, block, {
6528
- list: (block.list || []).filter(item => item.id !== fieldId)
7651
+ list: (block.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
6529
7652
  });
6530
7653
  }));
6531
7654
  };
@@ -6559,6 +7682,11 @@ const FormCreator = withLocale$1(({
6559
7682
  stepId: fieldContext.stepId,
6560
7683
  optionId: fieldContext.optionId
6561
7684
  }) : [];
7685
+ const conditionProps = useMemo(() => fieldContext ? {
7686
+ schema,
7687
+ scope: getBlockConditionScope(schema, fieldContext.blockId),
7688
+ triggerFields: collectConditionFields(schema).filter(item => !item.inList)
7689
+ } : null, [schema, fieldContext]);
6562
7690
  const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
6563
7691
  schema
6564
7692
  }) : extraToolbar;
@@ -6634,6 +7762,7 @@ const FormCreator = withLocale$1(({
6634
7762
  open: fieldEditorOpen,
6635
7763
  field: editingField,
6636
7764
  fieldList: currentFieldScope,
7765
+ conditionProps: conditionProps,
6637
7766
  renderModal: renderModal,
6638
7767
  onCancel: () => {
6639
7768
  setFieldEditorOpen(false);
@@ -6970,7 +8099,7 @@ const formatDateToToday = (value, itemSchema, ctx) => {
6970
8099
  if (items[1] == null || items[1] === '' || items[1] === true) {
6971
8100
  const until = (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
6972
8101
  id: 'schemaContentUntilToday'
6973
- })) || defaultLocale.schemaContentUntilToday;
8102
+ })) || zhCN.schemaContentUntilToday;
6974
8103
  return [start, until].filter(Boolean).join(' ~ ');
6975
8104
  }
6976
8105
  const end = formatByValueSchema(items[1], itemSchema, ctx);
@@ -7025,11 +8154,11 @@ const formatBoolean = (value, field, ctx) => {
7025
8154
  if (value) {
7026
8155
  return props.checkedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
7027
8156
  id: 'schemaContentYes'
7028
- })) || defaultLocale.schemaContentYes;
8157
+ })) || zhCN.schemaContentYes;
7029
8158
  }
7030
8159
  return props.unCheckedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
7031
8160
  id: 'schemaContentNo'
7032
- })) || defaultLocale.schemaContentNo;
8161
+ })) || zhCN.schemaContentNo;
7033
8162
  };
7034
8163
  const stringifyFallback = value => {
7035
8164
  if (value == null) {
@@ -7249,8 +8378,43 @@ const resolveChoiceSelectorName$1 = block => {
7249
8378
  }
7250
8379
  return `__choice_${block.id}`;
7251
8380
  };
8381
+
8382
+ /** 条件说明文案:按 options.locale 取包内语言包,英文以外回退中文 */
8383
+ const createConditionContext = (normalized, locale) => {
8384
+ const messages = String(locale || '').startsWith('en') ? enUS : zhCN;
8385
+ const formatMessage = ({
8386
+ id
8387
+ }, values = {}) => {
8388
+ var _messages$id;
8389
+ return String((_messages$id = messages[id]) != null ? _messages$id : id).replace(/\{(\w+)\}/g, (match, key) => values[key] != null ? values[key] : match);
8390
+ };
8391
+ const conditionFields = collectConditionFields(normalized).filter(item => !item.inList);
8392
+ return {
8393
+ formatMessage,
8394
+ knownNames: new Set(conditionFields.map(item => item.path)),
8395
+ fieldLookup: new Map(conditionFields.map(item => [item.path, item.field]))
8396
+ };
8397
+ };
8398
+ const describeVisibleWhen = (field, ctx) => {
8399
+ const visibleWhen = _extends({}, field.visibleWhen, {
8400
+ conditions: field.visibleWhen.conditions.filter(condition => ctx.knownNames.has(condition == null ? void 0 : condition.field))
8401
+ });
8402
+ if (!visibleWhen.conditions.length) {
8403
+ return '';
8404
+ }
8405
+ const condition = formatVisibleWhen(visibleWhen, {
8406
+ formatMessage: ctx.formatMessage,
8407
+ fieldLookup: ctx.fieldLookup
8408
+ });
8409
+ return ctx.formatMessage({
8410
+ id: 'conditionDescription'
8411
+ }, {
8412
+ condition
8413
+ });
8414
+ };
7252
8415
  const mergeFieldIntoLayer = (layer, field, {
7253
- allowRequired: _allowRequired = true
8416
+ allowRequired: _allowRequired = true,
8417
+ ctx
7254
8418
  } = {}) => {
7255
8419
  if (!(field != null && field.name)) {
7256
8420
  return;
@@ -7259,8 +8423,14 @@ const mergeFieldIntoLayer = (layer, field, {
7259
8423
  if (!name) {
7260
8424
  return;
7261
8425
  }
7262
- layer.properties[name] = resolveFieldValueSchema(field);
7263
- if (_allowRequired && isReq(field.rule) && !layer.required.includes(name)) {
8426
+ const valueSchema = resolveFieldValueSchema(field);
8427
+ const conditionText = ctx != null && ctx.formatMessage && hasVisibleWhen(field) ? describeVisibleWhen(field, ctx) : '';
8428
+ if (conditionText) {
8429
+ valueSchema.description = valueSchema.description ? `${valueSchema.description}\n${conditionText}` : conditionText;
8430
+ }
8431
+ layer.properties[name] = valueSchema;
8432
+ // 条件显示字段可能不出现在提交数据中,不进 required
8433
+ if (_allowRequired && !conditionText && isReq(field.rule) && !layer.required.includes(name)) {
7264
8434
  layer.required.push(name);
7265
8435
  }
7266
8436
  };
@@ -7302,33 +8472,39 @@ const finalizeObjectSchema = (layer, {
7302
8472
  }
7303
8473
  return schema;
7304
8474
  };
7305
- const walkBlocks = (blocks, layer, depth = 0) => {
8475
+ const walkBlocks = (blocks, layer, depth = 0, ctx = {}) => {
7306
8476
  (blocks || []).forEach(block => {
7307
8477
  if (!block) {
7308
8478
  return;
7309
8479
  }
7310
- walkBlock(block, layer, depth);
8480
+ walkBlock(block, layer, depth, ctx);
7311
8481
  });
7312
8482
  };
7313
- const walkBlock = (block, layer, depth = 0) => {
8483
+ const walkBlock = (block, layer, depth = 0, ctx = {}) => {
7314
8484
  switch (block.kind) {
7315
8485
  case 'formInfo':
7316
8486
  {
7317
- mergeFieldsIntoLayer(layer, block.list);
7318
- walkBlocks(block.blocks, layer, depth + 1);
8487
+ mergeFieldsIntoLayer(layer, block.list, {
8488
+ ctx
8489
+ });
8490
+ walkBlocks(block.blocks, layer, depth + 1, ctx);
7319
8491
  return;
7320
8492
  }
7321
8493
  case 'object':
7322
8494
  {
7323
8495
  const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
7324
8496
  if (!name) {
7325
- mergeFieldsIntoLayer(layer, block.list);
7326
- walkBlocks(block.blocks, layer, depth + 1);
8497
+ mergeFieldsIntoLayer(layer, block.list, {
8498
+ ctx
8499
+ });
8500
+ walkBlocks(block.blocks, layer, depth + 1, ctx);
7327
8501
  return;
7328
8502
  }
7329
8503
  const nested = createObjectLayer();
7330
- mergeFieldsIntoLayer(nested, block.list);
7331
- walkBlocks(block.blocks, nested, depth + 1);
8504
+ mergeFieldsIntoLayer(nested, block.list, {
8505
+ ctx
8506
+ });
8507
+ walkBlocks(block.blocks, nested, depth + 1, ctx);
7332
8508
  layer.properties[name] = finalizeObjectSchema(nested, {
7333
8509
  title: block.title || undefined,
7334
8510
  description: block.subtitle || undefined
@@ -7391,14 +8567,16 @@ const walkBlock = (block, layer, depth = 0) => {
7391
8567
  case 'steps':
7392
8568
  {
7393
8569
  (block.items || []).forEach(step => {
7394
- mergeFieldsIntoLayer(layer, step == null ? void 0 : step.list);
7395
- walkBlocks(step == null ? void 0 : step.blocks, layer, depth + 1);
8570
+ mergeFieldsIntoLayer(layer, step == null ? void 0 : step.list, {
8571
+ ctx
8572
+ });
8573
+ walkBlocks(step == null ? void 0 : step.blocks, layer, depth + 1, ctx);
7396
8574
  });
7397
8575
  return;
7398
8576
  }
7399
8577
  case 'choice':
7400
8578
  {
7401
- mergeChoiceIntoLayer(layer, block, depth);
8579
+ mergeChoiceIntoLayer(layer, block, depth, ctx);
7402
8580
  return;
7403
8581
  }
7404
8582
  default:
@@ -7411,7 +8589,7 @@ const walkBlock = (block, layer, depth = 0) => {
7411
8589
  * 每支为 object:单选支含 selector const;多选支为该 option 字段,selector 数组放在当前层。
7412
8590
  * 支内 REQ 可进 required;hidden 字段仍进入 schema。
7413
8591
  */
7414
- const mergeChoiceIntoLayer = (layer, block, depth) => {
8592
+ const mergeChoiceIntoLayer = (layer, block, depth, ctx) => {
7415
8593
  const mode = block.mode === 'multiple' ? 'multiple' : 'single';
7416
8594
  const selectorInData = block.selectorInData !== false;
7417
8595
  const selectorName = resolveChoiceSelectorName$1(block);
@@ -7429,9 +8607,10 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
7429
8607
  branch.required.push(selectorName);
7430
8608
  }
7431
8609
  mergeFieldsIntoLayer(branch, option.list, {
7432
- allowRequired: true
8610
+ allowRequired: true,
8611
+ ctx
7433
8612
  });
7434
- walkBlocks(option.blocks, branch, depth + 1);
8613
+ walkBlocks(option.blocks, branch, depth + 1, ctx);
7435
8614
  return finalizeObjectSchema(branch, {
7436
8615
  title: optionTitle
7437
8616
  });
@@ -7512,7 +8691,7 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
7512
8691
  const schemaToDataSchema = (schema, options = {}) => {
7513
8692
  const normalized = normalizeSchema(localizeSchema(schema || {}, options.locale, options.languages));
7514
8693
  const layer = createObjectLayer();
7515
- walkBlocks(normalized.blocks, layer, 0);
8694
+ walkBlocks(normalized.blocks, layer, 0, createConditionContext(normalized, options.locale));
7516
8695
  const root = finalizeObjectSchema(layer, {
7517
8696
  title: normalized.title || undefined,
7518
8697
  description: options.description
@@ -7548,9 +8727,10 @@ const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValu
7548
8727
  * 改为 label 在上、值在下,避免窄栏(如弹窗双栏预览)被撑乱。
7549
8728
  */
7550
8729
  const renderFieldsContent = (fields, data, formatMessage, column, {
7551
- showIndex: _showIndex = false
8730
+ showIndex: _showIndex = false,
8731
+ isFieldVisible
7552
8732
  } = {}) => {
7553
- const list = (fields || []).filter(field => field && !field.hidden && field.name).map((field, index) => {
8733
+ const list = (fields || []).filter(field => field && !field.hidden && field.name && (!isFieldVisible || isFieldVisible(field))).map((field, index) => {
7554
8734
  const baseLabel = field.label || field.name;
7555
8735
  const label = _showIndex ? `${index + 1}. ${baseLabel}` : baseLabel;
7556
8736
  return {
@@ -7585,7 +8765,8 @@ const renderBlock = (block, data, ctx) => {
7585
8765
  const {
7586
8766
  formatMessage,
7587
8767
  isMobile,
7588
- depth = 0
8768
+ depth = 0,
8769
+ isFieldVisible
7589
8770
  } = ctx;
7590
8771
  if (!block || depth > MAX_BLOCK_DEPTH) {
7591
8772
  return null;
@@ -7606,7 +8787,8 @@ const renderBlock = (block, data, ctx) => {
7606
8787
  {
7607
8788
  return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
7608
8789
  children: [renderFieldsContent(block.list, data, formatMessage, block.column, {
7609
- showIndex: !!block.showIndex
8790
+ showIndex: !!block.showIndex,
8791
+ isFieldVisible
7610
8792
  }), renderBlockList(block.blocks, data, nextCtx)]
7611
8793
  }));
7612
8794
  }
@@ -7615,7 +8797,9 @@ const renderBlock = (block, data, ctx) => {
7615
8797
  const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
7616
8798
  const nestedData = name ? getByPath(data, name) || {} : data;
7617
8799
  return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
7618
- children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column), renderBlockList(block.blocks, nestedData, nextCtx)]
8800
+ children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column, {
8801
+ isFieldVisible
8802
+ }), renderBlockList(block.blocks, nestedData, nextCtx)]
7619
8803
  }));
7620
8804
  }
7621
8805
  case 'list':
@@ -7670,11 +8854,13 @@ const renderBlock = (block, data, ctx) => {
7670
8854
  }
7671
8855
  case 'steps':
7672
8856
  {
7673
- return /*#__PURE__*/jsx(Fragment, {
8857
+ return /*#__PURE__*/jsx(Fragment$1, {
7674
8858
  children: (block.items || []).map(step => /*#__PURE__*/jsxs(InfoPage.Part, {
7675
8859
  title: step.title || undefined,
7676
8860
  bordered: bordered,
7677
- children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2), renderBlockList(step.blocks, data, nextCtx)]
8861
+ children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2, {
8862
+ isFieldVisible
8863
+ }), renderBlockList(step.blocks, data, nextCtx)]
7678
8864
  }, step.id))
7679
8865
  }, block.id);
7680
8866
  }
@@ -7689,7 +8875,9 @@ const renderBlock = (block, data, ctx) => {
7689
8875
  children: visibleOptions.map(option => /*#__PURE__*/jsxs(InfoPage.Part, {
7690
8876
  title: option.title || undefined,
7691
8877
  bordered: false,
7692
- children: [renderFieldsContent(option.list, data, formatMessage, block.column), renderBlockList(option.blocks, data, nextCtx)]
8878
+ children: [renderFieldsContent(option.list, data, formatMessage, block.column, {
8879
+ isFieldVisible
8880
+ }), renderBlockList(option.blocks, data, nextCtx)]
7693
8881
  }, option.id))
7694
8882
  }));
7695
8883
  }
@@ -7709,10 +8897,15 @@ const SchemaContentInnerView = ({
7709
8897
  } = useIntl();
7710
8898
  const isMobile = useIsMobile();
7711
8899
  const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
7712
- const children = renderBlockList(normalized.blocks, data || {}, {
8900
+ const rootData = data || {};
8901
+ const knownNames = collectTriggerNames(normalized);
8902
+ // 条件按提交数据根路径判断(object 内字段同样用完整路径)
8903
+ const isFieldVisible = field => evaluateVisibleWhen(field.visibleWhen, rootData, knownNames);
8904
+ const children = renderBlockList(normalized.blocks, rootData, {
7713
8905
  formatMessage,
7714
8906
  isMobile,
7715
- depth: 0
8907
+ depth: 0,
8908
+ isFieldVisible
7716
8909
  });
7717
8910
  if (!children.length) {
7718
8911
  return null;
@@ -7723,7 +8916,7 @@ const SchemaContentInnerView = ({
7723
8916
  children: children
7724
8917
  });
7725
8918
  }
7726
- return /*#__PURE__*/jsx(Fragment, {
8919
+ return /*#__PURE__*/jsx(Fragment$1, {
7727
8920
  children: children
7728
8921
  });
7729
8922
  };
@@ -7759,5 +8952,5 @@ const SchemaContent = withLocale$1(({
7759
8952
  });
7760
8953
  var SchemaContent$1 = SchemaContent;
7761
8954
 
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 };
8955
+ 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
8956
  //# sourceMappingURL=index.modern.js.map