@kne/form-creator 0.1.22 → 0.1.24
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 +79 -20
- package/dist/index.css +36 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +1028 -850
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +622 -267
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +20 -1
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +20 -1
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +20 -1
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +20 -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, createElement, Fragment } from 'react';
|
|
5
|
-
import { Space, Tag, Button, Typography, Flex, Dropdown, Empty, message, Checkbox as Checkbox$1,
|
|
4
|
+
import { createContext, useContext, useState, useRef, useMemo, useEffect, useCallback, createElement, Fragment } from 'react';
|
|
5
|
+
import { Input as Input$1, Space, Tag, Button, Typography, Flex, Dropdown, Empty, message, Checkbox as Checkbox$1, InputNumber as InputNumber$1, Card, Tooltip } from 'antd';
|
|
6
6
|
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
7
7
|
import { useIsMobile, RESPONSIVE_BOUNDARY_CLASS } from '@kne/responsive-utils';
|
|
8
8
|
import { ArrowUpOutlined, ArrowDownOutlined, EditOutlined, DeleteOutlined, PlusOutlined, SettingOutlined, FormOutlined, UnorderedListOutlined, TableOutlined, ProfileOutlined, ClusterOutlined, PartitionOutlined, AppstoreOutlined, OrderedListOutlined, SelectOutlined, ApartmentOutlined, ArrowLeftOutlined, ArrowRightOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
|
9
|
-
import { hooks, Input, TextArea, InputNumber, Select, RadioGroup, CheckboxGroup, Switch, Checkbox, DatePicker, useFormContext, Slider, SubmitButton, ResetButton, CancelButton,
|
|
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 {
|
|
14
|
+
import { jsx, jsxs } 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-header-actions":"kne-form-creator_Ue-nT","block-body":"kne-form-creator_je1H0","item-blocks-section":"kne-form-creator_wq4bT","nested-block-list":"kne-form-creator_4NWH4","block-section-nested":"kne-form-creator_mUKom","add-field-dropdown":"kne-form-creator_9JS0d","add-field-dropdown-item":"kne-form-creator_Ql1z3","add-field-dropdown-item-icon":"kne-form-creator_ZHB5O","add-field-dropdown-item-desc":"kne-form-creator_dcsOS","add-field-dropdown-divider":"kne-form-creator_CUK0H","add-field-dropdown-label":"kne-form-creator_bPJ-2","section-toolbar":"kne-form-creator_LUO8S","section-toolbar-label":"kne-form-creator_7KQ79","field-list":"kne-form-creator_-B7WZ","step-list":"kne-form-creator_kc1pH","step-section-header":"kne-form-creator_wkhEX","step-section-title":"kne-form-creator_NBinE","step-section-actions":"kne-form-creator_es-FC","step-index":"kne-form-creator_CCKZZ","field-row":"kne-form-creator_XMkdt","field-row-index":"kne-form-creator_a-cDo","field-row-main":"kne-form-creator_ftlwp","inline-empty":"kne-form-creator_yP-RF","action-group":"kne-form-creator_773yo","hover-reveal":"kne-form-creator_S234h","hover-reveal-active":"kne-form-creator_AE-6r","action-btn":"kne-form-creator_mLgqh","add-block-dropdown":"kne-form-creator_vmS-e","add-block-option":"kne-form-creator_gjg2Y","add-block-option-icon":"kne-form-creator_qh1hh","add-block-option-text":"kne-form-creator_G8iJO","add-block-option-title":"kne-form-creator_ETSvm","add-block-option-desc":"kne-form-creator_O0C3l","field-empty":"kne-form-creator_Nmpfl","field-label-tips-icon":"kne-form-creator_0VVaO","preview-header":"kne-form-creator_c4BT0","preview-title":"kne-form-creator_fPkK4","preview-body":"kne-form-creator_6JntQ","schema-form":"kne-form-creator_MxCWP","schema-body":"kne-form-creator_q9ydz","schema-actions":"kne-form-creator_Y4eEH","schema-actions-inner":"kne-form-creator_FT9Zf","choice-block":"kne-form-creator_RllJe","choice-selector":"kne-form-creator_5A1eM","choice-panels":"kne-form-creator_IO0MY","choice-panels-empty":"kne-form-creator_T0nND","choice-option-panel":"kne-form-creator_FQixN","choice-option-panel-title":"kne-form-creator_ofRo2","choice-option-summary":"kne-form-creator_pksH8","field-editor-form":"kne-form-creator_PGPHL","form-actions-editor":"kne-form-creator_fchMy","form-actions-switch-field":"kne-form-creator_6JE9x","form-actions-layout-panel":"kne-form-creator_rtm9D","form-actions-align-group":"kne-form-creator_51ZsV","form-actions-layout-title":"kne-form-creator_hFeiC","form-actions-gap-slider":"kne-form-creator_Gq0bk","editor-section":"kne-form-creator_jJy85","section-divider":"kne-form-creator_zA7L-","rule-editor":"kne-form-creator_bAlGU","options-editor":"kne-form-creator_AK4yO","super-select-props":"kne-form-creator_Iawhh","field-props-editor":"kne-form-creator_Gabf2","columns-editor":"kne-form-creator_DQW1N","prop-row":"kne-form-creator_7K54P","prop-label":"kne-form-creator_HAAyH","options-item":"kne-form-creator_dnOd2","table-row-card":"kne-form-creator_cwCYp","tree-options-editor":"kne-form-creator_s3nHO","tree-options-list":"kne-form-creator_Djs-E","tree-option-node":"kne-form-creator_XAcut","tree-option-row":"kne-form-creator_4K4Rj","tree-option-fields":"kne-form-creator_-4cjc","tree-option-actions":"kne-form-creator_IjCNI","tree-option-children":"kne-form-creator_pVPGJ","tree-add-sibling":"kne-form-creator_bl46P","rule-checkbox-group":"kne-form-creator_tDgVP","rule-len-row":"kne-form-creator_ATsae","rule-len-input":"kne-form-creator_jY4Ld","rule-len-sep":"kne-form-creator_jBDC8","options-list":"kne-form-creator_GUBNS","options-row":"kne-form-creator_uohD0","options-tip":"kne-form-creator_vrTmK","icon-square-btn":"kne-form-creator_DZjCf","icon-square-btn-sm":"kne-form-creator_GAh-t","locale-text":"kne-form-creator_hMXkE","is-compact":"kne-form-creator_jBFpL","locale-text-item":"kne-form-creator_NqCQD","locale-text-prefix":"kne-form-creator_BQl2X","options-locale-text":"kne-form-creator_7-99l","locale-text-tag":"kne-form-creator_65OWA","is-mobile":"kne-form-creator_LtgJz"};
|
|
21
21
|
|
|
22
22
|
function _extends() {
|
|
23
23
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
@@ -68,6 +68,14 @@ const locale$1 = {
|
|
|
68
68
|
blockKind_object: '分组信息',
|
|
69
69
|
blockKind_choice: '选项切换',
|
|
70
70
|
blockKind_steps: '分步表单',
|
|
71
|
+
blockKindDesc_formInfo: '最常用的表单模块,可设置标题、列数和间距',
|
|
72
|
+
blockKindDesc_list: '用户可以动态添加或删除多条记录,例如工作经历',
|
|
73
|
+
blockKindDesc_tableList: '以表格形式展示的可增减列表',
|
|
74
|
+
blockKindDesc_editableList: '每条记录只读展示,点击编辑后单独填写并保存;数据量大时不卡顿',
|
|
75
|
+
blockKindDesc_multiField: '同一种填写项可以输入多个值,例如多个手机号',
|
|
76
|
+
blockKindDesc_object: '把相关的填写项放在一起,例如「在校时间」下的开始与结束',
|
|
77
|
+
blockKindDesc_choice: '先选一类情况,再填写对应内容;可设为单选或多选',
|
|
78
|
+
blockKindDesc_steps: '将表单拆分成多个步骤,引导用户逐步填写',
|
|
71
79
|
choiceMode: '可选几个',
|
|
72
80
|
choiceModeSingle: '只能选一个',
|
|
73
81
|
choiceModeMultiple: '可以选多个',
|
|
@@ -150,6 +158,7 @@ const locale$1 = {
|
|
|
150
158
|
FieldTypeSwitch: '开关',
|
|
151
159
|
FieldTypeCheckbox: '复选框',
|
|
152
160
|
FieldTypeDatePicker: '日期',
|
|
161
|
+
extendedFieldPlaceholder: '请选择{label}',
|
|
153
162
|
fieldName: '保存用的名称',
|
|
154
163
|
fieldNamePlaceholder: '已自动生成,可修改',
|
|
155
164
|
fieldLabel: '显示名称',
|
|
@@ -244,12 +253,16 @@ const locale$1 = {
|
|
|
244
253
|
propDatePickerQuarter: '季度',
|
|
245
254
|
propDatePickerYear: '年份',
|
|
246
255
|
propDateFormat: '显示格式',
|
|
256
|
+
propDateFormatLocalized: 'YYYY年MM月DD日',
|
|
247
257
|
propShowTime: '同时选择时间',
|
|
248
258
|
propSwitchOnText: '打开时显示的文字',
|
|
249
259
|
propSwitchOffText: '关闭时显示的文字',
|
|
250
260
|
propSwitchOnTextHint: '例如:开',
|
|
251
261
|
propSwitchOffTextHint: '例如:关',
|
|
252
262
|
propOptionsInline: '选项横向排列',
|
|
263
|
+
rulePresetREQ: '必填',
|
|
264
|
+
rulePresetTEL: '手机号格式',
|
|
265
|
+
rulePresetEMAIL: '邮箱格式',
|
|
253
266
|
ruleLen: '长度限制',
|
|
254
267
|
ruleLenRange: '长度范围',
|
|
255
268
|
ruleLenMin: '最少字数',
|
|
@@ -265,9 +278,15 @@ const locale$1 = {
|
|
|
265
278
|
schemaContentNo: '否',
|
|
266
279
|
schemaContentItemIndex: '第 {index} 项',
|
|
267
280
|
schemaContentUntilToday: '至今',
|
|
268
|
-
schemaContentPasswordMasked: '••••••'
|
|
269
|
-
|
|
270
|
-
|
|
281
|
+
schemaContentPasswordMasked: '••••••',
|
|
282
|
+
ruleErrorTEL: '请输入有效的手机号',
|
|
283
|
+
ruleErrorEMAIL: '请输入有效的邮箱',
|
|
284
|
+
ruleErrorLenEqual: '%s长度必须等于{end}',
|
|
285
|
+
ruleErrorLenMin: '%s长度必须大于{start}',
|
|
286
|
+
ruleErrorLenMax: '%s长度必须小于{end}',
|
|
287
|
+
localeTextFallback: '留空时使用{language}'
|
|
288
|
+
};
|
|
289
|
+
var defaultLocale = locale$1;
|
|
271
290
|
|
|
272
291
|
const locale = {
|
|
273
292
|
addField: 'Add Field',
|
|
@@ -299,6 +318,14 @@ const locale = {
|
|
|
299
318
|
blockKind_object: 'Grouped Fields',
|
|
300
319
|
blockKind_choice: 'Options',
|
|
301
320
|
blockKind_steps: 'Step-by-Step',
|
|
321
|
+
blockKindDesc_formInfo: 'The most common section; set its title, columns and spacing',
|
|
322
|
+
blockKindDesc_list: 'Users can add or remove multiple records, e.g. work experience',
|
|
323
|
+
blockKindDesc_tableList: 'A repeatable list displayed as a table',
|
|
324
|
+
blockKindDesc_editableList: 'Records are shown read-only; click edit to fill in and save each one. Stays fast with lots of data',
|
|
325
|
+
blockKindDesc_multiField: 'Enter multiple values for the same field, e.g. several phone numbers',
|
|
326
|
+
blockKindDesc_object: 'Group related fields together, e.g. start and end under "School period"',
|
|
327
|
+
blockKindDesc_choice: 'Pick a case first, then fill in the matching content; single or multiple selection',
|
|
328
|
+
blockKindDesc_steps: 'Split the form into steps to guide users through it',
|
|
302
329
|
choiceMode: 'How many can be selected',
|
|
303
330
|
choiceModeSingle: 'One only',
|
|
304
331
|
choiceModeMultiple: 'More than one',
|
|
@@ -381,6 +408,7 @@ const locale = {
|
|
|
381
408
|
FieldTypeSwitch: 'Switch',
|
|
382
409
|
FieldTypeCheckbox: 'Checkbox',
|
|
383
410
|
FieldTypeDatePicker: 'Date',
|
|
411
|
+
extendedFieldPlaceholder: 'Please select {label}',
|
|
384
412
|
fieldName: 'Save name',
|
|
385
413
|
fieldNamePlaceholder: 'Auto-generated, editable',
|
|
386
414
|
fieldLabel: 'Display Name',
|
|
@@ -475,12 +503,16 @@ const locale = {
|
|
|
475
503
|
propDatePickerQuarter: 'Quarter',
|
|
476
504
|
propDatePickerYear: 'Year',
|
|
477
505
|
propDateFormat: 'Display format',
|
|
506
|
+
propDateFormatLocalized: 'MMM D, YYYY',
|
|
478
507
|
propShowTime: 'Include time',
|
|
479
508
|
propSwitchOnText: 'Text when on',
|
|
480
509
|
propSwitchOffText: 'Text when off',
|
|
481
510
|
propSwitchOnTextHint: 'e.g. On',
|
|
482
511
|
propSwitchOffTextHint: 'e.g. Off',
|
|
483
512
|
propOptionsInline: 'Arrange options horizontally',
|
|
513
|
+
rulePresetREQ: 'Required',
|
|
514
|
+
rulePresetTEL: 'Phone number format',
|
|
515
|
+
rulePresetEMAIL: 'Email format',
|
|
484
516
|
ruleLen: 'Length Limit',
|
|
485
517
|
ruleLenRange: 'Length Range',
|
|
486
518
|
ruleLenMin: 'Min',
|
|
@@ -496,20 +528,133 @@ const locale = {
|
|
|
496
528
|
schemaContentNo: 'No',
|
|
497
529
|
schemaContentItemIndex: 'Item {index}',
|
|
498
530
|
schemaContentUntilToday: 'Present',
|
|
499
|
-
schemaContentPasswordMasked: '••••••'
|
|
531
|
+
schemaContentPasswordMasked: '••••••',
|
|
532
|
+
ruleErrorTEL: 'Please enter a valid mobile number',
|
|
533
|
+
ruleErrorEMAIL: 'Please enter a valid email address',
|
|
534
|
+
ruleErrorLenEqual: '%s must be exactly {end} characters',
|
|
535
|
+
ruleErrorLenMin: '%s must be at least {start} characters',
|
|
536
|
+
ruleErrorLenMax: '%s must be at most {end} characters',
|
|
537
|
+
localeTextFallback: 'Falls back to {language} when empty'
|
|
500
538
|
};
|
|
501
539
|
var enUS = locale;
|
|
502
540
|
|
|
503
541
|
const withLocale = createWithIntlProvider({
|
|
504
542
|
defaultLocale: 'zh-CN',
|
|
505
543
|
messages: {
|
|
506
|
-
'zh-CN':
|
|
544
|
+
'zh-CN': defaultLocale,
|
|
507
545
|
'en-US': enUS
|
|
508
546
|
},
|
|
509
547
|
namespace: 'form-creator'
|
|
510
548
|
});
|
|
511
549
|
var withLocale$1 = withLocale;
|
|
512
550
|
|
|
551
|
+
/** 未传 languages 时,多语言文案按此顺序回退 */
|
|
552
|
+
const DEFAULT_FALLBACK_LANGUAGES = ['zh-CN', 'en-US'];
|
|
553
|
+
const LOCALE_KEY = /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/;
|
|
554
|
+
const isPlainObject = value => {
|
|
555
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
const proto = Object.getPrototypeOf(value);
|
|
559
|
+
return proto === Object.prototype || proto === null;
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
/** 多语言文案:键全为语言代码、值全为字符串,如 { 'zh-CN': '姓名', 'en-US': 'Name' } */
|
|
563
|
+
const isLocaleText = value => {
|
|
564
|
+
if (!isPlainObject(value)) {
|
|
565
|
+
return false;
|
|
566
|
+
}
|
|
567
|
+
const keys = Object.keys(value);
|
|
568
|
+
return keys.length > 0 && keys.every(key => LOCALE_KEY.test(key) && (value[key] == null || typeof value[key] === 'string'));
|
|
569
|
+
};
|
|
570
|
+
const hasText = value => typeof value === 'string' && value.trim() !== '';
|
|
571
|
+
|
|
572
|
+
/** 规范调用方传入的语言列表 [{ value, label }],丢弃无 value 的项 */
|
|
573
|
+
const normalizeLanguages = languages => (Array.isArray(languages) ? languages : []).filter(item => item && typeof item.value === 'string' && item.value).map(item => ({
|
|
574
|
+
value: item.value,
|
|
575
|
+
label: item.label || item.value
|
|
576
|
+
}));
|
|
577
|
+
const getFallbackLanguages = languages => {
|
|
578
|
+
const list = normalizeLanguages(languages);
|
|
579
|
+
return list.length ? list.map(item => item.value) : DEFAULT_FALLBACK_LANGUAGES;
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
/** 普通字符串原样返回;多语言按 locale → languages 顺序(未传为 zh-CN → en-US)取第一个有内容的 */
|
|
583
|
+
const resolveLocaleText = (value, locale, languages) => {
|
|
584
|
+
if (!isLocaleText(value)) {
|
|
585
|
+
return value;
|
|
586
|
+
}
|
|
587
|
+
const language = [locale, ...getFallbackLanguages(languages)].find(key => key && hasText(value[key]));
|
|
588
|
+
return language ? value[language] : '';
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
/** 深度解析 schema(或任意片段)中的多语言文案,返回新对象 */
|
|
592
|
+
const localizeSchema = (value, locale, languages) => {
|
|
593
|
+
if (Array.isArray(value)) {
|
|
594
|
+
return value.map(item => localizeSchema(item, locale, languages));
|
|
595
|
+
}
|
|
596
|
+
if (isLocaleText(value)) {
|
|
597
|
+
return resolveLocaleText(value, locale, languages);
|
|
598
|
+
}
|
|
599
|
+
if (!isPlainObject(value)) {
|
|
600
|
+
return value;
|
|
601
|
+
}
|
|
602
|
+
return Object.keys(value).reduce((result, key) => {
|
|
603
|
+
result[key] = localizeSchema(value[key], locale, languages);
|
|
604
|
+
return result;
|
|
605
|
+
}, {});
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
/** 取某个语言的原始输入值;普通字符串视为基础语言 */
|
|
609
|
+
const getLocaleTextValue = (value, language, baseLanguage) => {
|
|
610
|
+
if (isLocaleText(value)) {
|
|
611
|
+
return value[language] || '';
|
|
612
|
+
}
|
|
613
|
+
if (value == null || typeof value === 'object') {
|
|
614
|
+
return '';
|
|
615
|
+
}
|
|
616
|
+
return language === baseLanguage ? String(value) : '';
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
/** 只有基础语言时存为字符串,保持与单语言 schema 兼容 */
|
|
620
|
+
const toLocaleText = (map = {}, baseLanguage) => {
|
|
621
|
+
const entries = Object.keys(map).filter(key => hasText(map[key])).map(key => [key, map[key]]);
|
|
622
|
+
if (!entries.length) {
|
|
623
|
+
return '';
|
|
624
|
+
}
|
|
625
|
+
if (entries.length === 1 && entries[0][0] === baseLanguage) {
|
|
626
|
+
return entries[0][1];
|
|
627
|
+
}
|
|
628
|
+
return Object.fromEntries(entries);
|
|
629
|
+
};
|
|
630
|
+
const setLocaleTextValue = (value, language, text, baseLanguage) => {
|
|
631
|
+
const map = isLocaleText(value) ? _extends({}, value) : {
|
|
632
|
+
[baseLanguage]: getLocaleTextValue(value, baseLanguage, baseLanguage)
|
|
633
|
+
};
|
|
634
|
+
map[language] = text;
|
|
635
|
+
return toLocaleText(map, baseLanguage);
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
/** 判断文案(字符串或多语言)是否有内容 */
|
|
639
|
+
const hasLocaleText = value => isLocaleText(value) ? Object.values(value).some(hasText) : value != null && String(value).trim() !== '';
|
|
640
|
+
|
|
641
|
+
/** 去除首尾空白;多语言文案逐项处理 */
|
|
642
|
+
const trimLocaleText = (value, baseLanguage) => {
|
|
643
|
+
if (isLocaleText(value)) {
|
|
644
|
+
return toLocaleText(Object.fromEntries(Object.keys(value).map(key => [key, (value[key] || '').trim()])), baseLanguage);
|
|
645
|
+
}
|
|
646
|
+
return String(value != null ? value : '').trim();
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
/** 由文案派生数据值时用基础语言,保证各语言下值一致;基础语言为空时取第一个有内容的语言 */
|
|
650
|
+
const localeTextToValue = (value, baseLanguage) => {
|
|
651
|
+
if (!isLocaleText(value)) {
|
|
652
|
+
return String(value != null ? value : '').trim();
|
|
653
|
+
}
|
|
654
|
+
const text = resolveLocaleText(value, baseLanguage) || Object.values(value).find(hasText) || '';
|
|
655
|
+
return String(text).trim();
|
|
656
|
+
};
|
|
657
|
+
|
|
513
658
|
const createFieldId = () => `field_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
514
659
|
|
|
515
660
|
/** 生成可编辑的默认数据标识,如 field_xxxx / col_xxxx */
|
|
@@ -546,6 +691,7 @@ const defaultFormActions = () => ({
|
|
|
546
691
|
gap: 16
|
|
547
692
|
});
|
|
548
693
|
const FORM_ACTIONS_ALIGN = ['center', 'start', 'end'];
|
|
694
|
+
const normalizeActionText = value => value == null ? '' : isLocaleText(value) ? _extends({}, value) : String(value);
|
|
549
695
|
const normalizeFormActions = (actions = {}) => {
|
|
550
696
|
const base = defaultFormActions();
|
|
551
697
|
if (!actions || typeof actions !== 'object') {
|
|
@@ -558,9 +704,9 @@ const normalizeFormActions = (actions = {}) => {
|
|
|
558
704
|
showSubmit: actions.showSubmit !== false,
|
|
559
705
|
showReset: actions.showReset !== false,
|
|
560
706
|
showCancel: !!actions.showCancel,
|
|
561
|
-
submitText:
|
|
562
|
-
resetText:
|
|
563
|
-
cancelText:
|
|
707
|
+
submitText: normalizeActionText(actions.submitText),
|
|
708
|
+
resetText: normalizeActionText(actions.resetText),
|
|
709
|
+
cancelText: normalizeActionText(actions.cancelText),
|
|
564
710
|
align,
|
|
565
711
|
gap
|
|
566
712
|
}, actions.submitButtonProps && typeof actions.submitButtonProps === 'object' ? {
|
|
@@ -643,17 +789,13 @@ const createBlock = (kind, overrides = {}) => {
|
|
|
643
789
|
blocks: undefined,
|
|
644
790
|
items: undefined,
|
|
645
791
|
name: '',
|
|
646
|
-
options: [createChoiceOption(
|
|
647
|
-
title: '选项1'
|
|
648
|
-
})]
|
|
792
|
+
options: [createChoiceOption()]
|
|
649
793
|
}, overrides, {
|
|
650
794
|
kind: 'choice'
|
|
651
795
|
});
|
|
652
796
|
next.mode = next.mode === 'multiple' ? 'multiple' : 'single';
|
|
653
797
|
if (!Array.isArray(next.options)) {
|
|
654
|
-
next.options = [createChoiceOption(
|
|
655
|
-
title: '选项1'
|
|
656
|
-
})];
|
|
798
|
+
next.options = [createChoiceOption()];
|
|
657
799
|
}
|
|
658
800
|
return next;
|
|
659
801
|
}
|
|
@@ -1178,63 +1320,65 @@ const hasRenderableContent = schema => {
|
|
|
1178
1320
|
|
|
1179
1321
|
const BLOCK_KINDS = {
|
|
1180
1322
|
formInfo: {
|
|
1181
|
-
|
|
1323
|
+
labelId: 'blockKind_formInfo',
|
|
1182
1324
|
color: 'blue',
|
|
1183
1325
|
hasFieldList: true,
|
|
1184
|
-
|
|
1326
|
+
descriptionId: 'blockKindDesc_formInfo'
|
|
1185
1327
|
},
|
|
1186
1328
|
list: {
|
|
1187
|
-
|
|
1329
|
+
labelId: 'blockKind_list',
|
|
1188
1330
|
color: 'cyan',
|
|
1189
1331
|
hasFieldList: true,
|
|
1190
1332
|
requiresName: true,
|
|
1191
|
-
|
|
1333
|
+
descriptionId: 'blockKindDesc_list'
|
|
1192
1334
|
},
|
|
1193
1335
|
tableList: {
|
|
1194
|
-
|
|
1336
|
+
labelId: 'blockKind_tableList',
|
|
1195
1337
|
color: 'geekblue',
|
|
1196
1338
|
hasFieldList: true,
|
|
1197
1339
|
requiresName: true,
|
|
1198
|
-
|
|
1340
|
+
descriptionId: 'blockKindDesc_tableList'
|
|
1199
1341
|
},
|
|
1200
1342
|
editableList: {
|
|
1201
|
-
|
|
1343
|
+
labelId: 'blockKind_editableList',
|
|
1202
1344
|
color: 'green',
|
|
1203
1345
|
hasFieldList: true,
|
|
1204
1346
|
requiresName: true,
|
|
1205
|
-
|
|
1347
|
+
descriptionId: 'blockKindDesc_editableList'
|
|
1206
1348
|
},
|
|
1207
1349
|
multiField: {
|
|
1208
|
-
|
|
1350
|
+
labelId: 'blockKind_multiField',
|
|
1209
1351
|
color: 'purple',
|
|
1210
1352
|
requiresName: true,
|
|
1211
|
-
|
|
1353
|
+
descriptionId: 'blockKindDesc_multiField'
|
|
1212
1354
|
},
|
|
1213
1355
|
object: {
|
|
1214
|
-
|
|
1356
|
+
labelId: 'blockKind_object',
|
|
1215
1357
|
color: 'orange',
|
|
1216
1358
|
hasFieldList: true,
|
|
1217
1359
|
requiresName: true,
|
|
1218
|
-
|
|
1360
|
+
descriptionId: 'blockKindDesc_object'
|
|
1219
1361
|
},
|
|
1220
1362
|
choice: {
|
|
1221
|
-
|
|
1363
|
+
labelId: 'blockKind_choice',
|
|
1222
1364
|
color: 'magenta',
|
|
1223
1365
|
hasChoiceOptions: true,
|
|
1224
|
-
|
|
1366
|
+
descriptionId: 'blockKindDesc_choice'
|
|
1225
1367
|
},
|
|
1226
1368
|
steps: {
|
|
1227
|
-
|
|
1369
|
+
labelId: 'blockKind_steps',
|
|
1228
1370
|
color: 'gold',
|
|
1229
1371
|
hasSteps: true,
|
|
1230
|
-
|
|
1372
|
+
descriptionId: 'blockKindDesc_steps'
|
|
1231
1373
|
}
|
|
1232
1374
|
};
|
|
1233
1375
|
|
|
1234
1376
|
/** editableList 添加按钮位置,与 @kne/form-info EditableList addPosition 一致 */
|
|
1235
1377
|
const ADD_POSITIONS = ['bottom', 'top', 'both'];
|
|
1236
|
-
const getBlockKindOptions =
|
|
1237
|
-
label:
|
|
1378
|
+
const getBlockKindOptions = formatMessage => Object.entries(BLOCK_KINDS).map(([value, config]) => ({
|
|
1379
|
+
label: typeof formatMessage === 'function' ? formatMessage({
|
|
1380
|
+
id: config.labelId
|
|
1381
|
+
}) : config.labelId,
|
|
1238
1382
|
value
|
|
1239
1383
|
}));
|
|
1240
1384
|
const getBlockDefinition = kind => BLOCK_KINDS[kind];
|
|
@@ -1412,15 +1556,18 @@ const createApiFromOptions = (options = []) => ({
|
|
|
1412
1556
|
|
|
1413
1557
|
const _excluded$3 = ["options", "api", "placeholder"];
|
|
1414
1558
|
const {
|
|
1415
|
-
useOnChange: useOnChange$
|
|
1559
|
+
useOnChange: useOnChange$2
|
|
1416
1560
|
} = hooks;
|
|
1417
1561
|
const hasNestedOptions = options => Array.isArray(options) && options.some(item => Array.isArray(item == null ? void 0 : item.children) && item.children.length);
|
|
1418
1562
|
const createField = (Component, {
|
|
1419
1563
|
preferOptions: _preferOptions = false,
|
|
1420
|
-
flattenTree: _flattenTree = false
|
|
1421
|
-
placeholderPrefix: _placeholderPrefix = '请选择'
|
|
1564
|
+
flattenTree: _flattenTree = false
|
|
1422
1565
|
} = {}) => {
|
|
1423
|
-
const
|
|
1566
|
+
const FieldInner = props => {
|
|
1567
|
+
const {
|
|
1568
|
+
formatMessage,
|
|
1569
|
+
locale
|
|
1570
|
+
} = useIntl();
|
|
1424
1571
|
const {
|
|
1425
1572
|
options,
|
|
1426
1573
|
api,
|
|
@@ -1440,11 +1587,16 @@ const createField = (Component, {
|
|
|
1440
1587
|
}) : flattened;
|
|
1441
1588
|
const useOptionsDirectly = _preferOptions || hasNestedOptions(resolvedOptions);
|
|
1442
1589
|
const mergedApi = api || (!useOptionsDirectly && Array.isArray(resolvedOptions) && resolvedOptions.length ? createApiFromOptions(resolvedOptions) : undefined);
|
|
1443
|
-
const resolvedPlaceholder = placeholder != null && String(placeholder).trim() ? placeholder :
|
|
1444
|
-
|
|
1590
|
+
const resolvedPlaceholder = placeholder != null && String(placeholder).trim() ? placeholder : formatMessage({
|
|
1591
|
+
id: 'extendedFieldPlaceholder'
|
|
1592
|
+
}, {
|
|
1593
|
+
label: props.label || ''
|
|
1594
|
+
}).trim();
|
|
1595
|
+
const render = useOnChange$2(Object.assign({}, {
|
|
1445
1596
|
isPopup: true,
|
|
1446
1597
|
placeholder: resolvedPlaceholder
|
|
1447
1598
|
}, rest, {
|
|
1599
|
+
locale,
|
|
1448
1600
|
valueKey,
|
|
1449
1601
|
labelKey
|
|
1450
1602
|
}, useOptionsDirectly && Array.isArray(resolvedOptions) ? {
|
|
@@ -1454,6 +1606,7 @@ const createField = (Component, {
|
|
|
1454
1606
|
} : {}));
|
|
1455
1607
|
return render(Component);
|
|
1456
1608
|
};
|
|
1609
|
+
const Field = withLocale$1(FieldInner);
|
|
1457
1610
|
Field.field = Component;
|
|
1458
1611
|
return Field;
|
|
1459
1612
|
};
|
|
@@ -1474,13 +1627,13 @@ const SelectAddressField = createField(SelectAddress);
|
|
|
1474
1627
|
|
|
1475
1628
|
const RULE_PRESET_ITEMS = [{
|
|
1476
1629
|
value: 'REQ',
|
|
1477
|
-
|
|
1630
|
+
labelId: 'rulePresetREQ'
|
|
1478
1631
|
}, {
|
|
1479
1632
|
value: 'TEL',
|
|
1480
|
-
|
|
1633
|
+
labelId: 'rulePresetTEL'
|
|
1481
1634
|
}, {
|
|
1482
1635
|
value: 'EMAIL',
|
|
1483
|
-
|
|
1636
|
+
labelId: 'rulePresetEMAIL'
|
|
1484
1637
|
}];
|
|
1485
1638
|
const DEFAULT_RULE_CONFIG = () => ({
|
|
1486
1639
|
presets: [],
|
|
@@ -1966,8 +2119,10 @@ const resolveFieldValueSchema = field => {
|
|
|
1966
2119
|
} else {
|
|
1967
2120
|
schema = _extends({}, schema);
|
|
1968
2121
|
}
|
|
1969
|
-
const
|
|
1970
|
-
const
|
|
2122
|
+
const label = resolveLocaleText(field.label);
|
|
2123
|
+
const fieldDescription = resolveLocaleText(field.description);
|
|
2124
|
+
const title = label != null && String(label).trim() ? String(label).trim() : undefined;
|
|
2125
|
+
const description = fieldDescription != null && String(fieldDescription).trim() ? String(fieldDescription).trim() : undefined;
|
|
1971
2126
|
if (title && schema.title == null) {
|
|
1972
2127
|
schema.title = title;
|
|
1973
2128
|
}
|
|
@@ -2029,7 +2184,7 @@ const getFieldTypes = formatMessage => {
|
|
|
2029
2184
|
});
|
|
2030
2185
|
if (fallback.length) {
|
|
2031
2186
|
grouped.push({
|
|
2032
|
-
label: resolveRegistryLabel(formatMessage, 'FieldGroupExtended'
|
|
2187
|
+
label: resolveRegistryLabel(formatMessage, 'FieldGroupExtended'),
|
|
2033
2188
|
options: fallback
|
|
2034
2189
|
});
|
|
2035
2190
|
}
|
|
@@ -2044,26 +2199,26 @@ const normalizeOptions = (options, {
|
|
|
2044
2199
|
}
|
|
2045
2200
|
const columnNames = (_columns || []).map(item => item == null ? void 0 : item.name).filter(Boolean);
|
|
2046
2201
|
return options.map(item => {
|
|
2047
|
-
var _item$
|
|
2048
|
-
const label =
|
|
2202
|
+
var _item$value;
|
|
2203
|
+
const label = trimLocaleText(item == null ? void 0 : item.label);
|
|
2049
2204
|
let value = String((_item$value = item == null ? void 0 : item.value) != null ? _item$value : '').trim();
|
|
2050
2205
|
if (!value && label) {
|
|
2051
|
-
value = label;
|
|
2206
|
+
value = localeTextToValue(label);
|
|
2052
2207
|
}
|
|
2053
2208
|
const next = {
|
|
2054
2209
|
label,
|
|
2055
2210
|
value,
|
|
2056
|
-
description:
|
|
2211
|
+
description: trimLocaleText(item == null ? void 0 : item.description)
|
|
2057
2212
|
};
|
|
2058
2213
|
columnNames.forEach(name => {
|
|
2059
2214
|
var _item$name;
|
|
2060
2215
|
next[name] = (_item$name = item == null ? void 0 : item[name]) != null ? _item$name : '';
|
|
2061
2216
|
});
|
|
2062
|
-
if (!
|
|
2217
|
+
if (!hasLocaleText(next.label) && columnNames[0] && String(next[columnNames[0]] || '').trim()) {
|
|
2063
2218
|
next.label = String(next[columnNames[0]]).trim();
|
|
2064
2219
|
}
|
|
2065
|
-
if (!String(next.value).trim() &&
|
|
2066
|
-
next.value = next.label;
|
|
2220
|
+
if (!String(next.value).trim() && hasLocaleText(next.label)) {
|
|
2221
|
+
next.value = localeTextToValue(next.label);
|
|
2067
2222
|
}
|
|
2068
2223
|
if (_allowChildren && Array.isArray(item == null ? void 0 : item.children) && item.children.length) {
|
|
2069
2224
|
next.children = normalizeOptions(item.children, {
|
|
@@ -2274,10 +2429,14 @@ const applyFieldProps = (props, values, definition) => {
|
|
|
2274
2429
|
delete props.showTime;
|
|
2275
2430
|
}
|
|
2276
2431
|
if (values.range) {
|
|
2277
|
-
// RangePicker 用数组 placeholder
|
|
2432
|
+
// RangePicker 用数组 placeholder;单框用字符串;未填时交给 RangePicker 按 locale 显示默认提示
|
|
2278
2433
|
const raw = values.placeholder;
|
|
2279
|
-
const text =
|
|
2280
|
-
|
|
2434
|
+
const text = Array.isArray(raw) ? raw[0] : raw;
|
|
2435
|
+
if (text != null && String(text).trim()) {
|
|
2436
|
+
props.placeholder = [text, text];
|
|
2437
|
+
} else {
|
|
2438
|
+
delete props.placeholder;
|
|
2439
|
+
}
|
|
2281
2440
|
} else {
|
|
2282
2441
|
setOptionalString(props, 'placeholder', values.placeholder);
|
|
2283
2442
|
}
|
|
@@ -2370,6 +2529,102 @@ const formValuesToField = (values, existingField = {}) => {
|
|
|
2370
2529
|
};
|
|
2371
2530
|
};
|
|
2372
2531
|
|
|
2532
|
+
const {
|
|
2533
|
+
useOnChange: useOnChange$1
|
|
2534
|
+
} = hooks;
|
|
2535
|
+
const LocaleTextContext = /*#__PURE__*/createContext([]);
|
|
2536
|
+
|
|
2537
|
+
/** 向编辑器内的文案输入下发语言列表 [{ value, label }] */
|
|
2538
|
+
const LocaleTextProvider = ({
|
|
2539
|
+
languages,
|
|
2540
|
+
children
|
|
2541
|
+
}) => /*#__PURE__*/jsx(LocaleTextContext.Provider, {
|
|
2542
|
+
value: normalizeLanguages(languages),
|
|
2543
|
+
children: children
|
|
2544
|
+
});
|
|
2545
|
+
|
|
2546
|
+
/** 当前语言列表:组件 languages 优先,否则取 LocaleTextProvider */
|
|
2547
|
+
const useLocaleTextLanguages = languages => {
|
|
2548
|
+
const contextLanguages = useContext(LocaleTextContext);
|
|
2549
|
+
return languages ? normalizeLanguages(languages) : contextLanguages;
|
|
2550
|
+
};
|
|
2551
|
+
|
|
2552
|
+
/** 文案输入:未配置多语言时为单个输入框;配置后每种语言一个输入框,只填基础语言(首项)时存为字符串 */
|
|
2553
|
+
const LocaleTextControl = ({
|
|
2554
|
+
value,
|
|
2555
|
+
onChange,
|
|
2556
|
+
onBlur,
|
|
2557
|
+
placeholder,
|
|
2558
|
+
multiline: _multiline = false,
|
|
2559
|
+
compact: _compact = false,
|
|
2560
|
+
rows: _rows = 2,
|
|
2561
|
+
disabled,
|
|
2562
|
+
className,
|
|
2563
|
+
languages: languagesProp
|
|
2564
|
+
}) => {
|
|
2565
|
+
const {
|
|
2566
|
+
formatMessage,
|
|
2567
|
+
locale
|
|
2568
|
+
} = useIntl();
|
|
2569
|
+
const languages = useLocaleTextLanguages(languagesProp);
|
|
2570
|
+
const Control = _multiline ? Input$1.TextArea : Input$1;
|
|
2571
|
+
const controlProps = _extends({
|
|
2572
|
+
disabled,
|
|
2573
|
+
onBlur
|
|
2574
|
+
}, _multiline ? {
|
|
2575
|
+
rows: _rows
|
|
2576
|
+
} : {});
|
|
2577
|
+
if (languages.length < 2) {
|
|
2578
|
+
var _languages$;
|
|
2579
|
+
const _baseLanguage = (_languages$ = languages[0]) == null ? void 0 : _languages$.value;
|
|
2580
|
+
const editLanguage = isLocaleText(value) ? _baseLanguage || Object.keys(value).find(key => value[key] === resolveLocaleText(value, locale)) || Object.keys(value)[0] : null;
|
|
2581
|
+
return /*#__PURE__*/jsx(Control, _extends({}, controlProps, {
|
|
2582
|
+
className: className,
|
|
2583
|
+
value: editLanguage ? value[editLanguage] || '' : value != null ? value : '',
|
|
2584
|
+
placeholder: placeholder,
|
|
2585
|
+
onChange: e => onChange == null ? void 0 : onChange(editLanguage ? setLocaleTextValue(value, editLanguage, e.target.value, editLanguage) : e.target.value)
|
|
2586
|
+
}));
|
|
2587
|
+
}
|
|
2588
|
+
const baseLanguage = languages[0];
|
|
2589
|
+
return /*#__PURE__*/jsx("div", {
|
|
2590
|
+
className: [style['locale-text'], _compact ? style['is-compact'] : null, className].filter(Boolean).join(' '),
|
|
2591
|
+
children: languages.map(language => /*#__PURE__*/jsxs("div", {
|
|
2592
|
+
className: style['locale-text-item'],
|
|
2593
|
+
children: [_compact ? null : /*#__PURE__*/jsx("span", {
|
|
2594
|
+
className: style['locale-text-tag'],
|
|
2595
|
+
children: language.label
|
|
2596
|
+
}), /*#__PURE__*/jsx(Control, _extends({}, controlProps, {
|
|
2597
|
+
value: getLocaleTextValue(value, language.value, baseLanguage.value),
|
|
2598
|
+
placeholder: language.value === baseLanguage.value ? placeholder : formatMessage({
|
|
2599
|
+
id: 'localeTextFallback'
|
|
2600
|
+
}, {
|
|
2601
|
+
language: baseLanguage.label
|
|
2602
|
+
})
|
|
2603
|
+
}, _compact && !_multiline ? {
|
|
2604
|
+
prefix: /*#__PURE__*/jsx("span", {
|
|
2605
|
+
className: style['locale-text-prefix'],
|
|
2606
|
+
children: language.label
|
|
2607
|
+
})
|
|
2608
|
+
} : {}, {
|
|
2609
|
+
onChange: e => onChange == null ? void 0 : onChange(setLocaleTextValue(value, language.value, e.target.value, baseLanguage.value))
|
|
2610
|
+
}))]
|
|
2611
|
+
}, language.value))
|
|
2612
|
+
});
|
|
2613
|
+
};
|
|
2614
|
+
const LocaleInput = props => {
|
|
2615
|
+
const render = useOnChange$1(props);
|
|
2616
|
+
return render(LocaleTextControl);
|
|
2617
|
+
};
|
|
2618
|
+
LocaleInput.field = LocaleTextControl;
|
|
2619
|
+
const LocaleTextAreaControl = props => /*#__PURE__*/jsx(LocaleTextControl, _extends({}, props, {
|
|
2620
|
+
multiline: true
|
|
2621
|
+
}));
|
|
2622
|
+
const LocaleTextArea = props => {
|
|
2623
|
+
const render = useOnChange$1(props);
|
|
2624
|
+
return render(LocaleTextAreaControl);
|
|
2625
|
+
};
|
|
2626
|
+
LocaleTextArea.field = LocaleTextAreaControl;
|
|
2627
|
+
|
|
2373
2628
|
const {
|
|
2374
2629
|
Text: Text$4
|
|
2375
2630
|
} = Typography;
|
|
@@ -2400,8 +2655,10 @@ const FieldRow = ({
|
|
|
2400
2655
|
onMove
|
|
2401
2656
|
}) => {
|
|
2402
2657
|
const {
|
|
2403
|
-
formatMessage
|
|
2658
|
+
formatMessage,
|
|
2659
|
+
locale
|
|
2404
2660
|
} = useIntl();
|
|
2661
|
+
const languages = useLocaleTextLanguages();
|
|
2405
2662
|
const definition = getFieldDefinition(field.type);
|
|
2406
2663
|
return /*#__PURE__*/jsxs("div", {
|
|
2407
2664
|
className: style['field-row'],
|
|
@@ -2416,7 +2673,7 @@ const FieldRow = ({
|
|
|
2416
2673
|
children: [/*#__PURE__*/jsx(Text$4, {
|
|
2417
2674
|
strong: true,
|
|
2418
2675
|
ellipsis: true,
|
|
2419
|
-
children: field.label || formatMessage({
|
|
2676
|
+
children: resolveLocaleText(field.label, locale, languages) || formatMessage({
|
|
2420
2677
|
id: 'untitledField'
|
|
2421
2678
|
})
|
|
2422
2679
|
}), /*#__PURE__*/jsx(Tag, {
|
|
@@ -2557,8 +2814,11 @@ const BlockListPanel = ({
|
|
|
2557
2814
|
extraToolbar
|
|
2558
2815
|
}) => {
|
|
2559
2816
|
const {
|
|
2560
|
-
formatMessage
|
|
2817
|
+
formatMessage,
|
|
2818
|
+
locale
|
|
2561
2819
|
} = useIntl();
|
|
2820
|
+
const languages = useLocaleTextLanguages();
|
|
2821
|
+
const text = value => resolveLocaleText(value, locale, languages);
|
|
2562
2822
|
const [addMenuOpen, setAddMenuOpen] = useState(false);
|
|
2563
2823
|
const [addFieldMenuId, setAddFieldMenuId] = useState(null);
|
|
2564
2824
|
const keepAddFieldMenuOpenRef = useRef(false);
|
|
@@ -2591,7 +2851,9 @@ const BlockListPanel = ({
|
|
|
2591
2851
|
})
|
|
2592
2852
|
}), /*#__PURE__*/jsx("div", {
|
|
2593
2853
|
className: style['add-block-option-desc'],
|
|
2594
|
-
children: definition
|
|
2854
|
+
children: definition ? formatMessage({
|
|
2855
|
+
id: definition.descriptionId
|
|
2856
|
+
}) : null
|
|
2595
2857
|
})]
|
|
2596
2858
|
})]
|
|
2597
2859
|
}, opt.key);
|
|
@@ -2690,9 +2952,11 @@ const BlockListPanel = ({
|
|
|
2690
2952
|
children: formatMessage({
|
|
2691
2953
|
id: `blockKind_${opt.key}`
|
|
2692
2954
|
})
|
|
2693
|
-
}), definition
|
|
2955
|
+
}), definition ? /*#__PURE__*/jsx("span", {
|
|
2694
2956
|
className: style['add-field-dropdown-item-desc'],
|
|
2695
|
-
children:
|
|
2957
|
+
children: formatMessage({
|
|
2958
|
+
id: definition.descriptionId
|
|
2959
|
+
})
|
|
2696
2960
|
}) : null]
|
|
2697
2961
|
}, opt.key);
|
|
2698
2962
|
})]
|
|
@@ -2800,7 +3064,7 @@ const BlockListPanel = ({
|
|
|
2800
3064
|
children: stepIndex + 1
|
|
2801
3065
|
}), /*#__PURE__*/jsx(Text$3, {
|
|
2802
3066
|
strong: true,
|
|
2803
|
-
children: step.title || formatMessage({
|
|
3067
|
+
children: text(step.title) || formatMessage({
|
|
2804
3068
|
id: 'untitledStep'
|
|
2805
3069
|
}, {
|
|
2806
3070
|
index: stepIndex + 1
|
|
@@ -2926,7 +3190,7 @@ const BlockListPanel = ({
|
|
|
2926
3190
|
children: optionIndex + 1
|
|
2927
3191
|
}), /*#__PURE__*/jsx(Text$3, {
|
|
2928
3192
|
strong: true,
|
|
2929
|
-
children: option.title || formatMessage({
|
|
3193
|
+
children: text(option.title) || formatMessage({
|
|
2930
3194
|
id: 'choiceOptionFallback'
|
|
2931
3195
|
}, {
|
|
2932
3196
|
index: optionIndex + 1
|
|
@@ -3056,7 +3320,7 @@ const BlockListPanel = ({
|
|
|
3056
3320
|
strong: true,
|
|
3057
3321
|
ellipsis: true,
|
|
3058
3322
|
className: style['block-title'],
|
|
3059
|
-
children: block.title || block.label || block.name || formatMessage({
|
|
3323
|
+
children: text(block.title) || text(block.label) || block.name || formatMessage({
|
|
3060
3324
|
id: 'untitledBlock'
|
|
3061
3325
|
})
|
|
3062
3326
|
}), /*#__PURE__*/jsx("span", {
|
|
@@ -3173,7 +3437,7 @@ const BlockConfigFields = ({
|
|
|
3173
3437
|
const list = [];
|
|
3174
3438
|
const isListKind = kind === 'list' || kind === 'tableList' || kind === 'editableList';
|
|
3175
3439
|
if (kind === 'formInfo' || kind === 'list' || kind === 'tableList' || kind === 'editableList' || kind === 'object') {
|
|
3176
|
-
list.push(/*#__PURE__*/jsx(
|
|
3440
|
+
list.push(/*#__PURE__*/jsx(LocaleInput, {
|
|
3177
3441
|
name: "title",
|
|
3178
3442
|
label: formatMessage({
|
|
3179
3443
|
id: 'blockTitle'
|
|
@@ -3181,7 +3445,7 @@ const BlockConfigFields = ({
|
|
|
3181
3445
|
placeholder: formatMessage({
|
|
3182
3446
|
id: 'blockTitlePlaceholder'
|
|
3183
3447
|
})
|
|
3184
|
-
}, "title"), kind === 'formInfo' ? /*#__PURE__*/jsx(
|
|
3448
|
+
}, "title"), kind === 'formInfo' ? /*#__PURE__*/jsx(LocaleInput, {
|
|
3185
3449
|
name: "subtitle",
|
|
3186
3450
|
label: formatMessage({
|
|
3187
3451
|
id: 'blockSubtitle'
|
|
@@ -3227,7 +3491,7 @@ const BlockConfigFields = ({
|
|
|
3227
3491
|
children: formatMessage({
|
|
3228
3492
|
id: 'blockImportant'
|
|
3229
3493
|
})
|
|
3230
|
-
}, "important") : null, isListKind ? /*#__PURE__*/jsx(
|
|
3494
|
+
}, "important") : null, isListKind ? /*#__PURE__*/jsx(LocaleInput, {
|
|
3231
3495
|
name: "addText",
|
|
3232
3496
|
label: formatMessage({
|
|
3233
3497
|
id: 'blockAddText'
|
|
@@ -3261,7 +3525,7 @@ const BlockConfigFields = ({
|
|
|
3261
3525
|
}, "minLength") : null);
|
|
3262
3526
|
}
|
|
3263
3527
|
if (kind === 'choice') {
|
|
3264
|
-
list.push(/*#__PURE__*/jsx(
|
|
3528
|
+
list.push(/*#__PURE__*/jsx(LocaleInput, {
|
|
3265
3529
|
name: "title",
|
|
3266
3530
|
label: formatMessage({
|
|
3267
3531
|
id: 'blockTitle'
|
|
@@ -3347,7 +3611,7 @@ const BlockConfigFields = ({
|
|
|
3347
3611
|
placeholder: formatMessage({
|
|
3348
3612
|
id: 'fieldNamePlaceholder'
|
|
3349
3613
|
})
|
|
3350
|
-
}, "name"), /*#__PURE__*/jsx(
|
|
3614
|
+
}, "name"), /*#__PURE__*/jsx(LocaleInput, {
|
|
3351
3615
|
name: "label",
|
|
3352
3616
|
label: formatMessage({
|
|
3353
3617
|
id: 'fieldLabel'
|
|
@@ -3363,7 +3627,7 @@ const BlockConfigFields = ({
|
|
|
3363
3627
|
}),
|
|
3364
3628
|
rule: "REQ",
|
|
3365
3629
|
options: fieldTypeOptions
|
|
3366
|
-
}, "fieldType"), /*#__PURE__*/jsx(
|
|
3630
|
+
}, "fieldType"), /*#__PURE__*/jsx(LocaleInput, {
|
|
3367
3631
|
name: "addText",
|
|
3368
3632
|
label: formatMessage({
|
|
3369
3633
|
id: 'blockAddText'
|
|
@@ -3374,7 +3638,7 @@ const BlockConfigFields = ({
|
|
|
3374
3638
|
}, "addText"));
|
|
3375
3639
|
}
|
|
3376
3640
|
if (kind === 'steps') {
|
|
3377
|
-
list.push(/*#__PURE__*/jsx(
|
|
3641
|
+
list.push(/*#__PURE__*/jsx(LocaleInput, {
|
|
3378
3642
|
name: "title",
|
|
3379
3643
|
label: formatMessage({
|
|
3380
3644
|
id: 'blockTitle'
|
|
@@ -3382,7 +3646,7 @@ const BlockConfigFields = ({
|
|
|
3382
3646
|
placeholder: formatMessage({
|
|
3383
3647
|
id: 'blockTitlePlaceholder'
|
|
3384
3648
|
})
|
|
3385
|
-
}, "title"), /*#__PURE__*/jsx(
|
|
3649
|
+
}, "title"), /*#__PURE__*/jsx(LocaleInput, {
|
|
3386
3650
|
name: "subtitle",
|
|
3387
3651
|
label: formatMessage({
|
|
3388
3652
|
id: 'blockSubtitle'
|
|
@@ -3408,7 +3672,9 @@ const BlockConfigFields = ({
|
|
|
3408
3672
|
title: formatMessage({
|
|
3409
3673
|
id: `blockKind_${kind}`
|
|
3410
3674
|
}),
|
|
3411
|
-
subtitle: definition
|
|
3675
|
+
subtitle: definition ? formatMessage({
|
|
3676
|
+
id: definition.descriptionId
|
|
3677
|
+
}) : undefined,
|
|
3412
3678
|
column: 1,
|
|
3413
3679
|
list: list.filter(Boolean)
|
|
3414
3680
|
})
|
|
@@ -3504,7 +3770,7 @@ const StepEditorModal = ({
|
|
|
3504
3770
|
}),
|
|
3505
3771
|
children: /*#__PURE__*/jsx(FormInfo, {
|
|
3506
3772
|
column: 1,
|
|
3507
|
-
list: [/*#__PURE__*/jsx(
|
|
3773
|
+
list: [/*#__PURE__*/jsx(LocaleInput, {
|
|
3508
3774
|
name: "title",
|
|
3509
3775
|
label: formatMessage({
|
|
3510
3776
|
id: 'stepTitle'
|
|
@@ -3564,7 +3830,7 @@ const ChoiceOptionEditorModal = ({
|
|
|
3564
3830
|
}),
|
|
3565
3831
|
children: /*#__PURE__*/jsx(FormInfo, {
|
|
3566
3832
|
column: 1,
|
|
3567
|
-
list: [/*#__PURE__*/jsx(
|
|
3833
|
+
list: [/*#__PURE__*/jsx(LocaleInput, {
|
|
3568
3834
|
name: "title",
|
|
3569
3835
|
label: formatMessage({
|
|
3570
3836
|
id: 'choiceOptionTitle'
|
|
@@ -3595,7 +3861,9 @@ const RulePresetEditor = () => {
|
|
|
3595
3861
|
formatMessage
|
|
3596
3862
|
} = useIntl();
|
|
3597
3863
|
const options = [...RULE_PRESET_ITEMS.map(item => ({
|
|
3598
|
-
label: item.
|
|
3864
|
+
label: item.labelId ? formatMessage({
|
|
3865
|
+
id: item.labelId
|
|
3866
|
+
}) : item.label,
|
|
3599
3867
|
value: item.value
|
|
3600
3868
|
})), {
|
|
3601
3869
|
label: formatMessage({
|
|
@@ -3661,28 +3929,29 @@ const EMPTY_OPTION = () => ({
|
|
|
3661
3929
|
});
|
|
3662
3930
|
|
|
3663
3931
|
/** value 为空或仍等于当前 label 时视为联动中,改 label 会同步 value */
|
|
3664
|
-
const isOptionValueLinked = (label, value) => {
|
|
3665
|
-
const labelText = label
|
|
3932
|
+
const isOptionValueLinked = (label, value, baseLanguage) => {
|
|
3933
|
+
const labelText = localeTextToValue(label, baseLanguage);
|
|
3666
3934
|
const valueText = value == null ? '' : String(value);
|
|
3667
3935
|
return valueText === '' || valueText === labelText;
|
|
3668
3936
|
};
|
|
3669
|
-
const patchOptionLabelChange = (item, nextLabel) => {
|
|
3937
|
+
const patchOptionLabelChange = (item, nextLabel, baseLanguage) => {
|
|
3670
3938
|
const patch = {
|
|
3671
3939
|
label: nextLabel
|
|
3672
3940
|
};
|
|
3673
|
-
if (isOptionValueLinked(item.label, item.value)) {
|
|
3674
|
-
patch.value = nextLabel;
|
|
3941
|
+
if (isOptionValueLinked(item.label, item.value, baseLanguage)) {
|
|
3942
|
+
patch.value = localeTextToValue(nextLabel, baseLanguage);
|
|
3675
3943
|
}
|
|
3676
3944
|
return patch;
|
|
3677
3945
|
};
|
|
3678
|
-
const trimOptionLabelValue = item => {
|
|
3679
|
-
var _item$
|
|
3680
|
-
const label =
|
|
3946
|
+
const trimOptionLabelValue = (item, baseLanguage) => {
|
|
3947
|
+
var _item$value;
|
|
3948
|
+
const label = trimLocaleText(item == null ? void 0 : item.label, baseLanguage);
|
|
3949
|
+
const labelValue = localeTextToValue(label, baseLanguage);
|
|
3681
3950
|
const rawValue = String((_item$value = item == null ? void 0 : item.value) != null ? _item$value : '').trim();
|
|
3682
|
-
const linked = isOptionValueLinked(item == null ? void 0 : item.label, item == null ? void 0 : item.value) || rawValue === '' || rawValue ===
|
|
3951
|
+
const linked = isOptionValueLinked(item == null ? void 0 : item.label, item == null ? void 0 : item.value, baseLanguage) || rawValue === '' || rawValue === labelValue;
|
|
3683
3952
|
return {
|
|
3684
3953
|
label,
|
|
3685
|
-
value: linked ?
|
|
3954
|
+
value: linked ? labelValue : rawValue
|
|
3686
3955
|
};
|
|
3687
3956
|
};
|
|
3688
3957
|
const createEmptyTableRow = columns => {
|
|
@@ -3709,9 +3978,11 @@ const FlatOptionRows = ({
|
|
|
3709
3978
|
onChange,
|
|
3710
3979
|
allowDescription
|
|
3711
3980
|
}) => {
|
|
3981
|
+
var _useLocaleTextLanguag;
|
|
3712
3982
|
const {
|
|
3713
3983
|
formatMessage
|
|
3714
3984
|
} = useIntl();
|
|
3985
|
+
const baseLanguage = (_useLocaleTextLanguag = useLocaleTextLanguages()[0]) == null ? void 0 : _useLocaleTextLanguag.value;
|
|
3715
3986
|
const rows = list.length ? ensureOptionKeys(list) : [EMPTY_OPTION()];
|
|
3716
3987
|
const commit = next => onChange(next);
|
|
3717
3988
|
const updateItem = (index, patch) => {
|
|
@@ -3723,13 +3994,15 @@ const FlatOptionRows = ({
|
|
|
3723
3994
|
gap: 8,
|
|
3724
3995
|
align: "start",
|
|
3725
3996
|
className: style['options-row'],
|
|
3726
|
-
children: [/*#__PURE__*/jsx(
|
|
3997
|
+
children: [/*#__PURE__*/jsx(LocaleTextControl, {
|
|
3998
|
+
compact: true,
|
|
3999
|
+
className: style['options-locale-text'],
|
|
3727
4000
|
value: item.label,
|
|
3728
4001
|
placeholder: formatMessage({
|
|
3729
4002
|
id: 'optionLabelPlaceholder'
|
|
3730
4003
|
}),
|
|
3731
|
-
onChange:
|
|
3732
|
-
onBlur: () => updateItem(index, trimOptionLabelValue(item))
|
|
4004
|
+
onChange: nextLabel => updateItem(index, patchOptionLabelChange(item, nextLabel, baseLanguage)),
|
|
4005
|
+
onBlur: () => updateItem(index, trimOptionLabelValue(item, baseLanguage))
|
|
3733
4006
|
}), /*#__PURE__*/jsx(Input$1, {
|
|
3734
4007
|
value: item.value,
|
|
3735
4008
|
placeholder: formatMessage({
|
|
@@ -3744,20 +4017,19 @@ const FlatOptionRows = ({
|
|
|
3744
4017
|
value: String((_item$value2 = item.value) != null ? _item$value2 : '').trim()
|
|
3745
4018
|
});
|
|
3746
4019
|
}
|
|
3747
|
-
}), allowDescription ? /*#__PURE__*/jsx(
|
|
4020
|
+
}), allowDescription ? /*#__PURE__*/jsx(LocaleTextControl, {
|
|
4021
|
+
compact: true,
|
|
4022
|
+
className: style['options-locale-text'],
|
|
3748
4023
|
value: item.description || '',
|
|
3749
4024
|
placeholder: formatMessage({
|
|
3750
4025
|
id: 'optionDescPlaceholder'
|
|
3751
4026
|
}),
|
|
3752
|
-
onChange:
|
|
3753
|
-
description
|
|
4027
|
+
onChange: description => updateItem(index, {
|
|
4028
|
+
description
|
|
3754
4029
|
}),
|
|
3755
|
-
onBlur: () => {
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
description: String((_item$description = item.description) != null ? _item$description : '').trim()
|
|
3759
|
-
});
|
|
3760
|
-
}
|
|
4030
|
+
onBlur: () => updateItem(index, {
|
|
4031
|
+
description: trimLocaleText(item.description, baseLanguage)
|
|
4032
|
+
})
|
|
3761
4033
|
}) : null, /*#__PURE__*/jsx(Button, {
|
|
3762
4034
|
type: "text",
|
|
3763
4035
|
danger: true,
|
|
@@ -3791,9 +4063,11 @@ const TreeOptionNode = ({
|
|
|
3791
4063
|
depth,
|
|
3792
4064
|
maxDepth: _maxDepth = 4
|
|
3793
4065
|
}) => {
|
|
4066
|
+
var _useLocaleTextLanguag2;
|
|
3794
4067
|
const {
|
|
3795
4068
|
formatMessage
|
|
3796
4069
|
} = useIntl();
|
|
4070
|
+
const baseLanguage = (_useLocaleTextLanguag2 = useLocaleTextLanguages()[0]) == null ? void 0 : _useLocaleTextLanguag2.value;
|
|
3797
4071
|
const children = Array.isArray(item.children) ? item.children : [];
|
|
3798
4072
|
const canAddChild = depth < _maxDepth;
|
|
3799
4073
|
const updateSelf = patch => {
|
|
@@ -3825,13 +4099,14 @@ const TreeOptionNode = ({
|
|
|
3825
4099
|
className: style['tree-option-row'],
|
|
3826
4100
|
children: [/*#__PURE__*/jsxs("div", {
|
|
3827
4101
|
className: style['tree-option-fields'],
|
|
3828
|
-
children: [/*#__PURE__*/jsx(
|
|
4102
|
+
children: [/*#__PURE__*/jsx(LocaleTextControl, {
|
|
4103
|
+
compact: true,
|
|
3829
4104
|
value: item.label,
|
|
3830
4105
|
placeholder: formatMessage({
|
|
3831
4106
|
id: 'optionLabelPlaceholder'
|
|
3832
4107
|
}),
|
|
3833
|
-
onChange:
|
|
3834
|
-
onBlur: () => updateSelf(trimOptionLabelValue(item))
|
|
4108
|
+
onChange: nextLabel => updateSelf(patchOptionLabelChange(item, nextLabel, baseLanguage)),
|
|
4109
|
+
onBlur: () => updateSelf(trimOptionLabelValue(item, baseLanguage))
|
|
3835
4110
|
}), /*#__PURE__*/jsx(Input$1, {
|
|
3836
4111
|
value: item.value,
|
|
3837
4112
|
placeholder: formatMessage({
|
|
@@ -3846,20 +4121,18 @@ const TreeOptionNode = ({
|
|
|
3846
4121
|
value: String((_item$value3 = item.value) != null ? _item$value3 : '').trim()
|
|
3847
4122
|
});
|
|
3848
4123
|
}
|
|
3849
|
-
}), allowDescription ? /*#__PURE__*/jsx(
|
|
4124
|
+
}), allowDescription ? /*#__PURE__*/jsx(LocaleTextControl, {
|
|
4125
|
+
compact: true,
|
|
3850
4126
|
value: item.description || '',
|
|
3851
4127
|
placeholder: formatMessage({
|
|
3852
4128
|
id: 'optionDescPlaceholder'
|
|
3853
4129
|
}),
|
|
3854
|
-
onChange:
|
|
3855
|
-
description
|
|
4130
|
+
onChange: description => updateSelf({
|
|
4131
|
+
description
|
|
3856
4132
|
}),
|
|
3857
|
-
onBlur: () => {
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
description: String((_item$description2 = item.description) != null ? _item$description2 : '').trim()
|
|
3861
|
-
});
|
|
3862
|
-
}
|
|
4133
|
+
onBlur: () => updateSelf({
|
|
4134
|
+
description: trimLocaleText(item.description, baseLanguage)
|
|
4135
|
+
})
|
|
3863
4136
|
}) : null]
|
|
3864
4137
|
}), /*#__PURE__*/jsxs("div", {
|
|
3865
4138
|
className: style['tree-option-actions'],
|
|
@@ -3965,13 +4238,14 @@ const ColumnsEditor = ({
|
|
|
3965
4238
|
gap: 8,
|
|
3966
4239
|
align: "start",
|
|
3967
4240
|
className: style['options-row'],
|
|
3968
|
-
children: [/*#__PURE__*/jsx(
|
|
4241
|
+
children: [/*#__PURE__*/jsx(LocaleTextControl, {
|
|
4242
|
+
compact: true,
|
|
4243
|
+
className: style['options-locale-text'],
|
|
3969
4244
|
value: item.title || '',
|
|
3970
4245
|
placeholder: formatMessage({
|
|
3971
4246
|
id: 'columnTitlePlaceholder'
|
|
3972
4247
|
}),
|
|
3973
|
-
onChange:
|
|
3974
|
-
const title = e.target.value;
|
|
4248
|
+
onChange: title => {
|
|
3975
4249
|
const patch = {
|
|
3976
4250
|
title
|
|
3977
4251
|
};
|
|
@@ -4042,8 +4316,10 @@ const TableRowsEditor = ({
|
|
|
4042
4316
|
onChange
|
|
4043
4317
|
}) => {
|
|
4044
4318
|
const {
|
|
4045
|
-
formatMessage
|
|
4319
|
+
formatMessage,
|
|
4320
|
+
locale
|
|
4046
4321
|
} = useIntl();
|
|
4322
|
+
const languages = useLocaleTextLanguages();
|
|
4047
4323
|
const usableColumns = _columns.filter(column => (column == null ? void 0 : column.name) && String(column.name).trim());
|
|
4048
4324
|
const list = _value3.length ? _value3 : [createEmptyTableRow(usableColumns)];
|
|
4049
4325
|
const updateItem = (index, patch) => {
|
|
@@ -4115,13 +4391,15 @@ const TableRowsEditor = ({
|
|
|
4115
4391
|
onChange: e => updateItem(index, {
|
|
4116
4392
|
value: e.target.value
|
|
4117
4393
|
})
|
|
4118
|
-
}), /*#__PURE__*/jsx(
|
|
4394
|
+
}), /*#__PURE__*/jsx(LocaleTextControl, {
|
|
4395
|
+
compact: true,
|
|
4396
|
+
className: style['options-locale-text'],
|
|
4119
4397
|
value: item.label || '',
|
|
4120
4398
|
placeholder: formatMessage({
|
|
4121
4399
|
id: 'tableRowLabelPlaceholder'
|
|
4122
4400
|
}),
|
|
4123
|
-
onChange:
|
|
4124
|
-
label
|
|
4401
|
+
onChange: label => updateItem(index, {
|
|
4402
|
+
label
|
|
4125
4403
|
})
|
|
4126
4404
|
})]
|
|
4127
4405
|
}), /*#__PURE__*/jsx(Flex, {
|
|
@@ -4133,7 +4411,7 @@ const TableRowsEditor = ({
|
|
|
4133
4411
|
flex: 1
|
|
4134
4412
|
},
|
|
4135
4413
|
value: item[column.name] || '',
|
|
4136
|
-
placeholder: column.title || column.name,
|
|
4414
|
+
placeholder: resolveLocaleText(column.title, locale, languages) || column.name,
|
|
4137
4415
|
onChange: e => updateItem(index, {
|
|
4138
4416
|
[column.name]: e.target.value
|
|
4139
4417
|
})
|
|
@@ -4308,7 +4586,7 @@ const SuperSelectPropsEditor = ({
|
|
|
4308
4586
|
var _openApi$data2;
|
|
4309
4587
|
return !(openApi != null && (_openApi$data2 = openApi.data) != null && _openApi$data2.single);
|
|
4310
4588
|
}
|
|
4311
|
-
}, "maxLength"), /*#__PURE__*/jsx(
|
|
4589
|
+
}, "maxLength"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4312
4590
|
name: "placeholder",
|
|
4313
4591
|
label: formatMessage({
|
|
4314
4592
|
id: 'fieldPlaceholder'
|
|
@@ -4316,7 +4594,7 @@ const SuperSelectPropsEditor = ({
|
|
|
4316
4594
|
placeholder: formatMessage({
|
|
4317
4595
|
id: 'superSelectPlaceholderHint'
|
|
4318
4596
|
})
|
|
4319
|
-
}, "placeholder"), /*#__PURE__*/jsx(
|
|
4597
|
+
}, "placeholder"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4320
4598
|
name: "searchPlaceholder",
|
|
4321
4599
|
label: formatMessage({
|
|
4322
4600
|
id: 'superSelectSearchPlaceholder'
|
|
@@ -4372,7 +4650,7 @@ const buildPropsSchemaList = (schema, formatMessage) => (schema || []).filter(it
|
|
|
4372
4650
|
}, item.name);
|
|
4373
4651
|
});
|
|
4374
4652
|
const buildBuiltinList = (type, formatMessage) => {
|
|
4375
|
-
const placeholder = /*#__PURE__*/jsx(
|
|
4653
|
+
const placeholder = /*#__PURE__*/jsx(LocaleInput, {
|
|
4376
4654
|
name: "placeholder",
|
|
4377
4655
|
label: formatMessage({
|
|
4378
4656
|
id: 'fieldPlaceholder'
|
|
@@ -4526,8 +4804,12 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4526
4804
|
label: 'YYYY/MM/DD',
|
|
4527
4805
|
value: 'YYYY/MM/DD'
|
|
4528
4806
|
}, {
|
|
4529
|
-
label:
|
|
4530
|
-
|
|
4807
|
+
label: formatMessage({
|
|
4808
|
+
id: 'propDateFormatLocalized'
|
|
4809
|
+
}),
|
|
4810
|
+
value: formatMessage({
|
|
4811
|
+
id: 'propDateFormatLocalized'
|
|
4812
|
+
})
|
|
4531
4813
|
}, {
|
|
4532
4814
|
label: 'YYYY-MM-DD HH:mm:ss',
|
|
4533
4815
|
value: 'YYYY-MM-DD HH:mm:ss'
|
|
@@ -4551,7 +4833,7 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4551
4833
|
})
|
|
4552
4834
|
}, "showTime")];
|
|
4553
4835
|
case 'Switch':
|
|
4554
|
-
return [/*#__PURE__*/jsx(
|
|
4836
|
+
return [/*#__PURE__*/jsx(LocaleInput, {
|
|
4555
4837
|
name: "checkedChildren",
|
|
4556
4838
|
label: formatMessage({
|
|
4557
4839
|
id: 'propSwitchOnText'
|
|
@@ -4559,7 +4841,7 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4559
4841
|
placeholder: formatMessage({
|
|
4560
4842
|
id: 'propSwitchOnTextHint'
|
|
4561
4843
|
})
|
|
4562
|
-
}, "checkedChildren"), /*#__PURE__*/jsx(
|
|
4844
|
+
}, "checkedChildren"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4563
4845
|
name: "unCheckedChildren",
|
|
4564
4846
|
label: formatMessage({
|
|
4565
4847
|
id: 'propSwitchOffText'
|
|
@@ -4703,7 +4985,7 @@ const FieldConfigFields = ({
|
|
|
4703
4985
|
placeholder: formatMessage({
|
|
4704
4986
|
id: 'fieldNamePlaceholder'
|
|
4705
4987
|
})
|
|
4706
|
-
}, "name"), /*#__PURE__*/jsx(
|
|
4988
|
+
}, "name"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4707
4989
|
name: "label",
|
|
4708
4990
|
label: formatMessage({
|
|
4709
4991
|
id: 'fieldLabel'
|
|
@@ -4712,7 +4994,7 @@ const FieldConfigFields = ({
|
|
|
4712
4994
|
placeholder: formatMessage({
|
|
4713
4995
|
id: 'fieldLabelPlaceholder'
|
|
4714
4996
|
})
|
|
4715
|
-
}, "label"), /*#__PURE__*/jsx(
|
|
4997
|
+
}, "label"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4716
4998
|
name: "tips",
|
|
4717
4999
|
label: formatMessage({
|
|
4718
5000
|
id: 'fieldTips'
|
|
@@ -4720,7 +5002,7 @@ const FieldConfigFields = ({
|
|
|
4720
5002
|
placeholder: formatMessage({
|
|
4721
5003
|
id: 'fieldTipsPlaceholder'
|
|
4722
5004
|
})
|
|
4723
|
-
}, "tips"), /*#__PURE__*/jsx(
|
|
5005
|
+
}, "tips"), /*#__PURE__*/jsx(LocaleTextArea, {
|
|
4724
5006
|
name: "description",
|
|
4725
5007
|
label: formatMessage({
|
|
4726
5008
|
id: 'fieldDescription'
|
|
@@ -4953,7 +5235,7 @@ const FormActionsEditor = ({
|
|
|
4953
5235
|
id: 'formActionsShowSubmit'
|
|
4954
5236
|
}),
|
|
4955
5237
|
className: style['form-actions-switch-field']
|
|
4956
|
-
}, "showSubmit"), /*#__PURE__*/jsx(
|
|
5238
|
+
}, "showSubmit"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4957
5239
|
name: "submitText",
|
|
4958
5240
|
label: formatMessage({
|
|
4959
5241
|
id: 'formActionsSubmitText'
|
|
@@ -4976,7 +5258,7 @@ const FormActionsEditor = ({
|
|
|
4976
5258
|
id: 'formActionsShowReset'
|
|
4977
5259
|
}),
|
|
4978
5260
|
className: style['form-actions-switch-field']
|
|
4979
|
-
}, "showReset"), /*#__PURE__*/jsx(
|
|
5261
|
+
}, "showReset"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4980
5262
|
name: "resetText",
|
|
4981
5263
|
label: formatMessage({
|
|
4982
5264
|
id: 'formActionsResetText'
|
|
@@ -4999,7 +5281,7 @@ const FormActionsEditor = ({
|
|
|
4999
5281
|
id: 'formActionsShowCancel'
|
|
5000
5282
|
}),
|
|
5001
5283
|
className: style['form-actions-switch-field']
|
|
5002
|
-
}, "showCancel"), /*#__PURE__*/jsx(
|
|
5284
|
+
}, "showCancel"), /*#__PURE__*/jsx(LocaleInput, {
|
|
5003
5285
|
name: "cancelText",
|
|
5004
5286
|
label: formatMessage({
|
|
5005
5287
|
id: 'formActionsCancelText'
|
|
@@ -5135,30 +5417,30 @@ const resolveSelectLimits = block => {
|
|
|
5135
5417
|
};
|
|
5136
5418
|
const buildMultipleHint = (formatMessage, minLength, maxLength) => {
|
|
5137
5419
|
if (minLength != null && maxLength != null) {
|
|
5138
|
-
return formatMessage
|
|
5420
|
+
return formatMessage({
|
|
5139
5421
|
id: 'choiceModeHintMultipleRange'
|
|
5140
5422
|
}, {
|
|
5141
5423
|
min: minLength,
|
|
5142
5424
|
max: maxLength
|
|
5143
|
-
})
|
|
5425
|
+
});
|
|
5144
5426
|
}
|
|
5145
5427
|
if (minLength != null) {
|
|
5146
|
-
return formatMessage
|
|
5428
|
+
return formatMessage({
|
|
5147
5429
|
id: 'choiceModeHintMultipleMin'
|
|
5148
5430
|
}, {
|
|
5149
5431
|
count: minLength
|
|
5150
|
-
})
|
|
5432
|
+
});
|
|
5151
5433
|
}
|
|
5152
5434
|
if (maxLength != null) {
|
|
5153
|
-
return formatMessage
|
|
5435
|
+
return formatMessage({
|
|
5154
5436
|
id: 'choiceModeHintMultipleMax'
|
|
5155
5437
|
}, {
|
|
5156
5438
|
count: maxLength
|
|
5157
|
-
})
|
|
5439
|
+
});
|
|
5158
5440
|
}
|
|
5159
|
-
return formatMessage
|
|
5441
|
+
return formatMessage({
|
|
5160
5442
|
id: 'choiceModeHintMultiple'
|
|
5161
|
-
})
|
|
5443
|
+
});
|
|
5162
5444
|
};
|
|
5163
5445
|
|
|
5164
5446
|
/**
|
|
@@ -5184,9 +5466,9 @@ const ChoiceBlock = ({
|
|
|
5184
5466
|
openApi
|
|
5185
5467
|
} = useFormContext() || {};
|
|
5186
5468
|
const titleText = (block == null ? void 0 : block.title) != null ? String(block.title).trim() : '';
|
|
5187
|
-
const title = titleText ||
|
|
5469
|
+
const title = titleText || formatMessage({
|
|
5188
5470
|
id: 'choiceAreaTitle'
|
|
5189
|
-
})
|
|
5471
|
+
});
|
|
5190
5472
|
const bordered = _isMobile ? false : (block == null ? void 0 : block.bordered) || undefined;
|
|
5191
5473
|
const {
|
|
5192
5474
|
minLength,
|
|
@@ -5218,11 +5500,11 @@ const ChoiceBlock = ({
|
|
|
5218
5500
|
return options.map((option, index) => {
|
|
5219
5501
|
const value = String(option.id);
|
|
5220
5502
|
return {
|
|
5221
|
-
label: option.title ||
|
|
5503
|
+
label: option.title || formatMessage({
|
|
5222
5504
|
id: 'choiceOptionFallback'
|
|
5223
5505
|
}, {
|
|
5224
5506
|
index: index + 1
|
|
5225
|
-
})
|
|
5507
|
+
}),
|
|
5226
5508
|
value,
|
|
5227
5509
|
disabled: atMax && !selectedIdsFromValue.includes(value)
|
|
5228
5510
|
};
|
|
@@ -5251,21 +5533,21 @@ const ChoiceBlock = ({
|
|
|
5251
5533
|
if (minLength != null && ids.length < minLength) {
|
|
5252
5534
|
return {
|
|
5253
5535
|
result: false,
|
|
5254
|
-
errMsg: formatMessage
|
|
5536
|
+
errMsg: formatMessage({
|
|
5255
5537
|
id: 'choiceMinSelectError'
|
|
5256
5538
|
}, {
|
|
5257
5539
|
count: minLength
|
|
5258
|
-
})
|
|
5540
|
+
})
|
|
5259
5541
|
};
|
|
5260
5542
|
}
|
|
5261
5543
|
if (maxLength != null && ids.length > maxLength) {
|
|
5262
5544
|
return {
|
|
5263
5545
|
result: false,
|
|
5264
|
-
errMsg: formatMessage
|
|
5546
|
+
errMsg: formatMessage({
|
|
5265
5547
|
id: 'choiceMaxSelectError'
|
|
5266
5548
|
}, {
|
|
5267
5549
|
count: maxLength
|
|
5268
|
-
})
|
|
5550
|
+
})
|
|
5269
5551
|
};
|
|
5270
5552
|
}
|
|
5271
5553
|
return {
|
|
@@ -5278,9 +5560,9 @@ const ChoiceBlock = ({
|
|
|
5278
5560
|
const selectorProps = _extends({
|
|
5279
5561
|
key: `choice-selector-${mode}`,
|
|
5280
5562
|
name: selectorName,
|
|
5281
|
-
label: titleText ||
|
|
5563
|
+
label: titleText || formatMessage({
|
|
5282
5564
|
id: 'choiceAreaTitle'
|
|
5283
|
-
})
|
|
5565
|
+
}),
|
|
5284
5566
|
labelHidden: true,
|
|
5285
5567
|
options: selectorOptions,
|
|
5286
5568
|
onChange: handleChange
|
|
@@ -5311,9 +5593,9 @@ const ChoiceBlock = ({
|
|
|
5311
5593
|
}, option.title) : null, ...nodes));
|
|
5312
5594
|
}
|
|
5313
5595
|
});
|
|
5314
|
-
const modeHint = mode === 'multiple' ? buildMultipleHint(formatMessage, minLength, maxLength) : formatMessage
|
|
5596
|
+
const modeHint = mode === 'multiple' ? buildMultipleHint(formatMessage, minLength, maxLength) : formatMessage({
|
|
5315
5597
|
id: 'choiceModeHintSingle'
|
|
5316
|
-
})
|
|
5598
|
+
});
|
|
5317
5599
|
if (!block) {
|
|
5318
5600
|
return null;
|
|
5319
5601
|
}
|
|
@@ -5329,12 +5611,60 @@ const ChoiceBlock = ({
|
|
|
5329
5611
|
className: style['choice-panels']
|
|
5330
5612
|
}, ...contentChildren) : /*#__PURE__*/createElement('div', {
|
|
5331
5613
|
className: style['choice-panels-empty']
|
|
5332
|
-
}, formatMessage
|
|
5614
|
+
}, formatMessage({
|
|
5333
5615
|
id: 'choiceSelectFirstHint'
|
|
5334
|
-
})
|
|
5616
|
+
})));
|
|
5335
5617
|
};
|
|
5336
5618
|
var ChoiceBlock$1 = ChoiceBlock;
|
|
5337
5619
|
|
|
5620
|
+
// @kne/react-form 内置规则的错误提示写死中文;在 preset 覆盖前记下原函数,只替换未被业务覆盖的规则
|
|
5621
|
+
const BUILTIN_RULES = {
|
|
5622
|
+
TEL: RULES.TEL,
|
|
5623
|
+
EMAIL: RULES.EMAIL,
|
|
5624
|
+
LEN: RULES.LEN
|
|
5625
|
+
};
|
|
5626
|
+
const isBuiltin = name => RULES[name] === BUILTIN_RULES[name];
|
|
5627
|
+
const lenMessageId = (value, start, end) => {
|
|
5628
|
+
if (end === start) {
|
|
5629
|
+
return 'ruleErrorLenEqual';
|
|
5630
|
+
}
|
|
5631
|
+
return String(value != null ? value : '').length < start ? 'ruleErrorLenMin' : 'ruleErrorLenMax';
|
|
5632
|
+
};
|
|
5633
|
+
|
|
5634
|
+
/** 按当前语言生成表单级 rules,传给 Form 覆盖全局同名规则 */
|
|
5635
|
+
const createLocalizedRules = formatMessage => {
|
|
5636
|
+
if (typeof formatMessage !== 'function') {
|
|
5637
|
+
return {};
|
|
5638
|
+
}
|
|
5639
|
+
const rules = {};
|
|
5640
|
+
['TEL', 'EMAIL'].forEach(name => {
|
|
5641
|
+
if (isBuiltin(name)) {
|
|
5642
|
+
rules[name] = (...args) => {
|
|
5643
|
+
const res = BUILTIN_RULES[name](...args);
|
|
5644
|
+
return res.result ? res : _extends({}, res, {
|
|
5645
|
+
errMsg: formatMessage({
|
|
5646
|
+
id: `ruleError${name}`
|
|
5647
|
+
})
|
|
5648
|
+
});
|
|
5649
|
+
};
|
|
5650
|
+
}
|
|
5651
|
+
});
|
|
5652
|
+
if (isBuiltin('LEN')) {
|
|
5653
|
+
rules.LEN = (value, start, end) => {
|
|
5654
|
+
const res = BUILTIN_RULES.LEN(value, start, end);
|
|
5655
|
+
return res.result ? res : _extends({}, res, {
|
|
5656
|
+
errMsg: formatMessage({
|
|
5657
|
+
id: lenMessageId(value, start, end)
|
|
5658
|
+
}, {
|
|
5659
|
+
start,
|
|
5660
|
+
end
|
|
5661
|
+
})
|
|
5662
|
+
});
|
|
5663
|
+
};
|
|
5664
|
+
}
|
|
5665
|
+
return rules;
|
|
5666
|
+
};
|
|
5667
|
+
|
|
5338
5668
|
const buildLabelTips = tips => {
|
|
5339
5669
|
if (tips == null || !String(tips).trim()) {
|
|
5340
5670
|
return undefined;
|
|
@@ -5713,6 +6043,7 @@ const renderSchemaContent = (schema, {
|
|
|
5713
6043
|
}
|
|
5714
6044
|
const formClassName = [style['schema-form'], _formProps.className, className].filter(Boolean).join(' ');
|
|
5715
6045
|
return /*#__PURE__*/createElement(Form, _extends({}, _formProps, {
|
|
6046
|
+
rules: _extends({}, createLocalizedRules(formatMessage), _formProps.rules),
|
|
5716
6047
|
className: formClassName
|
|
5717
6048
|
}), /*#__PURE__*/createElement('div', {
|
|
5718
6049
|
className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
|
|
@@ -5812,14 +6143,15 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5812
6143
|
bodyClassName,
|
|
5813
6144
|
footerClassName,
|
|
5814
6145
|
buttonFooter = false,
|
|
5815
|
-
buttonFooterProps
|
|
6146
|
+
buttonFooterProps,
|
|
6147
|
+
languages
|
|
5816
6148
|
} = props;
|
|
5817
6149
|
const {
|
|
5818
6150
|
formatMessage,
|
|
5819
6151
|
locale
|
|
5820
6152
|
} = useIntl();
|
|
5821
6153
|
const isMobile = useIsMobile();
|
|
5822
|
-
const normalized = normalizeSchema(schema);
|
|
6154
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
5823
6155
|
if (!hasRenderableContent(normalized)) {
|
|
5824
6156
|
return null;
|
|
5825
6157
|
}
|
|
@@ -5877,14 +6209,15 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5877
6209
|
bodyClassName,
|
|
5878
6210
|
footerClassName,
|
|
5879
6211
|
buttonFooter = false,
|
|
5880
|
-
buttonFooterProps
|
|
6212
|
+
buttonFooterProps,
|
|
6213
|
+
languages
|
|
5881
6214
|
} = props;
|
|
5882
6215
|
const {
|
|
5883
6216
|
formatMessage,
|
|
5884
6217
|
locale
|
|
5885
6218
|
} = useIntl();
|
|
5886
6219
|
const isMobile = useIsMobile();
|
|
5887
|
-
const normalized = normalizeSchema(schema);
|
|
6220
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
5888
6221
|
if (!hasRenderableContent(normalized)) {
|
|
5889
6222
|
return null;
|
|
5890
6223
|
}
|
|
@@ -5930,7 +6263,8 @@ const FormCreator = withLocale$1(({
|
|
|
5930
6263
|
className,
|
|
5931
6264
|
formProps,
|
|
5932
6265
|
renderModal,
|
|
5933
|
-
extraToolbar
|
|
6266
|
+
extraToolbar,
|
|
6267
|
+
languages
|
|
5934
6268
|
}) => {
|
|
5935
6269
|
const {
|
|
5936
6270
|
formatMessage,
|
|
@@ -5971,7 +6305,15 @@ const FormCreator = withLocale$1(({
|
|
|
5971
6305
|
stepId,
|
|
5972
6306
|
optionId
|
|
5973
6307
|
} = {}) => {
|
|
5974
|
-
setEditingBlock(createBlock(kind
|
|
6308
|
+
setEditingBlock(createBlock(kind, kind === 'choice' ? {
|
|
6309
|
+
options: [createChoiceOption({
|
|
6310
|
+
title: formatMessage({
|
|
6311
|
+
id: 'choiceOptionFallback'
|
|
6312
|
+
}, {
|
|
6313
|
+
index: 1
|
|
6314
|
+
})
|
|
6315
|
+
})]
|
|
6316
|
+
} : undefined));
|
|
5975
6317
|
setBlockParentId(parentBlockId || null);
|
|
5976
6318
|
setBlockParentStepId(stepId || null);
|
|
5977
6319
|
setBlockParentOptionId(optionId || null);
|
|
@@ -6220,94 +6562,98 @@ const FormCreator = withLocale$1(({
|
|
|
6220
6562
|
const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
|
|
6221
6563
|
schema
|
|
6222
6564
|
}) : extraToolbar;
|
|
6223
|
-
return /*#__PURE__*/
|
|
6224
|
-
|
|
6225
|
-
children:
|
|
6226
|
-
className: style['
|
|
6227
|
-
children: /*#__PURE__*/jsx(
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
className: style['preview-
|
|
6252
|
-
children:
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6565
|
+
return /*#__PURE__*/jsx(LocaleTextProvider, {
|
|
6566
|
+
languages: languages,
|
|
6567
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
6568
|
+
className: [style['form-creator'], RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
|
|
6569
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
6570
|
+
className: style['editor-pane'],
|
|
6571
|
+
children: /*#__PURE__*/jsx(BlockListPanel$1, {
|
|
6572
|
+
blocks: schema.blocks,
|
|
6573
|
+
onAddBlock: handleAddBlock,
|
|
6574
|
+
onEditBlock: handleEditBlock,
|
|
6575
|
+
onDeleteBlock: handleDeleteBlock,
|
|
6576
|
+
onMoveBlock: handleMoveBlock,
|
|
6577
|
+
onAddField: handleAddField,
|
|
6578
|
+
onEditField: handleEditField,
|
|
6579
|
+
onDeleteField: handleDeleteField,
|
|
6580
|
+
onMoveField: handleMoveField,
|
|
6581
|
+
onAddStep: handleAddStep,
|
|
6582
|
+
onEditStep: handleEditStep,
|
|
6583
|
+
onDeleteStep: handleDeleteStep,
|
|
6584
|
+
onMoveStep: handleMoveStep,
|
|
6585
|
+
onAddChoiceOption: handleAddChoiceOption,
|
|
6586
|
+
onEditChoiceOption: handleEditChoiceOption,
|
|
6587
|
+
onDeleteChoiceOption: handleDeleteChoiceOption,
|
|
6588
|
+
onMoveChoiceOption: handleMoveChoiceOption,
|
|
6589
|
+
onOpenFormActions: () => setFormActionsOpen(true),
|
|
6590
|
+
extraToolbar: toolbarExtra
|
|
6591
|
+
})
|
|
6592
|
+
}), _showPreview ? /*#__PURE__*/jsx("div", {
|
|
6593
|
+
className: style['preview-pane'],
|
|
6594
|
+
children: /*#__PURE__*/jsx("div", {
|
|
6595
|
+
className: style['preview-body'],
|
|
6596
|
+
children: hasRenderableContent(schema) ? /*#__PURE__*/jsx(SchemaRenderer$1, {
|
|
6597
|
+
schema: schema,
|
|
6598
|
+
preview: true,
|
|
6599
|
+
formProps: formProps,
|
|
6600
|
+
locale: locale,
|
|
6601
|
+
languages: languages
|
|
6602
|
+
}) : /*#__PURE__*/jsx(Empty, {
|
|
6603
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
6604
|
+
description: formatMessage({
|
|
6605
|
+
id: 'emptyBlockList'
|
|
6606
|
+
})
|
|
6261
6607
|
})
|
|
6262
6608
|
})
|
|
6263
|
-
})
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
}
|
|
6310
|
-
})
|
|
6609
|
+
}) : null, /*#__PURE__*/jsx(BlockEditorModal$1, {
|
|
6610
|
+
open: blockEditorOpen,
|
|
6611
|
+
block: editingBlock,
|
|
6612
|
+
renderModal: renderModal,
|
|
6613
|
+
onCancel: clearBlockEditor,
|
|
6614
|
+
onSave: handleSaveBlock
|
|
6615
|
+
}), /*#__PURE__*/jsx(StepEditorModal$1, {
|
|
6616
|
+
open: stepEditorOpen,
|
|
6617
|
+
step: stepContext == null ? void 0 : stepContext.step,
|
|
6618
|
+
renderModal: renderModal,
|
|
6619
|
+
onCancel: () => {
|
|
6620
|
+
setStepEditorOpen(false);
|
|
6621
|
+
setStepContext(null);
|
|
6622
|
+
},
|
|
6623
|
+
onSave: handleSaveStep
|
|
6624
|
+
}), /*#__PURE__*/jsx(ChoiceOptionEditorModal$1, {
|
|
6625
|
+
open: choiceOptionEditorOpen,
|
|
6626
|
+
option: choiceOptionContext == null ? void 0 : choiceOptionContext.option,
|
|
6627
|
+
renderModal: renderModal,
|
|
6628
|
+
onCancel: () => {
|
|
6629
|
+
setChoiceOptionEditorOpen(false);
|
|
6630
|
+
setChoiceOptionContext(null);
|
|
6631
|
+
},
|
|
6632
|
+
onSave: handleSaveChoiceOption
|
|
6633
|
+
}), /*#__PURE__*/jsx(FieldEditorModal$1, {
|
|
6634
|
+
open: fieldEditorOpen,
|
|
6635
|
+
field: editingField,
|
|
6636
|
+
fieldList: currentFieldScope,
|
|
6637
|
+
renderModal: renderModal,
|
|
6638
|
+
onCancel: () => {
|
|
6639
|
+
setFieldEditorOpen(false);
|
|
6640
|
+
setFieldContext(null);
|
|
6641
|
+
setEditingField(null);
|
|
6642
|
+
},
|
|
6643
|
+
onSave: handleSaveField
|
|
6644
|
+
}), /*#__PURE__*/jsx(FormActionsEditor$1, {
|
|
6645
|
+
open: formActionsOpen,
|
|
6646
|
+
value: schema.actions,
|
|
6647
|
+
renderModal: renderModal,
|
|
6648
|
+
onCancel: () => setFormActionsOpen(false),
|
|
6649
|
+
onSave: actions => {
|
|
6650
|
+
updateSchema(_extends({}, schema, {
|
|
6651
|
+
actions
|
|
6652
|
+
}));
|
|
6653
|
+
setFormActionsOpen(false);
|
|
6654
|
+
}
|
|
6655
|
+
})]
|
|
6656
|
+
})
|
|
6311
6657
|
});
|
|
6312
6658
|
});
|
|
6313
6659
|
var FormCreator$1 = FormCreator;
|
|
@@ -6624,7 +6970,7 @@ const formatDateToToday = (value, itemSchema, ctx) => {
|
|
|
6624
6970
|
if (items[1] == null || items[1] === '' || items[1] === true) {
|
|
6625
6971
|
const until = (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6626
6972
|
id: 'schemaContentUntilToday'
|
|
6627
|
-
})) ||
|
|
6973
|
+
})) || defaultLocale.schemaContentUntilToday;
|
|
6628
6974
|
return [start, until].filter(Boolean).join(' ~ ');
|
|
6629
6975
|
}
|
|
6630
6976
|
const end = formatByValueSchema(items[1], itemSchema, ctx);
|
|
@@ -6679,11 +7025,11 @@ const formatBoolean = (value, field, ctx) => {
|
|
|
6679
7025
|
if (value) {
|
|
6680
7026
|
return props.checkedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6681
7027
|
id: 'schemaContentYes'
|
|
6682
|
-
})) ||
|
|
7028
|
+
})) || defaultLocale.schemaContentYes;
|
|
6683
7029
|
}
|
|
6684
7030
|
return props.unCheckedChildren || (ctx.formatMessage == null ? void 0 : ctx.formatMessage({
|
|
6685
7031
|
id: 'schemaContentNo'
|
|
6686
|
-
})) ||
|
|
7032
|
+
})) || defaultLocale.schemaContentNo;
|
|
6687
7033
|
};
|
|
6688
7034
|
const stringifyFallback = value => {
|
|
6689
7035
|
if (value == null) {
|
|
@@ -6810,9 +7156,12 @@ const formatByValueSchema = (value, schema, ctx = {}) => {
|
|
|
6810
7156
|
}
|
|
6811
7157
|
return String(value);
|
|
6812
7158
|
};
|
|
6813
|
-
const formatFieldDisplayValue = (
|
|
6814
|
-
formatMessage
|
|
7159
|
+
const formatFieldDisplayValue = (rawField, value, {
|
|
7160
|
+
formatMessage,
|
|
7161
|
+
locale,
|
|
7162
|
+
languages
|
|
6815
7163
|
} = {}) => {
|
|
7164
|
+
const field = localizeSchema(rawField, locale, languages);
|
|
6816
7165
|
const emptyText = (formatMessage == null ? void 0 : formatMessage({
|
|
6817
7166
|
id: 'schemaContentEmptyValue'
|
|
6818
7167
|
})) || '-';
|
|
@@ -7068,14 +7417,15 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
|
7068
7417
|
const selectorName = resolveChoiceSelectorName$1(block);
|
|
7069
7418
|
const options = block.options || [];
|
|
7070
7419
|
const optionIds = options.map(option => String(option.id));
|
|
7071
|
-
const branches = options.map(
|
|
7420
|
+
const branches = options.map(option => {
|
|
7072
7421
|
const branch = createObjectLayer();
|
|
7073
|
-
const optionTitle = option.title ||
|
|
7422
|
+
const optionTitle = option.title || undefined;
|
|
7074
7423
|
if (selectorInData && mode === 'single') {
|
|
7075
|
-
branch.properties[selectorName] = {
|
|
7076
|
-
const: String(option.id)
|
|
7424
|
+
branch.properties[selectorName] = _extends({
|
|
7425
|
+
const: String(option.id)
|
|
7426
|
+
}, optionTitle ? {
|
|
7077
7427
|
title: optionTitle
|
|
7078
|
-
};
|
|
7428
|
+
} : {});
|
|
7079
7429
|
branch.required.push(selectorName);
|
|
7080
7430
|
}
|
|
7081
7431
|
mergeFieldsIntoLayer(branch, option.list, {
|
|
@@ -7157,9 +7507,10 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
|
7157
7507
|
* - 扩展字段:registerField / preset 的 valueSchema;缺省 { type: 'string' }
|
|
7158
7508
|
* - hidden 字段仍进入 data schema(可提交)
|
|
7159
7509
|
* - choice:single → oneOf,multiple → anyOf
|
|
7510
|
+
* - options.locale / options.languages:多语言文案取该语言,取不到按 languages 顺序回退(未传为 zh-CN → en-US)
|
|
7160
7511
|
*/
|
|
7161
7512
|
const schemaToDataSchema = (schema, options = {}) => {
|
|
7162
|
-
const normalized = normalizeSchema(schema || {});
|
|
7513
|
+
const normalized = normalizeSchema(localizeSchema(schema || {}, options.locale, options.languages));
|
|
7163
7514
|
const layer = createObjectLayer();
|
|
7164
7515
|
walkBlocks(normalized.blocks, layer, 0);
|
|
7165
7516
|
const root = finalizeObjectSchema(layer, {
|
|
@@ -7349,13 +7700,15 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7349
7700
|
const SchemaContentInnerView = ({
|
|
7350
7701
|
schema,
|
|
7351
7702
|
data,
|
|
7352
|
-
className
|
|
7703
|
+
className,
|
|
7704
|
+
languages
|
|
7353
7705
|
}) => {
|
|
7354
7706
|
const {
|
|
7355
|
-
formatMessage
|
|
7707
|
+
formatMessage,
|
|
7708
|
+
locale
|
|
7356
7709
|
} = useIntl();
|
|
7357
7710
|
const isMobile = useIsMobile();
|
|
7358
|
-
const normalized = normalizeSchema(schema);
|
|
7711
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
7359
7712
|
const children = renderBlockList(normalized.blocks, data || {}, {
|
|
7360
7713
|
formatMessage,
|
|
7361
7714
|
isMobile,
|
|
@@ -7379,12 +7732,14 @@ const SchemaContent = withLocale$1(({
|
|
|
7379
7732
|
schema,
|
|
7380
7733
|
data,
|
|
7381
7734
|
className,
|
|
7382
|
-
empty
|
|
7735
|
+
empty,
|
|
7736
|
+
languages
|
|
7383
7737
|
}) => {
|
|
7384
7738
|
const {
|
|
7385
|
-
formatMessage
|
|
7739
|
+
formatMessage,
|
|
7740
|
+
locale
|
|
7386
7741
|
} = useIntl();
|
|
7387
|
-
const normalized = normalizeSchema(schema);
|
|
7742
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
7388
7743
|
const emptyNode = empty !== undefined ? empty : /*#__PURE__*/jsx(Empty, {
|
|
7389
7744
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
7390
7745
|
description: formatMessage({
|
|
@@ -7404,5 +7759,5 @@ const SchemaContent = withLocale$1(({
|
|
|
7404
7759
|
});
|
|
7405
7760
|
var SchemaContent$1 = SchemaContent;
|
|
7406
7761
|
|
|
7407
|
-
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 };
|
|
7762
|
+
export { FormCreator$1 as FormCreator, LocaleInput, LocaleTextArea, LocaleTextControl, LocaleTextProvider, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaContent$1 as SchemaContent, SchemaContentInner, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectBlockFieldNames, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, findBlockInTree, formValuesToBlock, formValuesToField, formatByValueSchema, formatFieldDisplayValue, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasLocaleText, hasRenderableContent, isFieldNameUnique, isLocaleText, localizeSchema, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, registerField, removeBlockInTree, resolveFieldTypeLabel, resolveFieldValueSchema, resolveLocaleText, schemaToDataSchema, updateBlocks };
|
|
7408
7763
|
//# sourceMappingURL=index.modern.js.map
|