@kne/form-creator 0.1.23 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -20
- package/dist/index.css +154 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +1866 -342
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1853 -363
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +51 -1
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +51 -1
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +51 -1
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +51 -1
- package/dist/locale/zh-CN.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -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 { useState, useRef, useMemo, useEffect, useCallback,
|
|
5
|
-
import { Space, Tag, Button, Typography, Flex, Dropdown, Empty, message, Checkbox as Checkbox$1,
|
|
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,
|
|
9
|
-
import { hooks, Input, TextArea, InputNumber, Select, RadioGroup, CheckboxGroup, Switch, Checkbox, DatePicker, useFormContext, Slider, SubmitButton, ResetButton, CancelButton,
|
|
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
|
+
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 { jsxs,
|
|
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","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: '未命名填写项',
|
|
@@ -278,9 +280,57 @@ const locale$1 = {
|
|
|
278
280
|
schemaContentNo: '否',
|
|
279
281
|
schemaContentItemIndex: '第 {index} 项',
|
|
280
282
|
schemaContentUntilToday: '至今',
|
|
281
|
-
schemaContentPasswordMasked: '••••••'
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
schemaContentPasswordMasked: '••••••',
|
|
284
|
+
ruleErrorTEL: '请输入有效的手机号',
|
|
285
|
+
ruleErrorEMAIL: '请输入有效的邮箱',
|
|
286
|
+
ruleErrorLenEqual: '%s长度必须等于{end}',
|
|
287
|
+
ruleErrorLenMin: '%s长度必须大于{start}',
|
|
288
|
+
ruleErrorLenMax: '%s长度必须小于{end}',
|
|
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;
|
|
284
334
|
|
|
285
335
|
const locale = {
|
|
286
336
|
addField: 'Add Field',
|
|
@@ -417,6 +467,8 @@ const locale = {
|
|
|
417
467
|
fieldBlock: 'Full Width',
|
|
418
468
|
fieldHidden: 'Hidden',
|
|
419
469
|
fieldHiddenTag: 'Hidden',
|
|
470
|
+
fieldLockedTag: 'Locked',
|
|
471
|
+
fieldLockedTips: 'Locked field: cannot be edited, deleted or moved',
|
|
420
472
|
fieldBlockTag: 'Full Width',
|
|
421
473
|
fieldNameDuplicate: 'This name is already in use, please choose another',
|
|
422
474
|
untitledField: 'Untitled Field',
|
|
@@ -522,20 +574,175 @@ const locale = {
|
|
|
522
574
|
schemaContentNo: 'No',
|
|
523
575
|
schemaContentItemIndex: 'Item {index}',
|
|
524
576
|
schemaContentUntilToday: 'Present',
|
|
525
|
-
schemaContentPasswordMasked: '••••••'
|
|
577
|
+
schemaContentPasswordMasked: '••••••',
|
|
578
|
+
ruleErrorTEL: 'Please enter a valid mobile number',
|
|
579
|
+
ruleErrorEMAIL: 'Please enter a valid email address',
|
|
580
|
+
ruleErrorLenEqual: '%s must be exactly {end} characters',
|
|
581
|
+
ruleErrorLenMin: '%s must be at least {start} characters',
|
|
582
|
+
ruleErrorLenMax: '%s must be at most {end} characters',
|
|
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}'
|
|
526
626
|
};
|
|
527
627
|
var enUS = locale;
|
|
528
628
|
|
|
529
629
|
const withLocale = createWithIntlProvider({
|
|
530
630
|
defaultLocale: 'zh-CN',
|
|
531
631
|
messages: {
|
|
532
|
-
'zh-CN':
|
|
632
|
+
'zh-CN': zhCN,
|
|
533
633
|
'en-US': enUS
|
|
534
634
|
},
|
|
535
635
|
namespace: 'form-creator'
|
|
536
636
|
});
|
|
537
637
|
var withLocale$1 = withLocale;
|
|
538
638
|
|
|
639
|
+
/** 未传 languages 时,多语言文案按此顺序回退 */
|
|
640
|
+
const DEFAULT_FALLBACK_LANGUAGES = ['zh-CN', 'en-US'];
|
|
641
|
+
const LOCALE_KEY = /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/;
|
|
642
|
+
const isPlainObject = value => {
|
|
643
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
644
|
+
return false;
|
|
645
|
+
}
|
|
646
|
+
const proto = Object.getPrototypeOf(value);
|
|
647
|
+
return proto === Object.prototype || proto === null;
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
/** 多语言文案:键全为语言代码、值全为字符串,如 { 'zh-CN': '姓名', 'en-US': 'Name' } */
|
|
651
|
+
const isLocaleText = value => {
|
|
652
|
+
if (!isPlainObject(value)) {
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
const keys = Object.keys(value);
|
|
656
|
+
return keys.length > 0 && keys.every(key => LOCALE_KEY.test(key) && (value[key] == null || typeof value[key] === 'string'));
|
|
657
|
+
};
|
|
658
|
+
const hasText = value => typeof value === 'string' && value.trim() !== '';
|
|
659
|
+
|
|
660
|
+
/** 规范调用方传入的语言列表 [{ value, label }],丢弃无 value 的项 */
|
|
661
|
+
const normalizeLanguages = languages => (Array.isArray(languages) ? languages : []).filter(item => item && typeof item.value === 'string' && item.value).map(item => ({
|
|
662
|
+
value: item.value,
|
|
663
|
+
label: item.label || item.value
|
|
664
|
+
}));
|
|
665
|
+
const getFallbackLanguages = languages => {
|
|
666
|
+
const list = normalizeLanguages(languages);
|
|
667
|
+
return list.length ? list.map(item => item.value) : DEFAULT_FALLBACK_LANGUAGES;
|
|
668
|
+
};
|
|
669
|
+
|
|
670
|
+
/** 普通字符串原样返回;多语言按 locale → languages 顺序(未传为 zh-CN → en-US)取第一个有内容的 */
|
|
671
|
+
const resolveLocaleText = (value, locale, languages) => {
|
|
672
|
+
if (!isLocaleText(value)) {
|
|
673
|
+
return value;
|
|
674
|
+
}
|
|
675
|
+
const language = [locale, ...getFallbackLanguages(languages)].find(key => key && hasText(value[key]));
|
|
676
|
+
return language ? value[language] : '';
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
/** 深度解析 schema(或任意片段)中的多语言文案,返回新对象 */
|
|
680
|
+
const localizeSchema = (value, locale, languages) => {
|
|
681
|
+
if (Array.isArray(value)) {
|
|
682
|
+
return value.map(item => localizeSchema(item, locale, languages));
|
|
683
|
+
}
|
|
684
|
+
if (isLocaleText(value)) {
|
|
685
|
+
return resolveLocaleText(value, locale, languages);
|
|
686
|
+
}
|
|
687
|
+
if (!isPlainObject(value)) {
|
|
688
|
+
return value;
|
|
689
|
+
}
|
|
690
|
+
return Object.keys(value).reduce((result, key) => {
|
|
691
|
+
result[key] = localizeSchema(value[key], locale, languages);
|
|
692
|
+
return result;
|
|
693
|
+
}, {});
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
/** 取某个语言的原始输入值;普通字符串视为基础语言 */
|
|
697
|
+
const getLocaleTextValue = (value, language, baseLanguage) => {
|
|
698
|
+
if (isLocaleText(value)) {
|
|
699
|
+
return value[language] || '';
|
|
700
|
+
}
|
|
701
|
+
if (value == null || typeof value === 'object') {
|
|
702
|
+
return '';
|
|
703
|
+
}
|
|
704
|
+
return language === baseLanguage ? String(value) : '';
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
/** 只有基础语言时存为字符串,保持与单语言 schema 兼容 */
|
|
708
|
+
const toLocaleText = (map = {}, baseLanguage) => {
|
|
709
|
+
const entries = Object.keys(map).filter(key => hasText(map[key])).map(key => [key, map[key]]);
|
|
710
|
+
if (!entries.length) {
|
|
711
|
+
return '';
|
|
712
|
+
}
|
|
713
|
+
if (entries.length === 1 && entries[0][0] === baseLanguage) {
|
|
714
|
+
return entries[0][1];
|
|
715
|
+
}
|
|
716
|
+
return Object.fromEntries(entries);
|
|
717
|
+
};
|
|
718
|
+
const setLocaleTextValue = (value, language, text, baseLanguage) => {
|
|
719
|
+
const map = isLocaleText(value) ? _extends({}, value) : {
|
|
720
|
+
[baseLanguage]: getLocaleTextValue(value, baseLanguage, baseLanguage)
|
|
721
|
+
};
|
|
722
|
+
map[language] = text;
|
|
723
|
+
return toLocaleText(map, baseLanguage);
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
/** 判断文案(字符串或多语言)是否有内容 */
|
|
727
|
+
const hasLocaleText = value => isLocaleText(value) ? Object.values(value).some(hasText) : value != null && String(value).trim() !== '';
|
|
728
|
+
|
|
729
|
+
/** 去除首尾空白;多语言文案逐项处理 */
|
|
730
|
+
const trimLocaleText = (value, baseLanguage) => {
|
|
731
|
+
if (isLocaleText(value)) {
|
|
732
|
+
return toLocaleText(Object.fromEntries(Object.keys(value).map(key => [key, (value[key] || '').trim()])), baseLanguage);
|
|
733
|
+
}
|
|
734
|
+
return String(value != null ? value : '').trim();
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
/** 由文案派生数据值时用基础语言,保证各语言下值一致;基础语言为空时取第一个有内容的语言 */
|
|
738
|
+
const localeTextToValue = (value, baseLanguage) => {
|
|
739
|
+
if (!isLocaleText(value)) {
|
|
740
|
+
return String(value != null ? value : '').trim();
|
|
741
|
+
}
|
|
742
|
+
const text = resolveLocaleText(value, baseLanguage) || Object.values(value).find(hasText) || '';
|
|
743
|
+
return String(text).trim();
|
|
744
|
+
};
|
|
745
|
+
|
|
539
746
|
const createFieldId = () => `field_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
540
747
|
|
|
541
748
|
/** 生成可编辑的默认数据标识,如 field_xxxx / col_xxxx */
|
|
@@ -572,6 +779,7 @@ const defaultFormActions = () => ({
|
|
|
572
779
|
gap: 16
|
|
573
780
|
});
|
|
574
781
|
const FORM_ACTIONS_ALIGN = ['center', 'start', 'end'];
|
|
782
|
+
const normalizeActionText = value => value == null ? '' : isLocaleText(value) ? _extends({}, value) : String(value);
|
|
575
783
|
const normalizeFormActions = (actions = {}) => {
|
|
576
784
|
const base = defaultFormActions();
|
|
577
785
|
if (!actions || typeof actions !== 'object') {
|
|
@@ -584,9 +792,9 @@ const normalizeFormActions = (actions = {}) => {
|
|
|
584
792
|
showSubmit: actions.showSubmit !== false,
|
|
585
793
|
showReset: actions.showReset !== false,
|
|
586
794
|
showCancel: !!actions.showCancel,
|
|
587
|
-
submitText:
|
|
588
|
-
resetText:
|
|
589
|
-
cancelText:
|
|
795
|
+
submitText: normalizeActionText(actions.submitText),
|
|
796
|
+
resetText: normalizeActionText(actions.resetText),
|
|
797
|
+
cancelText: normalizeActionText(actions.cancelText),
|
|
590
798
|
align,
|
|
591
799
|
gap
|
|
592
800
|
}, actions.submitButtonProps && typeof actions.submitButtonProps === 'object' ? {
|
|
@@ -844,7 +1052,23 @@ const normalizeSchema = (schema = {}) => {
|
|
|
844
1052
|
blocks: []
|
|
845
1053
|
});
|
|
846
1054
|
};
|
|
847
|
-
const
|
|
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) => {
|
|
848
1072
|
const index = list.findIndex(item => item.id === id);
|
|
849
1073
|
if (index < 0) {
|
|
850
1074
|
return list;
|
|
@@ -853,6 +1077,9 @@ const moveItem = (list, id, direction) => {
|
|
|
853
1077
|
if (targetIndex < 0 || targetIndex >= list.length) {
|
|
854
1078
|
return list;
|
|
855
1079
|
}
|
|
1080
|
+
if (isFixed(list[index]) || isFixed(list[targetIndex])) {
|
|
1081
|
+
return list;
|
|
1082
|
+
}
|
|
856
1083
|
const next = [...list];
|
|
857
1084
|
const [item] = next.splice(index, 1);
|
|
858
1085
|
next.splice(targetIndex, 0, item);
|
|
@@ -1157,7 +1384,7 @@ const removeBlockInTree = (blocks, blockId) => {
|
|
|
1157
1384
|
};
|
|
1158
1385
|
const moveBlockInTree = (blocks, blockId, direction) => {
|
|
1159
1386
|
if ((blocks || []).some(block => (block == null ? void 0 : block.id) === blockId)) {
|
|
1160
|
-
return moveItem(blocks, blockId, direction);
|
|
1387
|
+
return moveItem(blocks, blockId, direction, blockHasLockedField);
|
|
1161
1388
|
}
|
|
1162
1389
|
let changed = false;
|
|
1163
1390
|
const next = (blocks || []).map(block => {
|
|
@@ -1338,7 +1565,7 @@ const formValuesToChoiceOption = (values, existingOption = {}) => _extends({}, e
|
|
|
1338
1565
|
title: values.title
|
|
1339
1566
|
});
|
|
1340
1567
|
|
|
1341
|
-
const _excluded$
|
|
1568
|
+
const _excluded$5 = ["children"];
|
|
1342
1569
|
const mapOptionItem = item => {
|
|
1343
1570
|
if (!item || typeof item !== 'object') {
|
|
1344
1571
|
return item;
|
|
@@ -1346,7 +1573,7 @@ const mapOptionItem = item => {
|
|
|
1346
1573
|
const {
|
|
1347
1574
|
children
|
|
1348
1575
|
} = item,
|
|
1349
|
-
rest = _objectWithoutPropertiesLoose(item, _excluded$
|
|
1576
|
+
rest = _objectWithoutPropertiesLoose(item, _excluded$5);
|
|
1350
1577
|
const next = _extends({}, rest);
|
|
1351
1578
|
if (Array.isArray(children) && children.length) {
|
|
1352
1579
|
next.children = children.map(mapOptionItem);
|
|
@@ -1434,9 +1661,9 @@ const createApiFromOptions = (options = []) => ({
|
|
|
1434
1661
|
})
|
|
1435
1662
|
});
|
|
1436
1663
|
|
|
1437
|
-
const _excluded$
|
|
1664
|
+
const _excluded$4 = ["options", "api", "placeholder"];
|
|
1438
1665
|
const {
|
|
1439
|
-
useOnChange: useOnChange$
|
|
1666
|
+
useOnChange: useOnChange$2
|
|
1440
1667
|
} = hooks;
|
|
1441
1668
|
const hasNestedOptions = options => Array.isArray(options) && options.some(item => Array.isArray(item == null ? void 0 : item.children) && item.children.length);
|
|
1442
1669
|
const createField = (Component, {
|
|
@@ -1453,7 +1680,7 @@ const createField = (Component, {
|
|
|
1453
1680
|
api,
|
|
1454
1681
|
placeholder
|
|
1455
1682
|
} = props,
|
|
1456
|
-
rest = _objectWithoutPropertiesLoose(props, _excluded$
|
|
1683
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded$4);
|
|
1457
1684
|
const valueKey = rest.valueKey || 'value';
|
|
1458
1685
|
const labelKey = rest.labelKey || 'label';
|
|
1459
1686
|
const parentKey = rest.parentKey || 'parentId';
|
|
@@ -1472,7 +1699,7 @@ const createField = (Component, {
|
|
|
1472
1699
|
}, {
|
|
1473
1700
|
label: props.label || ''
|
|
1474
1701
|
}).trim();
|
|
1475
|
-
const render = useOnChange$
|
|
1702
|
+
const render = useOnChange$2(Object.assign({}, {
|
|
1476
1703
|
isPopup: true,
|
|
1477
1704
|
placeholder: resolvedPlaceholder
|
|
1478
1705
|
}, rest, {
|
|
@@ -1576,6 +1803,439 @@ const buildRuleString = ({
|
|
|
1576
1803
|
return parts.join(' ') || undefined;
|
|
1577
1804
|
};
|
|
1578
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
|
+
|
|
1579
2239
|
const registry = new Map();
|
|
1580
2240
|
const defineField = (type, definition) => {
|
|
1581
2241
|
registry.set(type, _extends({
|
|
@@ -1999,8 +2659,10 @@ const resolveFieldValueSchema = field => {
|
|
|
1999
2659
|
} else {
|
|
2000
2660
|
schema = _extends({}, schema);
|
|
2001
2661
|
}
|
|
2002
|
-
const
|
|
2003
|
-
const
|
|
2662
|
+
const label = resolveLocaleText(field.label);
|
|
2663
|
+
const fieldDescription = resolveLocaleText(field.description);
|
|
2664
|
+
const title = label != null && String(label).trim() ? String(label).trim() : undefined;
|
|
2665
|
+
const description = fieldDescription != null && String(fieldDescription).trim() ? String(fieldDescription).trim() : undefined;
|
|
2004
2666
|
if (title && schema.title == null) {
|
|
2005
2667
|
schema.title = title;
|
|
2006
2668
|
}
|
|
@@ -2077,26 +2739,26 @@ const normalizeOptions = (options, {
|
|
|
2077
2739
|
}
|
|
2078
2740
|
const columnNames = (_columns || []).map(item => item == null ? void 0 : item.name).filter(Boolean);
|
|
2079
2741
|
return options.map(item => {
|
|
2080
|
-
var _item$
|
|
2081
|
-
const label =
|
|
2742
|
+
var _item$value;
|
|
2743
|
+
const label = trimLocaleText(item == null ? void 0 : item.label);
|
|
2082
2744
|
let value = String((_item$value = item == null ? void 0 : item.value) != null ? _item$value : '').trim();
|
|
2083
2745
|
if (!value && label) {
|
|
2084
|
-
value = label;
|
|
2746
|
+
value = localeTextToValue(label);
|
|
2085
2747
|
}
|
|
2086
2748
|
const next = {
|
|
2087
2749
|
label,
|
|
2088
2750
|
value,
|
|
2089
|
-
description:
|
|
2751
|
+
description: trimLocaleText(item == null ? void 0 : item.description)
|
|
2090
2752
|
};
|
|
2091
2753
|
columnNames.forEach(name => {
|
|
2092
2754
|
var _item$name;
|
|
2093
2755
|
next[name] = (_item$name = item == null ? void 0 : item[name]) != null ? _item$name : '';
|
|
2094
2756
|
});
|
|
2095
|
-
if (!
|
|
2757
|
+
if (!hasLocaleText(next.label) && columnNames[0] && String(next[columnNames[0]] || '').trim()) {
|
|
2096
2758
|
next.label = String(next[columnNames[0]]).trim();
|
|
2097
2759
|
}
|
|
2098
|
-
if (!String(next.value).trim() &&
|
|
2099
|
-
next.value = next.label;
|
|
2760
|
+
if (!String(next.value).trim() && hasLocaleText(next.label)) {
|
|
2761
|
+
next.value = localeTextToValue(next.label);
|
|
2100
2762
|
}
|
|
2101
2763
|
if (_allowChildren && Array.isArray(item == null ? void 0 : item.children) && item.children.length) {
|
|
2102
2764
|
next.children = normalizeOptions(item.children, {
|
|
@@ -2356,6 +3018,7 @@ const fieldToFormValues = field => {
|
|
|
2356
3018
|
description: field.description || '',
|
|
2357
3019
|
block: !!field.block,
|
|
2358
3020
|
hidden: !!field.hidden,
|
|
3021
|
+
visibleWhen: field.visibleWhen,
|
|
2359
3022
|
placeholder,
|
|
2360
3023
|
options: options.length ? options : [{
|
|
2361
3024
|
label: '',
|
|
@@ -2393,7 +3056,8 @@ const formValuesToField = (values, existingField = {}) => {
|
|
|
2393
3056
|
props.children = values.label;
|
|
2394
3057
|
}
|
|
2395
3058
|
const rule = buildRuleString(values.ruleConfig);
|
|
2396
|
-
|
|
3059
|
+
const visibleWhen = normalizeVisibleWhen(values.visibleWhen);
|
|
3060
|
+
return _extends({
|
|
2397
3061
|
id: existingField.id,
|
|
2398
3062
|
type: values.type,
|
|
2399
3063
|
name: values.name,
|
|
@@ -2402,13 +3066,112 @@ const formValuesToField = (values, existingField = {}) => {
|
|
|
2402
3066
|
description: values.description != null && String(values.description).trim() ? values.description : '',
|
|
2403
3067
|
rule,
|
|
2404
3068
|
block: (_ref = (_values$block = values.block) != null ? _values$block : (_definition$defaults = definition.defaults) == null ? void 0 : _definition$defaults.block) != null ? _ref : false,
|
|
2405
|
-
hidden: !!values.hidden
|
|
3069
|
+
hidden: !!values.hidden
|
|
3070
|
+
}, visibleWhen ? {
|
|
3071
|
+
visibleWhen
|
|
3072
|
+
} : {}, {
|
|
2406
3073
|
props
|
|
2407
|
-
};
|
|
3074
|
+
});
|
|
2408
3075
|
};
|
|
2409
3076
|
|
|
2410
3077
|
const {
|
|
2411
|
-
|
|
3078
|
+
useOnChange: useOnChange$1
|
|
3079
|
+
} = hooks;
|
|
3080
|
+
const LocaleTextContext = /*#__PURE__*/createContext([]);
|
|
3081
|
+
|
|
3082
|
+
/** 向编辑器内的文案输入下发语言列表 [{ value, label }] */
|
|
3083
|
+
const LocaleTextProvider = ({
|
|
3084
|
+
languages,
|
|
3085
|
+
children
|
|
3086
|
+
}) => /*#__PURE__*/jsx(LocaleTextContext.Provider, {
|
|
3087
|
+
value: normalizeLanguages(languages),
|
|
3088
|
+
children: children
|
|
3089
|
+
});
|
|
3090
|
+
|
|
3091
|
+
/** 当前语言列表:组件 languages 优先,否则取 LocaleTextProvider */
|
|
3092
|
+
const useLocaleTextLanguages = languages => {
|
|
3093
|
+
const contextLanguages = useContext(LocaleTextContext);
|
|
3094
|
+
return languages ? normalizeLanguages(languages) : contextLanguages;
|
|
3095
|
+
};
|
|
3096
|
+
|
|
3097
|
+
/** 文案输入:未配置多语言时为单个输入框;配置后每种语言一个输入框,只填基础语言(首项)时存为字符串 */
|
|
3098
|
+
const LocaleTextControl = ({
|
|
3099
|
+
value,
|
|
3100
|
+
onChange,
|
|
3101
|
+
onBlur,
|
|
3102
|
+
placeholder,
|
|
3103
|
+
multiline: _multiline = false,
|
|
3104
|
+
compact: _compact = false,
|
|
3105
|
+
rows: _rows = 2,
|
|
3106
|
+
disabled,
|
|
3107
|
+
className,
|
|
3108
|
+
languages: languagesProp
|
|
3109
|
+
}) => {
|
|
3110
|
+
const {
|
|
3111
|
+
formatMessage,
|
|
3112
|
+
locale
|
|
3113
|
+
} = useIntl();
|
|
3114
|
+
const languages = useLocaleTextLanguages(languagesProp);
|
|
3115
|
+
const Control = _multiline ? Input$1.TextArea : Input$1;
|
|
3116
|
+
const controlProps = _extends({
|
|
3117
|
+
disabled,
|
|
3118
|
+
onBlur
|
|
3119
|
+
}, _multiline ? {
|
|
3120
|
+
rows: _rows
|
|
3121
|
+
} : {});
|
|
3122
|
+
if (languages.length < 2) {
|
|
3123
|
+
var _languages$;
|
|
3124
|
+
const _baseLanguage = (_languages$ = languages[0]) == null ? void 0 : _languages$.value;
|
|
3125
|
+
const editLanguage = isLocaleText(value) ? _baseLanguage || Object.keys(value).find(key => value[key] === resolveLocaleText(value, locale)) || Object.keys(value)[0] : null;
|
|
3126
|
+
return /*#__PURE__*/jsx(Control, _extends({}, controlProps, {
|
|
3127
|
+
className: className,
|
|
3128
|
+
value: editLanguage ? value[editLanguage] || '' : value != null ? value : '',
|
|
3129
|
+
placeholder: placeholder,
|
|
3130
|
+
onChange: e => onChange == null ? void 0 : onChange(editLanguage ? setLocaleTextValue(value, editLanguage, e.target.value, editLanguage) : e.target.value)
|
|
3131
|
+
}));
|
|
3132
|
+
}
|
|
3133
|
+
const baseLanguage = languages[0];
|
|
3134
|
+
return /*#__PURE__*/jsx("div", {
|
|
3135
|
+
className: [style['locale-text'], _compact ? style['is-compact'] : null, className].filter(Boolean).join(' '),
|
|
3136
|
+
children: languages.map(language => /*#__PURE__*/jsxs("div", {
|
|
3137
|
+
className: style['locale-text-item'],
|
|
3138
|
+
children: [_compact ? null : /*#__PURE__*/jsx("span", {
|
|
3139
|
+
className: style['locale-text-tag'],
|
|
3140
|
+
children: language.label
|
|
3141
|
+
}), /*#__PURE__*/jsx(Control, _extends({}, controlProps, {
|
|
3142
|
+
value: getLocaleTextValue(value, language.value, baseLanguage.value),
|
|
3143
|
+
placeholder: language.value === baseLanguage.value ? placeholder : formatMessage({
|
|
3144
|
+
id: 'localeTextFallback'
|
|
3145
|
+
}, {
|
|
3146
|
+
language: baseLanguage.label
|
|
3147
|
+
})
|
|
3148
|
+
}, _compact && !_multiline ? {
|
|
3149
|
+
prefix: /*#__PURE__*/jsx("span", {
|
|
3150
|
+
className: style['locale-text-prefix'],
|
|
3151
|
+
children: language.label
|
|
3152
|
+
})
|
|
3153
|
+
} : {}, {
|
|
3154
|
+
onChange: e => onChange == null ? void 0 : onChange(setLocaleTextValue(value, language.value, e.target.value, baseLanguage.value))
|
|
3155
|
+
}))]
|
|
3156
|
+
}, language.value))
|
|
3157
|
+
});
|
|
3158
|
+
};
|
|
3159
|
+
const LocaleInput = props => {
|
|
3160
|
+
const render = useOnChange$1(props);
|
|
3161
|
+
return render(LocaleTextControl);
|
|
3162
|
+
};
|
|
3163
|
+
LocaleInput.field = LocaleTextControl;
|
|
3164
|
+
const LocaleTextAreaControl = props => /*#__PURE__*/jsx(LocaleTextControl, _extends({}, props, {
|
|
3165
|
+
multiline: true
|
|
3166
|
+
}));
|
|
3167
|
+
const LocaleTextArea = props => {
|
|
3168
|
+
const render = useOnChange$1(props);
|
|
3169
|
+
return render(LocaleTextAreaControl);
|
|
3170
|
+
};
|
|
3171
|
+
LocaleTextArea.field = LocaleTextAreaControl;
|
|
3172
|
+
|
|
3173
|
+
const {
|
|
3174
|
+
Text: Text$5
|
|
2412
3175
|
} = Typography;
|
|
2413
3176
|
const TYPE_TAG_COLORS = {
|
|
2414
3177
|
Input: 'blue',
|
|
@@ -2428,52 +3191,117 @@ const TYPE_TAG_COLORS = {
|
|
|
2428
3191
|
Checkbox: 'green',
|
|
2429
3192
|
DatePicker: 'lime'
|
|
2430
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;
|
|
2431
3213
|
const FieldRow = ({
|
|
2432
3214
|
field,
|
|
2433
3215
|
index,
|
|
2434
3216
|
total,
|
|
2435
3217
|
onEdit,
|
|
2436
3218
|
onDelete,
|
|
2437
|
-
onMove
|
|
3219
|
+
onMove,
|
|
3220
|
+
prevLocked,
|
|
3221
|
+
nextLocked,
|
|
3222
|
+
conditionContext
|
|
2438
3223
|
}) => {
|
|
2439
3224
|
const {
|
|
2440
|
-
formatMessage
|
|
3225
|
+
formatMessage,
|
|
3226
|
+
locale
|
|
2441
3227
|
} = useIntl();
|
|
3228
|
+
const languages = useLocaleTextLanguages();
|
|
2442
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);
|
|
2443
3233
|
return /*#__PURE__*/jsxs("div", {
|
|
2444
3234
|
className: style['field-row'],
|
|
2445
3235
|
children: [/*#__PURE__*/jsx("span", {
|
|
2446
3236
|
className: style['field-row-index'],
|
|
2447
3237
|
children: index + 1
|
|
2448
|
-
}), /*#__PURE__*/
|
|
3238
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
2449
3239
|
className: style['field-row-main'],
|
|
2450
|
-
children: /*#__PURE__*/
|
|
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, {
|
|
2451
3247
|
size: 6,
|
|
2452
3248
|
wrap: true,
|
|
2453
|
-
children: [/*#__PURE__*/jsx(
|
|
2454
|
-
strong: true,
|
|
2455
|
-
ellipsis: true,
|
|
2456
|
-
children: field.label || formatMessage({
|
|
2457
|
-
id: 'untitledField'
|
|
2458
|
-
})
|
|
2459
|
-
}), /*#__PURE__*/jsx(Tag, {
|
|
3249
|
+
children: [/*#__PURE__*/jsx(Tag, {
|
|
2460
3250
|
bordered: false,
|
|
2461
3251
|
color: TYPE_TAG_COLORS[field.type] || 'default',
|
|
3252
|
+
icon: /*#__PURE__*/jsx(TypeIcon, {}),
|
|
2462
3253
|
children: resolveFieldTypeLabel(definition || field.type, formatMessage)
|
|
2463
|
-
}), field.
|
|
3254
|
+
}), field.locked ? /*#__PURE__*/jsx(Tag, {
|
|
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, {
|
|
2464
3264
|
bordered: false,
|
|
3265
|
+
icon: /*#__PURE__*/jsx(EyeInvisibleOutlined, {}),
|
|
2465
3266
|
children: formatMessage({
|
|
2466
3267
|
id: 'fieldHiddenTag'
|
|
2467
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
|
+
})
|
|
2468
3295
|
}) : null, field.block ? /*#__PURE__*/jsx(Tag, {
|
|
2469
3296
|
bordered: false,
|
|
2470
3297
|
color: "processing",
|
|
3298
|
+
icon: /*#__PURE__*/jsx(ColumnWidthOutlined, {}),
|
|
2471
3299
|
children: formatMessage({
|
|
2472
3300
|
id: 'fieldBlockTag'
|
|
2473
3301
|
})
|
|
2474
3302
|
}) : null]
|
|
2475
|
-
})
|
|
2476
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
3303
|
+
})]
|
|
3304
|
+
}), field.locked ? null : /*#__PURE__*/jsxs("div", {
|
|
2477
3305
|
className: style['action-group'],
|
|
2478
3306
|
children: [/*#__PURE__*/jsx(Button, {
|
|
2479
3307
|
type: "text",
|
|
@@ -2483,7 +3311,7 @@ const FieldRow = ({
|
|
|
2483
3311
|
id: 'moveUp'
|
|
2484
3312
|
}),
|
|
2485
3313
|
icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
|
|
2486
|
-
disabled: index === 0,
|
|
3314
|
+
disabled: index === 0 || prevLocked,
|
|
2487
3315
|
onClick: () => onMove(field.id, 'up')
|
|
2488
3316
|
}), /*#__PURE__*/jsx(Button, {
|
|
2489
3317
|
type: "text",
|
|
@@ -2493,7 +3321,7 @@ const FieldRow = ({
|
|
|
2493
3321
|
id: 'moveDown'
|
|
2494
3322
|
}),
|
|
2495
3323
|
icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
|
|
2496
|
-
disabled: index === total - 1,
|
|
3324
|
+
disabled: index === total - 1 || nextLocked,
|
|
2497
3325
|
onClick: () => onMove(field.id, 'down')
|
|
2498
3326
|
}), /*#__PURE__*/jsx(Button, {
|
|
2499
3327
|
type: "text",
|
|
@@ -2518,11 +3346,10 @@ const FieldRow = ({
|
|
|
2518
3346
|
})]
|
|
2519
3347
|
});
|
|
2520
3348
|
};
|
|
2521
|
-
var FieldRow$1 = FieldRow;
|
|
2522
3349
|
|
|
2523
|
-
const _excluded$
|
|
3350
|
+
const _excluded$3 = ["title", "danger"];
|
|
2524
3351
|
const {
|
|
2525
|
-
Text: Text$
|
|
3352
|
+
Text: Text$4
|
|
2526
3353
|
} = Typography;
|
|
2527
3354
|
const ActionGroup = ({
|
|
2528
3355
|
children
|
|
@@ -2535,7 +3362,7 @@ const IconBtn = _ref => {
|
|
|
2535
3362
|
title,
|
|
2536
3363
|
danger
|
|
2537
3364
|
} = _ref,
|
|
2538
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
3365
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
2539
3366
|
return /*#__PURE__*/jsx(Button, _extends({
|
|
2540
3367
|
type: "text",
|
|
2541
3368
|
size: "small",
|
|
@@ -2569,6 +3396,10 @@ const ROOT_ADD_OPTIONS = [{
|
|
|
2569
3396
|
key: 'steps',
|
|
2570
3397
|
icon: /*#__PURE__*/jsx(OrderedListOutlined, {})
|
|
2571
3398
|
}];
|
|
3399
|
+
const BLOCK_KIND_ICONS = Object.fromEntries(ROOT_ADD_OPTIONS.map(({
|
|
3400
|
+
key,
|
|
3401
|
+
icon
|
|
3402
|
+
}) => [key, icon]));
|
|
2572
3403
|
|
|
2573
3404
|
/** 可挂子模块的容器;表格列表 / 同类多值本身不支持子模块 */
|
|
2574
3405
|
const NESTED_ADD_OPTIONS = ROOT_ADD_OPTIONS.filter(opt => opt.key !== 'steps');
|
|
@@ -2594,11 +3425,23 @@ const BlockListPanel = ({
|
|
|
2594
3425
|
extraToolbar
|
|
2595
3426
|
}) => {
|
|
2596
3427
|
const {
|
|
2597
|
-
formatMessage
|
|
3428
|
+
formatMessage,
|
|
3429
|
+
locale
|
|
2598
3430
|
} = useIntl();
|
|
3431
|
+
const languages = useLocaleTextLanguages();
|
|
3432
|
+
const text = value => resolveLocaleText(value, locale, languages);
|
|
2599
3433
|
const [addMenuOpen, setAddMenuOpen] = useState(false);
|
|
2600
3434
|
const [addFieldMenuId, setAddFieldMenuId] = useState(null);
|
|
2601
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]);
|
|
2602
3445
|
const renderAddBlockMenu = (options, {
|
|
2603
3446
|
onSelect,
|
|
2604
3447
|
className
|
|
@@ -2760,7 +3603,7 @@ const BlockListPanel = ({
|
|
|
2760
3603
|
optionId
|
|
2761
3604
|
} = {}) => {
|
|
2762
3605
|
if (!(fields || []).length) {
|
|
2763
|
-
return /*#__PURE__*/jsx(Text$
|
|
3606
|
+
return /*#__PURE__*/jsx(Text$4, {
|
|
2764
3607
|
type: "secondary",
|
|
2765
3608
|
className: style['inline-empty'],
|
|
2766
3609
|
children: formatMessage({
|
|
@@ -2770,10 +3613,13 @@ const BlockListPanel = ({
|
|
|
2770
3613
|
}
|
|
2771
3614
|
return /*#__PURE__*/jsx("div", {
|
|
2772
3615
|
className: style['field-list'],
|
|
2773
|
-
children: fields.map((field, fieldIndex) => /*#__PURE__*/jsx(FieldRow
|
|
3616
|
+
children: fields.map((field, fieldIndex) => /*#__PURE__*/jsx(FieldRow, {
|
|
2774
3617
|
field: field,
|
|
2775
3618
|
index: fieldIndex,
|
|
2776
3619
|
total: fields.length,
|
|
3620
|
+
prevLocked: isFieldLocked(fields[fieldIndex - 1]),
|
|
3621
|
+
nextLocked: isFieldLocked(fields[fieldIndex + 1]),
|
|
3622
|
+
conditionContext: conditionContext,
|
|
2777
3623
|
onEdit: fieldItem => onEditField(blockId, fieldItem, {
|
|
2778
3624
|
stepId,
|
|
2779
3625
|
optionId
|
|
@@ -2797,7 +3643,7 @@ const BlockListPanel = ({
|
|
|
2797
3643
|
className: style['item-blocks-section'],
|
|
2798
3644
|
children: /*#__PURE__*/jsx("div", {
|
|
2799
3645
|
className: style['nested-block-list'],
|
|
2800
|
-
children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks
|
|
3646
|
+
children: childBlocks.map((child, childIndex) => renderBlockSection(child, childIndex, childBlocks, depth + 1))
|
|
2801
3647
|
})
|
|
2802
3648
|
});
|
|
2803
3649
|
};
|
|
@@ -2808,7 +3654,7 @@ const BlockListPanel = ({
|
|
|
2808
3654
|
className: style['block-body'],
|
|
2809
3655
|
children: [/*#__PURE__*/jsxs("div", {
|
|
2810
3656
|
className: style['section-toolbar'],
|
|
2811
|
-
children: [/*#__PURE__*/jsx(Text$
|
|
3657
|
+
children: [/*#__PURE__*/jsx(Text$4, {
|
|
2812
3658
|
type: "secondary",
|
|
2813
3659
|
className: style['section-toolbar-label'],
|
|
2814
3660
|
children: formatMessage({
|
|
@@ -2839,14 +3685,14 @@ const BlockListPanel = ({
|
|
|
2839
3685
|
children: [/*#__PURE__*/jsx("span", {
|
|
2840
3686
|
className: style['step-index'],
|
|
2841
3687
|
children: stepIndex + 1
|
|
2842
|
-
}), /*#__PURE__*/jsx(Text$
|
|
3688
|
+
}), /*#__PURE__*/jsx(Text$4, {
|
|
2843
3689
|
strong: true,
|
|
2844
|
-
children: step.title || formatMessage({
|
|
3690
|
+
children: text(step.title) || formatMessage({
|
|
2845
3691
|
id: 'untitledStep'
|
|
2846
3692
|
}, {
|
|
2847
3693
|
index: stepIndex + 1
|
|
2848
3694
|
})
|
|
2849
|
-
}), /*#__PURE__*/jsx(Text$
|
|
3695
|
+
}), /*#__PURE__*/jsx(Text$4, {
|
|
2850
3696
|
type: "secondary",
|
|
2851
3697
|
children: (step.blocks || []).length ? formatMessage({
|
|
2852
3698
|
id: 'fieldAndItemBlockCount'
|
|
@@ -2869,14 +3715,14 @@ const BlockListPanel = ({
|
|
|
2869
3715
|
id: 'moveUp'
|
|
2870
3716
|
}),
|
|
2871
3717
|
icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
|
|
2872
|
-
disabled: stepIndex === 0,
|
|
3718
|
+
disabled: stepIndex === 0 || blockHasLockedField(step) || blockHasLockedField(block.items[stepIndex - 1]),
|
|
2873
3719
|
onClick: () => onMoveStep(block.id, step.id, 'up')
|
|
2874
3720
|
}), /*#__PURE__*/jsx(IconBtn, {
|
|
2875
3721
|
title: formatMessage({
|
|
2876
3722
|
id: 'moveDown'
|
|
2877
3723
|
}),
|
|
2878
3724
|
icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
|
|
2879
|
-
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]),
|
|
2880
3726
|
onClick: () => onMoveStep(block.id, step.id, 'down')
|
|
2881
3727
|
}), /*#__PURE__*/jsx(IconBtn, {
|
|
2882
3728
|
title: formatMessage({
|
|
@@ -2884,7 +3730,7 @@ const BlockListPanel = ({
|
|
|
2884
3730
|
}),
|
|
2885
3731
|
icon: /*#__PURE__*/jsx(EditOutlined, {}),
|
|
2886
3732
|
onClick: () => onEditStep(block.id, step)
|
|
2887
|
-
}), /*#__PURE__*/jsx(IconBtn, {
|
|
3733
|
+
}), blockHasLockedField(step) ? null : /*#__PURE__*/jsx(IconBtn, {
|
|
2888
3734
|
title: formatMessage({
|
|
2889
3735
|
id: 'deleteStep'
|
|
2890
3736
|
}),
|
|
@@ -2909,7 +3755,7 @@ const BlockListPanel = ({
|
|
|
2909
3755
|
}), renderNestedBlocks(step.blocks, depth)]
|
|
2910
3756
|
}, step.id);
|
|
2911
3757
|
})
|
|
2912
|
-
}) : /*#__PURE__*/jsx(Text$
|
|
3758
|
+
}) : /*#__PURE__*/jsx(Text$4, {
|
|
2913
3759
|
type: "secondary",
|
|
2914
3760
|
className: style['inline-empty'],
|
|
2915
3761
|
children: formatMessage({
|
|
@@ -2921,7 +3767,7 @@ const BlockListPanel = ({
|
|
|
2921
3767
|
if (block.kind === 'multiField') {
|
|
2922
3768
|
return /*#__PURE__*/jsx("div", {
|
|
2923
3769
|
className: style['block-body'],
|
|
2924
|
-
children: /*#__PURE__*/jsx(Text$
|
|
3770
|
+
children: /*#__PURE__*/jsx(Text$4, {
|
|
2925
3771
|
type: "secondary",
|
|
2926
3772
|
children: formatMessage({
|
|
2927
3773
|
id: 'multiFieldEditorHint'
|
|
@@ -2934,7 +3780,7 @@ const BlockListPanel = ({
|
|
|
2934
3780
|
className: style['block-body'],
|
|
2935
3781
|
children: [/*#__PURE__*/jsxs("div", {
|
|
2936
3782
|
className: style['section-toolbar'],
|
|
2937
|
-
children: [/*#__PURE__*/jsx(Text$
|
|
3783
|
+
children: [/*#__PURE__*/jsx(Text$4, {
|
|
2938
3784
|
type: "secondary",
|
|
2939
3785
|
className: style['section-toolbar-label'],
|
|
2940
3786
|
children: formatMessage({
|
|
@@ -2965,14 +3811,14 @@ const BlockListPanel = ({
|
|
|
2965
3811
|
children: [/*#__PURE__*/jsx("span", {
|
|
2966
3812
|
className: style['step-index'],
|
|
2967
3813
|
children: optionIndex + 1
|
|
2968
|
-
}), /*#__PURE__*/jsx(Text$
|
|
3814
|
+
}), /*#__PURE__*/jsx(Text$4, {
|
|
2969
3815
|
strong: true,
|
|
2970
|
-
children: option.title || formatMessage({
|
|
3816
|
+
children: text(option.title) || formatMessage({
|
|
2971
3817
|
id: 'choiceOptionFallback'
|
|
2972
3818
|
}, {
|
|
2973
3819
|
index: optionIndex + 1
|
|
2974
3820
|
})
|
|
2975
|
-
}), /*#__PURE__*/jsx(Text$
|
|
3821
|
+
}), /*#__PURE__*/jsx(Text$4, {
|
|
2976
3822
|
type: "secondary",
|
|
2977
3823
|
children: (option.blocks || []).length ? formatMessage({
|
|
2978
3824
|
id: 'fieldAndItemBlockCount'
|
|
@@ -2995,14 +3841,14 @@ const BlockListPanel = ({
|
|
|
2995
3841
|
id: 'moveUp'
|
|
2996
3842
|
}),
|
|
2997
3843
|
icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
|
|
2998
|
-
disabled: optionIndex === 0,
|
|
3844
|
+
disabled: optionIndex === 0 || blockHasLockedField(option) || blockHasLockedField(block.options[optionIndex - 1]),
|
|
2999
3845
|
onClick: () => onMoveChoiceOption(block.id, option.id, 'up')
|
|
3000
3846
|
}), /*#__PURE__*/jsx(IconBtn, {
|
|
3001
3847
|
title: formatMessage({
|
|
3002
3848
|
id: 'moveDown'
|
|
3003
3849
|
}),
|
|
3004
3850
|
icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
|
|
3005
|
-
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]),
|
|
3006
3852
|
onClick: () => onMoveChoiceOption(block.id, option.id, 'down')
|
|
3007
3853
|
}), /*#__PURE__*/jsx(IconBtn, {
|
|
3008
3854
|
title: formatMessage({
|
|
@@ -3010,7 +3856,7 @@ const BlockListPanel = ({
|
|
|
3010
3856
|
}),
|
|
3011
3857
|
icon: /*#__PURE__*/jsx(EditOutlined, {}),
|
|
3012
3858
|
onClick: () => onEditChoiceOption(block.id, option)
|
|
3013
|
-
}), /*#__PURE__*/jsx(IconBtn, {
|
|
3859
|
+
}), blockHasLockedField(option) ? null : /*#__PURE__*/jsx(IconBtn, {
|
|
3014
3860
|
title: formatMessage({
|
|
3015
3861
|
id: 'deleteChoiceOption'
|
|
3016
3862
|
}),
|
|
@@ -3035,7 +3881,7 @@ const BlockListPanel = ({
|
|
|
3035
3881
|
}), renderNestedBlocks(option.blocks, depth)]
|
|
3036
3882
|
}, option.id);
|
|
3037
3883
|
})
|
|
3038
|
-
}) : /*#__PURE__*/jsx(Text$
|
|
3884
|
+
}) : /*#__PURE__*/jsx(Text$4, {
|
|
3039
3885
|
type: "secondary",
|
|
3040
3886
|
className: style['inline-empty'],
|
|
3041
3887
|
children: formatMessage({
|
|
@@ -3051,8 +3897,10 @@ const BlockListPanel = ({
|
|
|
3051
3897
|
children: [renderFieldList(block.list, block.id), supportsItemBlocks$1 ? renderItemBlocks(block, depth) : null, supportsBlocks ? renderNestedBlocks(block.blocks, depth) : null]
|
|
3052
3898
|
});
|
|
3053
3899
|
};
|
|
3054
|
-
const renderBlockSection = (block, blockIndex,
|
|
3900
|
+
const renderBlockSection = (block, blockIndex, siblings, depth = 0) => {
|
|
3055
3901
|
var _block$itemBlocks, _block$blocks, _block$items2, _block$options2, _block$list, _block$list2;
|
|
3902
|
+
const total = siblings.length;
|
|
3903
|
+
const locked = blockHasLockedField(block);
|
|
3056
3904
|
const definition = getBlockDefinition(block.kind);
|
|
3057
3905
|
const canAddField = block.kind !== 'steps' && block.kind !== 'multiField' && block.kind !== 'choice';
|
|
3058
3906
|
const supportsItemBlocks$1 = supportsItemBlocks(block.kind);
|
|
@@ -3066,7 +3914,10 @@ const BlockListPanel = ({
|
|
|
3066
3914
|
}) : block.kind === 'multiField' ? formatMessage({
|
|
3067
3915
|
id: 'multiFieldSummary'
|
|
3068
3916
|
}, {
|
|
3069
|
-
type:
|
|
3917
|
+
type: /*#__PURE__*/jsxs("span", {
|
|
3918
|
+
className: style['block-summary-type'],
|
|
3919
|
+
children: [/*#__PURE__*/createElement(getFieldTypeIcon(block.fieldType || 'Input')), resolveFieldTypeLabel(block.fieldType, formatMessage)]
|
|
3920
|
+
})
|
|
3070
3921
|
}) : block.kind === 'choice' ? formatMessage({
|
|
3071
3922
|
id: 'choiceOptionCount'
|
|
3072
3923
|
}, {
|
|
@@ -3090,14 +3941,15 @@ const BlockListPanel = ({
|
|
|
3090
3941
|
children: [/*#__PURE__*/jsx(Tag, {
|
|
3091
3942
|
bordered: false,
|
|
3092
3943
|
color: (definition == null ? void 0 : definition.color) || 'default',
|
|
3944
|
+
icon: BLOCK_KIND_ICONS[block.kind],
|
|
3093
3945
|
children: formatMessage({
|
|
3094
3946
|
id: `blockKind_${block.kind}`
|
|
3095
3947
|
})
|
|
3096
|
-
}), /*#__PURE__*/jsx(Text$
|
|
3948
|
+
}), /*#__PURE__*/jsx(Text$4, {
|
|
3097
3949
|
strong: true,
|
|
3098
3950
|
ellipsis: true,
|
|
3099
3951
|
className: style['block-title'],
|
|
3100
|
-
children: block.title || block.label || block.name || formatMessage({
|
|
3952
|
+
children: text(block.title) || text(block.label) || block.name || formatMessage({
|
|
3101
3953
|
id: 'untitledBlock'
|
|
3102
3954
|
})
|
|
3103
3955
|
}), /*#__PURE__*/jsx("span", {
|
|
@@ -3114,14 +3966,14 @@ const BlockListPanel = ({
|
|
|
3114
3966
|
id: 'moveUp'
|
|
3115
3967
|
}),
|
|
3116
3968
|
icon: /*#__PURE__*/jsx(ArrowUpOutlined, {}),
|
|
3117
|
-
disabled: blockIndex === 0,
|
|
3969
|
+
disabled: blockIndex === 0 || locked || blockHasLockedField(siblings[blockIndex - 1]),
|
|
3118
3970
|
onClick: () => onMoveBlock(block.id, 'up')
|
|
3119
3971
|
}), /*#__PURE__*/jsx(IconBtn, {
|
|
3120
3972
|
title: formatMessage({
|
|
3121
3973
|
id: 'moveDown'
|
|
3122
3974
|
}),
|
|
3123
3975
|
icon: /*#__PURE__*/jsx(ArrowDownOutlined, {}),
|
|
3124
|
-
disabled: blockIndex === total - 1,
|
|
3976
|
+
disabled: blockIndex === total - 1 || locked || blockHasLockedField(siblings[blockIndex + 1]),
|
|
3125
3977
|
onClick: () => onMoveBlock(block.id, 'down')
|
|
3126
3978
|
}), /*#__PURE__*/jsx(IconBtn, {
|
|
3127
3979
|
title: formatMessage({
|
|
@@ -3129,7 +3981,7 @@ const BlockListPanel = ({
|
|
|
3129
3981
|
}),
|
|
3130
3982
|
icon: /*#__PURE__*/jsx(SettingOutlined, {}),
|
|
3131
3983
|
onClick: () => onEditBlock(block)
|
|
3132
|
-
}), /*#__PURE__*/jsx(IconBtn, {
|
|
3984
|
+
}), locked ? null : /*#__PURE__*/jsx(IconBtn, {
|
|
3133
3985
|
title: formatMessage({
|
|
3134
3986
|
id: 'deleteBlock'
|
|
3135
3987
|
}),
|
|
@@ -3197,7 +4049,7 @@ const BlockListPanel = ({
|
|
|
3197
4049
|
})
|
|
3198
4050
|
}) : /*#__PURE__*/jsx("div", {
|
|
3199
4051
|
className: style['block-list'],
|
|
3200
|
-
children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks
|
|
4052
|
+
children: blocks.map((block, blockIndex) => renderBlockSection(block, blockIndex, blocks, 0))
|
|
3201
4053
|
})]
|
|
3202
4054
|
});
|
|
3203
4055
|
};
|
|
@@ -3214,7 +4066,7 @@ const BlockConfigFields = ({
|
|
|
3214
4066
|
const list = [];
|
|
3215
4067
|
const isListKind = kind === 'list' || kind === 'tableList' || kind === 'editableList';
|
|
3216
4068
|
if (kind === 'formInfo' || kind === 'list' || kind === 'tableList' || kind === 'editableList' || kind === 'object') {
|
|
3217
|
-
list.push(/*#__PURE__*/jsx(
|
|
4069
|
+
list.push(/*#__PURE__*/jsx(LocaleInput, {
|
|
3218
4070
|
name: "title",
|
|
3219
4071
|
label: formatMessage({
|
|
3220
4072
|
id: 'blockTitle'
|
|
@@ -3222,7 +4074,7 @@ const BlockConfigFields = ({
|
|
|
3222
4074
|
placeholder: formatMessage({
|
|
3223
4075
|
id: 'blockTitlePlaceholder'
|
|
3224
4076
|
})
|
|
3225
|
-
}, "title"), kind === 'formInfo' ? /*#__PURE__*/jsx(
|
|
4077
|
+
}, "title"), kind === 'formInfo' ? /*#__PURE__*/jsx(LocaleInput, {
|
|
3226
4078
|
name: "subtitle",
|
|
3227
4079
|
label: formatMessage({
|
|
3228
4080
|
id: 'blockSubtitle'
|
|
@@ -3268,7 +4120,7 @@ const BlockConfigFields = ({
|
|
|
3268
4120
|
children: formatMessage({
|
|
3269
4121
|
id: 'blockImportant'
|
|
3270
4122
|
})
|
|
3271
|
-
}, "important") : null, isListKind ? /*#__PURE__*/jsx(
|
|
4123
|
+
}, "important") : null, isListKind ? /*#__PURE__*/jsx(LocaleInput, {
|
|
3272
4124
|
name: "addText",
|
|
3273
4125
|
label: formatMessage({
|
|
3274
4126
|
id: 'blockAddText'
|
|
@@ -3302,7 +4154,7 @@ const BlockConfigFields = ({
|
|
|
3302
4154
|
}, "minLength") : null);
|
|
3303
4155
|
}
|
|
3304
4156
|
if (kind === 'choice') {
|
|
3305
|
-
list.push(/*#__PURE__*/jsx(
|
|
4157
|
+
list.push(/*#__PURE__*/jsx(LocaleInput, {
|
|
3306
4158
|
name: "title",
|
|
3307
4159
|
label: formatMessage({
|
|
3308
4160
|
id: 'blockTitle'
|
|
@@ -3388,7 +4240,7 @@ const BlockConfigFields = ({
|
|
|
3388
4240
|
placeholder: formatMessage({
|
|
3389
4241
|
id: 'fieldNamePlaceholder'
|
|
3390
4242
|
})
|
|
3391
|
-
}, "name"), /*#__PURE__*/jsx(
|
|
4243
|
+
}, "name"), /*#__PURE__*/jsx(LocaleInput, {
|
|
3392
4244
|
name: "label",
|
|
3393
4245
|
label: formatMessage({
|
|
3394
4246
|
id: 'fieldLabel'
|
|
@@ -3404,7 +4256,7 @@ const BlockConfigFields = ({
|
|
|
3404
4256
|
}),
|
|
3405
4257
|
rule: "REQ",
|
|
3406
4258
|
options: fieldTypeOptions
|
|
3407
|
-
}, "fieldType"), /*#__PURE__*/jsx(
|
|
4259
|
+
}, "fieldType"), /*#__PURE__*/jsx(LocaleInput, {
|
|
3408
4260
|
name: "addText",
|
|
3409
4261
|
label: formatMessage({
|
|
3410
4262
|
id: 'blockAddText'
|
|
@@ -3415,7 +4267,7 @@ const BlockConfigFields = ({
|
|
|
3415
4267
|
}, "addText"));
|
|
3416
4268
|
}
|
|
3417
4269
|
if (kind === 'steps') {
|
|
3418
|
-
list.push(/*#__PURE__*/jsx(
|
|
4270
|
+
list.push(/*#__PURE__*/jsx(LocaleInput, {
|
|
3419
4271
|
name: "title",
|
|
3420
4272
|
label: formatMessage({
|
|
3421
4273
|
id: 'blockTitle'
|
|
@@ -3423,7 +4275,7 @@ const BlockConfigFields = ({
|
|
|
3423
4275
|
placeholder: formatMessage({
|
|
3424
4276
|
id: 'blockTitlePlaceholder'
|
|
3425
4277
|
})
|
|
3426
|
-
}, "title"), /*#__PURE__*/jsx(
|
|
4278
|
+
}, "title"), /*#__PURE__*/jsx(LocaleInput, {
|
|
3427
4279
|
name: "subtitle",
|
|
3428
4280
|
label: formatMessage({
|
|
3429
4281
|
id: 'blockSubtitle'
|
|
@@ -3547,7 +4399,7 @@ const StepEditorModal = ({
|
|
|
3547
4399
|
}),
|
|
3548
4400
|
children: /*#__PURE__*/jsx(FormInfo, {
|
|
3549
4401
|
column: 1,
|
|
3550
|
-
list: [/*#__PURE__*/jsx(
|
|
4402
|
+
list: [/*#__PURE__*/jsx(LocaleInput, {
|
|
3551
4403
|
name: "title",
|
|
3552
4404
|
label: formatMessage({
|
|
3553
4405
|
id: 'stepTitle'
|
|
@@ -3607,7 +4459,7 @@ const ChoiceOptionEditorModal = ({
|
|
|
3607
4459
|
}),
|
|
3608
4460
|
children: /*#__PURE__*/jsx(FormInfo, {
|
|
3609
4461
|
column: 1,
|
|
3610
|
-
list: [/*#__PURE__*/jsx(
|
|
4462
|
+
list: [/*#__PURE__*/jsx(LocaleInput, {
|
|
3611
4463
|
name: "title",
|
|
3612
4464
|
label: formatMessage({
|
|
3613
4465
|
id: 'choiceOptionTitle'
|
|
@@ -3623,7 +4475,7 @@ const ChoiceOptionEditorModal = ({
|
|
|
3623
4475
|
var ChoiceOptionEditorModal$1 = ChoiceOptionEditorModal;
|
|
3624
4476
|
|
|
3625
4477
|
const {
|
|
3626
|
-
Text: Text$
|
|
4478
|
+
Text: Text$3
|
|
3627
4479
|
} = Typography;
|
|
3628
4480
|
const {
|
|
3629
4481
|
useOnChange
|
|
@@ -3678,7 +4530,7 @@ const RulePresetEditor = () => {
|
|
|
3678
4530
|
}
|
|
3679
4531
|
}, "lenMax"), /*#__PURE__*/jsx("div", {
|
|
3680
4532
|
block: true,
|
|
3681
|
-
children: /*#__PURE__*/jsx(Text$
|
|
4533
|
+
children: /*#__PURE__*/jsx(Text$3, {
|
|
3682
4534
|
type: "secondary",
|
|
3683
4535
|
children: formatMessage({
|
|
3684
4536
|
id: 'ruleEditorHint'
|
|
@@ -3696,7 +4548,7 @@ const RulePresetEditor = () => {
|
|
|
3696
4548
|
var RulePresetEditor$1 = RulePresetEditor;
|
|
3697
4549
|
|
|
3698
4550
|
const {
|
|
3699
|
-
Text: Text$
|
|
4551
|
+
Text: Text$2
|
|
3700
4552
|
} = Typography;
|
|
3701
4553
|
const createOptionKey = () => createDataKey('opt');
|
|
3702
4554
|
const EMPTY_OPTION = () => ({
|
|
@@ -3706,28 +4558,29 @@ const EMPTY_OPTION = () => ({
|
|
|
3706
4558
|
});
|
|
3707
4559
|
|
|
3708
4560
|
/** value 为空或仍等于当前 label 时视为联动中,改 label 会同步 value */
|
|
3709
|
-
const isOptionValueLinked = (label, value) => {
|
|
3710
|
-
const labelText = label
|
|
4561
|
+
const isOptionValueLinked = (label, value, baseLanguage) => {
|
|
4562
|
+
const labelText = localeTextToValue(label, baseLanguage);
|
|
3711
4563
|
const valueText = value == null ? '' : String(value);
|
|
3712
4564
|
return valueText === '' || valueText === labelText;
|
|
3713
4565
|
};
|
|
3714
|
-
const patchOptionLabelChange = (item, nextLabel) => {
|
|
4566
|
+
const patchOptionLabelChange = (item, nextLabel, baseLanguage) => {
|
|
3715
4567
|
const patch = {
|
|
3716
4568
|
label: nextLabel
|
|
3717
4569
|
};
|
|
3718
|
-
if (isOptionValueLinked(item.label, item.value)) {
|
|
3719
|
-
patch.value = nextLabel;
|
|
4570
|
+
if (isOptionValueLinked(item.label, item.value, baseLanguage)) {
|
|
4571
|
+
patch.value = localeTextToValue(nextLabel, baseLanguage);
|
|
3720
4572
|
}
|
|
3721
4573
|
return patch;
|
|
3722
4574
|
};
|
|
3723
|
-
const trimOptionLabelValue = item => {
|
|
3724
|
-
var _item$
|
|
3725
|
-
const label =
|
|
4575
|
+
const trimOptionLabelValue = (item, baseLanguage) => {
|
|
4576
|
+
var _item$value;
|
|
4577
|
+
const label = trimLocaleText(item == null ? void 0 : item.label, baseLanguage);
|
|
4578
|
+
const labelValue = localeTextToValue(label, baseLanguage);
|
|
3726
4579
|
const rawValue = String((_item$value = item == null ? void 0 : item.value) != null ? _item$value : '').trim();
|
|
3727
|
-
const linked = isOptionValueLinked(item == null ? void 0 : item.label, item == null ? void 0 : item.value) || rawValue === '' || rawValue ===
|
|
4580
|
+
const linked = isOptionValueLinked(item == null ? void 0 : item.label, item == null ? void 0 : item.value, baseLanguage) || rawValue === '' || rawValue === labelValue;
|
|
3728
4581
|
return {
|
|
3729
4582
|
label,
|
|
3730
|
-
value: linked ?
|
|
4583
|
+
value: linked ? labelValue : rawValue
|
|
3731
4584
|
};
|
|
3732
4585
|
};
|
|
3733
4586
|
const createEmptyTableRow = columns => {
|
|
@@ -3754,9 +4607,11 @@ const FlatOptionRows = ({
|
|
|
3754
4607
|
onChange,
|
|
3755
4608
|
allowDescription
|
|
3756
4609
|
}) => {
|
|
4610
|
+
var _useLocaleTextLanguag;
|
|
3757
4611
|
const {
|
|
3758
4612
|
formatMessage
|
|
3759
4613
|
} = useIntl();
|
|
4614
|
+
const baseLanguage = (_useLocaleTextLanguag = useLocaleTextLanguages()[0]) == null ? void 0 : _useLocaleTextLanguag.value;
|
|
3760
4615
|
const rows = list.length ? ensureOptionKeys(list) : [EMPTY_OPTION()];
|
|
3761
4616
|
const commit = next => onChange(next);
|
|
3762
4617
|
const updateItem = (index, patch) => {
|
|
@@ -3768,13 +4623,15 @@ const FlatOptionRows = ({
|
|
|
3768
4623
|
gap: 8,
|
|
3769
4624
|
align: "start",
|
|
3770
4625
|
className: style['options-row'],
|
|
3771
|
-
children: [/*#__PURE__*/jsx(
|
|
4626
|
+
children: [/*#__PURE__*/jsx(LocaleTextControl, {
|
|
4627
|
+
compact: true,
|
|
4628
|
+
className: style['options-locale-text'],
|
|
3772
4629
|
value: item.label,
|
|
3773
4630
|
placeholder: formatMessage({
|
|
3774
4631
|
id: 'optionLabelPlaceholder'
|
|
3775
4632
|
}),
|
|
3776
|
-
onChange:
|
|
3777
|
-
onBlur: () => updateItem(index, trimOptionLabelValue(item))
|
|
4633
|
+
onChange: nextLabel => updateItem(index, patchOptionLabelChange(item, nextLabel, baseLanguage)),
|
|
4634
|
+
onBlur: () => updateItem(index, trimOptionLabelValue(item, baseLanguage))
|
|
3778
4635
|
}), /*#__PURE__*/jsx(Input$1, {
|
|
3779
4636
|
value: item.value,
|
|
3780
4637
|
placeholder: formatMessage({
|
|
@@ -3789,20 +4646,19 @@ const FlatOptionRows = ({
|
|
|
3789
4646
|
value: String((_item$value2 = item.value) != null ? _item$value2 : '').trim()
|
|
3790
4647
|
});
|
|
3791
4648
|
}
|
|
3792
|
-
}), allowDescription ? /*#__PURE__*/jsx(
|
|
4649
|
+
}), allowDescription ? /*#__PURE__*/jsx(LocaleTextControl, {
|
|
4650
|
+
compact: true,
|
|
4651
|
+
className: style['options-locale-text'],
|
|
3793
4652
|
value: item.description || '',
|
|
3794
4653
|
placeholder: formatMessage({
|
|
3795
4654
|
id: 'optionDescPlaceholder'
|
|
3796
4655
|
}),
|
|
3797
|
-
onChange:
|
|
3798
|
-
description
|
|
4656
|
+
onChange: description => updateItem(index, {
|
|
4657
|
+
description
|
|
3799
4658
|
}),
|
|
3800
|
-
onBlur: () => {
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
description: String((_item$description = item.description) != null ? _item$description : '').trim()
|
|
3804
|
-
});
|
|
3805
|
-
}
|
|
4659
|
+
onBlur: () => updateItem(index, {
|
|
4660
|
+
description: trimLocaleText(item.description, baseLanguage)
|
|
4661
|
+
})
|
|
3806
4662
|
}) : null, /*#__PURE__*/jsx(Button, {
|
|
3807
4663
|
type: "text",
|
|
3808
4664
|
danger: true,
|
|
@@ -3836,9 +4692,11 @@ const TreeOptionNode = ({
|
|
|
3836
4692
|
depth,
|
|
3837
4693
|
maxDepth: _maxDepth = 4
|
|
3838
4694
|
}) => {
|
|
4695
|
+
var _useLocaleTextLanguag2;
|
|
3839
4696
|
const {
|
|
3840
4697
|
formatMessage
|
|
3841
4698
|
} = useIntl();
|
|
4699
|
+
const baseLanguage = (_useLocaleTextLanguag2 = useLocaleTextLanguages()[0]) == null ? void 0 : _useLocaleTextLanguag2.value;
|
|
3842
4700
|
const children = Array.isArray(item.children) ? item.children : [];
|
|
3843
4701
|
const canAddChild = depth < _maxDepth;
|
|
3844
4702
|
const updateSelf = patch => {
|
|
@@ -3870,13 +4728,14 @@ const TreeOptionNode = ({
|
|
|
3870
4728
|
className: style['tree-option-row'],
|
|
3871
4729
|
children: [/*#__PURE__*/jsxs("div", {
|
|
3872
4730
|
className: style['tree-option-fields'],
|
|
3873
|
-
children: [/*#__PURE__*/jsx(
|
|
4731
|
+
children: [/*#__PURE__*/jsx(LocaleTextControl, {
|
|
4732
|
+
compact: true,
|
|
3874
4733
|
value: item.label,
|
|
3875
4734
|
placeholder: formatMessage({
|
|
3876
4735
|
id: 'optionLabelPlaceholder'
|
|
3877
4736
|
}),
|
|
3878
|
-
onChange:
|
|
3879
|
-
onBlur: () => updateSelf(trimOptionLabelValue(item))
|
|
4737
|
+
onChange: nextLabel => updateSelf(patchOptionLabelChange(item, nextLabel, baseLanguage)),
|
|
4738
|
+
onBlur: () => updateSelf(trimOptionLabelValue(item, baseLanguage))
|
|
3880
4739
|
}), /*#__PURE__*/jsx(Input$1, {
|
|
3881
4740
|
value: item.value,
|
|
3882
4741
|
placeholder: formatMessage({
|
|
@@ -3891,20 +4750,18 @@ const TreeOptionNode = ({
|
|
|
3891
4750
|
value: String((_item$value3 = item.value) != null ? _item$value3 : '').trim()
|
|
3892
4751
|
});
|
|
3893
4752
|
}
|
|
3894
|
-
}), allowDescription ? /*#__PURE__*/jsx(
|
|
4753
|
+
}), allowDescription ? /*#__PURE__*/jsx(LocaleTextControl, {
|
|
4754
|
+
compact: true,
|
|
3895
4755
|
value: item.description || '',
|
|
3896
4756
|
placeholder: formatMessage({
|
|
3897
4757
|
id: 'optionDescPlaceholder'
|
|
3898
4758
|
}),
|
|
3899
|
-
onChange:
|
|
3900
|
-
description
|
|
4759
|
+
onChange: description => updateSelf({
|
|
4760
|
+
description
|
|
3901
4761
|
}),
|
|
3902
|
-
onBlur: () => {
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
description: String((_item$description2 = item.description) != null ? _item$description2 : '').trim()
|
|
3906
|
-
});
|
|
3907
|
-
}
|
|
4762
|
+
onBlur: () => updateSelf({
|
|
4763
|
+
description: trimLocaleText(item.description, baseLanguage)
|
|
4764
|
+
})
|
|
3908
4765
|
}) : null]
|
|
3909
4766
|
}), /*#__PURE__*/jsxs("div", {
|
|
3910
4767
|
className: style['tree-option-actions'],
|
|
@@ -4010,13 +4867,14 @@ const ColumnsEditor = ({
|
|
|
4010
4867
|
gap: 8,
|
|
4011
4868
|
align: "start",
|
|
4012
4869
|
className: style['options-row'],
|
|
4013
|
-
children: [/*#__PURE__*/jsx(
|
|
4870
|
+
children: [/*#__PURE__*/jsx(LocaleTextControl, {
|
|
4871
|
+
compact: true,
|
|
4872
|
+
className: style['options-locale-text'],
|
|
4014
4873
|
value: item.title || '',
|
|
4015
4874
|
placeholder: formatMessage({
|
|
4016
4875
|
id: 'columnTitlePlaceholder'
|
|
4017
4876
|
}),
|
|
4018
|
-
onChange:
|
|
4019
|
-
const title = e.target.value;
|
|
4877
|
+
onChange: title => {
|
|
4020
4878
|
const patch = {
|
|
4021
4879
|
title
|
|
4022
4880
|
};
|
|
@@ -4087,8 +4945,10 @@ const TableRowsEditor = ({
|
|
|
4087
4945
|
onChange
|
|
4088
4946
|
}) => {
|
|
4089
4947
|
const {
|
|
4090
|
-
formatMessage
|
|
4948
|
+
formatMessage,
|
|
4949
|
+
locale
|
|
4091
4950
|
} = useIntl();
|
|
4951
|
+
const languages = useLocaleTextLanguages();
|
|
4092
4952
|
const usableColumns = _columns.filter(column => (column == null ? void 0 : column.name) && String(column.name).trim());
|
|
4093
4953
|
const list = _value3.length ? _value3 : [createEmptyTableRow(usableColumns)];
|
|
4094
4954
|
const updateItem = (index, patch) => {
|
|
@@ -4102,7 +4962,7 @@ const TableRowsEditor = ({
|
|
|
4102
4962
|
column: 1,
|
|
4103
4963
|
list: [/*#__PURE__*/jsx("div", {
|
|
4104
4964
|
block: true,
|
|
4105
|
-
children: /*#__PURE__*/jsx(Text$
|
|
4965
|
+
children: /*#__PURE__*/jsx(Text$2, {
|
|
4106
4966
|
type: "secondary",
|
|
4107
4967
|
children: formatMessage({
|
|
4108
4968
|
id: 'tableRowsNeedColumnsHint'
|
|
@@ -4160,13 +5020,15 @@ const TableRowsEditor = ({
|
|
|
4160
5020
|
onChange: e => updateItem(index, {
|
|
4161
5021
|
value: e.target.value
|
|
4162
5022
|
})
|
|
4163
|
-
}), /*#__PURE__*/jsx(
|
|
5023
|
+
}), /*#__PURE__*/jsx(LocaleTextControl, {
|
|
5024
|
+
compact: true,
|
|
5025
|
+
className: style['options-locale-text'],
|
|
4164
5026
|
value: item.label || '',
|
|
4165
5027
|
placeholder: formatMessage({
|
|
4166
5028
|
id: 'tableRowLabelPlaceholder'
|
|
4167
5029
|
}),
|
|
4168
|
-
onChange:
|
|
4169
|
-
label
|
|
5030
|
+
onChange: label => updateItem(index, {
|
|
5031
|
+
label
|
|
4170
5032
|
})
|
|
4171
5033
|
})]
|
|
4172
5034
|
}), /*#__PURE__*/jsx(Flex, {
|
|
@@ -4178,7 +5040,7 @@ const TableRowsEditor = ({
|
|
|
4178
5040
|
flex: 1
|
|
4179
5041
|
},
|
|
4180
5042
|
value: item[column.name] || '',
|
|
4181
|
-
placeholder: column.title || column.name,
|
|
5043
|
+
placeholder: resolveLocaleText(column.title, locale, languages) || column.name,
|
|
4182
5044
|
onChange: e => updateItem(index, {
|
|
4183
5045
|
[column.name]: e.target.value
|
|
4184
5046
|
})
|
|
@@ -4353,7 +5215,7 @@ const SuperSelectPropsEditor = ({
|
|
|
4353
5215
|
var _openApi$data2;
|
|
4354
5216
|
return !(openApi != null && (_openApi$data2 = openApi.data) != null && _openApi$data2.single);
|
|
4355
5217
|
}
|
|
4356
|
-
}, "maxLength"), /*#__PURE__*/jsx(
|
|
5218
|
+
}, "maxLength"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4357
5219
|
name: "placeholder",
|
|
4358
5220
|
label: formatMessage({
|
|
4359
5221
|
id: 'fieldPlaceholder'
|
|
@@ -4361,7 +5223,7 @@ const SuperSelectPropsEditor = ({
|
|
|
4361
5223
|
placeholder: formatMessage({
|
|
4362
5224
|
id: 'superSelectPlaceholderHint'
|
|
4363
5225
|
})
|
|
4364
|
-
}, "placeholder"), /*#__PURE__*/jsx(
|
|
5226
|
+
}, "placeholder"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4365
5227
|
name: "searchPlaceholder",
|
|
4366
5228
|
label: formatMessage({
|
|
4367
5229
|
id: 'superSelectSearchPlaceholder'
|
|
@@ -4417,7 +5279,7 @@ const buildPropsSchemaList = (schema, formatMessage) => (schema || []).filter(it
|
|
|
4417
5279
|
}, item.name);
|
|
4418
5280
|
});
|
|
4419
5281
|
const buildBuiltinList = (type, formatMessage) => {
|
|
4420
|
-
const placeholder = /*#__PURE__*/jsx(
|
|
5282
|
+
const placeholder = /*#__PURE__*/jsx(LocaleInput, {
|
|
4421
5283
|
name: "placeholder",
|
|
4422
5284
|
label: formatMessage({
|
|
4423
5285
|
id: 'fieldPlaceholder'
|
|
@@ -4600,7 +5462,7 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4600
5462
|
})
|
|
4601
5463
|
}, "showTime")];
|
|
4602
5464
|
case 'Switch':
|
|
4603
|
-
return [/*#__PURE__*/jsx(
|
|
5465
|
+
return [/*#__PURE__*/jsx(LocaleInput, {
|
|
4604
5466
|
name: "checkedChildren",
|
|
4605
5467
|
label: formatMessage({
|
|
4606
5468
|
id: 'propSwitchOnText'
|
|
@@ -4608,7 +5470,7 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4608
5470
|
placeholder: formatMessage({
|
|
4609
5471
|
id: 'propSwitchOnTextHint'
|
|
4610
5472
|
})
|
|
4611
|
-
}, "checkedChildren"), /*#__PURE__*/jsx(
|
|
5473
|
+
}, "checkedChildren"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4612
5474
|
name: "unCheckedChildren",
|
|
4613
5475
|
label: formatMessage({
|
|
4614
5476
|
id: 'propSwitchOffText'
|
|
@@ -4624,51 +5486,435 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4624
5486
|
children: formatMessage({
|
|
4625
5487
|
id: 'propOptionsInline'
|
|
4626
5488
|
})
|
|
4627
|
-
}, "inline")];
|
|
4628
|
-
default:
|
|
4629
|
-
return [];
|
|
5489
|
+
}, "inline")];
|
|
5490
|
+
default:
|
|
5491
|
+
return [];
|
|
5492
|
+
}
|
|
5493
|
+
};
|
|
5494
|
+
const FieldPropsEditor = ({
|
|
5495
|
+
type,
|
|
5496
|
+
definition: definitionProp
|
|
5497
|
+
}) => {
|
|
5498
|
+
const {
|
|
5499
|
+
formatMessage
|
|
5500
|
+
} = useIntl();
|
|
5501
|
+
const definition = definitionProp || getFieldDefinition(type);
|
|
5502
|
+
const list = useMemo(() => {
|
|
5503
|
+
var _definition$propsSche;
|
|
5504
|
+
if (!type) {
|
|
5505
|
+
return [];
|
|
5506
|
+
}
|
|
5507
|
+
if (definition != null && (_definition$propsSche = definition.propsSchema) != null && _definition$propsSche.length) {
|
|
5508
|
+
return buildPropsSchemaList(definition.propsSchema, formatMessage);
|
|
5509
|
+
}
|
|
5510
|
+
return buildBuiltinList(type, formatMessage);
|
|
5511
|
+
}, [type, definition, formatMessage]);
|
|
5512
|
+
if (!list.length) {
|
|
5513
|
+
return null;
|
|
5514
|
+
}
|
|
5515
|
+
return /*#__PURE__*/jsx(FormInfo, {
|
|
5516
|
+
title: formatMessage({
|
|
5517
|
+
id: 'fieldPropsSection'
|
|
5518
|
+
}),
|
|
5519
|
+
column: 1,
|
|
5520
|
+
list: list
|
|
5521
|
+
});
|
|
5522
|
+
};
|
|
5523
|
+
const hasFieldPropsEditor = (type, definition) => {
|
|
5524
|
+
var _def$propsSchema;
|
|
5525
|
+
const def = definition || getFieldDefinition(type);
|
|
5526
|
+
if (def != null && (_def$propsSchema = def.propsSchema) != null && _def$propsSchema.length) {
|
|
5527
|
+
return true;
|
|
5528
|
+
}
|
|
5529
|
+
return BUILTIN_PROP_TYPES.includes(type);
|
|
5530
|
+
};
|
|
5531
|
+
var FieldPropsEditor$1 = FieldPropsEditor;
|
|
5532
|
+
|
|
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
|
+
});
|
|
4630
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
|
+
});
|
|
4631
5724
|
};
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
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
|
|
4635
5737
|
}) => {
|
|
4636
5738
|
const {
|
|
4637
|
-
formatMessage
|
|
5739
|
+
formatMessage,
|
|
5740
|
+
locale
|
|
4638
5741
|
} = useIntl();
|
|
4639
|
-
const
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
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
|
+
});
|
|
4652
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");
|
|
4653
5907
|
return /*#__PURE__*/jsx(FormInfo, {
|
|
4654
5908
|
title: formatMessage({
|
|
4655
|
-
id: '
|
|
5909
|
+
id: 'visibleWhenTitle'
|
|
4656
5910
|
}),
|
|
4657
5911
|
column: 1,
|
|
4658
|
-
list:
|
|
5912
|
+
list: [body]
|
|
4659
5913
|
});
|
|
4660
5914
|
};
|
|
4661
|
-
|
|
4662
|
-
var _def$propsSchema;
|
|
4663
|
-
const def = definition || getFieldDefinition(type);
|
|
4664
|
-
if (def != null && (_def$propsSchema = def.propsSchema) != null && _def$propsSchema.length) {
|
|
4665
|
-
return true;
|
|
4666
|
-
}
|
|
4667
|
-
return BUILTIN_PROP_TYPES.includes(type);
|
|
4668
|
-
};
|
|
4669
|
-
var FieldPropsEditor$1 = FieldPropsEditor;
|
|
5915
|
+
var VisibleWhenEditor$1 = VisibleWhenEditor;
|
|
4670
5916
|
|
|
4671
|
-
const _excluded$
|
|
5917
|
+
const _excluded$2 = ["columns"];
|
|
4672
5918
|
const {
|
|
4673
5919
|
Text
|
|
4674
5920
|
} = Typography;
|
|
@@ -4684,7 +5930,7 @@ const getDefaultSelectProps = () => ({
|
|
|
4684
5930
|
columns: [createEmptyColumn()]
|
|
4685
5931
|
});
|
|
4686
5932
|
const omitColumns = (_ref = {}) => {
|
|
4687
|
-
let rest = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
5933
|
+
let rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
4688
5934
|
return rest;
|
|
4689
5935
|
};
|
|
4690
5936
|
const FieldConfigFields = ({
|
|
@@ -4692,7 +5938,10 @@ const FieldConfigFields = ({
|
|
|
4692
5938
|
options,
|
|
4693
5939
|
onOptionsChange,
|
|
4694
5940
|
columns,
|
|
4695
|
-
onColumnsChange
|
|
5941
|
+
onColumnsChange,
|
|
5942
|
+
visibleWhen,
|
|
5943
|
+
onVisibleWhenChange,
|
|
5944
|
+
conditionProps
|
|
4696
5945
|
}) => {
|
|
4697
5946
|
const {
|
|
4698
5947
|
formatMessage
|
|
@@ -4752,7 +6001,7 @@ const FieldConfigFields = ({
|
|
|
4752
6001
|
placeholder: formatMessage({
|
|
4753
6002
|
id: 'fieldNamePlaceholder'
|
|
4754
6003
|
})
|
|
4755
|
-
}, "name"), /*#__PURE__*/jsx(
|
|
6004
|
+
}, "name"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4756
6005
|
name: "label",
|
|
4757
6006
|
label: formatMessage({
|
|
4758
6007
|
id: 'fieldLabel'
|
|
@@ -4761,7 +6010,7 @@ const FieldConfigFields = ({
|
|
|
4761
6010
|
placeholder: formatMessage({
|
|
4762
6011
|
id: 'fieldLabelPlaceholder'
|
|
4763
6012
|
})
|
|
4764
|
-
}, "label"), /*#__PURE__*/jsx(
|
|
6013
|
+
}, "label"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4765
6014
|
name: "tips",
|
|
4766
6015
|
label: formatMessage({
|
|
4767
6016
|
id: 'fieldTips'
|
|
@@ -4769,7 +6018,7 @@ const FieldConfigFields = ({
|
|
|
4769
6018
|
placeholder: formatMessage({
|
|
4770
6019
|
id: 'fieldTipsPlaceholder'
|
|
4771
6020
|
})
|
|
4772
|
-
}, "tips"), /*#__PURE__*/jsx(
|
|
6021
|
+
}, "tips"), /*#__PURE__*/jsx(LocaleTextArea, {
|
|
4773
6022
|
name: "description",
|
|
4774
6023
|
label: formatMessage({
|
|
4775
6024
|
id: 'fieldDescription'
|
|
@@ -4816,13 +6065,17 @@ const FieldConfigFields = ({
|
|
|
4816
6065
|
hasColumns: definition.hasColumns,
|
|
4817
6066
|
columns: columns,
|
|
4818
6067
|
onColumnsChange: onColumnsChange
|
|
4819
|
-
}) : null
|
|
6068
|
+
}) : null, conditionProps ? /*#__PURE__*/jsx(VisibleWhenEditor$1, _extends({}, conditionProps, {
|
|
6069
|
+
value: visibleWhen,
|
|
6070
|
+
onChange: onVisibleWhenChange
|
|
6071
|
+
})) : null]
|
|
4820
6072
|
});
|
|
4821
6073
|
};
|
|
4822
6074
|
const FieldEditorModal = ({
|
|
4823
6075
|
open,
|
|
4824
6076
|
field,
|
|
4825
6077
|
fieldList,
|
|
6078
|
+
conditionProps,
|
|
4826
6079
|
onCancel,
|
|
4827
6080
|
onSave,
|
|
4828
6081
|
renderModal
|
|
@@ -4858,6 +6111,7 @@ const FieldEditorModal = ({
|
|
|
4858
6111
|
value: ''
|
|
4859
6112
|
}]);
|
|
4860
6113
|
const [columns, setColumns] = useState(() => [createEmptyColumn()]);
|
|
6114
|
+
const [visibleWhen, setVisibleWhen] = useState(undefined);
|
|
4861
6115
|
useEffect(() => {
|
|
4862
6116
|
var _editorValues$options, _editorValues$selectP;
|
|
4863
6117
|
if (!open) {
|
|
@@ -4868,15 +6122,23 @@ const FieldEditorModal = ({
|
|
|
4868
6122
|
value: ''
|
|
4869
6123
|
}]);
|
|
4870
6124
|
setColumns((_editorValues$selectP = editorValues.selectProps) != null && (_editorValues$selectP = _editorValues$selectP.columns) != null && _editorValues$selectP.length ? editorValues.selectProps.columns : [createEmptyColumn()]);
|
|
6125
|
+
setVisibleWhen(editorValues.visibleWhen);
|
|
4871
6126
|
}, [open, editorValues]);
|
|
4872
6127
|
const handleSubmit = async values => {
|
|
4873
|
-
var _values$lenMin, _values$lenMax;
|
|
6128
|
+
var _conditionProps$scope, _values$lenMin, _values$lenMax;
|
|
4874
6129
|
if (!isFieldNameUnique(fieldList, values.name, field == null ? void 0 : field.id)) {
|
|
4875
6130
|
message.error(formatMessage({
|
|
4876
6131
|
id: 'fieldNameDuplicate'
|
|
4877
6132
|
}));
|
|
4878
6133
|
return false;
|
|
4879
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
|
+
}
|
|
4880
6142
|
const definition = getFieldDefinition(values.type);
|
|
4881
6143
|
const normalizedColumns = definition != null && definition.hasColumns ? normalizeColumns(columns) : [];
|
|
4882
6144
|
const nextField = formValuesToField(_extends({}, values, {
|
|
@@ -4892,12 +6154,13 @@ const FieldEditorModal = ({
|
|
|
4892
6154
|
selectProps: _extends({}, values, {
|
|
4893
6155
|
columns: normalizedColumns
|
|
4894
6156
|
}),
|
|
4895
|
-
fieldProps: values
|
|
6157
|
+
fieldProps: values,
|
|
6158
|
+
visibleWhen
|
|
4896
6159
|
}), field || createField$1());
|
|
4897
6160
|
if (!nextField.id) {
|
|
4898
6161
|
nextField.id = createField$1().id;
|
|
4899
6162
|
}
|
|
4900
|
-
onSave(nextField);
|
|
6163
|
+
return onSave(nextField);
|
|
4901
6164
|
};
|
|
4902
6165
|
const modalKey = open ? field != null && field.id ? `edit-${field.id}` : `add-${formData.name}` : 'closed';
|
|
4903
6166
|
return /*#__PURE__*/jsx(FormModal, _extends({
|
|
@@ -4927,7 +6190,12 @@ const FieldEditorModal = ({
|
|
|
4927
6190
|
options: options,
|
|
4928
6191
|
onOptionsChange: setOptions,
|
|
4929
6192
|
columns: columns,
|
|
4930
|
-
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
|
|
4931
6199
|
})
|
|
4932
6200
|
}), modalKey);
|
|
4933
6201
|
};
|
|
@@ -5002,7 +6270,7 @@ const FormActionsEditor = ({
|
|
|
5002
6270
|
id: 'formActionsShowSubmit'
|
|
5003
6271
|
}),
|
|
5004
6272
|
className: style['form-actions-switch-field']
|
|
5005
|
-
}, "showSubmit"), /*#__PURE__*/jsx(
|
|
6273
|
+
}, "showSubmit"), /*#__PURE__*/jsx(LocaleInput, {
|
|
5006
6274
|
name: "submitText",
|
|
5007
6275
|
label: formatMessage({
|
|
5008
6276
|
id: 'formActionsSubmitText'
|
|
@@ -5025,7 +6293,7 @@ const FormActionsEditor = ({
|
|
|
5025
6293
|
id: 'formActionsShowReset'
|
|
5026
6294
|
}),
|
|
5027
6295
|
className: style['form-actions-switch-field']
|
|
5028
|
-
}, "showReset"), /*#__PURE__*/jsx(
|
|
6296
|
+
}, "showReset"), /*#__PURE__*/jsx(LocaleInput, {
|
|
5029
6297
|
name: "resetText",
|
|
5030
6298
|
label: formatMessage({
|
|
5031
6299
|
id: 'formActionsResetText'
|
|
@@ -5048,7 +6316,7 @@ const FormActionsEditor = ({
|
|
|
5048
6316
|
id: 'formActionsShowCancel'
|
|
5049
6317
|
}),
|
|
5050
6318
|
className: style['form-actions-switch-field']
|
|
5051
|
-
}, "showCancel"), /*#__PURE__*/jsx(
|
|
6319
|
+
}, "showCancel"), /*#__PURE__*/jsx(LocaleInput, {
|
|
5052
6320
|
name: "cancelText",
|
|
5053
6321
|
label: formatMessage({
|
|
5054
6322
|
id: 'formActionsCancelText'
|
|
@@ -5384,6 +6652,100 @@ const ChoiceBlock = ({
|
|
|
5384
6652
|
};
|
|
5385
6653
|
var ChoiceBlock$1 = ChoiceBlock;
|
|
5386
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
|
+
|
|
6701
|
+
// @kne/react-form 内置规则的错误提示写死中文;在 preset 覆盖前记下原函数,只替换未被业务覆盖的规则
|
|
6702
|
+
const BUILTIN_RULES = {
|
|
6703
|
+
TEL: RULES.TEL,
|
|
6704
|
+
EMAIL: RULES.EMAIL,
|
|
6705
|
+
LEN: RULES.LEN
|
|
6706
|
+
};
|
|
6707
|
+
const isBuiltin = name => RULES[name] === BUILTIN_RULES[name];
|
|
6708
|
+
const lenMessageId = (value, start, end) => {
|
|
6709
|
+
if (end === start) {
|
|
6710
|
+
return 'ruleErrorLenEqual';
|
|
6711
|
+
}
|
|
6712
|
+
return String(value != null ? value : '').length < start ? 'ruleErrorLenMin' : 'ruleErrorLenMax';
|
|
6713
|
+
};
|
|
6714
|
+
|
|
6715
|
+
/** 按当前语言生成表单级 rules,传给 Form 覆盖全局同名规则 */
|
|
6716
|
+
const createLocalizedRules = formatMessage => {
|
|
6717
|
+
if (typeof formatMessage !== 'function') {
|
|
6718
|
+
return {};
|
|
6719
|
+
}
|
|
6720
|
+
const rules = {};
|
|
6721
|
+
['TEL', 'EMAIL'].forEach(name => {
|
|
6722
|
+
if (isBuiltin(name)) {
|
|
6723
|
+
rules[name] = (...args) => {
|
|
6724
|
+
const res = BUILTIN_RULES[name](...args);
|
|
6725
|
+
return res.result ? res : _extends({}, res, {
|
|
6726
|
+
errMsg: formatMessage({
|
|
6727
|
+
id: `ruleError${name}`
|
|
6728
|
+
})
|
|
6729
|
+
});
|
|
6730
|
+
};
|
|
6731
|
+
}
|
|
6732
|
+
});
|
|
6733
|
+
if (isBuiltin('LEN')) {
|
|
6734
|
+
rules.LEN = (value, start, end) => {
|
|
6735
|
+
const res = BUILTIN_RULES.LEN(value, start, end);
|
|
6736
|
+
return res.result ? res : _extends({}, res, {
|
|
6737
|
+
errMsg: formatMessage({
|
|
6738
|
+
id: lenMessageId(value, start, end)
|
|
6739
|
+
}, {
|
|
6740
|
+
start,
|
|
6741
|
+
end
|
|
6742
|
+
})
|
|
6743
|
+
});
|
|
6744
|
+
};
|
|
6745
|
+
}
|
|
6746
|
+
return rules;
|
|
6747
|
+
};
|
|
6748
|
+
|
|
5387
6749
|
const buildLabelTips = tips => {
|
|
5388
6750
|
if (tips == null || !String(tips).trim()) {
|
|
5389
6751
|
return undefined;
|
|
@@ -5408,18 +6770,18 @@ const buildIndexedLabelRender = index => {
|
|
|
5408
6770
|
label
|
|
5409
6771
|
}) => {
|
|
5410
6772
|
const text = label != null ? String(label).replace(/\u200b/g, '') : '';
|
|
5411
|
-
return /*#__PURE__*/createElement(Fragment, null, /*#__PURE__*/createElement('span', {
|
|
6773
|
+
return /*#__PURE__*/createElement(Fragment$1, null, /*#__PURE__*/createElement('span', {
|
|
5412
6774
|
className: style['field-label-index']
|
|
5413
6775
|
}, `${index + 1}.`), text ? /*#__PURE__*/createElement('span', {
|
|
5414
6776
|
className: style['field-label-main']
|
|
5415
6777
|
}, text) : null);
|
|
5416
6778
|
};
|
|
5417
6779
|
};
|
|
5418
|
-
const
|
|
6780
|
+
const renderFieldEntries = (fields = [], preview = false, {
|
|
5419
6781
|
namePrefix,
|
|
5420
6782
|
locale,
|
|
5421
6783
|
showIndex: _showIndex = false
|
|
5422
|
-
} = {}) => fields.filter(field => !field.hidden).map((field, index) => {
|
|
6784
|
+
} = {}) => (fields || []).filter(field => !field.hidden).map((field, index) => {
|
|
5423
6785
|
var _props$options;
|
|
5424
6786
|
const Component = getFieldComponent(field.type, field);
|
|
5425
6787
|
if (!Component) {
|
|
@@ -5453,7 +6815,7 @@ const renderFieldElements = (fields = [], preview = false, {
|
|
|
5453
6815
|
locale
|
|
5454
6816
|
} : {};
|
|
5455
6817
|
const label = buildFieldLabel(field);
|
|
5456
|
-
|
|
6818
|
+
const element = /*#__PURE__*/createElement(Component, _extends({
|
|
5457
6819
|
key: field.id,
|
|
5458
6820
|
name: fieldName,
|
|
5459
6821
|
label: _showIndex ? label || '\u200b' : label
|
|
@@ -5466,7 +6828,27 @@ const renderFieldElements = (fields = [], preview = false, {
|
|
|
5466
6828
|
labelTips: buildLabelTips(field.tips),
|
|
5467
6829
|
description
|
|
5468
6830
|
}));
|
|
6831
|
+
return {
|
|
6832
|
+
element,
|
|
6833
|
+
path: fieldName,
|
|
6834
|
+
visibleWhen: hasVisibleWhen(field) ? field.visibleWhen : null
|
|
6835
|
+
};
|
|
5469
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
|
+
};
|
|
5470
6852
|
const withBlockLayout = (element, forceBlock) => {
|
|
5471
6853
|
var _element$props;
|
|
5472
6854
|
if (!element || !forceBlock) {
|
|
@@ -5503,7 +6885,8 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5503
6885
|
formatMessage,
|
|
5504
6886
|
depth = 0,
|
|
5505
6887
|
asListItem = false,
|
|
5506
|
-
locale
|
|
6888
|
+
locale,
|
|
6889
|
+
knownNames
|
|
5507
6890
|
} = ctx;
|
|
5508
6891
|
if (!block || depth > MAX_BLOCK_DEPTH) {
|
|
5509
6892
|
return null;
|
|
@@ -5531,39 +6914,37 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5531
6914
|
case 'formInfo':
|
|
5532
6915
|
{
|
|
5533
6916
|
const showIndex = !!block.showIndex;
|
|
5534
|
-
const
|
|
6917
|
+
const entries = renderFieldEntries(block.list, preview, _extends({}, fieldRenderOpts, {
|
|
5535
6918
|
showIndex
|
|
5536
6919
|
}));
|
|
5537
6920
|
const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
|
|
5538
|
-
return withBlockLayout(
|
|
6921
|
+
return withBlockLayout(createFieldsFormInfo(_extends({
|
|
5539
6922
|
key: block.id,
|
|
5540
6923
|
title: block.title || undefined,
|
|
5541
6924
|
subtitle: block.subtitle || undefined,
|
|
5542
6925
|
column: block.column,
|
|
5543
6926
|
gap: block.gap,
|
|
5544
|
-
bordered
|
|
5545
|
-
list: [...fields, ...nested]
|
|
6927
|
+
bordered
|
|
5546
6928
|
}, listItemPartProps || {}, {
|
|
5547
6929
|
className: resolvePartRootClassName(depth, showIndex ? style['form-info-show-index'] : null)
|
|
5548
|
-
})), asListItem);
|
|
6930
|
+
}), entries, nested, knownNames), asListItem);
|
|
5549
6931
|
}
|
|
5550
6932
|
case 'object':
|
|
5551
6933
|
{
|
|
5552
|
-
const
|
|
6934
|
+
const entries = renderFieldEntries(block.list, preview, _extends({}, fieldRenderOpts, {
|
|
5553
6935
|
namePrefix: block.name || ''
|
|
5554
6936
|
}));
|
|
5555
6937
|
const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
|
|
5556
|
-
return withBlockLayout(
|
|
6938
|
+
return withBlockLayout(createFieldsFormInfo(_extends({
|
|
5557
6939
|
key: block.id,
|
|
5558
6940
|
title: block.title || undefined,
|
|
5559
6941
|
subtitle: block.subtitle || undefined,
|
|
5560
6942
|
column: block.column,
|
|
5561
6943
|
gap: block.gap,
|
|
5562
|
-
bordered
|
|
5563
|
-
list: [...fields, ...nested]
|
|
6944
|
+
bordered
|
|
5564
6945
|
}, listItemPartProps || {}, {
|
|
5565
6946
|
className: resolvePartRootClassName(depth)
|
|
5566
|
-
})), asListItem);
|
|
6947
|
+
}), entries, nested, knownNames), asListItem);
|
|
5567
6948
|
}
|
|
5568
6949
|
case 'list':
|
|
5569
6950
|
{
|
|
@@ -5654,24 +7035,24 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5654
7035
|
prevIcon: /*#__PURE__*/createElement(ArrowLeftOutlined),
|
|
5655
7036
|
nextIcon: /*#__PURE__*/createElement(ArrowRightOutlined),
|
|
5656
7037
|
items: (block.items || []).map(step => {
|
|
5657
|
-
const
|
|
7038
|
+
const entries = renderFieldEntries(step.list, preview, fieldRenderOpts);
|
|
5658
7039
|
const nested = renderChildBlocks(step.blocks || [], nextCtx);
|
|
5659
7040
|
const fieldNames = [...(step.list || []).filter(field => field && !field.hidden && field.name).map(field => field.name), ...collectBlockFieldNames(step.blocks || [])];
|
|
5660
|
-
|
|
7041
|
+
const hasConditional = entries.some(entry => entry.visibleWhen);
|
|
7042
|
+
if (nested.length || hasConditional) {
|
|
5661
7043
|
return {
|
|
5662
7044
|
key: step.id,
|
|
5663
7045
|
title: step.title,
|
|
5664
7046
|
column: step.column,
|
|
5665
7047
|
gap: block.gap,
|
|
5666
7048
|
fieldNames,
|
|
5667
|
-
children: /*#__PURE__*/createElement(Fragment, {
|
|
7049
|
+
children: /*#__PURE__*/createElement(Fragment$1, {
|
|
5668
7050
|
key: `${step.id}-body`
|
|
5669
|
-
},
|
|
7051
|
+
}, entries.length ? createFieldsFormInfo({
|
|
5670
7052
|
key: `${step.id}-fields`,
|
|
5671
7053
|
column: step.column,
|
|
5672
|
-
gap: block.gap
|
|
5673
|
-
|
|
5674
|
-
}) : null, ...nested)
|
|
7054
|
+
gap: block.gap
|
|
7055
|
+
}, entries, [], knownNames) : null, ...nested)
|
|
5675
7056
|
};
|
|
5676
7057
|
}
|
|
5677
7058
|
return {
|
|
@@ -5679,7 +7060,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5679
7060
|
title: step.title,
|
|
5680
7061
|
column: step.column,
|
|
5681
7062
|
gap: block.gap,
|
|
5682
|
-
list:
|
|
7063
|
+
list: entries.map(entry => entry.element),
|
|
5683
7064
|
fieldNames
|
|
5684
7065
|
};
|
|
5685
7066
|
})
|
|
@@ -5696,12 +7077,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5696
7077
|
renderOptionContent: option => {
|
|
5697
7078
|
const nodes = [];
|
|
5698
7079
|
if ((option.list || []).length) {
|
|
5699
|
-
nodes.push(
|
|
7080
|
+
nodes.push(createFieldsFormInfo({
|
|
5700
7081
|
key: `${option.id}-fields`,
|
|
5701
7082
|
column: block.column || 2,
|
|
5702
|
-
gap: block.gap
|
|
5703
|
-
|
|
5704
|
-
}));
|
|
7083
|
+
gap: block.gap
|
|
7084
|
+
}, renderFieldEntries(option.list, preview), [], knownNames));
|
|
5705
7085
|
}
|
|
5706
7086
|
nodes.push(...renderChildBlocks(option.blocks || [], nextCtx));
|
|
5707
7087
|
return nodes.filter(Boolean);
|
|
@@ -5723,10 +7103,12 @@ const renderSchemaInner = (schema, {
|
|
|
5723
7103
|
} = {}) => {
|
|
5724
7104
|
const normalized = normalizeSchema(schema);
|
|
5725
7105
|
const blocks = normalized.blocks || [];
|
|
7106
|
+
const knownNames = collectTriggerNames(normalized);
|
|
5726
7107
|
const contentChildren = blocks.map(block => renderBlockElement(block, _preview, {
|
|
5727
7108
|
isMobile: _isMobile,
|
|
5728
7109
|
formatMessage,
|
|
5729
|
-
locale
|
|
7110
|
+
locale,
|
|
7111
|
+
knownNames
|
|
5730
7112
|
})).filter(Boolean);
|
|
5731
7113
|
if (!contentChildren.length && !children && !actionNode) {
|
|
5732
7114
|
return null;
|
|
@@ -5734,7 +7116,7 @@ const renderSchemaInner = (schema, {
|
|
|
5734
7116
|
const body = /*#__PURE__*/createElement('div', {
|
|
5735
7117
|
className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
|
|
5736
7118
|
}, ...contentChildren, children);
|
|
5737
|
-
const content = /*#__PURE__*/createElement(Fragment, null, body, actionNode || null);
|
|
7119
|
+
const content = /*#__PURE__*/createElement(Fragment$1, null, body, actionNode || null);
|
|
5738
7120
|
return className ? /*#__PURE__*/createElement('div', {
|
|
5739
7121
|
className
|
|
5740
7122
|
}, content) : content;
|
|
@@ -5752,16 +7134,19 @@ const renderSchemaContent = (schema, {
|
|
|
5752
7134
|
} = {}) => {
|
|
5753
7135
|
const normalized = normalizeSchema(schema);
|
|
5754
7136
|
const blocks = normalized.blocks || [];
|
|
7137
|
+
const knownNames = collectTriggerNames(normalized);
|
|
5755
7138
|
const contentChildren = blocks.map(block => renderBlockElement(block, _preview2, {
|
|
5756
7139
|
isMobile: _isMobile2,
|
|
5757
7140
|
formatMessage,
|
|
5758
|
-
locale
|
|
7141
|
+
locale,
|
|
7142
|
+
knownNames
|
|
5759
7143
|
})).filter(Boolean);
|
|
5760
7144
|
if (!contentChildren.length && !children) {
|
|
5761
7145
|
return null;
|
|
5762
7146
|
}
|
|
5763
7147
|
const formClassName = [style['schema-form'], _formProps.className, className].filter(Boolean).join(' ');
|
|
5764
7148
|
return /*#__PURE__*/createElement(Form, _extends({}, _formProps, {
|
|
7149
|
+
rules: _extends({}, createLocalizedRules(formatMessage), _formProps.rules),
|
|
5765
7150
|
className: formClassName
|
|
5766
7151
|
}), /*#__PURE__*/createElement('div', {
|
|
5767
7152
|
className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
|
|
@@ -5861,14 +7246,15 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5861
7246
|
bodyClassName,
|
|
5862
7247
|
footerClassName,
|
|
5863
7248
|
buttonFooter = false,
|
|
5864
|
-
buttonFooterProps
|
|
7249
|
+
buttonFooterProps,
|
|
7250
|
+
languages
|
|
5865
7251
|
} = props;
|
|
5866
7252
|
const {
|
|
5867
7253
|
formatMessage,
|
|
5868
7254
|
locale
|
|
5869
7255
|
} = useIntl();
|
|
5870
7256
|
const isMobile = useIsMobile();
|
|
5871
|
-
const normalized = normalizeSchema(schema);
|
|
7257
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
5872
7258
|
if (!hasRenderableContent(normalized)) {
|
|
5873
7259
|
return null;
|
|
5874
7260
|
}
|
|
@@ -5926,14 +7312,15 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5926
7312
|
bodyClassName,
|
|
5927
7313
|
footerClassName,
|
|
5928
7314
|
buttonFooter = false,
|
|
5929
|
-
buttonFooterProps
|
|
7315
|
+
buttonFooterProps,
|
|
7316
|
+
languages
|
|
5930
7317
|
} = props;
|
|
5931
7318
|
const {
|
|
5932
7319
|
formatMessage,
|
|
5933
7320
|
locale
|
|
5934
7321
|
} = useIntl();
|
|
5935
7322
|
const isMobile = useIsMobile();
|
|
5936
|
-
const normalized = normalizeSchema(schema);
|
|
7323
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
5937
7324
|
if (!hasRenderableContent(normalized)) {
|
|
5938
7325
|
return null;
|
|
5939
7326
|
}
|
|
@@ -5979,7 +7366,8 @@ const FormCreator = withLocale$1(({
|
|
|
5979
7366
|
className,
|
|
5980
7367
|
formProps,
|
|
5981
7368
|
renderModal,
|
|
5982
|
-
extraToolbar
|
|
7369
|
+
extraToolbar,
|
|
7370
|
+
languages
|
|
5983
7371
|
}) => {
|
|
5984
7372
|
const {
|
|
5985
7373
|
formatMessage,
|
|
@@ -6076,6 +7464,9 @@ const FormCreator = withLocale$1(({
|
|
|
6076
7464
|
clearBlockEditor();
|
|
6077
7465
|
};
|
|
6078
7466
|
const handleDeleteBlock = blockId => {
|
|
7467
|
+
if (blockHasLockedField(findBlock(schema, blockId))) {
|
|
7468
|
+
return;
|
|
7469
|
+
}
|
|
6079
7470
|
updateSchema(updateBlocks(schema, blocks => removeBlockInTree(blocks, blockId)));
|
|
6080
7471
|
};
|
|
6081
7472
|
const handleMoveBlock = (blockId, direction) => {
|
|
@@ -6110,12 +7501,12 @@ const FormCreator = withLocale$1(({
|
|
|
6110
7501
|
};
|
|
6111
7502
|
const handleDeleteStep = (blockId, stepId) => {
|
|
6112
7503
|
updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
|
|
6113
|
-
items: (block.items || []).filter(item => item.id !== stepId)
|
|
7504
|
+
items: (block.items || []).filter(item => item.id !== stepId || blockHasLockedField(item))
|
|
6114
7505
|
})));
|
|
6115
7506
|
};
|
|
6116
7507
|
const handleMoveStep = (blockId, stepId, direction) => {
|
|
6117
7508
|
updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
|
|
6118
|
-
items: moveItem(block.items || [], stepId, direction)
|
|
7509
|
+
items: moveItem(block.items || [], stepId, direction, blockHasLockedField)
|
|
6119
7510
|
})));
|
|
6120
7511
|
};
|
|
6121
7512
|
const handleAddChoiceOption = blockId => {
|
|
@@ -6147,12 +7538,12 @@ const FormCreator = withLocale$1(({
|
|
|
6147
7538
|
};
|
|
6148
7539
|
const handleDeleteChoiceOption = (blockId, optionId) => {
|
|
6149
7540
|
updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
|
|
6150
|
-
options: (block.options || []).filter(item => item.id !== optionId)
|
|
7541
|
+
options: (block.options || []).filter(item => item.id !== optionId || blockHasLockedField(item))
|
|
6151
7542
|
})));
|
|
6152
7543
|
};
|
|
6153
7544
|
const handleMoveChoiceOption = (blockId, optionId, direction) => {
|
|
6154
7545
|
updateSchema(mapBlocks(schema, blockId, block => _extends({}, block, {
|
|
6155
|
-
options: moveItem(block.options || [], optionId, direction)
|
|
7546
|
+
options: moveItem(block.options || [], optionId, direction, blockHasLockedField)
|
|
6156
7547
|
})));
|
|
6157
7548
|
};
|
|
6158
7549
|
const normalizeFieldScope = scope => {
|
|
@@ -6171,6 +7562,9 @@ const FormCreator = withLocale$1(({
|
|
|
6171
7562
|
setFieldEditorOpen(true);
|
|
6172
7563
|
};
|
|
6173
7564
|
const handleEditField = (blockId, field, scope) => {
|
|
7565
|
+
if (isFieldLocked(field)) {
|
|
7566
|
+
return;
|
|
7567
|
+
}
|
|
6174
7568
|
setFieldContext(_extends({
|
|
6175
7569
|
blockId
|
|
6176
7570
|
}, normalizeFieldScope(scope)));
|
|
@@ -6183,7 +7577,7 @@ const FormCreator = withLocale$1(({
|
|
|
6183
7577
|
stepId,
|
|
6184
7578
|
optionId
|
|
6185
7579
|
} = fieldContext || {};
|
|
6186
|
-
|
|
7580
|
+
let nextSchema = mapBlocks(schema, blockId, block => {
|
|
6187
7581
|
if (block.kind === 'steps') {
|
|
6188
7582
|
return _extends({}, block, {
|
|
6189
7583
|
items: (block.items || []).map(step => {
|
|
@@ -6214,7 +7608,21 @@ const FormCreator = withLocale$1(({
|
|
|
6214
7608
|
return _extends({}, block, {
|
|
6215
7609
|
list: exists ? block.list.map(item => item.id === field.id ? field : item) : [...(block.list || []), field]
|
|
6216
7610
|
});
|
|
6217
|
-
})
|
|
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);
|
|
6218
7626
|
setFieldEditorOpen(false);
|
|
6219
7627
|
setFieldContext(null);
|
|
6220
7628
|
setEditingField(null);
|
|
@@ -6228,19 +7636,19 @@ const FormCreator = withLocale$1(({
|
|
|
6228
7636
|
if (block.kind === 'steps') {
|
|
6229
7637
|
return _extends({}, block, {
|
|
6230
7638
|
items: (block.items || []).map(step => step.id === stepId ? _extends({}, step, {
|
|
6231
|
-
list: (step.list || []).filter(item => item.id !== fieldId)
|
|
7639
|
+
list: (step.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
|
|
6232
7640
|
}) : step)
|
|
6233
7641
|
});
|
|
6234
7642
|
}
|
|
6235
7643
|
if (block.kind === 'choice') {
|
|
6236
7644
|
return _extends({}, block, {
|
|
6237
7645
|
options: (block.options || []).map(option => option.id === optionId ? _extends({}, option, {
|
|
6238
|
-
list: (option.list || []).filter(item => item.id !== fieldId)
|
|
7646
|
+
list: (option.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
|
|
6239
7647
|
}) : option)
|
|
6240
7648
|
});
|
|
6241
7649
|
}
|
|
6242
7650
|
return _extends({}, block, {
|
|
6243
|
-
list: (block.list || []).filter(item => item.id !== fieldId)
|
|
7651
|
+
list: (block.list || []).filter(item => item.id !== fieldId || isFieldLocked(item))
|
|
6244
7652
|
});
|
|
6245
7653
|
}));
|
|
6246
7654
|
};
|
|
@@ -6274,97 +7682,107 @@ const FormCreator = withLocale$1(({
|
|
|
6274
7682
|
stepId: fieldContext.stepId,
|
|
6275
7683
|
optionId: fieldContext.optionId
|
|
6276
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]);
|
|
6277
7690
|
const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
|
|
6278
7691
|
schema
|
|
6279
7692
|
}) : extraToolbar;
|
|
6280
|
-
return /*#__PURE__*/
|
|
6281
|
-
|
|
6282
|
-
children:
|
|
6283
|
-
className: style['
|
|
6284
|
-
children: /*#__PURE__*/jsx(
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
className: style['preview-
|
|
6309
|
-
children:
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
7693
|
+
return /*#__PURE__*/jsx(LocaleTextProvider, {
|
|
7694
|
+
languages: languages,
|
|
7695
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
7696
|
+
className: [style['form-creator'], RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
|
|
7697
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
7698
|
+
className: style['editor-pane'],
|
|
7699
|
+
children: /*#__PURE__*/jsx(BlockListPanel$1, {
|
|
7700
|
+
blocks: schema.blocks,
|
|
7701
|
+
onAddBlock: handleAddBlock,
|
|
7702
|
+
onEditBlock: handleEditBlock,
|
|
7703
|
+
onDeleteBlock: handleDeleteBlock,
|
|
7704
|
+
onMoveBlock: handleMoveBlock,
|
|
7705
|
+
onAddField: handleAddField,
|
|
7706
|
+
onEditField: handleEditField,
|
|
7707
|
+
onDeleteField: handleDeleteField,
|
|
7708
|
+
onMoveField: handleMoveField,
|
|
7709
|
+
onAddStep: handleAddStep,
|
|
7710
|
+
onEditStep: handleEditStep,
|
|
7711
|
+
onDeleteStep: handleDeleteStep,
|
|
7712
|
+
onMoveStep: handleMoveStep,
|
|
7713
|
+
onAddChoiceOption: handleAddChoiceOption,
|
|
7714
|
+
onEditChoiceOption: handleEditChoiceOption,
|
|
7715
|
+
onDeleteChoiceOption: handleDeleteChoiceOption,
|
|
7716
|
+
onMoveChoiceOption: handleMoveChoiceOption,
|
|
7717
|
+
onOpenFormActions: () => setFormActionsOpen(true),
|
|
7718
|
+
extraToolbar: toolbarExtra
|
|
7719
|
+
})
|
|
7720
|
+
}), _showPreview ? /*#__PURE__*/jsx("div", {
|
|
7721
|
+
className: style['preview-pane'],
|
|
7722
|
+
children: /*#__PURE__*/jsx("div", {
|
|
7723
|
+
className: style['preview-body'],
|
|
7724
|
+
children: hasRenderableContent(schema) ? /*#__PURE__*/jsx(SchemaRenderer$1, {
|
|
7725
|
+
schema: schema,
|
|
7726
|
+
preview: true,
|
|
7727
|
+
formProps: formProps,
|
|
7728
|
+
locale: locale,
|
|
7729
|
+
languages: languages
|
|
7730
|
+
}) : /*#__PURE__*/jsx(Empty, {
|
|
7731
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
7732
|
+
description: formatMessage({
|
|
7733
|
+
id: 'emptyBlockList'
|
|
7734
|
+
})
|
|
6318
7735
|
})
|
|
6319
7736
|
})
|
|
6320
|
-
})
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
7737
|
+
}) : null, /*#__PURE__*/jsx(BlockEditorModal$1, {
|
|
7738
|
+
open: blockEditorOpen,
|
|
7739
|
+
block: editingBlock,
|
|
7740
|
+
renderModal: renderModal,
|
|
7741
|
+
onCancel: clearBlockEditor,
|
|
7742
|
+
onSave: handleSaveBlock
|
|
7743
|
+
}), /*#__PURE__*/jsx(StepEditorModal$1, {
|
|
7744
|
+
open: stepEditorOpen,
|
|
7745
|
+
step: stepContext == null ? void 0 : stepContext.step,
|
|
7746
|
+
renderModal: renderModal,
|
|
7747
|
+
onCancel: () => {
|
|
7748
|
+
setStepEditorOpen(false);
|
|
7749
|
+
setStepContext(null);
|
|
7750
|
+
},
|
|
7751
|
+
onSave: handleSaveStep
|
|
7752
|
+
}), /*#__PURE__*/jsx(ChoiceOptionEditorModal$1, {
|
|
7753
|
+
open: choiceOptionEditorOpen,
|
|
7754
|
+
option: choiceOptionContext == null ? void 0 : choiceOptionContext.option,
|
|
7755
|
+
renderModal: renderModal,
|
|
7756
|
+
onCancel: () => {
|
|
7757
|
+
setChoiceOptionEditorOpen(false);
|
|
7758
|
+
setChoiceOptionContext(null);
|
|
7759
|
+
},
|
|
7760
|
+
onSave: handleSaveChoiceOption
|
|
7761
|
+
}), /*#__PURE__*/jsx(FieldEditorModal$1, {
|
|
7762
|
+
open: fieldEditorOpen,
|
|
7763
|
+
field: editingField,
|
|
7764
|
+
fieldList: currentFieldScope,
|
|
7765
|
+
conditionProps: conditionProps,
|
|
7766
|
+
renderModal: renderModal,
|
|
7767
|
+
onCancel: () => {
|
|
7768
|
+
setFieldEditorOpen(false);
|
|
7769
|
+
setFieldContext(null);
|
|
7770
|
+
setEditingField(null);
|
|
7771
|
+
},
|
|
7772
|
+
onSave: handleSaveField
|
|
7773
|
+
}), /*#__PURE__*/jsx(FormActionsEditor$1, {
|
|
7774
|
+
open: formActionsOpen,
|
|
7775
|
+
value: schema.actions,
|
|
7776
|
+
renderModal: renderModal,
|
|
7777
|
+
onCancel: () => setFormActionsOpen(false),
|
|
7778
|
+
onSave: actions => {
|
|
7779
|
+
updateSchema(_extends({}, schema, {
|
|
7780
|
+
actions
|
|
7781
|
+
}));
|
|
7782
|
+
setFormActionsOpen(false);
|
|
7783
|
+
}
|
|
7784
|
+
})]
|
|
7785
|
+
})
|
|
6368
7786
|
});
|
|
6369
7787
|
});
|
|
6370
7788
|
var FormCreator$1 = FormCreator;
|
|
@@ -6681,7 +8099,7 @@ const formatDateToToday = (value, itemSchema, ctx) => {
|
|
|
6681
8099
|
if (items[1] == null || items[1] === '' || items[1] === true) {
|
|
6682
8100
|
const until = (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6683
8101
|
id: 'schemaContentUntilToday'
|
|
6684
|
-
})) ||
|
|
8102
|
+
})) || zhCN.schemaContentUntilToday;
|
|
6685
8103
|
return [start, until].filter(Boolean).join(' ~ ');
|
|
6686
8104
|
}
|
|
6687
8105
|
const end = formatByValueSchema(items[1], itemSchema, ctx);
|
|
@@ -6736,11 +8154,11 @@ const formatBoolean = (value, field, ctx) => {
|
|
|
6736
8154
|
if (value) {
|
|
6737
8155
|
return props.checkedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6738
8156
|
id: 'schemaContentYes'
|
|
6739
|
-
})) ||
|
|
8157
|
+
})) || zhCN.schemaContentYes;
|
|
6740
8158
|
}
|
|
6741
8159
|
return props.unCheckedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6742
8160
|
id: 'schemaContentNo'
|
|
6743
|
-
})) ||
|
|
8161
|
+
})) || zhCN.schemaContentNo;
|
|
6744
8162
|
};
|
|
6745
8163
|
const stringifyFallback = value => {
|
|
6746
8164
|
if (value == null) {
|
|
@@ -6867,9 +8285,12 @@ const formatByValueSchema = (value, schema, ctx = {}) => {
|
|
|
6867
8285
|
}
|
|
6868
8286
|
return String(value);
|
|
6869
8287
|
};
|
|
6870
|
-
const formatFieldDisplayValue = (
|
|
6871
|
-
formatMessage
|
|
8288
|
+
const formatFieldDisplayValue = (rawField, value, {
|
|
8289
|
+
formatMessage,
|
|
8290
|
+
locale,
|
|
8291
|
+
languages
|
|
6872
8292
|
} = {}) => {
|
|
8293
|
+
const field = localizeSchema(rawField, locale, languages);
|
|
6873
8294
|
const emptyText = (formatMessage == null ? void 0 : formatMessage({
|
|
6874
8295
|
id: 'schemaContentEmptyValue'
|
|
6875
8296
|
})) || '-';
|
|
@@ -6957,8 +8378,43 @@ const resolveChoiceSelectorName$1 = block => {
|
|
|
6957
8378
|
}
|
|
6958
8379
|
return `__choice_${block.id}`;
|
|
6959
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
|
+
};
|
|
6960
8415
|
const mergeFieldIntoLayer = (layer, field, {
|
|
6961
|
-
allowRequired: _allowRequired = true
|
|
8416
|
+
allowRequired: _allowRequired = true,
|
|
8417
|
+
ctx
|
|
6962
8418
|
} = {}) => {
|
|
6963
8419
|
if (!(field != null && field.name)) {
|
|
6964
8420
|
return;
|
|
@@ -6967,8 +8423,14 @@ const mergeFieldIntoLayer = (layer, field, {
|
|
|
6967
8423
|
if (!name) {
|
|
6968
8424
|
return;
|
|
6969
8425
|
}
|
|
6970
|
-
|
|
6971
|
-
|
|
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)) {
|
|
6972
8434
|
layer.required.push(name);
|
|
6973
8435
|
}
|
|
6974
8436
|
};
|
|
@@ -7010,33 +8472,39 @@ const finalizeObjectSchema = (layer, {
|
|
|
7010
8472
|
}
|
|
7011
8473
|
return schema;
|
|
7012
8474
|
};
|
|
7013
|
-
const walkBlocks = (blocks, layer, depth = 0) => {
|
|
8475
|
+
const walkBlocks = (blocks, layer, depth = 0, ctx = {}) => {
|
|
7014
8476
|
(blocks || []).forEach(block => {
|
|
7015
8477
|
if (!block) {
|
|
7016
8478
|
return;
|
|
7017
8479
|
}
|
|
7018
|
-
walkBlock(block, layer, depth);
|
|
8480
|
+
walkBlock(block, layer, depth, ctx);
|
|
7019
8481
|
});
|
|
7020
8482
|
};
|
|
7021
|
-
const walkBlock = (block, layer, depth = 0) => {
|
|
8483
|
+
const walkBlock = (block, layer, depth = 0, ctx = {}) => {
|
|
7022
8484
|
switch (block.kind) {
|
|
7023
8485
|
case 'formInfo':
|
|
7024
8486
|
{
|
|
7025
|
-
mergeFieldsIntoLayer(layer, block.list
|
|
7026
|
-
|
|
8487
|
+
mergeFieldsIntoLayer(layer, block.list, {
|
|
8488
|
+
ctx
|
|
8489
|
+
});
|
|
8490
|
+
walkBlocks(block.blocks, layer, depth + 1, ctx);
|
|
7027
8491
|
return;
|
|
7028
8492
|
}
|
|
7029
8493
|
case 'object':
|
|
7030
8494
|
{
|
|
7031
8495
|
const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
|
|
7032
8496
|
if (!name) {
|
|
7033
|
-
mergeFieldsIntoLayer(layer, block.list
|
|
7034
|
-
|
|
8497
|
+
mergeFieldsIntoLayer(layer, block.list, {
|
|
8498
|
+
ctx
|
|
8499
|
+
});
|
|
8500
|
+
walkBlocks(block.blocks, layer, depth + 1, ctx);
|
|
7035
8501
|
return;
|
|
7036
8502
|
}
|
|
7037
8503
|
const nested = createObjectLayer();
|
|
7038
|
-
mergeFieldsIntoLayer(nested, block.list
|
|
7039
|
-
|
|
8504
|
+
mergeFieldsIntoLayer(nested, block.list, {
|
|
8505
|
+
ctx
|
|
8506
|
+
});
|
|
8507
|
+
walkBlocks(block.blocks, nested, depth + 1, ctx);
|
|
7040
8508
|
layer.properties[name] = finalizeObjectSchema(nested, {
|
|
7041
8509
|
title: block.title || undefined,
|
|
7042
8510
|
description: block.subtitle || undefined
|
|
@@ -7099,14 +8567,16 @@ const walkBlock = (block, layer, depth = 0) => {
|
|
|
7099
8567
|
case 'steps':
|
|
7100
8568
|
{
|
|
7101
8569
|
(block.items || []).forEach(step => {
|
|
7102
|
-
mergeFieldsIntoLayer(layer, step == null ? void 0 : step.list
|
|
7103
|
-
|
|
8570
|
+
mergeFieldsIntoLayer(layer, step == null ? void 0 : step.list, {
|
|
8571
|
+
ctx
|
|
8572
|
+
});
|
|
8573
|
+
walkBlocks(step == null ? void 0 : step.blocks, layer, depth + 1, ctx);
|
|
7104
8574
|
});
|
|
7105
8575
|
return;
|
|
7106
8576
|
}
|
|
7107
8577
|
case 'choice':
|
|
7108
8578
|
{
|
|
7109
|
-
mergeChoiceIntoLayer(layer, block, depth);
|
|
8579
|
+
mergeChoiceIntoLayer(layer, block, depth, ctx);
|
|
7110
8580
|
return;
|
|
7111
8581
|
}
|
|
7112
8582
|
default:
|
|
@@ -7119,7 +8589,7 @@ const walkBlock = (block, layer, depth = 0) => {
|
|
|
7119
8589
|
* 每支为 object:单选支含 selector const;多选支为该 option 字段,selector 数组放在当前层。
|
|
7120
8590
|
* 支内 REQ 可进 required;hidden 字段仍进入 schema。
|
|
7121
8591
|
*/
|
|
7122
|
-
const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
8592
|
+
const mergeChoiceIntoLayer = (layer, block, depth, ctx) => {
|
|
7123
8593
|
const mode = block.mode === 'multiple' ? 'multiple' : 'single';
|
|
7124
8594
|
const selectorInData = block.selectorInData !== false;
|
|
7125
8595
|
const selectorName = resolveChoiceSelectorName$1(block);
|
|
@@ -7137,9 +8607,10 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
|
7137
8607
|
branch.required.push(selectorName);
|
|
7138
8608
|
}
|
|
7139
8609
|
mergeFieldsIntoLayer(branch, option.list, {
|
|
7140
|
-
allowRequired: true
|
|
8610
|
+
allowRequired: true,
|
|
8611
|
+
ctx
|
|
7141
8612
|
});
|
|
7142
|
-
walkBlocks(option.blocks, branch, depth + 1);
|
|
8613
|
+
walkBlocks(option.blocks, branch, depth + 1, ctx);
|
|
7143
8614
|
return finalizeObjectSchema(branch, {
|
|
7144
8615
|
title: optionTitle
|
|
7145
8616
|
});
|
|
@@ -7215,11 +8686,12 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
|
7215
8686
|
* - 扩展字段:registerField / preset 的 valueSchema;缺省 { type: 'string' }
|
|
7216
8687
|
* - hidden 字段仍进入 data schema(可提交)
|
|
7217
8688
|
* - choice:single → oneOf,multiple → anyOf
|
|
8689
|
+
* - options.locale / options.languages:多语言文案取该语言,取不到按 languages 顺序回退(未传为 zh-CN → en-US)
|
|
7218
8690
|
*/
|
|
7219
8691
|
const schemaToDataSchema = (schema, options = {}) => {
|
|
7220
|
-
const normalized = normalizeSchema(schema || {});
|
|
8692
|
+
const normalized = normalizeSchema(localizeSchema(schema || {}, options.locale, options.languages));
|
|
7221
8693
|
const layer = createObjectLayer();
|
|
7222
|
-
walkBlocks(normalized.blocks, layer, 0);
|
|
8694
|
+
walkBlocks(normalized.blocks, layer, 0, createConditionContext(normalized, options.locale));
|
|
7223
8695
|
const root = finalizeObjectSchema(layer, {
|
|
7224
8696
|
title: normalized.title || undefined,
|
|
7225
8697
|
description: options.description
|
|
@@ -7255,9 +8727,10 @@ const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValu
|
|
|
7255
8727
|
* 改为 label 在上、值在下,避免窄栏(如弹窗双栏预览)被撑乱。
|
|
7256
8728
|
*/
|
|
7257
8729
|
const renderFieldsContent = (fields, data, formatMessage, column, {
|
|
7258
|
-
showIndex: _showIndex = false
|
|
8730
|
+
showIndex: _showIndex = false,
|
|
8731
|
+
isFieldVisible
|
|
7259
8732
|
} = {}) => {
|
|
7260
|
-
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) => {
|
|
7261
8734
|
const baseLabel = field.label || field.name;
|
|
7262
8735
|
const label = _showIndex ? `${index + 1}. ${baseLabel}` : baseLabel;
|
|
7263
8736
|
return {
|
|
@@ -7292,7 +8765,8 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7292
8765
|
const {
|
|
7293
8766
|
formatMessage,
|
|
7294
8767
|
isMobile,
|
|
7295
|
-
depth = 0
|
|
8768
|
+
depth = 0,
|
|
8769
|
+
isFieldVisible
|
|
7296
8770
|
} = ctx;
|
|
7297
8771
|
if (!block || depth > MAX_BLOCK_DEPTH) {
|
|
7298
8772
|
return null;
|
|
@@ -7313,7 +8787,8 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7313
8787
|
{
|
|
7314
8788
|
return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
|
|
7315
8789
|
children: [renderFieldsContent(block.list, data, formatMessage, block.column, {
|
|
7316
|
-
showIndex: !!block.showIndex
|
|
8790
|
+
showIndex: !!block.showIndex,
|
|
8791
|
+
isFieldVisible
|
|
7317
8792
|
}), renderBlockList(block.blocks, data, nextCtx)]
|
|
7318
8793
|
}));
|
|
7319
8794
|
}
|
|
@@ -7322,7 +8797,9 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7322
8797
|
const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
|
|
7323
8798
|
const nestedData = name ? getByPath(data, name) || {} : data;
|
|
7324
8799
|
return /*#__PURE__*/jsxs(InfoPage.Part, _extends({}, partProps, {
|
|
7325
|
-
children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column
|
|
8800
|
+
children: [renderFieldsContent(block.list, nestedData, formatMessage, block.column, {
|
|
8801
|
+
isFieldVisible
|
|
8802
|
+
}), renderBlockList(block.blocks, nestedData, nextCtx)]
|
|
7326
8803
|
}));
|
|
7327
8804
|
}
|
|
7328
8805
|
case 'list':
|
|
@@ -7377,11 +8854,13 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7377
8854
|
}
|
|
7378
8855
|
case 'steps':
|
|
7379
8856
|
{
|
|
7380
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
8857
|
+
return /*#__PURE__*/jsx(Fragment$1, {
|
|
7381
8858
|
children: (block.items || []).map(step => /*#__PURE__*/jsxs(InfoPage.Part, {
|
|
7382
8859
|
title: step.title || undefined,
|
|
7383
8860
|
bordered: bordered,
|
|
7384
|
-
children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2
|
|
8861
|
+
children: [renderFieldsContent(step.list, data, formatMessage, step.column || 2, {
|
|
8862
|
+
isFieldVisible
|
|
8863
|
+
}), renderBlockList(step.blocks, data, nextCtx)]
|
|
7385
8864
|
}, step.id))
|
|
7386
8865
|
}, block.id);
|
|
7387
8866
|
}
|
|
@@ -7396,7 +8875,9 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7396
8875
|
children: visibleOptions.map(option => /*#__PURE__*/jsxs(InfoPage.Part, {
|
|
7397
8876
|
title: option.title || undefined,
|
|
7398
8877
|
bordered: false,
|
|
7399
|
-
children: [renderFieldsContent(option.list, data, formatMessage, block.column
|
|
8878
|
+
children: [renderFieldsContent(option.list, data, formatMessage, block.column, {
|
|
8879
|
+
isFieldVisible
|
|
8880
|
+
}), renderBlockList(option.blocks, data, nextCtx)]
|
|
7400
8881
|
}, option.id))
|
|
7401
8882
|
}));
|
|
7402
8883
|
}
|
|
@@ -7407,17 +8888,24 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7407
8888
|
const SchemaContentInnerView = ({
|
|
7408
8889
|
schema,
|
|
7409
8890
|
data,
|
|
7410
|
-
className
|
|
8891
|
+
className,
|
|
8892
|
+
languages
|
|
7411
8893
|
}) => {
|
|
7412
8894
|
const {
|
|
7413
|
-
formatMessage
|
|
8895
|
+
formatMessage,
|
|
8896
|
+
locale
|
|
7414
8897
|
} = useIntl();
|
|
7415
8898
|
const isMobile = useIsMobile();
|
|
7416
|
-
const normalized = normalizeSchema(schema);
|
|
7417
|
-
const
|
|
8899
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
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, {
|
|
7418
8905
|
formatMessage,
|
|
7419
8906
|
isMobile,
|
|
7420
|
-
depth: 0
|
|
8907
|
+
depth: 0,
|
|
8908
|
+
isFieldVisible
|
|
7421
8909
|
});
|
|
7422
8910
|
if (!children.length) {
|
|
7423
8911
|
return null;
|
|
@@ -7428,7 +8916,7 @@ const SchemaContentInnerView = ({
|
|
|
7428
8916
|
children: children
|
|
7429
8917
|
});
|
|
7430
8918
|
}
|
|
7431
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
8919
|
+
return /*#__PURE__*/jsx(Fragment$1, {
|
|
7432
8920
|
children: children
|
|
7433
8921
|
});
|
|
7434
8922
|
};
|
|
@@ -7437,12 +8925,14 @@ const SchemaContent = withLocale$1(({
|
|
|
7437
8925
|
schema,
|
|
7438
8926
|
data,
|
|
7439
8927
|
className,
|
|
7440
|
-
empty
|
|
8928
|
+
empty,
|
|
8929
|
+
languages
|
|
7441
8930
|
}) => {
|
|
7442
8931
|
const {
|
|
7443
|
-
formatMessage
|
|
8932
|
+
formatMessage,
|
|
8933
|
+
locale
|
|
7444
8934
|
} = useIntl();
|
|
7445
|
-
const normalized = normalizeSchema(schema);
|
|
8935
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
7446
8936
|
const emptyNode = empty !== undefined ? empty : /*#__PURE__*/jsx(Empty, {
|
|
7447
8937
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
7448
8938
|
description: formatMessage({
|
|
@@ -7462,5 +8952,5 @@ const SchemaContent = withLocale$1(({
|
|
|
7462
8952
|
});
|
|
7463
8953
|
var SchemaContent$1 = SchemaContent;
|
|
7464
8954
|
|
|
7465
|
-
export { FormCreator$1 as FormCreator, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaContent$1 as SchemaContent, SchemaContentInner, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectBlockFieldNames, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, findBlockInTree, formValuesToBlock, formValuesToField, formatByValueSchema, formatFieldDisplayValue, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasRenderableContent, isFieldNameUnique, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, registerField, removeBlockInTree, resolveFieldTypeLabel, resolveFieldValueSchema, 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 };
|
|
7466
8956
|
//# sourceMappingURL=index.modern.js.map
|