@kne/form-creator 0.1.23 → 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 +496 -175
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +488 -191
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +7 -1
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +7 -1
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +7 -1
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +7 -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) {
|
|
@@ -278,7 +278,13 @@ const locale$1 = {
|
|
|
278
278
|
schemaContentNo: '否',
|
|
279
279
|
schemaContentItemIndex: '第 {index} 项',
|
|
280
280
|
schemaContentUntilToday: '至今',
|
|
281
|
-
schemaContentPasswordMasked: '••••••'
|
|
281
|
+
schemaContentPasswordMasked: '••••••',
|
|
282
|
+
ruleErrorTEL: '请输入有效的手机号',
|
|
283
|
+
ruleErrorEMAIL: '请输入有效的邮箱',
|
|
284
|
+
ruleErrorLenEqual: '%s长度必须等于{end}',
|
|
285
|
+
ruleErrorLenMin: '%s长度必须大于{start}',
|
|
286
|
+
ruleErrorLenMax: '%s长度必须小于{end}',
|
|
287
|
+
localeTextFallback: '留空时使用{language}'
|
|
282
288
|
};
|
|
283
289
|
var defaultLocale = locale$1;
|
|
284
290
|
|
|
@@ -522,7 +528,13 @@ const locale = {
|
|
|
522
528
|
schemaContentNo: 'No',
|
|
523
529
|
schemaContentItemIndex: 'Item {index}',
|
|
524
530
|
schemaContentUntilToday: 'Present',
|
|
525
|
-
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'
|
|
526
538
|
};
|
|
527
539
|
var enUS = locale;
|
|
528
540
|
|
|
@@ -536,6 +548,113 @@ const withLocale = createWithIntlProvider({
|
|
|
536
548
|
});
|
|
537
549
|
var withLocale$1 = withLocale;
|
|
538
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
|
+
|
|
539
658
|
const createFieldId = () => `field_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
540
659
|
|
|
541
660
|
/** 生成可编辑的默认数据标识,如 field_xxxx / col_xxxx */
|
|
@@ -572,6 +691,7 @@ const defaultFormActions = () => ({
|
|
|
572
691
|
gap: 16
|
|
573
692
|
});
|
|
574
693
|
const FORM_ACTIONS_ALIGN = ['center', 'start', 'end'];
|
|
694
|
+
const normalizeActionText = value => value == null ? '' : isLocaleText(value) ? _extends({}, value) : String(value);
|
|
575
695
|
const normalizeFormActions = (actions = {}) => {
|
|
576
696
|
const base = defaultFormActions();
|
|
577
697
|
if (!actions || typeof actions !== 'object') {
|
|
@@ -584,9 +704,9 @@ const normalizeFormActions = (actions = {}) => {
|
|
|
584
704
|
showSubmit: actions.showSubmit !== false,
|
|
585
705
|
showReset: actions.showReset !== false,
|
|
586
706
|
showCancel: !!actions.showCancel,
|
|
587
|
-
submitText:
|
|
588
|
-
resetText:
|
|
589
|
-
cancelText:
|
|
707
|
+
submitText: normalizeActionText(actions.submitText),
|
|
708
|
+
resetText: normalizeActionText(actions.resetText),
|
|
709
|
+
cancelText: normalizeActionText(actions.cancelText),
|
|
590
710
|
align,
|
|
591
711
|
gap
|
|
592
712
|
}, actions.submitButtonProps && typeof actions.submitButtonProps === 'object' ? {
|
|
@@ -1436,7 +1556,7 @@ const createApiFromOptions = (options = []) => ({
|
|
|
1436
1556
|
|
|
1437
1557
|
const _excluded$3 = ["options", "api", "placeholder"];
|
|
1438
1558
|
const {
|
|
1439
|
-
useOnChange: useOnChange$
|
|
1559
|
+
useOnChange: useOnChange$2
|
|
1440
1560
|
} = hooks;
|
|
1441
1561
|
const hasNestedOptions = options => Array.isArray(options) && options.some(item => Array.isArray(item == null ? void 0 : item.children) && item.children.length);
|
|
1442
1562
|
const createField = (Component, {
|
|
@@ -1472,7 +1592,7 @@ const createField = (Component, {
|
|
|
1472
1592
|
}, {
|
|
1473
1593
|
label: props.label || ''
|
|
1474
1594
|
}).trim();
|
|
1475
|
-
const render = useOnChange$
|
|
1595
|
+
const render = useOnChange$2(Object.assign({}, {
|
|
1476
1596
|
isPopup: true,
|
|
1477
1597
|
placeholder: resolvedPlaceholder
|
|
1478
1598
|
}, rest, {
|
|
@@ -1999,8 +2119,10 @@ const resolveFieldValueSchema = field => {
|
|
|
1999
2119
|
} else {
|
|
2000
2120
|
schema = _extends({}, schema);
|
|
2001
2121
|
}
|
|
2002
|
-
const
|
|
2003
|
-
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;
|
|
2004
2126
|
if (title && schema.title == null) {
|
|
2005
2127
|
schema.title = title;
|
|
2006
2128
|
}
|
|
@@ -2077,26 +2199,26 @@ const normalizeOptions = (options, {
|
|
|
2077
2199
|
}
|
|
2078
2200
|
const columnNames = (_columns || []).map(item => item == null ? void 0 : item.name).filter(Boolean);
|
|
2079
2201
|
return options.map(item => {
|
|
2080
|
-
var _item$
|
|
2081
|
-
const label =
|
|
2202
|
+
var _item$value;
|
|
2203
|
+
const label = trimLocaleText(item == null ? void 0 : item.label);
|
|
2082
2204
|
let value = String((_item$value = item == null ? void 0 : item.value) != null ? _item$value : '').trim();
|
|
2083
2205
|
if (!value && label) {
|
|
2084
|
-
value = label;
|
|
2206
|
+
value = localeTextToValue(label);
|
|
2085
2207
|
}
|
|
2086
2208
|
const next = {
|
|
2087
2209
|
label,
|
|
2088
2210
|
value,
|
|
2089
|
-
description:
|
|
2211
|
+
description: trimLocaleText(item == null ? void 0 : item.description)
|
|
2090
2212
|
};
|
|
2091
2213
|
columnNames.forEach(name => {
|
|
2092
2214
|
var _item$name;
|
|
2093
2215
|
next[name] = (_item$name = item == null ? void 0 : item[name]) != null ? _item$name : '';
|
|
2094
2216
|
});
|
|
2095
|
-
if (!
|
|
2217
|
+
if (!hasLocaleText(next.label) && columnNames[0] && String(next[columnNames[0]] || '').trim()) {
|
|
2096
2218
|
next.label = String(next[columnNames[0]]).trim();
|
|
2097
2219
|
}
|
|
2098
|
-
if (!String(next.value).trim() &&
|
|
2099
|
-
next.value = next.label;
|
|
2220
|
+
if (!String(next.value).trim() && hasLocaleText(next.label)) {
|
|
2221
|
+
next.value = localeTextToValue(next.label);
|
|
2100
2222
|
}
|
|
2101
2223
|
if (_allowChildren && Array.isArray(item == null ? void 0 : item.children) && item.children.length) {
|
|
2102
2224
|
next.children = normalizeOptions(item.children, {
|
|
@@ -2407,6 +2529,102 @@ const formValuesToField = (values, existingField = {}) => {
|
|
|
2407
2529
|
};
|
|
2408
2530
|
};
|
|
2409
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
|
+
|
|
2410
2628
|
const {
|
|
2411
2629
|
Text: Text$4
|
|
2412
2630
|
} = Typography;
|
|
@@ -2437,8 +2655,10 @@ const FieldRow = ({
|
|
|
2437
2655
|
onMove
|
|
2438
2656
|
}) => {
|
|
2439
2657
|
const {
|
|
2440
|
-
formatMessage
|
|
2658
|
+
formatMessage,
|
|
2659
|
+
locale
|
|
2441
2660
|
} = useIntl();
|
|
2661
|
+
const languages = useLocaleTextLanguages();
|
|
2442
2662
|
const definition = getFieldDefinition(field.type);
|
|
2443
2663
|
return /*#__PURE__*/jsxs("div", {
|
|
2444
2664
|
className: style['field-row'],
|
|
@@ -2453,7 +2673,7 @@ const FieldRow = ({
|
|
|
2453
2673
|
children: [/*#__PURE__*/jsx(Text$4, {
|
|
2454
2674
|
strong: true,
|
|
2455
2675
|
ellipsis: true,
|
|
2456
|
-
children: field.label || formatMessage({
|
|
2676
|
+
children: resolveLocaleText(field.label, locale, languages) || formatMessage({
|
|
2457
2677
|
id: 'untitledField'
|
|
2458
2678
|
})
|
|
2459
2679
|
}), /*#__PURE__*/jsx(Tag, {
|
|
@@ -2594,8 +2814,11 @@ const BlockListPanel = ({
|
|
|
2594
2814
|
extraToolbar
|
|
2595
2815
|
}) => {
|
|
2596
2816
|
const {
|
|
2597
|
-
formatMessage
|
|
2817
|
+
formatMessage,
|
|
2818
|
+
locale
|
|
2598
2819
|
} = useIntl();
|
|
2820
|
+
const languages = useLocaleTextLanguages();
|
|
2821
|
+
const text = value => resolveLocaleText(value, locale, languages);
|
|
2599
2822
|
const [addMenuOpen, setAddMenuOpen] = useState(false);
|
|
2600
2823
|
const [addFieldMenuId, setAddFieldMenuId] = useState(null);
|
|
2601
2824
|
const keepAddFieldMenuOpenRef = useRef(false);
|
|
@@ -2841,7 +3064,7 @@ const BlockListPanel = ({
|
|
|
2841
3064
|
children: stepIndex + 1
|
|
2842
3065
|
}), /*#__PURE__*/jsx(Text$3, {
|
|
2843
3066
|
strong: true,
|
|
2844
|
-
children: step.title || formatMessage({
|
|
3067
|
+
children: text(step.title) || formatMessage({
|
|
2845
3068
|
id: 'untitledStep'
|
|
2846
3069
|
}, {
|
|
2847
3070
|
index: stepIndex + 1
|
|
@@ -2967,7 +3190,7 @@ const BlockListPanel = ({
|
|
|
2967
3190
|
children: optionIndex + 1
|
|
2968
3191
|
}), /*#__PURE__*/jsx(Text$3, {
|
|
2969
3192
|
strong: true,
|
|
2970
|
-
children: option.title || formatMessage({
|
|
3193
|
+
children: text(option.title) || formatMessage({
|
|
2971
3194
|
id: 'choiceOptionFallback'
|
|
2972
3195
|
}, {
|
|
2973
3196
|
index: optionIndex + 1
|
|
@@ -3097,7 +3320,7 @@ const BlockListPanel = ({
|
|
|
3097
3320
|
strong: true,
|
|
3098
3321
|
ellipsis: true,
|
|
3099
3322
|
className: style['block-title'],
|
|
3100
|
-
children: block.title || block.label || block.name || formatMessage({
|
|
3323
|
+
children: text(block.title) || text(block.label) || block.name || formatMessage({
|
|
3101
3324
|
id: 'untitledBlock'
|
|
3102
3325
|
})
|
|
3103
3326
|
}), /*#__PURE__*/jsx("span", {
|
|
@@ -3214,7 +3437,7 @@ const BlockConfigFields = ({
|
|
|
3214
3437
|
const list = [];
|
|
3215
3438
|
const isListKind = kind === 'list' || kind === 'tableList' || kind === 'editableList';
|
|
3216
3439
|
if (kind === 'formInfo' || kind === 'list' || kind === 'tableList' || kind === 'editableList' || kind === 'object') {
|
|
3217
|
-
list.push(/*#__PURE__*/jsx(
|
|
3440
|
+
list.push(/*#__PURE__*/jsx(LocaleInput, {
|
|
3218
3441
|
name: "title",
|
|
3219
3442
|
label: formatMessage({
|
|
3220
3443
|
id: 'blockTitle'
|
|
@@ -3222,7 +3445,7 @@ const BlockConfigFields = ({
|
|
|
3222
3445
|
placeholder: formatMessage({
|
|
3223
3446
|
id: 'blockTitlePlaceholder'
|
|
3224
3447
|
})
|
|
3225
|
-
}, "title"), kind === 'formInfo' ? /*#__PURE__*/jsx(
|
|
3448
|
+
}, "title"), kind === 'formInfo' ? /*#__PURE__*/jsx(LocaleInput, {
|
|
3226
3449
|
name: "subtitle",
|
|
3227
3450
|
label: formatMessage({
|
|
3228
3451
|
id: 'blockSubtitle'
|
|
@@ -3268,7 +3491,7 @@ const BlockConfigFields = ({
|
|
|
3268
3491
|
children: formatMessage({
|
|
3269
3492
|
id: 'blockImportant'
|
|
3270
3493
|
})
|
|
3271
|
-
}, "important") : null, isListKind ? /*#__PURE__*/jsx(
|
|
3494
|
+
}, "important") : null, isListKind ? /*#__PURE__*/jsx(LocaleInput, {
|
|
3272
3495
|
name: "addText",
|
|
3273
3496
|
label: formatMessage({
|
|
3274
3497
|
id: 'blockAddText'
|
|
@@ -3302,7 +3525,7 @@ const BlockConfigFields = ({
|
|
|
3302
3525
|
}, "minLength") : null);
|
|
3303
3526
|
}
|
|
3304
3527
|
if (kind === 'choice') {
|
|
3305
|
-
list.push(/*#__PURE__*/jsx(
|
|
3528
|
+
list.push(/*#__PURE__*/jsx(LocaleInput, {
|
|
3306
3529
|
name: "title",
|
|
3307
3530
|
label: formatMessage({
|
|
3308
3531
|
id: 'blockTitle'
|
|
@@ -3388,7 +3611,7 @@ const BlockConfigFields = ({
|
|
|
3388
3611
|
placeholder: formatMessage({
|
|
3389
3612
|
id: 'fieldNamePlaceholder'
|
|
3390
3613
|
})
|
|
3391
|
-
}, "name"), /*#__PURE__*/jsx(
|
|
3614
|
+
}, "name"), /*#__PURE__*/jsx(LocaleInput, {
|
|
3392
3615
|
name: "label",
|
|
3393
3616
|
label: formatMessage({
|
|
3394
3617
|
id: 'fieldLabel'
|
|
@@ -3404,7 +3627,7 @@ const BlockConfigFields = ({
|
|
|
3404
3627
|
}),
|
|
3405
3628
|
rule: "REQ",
|
|
3406
3629
|
options: fieldTypeOptions
|
|
3407
|
-
}, "fieldType"), /*#__PURE__*/jsx(
|
|
3630
|
+
}, "fieldType"), /*#__PURE__*/jsx(LocaleInput, {
|
|
3408
3631
|
name: "addText",
|
|
3409
3632
|
label: formatMessage({
|
|
3410
3633
|
id: 'blockAddText'
|
|
@@ -3415,7 +3638,7 @@ const BlockConfigFields = ({
|
|
|
3415
3638
|
}, "addText"));
|
|
3416
3639
|
}
|
|
3417
3640
|
if (kind === 'steps') {
|
|
3418
|
-
list.push(/*#__PURE__*/jsx(
|
|
3641
|
+
list.push(/*#__PURE__*/jsx(LocaleInput, {
|
|
3419
3642
|
name: "title",
|
|
3420
3643
|
label: formatMessage({
|
|
3421
3644
|
id: 'blockTitle'
|
|
@@ -3423,7 +3646,7 @@ const BlockConfigFields = ({
|
|
|
3423
3646
|
placeholder: formatMessage({
|
|
3424
3647
|
id: 'blockTitlePlaceholder'
|
|
3425
3648
|
})
|
|
3426
|
-
}, "title"), /*#__PURE__*/jsx(
|
|
3649
|
+
}, "title"), /*#__PURE__*/jsx(LocaleInput, {
|
|
3427
3650
|
name: "subtitle",
|
|
3428
3651
|
label: formatMessage({
|
|
3429
3652
|
id: 'blockSubtitle'
|
|
@@ -3547,7 +3770,7 @@ const StepEditorModal = ({
|
|
|
3547
3770
|
}),
|
|
3548
3771
|
children: /*#__PURE__*/jsx(FormInfo, {
|
|
3549
3772
|
column: 1,
|
|
3550
|
-
list: [/*#__PURE__*/jsx(
|
|
3773
|
+
list: [/*#__PURE__*/jsx(LocaleInput, {
|
|
3551
3774
|
name: "title",
|
|
3552
3775
|
label: formatMessage({
|
|
3553
3776
|
id: 'stepTitle'
|
|
@@ -3607,7 +3830,7 @@ const ChoiceOptionEditorModal = ({
|
|
|
3607
3830
|
}),
|
|
3608
3831
|
children: /*#__PURE__*/jsx(FormInfo, {
|
|
3609
3832
|
column: 1,
|
|
3610
|
-
list: [/*#__PURE__*/jsx(
|
|
3833
|
+
list: [/*#__PURE__*/jsx(LocaleInput, {
|
|
3611
3834
|
name: "title",
|
|
3612
3835
|
label: formatMessage({
|
|
3613
3836
|
id: 'choiceOptionTitle'
|
|
@@ -3706,28 +3929,29 @@ const EMPTY_OPTION = () => ({
|
|
|
3706
3929
|
});
|
|
3707
3930
|
|
|
3708
3931
|
/** value 为空或仍等于当前 label 时视为联动中,改 label 会同步 value */
|
|
3709
|
-
const isOptionValueLinked = (label, value) => {
|
|
3710
|
-
const labelText = label
|
|
3932
|
+
const isOptionValueLinked = (label, value, baseLanguage) => {
|
|
3933
|
+
const labelText = localeTextToValue(label, baseLanguage);
|
|
3711
3934
|
const valueText = value == null ? '' : String(value);
|
|
3712
3935
|
return valueText === '' || valueText === labelText;
|
|
3713
3936
|
};
|
|
3714
|
-
const patchOptionLabelChange = (item, nextLabel) => {
|
|
3937
|
+
const patchOptionLabelChange = (item, nextLabel, baseLanguage) => {
|
|
3715
3938
|
const patch = {
|
|
3716
3939
|
label: nextLabel
|
|
3717
3940
|
};
|
|
3718
|
-
if (isOptionValueLinked(item.label, item.value)) {
|
|
3719
|
-
patch.value = nextLabel;
|
|
3941
|
+
if (isOptionValueLinked(item.label, item.value, baseLanguage)) {
|
|
3942
|
+
patch.value = localeTextToValue(nextLabel, baseLanguage);
|
|
3720
3943
|
}
|
|
3721
3944
|
return patch;
|
|
3722
3945
|
};
|
|
3723
|
-
const trimOptionLabelValue = item => {
|
|
3724
|
-
var _item$
|
|
3725
|
-
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);
|
|
3726
3950
|
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 ===
|
|
3951
|
+
const linked = isOptionValueLinked(item == null ? void 0 : item.label, item == null ? void 0 : item.value, baseLanguage) || rawValue === '' || rawValue === labelValue;
|
|
3728
3952
|
return {
|
|
3729
3953
|
label,
|
|
3730
|
-
value: linked ?
|
|
3954
|
+
value: linked ? labelValue : rawValue
|
|
3731
3955
|
};
|
|
3732
3956
|
};
|
|
3733
3957
|
const createEmptyTableRow = columns => {
|
|
@@ -3754,9 +3978,11 @@ const FlatOptionRows = ({
|
|
|
3754
3978
|
onChange,
|
|
3755
3979
|
allowDescription
|
|
3756
3980
|
}) => {
|
|
3981
|
+
var _useLocaleTextLanguag;
|
|
3757
3982
|
const {
|
|
3758
3983
|
formatMessage
|
|
3759
3984
|
} = useIntl();
|
|
3985
|
+
const baseLanguage = (_useLocaleTextLanguag = useLocaleTextLanguages()[0]) == null ? void 0 : _useLocaleTextLanguag.value;
|
|
3760
3986
|
const rows = list.length ? ensureOptionKeys(list) : [EMPTY_OPTION()];
|
|
3761
3987
|
const commit = next => onChange(next);
|
|
3762
3988
|
const updateItem = (index, patch) => {
|
|
@@ -3768,13 +3994,15 @@ const FlatOptionRows = ({
|
|
|
3768
3994
|
gap: 8,
|
|
3769
3995
|
align: "start",
|
|
3770
3996
|
className: style['options-row'],
|
|
3771
|
-
children: [/*#__PURE__*/jsx(
|
|
3997
|
+
children: [/*#__PURE__*/jsx(LocaleTextControl, {
|
|
3998
|
+
compact: true,
|
|
3999
|
+
className: style['options-locale-text'],
|
|
3772
4000
|
value: item.label,
|
|
3773
4001
|
placeholder: formatMessage({
|
|
3774
4002
|
id: 'optionLabelPlaceholder'
|
|
3775
4003
|
}),
|
|
3776
|
-
onChange:
|
|
3777
|
-
onBlur: () => updateItem(index, trimOptionLabelValue(item))
|
|
4004
|
+
onChange: nextLabel => updateItem(index, patchOptionLabelChange(item, nextLabel, baseLanguage)),
|
|
4005
|
+
onBlur: () => updateItem(index, trimOptionLabelValue(item, baseLanguage))
|
|
3778
4006
|
}), /*#__PURE__*/jsx(Input$1, {
|
|
3779
4007
|
value: item.value,
|
|
3780
4008
|
placeholder: formatMessage({
|
|
@@ -3789,20 +4017,19 @@ const FlatOptionRows = ({
|
|
|
3789
4017
|
value: String((_item$value2 = item.value) != null ? _item$value2 : '').trim()
|
|
3790
4018
|
});
|
|
3791
4019
|
}
|
|
3792
|
-
}), allowDescription ? /*#__PURE__*/jsx(
|
|
4020
|
+
}), allowDescription ? /*#__PURE__*/jsx(LocaleTextControl, {
|
|
4021
|
+
compact: true,
|
|
4022
|
+
className: style['options-locale-text'],
|
|
3793
4023
|
value: item.description || '',
|
|
3794
4024
|
placeholder: formatMessage({
|
|
3795
4025
|
id: 'optionDescPlaceholder'
|
|
3796
4026
|
}),
|
|
3797
|
-
onChange:
|
|
3798
|
-
description
|
|
4027
|
+
onChange: description => updateItem(index, {
|
|
4028
|
+
description
|
|
3799
4029
|
}),
|
|
3800
|
-
onBlur: () => {
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
description: String((_item$description = item.description) != null ? _item$description : '').trim()
|
|
3804
|
-
});
|
|
3805
|
-
}
|
|
4030
|
+
onBlur: () => updateItem(index, {
|
|
4031
|
+
description: trimLocaleText(item.description, baseLanguage)
|
|
4032
|
+
})
|
|
3806
4033
|
}) : null, /*#__PURE__*/jsx(Button, {
|
|
3807
4034
|
type: "text",
|
|
3808
4035
|
danger: true,
|
|
@@ -3836,9 +4063,11 @@ const TreeOptionNode = ({
|
|
|
3836
4063
|
depth,
|
|
3837
4064
|
maxDepth: _maxDepth = 4
|
|
3838
4065
|
}) => {
|
|
4066
|
+
var _useLocaleTextLanguag2;
|
|
3839
4067
|
const {
|
|
3840
4068
|
formatMessage
|
|
3841
4069
|
} = useIntl();
|
|
4070
|
+
const baseLanguage = (_useLocaleTextLanguag2 = useLocaleTextLanguages()[0]) == null ? void 0 : _useLocaleTextLanguag2.value;
|
|
3842
4071
|
const children = Array.isArray(item.children) ? item.children : [];
|
|
3843
4072
|
const canAddChild = depth < _maxDepth;
|
|
3844
4073
|
const updateSelf = patch => {
|
|
@@ -3870,13 +4099,14 @@ const TreeOptionNode = ({
|
|
|
3870
4099
|
className: style['tree-option-row'],
|
|
3871
4100
|
children: [/*#__PURE__*/jsxs("div", {
|
|
3872
4101
|
className: style['tree-option-fields'],
|
|
3873
|
-
children: [/*#__PURE__*/jsx(
|
|
4102
|
+
children: [/*#__PURE__*/jsx(LocaleTextControl, {
|
|
4103
|
+
compact: true,
|
|
3874
4104
|
value: item.label,
|
|
3875
4105
|
placeholder: formatMessage({
|
|
3876
4106
|
id: 'optionLabelPlaceholder'
|
|
3877
4107
|
}),
|
|
3878
|
-
onChange:
|
|
3879
|
-
onBlur: () => updateSelf(trimOptionLabelValue(item))
|
|
4108
|
+
onChange: nextLabel => updateSelf(patchOptionLabelChange(item, nextLabel, baseLanguage)),
|
|
4109
|
+
onBlur: () => updateSelf(trimOptionLabelValue(item, baseLanguage))
|
|
3880
4110
|
}), /*#__PURE__*/jsx(Input$1, {
|
|
3881
4111
|
value: item.value,
|
|
3882
4112
|
placeholder: formatMessage({
|
|
@@ -3891,20 +4121,18 @@ const TreeOptionNode = ({
|
|
|
3891
4121
|
value: String((_item$value3 = item.value) != null ? _item$value3 : '').trim()
|
|
3892
4122
|
});
|
|
3893
4123
|
}
|
|
3894
|
-
}), allowDescription ? /*#__PURE__*/jsx(
|
|
4124
|
+
}), allowDescription ? /*#__PURE__*/jsx(LocaleTextControl, {
|
|
4125
|
+
compact: true,
|
|
3895
4126
|
value: item.description || '',
|
|
3896
4127
|
placeholder: formatMessage({
|
|
3897
4128
|
id: 'optionDescPlaceholder'
|
|
3898
4129
|
}),
|
|
3899
|
-
onChange:
|
|
3900
|
-
description
|
|
4130
|
+
onChange: description => updateSelf({
|
|
4131
|
+
description
|
|
3901
4132
|
}),
|
|
3902
|
-
onBlur: () => {
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
description: String((_item$description2 = item.description) != null ? _item$description2 : '').trim()
|
|
3906
|
-
});
|
|
3907
|
-
}
|
|
4133
|
+
onBlur: () => updateSelf({
|
|
4134
|
+
description: trimLocaleText(item.description, baseLanguage)
|
|
4135
|
+
})
|
|
3908
4136
|
}) : null]
|
|
3909
4137
|
}), /*#__PURE__*/jsxs("div", {
|
|
3910
4138
|
className: style['tree-option-actions'],
|
|
@@ -4010,13 +4238,14 @@ const ColumnsEditor = ({
|
|
|
4010
4238
|
gap: 8,
|
|
4011
4239
|
align: "start",
|
|
4012
4240
|
className: style['options-row'],
|
|
4013
|
-
children: [/*#__PURE__*/jsx(
|
|
4241
|
+
children: [/*#__PURE__*/jsx(LocaleTextControl, {
|
|
4242
|
+
compact: true,
|
|
4243
|
+
className: style['options-locale-text'],
|
|
4014
4244
|
value: item.title || '',
|
|
4015
4245
|
placeholder: formatMessage({
|
|
4016
4246
|
id: 'columnTitlePlaceholder'
|
|
4017
4247
|
}),
|
|
4018
|
-
onChange:
|
|
4019
|
-
const title = e.target.value;
|
|
4248
|
+
onChange: title => {
|
|
4020
4249
|
const patch = {
|
|
4021
4250
|
title
|
|
4022
4251
|
};
|
|
@@ -4087,8 +4316,10 @@ const TableRowsEditor = ({
|
|
|
4087
4316
|
onChange
|
|
4088
4317
|
}) => {
|
|
4089
4318
|
const {
|
|
4090
|
-
formatMessage
|
|
4319
|
+
formatMessage,
|
|
4320
|
+
locale
|
|
4091
4321
|
} = useIntl();
|
|
4322
|
+
const languages = useLocaleTextLanguages();
|
|
4092
4323
|
const usableColumns = _columns.filter(column => (column == null ? void 0 : column.name) && String(column.name).trim());
|
|
4093
4324
|
const list = _value3.length ? _value3 : [createEmptyTableRow(usableColumns)];
|
|
4094
4325
|
const updateItem = (index, patch) => {
|
|
@@ -4160,13 +4391,15 @@ const TableRowsEditor = ({
|
|
|
4160
4391
|
onChange: e => updateItem(index, {
|
|
4161
4392
|
value: e.target.value
|
|
4162
4393
|
})
|
|
4163
|
-
}), /*#__PURE__*/jsx(
|
|
4394
|
+
}), /*#__PURE__*/jsx(LocaleTextControl, {
|
|
4395
|
+
compact: true,
|
|
4396
|
+
className: style['options-locale-text'],
|
|
4164
4397
|
value: item.label || '',
|
|
4165
4398
|
placeholder: formatMessage({
|
|
4166
4399
|
id: 'tableRowLabelPlaceholder'
|
|
4167
4400
|
}),
|
|
4168
|
-
onChange:
|
|
4169
|
-
label
|
|
4401
|
+
onChange: label => updateItem(index, {
|
|
4402
|
+
label
|
|
4170
4403
|
})
|
|
4171
4404
|
})]
|
|
4172
4405
|
}), /*#__PURE__*/jsx(Flex, {
|
|
@@ -4178,7 +4411,7 @@ const TableRowsEditor = ({
|
|
|
4178
4411
|
flex: 1
|
|
4179
4412
|
},
|
|
4180
4413
|
value: item[column.name] || '',
|
|
4181
|
-
placeholder: column.title || column.name,
|
|
4414
|
+
placeholder: resolveLocaleText(column.title, locale, languages) || column.name,
|
|
4182
4415
|
onChange: e => updateItem(index, {
|
|
4183
4416
|
[column.name]: e.target.value
|
|
4184
4417
|
})
|
|
@@ -4353,7 +4586,7 @@ const SuperSelectPropsEditor = ({
|
|
|
4353
4586
|
var _openApi$data2;
|
|
4354
4587
|
return !(openApi != null && (_openApi$data2 = openApi.data) != null && _openApi$data2.single);
|
|
4355
4588
|
}
|
|
4356
|
-
}, "maxLength"), /*#__PURE__*/jsx(
|
|
4589
|
+
}, "maxLength"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4357
4590
|
name: "placeholder",
|
|
4358
4591
|
label: formatMessage({
|
|
4359
4592
|
id: 'fieldPlaceholder'
|
|
@@ -4361,7 +4594,7 @@ const SuperSelectPropsEditor = ({
|
|
|
4361
4594
|
placeholder: formatMessage({
|
|
4362
4595
|
id: 'superSelectPlaceholderHint'
|
|
4363
4596
|
})
|
|
4364
|
-
}, "placeholder"), /*#__PURE__*/jsx(
|
|
4597
|
+
}, "placeholder"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4365
4598
|
name: "searchPlaceholder",
|
|
4366
4599
|
label: formatMessage({
|
|
4367
4600
|
id: 'superSelectSearchPlaceholder'
|
|
@@ -4417,7 +4650,7 @@ const buildPropsSchemaList = (schema, formatMessage) => (schema || []).filter(it
|
|
|
4417
4650
|
}, item.name);
|
|
4418
4651
|
});
|
|
4419
4652
|
const buildBuiltinList = (type, formatMessage) => {
|
|
4420
|
-
const placeholder = /*#__PURE__*/jsx(
|
|
4653
|
+
const placeholder = /*#__PURE__*/jsx(LocaleInput, {
|
|
4421
4654
|
name: "placeholder",
|
|
4422
4655
|
label: formatMessage({
|
|
4423
4656
|
id: 'fieldPlaceholder'
|
|
@@ -4600,7 +4833,7 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4600
4833
|
})
|
|
4601
4834
|
}, "showTime")];
|
|
4602
4835
|
case 'Switch':
|
|
4603
|
-
return [/*#__PURE__*/jsx(
|
|
4836
|
+
return [/*#__PURE__*/jsx(LocaleInput, {
|
|
4604
4837
|
name: "checkedChildren",
|
|
4605
4838
|
label: formatMessage({
|
|
4606
4839
|
id: 'propSwitchOnText'
|
|
@@ -4608,7 +4841,7 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4608
4841
|
placeholder: formatMessage({
|
|
4609
4842
|
id: 'propSwitchOnTextHint'
|
|
4610
4843
|
})
|
|
4611
|
-
}, "checkedChildren"), /*#__PURE__*/jsx(
|
|
4844
|
+
}, "checkedChildren"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4612
4845
|
name: "unCheckedChildren",
|
|
4613
4846
|
label: formatMessage({
|
|
4614
4847
|
id: 'propSwitchOffText'
|
|
@@ -4752,7 +4985,7 @@ const FieldConfigFields = ({
|
|
|
4752
4985
|
placeholder: formatMessage({
|
|
4753
4986
|
id: 'fieldNamePlaceholder'
|
|
4754
4987
|
})
|
|
4755
|
-
}, "name"), /*#__PURE__*/jsx(
|
|
4988
|
+
}, "name"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4756
4989
|
name: "label",
|
|
4757
4990
|
label: formatMessage({
|
|
4758
4991
|
id: 'fieldLabel'
|
|
@@ -4761,7 +4994,7 @@ const FieldConfigFields = ({
|
|
|
4761
4994
|
placeholder: formatMessage({
|
|
4762
4995
|
id: 'fieldLabelPlaceholder'
|
|
4763
4996
|
})
|
|
4764
|
-
}, "label"), /*#__PURE__*/jsx(
|
|
4997
|
+
}, "label"), /*#__PURE__*/jsx(LocaleInput, {
|
|
4765
4998
|
name: "tips",
|
|
4766
4999
|
label: formatMessage({
|
|
4767
5000
|
id: 'fieldTips'
|
|
@@ -4769,7 +5002,7 @@ const FieldConfigFields = ({
|
|
|
4769
5002
|
placeholder: formatMessage({
|
|
4770
5003
|
id: 'fieldTipsPlaceholder'
|
|
4771
5004
|
})
|
|
4772
|
-
}, "tips"), /*#__PURE__*/jsx(
|
|
5005
|
+
}, "tips"), /*#__PURE__*/jsx(LocaleTextArea, {
|
|
4773
5006
|
name: "description",
|
|
4774
5007
|
label: formatMessage({
|
|
4775
5008
|
id: 'fieldDescription'
|
|
@@ -5002,7 +5235,7 @@ const FormActionsEditor = ({
|
|
|
5002
5235
|
id: 'formActionsShowSubmit'
|
|
5003
5236
|
}),
|
|
5004
5237
|
className: style['form-actions-switch-field']
|
|
5005
|
-
}, "showSubmit"), /*#__PURE__*/jsx(
|
|
5238
|
+
}, "showSubmit"), /*#__PURE__*/jsx(LocaleInput, {
|
|
5006
5239
|
name: "submitText",
|
|
5007
5240
|
label: formatMessage({
|
|
5008
5241
|
id: 'formActionsSubmitText'
|
|
@@ -5025,7 +5258,7 @@ const FormActionsEditor = ({
|
|
|
5025
5258
|
id: 'formActionsShowReset'
|
|
5026
5259
|
}),
|
|
5027
5260
|
className: style['form-actions-switch-field']
|
|
5028
|
-
}, "showReset"), /*#__PURE__*/jsx(
|
|
5261
|
+
}, "showReset"), /*#__PURE__*/jsx(LocaleInput, {
|
|
5029
5262
|
name: "resetText",
|
|
5030
5263
|
label: formatMessage({
|
|
5031
5264
|
id: 'formActionsResetText'
|
|
@@ -5048,7 +5281,7 @@ const FormActionsEditor = ({
|
|
|
5048
5281
|
id: 'formActionsShowCancel'
|
|
5049
5282
|
}),
|
|
5050
5283
|
className: style['form-actions-switch-field']
|
|
5051
|
-
}, "showCancel"), /*#__PURE__*/jsx(
|
|
5284
|
+
}, "showCancel"), /*#__PURE__*/jsx(LocaleInput, {
|
|
5052
5285
|
name: "cancelText",
|
|
5053
5286
|
label: formatMessage({
|
|
5054
5287
|
id: 'formActionsCancelText'
|
|
@@ -5384,6 +5617,54 @@ const ChoiceBlock = ({
|
|
|
5384
5617
|
};
|
|
5385
5618
|
var ChoiceBlock$1 = ChoiceBlock;
|
|
5386
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
|
+
|
|
5387
5668
|
const buildLabelTips = tips => {
|
|
5388
5669
|
if (tips == null || !String(tips).trim()) {
|
|
5389
5670
|
return undefined;
|
|
@@ -5762,6 +6043,7 @@ const renderSchemaContent = (schema, {
|
|
|
5762
6043
|
}
|
|
5763
6044
|
const formClassName = [style['schema-form'], _formProps.className, className].filter(Boolean).join(' ');
|
|
5764
6045
|
return /*#__PURE__*/createElement(Form, _extends({}, _formProps, {
|
|
6046
|
+
rules: _extends({}, createLocalizedRules(formatMessage), _formProps.rules),
|
|
5765
6047
|
className: formClassName
|
|
5766
6048
|
}), /*#__PURE__*/createElement('div', {
|
|
5767
6049
|
className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
|
|
@@ -5861,14 +6143,15 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5861
6143
|
bodyClassName,
|
|
5862
6144
|
footerClassName,
|
|
5863
6145
|
buttonFooter = false,
|
|
5864
|
-
buttonFooterProps
|
|
6146
|
+
buttonFooterProps,
|
|
6147
|
+
languages
|
|
5865
6148
|
} = props;
|
|
5866
6149
|
const {
|
|
5867
6150
|
formatMessage,
|
|
5868
6151
|
locale
|
|
5869
6152
|
} = useIntl();
|
|
5870
6153
|
const isMobile = useIsMobile();
|
|
5871
|
-
const normalized = normalizeSchema(schema);
|
|
6154
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
5872
6155
|
if (!hasRenderableContent(normalized)) {
|
|
5873
6156
|
return null;
|
|
5874
6157
|
}
|
|
@@ -5926,14 +6209,15 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5926
6209
|
bodyClassName,
|
|
5927
6210
|
footerClassName,
|
|
5928
6211
|
buttonFooter = false,
|
|
5929
|
-
buttonFooterProps
|
|
6212
|
+
buttonFooterProps,
|
|
6213
|
+
languages
|
|
5930
6214
|
} = props;
|
|
5931
6215
|
const {
|
|
5932
6216
|
formatMessage,
|
|
5933
6217
|
locale
|
|
5934
6218
|
} = useIntl();
|
|
5935
6219
|
const isMobile = useIsMobile();
|
|
5936
|
-
const normalized = normalizeSchema(schema);
|
|
6220
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
5937
6221
|
if (!hasRenderableContent(normalized)) {
|
|
5938
6222
|
return null;
|
|
5939
6223
|
}
|
|
@@ -5979,7 +6263,8 @@ const FormCreator = withLocale$1(({
|
|
|
5979
6263
|
className,
|
|
5980
6264
|
formProps,
|
|
5981
6265
|
renderModal,
|
|
5982
|
-
extraToolbar
|
|
6266
|
+
extraToolbar,
|
|
6267
|
+
languages
|
|
5983
6268
|
}) => {
|
|
5984
6269
|
const {
|
|
5985
6270
|
formatMessage,
|
|
@@ -6277,94 +6562,98 @@ const FormCreator = withLocale$1(({
|
|
|
6277
6562
|
const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
|
|
6278
6563
|
schema
|
|
6279
6564
|
}) : 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
|
-
|
|
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
|
+
})
|
|
6318
6607
|
})
|
|
6319
6608
|
})
|
|
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
|
-
})
|
|
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
|
+
})
|
|
6368
6657
|
});
|
|
6369
6658
|
});
|
|
6370
6659
|
var FormCreator$1 = FormCreator;
|
|
@@ -6867,9 +7156,12 @@ const formatByValueSchema = (value, schema, ctx = {}) => {
|
|
|
6867
7156
|
}
|
|
6868
7157
|
return String(value);
|
|
6869
7158
|
};
|
|
6870
|
-
const formatFieldDisplayValue = (
|
|
6871
|
-
formatMessage
|
|
7159
|
+
const formatFieldDisplayValue = (rawField, value, {
|
|
7160
|
+
formatMessage,
|
|
7161
|
+
locale,
|
|
7162
|
+
languages
|
|
6872
7163
|
} = {}) => {
|
|
7164
|
+
const field = localizeSchema(rawField, locale, languages);
|
|
6873
7165
|
const emptyText = (formatMessage == null ? void 0 : formatMessage({
|
|
6874
7166
|
id: 'schemaContentEmptyValue'
|
|
6875
7167
|
})) || '-';
|
|
@@ -7215,9 +7507,10 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
|
7215
7507
|
* - 扩展字段:registerField / preset 的 valueSchema;缺省 { type: 'string' }
|
|
7216
7508
|
* - hidden 字段仍进入 data schema(可提交)
|
|
7217
7509
|
* - choice:single → oneOf,multiple → anyOf
|
|
7510
|
+
* - options.locale / options.languages:多语言文案取该语言,取不到按 languages 顺序回退(未传为 zh-CN → en-US)
|
|
7218
7511
|
*/
|
|
7219
7512
|
const schemaToDataSchema = (schema, options = {}) => {
|
|
7220
|
-
const normalized = normalizeSchema(schema || {});
|
|
7513
|
+
const normalized = normalizeSchema(localizeSchema(schema || {}, options.locale, options.languages));
|
|
7221
7514
|
const layer = createObjectLayer();
|
|
7222
7515
|
walkBlocks(normalized.blocks, layer, 0);
|
|
7223
7516
|
const root = finalizeObjectSchema(layer, {
|
|
@@ -7407,13 +7700,15 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7407
7700
|
const SchemaContentInnerView = ({
|
|
7408
7701
|
schema,
|
|
7409
7702
|
data,
|
|
7410
|
-
className
|
|
7703
|
+
className,
|
|
7704
|
+
languages
|
|
7411
7705
|
}) => {
|
|
7412
7706
|
const {
|
|
7413
|
-
formatMessage
|
|
7707
|
+
formatMessage,
|
|
7708
|
+
locale
|
|
7414
7709
|
} = useIntl();
|
|
7415
7710
|
const isMobile = useIsMobile();
|
|
7416
|
-
const normalized = normalizeSchema(schema);
|
|
7711
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
7417
7712
|
const children = renderBlockList(normalized.blocks, data || {}, {
|
|
7418
7713
|
formatMessage,
|
|
7419
7714
|
isMobile,
|
|
@@ -7437,12 +7732,14 @@ const SchemaContent = withLocale$1(({
|
|
|
7437
7732
|
schema,
|
|
7438
7733
|
data,
|
|
7439
7734
|
className,
|
|
7440
|
-
empty
|
|
7735
|
+
empty,
|
|
7736
|
+
languages
|
|
7441
7737
|
}) => {
|
|
7442
7738
|
const {
|
|
7443
|
-
formatMessage
|
|
7739
|
+
formatMessage,
|
|
7740
|
+
locale
|
|
7444
7741
|
} = useIntl();
|
|
7445
|
-
const normalized = normalizeSchema(schema);
|
|
7742
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
7446
7743
|
const emptyNode = empty !== undefined ? empty : /*#__PURE__*/jsx(Empty, {
|
|
7447
7744
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
7448
7745
|
description: formatMessage({
|
|
@@ -7462,5 +7759,5 @@ const SchemaContent = withLocale$1(({
|
|
|
7462
7759
|
});
|
|
7463
7760
|
var SchemaContent$1 = SchemaContent;
|
|
7464
7761
|
|
|
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 };
|
|
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 };
|
|
7466
7763
|
//# sourceMappingURL=index.modern.js.map
|