@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.js
CHANGED
|
@@ -23,7 +23,7 @@ var SelectList__default = /*#__PURE__*/_interopDefaultLegacy(SelectList);
|
|
|
23
23
|
var FormInfo__default = /*#__PURE__*/_interopDefaultLegacy(FormInfo);
|
|
24
24
|
var InfoPage__default = /*#__PURE__*/_interopDefaultLegacy(InfoPage);
|
|
25
25
|
|
|
26
|
-
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"};
|
|
26
|
+
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"};
|
|
27
27
|
|
|
28
28
|
const locale$1 = {
|
|
29
29
|
addField: '添加填写项',
|
|
@@ -265,7 +265,13 @@ const locale$1 = {
|
|
|
265
265
|
schemaContentNo: '否',
|
|
266
266
|
schemaContentItemIndex: '第 {index} 项',
|
|
267
267
|
schemaContentUntilToday: '至今',
|
|
268
|
-
schemaContentPasswordMasked: '••••••'
|
|
268
|
+
schemaContentPasswordMasked: '••••••',
|
|
269
|
+
ruleErrorTEL: '请输入有效的手机号',
|
|
270
|
+
ruleErrorEMAIL: '请输入有效的邮箱',
|
|
271
|
+
ruleErrorLenEqual: '%s长度必须等于{end}',
|
|
272
|
+
ruleErrorLenMin: '%s长度必须大于{start}',
|
|
273
|
+
ruleErrorLenMax: '%s长度必须小于{end}',
|
|
274
|
+
localeTextFallback: '留空时使用{language}'
|
|
269
275
|
};
|
|
270
276
|
var defaultLocale = locale$1;
|
|
271
277
|
|
|
@@ -509,7 +515,13 @@ const locale = {
|
|
|
509
515
|
schemaContentNo: 'No',
|
|
510
516
|
schemaContentItemIndex: 'Item {index}',
|
|
511
517
|
schemaContentUntilToday: 'Present',
|
|
512
|
-
schemaContentPasswordMasked: '••••••'
|
|
518
|
+
schemaContentPasswordMasked: '••••••',
|
|
519
|
+
ruleErrorTEL: 'Please enter a valid mobile number',
|
|
520
|
+
ruleErrorEMAIL: 'Please enter a valid email address',
|
|
521
|
+
ruleErrorLenEqual: '%s must be exactly {end} characters',
|
|
522
|
+
ruleErrorLenMin: '%s must be at least {start} characters',
|
|
523
|
+
ruleErrorLenMax: '%s must be at most {end} characters',
|
|
524
|
+
localeTextFallback: 'Falls back to {language} when empty'
|
|
513
525
|
};
|
|
514
526
|
var enUS = locale;
|
|
515
527
|
|
|
@@ -523,6 +535,115 @@ const withLocale = reactIntl.createWithIntlProvider({
|
|
|
523
535
|
});
|
|
524
536
|
var withLocale$1 = withLocale;
|
|
525
537
|
|
|
538
|
+
/** 未传 languages 时,多语言文案按此顺序回退 */
|
|
539
|
+
const DEFAULT_FALLBACK_LANGUAGES = ['zh-CN', 'en-US'];
|
|
540
|
+
const LOCALE_KEY = /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/;
|
|
541
|
+
const isPlainObject = value => {
|
|
542
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
const proto = Object.getPrototypeOf(value);
|
|
546
|
+
return proto === Object.prototype || proto === null;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
/** 多语言文案:键全为语言代码、值全为字符串,如 { 'zh-CN': '姓名', 'en-US': 'Name' } */
|
|
550
|
+
const isLocaleText = value => {
|
|
551
|
+
if (!isPlainObject(value)) {
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
const keys = Object.keys(value);
|
|
555
|
+
return keys.length > 0 && keys.every(key => LOCALE_KEY.test(key) && (value[key] == null || typeof value[key] === 'string'));
|
|
556
|
+
};
|
|
557
|
+
const hasText = value => typeof value === 'string' && value.trim() !== '';
|
|
558
|
+
|
|
559
|
+
/** 规范调用方传入的语言列表 [{ value, label }],丢弃无 value 的项 */
|
|
560
|
+
const normalizeLanguages = languages => (Array.isArray(languages) ? languages : []).filter(item => item && typeof item.value === 'string' && item.value).map(item => ({
|
|
561
|
+
value: item.value,
|
|
562
|
+
label: item.label || item.value
|
|
563
|
+
}));
|
|
564
|
+
const getFallbackLanguages = languages => {
|
|
565
|
+
const list = normalizeLanguages(languages);
|
|
566
|
+
return list.length ? list.map(item => item.value) : DEFAULT_FALLBACK_LANGUAGES;
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
/** 普通字符串原样返回;多语言按 locale → languages 顺序(未传为 zh-CN → en-US)取第一个有内容的 */
|
|
570
|
+
const resolveLocaleText = (value, locale, languages) => {
|
|
571
|
+
if (!isLocaleText(value)) {
|
|
572
|
+
return value;
|
|
573
|
+
}
|
|
574
|
+
const language = [locale, ...getFallbackLanguages(languages)].find(key => key && hasText(value[key]));
|
|
575
|
+
return language ? value[language] : '';
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
/** 深度解析 schema(或任意片段)中的多语言文案,返回新对象 */
|
|
579
|
+
const localizeSchema = (value, locale, languages) => {
|
|
580
|
+
if (Array.isArray(value)) {
|
|
581
|
+
return value.map(item => localizeSchema(item, locale, languages));
|
|
582
|
+
}
|
|
583
|
+
if (isLocaleText(value)) {
|
|
584
|
+
return resolveLocaleText(value, locale, languages);
|
|
585
|
+
}
|
|
586
|
+
if (!isPlainObject(value)) {
|
|
587
|
+
return value;
|
|
588
|
+
}
|
|
589
|
+
return Object.keys(value).reduce((result, key) => {
|
|
590
|
+
result[key] = localizeSchema(value[key], locale, languages);
|
|
591
|
+
return result;
|
|
592
|
+
}, {});
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/** 取某个语言的原始输入值;普通字符串视为基础语言 */
|
|
596
|
+
const getLocaleTextValue = (value, language, baseLanguage) => {
|
|
597
|
+
if (isLocaleText(value)) {
|
|
598
|
+
return value[language] || '';
|
|
599
|
+
}
|
|
600
|
+
if (value == null || typeof value === 'object') {
|
|
601
|
+
return '';
|
|
602
|
+
}
|
|
603
|
+
return language === baseLanguage ? String(value) : '';
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
/** 只有基础语言时存为字符串,保持与单语言 schema 兼容 */
|
|
607
|
+
const toLocaleText = (map = {}, baseLanguage) => {
|
|
608
|
+
const entries = Object.keys(map).filter(key => hasText(map[key])).map(key => [key, map[key]]);
|
|
609
|
+
if (!entries.length) {
|
|
610
|
+
return '';
|
|
611
|
+
}
|
|
612
|
+
if (entries.length === 1 && entries[0][0] === baseLanguage) {
|
|
613
|
+
return entries[0][1];
|
|
614
|
+
}
|
|
615
|
+
return Object.fromEntries(entries);
|
|
616
|
+
};
|
|
617
|
+
const setLocaleTextValue = (value, language, text, baseLanguage) => {
|
|
618
|
+
const map = isLocaleText(value) ? {
|
|
619
|
+
...value
|
|
620
|
+
} : {
|
|
621
|
+
[baseLanguage]: getLocaleTextValue(value, baseLanguage, baseLanguage)
|
|
622
|
+
};
|
|
623
|
+
map[language] = text;
|
|
624
|
+
return toLocaleText(map, baseLanguage);
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
/** 判断文案(字符串或多语言)是否有内容 */
|
|
628
|
+
const hasLocaleText = value => isLocaleText(value) ? Object.values(value).some(hasText) : value != null && String(value).trim() !== '';
|
|
629
|
+
|
|
630
|
+
/** 去除首尾空白;多语言文案逐项处理 */
|
|
631
|
+
const trimLocaleText = (value, baseLanguage) => {
|
|
632
|
+
if (isLocaleText(value)) {
|
|
633
|
+
return toLocaleText(Object.fromEntries(Object.keys(value).map(key => [key, (value[key] || '').trim()])), baseLanguage);
|
|
634
|
+
}
|
|
635
|
+
return String(value ?? '').trim();
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
/** 由文案派生数据值时用基础语言,保证各语言下值一致;基础语言为空时取第一个有内容的语言 */
|
|
639
|
+
const localeTextToValue = (value, baseLanguage) => {
|
|
640
|
+
if (!isLocaleText(value)) {
|
|
641
|
+
return String(value ?? '').trim();
|
|
642
|
+
}
|
|
643
|
+
const text = resolveLocaleText(value, baseLanguage) || Object.values(value).find(hasText) || '';
|
|
644
|
+
return String(text).trim();
|
|
645
|
+
};
|
|
646
|
+
|
|
526
647
|
const createFieldId = () => `field_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
527
648
|
|
|
528
649
|
/** 生成可编辑的默认数据标识,如 field_xxxx / col_xxxx */
|
|
@@ -559,6 +680,9 @@ const defaultFormActions = () => ({
|
|
|
559
680
|
gap: 16
|
|
560
681
|
});
|
|
561
682
|
const FORM_ACTIONS_ALIGN = ['center', 'start', 'end'];
|
|
683
|
+
const normalizeActionText = value => value == null ? '' : isLocaleText(value) ? {
|
|
684
|
+
...value
|
|
685
|
+
} : String(value);
|
|
562
686
|
const normalizeFormActions = (actions = {}) => {
|
|
563
687
|
const base = defaultFormActions();
|
|
564
688
|
if (!actions || typeof actions !== 'object') {
|
|
@@ -571,9 +695,9 @@ const normalizeFormActions = (actions = {}) => {
|
|
|
571
695
|
showSubmit: actions.showSubmit !== false,
|
|
572
696
|
showReset: actions.showReset !== false,
|
|
573
697
|
showCancel: !!actions.showCancel,
|
|
574
|
-
submitText:
|
|
575
|
-
resetText:
|
|
576
|
-
cancelText:
|
|
698
|
+
submitText: normalizeActionText(actions.submitText),
|
|
699
|
+
resetText: normalizeActionText(actions.resetText),
|
|
700
|
+
cancelText: normalizeActionText(actions.cancelText),
|
|
577
701
|
align,
|
|
578
702
|
gap,
|
|
579
703
|
...(actions.submitButtonProps && typeof actions.submitButtonProps === 'object' ? {
|
|
@@ -1471,7 +1595,7 @@ const createApiFromOptions = (options = []) => ({
|
|
|
1471
1595
|
});
|
|
1472
1596
|
|
|
1473
1597
|
const {
|
|
1474
|
-
useOnChange: useOnChange$
|
|
1598
|
+
useOnChange: useOnChange$2
|
|
1475
1599
|
} = reactFormAntd.hooks;
|
|
1476
1600
|
const hasNestedOptions = options => Array.isArray(options) && options.some(item => Array.isArray(item?.children) && item.children.length);
|
|
1477
1601
|
const createField = (Component, {
|
|
@@ -1507,7 +1631,7 @@ const createField = (Component, {
|
|
|
1507
1631
|
}, {
|
|
1508
1632
|
label: props.label || ''
|
|
1509
1633
|
}).trim();
|
|
1510
|
-
const render = useOnChange$
|
|
1634
|
+
const render = useOnChange$2(Object.assign({}, {
|
|
1511
1635
|
isPopup: true,
|
|
1512
1636
|
placeholder: resolvedPlaceholder
|
|
1513
1637
|
}, rest, {
|
|
@@ -2040,8 +2164,10 @@ const resolveFieldValueSchema = field => {
|
|
|
2040
2164
|
...schema
|
|
2041
2165
|
};
|
|
2042
2166
|
}
|
|
2043
|
-
const
|
|
2044
|
-
const
|
|
2167
|
+
const label = resolveLocaleText(field.label);
|
|
2168
|
+
const fieldDescription = resolveLocaleText(field.description);
|
|
2169
|
+
const title = label != null && String(label).trim() ? String(label).trim() : undefined;
|
|
2170
|
+
const description = fieldDescription != null && String(fieldDescription).trim() ? String(fieldDescription).trim() : undefined;
|
|
2045
2171
|
if (title && schema.title == null) {
|
|
2046
2172
|
schema.title = title;
|
|
2047
2173
|
}
|
|
@@ -2118,24 +2244,24 @@ const normalizeOptions = (options, {
|
|
|
2118
2244
|
}
|
|
2119
2245
|
const columnNames = (columns || []).map(item => item?.name).filter(Boolean);
|
|
2120
2246
|
return options.map(item => {
|
|
2121
|
-
const label =
|
|
2247
|
+
const label = trimLocaleText(item?.label);
|
|
2122
2248
|
let value = String(item?.value ?? '').trim();
|
|
2123
2249
|
if (!value && label) {
|
|
2124
|
-
value = label;
|
|
2250
|
+
value = localeTextToValue(label);
|
|
2125
2251
|
}
|
|
2126
2252
|
const next = {
|
|
2127
2253
|
label,
|
|
2128
2254
|
value,
|
|
2129
|
-
description:
|
|
2255
|
+
description: trimLocaleText(item?.description)
|
|
2130
2256
|
};
|
|
2131
2257
|
columnNames.forEach(name => {
|
|
2132
2258
|
next[name] = item?.[name] ?? '';
|
|
2133
2259
|
});
|
|
2134
|
-
if (!
|
|
2260
|
+
if (!hasLocaleText(next.label) && columnNames[0] && String(next[columnNames[0]] || '').trim()) {
|
|
2135
2261
|
next.label = String(next[columnNames[0]]).trim();
|
|
2136
2262
|
}
|
|
2137
|
-
if (!String(next.value).trim() &&
|
|
2138
|
-
next.value = next.label;
|
|
2263
|
+
if (!String(next.value).trim() && hasLocaleText(next.label)) {
|
|
2264
|
+
next.value = localeTextToValue(next.label);
|
|
2139
2265
|
}
|
|
2140
2266
|
if (allowChildren && Array.isArray(item?.children) && item.children.length) {
|
|
2141
2267
|
next.children = normalizeOptions(item.children, {
|
|
@@ -2442,6 +2568,105 @@ const formValuesToField = (values, existingField = {}) => {
|
|
|
2442
2568
|
};
|
|
2443
2569
|
};
|
|
2444
2570
|
|
|
2571
|
+
const {
|
|
2572
|
+
useOnChange: useOnChange$1
|
|
2573
|
+
} = reactFormAntd.hooks;
|
|
2574
|
+
const LocaleTextContext = /*#__PURE__*/react.createContext([]);
|
|
2575
|
+
|
|
2576
|
+
/** 向编辑器内的文案输入下发语言列表 [{ value, label }] */
|
|
2577
|
+
const LocaleTextProvider = ({
|
|
2578
|
+
languages,
|
|
2579
|
+
children
|
|
2580
|
+
}) => /*#__PURE__*/jsxRuntime.jsx(LocaleTextContext.Provider, {
|
|
2581
|
+
value: normalizeLanguages(languages),
|
|
2582
|
+
children: children
|
|
2583
|
+
});
|
|
2584
|
+
|
|
2585
|
+
/** 当前语言列表:组件 languages 优先,否则取 LocaleTextProvider */
|
|
2586
|
+
const useLocaleTextLanguages = languages => {
|
|
2587
|
+
const contextLanguages = react.useContext(LocaleTextContext);
|
|
2588
|
+
return languages ? normalizeLanguages(languages) : contextLanguages;
|
|
2589
|
+
};
|
|
2590
|
+
|
|
2591
|
+
/** 文案输入:未配置多语言时为单个输入框;配置后每种语言一个输入框,只填基础语言(首项)时存为字符串 */
|
|
2592
|
+
const LocaleTextControl = ({
|
|
2593
|
+
value,
|
|
2594
|
+
onChange,
|
|
2595
|
+
onBlur,
|
|
2596
|
+
placeholder,
|
|
2597
|
+
multiline = false,
|
|
2598
|
+
compact = false,
|
|
2599
|
+
rows = 2,
|
|
2600
|
+
disabled,
|
|
2601
|
+
className,
|
|
2602
|
+
languages: languagesProp
|
|
2603
|
+
}) => {
|
|
2604
|
+
const {
|
|
2605
|
+
formatMessage,
|
|
2606
|
+
locale
|
|
2607
|
+
} = reactIntl.useIntl();
|
|
2608
|
+
const languages = useLocaleTextLanguages(languagesProp);
|
|
2609
|
+
const Control = multiline ? antd.Input.TextArea : antd.Input;
|
|
2610
|
+
const controlProps = {
|
|
2611
|
+
disabled,
|
|
2612
|
+
onBlur,
|
|
2613
|
+
...(multiline ? {
|
|
2614
|
+
rows
|
|
2615
|
+
} : {})
|
|
2616
|
+
};
|
|
2617
|
+
if (languages.length < 2) {
|
|
2618
|
+
const baseLanguage = languages[0]?.value;
|
|
2619
|
+
const editLanguage = isLocaleText(value) ? baseLanguage || Object.keys(value).find(key => value[key] === resolveLocaleText(value, locale)) || Object.keys(value)[0] : null;
|
|
2620
|
+
return /*#__PURE__*/jsxRuntime.jsx(Control, {
|
|
2621
|
+
...controlProps,
|
|
2622
|
+
className: className,
|
|
2623
|
+
value: editLanguage ? value[editLanguage] || '' : value ?? '',
|
|
2624
|
+
placeholder: placeholder,
|
|
2625
|
+
onChange: e => onChange?.(editLanguage ? setLocaleTextValue(value, editLanguage, e.target.value, editLanguage) : e.target.value)
|
|
2626
|
+
});
|
|
2627
|
+
}
|
|
2628
|
+
const baseLanguage = languages[0];
|
|
2629
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2630
|
+
className: [style['locale-text'], compact ? style['is-compact'] : null, className].filter(Boolean).join(' '),
|
|
2631
|
+
children: languages.map(language => /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2632
|
+
className: style['locale-text-item'],
|
|
2633
|
+
children: [compact ? null : /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
2634
|
+
className: style['locale-text-tag'],
|
|
2635
|
+
children: language.label
|
|
2636
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Control, {
|
|
2637
|
+
...controlProps,
|
|
2638
|
+
value: getLocaleTextValue(value, language.value, baseLanguage.value),
|
|
2639
|
+
placeholder: language.value === baseLanguage.value ? placeholder : formatMessage({
|
|
2640
|
+
id: 'localeTextFallback'
|
|
2641
|
+
}, {
|
|
2642
|
+
language: baseLanguage.label
|
|
2643
|
+
}),
|
|
2644
|
+
...(compact && !multiline ? {
|
|
2645
|
+
prefix: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
2646
|
+
className: style['locale-text-prefix'],
|
|
2647
|
+
children: language.label
|
|
2648
|
+
})
|
|
2649
|
+
} : {}),
|
|
2650
|
+
onChange: e => onChange?.(setLocaleTextValue(value, language.value, e.target.value, baseLanguage.value))
|
|
2651
|
+
})]
|
|
2652
|
+
}, language.value))
|
|
2653
|
+
});
|
|
2654
|
+
};
|
|
2655
|
+
const LocaleInput = props => {
|
|
2656
|
+
const render = useOnChange$1(props);
|
|
2657
|
+
return render(LocaleTextControl);
|
|
2658
|
+
};
|
|
2659
|
+
LocaleInput.field = LocaleTextControl;
|
|
2660
|
+
const LocaleTextAreaControl = props => /*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
|
|
2661
|
+
...props,
|
|
2662
|
+
multiline: true
|
|
2663
|
+
});
|
|
2664
|
+
const LocaleTextArea = props => {
|
|
2665
|
+
const render = useOnChange$1(props);
|
|
2666
|
+
return render(LocaleTextAreaControl);
|
|
2667
|
+
};
|
|
2668
|
+
LocaleTextArea.field = LocaleTextAreaControl;
|
|
2669
|
+
|
|
2445
2670
|
const {
|
|
2446
2671
|
Text: Text$4
|
|
2447
2672
|
} = antd.Typography;
|
|
@@ -2472,8 +2697,10 @@ const FieldRow = ({
|
|
|
2472
2697
|
onMove
|
|
2473
2698
|
}) => {
|
|
2474
2699
|
const {
|
|
2475
|
-
formatMessage
|
|
2700
|
+
formatMessage,
|
|
2701
|
+
locale
|
|
2476
2702
|
} = reactIntl.useIntl();
|
|
2703
|
+
const languages = useLocaleTextLanguages();
|
|
2477
2704
|
const definition = getFieldDefinition(field.type);
|
|
2478
2705
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2479
2706
|
className: style['field-row'],
|
|
@@ -2488,7 +2715,7 @@ const FieldRow = ({
|
|
|
2488
2715
|
children: [/*#__PURE__*/jsxRuntime.jsx(Text$4, {
|
|
2489
2716
|
strong: true,
|
|
2490
2717
|
ellipsis: true,
|
|
2491
|
-
children: field.label || formatMessage({
|
|
2718
|
+
children: resolveLocaleText(field.label, locale, languages) || formatMessage({
|
|
2492
2719
|
id: 'untitledField'
|
|
2493
2720
|
})
|
|
2494
2721
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
|
|
@@ -2626,8 +2853,11 @@ const BlockListPanel = ({
|
|
|
2626
2853
|
extraToolbar
|
|
2627
2854
|
}) => {
|
|
2628
2855
|
const {
|
|
2629
|
-
formatMessage
|
|
2856
|
+
formatMessage,
|
|
2857
|
+
locale
|
|
2630
2858
|
} = reactIntl.useIntl();
|
|
2859
|
+
const languages = useLocaleTextLanguages();
|
|
2860
|
+
const text = value => resolveLocaleText(value, locale, languages);
|
|
2631
2861
|
const [addMenuOpen, setAddMenuOpen] = react.useState(false);
|
|
2632
2862
|
const [addFieldMenuId, setAddFieldMenuId] = react.useState(null);
|
|
2633
2863
|
const keepAddFieldMenuOpenRef = react.useRef(false);
|
|
@@ -2871,7 +3101,7 @@ const BlockListPanel = ({
|
|
|
2871
3101
|
children: stepIndex + 1
|
|
2872
3102
|
}), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
|
|
2873
3103
|
strong: true,
|
|
2874
|
-
children: step.title || formatMessage({
|
|
3104
|
+
children: text(step.title) || formatMessage({
|
|
2875
3105
|
id: 'untitledStep'
|
|
2876
3106
|
}, {
|
|
2877
3107
|
index: stepIndex + 1
|
|
@@ -2994,7 +3224,7 @@ const BlockListPanel = ({
|
|
|
2994
3224
|
children: optionIndex + 1
|
|
2995
3225
|
}), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
|
|
2996
3226
|
strong: true,
|
|
2997
|
-
children: option.title || formatMessage({
|
|
3227
|
+
children: text(option.title) || formatMessage({
|
|
2998
3228
|
id: 'choiceOptionFallback'
|
|
2999
3229
|
}, {
|
|
3000
3230
|
index: optionIndex + 1
|
|
@@ -3122,7 +3352,7 @@ const BlockListPanel = ({
|
|
|
3122
3352
|
strong: true,
|
|
3123
3353
|
ellipsis: true,
|
|
3124
3354
|
className: style['block-title'],
|
|
3125
|
-
children: block.title || block.label || block.name || formatMessage({
|
|
3355
|
+
children: text(block.title) || text(block.label) || block.name || formatMessage({
|
|
3126
3356
|
id: 'untitledBlock'
|
|
3127
3357
|
})
|
|
3128
3358
|
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
@@ -3239,7 +3469,7 @@ const BlockConfigFields = ({
|
|
|
3239
3469
|
const list = [];
|
|
3240
3470
|
const isListKind = kind === 'list' || kind === 'tableList' || kind === 'editableList';
|
|
3241
3471
|
if (kind === 'formInfo' || kind === 'list' || kind === 'tableList' || kind === 'editableList' || kind === 'object') {
|
|
3242
|
-
list.push(/*#__PURE__*/jsxRuntime.jsx(
|
|
3472
|
+
list.push(/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3243
3473
|
name: "title",
|
|
3244
3474
|
label: formatMessage({
|
|
3245
3475
|
id: 'blockTitle'
|
|
@@ -3247,7 +3477,7 @@ const BlockConfigFields = ({
|
|
|
3247
3477
|
placeholder: formatMessage({
|
|
3248
3478
|
id: 'blockTitlePlaceholder'
|
|
3249
3479
|
})
|
|
3250
|
-
}, "title"), kind === 'formInfo' ? /*#__PURE__*/jsxRuntime.jsx(
|
|
3480
|
+
}, "title"), kind === 'formInfo' ? /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3251
3481
|
name: "subtitle",
|
|
3252
3482
|
label: formatMessage({
|
|
3253
3483
|
id: 'blockSubtitle'
|
|
@@ -3293,7 +3523,7 @@ const BlockConfigFields = ({
|
|
|
3293
3523
|
children: formatMessage({
|
|
3294
3524
|
id: 'blockImportant'
|
|
3295
3525
|
})
|
|
3296
|
-
}, "important") : null, isListKind ? /*#__PURE__*/jsxRuntime.jsx(
|
|
3526
|
+
}, "important") : null, isListKind ? /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3297
3527
|
name: "addText",
|
|
3298
3528
|
label: formatMessage({
|
|
3299
3529
|
id: 'blockAddText'
|
|
@@ -3327,7 +3557,7 @@ const BlockConfigFields = ({
|
|
|
3327
3557
|
}, "minLength") : null);
|
|
3328
3558
|
}
|
|
3329
3559
|
if (kind === 'choice') {
|
|
3330
|
-
list.push(/*#__PURE__*/jsxRuntime.jsx(
|
|
3560
|
+
list.push(/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3331
3561
|
name: "title",
|
|
3332
3562
|
label: formatMessage({
|
|
3333
3563
|
id: 'blockTitle'
|
|
@@ -3404,7 +3634,7 @@ const BlockConfigFields = ({
|
|
|
3404
3634
|
placeholder: formatMessage({
|
|
3405
3635
|
id: 'fieldNamePlaceholder'
|
|
3406
3636
|
})
|
|
3407
|
-
}, "name"), /*#__PURE__*/jsxRuntime.jsx(
|
|
3637
|
+
}, "name"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3408
3638
|
name: "label",
|
|
3409
3639
|
label: formatMessage({
|
|
3410
3640
|
id: 'fieldLabel'
|
|
@@ -3420,7 +3650,7 @@ const BlockConfigFields = ({
|
|
|
3420
3650
|
}),
|
|
3421
3651
|
rule: "REQ",
|
|
3422
3652
|
options: fieldTypeOptions
|
|
3423
|
-
}, "fieldType"), /*#__PURE__*/jsxRuntime.jsx(
|
|
3653
|
+
}, "fieldType"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3424
3654
|
name: "addText",
|
|
3425
3655
|
label: formatMessage({
|
|
3426
3656
|
id: 'blockAddText'
|
|
@@ -3431,7 +3661,7 @@ const BlockConfigFields = ({
|
|
|
3431
3661
|
}, "addText"));
|
|
3432
3662
|
}
|
|
3433
3663
|
if (kind === 'steps') {
|
|
3434
|
-
list.push(/*#__PURE__*/jsxRuntime.jsx(
|
|
3664
|
+
list.push(/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3435
3665
|
name: "title",
|
|
3436
3666
|
label: formatMessage({
|
|
3437
3667
|
id: 'blockTitle'
|
|
@@ -3439,7 +3669,7 @@ const BlockConfigFields = ({
|
|
|
3439
3669
|
placeholder: formatMessage({
|
|
3440
3670
|
id: 'blockTitlePlaceholder'
|
|
3441
3671
|
})
|
|
3442
|
-
}, "title"), /*#__PURE__*/jsxRuntime.jsx(
|
|
3672
|
+
}, "title"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3443
3673
|
name: "subtitle",
|
|
3444
3674
|
label: formatMessage({
|
|
3445
3675
|
id: 'blockSubtitle'
|
|
@@ -3567,7 +3797,7 @@ const StepEditorModal = ({
|
|
|
3567
3797
|
}),
|
|
3568
3798
|
children: /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
|
|
3569
3799
|
column: 1,
|
|
3570
|
-
list: [/*#__PURE__*/jsxRuntime.jsx(
|
|
3800
|
+
list: [/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3571
3801
|
name: "title",
|
|
3572
3802
|
label: formatMessage({
|
|
3573
3803
|
id: 'stepTitle'
|
|
@@ -3627,7 +3857,7 @@ const ChoiceOptionEditorModal = ({
|
|
|
3627
3857
|
}),
|
|
3628
3858
|
children: /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
|
|
3629
3859
|
column: 1,
|
|
3630
|
-
list: [/*#__PURE__*/jsxRuntime.jsx(
|
|
3860
|
+
list: [/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
3631
3861
|
name: "title",
|
|
3632
3862
|
label: formatMessage({
|
|
3633
3863
|
id: 'choiceOptionTitle'
|
|
@@ -3720,27 +3950,28 @@ const EMPTY_OPTION = () => ({
|
|
|
3720
3950
|
});
|
|
3721
3951
|
|
|
3722
3952
|
/** value 为空或仍等于当前 label 时视为联动中,改 label 会同步 value */
|
|
3723
|
-
const isOptionValueLinked = (label, value) => {
|
|
3724
|
-
const labelText = label
|
|
3953
|
+
const isOptionValueLinked = (label, value, baseLanguage) => {
|
|
3954
|
+
const labelText = localeTextToValue(label, baseLanguage);
|
|
3725
3955
|
const valueText = value == null ? '' : String(value);
|
|
3726
3956
|
return valueText === '' || valueText === labelText;
|
|
3727
3957
|
};
|
|
3728
|
-
const patchOptionLabelChange = (item, nextLabel) => {
|
|
3958
|
+
const patchOptionLabelChange = (item, nextLabel, baseLanguage) => {
|
|
3729
3959
|
const patch = {
|
|
3730
3960
|
label: nextLabel
|
|
3731
3961
|
};
|
|
3732
|
-
if (isOptionValueLinked(item.label, item.value)) {
|
|
3733
|
-
patch.value = nextLabel;
|
|
3962
|
+
if (isOptionValueLinked(item.label, item.value, baseLanguage)) {
|
|
3963
|
+
patch.value = localeTextToValue(nextLabel, baseLanguage);
|
|
3734
3964
|
}
|
|
3735
3965
|
return patch;
|
|
3736
3966
|
};
|
|
3737
|
-
const trimOptionLabelValue = item => {
|
|
3738
|
-
const label =
|
|
3967
|
+
const trimOptionLabelValue = (item, baseLanguage) => {
|
|
3968
|
+
const label = trimLocaleText(item?.label, baseLanguage);
|
|
3969
|
+
const labelValue = localeTextToValue(label, baseLanguage);
|
|
3739
3970
|
const rawValue = String(item?.value ?? '').trim();
|
|
3740
|
-
const linked = isOptionValueLinked(item?.label, item?.value) || rawValue === '' || rawValue ===
|
|
3971
|
+
const linked = isOptionValueLinked(item?.label, item?.value, baseLanguage) || rawValue === '' || rawValue === labelValue;
|
|
3741
3972
|
return {
|
|
3742
3973
|
label,
|
|
3743
|
-
value: linked ?
|
|
3974
|
+
value: linked ? labelValue : rawValue
|
|
3744
3975
|
};
|
|
3745
3976
|
};
|
|
3746
3977
|
const createEmptyTableRow = columns => {
|
|
@@ -3771,6 +4002,7 @@ const FlatOptionRows = ({
|
|
|
3771
4002
|
const {
|
|
3772
4003
|
formatMessage
|
|
3773
4004
|
} = reactIntl.useIntl();
|
|
4005
|
+
const baseLanguage = useLocaleTextLanguages()[0]?.value;
|
|
3774
4006
|
const rows = list.length ? ensureOptionKeys(list) : [EMPTY_OPTION()];
|
|
3775
4007
|
const commit = next => onChange(next);
|
|
3776
4008
|
const updateItem = (index, patch) => {
|
|
@@ -3785,13 +4017,15 @@ const FlatOptionRows = ({
|
|
|
3785
4017
|
gap: 8,
|
|
3786
4018
|
align: "start",
|
|
3787
4019
|
className: style['options-row'],
|
|
3788
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
4020
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
|
|
4021
|
+
compact: true,
|
|
4022
|
+
className: style['options-locale-text'],
|
|
3789
4023
|
value: item.label,
|
|
3790
4024
|
placeholder: formatMessage({
|
|
3791
4025
|
id: 'optionLabelPlaceholder'
|
|
3792
4026
|
}),
|
|
3793
|
-
onChange:
|
|
3794
|
-
onBlur: () => updateItem(index, trimOptionLabelValue(item))
|
|
4027
|
+
onChange: nextLabel => updateItem(index, patchOptionLabelChange(item, nextLabel, baseLanguage)),
|
|
4028
|
+
onBlur: () => updateItem(index, trimOptionLabelValue(item, baseLanguage))
|
|
3795
4029
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
3796
4030
|
value: item.value,
|
|
3797
4031
|
placeholder: formatMessage({
|
|
@@ -3803,16 +4037,18 @@ const FlatOptionRows = ({
|
|
|
3803
4037
|
onBlur: () => updateItem(index, {
|
|
3804
4038
|
value: String(item.value ?? '').trim()
|
|
3805
4039
|
})
|
|
3806
|
-
}), allowDescription ? /*#__PURE__*/jsxRuntime.jsx(
|
|
4040
|
+
}), allowDescription ? /*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
|
|
4041
|
+
compact: true,
|
|
4042
|
+
className: style['options-locale-text'],
|
|
3807
4043
|
value: item.description || '',
|
|
3808
4044
|
placeholder: formatMessage({
|
|
3809
4045
|
id: 'optionDescPlaceholder'
|
|
3810
4046
|
}),
|
|
3811
|
-
onChange:
|
|
3812
|
-
description
|
|
4047
|
+
onChange: description => updateItem(index, {
|
|
4048
|
+
description
|
|
3813
4049
|
}),
|
|
3814
4050
|
onBlur: () => updateItem(index, {
|
|
3815
|
-
description:
|
|
4051
|
+
description: trimLocaleText(item.description, baseLanguage)
|
|
3816
4052
|
})
|
|
3817
4053
|
}) : null, /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
3818
4054
|
type: "text",
|
|
@@ -3850,6 +4086,7 @@ const TreeOptionNode = ({
|
|
|
3850
4086
|
const {
|
|
3851
4087
|
formatMessage
|
|
3852
4088
|
} = reactIntl.useIntl();
|
|
4089
|
+
const baseLanguage = useLocaleTextLanguages()[0]?.value;
|
|
3853
4090
|
const children = Array.isArray(item.children) ? item.children : [];
|
|
3854
4091
|
const canAddChild = depth < maxDepth;
|
|
3855
4092
|
const updateSelf = patch => {
|
|
@@ -3884,13 +4121,14 @@ const TreeOptionNode = ({
|
|
|
3884
4121
|
className: style['tree-option-row'],
|
|
3885
4122
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3886
4123
|
className: style['tree-option-fields'],
|
|
3887
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
4124
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
|
|
4125
|
+
compact: true,
|
|
3888
4126
|
value: item.label,
|
|
3889
4127
|
placeholder: formatMessage({
|
|
3890
4128
|
id: 'optionLabelPlaceholder'
|
|
3891
4129
|
}),
|
|
3892
|
-
onChange:
|
|
3893
|
-
onBlur: () => updateSelf(trimOptionLabelValue(item))
|
|
4130
|
+
onChange: nextLabel => updateSelf(patchOptionLabelChange(item, nextLabel, baseLanguage)),
|
|
4131
|
+
onBlur: () => updateSelf(trimOptionLabelValue(item, baseLanguage))
|
|
3894
4132
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
3895
4133
|
value: item.value,
|
|
3896
4134
|
placeholder: formatMessage({
|
|
@@ -3902,16 +4140,17 @@ const TreeOptionNode = ({
|
|
|
3902
4140
|
onBlur: () => updateSelf({
|
|
3903
4141
|
value: String(item.value ?? '').trim()
|
|
3904
4142
|
})
|
|
3905
|
-
}), allowDescription ? /*#__PURE__*/jsxRuntime.jsx(
|
|
4143
|
+
}), allowDescription ? /*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
|
|
4144
|
+
compact: true,
|
|
3906
4145
|
value: item.description || '',
|
|
3907
4146
|
placeholder: formatMessage({
|
|
3908
4147
|
id: 'optionDescPlaceholder'
|
|
3909
4148
|
}),
|
|
3910
|
-
onChange:
|
|
3911
|
-
description
|
|
4149
|
+
onChange: description => updateSelf({
|
|
4150
|
+
description
|
|
3912
4151
|
}),
|
|
3913
4152
|
onBlur: () => updateSelf({
|
|
3914
|
-
description:
|
|
4153
|
+
description: trimLocaleText(item.description, baseLanguage)
|
|
3915
4154
|
})
|
|
3916
4155
|
}) : null]
|
|
3917
4156
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
@@ -4019,13 +4258,14 @@ const ColumnsEditor = ({
|
|
|
4019
4258
|
gap: 8,
|
|
4020
4259
|
align: "start",
|
|
4021
4260
|
className: style['options-row'],
|
|
4022
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(
|
|
4261
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
|
|
4262
|
+
compact: true,
|
|
4263
|
+
className: style['options-locale-text'],
|
|
4023
4264
|
value: item.title || '',
|
|
4024
4265
|
placeholder: formatMessage({
|
|
4025
4266
|
id: 'columnTitlePlaceholder'
|
|
4026
4267
|
}),
|
|
4027
|
-
onChange:
|
|
4028
|
-
const title = e.target.value;
|
|
4268
|
+
onChange: title => {
|
|
4029
4269
|
const patch = {
|
|
4030
4270
|
title
|
|
4031
4271
|
};
|
|
@@ -4095,8 +4335,10 @@ const TableRowsEditor = ({
|
|
|
4095
4335
|
onChange
|
|
4096
4336
|
}) => {
|
|
4097
4337
|
const {
|
|
4098
|
-
formatMessage
|
|
4338
|
+
formatMessage,
|
|
4339
|
+
locale
|
|
4099
4340
|
} = reactIntl.useIntl();
|
|
4341
|
+
const languages = useLocaleTextLanguages();
|
|
4100
4342
|
const usableColumns = columns.filter(column => column?.name && String(column.name).trim());
|
|
4101
4343
|
const list = value.length ? value : [createEmptyTableRow(usableColumns)];
|
|
4102
4344
|
const updateItem = (index, patch) => {
|
|
@@ -4171,13 +4413,15 @@ const TableRowsEditor = ({
|
|
|
4171
4413
|
onChange: e => updateItem(index, {
|
|
4172
4414
|
value: e.target.value
|
|
4173
4415
|
})
|
|
4174
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
4416
|
+
}), /*#__PURE__*/jsxRuntime.jsx(LocaleTextControl, {
|
|
4417
|
+
compact: true,
|
|
4418
|
+
className: style['options-locale-text'],
|
|
4175
4419
|
value: item.label || '',
|
|
4176
4420
|
placeholder: formatMessage({
|
|
4177
4421
|
id: 'tableRowLabelPlaceholder'
|
|
4178
4422
|
}),
|
|
4179
|
-
onChange:
|
|
4180
|
-
label
|
|
4423
|
+
onChange: label => updateItem(index, {
|
|
4424
|
+
label
|
|
4181
4425
|
})
|
|
4182
4426
|
})]
|
|
4183
4427
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.Flex, {
|
|
@@ -4189,7 +4433,7 @@ const TableRowsEditor = ({
|
|
|
4189
4433
|
flex: 1
|
|
4190
4434
|
},
|
|
4191
4435
|
value: item[column.name] || '',
|
|
4192
|
-
placeholder: column.title || column.name,
|
|
4436
|
+
placeholder: resolveLocaleText(column.title, locale, languages) || column.name,
|
|
4193
4437
|
onChange: e => updateItem(index, {
|
|
4194
4438
|
[column.name]: e.target.value
|
|
4195
4439
|
})
|
|
@@ -4360,7 +4604,7 @@ const SuperSelectPropsEditor = ({
|
|
|
4360
4604
|
display: ({
|
|
4361
4605
|
openApi
|
|
4362
4606
|
}) => !openApi?.data?.single
|
|
4363
|
-
}, "maxLength"), /*#__PURE__*/jsxRuntime.jsx(
|
|
4607
|
+
}, "maxLength"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
4364
4608
|
name: "placeholder",
|
|
4365
4609
|
label: formatMessage({
|
|
4366
4610
|
id: 'fieldPlaceholder'
|
|
@@ -4368,7 +4612,7 @@ const SuperSelectPropsEditor = ({
|
|
|
4368
4612
|
placeholder: formatMessage({
|
|
4369
4613
|
id: 'superSelectPlaceholderHint'
|
|
4370
4614
|
})
|
|
4371
|
-
}, "placeholder"), /*#__PURE__*/jsxRuntime.jsx(
|
|
4615
|
+
}, "placeholder"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
4372
4616
|
name: "searchPlaceholder",
|
|
4373
4617
|
label: formatMessage({
|
|
4374
4618
|
id: 'superSelectSearchPlaceholder'
|
|
@@ -4424,7 +4668,7 @@ const buildPropsSchemaList = (schema, formatMessage) => (schema || []).filter(it
|
|
|
4424
4668
|
}, item.name);
|
|
4425
4669
|
});
|
|
4426
4670
|
const buildBuiltinList = (type, formatMessage) => {
|
|
4427
|
-
const placeholder = /*#__PURE__*/jsxRuntime.jsx(
|
|
4671
|
+
const placeholder = /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
4428
4672
|
name: "placeholder",
|
|
4429
4673
|
label: formatMessage({
|
|
4430
4674
|
id: 'fieldPlaceholder'
|
|
@@ -4604,7 +4848,7 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4604
4848
|
})
|
|
4605
4849
|
}, "showTime")];
|
|
4606
4850
|
case 'Switch':
|
|
4607
|
-
return [/*#__PURE__*/jsxRuntime.jsx(
|
|
4851
|
+
return [/*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
4608
4852
|
name: "checkedChildren",
|
|
4609
4853
|
label: formatMessage({
|
|
4610
4854
|
id: 'propSwitchOnText'
|
|
@@ -4612,7 +4856,7 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4612
4856
|
placeholder: formatMessage({
|
|
4613
4857
|
id: 'propSwitchOnTextHint'
|
|
4614
4858
|
})
|
|
4615
|
-
}, "checkedChildren"), /*#__PURE__*/jsxRuntime.jsx(
|
|
4859
|
+
}, "checkedChildren"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
4616
4860
|
name: "unCheckedChildren",
|
|
4617
4861
|
label: formatMessage({
|
|
4618
4862
|
id: 'propSwitchOffText'
|
|
@@ -4752,7 +4996,7 @@ const FieldConfigFields = ({
|
|
|
4752
4996
|
placeholder: formatMessage({
|
|
4753
4997
|
id: 'fieldNamePlaceholder'
|
|
4754
4998
|
})
|
|
4755
|
-
}, "name"), /*#__PURE__*/jsxRuntime.jsx(
|
|
4999
|
+
}, "name"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
4756
5000
|
name: "label",
|
|
4757
5001
|
label: formatMessage({
|
|
4758
5002
|
id: 'fieldLabel'
|
|
@@ -4761,7 +5005,7 @@ const FieldConfigFields = ({
|
|
|
4761
5005
|
placeholder: formatMessage({
|
|
4762
5006
|
id: 'fieldLabelPlaceholder'
|
|
4763
5007
|
})
|
|
4764
|
-
}, "label"), /*#__PURE__*/jsxRuntime.jsx(
|
|
5008
|
+
}, "label"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
4765
5009
|
name: "tips",
|
|
4766
5010
|
label: formatMessage({
|
|
4767
5011
|
id: 'fieldTips'
|
|
@@ -4769,7 +5013,7 @@ const FieldConfigFields = ({
|
|
|
4769
5013
|
placeholder: formatMessage({
|
|
4770
5014
|
id: 'fieldTipsPlaceholder'
|
|
4771
5015
|
})
|
|
4772
|
-
}, "tips"), /*#__PURE__*/jsxRuntime.jsx(
|
|
5016
|
+
}, "tips"), /*#__PURE__*/jsxRuntime.jsx(LocaleTextArea, {
|
|
4773
5017
|
name: "description",
|
|
4774
5018
|
label: formatMessage({
|
|
4775
5019
|
id: 'fieldDescription'
|
|
@@ -5008,7 +5252,7 @@ const FormActionsEditor = ({
|
|
|
5008
5252
|
id: 'formActionsShowSubmit'
|
|
5009
5253
|
}),
|
|
5010
5254
|
className: style['form-actions-switch-field']
|
|
5011
|
-
}, "showSubmit"), /*#__PURE__*/jsxRuntime.jsx(
|
|
5255
|
+
}, "showSubmit"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
5012
5256
|
name: "submitText",
|
|
5013
5257
|
label: formatMessage({
|
|
5014
5258
|
id: 'formActionsSubmitText'
|
|
@@ -5028,7 +5272,7 @@ const FormActionsEditor = ({
|
|
|
5028
5272
|
id: 'formActionsShowReset'
|
|
5029
5273
|
}),
|
|
5030
5274
|
className: style['form-actions-switch-field']
|
|
5031
|
-
}, "showReset"), /*#__PURE__*/jsxRuntime.jsx(
|
|
5275
|
+
}, "showReset"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
5032
5276
|
name: "resetText",
|
|
5033
5277
|
label: formatMessage({
|
|
5034
5278
|
id: 'formActionsResetText'
|
|
@@ -5048,7 +5292,7 @@ const FormActionsEditor = ({
|
|
|
5048
5292
|
id: 'formActionsShowCancel'
|
|
5049
5293
|
}),
|
|
5050
5294
|
className: style['form-actions-switch-field']
|
|
5051
|
-
}, "showCancel"), /*#__PURE__*/jsxRuntime.jsx(
|
|
5295
|
+
}, "showCancel"), /*#__PURE__*/jsxRuntime.jsx(LocaleInput, {
|
|
5052
5296
|
name: "cancelText",
|
|
5053
5297
|
label: formatMessage({
|
|
5054
5298
|
id: 'formActionsCancelText'
|
|
@@ -5383,6 +5627,56 @@ const ChoiceBlock = ({
|
|
|
5383
5627
|
};
|
|
5384
5628
|
var ChoiceBlock$1 = ChoiceBlock;
|
|
5385
5629
|
|
|
5630
|
+
// @kne/react-form 内置规则的错误提示写死中文;在 preset 覆盖前记下原函数,只替换未被业务覆盖的规则
|
|
5631
|
+
const BUILTIN_RULES = {
|
|
5632
|
+
TEL: reactFormAntd.RULES.TEL,
|
|
5633
|
+
EMAIL: reactFormAntd.RULES.EMAIL,
|
|
5634
|
+
LEN: reactFormAntd.RULES.LEN
|
|
5635
|
+
};
|
|
5636
|
+
const isBuiltin = name => reactFormAntd.RULES[name] === BUILTIN_RULES[name];
|
|
5637
|
+
const lenMessageId = (value, start, end) => {
|
|
5638
|
+
if (end === start) {
|
|
5639
|
+
return 'ruleErrorLenEqual';
|
|
5640
|
+
}
|
|
5641
|
+
return String(value ?? '').length < start ? 'ruleErrorLenMin' : 'ruleErrorLenMax';
|
|
5642
|
+
};
|
|
5643
|
+
|
|
5644
|
+
/** 按当前语言生成表单级 rules,传给 Form 覆盖全局同名规则 */
|
|
5645
|
+
const createLocalizedRules = formatMessage => {
|
|
5646
|
+
if (typeof formatMessage !== 'function') {
|
|
5647
|
+
return {};
|
|
5648
|
+
}
|
|
5649
|
+
const rules = {};
|
|
5650
|
+
['TEL', 'EMAIL'].forEach(name => {
|
|
5651
|
+
if (isBuiltin(name)) {
|
|
5652
|
+
rules[name] = function () {
|
|
5653
|
+
const res = BUILTIN_RULES[name](...[].slice.call(arguments));
|
|
5654
|
+
return res.result ? res : {
|
|
5655
|
+
...res,
|
|
5656
|
+
errMsg: formatMessage({
|
|
5657
|
+
id: `ruleError${name}`
|
|
5658
|
+
})
|
|
5659
|
+
};
|
|
5660
|
+
};
|
|
5661
|
+
}
|
|
5662
|
+
});
|
|
5663
|
+
if (isBuiltin('LEN')) {
|
|
5664
|
+
rules.LEN = (value, start, end) => {
|
|
5665
|
+
const res = BUILTIN_RULES.LEN(value, start, end);
|
|
5666
|
+
return res.result ? res : {
|
|
5667
|
+
...res,
|
|
5668
|
+
errMsg: formatMessage({
|
|
5669
|
+
id: lenMessageId(value, start, end)
|
|
5670
|
+
}, {
|
|
5671
|
+
start,
|
|
5672
|
+
end
|
|
5673
|
+
})
|
|
5674
|
+
};
|
|
5675
|
+
};
|
|
5676
|
+
}
|
|
5677
|
+
return rules;
|
|
5678
|
+
};
|
|
5679
|
+
|
|
5386
5680
|
const buildLabelTips = tips => {
|
|
5387
5681
|
if (tips == null || !String(tips).trim()) {
|
|
5388
5682
|
return undefined;
|
|
@@ -5773,6 +6067,10 @@ const renderSchemaContent = (schema, {
|
|
|
5773
6067
|
const formClassName = [style['schema-form'], formProps.className, className].filter(Boolean).join(' ');
|
|
5774
6068
|
return /*#__PURE__*/react.createElement(FormInfo.Form, {
|
|
5775
6069
|
...formProps,
|
|
6070
|
+
rules: {
|
|
6071
|
+
...createLocalizedRules(formatMessage),
|
|
6072
|
+
...formProps.rules
|
|
6073
|
+
},
|
|
5776
6074
|
className: formClassName
|
|
5777
6075
|
}, /*#__PURE__*/react.createElement('div', {
|
|
5778
6076
|
className: [style['schema-body'], bodyClassName].filter(Boolean).join(' ')
|
|
@@ -5884,14 +6182,15 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5884
6182
|
bodyClassName,
|
|
5885
6183
|
footerClassName,
|
|
5886
6184
|
buttonFooter = false,
|
|
5887
|
-
buttonFooterProps
|
|
6185
|
+
buttonFooterProps,
|
|
6186
|
+
languages
|
|
5888
6187
|
} = props;
|
|
5889
6188
|
const {
|
|
5890
6189
|
formatMessage,
|
|
5891
6190
|
locale
|
|
5892
6191
|
} = reactIntl.useIntl();
|
|
5893
6192
|
const isMobile = responsiveUtils.useIsMobile();
|
|
5894
|
-
const normalized = normalizeSchema(schema);
|
|
6193
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
5895
6194
|
if (!hasRenderableContent(normalized)) {
|
|
5896
6195
|
return null;
|
|
5897
6196
|
}
|
|
@@ -5949,14 +6248,15 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5949
6248
|
bodyClassName,
|
|
5950
6249
|
footerClassName,
|
|
5951
6250
|
buttonFooter = false,
|
|
5952
|
-
buttonFooterProps
|
|
6251
|
+
buttonFooterProps,
|
|
6252
|
+
languages
|
|
5953
6253
|
} = props;
|
|
5954
6254
|
const {
|
|
5955
6255
|
formatMessage,
|
|
5956
6256
|
locale
|
|
5957
6257
|
} = reactIntl.useIntl();
|
|
5958
6258
|
const isMobile = responsiveUtils.useIsMobile();
|
|
5959
|
-
const normalized = normalizeSchema(schema);
|
|
6259
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
5960
6260
|
if (!hasRenderableContent(normalized)) {
|
|
5961
6261
|
return null;
|
|
5962
6262
|
}
|
|
@@ -6002,7 +6302,8 @@ const FormCreator = withLocale$1(({
|
|
|
6002
6302
|
className,
|
|
6003
6303
|
formProps,
|
|
6004
6304
|
renderModal,
|
|
6005
|
-
extraToolbar
|
|
6305
|
+
extraToolbar,
|
|
6306
|
+
languages
|
|
6006
6307
|
}) => {
|
|
6007
6308
|
const {
|
|
6008
6309
|
formatMessage,
|
|
@@ -6330,95 +6631,99 @@ const FormCreator = withLocale$1(({
|
|
|
6330
6631
|
const toolbarExtra = typeof extraToolbar === 'function' ? extraToolbar({
|
|
6331
6632
|
schema
|
|
6332
6633
|
}) : extraToolbar;
|
|
6333
|
-
return /*#__PURE__*/jsxRuntime.
|
|
6334
|
-
|
|
6335
|
-
children:
|
|
6336
|
-
className: style['
|
|
6337
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
className: style['preview-
|
|
6362
|
-
children:
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6634
|
+
return /*#__PURE__*/jsxRuntime.jsx(LocaleTextProvider, {
|
|
6635
|
+
languages: languages,
|
|
6636
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
6637
|
+
className: [style['form-creator'], responsiveUtils.RESPONSIVE_BOUNDARY_CLASS, isMobile ? style['is-mobile'] : '', className].filter(Boolean).join(' '),
|
|
6638
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
6639
|
+
className: style['editor-pane'],
|
|
6640
|
+
children: /*#__PURE__*/jsxRuntime.jsx(BlockListPanel$1, {
|
|
6641
|
+
blocks: schema.blocks,
|
|
6642
|
+
onAddBlock: handleAddBlock,
|
|
6643
|
+
onEditBlock: handleEditBlock,
|
|
6644
|
+
onDeleteBlock: handleDeleteBlock,
|
|
6645
|
+
onMoveBlock: handleMoveBlock,
|
|
6646
|
+
onAddField: handleAddField,
|
|
6647
|
+
onEditField: handleEditField,
|
|
6648
|
+
onDeleteField: handleDeleteField,
|
|
6649
|
+
onMoveField: handleMoveField,
|
|
6650
|
+
onAddStep: handleAddStep,
|
|
6651
|
+
onEditStep: handleEditStep,
|
|
6652
|
+
onDeleteStep: handleDeleteStep,
|
|
6653
|
+
onMoveStep: handleMoveStep,
|
|
6654
|
+
onAddChoiceOption: handleAddChoiceOption,
|
|
6655
|
+
onEditChoiceOption: handleEditChoiceOption,
|
|
6656
|
+
onDeleteChoiceOption: handleDeleteChoiceOption,
|
|
6657
|
+
onMoveChoiceOption: handleMoveChoiceOption,
|
|
6658
|
+
onOpenFormActions: () => setFormActionsOpen(true),
|
|
6659
|
+
extraToolbar: toolbarExtra
|
|
6660
|
+
})
|
|
6661
|
+
}), showPreview ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
6662
|
+
className: style['preview-pane'],
|
|
6663
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
6664
|
+
className: style['preview-body'],
|
|
6665
|
+
children: hasRenderableContent(schema) ? /*#__PURE__*/jsxRuntime.jsx(SchemaRenderer$1, {
|
|
6666
|
+
schema: schema,
|
|
6667
|
+
preview: true,
|
|
6668
|
+
formProps: formProps,
|
|
6669
|
+
locale: locale,
|
|
6670
|
+
languages: languages
|
|
6671
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
|
|
6672
|
+
image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
|
|
6673
|
+
description: formatMessage({
|
|
6674
|
+
id: 'emptyBlockList'
|
|
6675
|
+
})
|
|
6371
6676
|
})
|
|
6372
6677
|
})
|
|
6373
|
-
})
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
}
|
|
6421
|
-
})
|
|
6678
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsx(BlockEditorModal$1, {
|
|
6679
|
+
open: blockEditorOpen,
|
|
6680
|
+
block: editingBlock,
|
|
6681
|
+
renderModal: renderModal,
|
|
6682
|
+
onCancel: clearBlockEditor,
|
|
6683
|
+
onSave: handleSaveBlock
|
|
6684
|
+
}), /*#__PURE__*/jsxRuntime.jsx(StepEditorModal$1, {
|
|
6685
|
+
open: stepEditorOpen,
|
|
6686
|
+
step: stepContext?.step,
|
|
6687
|
+
renderModal: renderModal,
|
|
6688
|
+
onCancel: () => {
|
|
6689
|
+
setStepEditorOpen(false);
|
|
6690
|
+
setStepContext(null);
|
|
6691
|
+
},
|
|
6692
|
+
onSave: handleSaveStep
|
|
6693
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ChoiceOptionEditorModal$1, {
|
|
6694
|
+
open: choiceOptionEditorOpen,
|
|
6695
|
+
option: choiceOptionContext?.option,
|
|
6696
|
+
renderModal: renderModal,
|
|
6697
|
+
onCancel: () => {
|
|
6698
|
+
setChoiceOptionEditorOpen(false);
|
|
6699
|
+
setChoiceOptionContext(null);
|
|
6700
|
+
},
|
|
6701
|
+
onSave: handleSaveChoiceOption
|
|
6702
|
+
}), /*#__PURE__*/jsxRuntime.jsx(FieldEditorModal$1, {
|
|
6703
|
+
open: fieldEditorOpen,
|
|
6704
|
+
field: editingField,
|
|
6705
|
+
fieldList: currentFieldScope,
|
|
6706
|
+
renderModal: renderModal,
|
|
6707
|
+
onCancel: () => {
|
|
6708
|
+
setFieldEditorOpen(false);
|
|
6709
|
+
setFieldContext(null);
|
|
6710
|
+
setEditingField(null);
|
|
6711
|
+
},
|
|
6712
|
+
onSave: handleSaveField
|
|
6713
|
+
}), /*#__PURE__*/jsxRuntime.jsx(FormActionsEditor$1, {
|
|
6714
|
+
open: formActionsOpen,
|
|
6715
|
+
value: schema.actions,
|
|
6716
|
+
renderModal: renderModal,
|
|
6717
|
+
onCancel: () => setFormActionsOpen(false),
|
|
6718
|
+
onSave: actions => {
|
|
6719
|
+
updateSchema({
|
|
6720
|
+
...schema,
|
|
6721
|
+
actions
|
|
6722
|
+
});
|
|
6723
|
+
setFormActionsOpen(false);
|
|
6724
|
+
}
|
|
6725
|
+
})]
|
|
6726
|
+
})
|
|
6422
6727
|
});
|
|
6423
6728
|
});
|
|
6424
6729
|
var FormCreator$1 = FormCreator;
|
|
@@ -6917,9 +7222,12 @@ const formatByValueSchema = (value, schema, ctx = {}) => {
|
|
|
6917
7222
|
}
|
|
6918
7223
|
return String(value);
|
|
6919
7224
|
};
|
|
6920
|
-
const formatFieldDisplayValue = (
|
|
6921
|
-
formatMessage
|
|
7225
|
+
const formatFieldDisplayValue = (rawField, value, {
|
|
7226
|
+
formatMessage,
|
|
7227
|
+
locale,
|
|
7228
|
+
languages
|
|
6922
7229
|
} = {}) => {
|
|
7230
|
+
const field = localizeSchema(rawField, locale, languages);
|
|
6923
7231
|
const emptyText = formatMessage?.({
|
|
6924
7232
|
id: 'schemaContentEmptyValue'
|
|
6925
7233
|
}) || '-';
|
|
@@ -7268,9 +7576,10 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
|
7268
7576
|
* - 扩展字段:registerField / preset 的 valueSchema;缺省 { type: 'string' }
|
|
7269
7577
|
* - hidden 字段仍进入 data schema(可提交)
|
|
7270
7578
|
* - choice:single → oneOf,multiple → anyOf
|
|
7579
|
+
* - options.locale / options.languages:多语言文案取该语言,取不到按 languages 顺序回退(未传为 zh-CN → en-US)
|
|
7271
7580
|
*/
|
|
7272
7581
|
const schemaToDataSchema = (schema, options = {}) => {
|
|
7273
|
-
const normalized = normalizeSchema(schema || {});
|
|
7582
|
+
const normalized = normalizeSchema(localizeSchema(schema || {}, options.locale, options.languages));
|
|
7274
7583
|
const layer = createObjectLayer();
|
|
7275
7584
|
walkBlocks(normalized.blocks, layer, 0);
|
|
7276
7585
|
const root = finalizeObjectSchema(layer, {
|
|
@@ -7465,13 +7774,15 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7465
7774
|
const SchemaContentInnerView = ({
|
|
7466
7775
|
schema,
|
|
7467
7776
|
data,
|
|
7468
|
-
className
|
|
7777
|
+
className,
|
|
7778
|
+
languages
|
|
7469
7779
|
}) => {
|
|
7470
7780
|
const {
|
|
7471
|
-
formatMessage
|
|
7781
|
+
formatMessage,
|
|
7782
|
+
locale
|
|
7472
7783
|
} = reactIntl.useIntl();
|
|
7473
7784
|
const isMobile = responsiveUtils.useIsMobile();
|
|
7474
|
-
const normalized = normalizeSchema(schema);
|
|
7785
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
7475
7786
|
const children = renderBlockList(normalized.blocks, data || {}, {
|
|
7476
7787
|
formatMessage,
|
|
7477
7788
|
isMobile,
|
|
@@ -7495,12 +7806,14 @@ const SchemaContent = withLocale$1(({
|
|
|
7495
7806
|
schema,
|
|
7496
7807
|
data,
|
|
7497
7808
|
className,
|
|
7498
|
-
empty
|
|
7809
|
+
empty,
|
|
7810
|
+
languages
|
|
7499
7811
|
}) => {
|
|
7500
7812
|
const {
|
|
7501
|
-
formatMessage
|
|
7813
|
+
formatMessage,
|
|
7814
|
+
locale
|
|
7502
7815
|
} = reactIntl.useIntl();
|
|
7503
|
-
const normalized = normalizeSchema(schema);
|
|
7816
|
+
const normalized = normalizeSchema(localizeSchema(schema, locale, languages));
|
|
7504
7817
|
const emptyNode = empty !== undefined ? empty : /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
|
|
7505
7818
|
image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
|
|
7506
7819
|
description: formatMessage({
|
|
@@ -7521,6 +7834,10 @@ const SchemaContent = withLocale$1(({
|
|
|
7521
7834
|
var SchemaContent$1 = SchemaContent;
|
|
7522
7835
|
|
|
7523
7836
|
exports.FormCreator = FormCreator$1;
|
|
7837
|
+
exports.LocaleInput = LocaleInput;
|
|
7838
|
+
exports.LocaleTextArea = LocaleTextArea;
|
|
7839
|
+
exports.LocaleTextControl = LocaleTextControl;
|
|
7840
|
+
exports.LocaleTextProvider = LocaleTextProvider;
|
|
7524
7841
|
exports.MAX_BLOCK_DEPTH = MAX_BLOCK_DEPTH;
|
|
7525
7842
|
exports.RULE_LEN_PRESET = RULE_LEN_PRESET;
|
|
7526
7843
|
exports.RULE_PRESET_ITEMS = RULE_PRESET_ITEMS;
|
|
@@ -7554,8 +7871,11 @@ exports.getFieldComponent = getFieldComponent;
|
|
|
7554
7871
|
exports.getFieldDefinition = getFieldDefinition;
|
|
7555
7872
|
exports.getFieldTypes = getFieldTypes;
|
|
7556
7873
|
exports.getRulePresetItems = getRulePresetItems;
|
|
7874
|
+
exports.hasLocaleText = hasLocaleText;
|
|
7557
7875
|
exports.hasRenderableContent = hasRenderableContent;
|
|
7558
7876
|
exports.isFieldNameUnique = isFieldNameUnique;
|
|
7877
|
+
exports.isLocaleText = isLocaleText;
|
|
7878
|
+
exports.localizeSchema = localizeSchema;
|
|
7559
7879
|
exports.mapBlocks = mapBlocks;
|
|
7560
7880
|
exports.moveBlockInTree = moveBlockInTree;
|
|
7561
7881
|
exports.moveItem = moveItem;
|
|
@@ -7571,6 +7891,7 @@ exports.registerField = registerField;
|
|
|
7571
7891
|
exports.removeBlockInTree = removeBlockInTree;
|
|
7572
7892
|
exports.resolveFieldTypeLabel = resolveFieldTypeLabel;
|
|
7573
7893
|
exports.resolveFieldValueSchema = resolveFieldValueSchema;
|
|
7894
|
+
exports.resolveLocaleText = resolveLocaleText;
|
|
7574
7895
|
exports.schemaToDataSchema = schemaToDataSchema;
|
|
7575
7896
|
exports.updateBlocks = updateBlocks;
|
|
7576
7897
|
//# sourceMappingURL=index.js.map
|