@kne/form-creator 0.1.22 → 0.1.23
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/dist/index.js +538 -681
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +133 -75
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +13 -0
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +13 -0
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +13 -0
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +13 -0
- package/dist/locale/zh-CN.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -55,6 +55,14 @@ const locale$1 = {
|
|
|
55
55
|
blockKind_object: '分组信息',
|
|
56
56
|
blockKind_choice: '选项切换',
|
|
57
57
|
blockKind_steps: '分步表单',
|
|
58
|
+
blockKindDesc_formInfo: '最常用的表单模块,可设置标题、列数和间距',
|
|
59
|
+
blockKindDesc_list: '用户可以动态添加或删除多条记录,例如工作经历',
|
|
60
|
+
blockKindDesc_tableList: '以表格形式展示的可增减列表',
|
|
61
|
+
blockKindDesc_editableList: '每条记录只读展示,点击编辑后单独填写并保存;数据量大时不卡顿',
|
|
62
|
+
blockKindDesc_multiField: '同一种填写项可以输入多个值,例如多个手机号',
|
|
63
|
+
blockKindDesc_object: '把相关的填写项放在一起,例如「在校时间」下的开始与结束',
|
|
64
|
+
blockKindDesc_choice: '先选一类情况,再填写对应内容;可设为单选或多选',
|
|
65
|
+
blockKindDesc_steps: '将表单拆分成多个步骤,引导用户逐步填写',
|
|
58
66
|
choiceMode: '可选几个',
|
|
59
67
|
choiceModeSingle: '只能选一个',
|
|
60
68
|
choiceModeMultiple: '可以选多个',
|
|
@@ -137,6 +145,7 @@ const locale$1 = {
|
|
|
137
145
|
FieldTypeSwitch: '开关',
|
|
138
146
|
FieldTypeCheckbox: '复选框',
|
|
139
147
|
FieldTypeDatePicker: '日期',
|
|
148
|
+
extendedFieldPlaceholder: '请选择{label}',
|
|
140
149
|
fieldName: '保存用的名称',
|
|
141
150
|
fieldNamePlaceholder: '已自动生成,可修改',
|
|
142
151
|
fieldLabel: '显示名称',
|
|
@@ -231,12 +240,16 @@ const locale$1 = {
|
|
|
231
240
|
propDatePickerQuarter: '季度',
|
|
232
241
|
propDatePickerYear: '年份',
|
|
233
242
|
propDateFormat: '显示格式',
|
|
243
|
+
propDateFormatLocalized: 'YYYY年MM月DD日',
|
|
234
244
|
propShowTime: '同时选择时间',
|
|
235
245
|
propSwitchOnText: '打开时显示的文字',
|
|
236
246
|
propSwitchOffText: '关闭时显示的文字',
|
|
237
247
|
propSwitchOnTextHint: '例如:开',
|
|
238
248
|
propSwitchOffTextHint: '例如:关',
|
|
239
249
|
propOptionsInline: '选项横向排列',
|
|
250
|
+
rulePresetREQ: '必填',
|
|
251
|
+
rulePresetTEL: '手机号格式',
|
|
252
|
+
rulePresetEMAIL: '邮箱格式',
|
|
240
253
|
ruleLen: '长度限制',
|
|
241
254
|
ruleLenRange: '长度范围',
|
|
242
255
|
ruleLenMin: '最少字数',
|
|
@@ -254,7 +267,7 @@ const locale$1 = {
|
|
|
254
267
|
schemaContentUntilToday: '至今',
|
|
255
268
|
schemaContentPasswordMasked: '••••••'
|
|
256
269
|
};
|
|
257
|
-
var
|
|
270
|
+
var defaultLocale = locale$1;
|
|
258
271
|
|
|
259
272
|
const locale = {
|
|
260
273
|
addField: 'Add Field',
|
|
@@ -286,6 +299,14 @@ const locale = {
|
|
|
286
299
|
blockKind_object: 'Grouped Fields',
|
|
287
300
|
blockKind_choice: 'Options',
|
|
288
301
|
blockKind_steps: 'Step-by-Step',
|
|
302
|
+
blockKindDesc_formInfo: 'The most common section; set its title, columns and spacing',
|
|
303
|
+
blockKindDesc_list: 'Users can add or remove multiple records, e.g. work experience',
|
|
304
|
+
blockKindDesc_tableList: 'A repeatable list displayed as a table',
|
|
305
|
+
blockKindDesc_editableList: 'Records are shown read-only; click edit to fill in and save each one. Stays fast with lots of data',
|
|
306
|
+
blockKindDesc_multiField: 'Enter multiple values for the same field, e.g. several phone numbers',
|
|
307
|
+
blockKindDesc_object: 'Group related fields together, e.g. start and end under "School period"',
|
|
308
|
+
blockKindDesc_choice: 'Pick a case first, then fill in the matching content; single or multiple selection',
|
|
309
|
+
blockKindDesc_steps: 'Split the form into steps to guide users through it',
|
|
289
310
|
choiceMode: 'How many can be selected',
|
|
290
311
|
choiceModeSingle: 'One only',
|
|
291
312
|
choiceModeMultiple: 'More than one',
|
|
@@ -368,6 +389,7 @@ const locale = {
|
|
|
368
389
|
FieldTypeSwitch: 'Switch',
|
|
369
390
|
FieldTypeCheckbox: 'Checkbox',
|
|
370
391
|
FieldTypeDatePicker: 'Date',
|
|
392
|
+
extendedFieldPlaceholder: 'Please select {label}',
|
|
371
393
|
fieldName: 'Save name',
|
|
372
394
|
fieldNamePlaceholder: 'Auto-generated, editable',
|
|
373
395
|
fieldLabel: 'Display Name',
|
|
@@ -462,12 +484,16 @@ const locale = {
|
|
|
462
484
|
propDatePickerQuarter: 'Quarter',
|
|
463
485
|
propDatePickerYear: 'Year',
|
|
464
486
|
propDateFormat: 'Display format',
|
|
487
|
+
propDateFormatLocalized: 'MMM D, YYYY',
|
|
465
488
|
propShowTime: 'Include time',
|
|
466
489
|
propSwitchOnText: 'Text when on',
|
|
467
490
|
propSwitchOffText: 'Text when off',
|
|
468
491
|
propSwitchOnTextHint: 'e.g. On',
|
|
469
492
|
propSwitchOffTextHint: 'e.g. Off',
|
|
470
493
|
propOptionsInline: 'Arrange options horizontally',
|
|
494
|
+
rulePresetREQ: 'Required',
|
|
495
|
+
rulePresetTEL: 'Phone number format',
|
|
496
|
+
rulePresetEMAIL: 'Email format',
|
|
471
497
|
ruleLen: 'Length Limit',
|
|
472
498
|
ruleLenRange: 'Length Range',
|
|
473
499
|
ruleLenMin: 'Min',
|
|
@@ -490,7 +516,7 @@ var enUS = locale;
|
|
|
490
516
|
const withLocale = reactIntl.createWithIntlProvider({
|
|
491
517
|
defaultLocale: 'zh-CN',
|
|
492
518
|
messages: {
|
|
493
|
-
'zh-CN':
|
|
519
|
+
'zh-CN': defaultLocale,
|
|
494
520
|
'en-US': enUS
|
|
495
521
|
},
|
|
496
522
|
namespace: 'form-creator'
|
|
@@ -500,18 +526,8 @@ var withLocale$1 = withLocale;
|
|
|
500
526
|
const createFieldId = () => `field_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
501
527
|
|
|
502
528
|
/** 生成可编辑的默认数据标识,如 field_xxxx / col_xxxx */
|
|
503
|
-
const createDataKey =
|
|
504
|
-
|
|
505
|
-
prefix = 'field';
|
|
506
|
-
}
|
|
507
|
-
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 6)}`;
|
|
508
|
-
};
|
|
509
|
-
const isAutoDataKey = function (value, prefix) {
|
|
510
|
-
if (prefix === void 0) {
|
|
511
|
-
prefix = 'field';
|
|
512
|
-
}
|
|
513
|
-
return new RegExp(`^${prefix}_[a-z0-9]+_[a-z0-9]+$`, 'i').test(String(value || '').trim());
|
|
514
|
-
};
|
|
529
|
+
const createDataKey = (prefix = 'field') => `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 6)}`;
|
|
530
|
+
const isAutoDataKey = (value, prefix = 'field') => new RegExp(`^${prefix}_[a-z0-9]+_[a-z0-9]+$`, 'i').test(String(value || '').trim());
|
|
515
531
|
const MAX_BLOCK_DEPTH = 14;
|
|
516
532
|
|
|
517
533
|
/** 列表项内可挂子模块(itemBlocks)的模块类型 */
|
|
@@ -543,10 +559,7 @@ const defaultFormActions = () => ({
|
|
|
543
559
|
gap: 16
|
|
544
560
|
});
|
|
545
561
|
const FORM_ACTIONS_ALIGN = ['center', 'start', 'end'];
|
|
546
|
-
const normalizeFormActions =
|
|
547
|
-
if (actions === void 0) {
|
|
548
|
-
actions = {};
|
|
549
|
-
}
|
|
562
|
+
const normalizeFormActions = (actions = {}) => {
|
|
550
563
|
const base = defaultFormActions();
|
|
551
564
|
if (!actions || typeof actions !== 'object') {
|
|
552
565
|
return base;
|
|
@@ -580,40 +593,27 @@ const normalizeFormActions = function (actions) {
|
|
|
580
593
|
} : {})
|
|
581
594
|
};
|
|
582
595
|
};
|
|
583
|
-
const createField$1 =
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
return {
|
|
606
|
-
id: createFieldId(),
|
|
607
|
-
title: '',
|
|
608
|
-
list: [],
|
|
609
|
-
blocks: [],
|
|
610
|
-
...overrides
|
|
611
|
-
};
|
|
612
|
-
};
|
|
613
|
-
const createBlock = function (kind, overrides) {
|
|
614
|
-
if (overrides === void 0) {
|
|
615
|
-
overrides = {};
|
|
616
|
-
}
|
|
596
|
+
const createField$1 = (overrides = {}) => ({
|
|
597
|
+
id: createFieldId(),
|
|
598
|
+
type: 'Input',
|
|
599
|
+
name: createDataKey('field'),
|
|
600
|
+
label: '',
|
|
601
|
+
tips: '',
|
|
602
|
+
description: '',
|
|
603
|
+
rule: '',
|
|
604
|
+
block: false,
|
|
605
|
+
hidden: false,
|
|
606
|
+
props: {},
|
|
607
|
+
...overrides
|
|
608
|
+
});
|
|
609
|
+
const createChoiceOption = (overrides = {}) => ({
|
|
610
|
+
id: createFieldId(),
|
|
611
|
+
title: '',
|
|
612
|
+
list: [],
|
|
613
|
+
blocks: [],
|
|
614
|
+
...overrides
|
|
615
|
+
});
|
|
616
|
+
const createBlock = (kind, overrides = {}) => {
|
|
617
617
|
const needsName = ['list', 'tableList', 'editableList', 'multiField', 'object'].includes(kind);
|
|
618
618
|
const base = {
|
|
619
619
|
id: createFieldId(),
|
|
@@ -672,17 +672,13 @@ const createBlock = function (kind, overrides) {
|
|
|
672
672
|
blocks: undefined,
|
|
673
673
|
items: undefined,
|
|
674
674
|
name: '',
|
|
675
|
-
options: [createChoiceOption(
|
|
676
|
-
title: '选项1'
|
|
677
|
-
})],
|
|
675
|
+
options: [createChoiceOption()],
|
|
678
676
|
...overrides,
|
|
679
677
|
kind: 'choice'
|
|
680
678
|
};
|
|
681
679
|
next.mode = next.mode === 'multiple' ? 'multiple' : 'single';
|
|
682
680
|
if (!Array.isArray(next.options)) {
|
|
683
|
-
next.options = [createChoiceOption(
|
|
684
|
-
title: '选项1'
|
|
685
|
-
})];
|
|
681
|
+
next.options = [createChoiceOption()];
|
|
686
682
|
}
|
|
687
683
|
return next;
|
|
688
684
|
}
|
|
@@ -718,23 +714,15 @@ const createBlock = function (kind, overrides) {
|
|
|
718
714
|
...overrides
|
|
719
715
|
};
|
|
720
716
|
};
|
|
721
|
-
const createStep =
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
blocks: [],
|
|
731
|
-
...overrides
|
|
732
|
-
};
|
|
733
|
-
};
|
|
734
|
-
const normalizeSelectCount = function (value, minAllowed) {
|
|
735
|
-
if (minAllowed === void 0) {
|
|
736
|
-
minAllowed = 0;
|
|
737
|
-
}
|
|
717
|
+
const createStep = (overrides = {}) => ({
|
|
718
|
+
id: createFieldId(),
|
|
719
|
+
title: '',
|
|
720
|
+
column: 2,
|
|
721
|
+
list: [],
|
|
722
|
+
blocks: [],
|
|
723
|
+
...overrides
|
|
724
|
+
});
|
|
725
|
+
const normalizeSelectCount = (value, minAllowed = 0) => {
|
|
738
726
|
if (value == null || value === '') {
|
|
739
727
|
return undefined;
|
|
740
728
|
}
|
|
@@ -755,17 +743,12 @@ const normalizeField = field => ({
|
|
|
755
743
|
...(field.props || {})
|
|
756
744
|
}
|
|
757
745
|
});
|
|
758
|
-
const normalizeStep =
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
...step,
|
|
765
|
-
list: Array.isArray(step.list) ? step.list.map(normalizeField) : [],
|
|
766
|
-
blocks: Array.isArray(step.blocks) ? step.blocks.map(child => normalizeBlock(child, depth + 1)) : []
|
|
767
|
-
};
|
|
768
|
-
};
|
|
746
|
+
const normalizeStep = (step, depth = 0) => ({
|
|
747
|
+
...createStep(),
|
|
748
|
+
...step,
|
|
749
|
+
list: Array.isArray(step.list) ? step.list.map(normalizeField) : [],
|
|
750
|
+
blocks: Array.isArray(step.blocks) ? step.blocks.map(child => normalizeBlock(child, depth + 1)) : []
|
|
751
|
+
});
|
|
769
752
|
const normalizeChoiceOption = (option, depth) => {
|
|
770
753
|
let list = Array.isArray(option.list) ? option.list.map(normalizeField) : [];
|
|
771
754
|
let blocks = Array.isArray(option.blocks) ? option.blocks.map(block => normalizeBlock(block, depth + 1)) : [];
|
|
@@ -782,10 +765,7 @@ const normalizeChoiceOption = (option, depth) => {
|
|
|
782
765
|
blocks
|
|
783
766
|
};
|
|
784
767
|
};
|
|
785
|
-
const normalizeBlock =
|
|
786
|
-
if (depth === void 0) {
|
|
787
|
-
depth = 0;
|
|
788
|
-
}
|
|
768
|
+
const normalizeBlock = (block, depth = 0) => {
|
|
789
769
|
const kind = block.kind || 'formInfo';
|
|
790
770
|
if (depth > MAX_BLOCK_DEPTH) {
|
|
791
771
|
return {
|
|
@@ -864,10 +844,7 @@ const normalizeBlock = function (block, depth) {
|
|
|
864
844
|
}
|
|
865
845
|
return normalized;
|
|
866
846
|
};
|
|
867
|
-
const normalizeSchema =
|
|
868
|
-
if (schema === void 0) {
|
|
869
|
-
schema = {};
|
|
870
|
-
}
|
|
847
|
+
const normalizeSchema = (schema = {}) => {
|
|
871
848
|
const base = defaultSchema();
|
|
872
849
|
if (Array.isArray(schema.blocks)) {
|
|
873
850
|
return {
|
|
@@ -919,13 +896,7 @@ const isFieldNameUnique = (fields, name, excludeId) => {
|
|
|
919
896
|
}
|
|
920
897
|
return !fields.some(item => item.name === name && item.id !== excludeId);
|
|
921
898
|
};
|
|
922
|
-
const collectFieldsFromBlocks =
|
|
923
|
-
if (blocks === void 0) {
|
|
924
|
-
blocks = [];
|
|
925
|
-
}
|
|
926
|
-
if (acc === void 0) {
|
|
927
|
-
acc = [];
|
|
928
|
-
}
|
|
899
|
+
const collectFieldsFromBlocks = (blocks = [], acc = []) => {
|
|
929
900
|
blocks.forEach(block => {
|
|
930
901
|
if (!block) {
|
|
931
902
|
return;
|
|
@@ -956,12 +927,11 @@ const collectFieldsFromBlocks = function (blocks, acc) {
|
|
|
956
927
|
});
|
|
957
928
|
return acc;
|
|
958
929
|
};
|
|
959
|
-
const collectSchemaFields =
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
} = _temp === void 0 ? {} : _temp;
|
|
930
|
+
const collectSchemaFields = (schema, {
|
|
931
|
+
blockId,
|
|
932
|
+
stepId,
|
|
933
|
+
optionId
|
|
934
|
+
} = {}) => {
|
|
965
935
|
const blocks = schema.blocks || [];
|
|
966
936
|
if (!blockId) {
|
|
967
937
|
return collectFieldsFromBlocks(blocks);
|
|
@@ -997,13 +967,9 @@ const collectSchemaFields = function (schema, _temp) {
|
|
|
997
967
|
};
|
|
998
968
|
|
|
999
969
|
/** 收集 blocks 树中所有字段 name(含 object 前缀后的完整名需在渲染层处理) */
|
|
1000
|
-
const collectBlockFieldNames =
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
}
|
|
1004
|
-
let {
|
|
1005
|
-
objectNamePrefix = ''
|
|
1006
|
-
} = _temp2 === void 0 ? {} : _temp2;
|
|
970
|
+
const collectBlockFieldNames = (blocks = [], {
|
|
971
|
+
objectNamePrefix = ''
|
|
972
|
+
} = {}) => {
|
|
1007
973
|
const names = [];
|
|
1008
974
|
const walk = (list, prefix) => {
|
|
1009
975
|
(list || []).forEach(block => {
|
|
@@ -1067,10 +1033,7 @@ const updateBlocks = (schema, updater) => ({
|
|
|
1067
1033
|
});
|
|
1068
1034
|
|
|
1069
1035
|
/** 在 blocks / itemBlocks / choice.options.blocks / steps.items.blocks 树中查找模块 */
|
|
1070
|
-
const findBlockInTree =
|
|
1071
|
-
if (blocks === void 0) {
|
|
1072
|
-
blocks = [];
|
|
1073
|
-
}
|
|
1036
|
+
const findBlockInTree = (blocks = [], blockId) => {
|
|
1074
1037
|
for (const block of blocks) {
|
|
1075
1038
|
if (!block) {
|
|
1076
1039
|
continue;
|
|
@@ -1276,68 +1239,67 @@ const hasRenderableContent = schema => {
|
|
|
1276
1239
|
|
|
1277
1240
|
const BLOCK_KINDS = {
|
|
1278
1241
|
formInfo: {
|
|
1279
|
-
|
|
1242
|
+
labelId: 'blockKind_formInfo',
|
|
1280
1243
|
color: 'blue',
|
|
1281
1244
|
hasFieldList: true,
|
|
1282
|
-
|
|
1245
|
+
descriptionId: 'blockKindDesc_formInfo'
|
|
1283
1246
|
},
|
|
1284
1247
|
list: {
|
|
1285
|
-
|
|
1248
|
+
labelId: 'blockKind_list',
|
|
1286
1249
|
color: 'cyan',
|
|
1287
1250
|
hasFieldList: true,
|
|
1288
1251
|
requiresName: true,
|
|
1289
|
-
|
|
1252
|
+
descriptionId: 'blockKindDesc_list'
|
|
1290
1253
|
},
|
|
1291
1254
|
tableList: {
|
|
1292
|
-
|
|
1255
|
+
labelId: 'blockKind_tableList',
|
|
1293
1256
|
color: 'geekblue',
|
|
1294
1257
|
hasFieldList: true,
|
|
1295
1258
|
requiresName: true,
|
|
1296
|
-
|
|
1259
|
+
descriptionId: 'blockKindDesc_tableList'
|
|
1297
1260
|
},
|
|
1298
1261
|
editableList: {
|
|
1299
|
-
|
|
1262
|
+
labelId: 'blockKind_editableList',
|
|
1300
1263
|
color: 'green',
|
|
1301
1264
|
hasFieldList: true,
|
|
1302
1265
|
requiresName: true,
|
|
1303
|
-
|
|
1266
|
+
descriptionId: 'blockKindDesc_editableList'
|
|
1304
1267
|
},
|
|
1305
1268
|
multiField: {
|
|
1306
|
-
|
|
1269
|
+
labelId: 'blockKind_multiField',
|
|
1307
1270
|
color: 'purple',
|
|
1308
1271
|
requiresName: true,
|
|
1309
|
-
|
|
1272
|
+
descriptionId: 'blockKindDesc_multiField'
|
|
1310
1273
|
},
|
|
1311
1274
|
object: {
|
|
1312
|
-
|
|
1275
|
+
labelId: 'blockKind_object',
|
|
1313
1276
|
color: 'orange',
|
|
1314
1277
|
hasFieldList: true,
|
|
1315
1278
|
requiresName: true,
|
|
1316
|
-
|
|
1279
|
+
descriptionId: 'blockKindDesc_object'
|
|
1317
1280
|
},
|
|
1318
1281
|
choice: {
|
|
1319
|
-
|
|
1282
|
+
labelId: 'blockKind_choice',
|
|
1320
1283
|
color: 'magenta',
|
|
1321
1284
|
hasChoiceOptions: true,
|
|
1322
|
-
|
|
1285
|
+
descriptionId: 'blockKindDesc_choice'
|
|
1323
1286
|
},
|
|
1324
1287
|
steps: {
|
|
1325
|
-
|
|
1288
|
+
labelId: 'blockKind_steps',
|
|
1326
1289
|
color: 'gold',
|
|
1327
1290
|
hasSteps: true,
|
|
1328
|
-
|
|
1291
|
+
descriptionId: 'blockKindDesc_steps'
|
|
1329
1292
|
}
|
|
1330
1293
|
};
|
|
1331
1294
|
|
|
1332
1295
|
/** editableList 添加按钮位置,与 @kne/form-info EditableList addPosition 一致 */
|
|
1333
1296
|
const ADD_POSITIONS = ['bottom', 'top', 'both'];
|
|
1334
|
-
const getBlockKindOptions =
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
});
|
|
1297
|
+
const getBlockKindOptions = formatMessage => Object.entries(BLOCK_KINDS).map(([value, config]) => ({
|
|
1298
|
+
label: typeof formatMessage === 'function' ? formatMessage({
|
|
1299
|
+
id: config.labelId
|
|
1300
|
+
}) : config.labelId,
|
|
1301
|
+
value
|
|
1302
|
+
}));
|
|
1341
1303
|
const getBlockDefinition = kind => BLOCK_KINDS[kind];
|
|
1342
1304
|
const blockToFormValues = block => ({
|
|
1343
1305
|
kind: block.kind,
|
|
@@ -1360,10 +1322,7 @@ const blockToFormValues = block => ({
|
|
|
1360
1322
|
selectorName: block.selectorName || '',
|
|
1361
1323
|
selectorInData: block.selectorInData !== false
|
|
1362
1324
|
});
|
|
1363
|
-
const formValuesToBlock =
|
|
1364
|
-
if (existingBlock === void 0) {
|
|
1365
|
-
existingBlock = {};
|
|
1366
|
-
}
|
|
1325
|
+
const formValuesToBlock = (values, existingBlock = {}) => {
|
|
1367
1326
|
const kind = values.kind || existingBlock.kind;
|
|
1368
1327
|
const mode = values.mode === 'multiple' ? 'multiple' : 'single';
|
|
1369
1328
|
const next = {
|
|
@@ -1398,28 +1357,18 @@ const stepToFormValues = step => ({
|
|
|
1398
1357
|
title: step.title || '',
|
|
1399
1358
|
column: step.column ?? 2
|
|
1400
1359
|
});
|
|
1401
|
-
const formValuesToStep =
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
...existingStep,
|
|
1407
|
-
title: values.title,
|
|
1408
|
-
column: values.column ?? 2
|
|
1409
|
-
};
|
|
1410
|
-
};
|
|
1360
|
+
const formValuesToStep = (values, existingStep = {}) => ({
|
|
1361
|
+
...existingStep,
|
|
1362
|
+
title: values.title,
|
|
1363
|
+
column: values.column ?? 2
|
|
1364
|
+
});
|
|
1411
1365
|
const choiceOptionToFormValues = option => ({
|
|
1412
1366
|
title: option.title || ''
|
|
1413
1367
|
});
|
|
1414
|
-
const formValuesToChoiceOption =
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
return {
|
|
1419
|
-
...existingOption,
|
|
1420
|
-
title: values.title
|
|
1421
|
-
};
|
|
1422
|
-
};
|
|
1368
|
+
const formValuesToChoiceOption = (values, existingOption = {}) => ({
|
|
1369
|
+
...existingOption,
|
|
1370
|
+
title: values.title
|
|
1371
|
+
});
|
|
1423
1372
|
|
|
1424
1373
|
const mapOptionItem = item => {
|
|
1425
1374
|
if (!item || typeof item !== 'object') {
|
|
@@ -1525,13 +1474,15 @@ const {
|
|
|
1525
1474
|
useOnChange: useOnChange$1
|
|
1526
1475
|
} = reactFormAntd.hooks;
|
|
1527
1476
|
const hasNestedOptions = options => Array.isArray(options) && options.some(item => Array.isArray(item?.children) && item.children.length);
|
|
1528
|
-
const createField =
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1477
|
+
const createField = (Component, {
|
|
1478
|
+
preferOptions = false,
|
|
1479
|
+
flattenTree = false
|
|
1480
|
+
} = {}) => {
|
|
1481
|
+
const FieldInner = props => {
|
|
1482
|
+
const {
|
|
1483
|
+
formatMessage,
|
|
1484
|
+
locale
|
|
1485
|
+
} = reactIntl.useIntl();
|
|
1535
1486
|
const {
|
|
1536
1487
|
options,
|
|
1537
1488
|
api,
|
|
@@ -1551,11 +1502,16 @@ const createField = function (Component, _temp) {
|
|
|
1551
1502
|
}) : flattened;
|
|
1552
1503
|
const useOptionsDirectly = preferOptions || hasNestedOptions(resolvedOptions);
|
|
1553
1504
|
const mergedApi = api || (!useOptionsDirectly && Array.isArray(resolvedOptions) && resolvedOptions.length ? createApiFromOptions(resolvedOptions) : undefined);
|
|
1554
|
-
const resolvedPlaceholder = placeholder != null && String(placeholder).trim() ? placeholder :
|
|
1505
|
+
const resolvedPlaceholder = placeholder != null && String(placeholder).trim() ? placeholder : formatMessage({
|
|
1506
|
+
id: 'extendedFieldPlaceholder'
|
|
1507
|
+
}, {
|
|
1508
|
+
label: props.label || ''
|
|
1509
|
+
}).trim();
|
|
1555
1510
|
const render = useOnChange$1(Object.assign({}, {
|
|
1556
1511
|
isPopup: true,
|
|
1557
1512
|
placeholder: resolvedPlaceholder
|
|
1558
1513
|
}, rest, {
|
|
1514
|
+
locale,
|
|
1559
1515
|
valueKey,
|
|
1560
1516
|
labelKey
|
|
1561
1517
|
}, useOptionsDirectly && Array.isArray(resolvedOptions) ? {
|
|
@@ -1565,6 +1521,7 @@ const createField = function (Component, _temp) {
|
|
|
1565
1521
|
} : {}));
|
|
1566
1522
|
return render(Component);
|
|
1567
1523
|
};
|
|
1524
|
+
const Field = withLocale$1(FieldInner);
|
|
1568
1525
|
Field.field = Component;
|
|
1569
1526
|
return Field;
|
|
1570
1527
|
};
|
|
@@ -1585,13 +1542,13 @@ const SelectAddressField = createField(superSelectPlus.SelectAddress);
|
|
|
1585
1542
|
|
|
1586
1543
|
const RULE_PRESET_ITEMS = [{
|
|
1587
1544
|
value: 'REQ',
|
|
1588
|
-
|
|
1545
|
+
labelId: 'rulePresetREQ'
|
|
1589
1546
|
}, {
|
|
1590
1547
|
value: 'TEL',
|
|
1591
|
-
|
|
1548
|
+
labelId: 'rulePresetTEL'
|
|
1592
1549
|
}, {
|
|
1593
1550
|
value: 'EMAIL',
|
|
1594
|
-
|
|
1551
|
+
labelId: 'rulePresetEMAIL'
|
|
1595
1552
|
}];
|
|
1596
1553
|
const DEFAULT_RULE_CONFIG = () => ({
|
|
1597
1554
|
presets: [],
|
|
@@ -1637,12 +1594,11 @@ const parseRuleString = rule => {
|
|
|
1637
1594
|
});
|
|
1638
1595
|
return config;
|
|
1639
1596
|
};
|
|
1640
|
-
const buildRuleString =
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
} = _temp === void 0 ? {} : _temp;
|
|
1597
|
+
const buildRuleString = ({
|
|
1598
|
+
presets = [],
|
|
1599
|
+
lenMin,
|
|
1600
|
+
lenMax
|
|
1601
|
+
} = {}) => {
|
|
1646
1602
|
const parts = [];
|
|
1647
1603
|
RULE_PRESET_ITEMS.forEach(item => {
|
|
1648
1604
|
if (presets.includes(item.value)) {
|
|
@@ -1988,16 +1944,7 @@ const registerField = (type, definition) => {
|
|
|
1988
1944
|
hasFieldProps: definition.hasFieldProps ?? !!(propsSchema && propsSchema.length)
|
|
1989
1945
|
});
|
|
1990
1946
|
};
|
|
1991
|
-
const pickFromPropsSchema =
|
|
1992
|
-
if (props === void 0) {
|
|
1993
|
-
props = {};
|
|
1994
|
-
}
|
|
1995
|
-
if (propsSchema === void 0) {
|
|
1996
|
-
propsSchema = [];
|
|
1997
|
-
}
|
|
1998
|
-
if (defaultProps === void 0) {
|
|
1999
|
-
defaultProps = {};
|
|
2000
|
-
}
|
|
1947
|
+
const pickFromPropsSchema = (props = {}, propsSchema = [], defaultProps = {}) => {
|
|
2001
1948
|
const next = {};
|
|
2002
1949
|
propsSchema.forEach(item => {
|
|
2003
1950
|
if (!item?.name) {
|
|
@@ -2021,13 +1968,7 @@ const pickFromPropsSchema = function (props, propsSchema, defaultProps) {
|
|
|
2021
1968
|
});
|
|
2022
1969
|
return next;
|
|
2023
1970
|
};
|
|
2024
|
-
const applyFromPropsSchema =
|
|
2025
|
-
if (values === void 0) {
|
|
2026
|
-
values = {};
|
|
2027
|
-
}
|
|
2028
|
-
if (propsSchema === void 0) {
|
|
2029
|
-
propsSchema = [];
|
|
2030
|
-
}
|
|
1971
|
+
const applyFromPropsSchema = (props, values = {}, propsSchema = []) => {
|
|
2031
1972
|
propsSchema.forEach(item => {
|
|
2032
1973
|
if (!item?.name) {
|
|
2033
1974
|
return;
|
|
@@ -2151,11 +2092,10 @@ const getFieldTypes = formatMessage => {
|
|
|
2151
2092
|
}
|
|
2152
2093
|
customGroups.get(groupKey).options.push(option);
|
|
2153
2094
|
});
|
|
2154
|
-
customGroups.forEach(
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
} = _ref;
|
|
2095
|
+
customGroups.forEach(({
|
|
2096
|
+
label,
|
|
2097
|
+
options
|
|
2098
|
+
}) => {
|
|
2159
2099
|
grouped.push({
|
|
2160
2100
|
label,
|
|
2161
2101
|
options
|
|
@@ -2163,17 +2103,16 @@ const getFieldTypes = formatMessage => {
|
|
|
2163
2103
|
});
|
|
2164
2104
|
if (fallback.length) {
|
|
2165
2105
|
grouped.push({
|
|
2166
|
-
label: resolveRegistryLabel(formatMessage, 'FieldGroupExtended'
|
|
2106
|
+
label: resolveRegistryLabel(formatMessage, 'FieldGroupExtended'),
|
|
2167
2107
|
options: fallback
|
|
2168
2108
|
});
|
|
2169
2109
|
}
|
|
2170
2110
|
return grouped;
|
|
2171
2111
|
};
|
|
2172
|
-
const normalizeOptions =
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
} = _temp === void 0 ? {} : _temp;
|
|
2112
|
+
const normalizeOptions = (options, {
|
|
2113
|
+
allowChildren = false,
|
|
2114
|
+
columns = []
|
|
2115
|
+
} = {}) => {
|
|
2177
2116
|
if (!Array.isArray(options)) {
|
|
2178
2117
|
return [];
|
|
2179
2118
|
}
|
|
@@ -2403,10 +2342,14 @@ const applyFieldProps = (props, values, definition) => {
|
|
|
2403
2342
|
delete props.showTime;
|
|
2404
2343
|
}
|
|
2405
2344
|
if (values.range) {
|
|
2406
|
-
// RangePicker 用数组 placeholder
|
|
2345
|
+
// RangePicker 用数组 placeholder;单框用字符串;未填时交给 RangePicker 按 locale 显示默认提示
|
|
2407
2346
|
const raw = values.placeholder;
|
|
2408
|
-
const text =
|
|
2409
|
-
|
|
2347
|
+
const text = Array.isArray(raw) ? raw[0] : raw;
|
|
2348
|
+
if (text != null && String(text).trim()) {
|
|
2349
|
+
props.placeholder = [text, text];
|
|
2350
|
+
} else {
|
|
2351
|
+
delete props.placeholder;
|
|
2352
|
+
}
|
|
2410
2353
|
} else {
|
|
2411
2354
|
setOptionalString(props, 'placeholder', values.placeholder);
|
|
2412
2355
|
}
|
|
@@ -2458,10 +2401,7 @@ const fieldToFormValues = field => {
|
|
|
2458
2401
|
fieldProps: definition?.hasFieldProps ? pickFieldProps(field, definition) : undefined
|
|
2459
2402
|
};
|
|
2460
2403
|
};
|
|
2461
|
-
const formValuesToField =
|
|
2462
|
-
if (existingField === void 0) {
|
|
2463
|
-
existingField = {};
|
|
2464
|
-
}
|
|
2404
|
+
const formValuesToField = (values, existingField = {}) => {
|
|
2465
2405
|
const definition = getFieldDefinition(values.type) || getFieldDefinition('Input');
|
|
2466
2406
|
// 不沿用旧类型残留 props,避免切换填写项类型后参数串味
|
|
2467
2407
|
const props = {
|
|
@@ -2618,30 +2558,24 @@ var FieldRow$1 = FieldRow;
|
|
|
2618
2558
|
const {
|
|
2619
2559
|
Text: Text$3
|
|
2620
2560
|
} = antd.Typography;
|
|
2621
|
-
const ActionGroup =
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
title: title,
|
|
2640
|
-
danger: danger,
|
|
2641
|
-
className: style['action-btn'],
|
|
2642
|
-
...props
|
|
2643
|
-
});
|
|
2644
|
-
};
|
|
2561
|
+
const ActionGroup = ({
|
|
2562
|
+
children
|
|
2563
|
+
}) => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2564
|
+
className: style['action-group'],
|
|
2565
|
+
children: children
|
|
2566
|
+
});
|
|
2567
|
+
const IconBtn = ({
|
|
2568
|
+
title,
|
|
2569
|
+
danger,
|
|
2570
|
+
...props
|
|
2571
|
+
}) => /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
2572
|
+
type: "text",
|
|
2573
|
+
size: "small",
|
|
2574
|
+
title: title,
|
|
2575
|
+
danger: danger,
|
|
2576
|
+
className: style['action-btn'],
|
|
2577
|
+
...props
|
|
2578
|
+
});
|
|
2645
2579
|
const ROOT_ADD_OPTIONS = [{
|
|
2646
2580
|
key: 'formInfo',
|
|
2647
2581
|
icon: /*#__PURE__*/jsxRuntime.jsx(icons.FormOutlined, {})
|
|
@@ -2670,79 +2604,76 @@ const ROOT_ADD_OPTIONS = [{
|
|
|
2670
2604
|
|
|
2671
2605
|
/** 可挂子模块的容器;表格列表 / 同类多值本身不支持子模块 */
|
|
2672
2606
|
const NESTED_ADD_OPTIONS = ROOT_ADD_OPTIONS.filter(opt => opt.key !== 'steps');
|
|
2673
|
-
const BlockListPanel =
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
} = _ref3;
|
|
2607
|
+
const BlockListPanel = ({
|
|
2608
|
+
blocks,
|
|
2609
|
+
onAddBlock,
|
|
2610
|
+
onEditBlock,
|
|
2611
|
+
onDeleteBlock,
|
|
2612
|
+
onMoveBlock,
|
|
2613
|
+
onAddField,
|
|
2614
|
+
onEditField,
|
|
2615
|
+
onDeleteField,
|
|
2616
|
+
onMoveField,
|
|
2617
|
+
onAddStep,
|
|
2618
|
+
onEditStep,
|
|
2619
|
+
onDeleteStep,
|
|
2620
|
+
onMoveStep,
|
|
2621
|
+
onAddChoiceOption,
|
|
2622
|
+
onEditChoiceOption,
|
|
2623
|
+
onDeleteChoiceOption,
|
|
2624
|
+
onMoveChoiceOption,
|
|
2625
|
+
onOpenFormActions,
|
|
2626
|
+
extraToolbar
|
|
2627
|
+
}) => {
|
|
2695
2628
|
const {
|
|
2696
2629
|
formatMessage
|
|
2697
2630
|
} = reactIntl.useIntl();
|
|
2698
2631
|
const [addMenuOpen, setAddMenuOpen] = react.useState(false);
|
|
2699
2632
|
const [addFieldMenuId, setAddFieldMenuId] = react.useState(null);
|
|
2700
2633
|
const keepAddFieldMenuOpenRef = react.useRef(false);
|
|
2701
|
-
const renderAddBlockMenu =
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2634
|
+
const renderAddBlockMenu = (options, {
|
|
2635
|
+
onSelect,
|
|
2636
|
+
className
|
|
2637
|
+
} = {}) => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2638
|
+
className: className || style['add-block-dropdown'],
|
|
2639
|
+
children: options.map(opt => {
|
|
2640
|
+
const definition = getBlockDefinition(opt.key);
|
|
2641
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2642
|
+
role: "button",
|
|
2643
|
+
tabIndex: 0,
|
|
2644
|
+
className: style['add-block-option'],
|
|
2645
|
+
onClick: () => onSelect(opt.key),
|
|
2646
|
+
onKeyDown: e => {
|
|
2647
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
2648
|
+
onSelect(opt.key);
|
|
2649
|
+
}
|
|
2650
|
+
},
|
|
2651
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2652
|
+
className: style['add-block-option-icon'],
|
|
2653
|
+
children: opt.icon
|
|
2654
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2655
|
+
className: style['add-block-option-text'],
|
|
2720
2656
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2721
|
-
className: style['add-block-option-
|
|
2722
|
-
children:
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2731
|
-
className: style['add-block-option-desc'],
|
|
2732
|
-
children: definition?.description
|
|
2733
|
-
})]
|
|
2657
|
+
className: style['add-block-option-title'],
|
|
2658
|
+
children: formatMessage({
|
|
2659
|
+
id: `blockKind_${opt.key}`
|
|
2660
|
+
})
|
|
2661
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2662
|
+
className: style['add-block-option-desc'],
|
|
2663
|
+
children: definition ? formatMessage({
|
|
2664
|
+
id: definition.descriptionId
|
|
2665
|
+
}) : null
|
|
2734
2666
|
})]
|
|
2735
|
-
}
|
|
2736
|
-
})
|
|
2737
|
-
})
|
|
2738
|
-
};
|
|
2739
|
-
const renderAddFieldButton =
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
} = _ref4;
|
|
2667
|
+
})]
|
|
2668
|
+
}, opt.key);
|
|
2669
|
+
})
|
|
2670
|
+
});
|
|
2671
|
+
const renderAddFieldButton = ({
|
|
2672
|
+
menuKey,
|
|
2673
|
+
depth,
|
|
2674
|
+
onAddFieldClick,
|
|
2675
|
+
onAddChildBlock
|
|
2676
|
+
}) => {
|
|
2746
2677
|
const canAddChild = typeof onAddChildBlock === 'function' && depth < MAX_BLOCK_DEPTH;
|
|
2747
2678
|
const menuOpen = addFieldMenuId === menuKey;
|
|
2748
2679
|
const btnClass = `${style['add-inline-btn']} ${style['hover-reveal']} ${menuOpen ? style['hover-reveal-active'] : ''}`.trim();
|
|
@@ -2830,9 +2761,11 @@ const BlockListPanel = _ref3 => {
|
|
|
2830
2761
|
children: formatMessage({
|
|
2831
2762
|
id: `blockKind_${opt.key}`
|
|
2832
2763
|
})
|
|
2833
|
-
}), definition
|
|
2764
|
+
}), definition ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
2834
2765
|
className: style['add-field-dropdown-item-desc'],
|
|
2835
|
-
children:
|
|
2766
|
+
children: formatMessage({
|
|
2767
|
+
id: definition.descriptionId
|
|
2768
|
+
})
|
|
2836
2769
|
}) : null]
|
|
2837
2770
|
}, opt.key);
|
|
2838
2771
|
})]
|
|
@@ -2854,11 +2787,10 @@ const BlockListPanel = _ref3 => {
|
|
|
2854
2787
|
})
|
|
2855
2788
|
});
|
|
2856
2789
|
};
|
|
2857
|
-
const renderFieldList =
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
} = _temp2 === void 0 ? {} : _temp2;
|
|
2790
|
+
const renderFieldList = (fields, blockId, {
|
|
2791
|
+
stepId,
|
|
2792
|
+
optionId
|
|
2793
|
+
} = {}) => {
|
|
2862
2794
|
if (!(fields || []).length) {
|
|
2863
2795
|
return /*#__PURE__*/jsxRuntime.jsx(Text$3, {
|
|
2864
2796
|
type: "secondary",
|
|
@@ -3145,10 +3077,7 @@ const BlockListPanel = _ref3 => {
|
|
|
3145
3077
|
children: [renderFieldList(block.list, block.id), supportsItemBlocks$1 ? renderItemBlocks(block, depth) : null, supportsBlocks ? renderNestedBlocks(block.blocks, depth) : null]
|
|
3146
3078
|
});
|
|
3147
3079
|
};
|
|
3148
|
-
const renderBlockSection =
|
|
3149
|
-
if (depth === void 0) {
|
|
3150
|
-
depth = 0;
|
|
3151
|
-
}
|
|
3080
|
+
const renderBlockSection = (block, blockIndex, total, depth = 0) => {
|
|
3152
3081
|
const definition = getBlockDefinition(block.kind);
|
|
3153
3082
|
const canAddField = block.kind !== 'steps' && block.kind !== 'multiField' && block.kind !== 'choice';
|
|
3154
3083
|
const supportsItemBlocks$1 = supportsItemBlocks(block.kind);
|
|
@@ -3299,10 +3228,9 @@ const BlockListPanel = _ref3 => {
|
|
|
3299
3228
|
};
|
|
3300
3229
|
var BlockListPanel$1 = BlockListPanel;
|
|
3301
3230
|
|
|
3302
|
-
const BlockConfigFields =
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
} = _ref;
|
|
3231
|
+
const BlockConfigFields = ({
|
|
3232
|
+
kind
|
|
3233
|
+
}) => {
|
|
3306
3234
|
const {
|
|
3307
3235
|
formatMessage
|
|
3308
3236
|
} = reactIntl.useIntl();
|
|
@@ -3433,12 +3361,9 @@ const BlockConfigFields = _ref => {
|
|
|
3433
3361
|
placeholder: formatMessage({
|
|
3434
3362
|
id: 'propOptionalNumber'
|
|
3435
3363
|
}),
|
|
3436
|
-
display:
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
} = _ref2;
|
|
3440
|
-
return openApi?.data?.mode === 'multiple';
|
|
3441
|
-
}
|
|
3364
|
+
display: ({
|
|
3365
|
+
openApi
|
|
3366
|
+
}) => openApi?.data?.mode === 'multiple'
|
|
3442
3367
|
}, "minLength"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.InputNumber, {
|
|
3443
3368
|
name: "maxLength",
|
|
3444
3369
|
label: formatMessage({
|
|
@@ -3448,12 +3373,9 @@ const BlockConfigFields = _ref => {
|
|
|
3448
3373
|
placeholder: formatMessage({
|
|
3449
3374
|
id: 'propOptionalNumber'
|
|
3450
3375
|
}),
|
|
3451
|
-
display:
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
} = _ref3;
|
|
3455
|
-
return openApi?.data?.mode === 'multiple';
|
|
3456
|
-
}
|
|
3376
|
+
display: ({
|
|
3377
|
+
openApi
|
|
3378
|
+
}) => openApi?.data?.mode === 'multiple'
|
|
3457
3379
|
}, "maxLength"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Checkbox, {
|
|
3458
3380
|
name: "selectorInData",
|
|
3459
3381
|
children: formatMessage({
|
|
@@ -3467,12 +3389,9 @@ const BlockConfigFields = _ref => {
|
|
|
3467
3389
|
placeholder: formatMessage({
|
|
3468
3390
|
id: 'choiceSelectorNamePlaceholder'
|
|
3469
3391
|
}),
|
|
3470
|
-
display:
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
} = _ref4;
|
|
3474
|
-
return openApi?.data?.selectorInData !== false;
|
|
3475
|
-
}
|
|
3392
|
+
display: ({
|
|
3393
|
+
openApi
|
|
3394
|
+
}) => openApi?.data?.selectorInData !== false
|
|
3476
3395
|
}, "selectorName"));
|
|
3477
3396
|
}
|
|
3478
3397
|
if (kind === 'multiField') {
|
|
@@ -3546,20 +3465,21 @@ const BlockConfigFields = _ref => {
|
|
|
3546
3465
|
title: formatMessage({
|
|
3547
3466
|
id: `blockKind_${kind}`
|
|
3548
3467
|
}),
|
|
3549
|
-
subtitle: definition
|
|
3468
|
+
subtitle: definition ? formatMessage({
|
|
3469
|
+
id: definition.descriptionId
|
|
3470
|
+
}) : undefined,
|
|
3550
3471
|
column: 1,
|
|
3551
3472
|
list: list.filter(Boolean)
|
|
3552
3473
|
})
|
|
3553
3474
|
});
|
|
3554
3475
|
};
|
|
3555
|
-
const BlockEditorModal =
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
} = _ref5;
|
|
3476
|
+
const BlockEditorModal = ({
|
|
3477
|
+
open,
|
|
3478
|
+
block,
|
|
3479
|
+
onCancel,
|
|
3480
|
+
onSave,
|
|
3481
|
+
renderModal
|
|
3482
|
+
}) => {
|
|
3563
3483
|
const {
|
|
3564
3484
|
formatMessage
|
|
3565
3485
|
} = reactIntl.useIntl();
|
|
@@ -3609,14 +3529,13 @@ const BlockEditorModal = _ref5 => {
|
|
|
3609
3529
|
};
|
|
3610
3530
|
var BlockEditorModal$1 = BlockEditorModal;
|
|
3611
3531
|
|
|
3612
|
-
const StepEditorModal =
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
} = _ref;
|
|
3532
|
+
const StepEditorModal = ({
|
|
3533
|
+
open,
|
|
3534
|
+
step,
|
|
3535
|
+
onCancel,
|
|
3536
|
+
onSave,
|
|
3537
|
+
renderModal
|
|
3538
|
+
}) => {
|
|
3620
3539
|
const {
|
|
3621
3540
|
formatMessage
|
|
3622
3541
|
} = reactIntl.useIntl();
|
|
@@ -3670,14 +3589,13 @@ const StepEditorModal = _ref => {
|
|
|
3670
3589
|
};
|
|
3671
3590
|
var StepEditorModal$1 = StepEditorModal;
|
|
3672
3591
|
|
|
3673
|
-
const ChoiceOptionEditorModal =
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
} = _ref;
|
|
3592
|
+
const ChoiceOptionEditorModal = ({
|
|
3593
|
+
open,
|
|
3594
|
+
option,
|
|
3595
|
+
onCancel,
|
|
3596
|
+
onSave,
|
|
3597
|
+
renderModal
|
|
3598
|
+
}) => {
|
|
3681
3599
|
const {
|
|
3682
3600
|
formatMessage
|
|
3683
3601
|
} = reactIntl.useIntl();
|
|
@@ -3740,7 +3658,9 @@ const RulePresetEditor = () => {
|
|
|
3740
3658
|
formatMessage
|
|
3741
3659
|
} = reactIntl.useIntl();
|
|
3742
3660
|
const options = [...RULE_PRESET_ITEMS.map(item => ({
|
|
3743
|
-
label: item.
|
|
3661
|
+
label: item.labelId ? formatMessage({
|
|
3662
|
+
id: item.labelId
|
|
3663
|
+
}) : item.label,
|
|
3744
3664
|
value: item.value
|
|
3745
3665
|
})), {
|
|
3746
3666
|
label: formatMessage({
|
|
@@ -4658,8 +4578,12 @@ const buildBuiltinList = (type, formatMessage) => {
|
|
|
4658
4578
|
label: 'YYYY/MM/DD',
|
|
4659
4579
|
value: 'YYYY/MM/DD'
|
|
4660
4580
|
}, {
|
|
4661
|
-
label:
|
|
4662
|
-
|
|
4581
|
+
label: formatMessage({
|
|
4582
|
+
id: 'propDateFormatLocalized'
|
|
4583
|
+
}),
|
|
4584
|
+
value: formatMessage({
|
|
4585
|
+
id: 'propDateFormatLocalized'
|
|
4586
|
+
})
|
|
4663
4587
|
}, {
|
|
4664
4588
|
label: 'YYYY-MM-DD HH:mm:ss',
|
|
4665
4589
|
value: 'YYYY-MM-DD HH:mm:ss'
|
|
@@ -4760,21 +4684,17 @@ const getDefaultSelectProps = () => ({
|
|
|
4760
4684
|
searchPlaceholder: '',
|
|
4761
4685
|
columns: [createEmptyColumn()]
|
|
4762
4686
|
});
|
|
4763
|
-
const omitColumns =
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
onOptionsChange,
|
|
4775
|
-
columns,
|
|
4776
|
-
onColumnsChange
|
|
4777
|
-
} = _ref;
|
|
4687
|
+
const omitColumns = ({
|
|
4688
|
+
columns,
|
|
4689
|
+
...rest
|
|
4690
|
+
} = {}) => rest;
|
|
4691
|
+
const FieldConfigFields = ({
|
|
4692
|
+
initialType,
|
|
4693
|
+
options,
|
|
4694
|
+
onOptionsChange,
|
|
4695
|
+
columns,
|
|
4696
|
+
onColumnsChange
|
|
4697
|
+
}) => {
|
|
4778
4698
|
const {
|
|
4779
4699
|
formatMessage
|
|
4780
4700
|
} = reactIntl.useIntl();
|
|
@@ -4798,13 +4718,10 @@ const FieldConfigFields = _ref => {
|
|
|
4798
4718
|
props: nextDefinition.defaultProps || {}
|
|
4799
4719
|
}, nextDefinition);
|
|
4800
4720
|
}
|
|
4801
|
-
const entries = Object.entries(nextValues).map(
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
value
|
|
4806
|
-
};
|
|
4807
|
-
});
|
|
4721
|
+
const entries = Object.entries(nextValues).map(([name, value]) => ({
|
|
4722
|
+
name,
|
|
4723
|
+
value
|
|
4724
|
+
}));
|
|
4808
4725
|
if (!entries.length || !openApi?.setFields) {
|
|
4809
4726
|
return;
|
|
4810
4727
|
}
|
|
@@ -4902,15 +4819,14 @@ const FieldConfigFields = _ref => {
|
|
|
4902
4819
|
}) : null]
|
|
4903
4820
|
});
|
|
4904
4821
|
};
|
|
4905
|
-
const FieldEditorModal =
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
} = _ref3;
|
|
4822
|
+
const FieldEditorModal = ({
|
|
4823
|
+
open,
|
|
4824
|
+
field,
|
|
4825
|
+
fieldList,
|
|
4826
|
+
onCancel,
|
|
4827
|
+
onSave,
|
|
4828
|
+
renderModal
|
|
4829
|
+
}) => {
|
|
4914
4830
|
const {
|
|
4915
4831
|
formatMessage
|
|
4916
4832
|
} = reactIntl.useIntl();
|
|
@@ -5023,14 +4939,13 @@ const FieldEditorModal = _ref3 => {
|
|
|
5023
4939
|
};
|
|
5024
4940
|
var FieldEditorModal$1 = FieldEditorModal;
|
|
5025
4941
|
|
|
5026
|
-
const FormActionsEditor =
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
} = _ref;
|
|
4942
|
+
const FormActionsEditor = ({
|
|
4943
|
+
open,
|
|
4944
|
+
value,
|
|
4945
|
+
onCancel,
|
|
4946
|
+
onSave,
|
|
4947
|
+
renderModal
|
|
4948
|
+
}) => {
|
|
5034
4949
|
const {
|
|
5035
4950
|
formatMessage
|
|
5036
4951
|
} = reactIntl.useIntl();
|
|
@@ -5101,12 +5016,9 @@ const FormActionsEditor = _ref => {
|
|
|
5101
5016
|
placeholder: formatMessage({
|
|
5102
5017
|
id: 'formActionsSubmitTextHint'
|
|
5103
5018
|
}),
|
|
5104
|
-
display:
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
} = _ref2;
|
|
5108
|
-
return Boolean(openApi?.data?.showSubmit);
|
|
5109
|
-
}
|
|
5019
|
+
display: ({
|
|
5020
|
+
openApi
|
|
5021
|
+
}) => Boolean(openApi?.data?.showSubmit)
|
|
5110
5022
|
}, "submitText")]
|
|
5111
5023
|
}), /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
|
|
5112
5024
|
column: 2,
|
|
@@ -5124,12 +5036,9 @@ const FormActionsEditor = _ref => {
|
|
|
5124
5036
|
placeholder: formatMessage({
|
|
5125
5037
|
id: 'formActionsResetTextHint'
|
|
5126
5038
|
}),
|
|
5127
|
-
display:
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
} = _ref3;
|
|
5131
|
-
return Boolean(openApi?.data?.showReset);
|
|
5132
|
-
}
|
|
5039
|
+
display: ({
|
|
5040
|
+
openApi
|
|
5041
|
+
}) => Boolean(openApi?.data?.showReset)
|
|
5133
5042
|
}, "resetText")]
|
|
5134
5043
|
}), /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
|
|
5135
5044
|
column: 2,
|
|
@@ -5147,12 +5056,9 @@ const FormActionsEditor = _ref => {
|
|
|
5147
5056
|
placeholder: formatMessage({
|
|
5148
5057
|
id: 'formActionsCancelTextHint'
|
|
5149
5058
|
}),
|
|
5150
|
-
display:
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
} = _ref4;
|
|
5154
|
-
return Boolean(openApi?.data?.showCancel);
|
|
5155
|
-
}
|
|
5059
|
+
display: ({
|
|
5060
|
+
openApi
|
|
5061
|
+
}) => Boolean(openApi?.data?.showCancel)
|
|
5156
5062
|
}, "cancelText")]
|
|
5157
5063
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
5158
5064
|
className: style['form-actions-layout-panel'],
|
|
@@ -5274,30 +5180,30 @@ const resolveSelectLimits = block => {
|
|
|
5274
5180
|
};
|
|
5275
5181
|
const buildMultipleHint = (formatMessage, minLength, maxLength) => {
|
|
5276
5182
|
if (minLength != null && maxLength != null) {
|
|
5277
|
-
return formatMessage
|
|
5183
|
+
return formatMessage({
|
|
5278
5184
|
id: 'choiceModeHintMultipleRange'
|
|
5279
5185
|
}, {
|
|
5280
5186
|
min: minLength,
|
|
5281
5187
|
max: maxLength
|
|
5282
|
-
})
|
|
5188
|
+
});
|
|
5283
5189
|
}
|
|
5284
5190
|
if (minLength != null) {
|
|
5285
|
-
return formatMessage
|
|
5191
|
+
return formatMessage({
|
|
5286
5192
|
id: 'choiceModeHintMultipleMin'
|
|
5287
5193
|
}, {
|
|
5288
5194
|
count: minLength
|
|
5289
|
-
})
|
|
5195
|
+
});
|
|
5290
5196
|
}
|
|
5291
5197
|
if (maxLength != null) {
|
|
5292
|
-
return formatMessage
|
|
5198
|
+
return formatMessage({
|
|
5293
5199
|
id: 'choiceModeHintMultipleMax'
|
|
5294
5200
|
}, {
|
|
5295
5201
|
count: maxLength
|
|
5296
|
-
})
|
|
5202
|
+
});
|
|
5297
5203
|
}
|
|
5298
|
-
return formatMessage
|
|
5204
|
+
return formatMessage({
|
|
5299
5205
|
id: 'choiceModeHintMultiple'
|
|
5300
|
-
})
|
|
5206
|
+
});
|
|
5301
5207
|
};
|
|
5302
5208
|
|
|
5303
5209
|
/**
|
|
@@ -5323,9 +5229,9 @@ const ChoiceBlock = ({
|
|
|
5323
5229
|
openApi
|
|
5324
5230
|
} = reactFormAntd.useFormContext() || {};
|
|
5325
5231
|
const titleText = block?.title != null ? String(block.title).trim() : '';
|
|
5326
|
-
const title = titleText ||
|
|
5232
|
+
const title = titleText || formatMessage({
|
|
5327
5233
|
id: 'choiceAreaTitle'
|
|
5328
|
-
})
|
|
5234
|
+
});
|
|
5329
5235
|
const bordered = isMobile ? false : block?.bordered || undefined;
|
|
5330
5236
|
const {
|
|
5331
5237
|
minLength,
|
|
@@ -5357,11 +5263,11 @@ const ChoiceBlock = ({
|
|
|
5357
5263
|
return options.map((option, index) => {
|
|
5358
5264
|
const value = String(option.id);
|
|
5359
5265
|
return {
|
|
5360
|
-
label: option.title ||
|
|
5266
|
+
label: option.title || formatMessage({
|
|
5361
5267
|
id: 'choiceOptionFallback'
|
|
5362
5268
|
}, {
|
|
5363
5269
|
index: index + 1
|
|
5364
|
-
})
|
|
5270
|
+
}),
|
|
5365
5271
|
value,
|
|
5366
5272
|
disabled: atMax && !selectedIdsFromValue.includes(value)
|
|
5367
5273
|
};
|
|
@@ -5390,21 +5296,21 @@ const ChoiceBlock = ({
|
|
|
5390
5296
|
if (minLength != null && ids.length < minLength) {
|
|
5391
5297
|
return {
|
|
5392
5298
|
result: false,
|
|
5393
|
-
errMsg: formatMessage
|
|
5299
|
+
errMsg: formatMessage({
|
|
5394
5300
|
id: 'choiceMinSelectError'
|
|
5395
5301
|
}, {
|
|
5396
5302
|
count: minLength
|
|
5397
|
-
})
|
|
5303
|
+
})
|
|
5398
5304
|
};
|
|
5399
5305
|
}
|
|
5400
5306
|
if (maxLength != null && ids.length > maxLength) {
|
|
5401
5307
|
return {
|
|
5402
5308
|
result: false,
|
|
5403
|
-
errMsg: formatMessage
|
|
5309
|
+
errMsg: formatMessage({
|
|
5404
5310
|
id: 'choiceMaxSelectError'
|
|
5405
5311
|
}, {
|
|
5406
5312
|
count: maxLength
|
|
5407
|
-
})
|
|
5313
|
+
})
|
|
5408
5314
|
};
|
|
5409
5315
|
}
|
|
5410
5316
|
return {
|
|
@@ -5417,9 +5323,9 @@ const ChoiceBlock = ({
|
|
|
5417
5323
|
const selectorProps = {
|
|
5418
5324
|
key: `choice-selector-${mode}`,
|
|
5419
5325
|
name: selectorName,
|
|
5420
|
-
label: titleText ||
|
|
5326
|
+
label: titleText || formatMessage({
|
|
5421
5327
|
id: 'choiceAreaTitle'
|
|
5422
|
-
})
|
|
5328
|
+
}),
|
|
5423
5329
|
labelHidden: true,
|
|
5424
5330
|
options: selectorOptions,
|
|
5425
5331
|
onChange: handleChange,
|
|
@@ -5453,9 +5359,9 @@ const ChoiceBlock = ({
|
|
|
5453
5359
|
}, option.title) : null, ...nodes));
|
|
5454
5360
|
}
|
|
5455
5361
|
});
|
|
5456
|
-
const modeHint = mode === 'multiple' ? buildMultipleHint(formatMessage, minLength, maxLength) : formatMessage
|
|
5362
|
+
const modeHint = mode === 'multiple' ? buildMultipleHint(formatMessage, minLength, maxLength) : formatMessage({
|
|
5457
5363
|
id: 'choiceModeHintSingle'
|
|
5458
|
-
})
|
|
5364
|
+
});
|
|
5459
5365
|
if (!block) {
|
|
5460
5366
|
return null;
|
|
5461
5367
|
}
|
|
@@ -5471,9 +5377,9 @@ const ChoiceBlock = ({
|
|
|
5471
5377
|
className: style['choice-panels']
|
|
5472
5378
|
}, ...contentChildren) : /*#__PURE__*/react.createElement('div', {
|
|
5473
5379
|
className: style['choice-panels-empty']
|
|
5474
|
-
}, formatMessage
|
|
5380
|
+
}, formatMessage({
|
|
5475
5381
|
id: 'choiceSelectFirstHint'
|
|
5476
|
-
})
|
|
5382
|
+
})));
|
|
5477
5383
|
};
|
|
5478
5384
|
var ChoiceBlock$1 = ChoiceBlock;
|
|
5479
5385
|
|
|
@@ -5497,10 +5403,9 @@ const buildFieldLabel = field => {
|
|
|
5497
5403
|
return base || undefined;
|
|
5498
5404
|
};
|
|
5499
5405
|
const buildIndexedLabelRender = index => {
|
|
5500
|
-
return
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
} = _ref;
|
|
5406
|
+
return ({
|
|
5407
|
+
label
|
|
5408
|
+
}) => {
|
|
5504
5409
|
const text = label != null ? String(label).replace(/\u200b/g, '') : '';
|
|
5505
5410
|
return /*#__PURE__*/react.createElement(react.Fragment, null, /*#__PURE__*/react.createElement('span', {
|
|
5506
5411
|
className: style['field-label-index']
|
|
@@ -5509,67 +5414,61 @@ const buildIndexedLabelRender = index => {
|
|
|
5509
5414
|
}, text) : null);
|
|
5510
5415
|
};
|
|
5511
5416
|
};
|
|
5512
|
-
const renderFieldElements =
|
|
5513
|
-
|
|
5514
|
-
|
|
5417
|
+
const renderFieldElements = (fields = [], preview = false, {
|
|
5418
|
+
namePrefix,
|
|
5419
|
+
locale,
|
|
5420
|
+
showIndex = false
|
|
5421
|
+
} = {}) => fields.filter(field => !field.hidden).map((field, index) => {
|
|
5422
|
+
const Component = getFieldComponent(field.type, field);
|
|
5423
|
+
if (!Component) {
|
|
5424
|
+
return null;
|
|
5515
5425
|
}
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
}
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
...(definition?.defaultProps || {}),
|
|
5529
|
-
...(field.props || {})
|
|
5530
|
-
};
|
|
5531
|
-
if (definition?.optionsAllowDescription && props.options?.length && !props.api && !definition.optionsAllowChildren) {
|
|
5532
|
-
props.api = createApiFromOptions(props.options);
|
|
5533
|
-
}
|
|
5534
|
-
if (!Array.isArray(props.placeholder) && props.placeholder != null && !String(props.placeholder).trim()) {
|
|
5535
|
-
delete props.placeholder;
|
|
5536
|
-
}
|
|
5537
|
-
delete props.range;
|
|
5426
|
+
const definition = getFieldDefinition(field.type);
|
|
5427
|
+
const props = {
|
|
5428
|
+
...(definition?.defaultProps || {}),
|
|
5429
|
+
...(field.props || {})
|
|
5430
|
+
};
|
|
5431
|
+
if (definition?.optionsAllowDescription && props.options?.length && !props.api && !definition.optionsAllowChildren) {
|
|
5432
|
+
props.api = createApiFromOptions(props.options);
|
|
5433
|
+
}
|
|
5434
|
+
if (!Array.isArray(props.placeholder) && props.placeholder != null && !String(props.placeholder).trim()) {
|
|
5435
|
+
delete props.placeholder;
|
|
5436
|
+
}
|
|
5437
|
+
delete props.range;
|
|
5538
5438
|
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
}
|
|
5547
|
-
props.className = [props.className, style['option-group-stack']].filter(Boolean).join(' ');
|
|
5439
|
+
// Radio/Checkbox 选项布局:inline=false 纵向;Radio 用 antd vertical,Checkbox 用样式兜底
|
|
5440
|
+
if (field.type === 'RadioGroup' || field.type === 'CheckboxGroup') {
|
|
5441
|
+
const optionsInline = props.inline !== false;
|
|
5442
|
+
delete props.inline;
|
|
5443
|
+
if (!optionsInline) {
|
|
5444
|
+
if (field.type === 'RadioGroup') {
|
|
5445
|
+
props.vertical = true;
|
|
5548
5446
|
}
|
|
5447
|
+
props.className = [props.className, style['option-group-stack']].filter(Boolean).join(' ');
|
|
5549
5448
|
}
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
})
|
|
5572
|
-
};
|
|
5449
|
+
}
|
|
5450
|
+
const description = field.description != null && String(field.description).trim() ? field.description : undefined;
|
|
5451
|
+
const fieldName = namePrefix && field.name ? `${namePrefix}.${field.name}` : field.name;
|
|
5452
|
+
// 显式传 locale,避免 Global 仍为 zh-CN 时 react-form-antd withLocale 盖掉父级英文
|
|
5453
|
+
const localeProps = locale ? {
|
|
5454
|
+
locale
|
|
5455
|
+
} : {};
|
|
5456
|
+
const label = buildFieldLabel(field);
|
|
5457
|
+
return /*#__PURE__*/react.createElement(Component, {
|
|
5458
|
+
key: field.id,
|
|
5459
|
+
name: fieldName,
|
|
5460
|
+
label: showIndex ? label || '\u200b' : label,
|
|
5461
|
+
...(showIndex ? {
|
|
5462
|
+
labelRender: buildIndexedLabelRender(index)
|
|
5463
|
+
} : null),
|
|
5464
|
+
rule: field.rule || undefined,
|
|
5465
|
+
block: field.block || undefined,
|
|
5466
|
+
...props,
|
|
5467
|
+
...localeProps,
|
|
5468
|
+
labelTips: buildLabelTips(field.tips),
|
|
5469
|
+
description
|
|
5470
|
+
});
|
|
5471
|
+
}).filter(Boolean);
|
|
5573
5472
|
const withBlockLayout = (element, forceBlock) => {
|
|
5574
5473
|
if (!element || !forceBlock) {
|
|
5575
5474
|
return element;
|
|
@@ -5600,13 +5499,7 @@ const nestedListItemPartProps = {
|
|
|
5600
5499
|
}
|
|
5601
5500
|
};
|
|
5602
5501
|
const isFormInfoLikeBlock = kind => kind === 'formInfo' || kind === 'object';
|
|
5603
|
-
const renderBlockElement =
|
|
5604
|
-
if (preview === void 0) {
|
|
5605
|
-
preview = false;
|
|
5606
|
-
}
|
|
5607
|
-
if (ctx === void 0) {
|
|
5608
|
-
ctx = {};
|
|
5609
|
-
}
|
|
5502
|
+
const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
5610
5503
|
const {
|
|
5611
5504
|
isMobile = false,
|
|
5612
5505
|
formatMessage,
|
|
@@ -5628,29 +5521,16 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5628
5521
|
const bordered = isMobile ? false : block.bordered || undefined;
|
|
5629
5522
|
// 仅 FormInfo/object 吃列表项 Part 样式;List 等交给 form-info nestDepth
|
|
5630
5523
|
const listItemPartProps = asListItem && isFormInfoLikeBlock(block.kind) ? nestedListItemPartProps : null;
|
|
5631
|
-
const renderChildBlocks =
|
|
5632
|
-
if (blocks === void 0) {
|
|
5633
|
-
blocks = [];
|
|
5634
|
-
}
|
|
5635
|
-
if (childCtx === void 0) {
|
|
5636
|
-
childCtx = nextCtx;
|
|
5637
|
-
}
|
|
5638
|
-
return (blocks || []).map(child => renderBlockElement(child, preview, childCtx)).filter(Boolean);
|
|
5639
|
-
};
|
|
5524
|
+
const renderChildBlocks = (blocks = [], childCtx = nextCtx) => (blocks || []).map(child => renderBlockElement(child, preview, childCtx)).filter(Boolean);
|
|
5640
5525
|
|
|
5641
5526
|
/** list.itemBlocks:object/formInfo 走 asListItem;嵌套 list 等保持 nestDepth 链路 */
|
|
5642
|
-
const renderItemBlocks =
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
asListItem: isFormInfoLikeBlock(child.kind)
|
|
5650
|
-
};
|
|
5651
|
-
return withBlockLayout(renderBlockElement(child, preview, childCtx), true);
|
|
5652
|
-
}).filter(Boolean);
|
|
5653
|
-
};
|
|
5527
|
+
const renderItemBlocks = (blocks = []) => (blocks || []).map(child => {
|
|
5528
|
+
const childCtx = {
|
|
5529
|
+
...nextCtx,
|
|
5530
|
+
asListItem: isFormInfoLikeBlock(child.kind)
|
|
5531
|
+
};
|
|
5532
|
+
return withBlockLayout(renderBlockElement(child, preview, childCtx), true);
|
|
5533
|
+
}).filter(Boolean);
|
|
5654
5534
|
switch (block.kind) {
|
|
5655
5535
|
case 'formInfo':
|
|
5656
5536
|
{
|
|
@@ -5830,7 +5710,7 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5830
5710
|
key: `${option.id}-fields`,
|
|
5831
5711
|
column: block.column || 2,
|
|
5832
5712
|
gap: block.gap,
|
|
5833
|
-
list: renderFieldElements(option.list)
|
|
5713
|
+
list: renderFieldElements(option.list, preview)
|
|
5834
5714
|
}));
|
|
5835
5715
|
}
|
|
5836
5716
|
nodes.push(...renderChildBlocks(option.blocks || [], nextCtx));
|
|
@@ -5841,17 +5721,16 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5841
5721
|
return null;
|
|
5842
5722
|
}
|
|
5843
5723
|
};
|
|
5844
|
-
const renderSchemaInner =
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
} = _temp2 === void 0 ? {} : _temp2;
|
|
5724
|
+
const renderSchemaInner = (schema, {
|
|
5725
|
+
preview = false,
|
|
5726
|
+
className,
|
|
5727
|
+
bodyClassName,
|
|
5728
|
+
isMobile = false,
|
|
5729
|
+
formatMessage,
|
|
5730
|
+
locale,
|
|
5731
|
+
children,
|
|
5732
|
+
actionNode
|
|
5733
|
+
} = {}) => {
|
|
5855
5734
|
const normalized = normalizeSchema(schema);
|
|
5856
5735
|
const blocks = normalized.blocks || [];
|
|
5857
5736
|
const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
|
|
@@ -5870,18 +5749,17 @@ const renderSchemaInner = function (schema, _temp2) {
|
|
|
5870
5749
|
className
|
|
5871
5750
|
}, content) : content;
|
|
5872
5751
|
};
|
|
5873
|
-
const renderSchemaContent =
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
} = _temp3 === void 0 ? {} : _temp3;
|
|
5752
|
+
const renderSchemaContent = (schema, {
|
|
5753
|
+
preview = false,
|
|
5754
|
+
formProps = {},
|
|
5755
|
+
className,
|
|
5756
|
+
bodyClassName,
|
|
5757
|
+
isMobile = false,
|
|
5758
|
+
formatMessage,
|
|
5759
|
+
locale,
|
|
5760
|
+
children,
|
|
5761
|
+
actionNode
|
|
5762
|
+
} = {}) => {
|
|
5885
5763
|
const normalized = normalizeSchema(schema);
|
|
5886
5764
|
const blocks = normalized.blocks || [];
|
|
5887
5765
|
const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
|
|
@@ -5905,27 +5783,26 @@ var renderSchemaContent$1 = renderSchemaContent;
|
|
|
5905
5783
|
const joinClass = function () {
|
|
5906
5784
|
return [].slice.call(arguments).filter(Boolean).join(' ');
|
|
5907
5785
|
};
|
|
5908
|
-
const resolveActionNode =
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
} = _ref;
|
|
5786
|
+
const resolveActionNode = ({
|
|
5787
|
+
schema,
|
|
5788
|
+
formatMessage,
|
|
5789
|
+
actions,
|
|
5790
|
+
showActions = true,
|
|
5791
|
+
submitText,
|
|
5792
|
+
resetText,
|
|
5793
|
+
cancelText,
|
|
5794
|
+
submitButtonProps,
|
|
5795
|
+
resetButtonProps,
|
|
5796
|
+
cancelButtonProps,
|
|
5797
|
+
showSubmit,
|
|
5798
|
+
showReset,
|
|
5799
|
+
showCancel,
|
|
5800
|
+
actionsAlign,
|
|
5801
|
+
actionsGap,
|
|
5802
|
+
footerClassName,
|
|
5803
|
+
buttonFooter = false,
|
|
5804
|
+
buttonFooterProps
|
|
5805
|
+
}) => {
|
|
5929
5806
|
if (showActions === false || actions === false || actions === null) {
|
|
5930
5807
|
return null;
|
|
5931
5808
|
}
|
|
@@ -6117,17 +5994,16 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
6117
5994
|
});
|
|
6118
5995
|
var SchemaRenderer$1 = SchemaRenderer;
|
|
6119
5996
|
|
|
6120
|
-
const FormCreator = withLocale$1(
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
} = _ref;
|
|
5997
|
+
const FormCreator = withLocale$1(({
|
|
5998
|
+
value,
|
|
5999
|
+
defaultValue,
|
|
6000
|
+
onChange,
|
|
6001
|
+
showPreview = true,
|
|
6002
|
+
className,
|
|
6003
|
+
formProps,
|
|
6004
|
+
renderModal,
|
|
6005
|
+
extraToolbar
|
|
6006
|
+
}) => {
|
|
6131
6007
|
const {
|
|
6132
6008
|
formatMessage,
|
|
6133
6009
|
locale
|
|
@@ -6162,13 +6038,20 @@ const FormCreator = withLocale$1(_ref => {
|
|
|
6162
6038
|
setBlockParentStepId(null);
|
|
6163
6039
|
setBlockParentOptionId(null);
|
|
6164
6040
|
};
|
|
6165
|
-
const handleAddBlock =
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6041
|
+
const handleAddBlock = (kind, {
|
|
6042
|
+
parentBlockId,
|
|
6043
|
+
stepId,
|
|
6044
|
+
optionId
|
|
6045
|
+
} = {}) => {
|
|
6046
|
+
setEditingBlock(createBlock(kind, kind === 'choice' ? {
|
|
6047
|
+
options: [createChoiceOption({
|
|
6048
|
+
title: formatMessage({
|
|
6049
|
+
id: 'choiceOptionFallback'
|
|
6050
|
+
}, {
|
|
6051
|
+
index: 1
|
|
6052
|
+
})
|
|
6053
|
+
})]
|
|
6054
|
+
} : undefined));
|
|
6172
6055
|
setBlockParentId(parentBlockId || null);
|
|
6173
6056
|
setBlockParentStepId(stepId || null);
|
|
6174
6057
|
setBlockParentOptionId(optionId || null);
|
|
@@ -6600,12 +6483,11 @@ const isImageFile = (item, field) => {
|
|
|
6600
6483
|
};
|
|
6601
6484
|
const FileFieldPreview = remoteLoader.createWithRemoteLoader({
|
|
6602
6485
|
modules: ['components-core:File@FileLink', 'components-core:Image']
|
|
6603
|
-
})(
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
} = _ref;
|
|
6486
|
+
})(({
|
|
6487
|
+
remoteModules,
|
|
6488
|
+
value,
|
|
6489
|
+
field
|
|
6490
|
+
}) => {
|
|
6609
6491
|
const [FileLink, Image] = remoteModules;
|
|
6610
6492
|
const files = toFileList(value).map(pickFilePreviewProps).filter(Boolean);
|
|
6611
6493
|
if (!files.length) {
|
|
@@ -6757,13 +6639,7 @@ const formatTemporal = (value, formatKey, patternOverride) => {
|
|
|
6757
6639
|
return applyPattern(date, pattern);
|
|
6758
6640
|
};
|
|
6759
6641
|
const isTemporalKey = key => !!(key && (TEMPORAL_PATTERN[key] || key === 'week' || key === 'quarter'));
|
|
6760
|
-
const pickObjectLabel =
|
|
6761
|
-
if (labelKey === void 0) {
|
|
6762
|
-
labelKey = 'label';
|
|
6763
|
-
}
|
|
6764
|
-
if (valueKey === void 0) {
|
|
6765
|
-
valueKey = 'value';
|
|
6766
|
-
}
|
|
6642
|
+
const pickObjectLabel = (item, labelKey = 'label', valueKey = 'value') => {
|
|
6767
6643
|
if (item == null) {
|
|
6768
6644
|
return '';
|
|
6769
6645
|
}
|
|
@@ -6780,13 +6656,7 @@ const pickObjectLabel = function (item, labelKey, valueKey) {
|
|
|
6780
6656
|
}
|
|
6781
6657
|
return '';
|
|
6782
6658
|
};
|
|
6783
|
-
const mapOptionLabel =
|
|
6784
|
-
if (labelKey === void 0) {
|
|
6785
|
-
labelKey = 'label';
|
|
6786
|
-
}
|
|
6787
|
-
if (valueKey === void 0) {
|
|
6788
|
-
valueKey = 'value';
|
|
6789
|
-
}
|
|
6659
|
+
const mapOptionLabel = (value, options, labelKey = 'label', valueKey = 'value') => {
|
|
6790
6660
|
if (value && typeof value === 'object') {
|
|
6791
6661
|
return pickObjectLabel(value, labelKey, valueKey);
|
|
6792
6662
|
}
|
|
@@ -6861,7 +6731,7 @@ const formatDateToToday = (value, itemSchema, ctx) => {
|
|
|
6861
6731
|
if (items[1] == null || items[1] === '' || items[1] === true) {
|
|
6862
6732
|
const until = ctx.formatMessage?.({
|
|
6863
6733
|
id: 'schemaContentUntilToday'
|
|
6864
|
-
}) ||
|
|
6734
|
+
}) || defaultLocale.schemaContentUntilToday;
|
|
6865
6735
|
return [start, until].filter(Boolean).join(' ~ ');
|
|
6866
6736
|
}
|
|
6867
6737
|
const end = formatByValueSchema(items[1], itemSchema, ctx);
|
|
@@ -6916,11 +6786,11 @@ const formatBoolean = (value, field, ctx) => {
|
|
|
6916
6786
|
if (value) {
|
|
6917
6787
|
return props.checkedChildren || ctx.formatMessage?.({
|
|
6918
6788
|
id: 'schemaContentYes'
|
|
6919
|
-
}) ||
|
|
6789
|
+
}) || defaultLocale.schemaContentYes;
|
|
6920
6790
|
}
|
|
6921
6791
|
return props.unCheckedChildren || ctx.formatMessage?.({
|
|
6922
6792
|
id: 'schemaContentNo'
|
|
6923
|
-
}) ||
|
|
6793
|
+
}) || defaultLocale.schemaContentNo;
|
|
6924
6794
|
};
|
|
6925
6795
|
const stringifyFallback = value => {
|
|
6926
6796
|
if (value == null) {
|
|
@@ -6955,10 +6825,7 @@ const stringifyFallback = value => {
|
|
|
6955
6825
|
return '';
|
|
6956
6826
|
}
|
|
6957
6827
|
};
|
|
6958
|
-
const formatByValueSchema =
|
|
6959
|
-
if (ctx === void 0) {
|
|
6960
|
-
ctx = {};
|
|
6961
|
-
}
|
|
6828
|
+
const formatByValueSchema = (value, schema, ctx = {}) => {
|
|
6962
6829
|
if (isEmptyValue(value)) {
|
|
6963
6830
|
return '';
|
|
6964
6831
|
}
|
|
@@ -7050,10 +6917,9 @@ const formatByValueSchema = function (value, schema, ctx) {
|
|
|
7050
6917
|
}
|
|
7051
6918
|
return String(value);
|
|
7052
6919
|
};
|
|
7053
|
-
const formatFieldDisplayValue =
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
} = _temp === void 0 ? {} : _temp;
|
|
6920
|
+
const formatFieldDisplayValue = (field, value, {
|
|
6921
|
+
formatMessage
|
|
6922
|
+
} = {}) => {
|
|
7057
6923
|
const emptyText = formatMessage?.({
|
|
7058
6924
|
id: 'schemaContentEmptyValue'
|
|
7059
6925
|
}) || '-';
|
|
@@ -7081,16 +6947,14 @@ const formatFieldDisplayValue = function (field, value, _temp) {
|
|
|
7081
6947
|
* 统一注册扩展规则与填写项:运行时校验 + 编辑器规则面板 + 字段类型 registry。
|
|
7082
6948
|
* 应用入口调用一次即可,FormCreator / SchemaRenderer 共用。
|
|
7083
6949
|
*/
|
|
7084
|
-
const preset =
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
} = _temp === void 0 ? {} : _temp;
|
|
6950
|
+
const preset = ({
|
|
6951
|
+
rules = {},
|
|
6952
|
+
fields = {}
|
|
6953
|
+
} = {}) => {
|
|
7089
6954
|
const runtimeRules = {
|
|
7090
6955
|
...reactFormAntd.RULES
|
|
7091
6956
|
};
|
|
7092
|
-
Object.entries(rules).forEach(
|
|
7093
|
-
let [value, def] = _ref;
|
|
6957
|
+
Object.entries(rules).forEach(([value, def]) => {
|
|
7094
6958
|
if (def == null) {
|
|
7095
6959
|
return;
|
|
7096
6960
|
}
|
|
@@ -7122,8 +6986,7 @@ const preset = function (_temp) {
|
|
|
7122
6986
|
reactFormAntd.preset({
|
|
7123
6987
|
rules: runtimeRules
|
|
7124
6988
|
});
|
|
7125
|
-
Object.entries(fields).forEach(
|
|
7126
|
-
let [type, definition] = _ref2;
|
|
6989
|
+
Object.entries(fields).forEach(([type, definition]) => {
|
|
7127
6990
|
registerField(type, definition);
|
|
7128
6991
|
});
|
|
7129
6992
|
};
|
|
@@ -7143,10 +7006,9 @@ const resolveChoiceSelectorName$1 = block => {
|
|
|
7143
7006
|
}
|
|
7144
7007
|
return `__choice_${block.id}`;
|
|
7145
7008
|
};
|
|
7146
|
-
const mergeFieldIntoLayer =
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
} = _temp === void 0 ? {} : _temp;
|
|
7009
|
+
const mergeFieldIntoLayer = (layer, field, {
|
|
7010
|
+
allowRequired = true
|
|
7011
|
+
} = {}) => {
|
|
7150
7012
|
if (!field?.name) {
|
|
7151
7013
|
return;
|
|
7152
7014
|
}
|
|
@@ -7173,11 +7035,10 @@ const toFiniteInt = (value, minAllowed) => {
|
|
|
7173
7035
|
const int = Math.floor(num);
|
|
7174
7036
|
return int < minAllowed ? minAllowed : int;
|
|
7175
7037
|
};
|
|
7176
|
-
const finalizeObjectSchema =
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
} = _temp2 === void 0 ? {} : _temp2;
|
|
7038
|
+
const finalizeObjectSchema = (layer, {
|
|
7039
|
+
title,
|
|
7040
|
+
description
|
|
7041
|
+
} = {}) => {
|
|
7181
7042
|
const schema = {
|
|
7182
7043
|
type: 'object',
|
|
7183
7044
|
properties: {
|
|
@@ -7200,20 +7061,20 @@ const finalizeObjectSchema = function (layer, _temp2) {
|
|
|
7200
7061
|
}
|
|
7201
7062
|
return schema;
|
|
7202
7063
|
};
|
|
7203
|
-
const walkBlocks =
|
|
7064
|
+
const walkBlocks = (blocks, layer, depth = 0) => {
|
|
7204
7065
|
(blocks || []).forEach(block => {
|
|
7205
7066
|
if (!block) {
|
|
7206
7067
|
return;
|
|
7207
7068
|
}
|
|
7208
|
-
walkBlock(block, layer);
|
|
7069
|
+
walkBlock(block, layer, depth);
|
|
7209
7070
|
});
|
|
7210
7071
|
};
|
|
7211
|
-
const walkBlock =
|
|
7072
|
+
const walkBlock = (block, layer, depth = 0) => {
|
|
7212
7073
|
switch (block.kind) {
|
|
7213
7074
|
case 'formInfo':
|
|
7214
7075
|
{
|
|
7215
7076
|
mergeFieldsIntoLayer(layer, block.list);
|
|
7216
|
-
walkBlocks(block.blocks, layer);
|
|
7077
|
+
walkBlocks(block.blocks, layer, depth + 1);
|
|
7217
7078
|
return;
|
|
7218
7079
|
}
|
|
7219
7080
|
case 'object':
|
|
@@ -7221,12 +7082,12 @@ const walkBlock = function (block, layer, depth) {
|
|
|
7221
7082
|
const name = block.name != null && String(block.name).trim() ? String(block.name).trim() : '';
|
|
7222
7083
|
if (!name) {
|
|
7223
7084
|
mergeFieldsIntoLayer(layer, block.list);
|
|
7224
|
-
walkBlocks(block.blocks, layer);
|
|
7085
|
+
walkBlocks(block.blocks, layer, depth + 1);
|
|
7225
7086
|
return;
|
|
7226
7087
|
}
|
|
7227
7088
|
const nested = createObjectLayer();
|
|
7228
7089
|
mergeFieldsIntoLayer(nested, block.list);
|
|
7229
|
-
walkBlocks(block.blocks, nested);
|
|
7090
|
+
walkBlocks(block.blocks, nested, depth + 1);
|
|
7230
7091
|
layer.properties[name] = finalizeObjectSchema(nested, {
|
|
7231
7092
|
title: block.title || undefined,
|
|
7232
7093
|
description: block.subtitle || undefined
|
|
@@ -7244,7 +7105,7 @@ const walkBlock = function (block, layer, depth) {
|
|
|
7244
7105
|
const itemLayer = createObjectLayer();
|
|
7245
7106
|
mergeFieldsIntoLayer(itemLayer, block.list);
|
|
7246
7107
|
if (supportsItemBlocks(block.kind)) {
|
|
7247
|
-
walkBlocks(block.itemBlocks, itemLayer);
|
|
7108
|
+
walkBlocks(block.itemBlocks, itemLayer, depth + 1);
|
|
7248
7109
|
}
|
|
7249
7110
|
const items = finalizeObjectSchema(itemLayer);
|
|
7250
7111
|
const arraySchema = {
|
|
@@ -7290,13 +7151,13 @@ const walkBlock = function (block, layer, depth) {
|
|
|
7290
7151
|
{
|
|
7291
7152
|
(block.items || []).forEach(step => {
|
|
7292
7153
|
mergeFieldsIntoLayer(layer, step?.list);
|
|
7293
|
-
walkBlocks(step?.blocks, layer);
|
|
7154
|
+
walkBlocks(step?.blocks, layer, depth + 1);
|
|
7294
7155
|
});
|
|
7295
7156
|
return;
|
|
7296
7157
|
}
|
|
7297
7158
|
case 'choice':
|
|
7298
7159
|
{
|
|
7299
|
-
mergeChoiceIntoLayer(layer, block);
|
|
7160
|
+
mergeChoiceIntoLayer(layer, block, depth);
|
|
7300
7161
|
return;
|
|
7301
7162
|
}
|
|
7302
7163
|
default:
|
|
@@ -7315,20 +7176,22 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
|
7315
7176
|
const selectorName = resolveChoiceSelectorName$1(block);
|
|
7316
7177
|
const options = block.options || [];
|
|
7317
7178
|
const optionIds = options.map(option => String(option.id));
|
|
7318
|
-
const branches = options.map(
|
|
7179
|
+
const branches = options.map(option => {
|
|
7319
7180
|
const branch = createObjectLayer();
|
|
7320
|
-
const optionTitle = option.title ||
|
|
7181
|
+
const optionTitle = option.title || undefined;
|
|
7321
7182
|
if (selectorInData && mode === 'single') {
|
|
7322
7183
|
branch.properties[selectorName] = {
|
|
7323
7184
|
const: String(option.id),
|
|
7324
|
-
|
|
7185
|
+
...(optionTitle ? {
|
|
7186
|
+
title: optionTitle
|
|
7187
|
+
} : {})
|
|
7325
7188
|
};
|
|
7326
7189
|
branch.required.push(selectorName);
|
|
7327
7190
|
}
|
|
7328
7191
|
mergeFieldsIntoLayer(branch, option.list, {
|
|
7329
7192
|
allowRequired: true
|
|
7330
7193
|
});
|
|
7331
|
-
walkBlocks(option.blocks, branch);
|
|
7194
|
+
walkBlocks(option.blocks, branch, depth + 1);
|
|
7332
7195
|
return finalizeObjectSchema(branch, {
|
|
7333
7196
|
title: optionTitle
|
|
7334
7197
|
});
|
|
@@ -7406,13 +7269,10 @@ const mergeChoiceIntoLayer = (layer, block, depth) => {
|
|
|
7406
7269
|
* - hidden 字段仍进入 data schema(可提交)
|
|
7407
7270
|
* - choice:single → oneOf,multiple → anyOf
|
|
7408
7271
|
*/
|
|
7409
|
-
const schemaToDataSchema =
|
|
7410
|
-
if (options === void 0) {
|
|
7411
|
-
options = {};
|
|
7412
|
-
}
|
|
7272
|
+
const schemaToDataSchema = (schema, options = {}) => {
|
|
7413
7273
|
const normalized = normalizeSchema(schema || {});
|
|
7414
7274
|
const layer = createObjectLayer();
|
|
7415
|
-
walkBlocks(normalized.blocks, layer);
|
|
7275
|
+
walkBlocks(normalized.blocks, layer, 0);
|
|
7416
7276
|
const root = finalizeObjectSchema(layer, {
|
|
7417
7277
|
title: normalized.title || undefined,
|
|
7418
7278
|
description: options.description
|
|
@@ -7446,10 +7306,9 @@ const formatFieldValue = (field, value, formatMessage) => formatFieldDisplayValu
|
|
|
7446
7306
|
* 问卷题干往往很长:不用 InfoPage Content 的横向 label 列宽对齐(minWidth),
|
|
7447
7307
|
* 改为 label 在上、值在下,避免窄栏(如弹窗双栏预览)被撑乱。
|
|
7448
7308
|
*/
|
|
7449
|
-
const renderFieldsContent =
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
} = _temp === void 0 ? {} : _temp;
|
|
7309
|
+
const renderFieldsContent = (fields, data, formatMessage, column, {
|
|
7310
|
+
showIndex = false
|
|
7311
|
+
} = {}) => {
|
|
7453
7312
|
const list = (fields || []).filter(field => field && !field.hidden && field.name).map((field, index) => {
|
|
7454
7313
|
const baseLabel = field.label || field.name;
|
|
7455
7314
|
const label = showIndex ? `${index + 1}. ${baseLabel}` : baseLabel;
|
|
@@ -7603,12 +7462,11 @@ const renderBlock = (block, data, ctx) => {
|
|
|
7603
7462
|
return null;
|
|
7604
7463
|
}
|
|
7605
7464
|
};
|
|
7606
|
-
const SchemaContentInnerView =
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
} = _ref;
|
|
7465
|
+
const SchemaContentInnerView = ({
|
|
7466
|
+
schema,
|
|
7467
|
+
data,
|
|
7468
|
+
className
|
|
7469
|
+
}) => {
|
|
7612
7470
|
const {
|
|
7613
7471
|
formatMessage
|
|
7614
7472
|
} = reactIntl.useIntl();
|
|
@@ -7633,13 +7491,12 @@ const SchemaContentInnerView = _ref => {
|
|
|
7633
7491
|
});
|
|
7634
7492
|
};
|
|
7635
7493
|
const SchemaContentInner = withLocale$1(SchemaContentInnerView);
|
|
7636
|
-
const SchemaContent = withLocale$1(
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
} = _ref2;
|
|
7494
|
+
const SchemaContent = withLocale$1(({
|
|
7495
|
+
schema,
|
|
7496
|
+
data,
|
|
7497
|
+
className,
|
|
7498
|
+
empty
|
|
7499
|
+
}) => {
|
|
7643
7500
|
const {
|
|
7644
7501
|
formatMessage
|
|
7645
7502
|
} = reactIntl.useIntl();
|