@kne/form-creator 0.1.16 → 0.1.18
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 +295 -75
- package/dist/index.css +14 -13
- package/dist/index.css.map +1 -1
- package/dist/index.js +269 -223
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +175 -80
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +21 -0
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +21 -0
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +21 -0
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +21 -0
- package/dist/locale/zh-CN.modern.js.map +1 -1
- package/package.json +7 -7
package/dist/index.modern.js
CHANGED
|
@@ -123,6 +123,27 @@ const locale$1 = {
|
|
|
123
123
|
stepNext: '下一步',
|
|
124
124
|
stepComplete: '完成',
|
|
125
125
|
fieldType: '填写项类型',
|
|
126
|
+
FieldGroupBasic: '基础字段',
|
|
127
|
+
FieldGroupSelect: '选择字段',
|
|
128
|
+
FieldGroupAdvancedSelect: '高级选择',
|
|
129
|
+
FieldGroupBusinessSelect: '业务选择',
|
|
130
|
+
FieldGroupExtended: '扩展字段',
|
|
131
|
+
FieldTypeInput: '单行文本',
|
|
132
|
+
FieldTypeTextArea: '多行文本',
|
|
133
|
+
FieldTypeInputNumber: '数字',
|
|
134
|
+
FieldTypeSelect: '下拉选择',
|
|
135
|
+
FieldTypeRadioGroup: '单选组',
|
|
136
|
+
FieldTypeCheckboxGroup: '复选组',
|
|
137
|
+
FieldTypeSuperSelectList: '普通下拉',
|
|
138
|
+
FieldTypeSuperSelectTableList: '表格选择',
|
|
139
|
+
FieldTypeSuperSelectTree: '树形选择',
|
|
140
|
+
FieldTypeSuperSelectCascader: '级联选择',
|
|
141
|
+
FieldTypeSelectFunction: '职能选择',
|
|
142
|
+
FieldTypeSelectIndustry: '行业选择',
|
|
143
|
+
FieldTypeSelectAddress: '地址选择',
|
|
144
|
+
FieldTypeSwitch: '开关',
|
|
145
|
+
FieldTypeCheckbox: '复选框',
|
|
146
|
+
FieldTypeDatePicker: '日期',
|
|
126
147
|
fieldName: '保存用的名称',
|
|
127
148
|
fieldNamePlaceholder: '已自动生成,可修改',
|
|
128
149
|
fieldLabel: '显示名称',
|
|
@@ -326,6 +347,27 @@ const locale = {
|
|
|
326
347
|
stepNext: 'Next',
|
|
327
348
|
stepComplete: 'Done',
|
|
328
349
|
fieldType: 'Field Type',
|
|
350
|
+
FieldGroupBasic: 'Basic Fields',
|
|
351
|
+
FieldGroupSelect: 'Select Fields',
|
|
352
|
+
FieldGroupAdvancedSelect: 'Advanced Select',
|
|
353
|
+
FieldGroupBusinessSelect: 'Business Select',
|
|
354
|
+
FieldGroupExtended: 'Extended Fields',
|
|
355
|
+
FieldTypeInput: 'Single-line Text',
|
|
356
|
+
FieldTypeTextArea: 'Multi-line Text',
|
|
357
|
+
FieldTypeInputNumber: 'Number',
|
|
358
|
+
FieldTypeSelect: 'Dropdown',
|
|
359
|
+
FieldTypeRadioGroup: 'Radio Group',
|
|
360
|
+
FieldTypeCheckboxGroup: 'Checkbox Group',
|
|
361
|
+
FieldTypeSuperSelectList: 'Select List',
|
|
362
|
+
FieldTypeSuperSelectTableList: 'Table Select',
|
|
363
|
+
FieldTypeSuperSelectTree: 'Tree Select',
|
|
364
|
+
FieldTypeSuperSelectCascader: 'Cascader',
|
|
365
|
+
FieldTypeSelectFunction: 'Job Function',
|
|
366
|
+
FieldTypeSelectIndustry: 'Industry',
|
|
367
|
+
FieldTypeSelectAddress: 'Address',
|
|
368
|
+
FieldTypeSwitch: 'Switch',
|
|
369
|
+
FieldTypeCheckbox: 'Checkbox',
|
|
370
|
+
FieldTypeDatePicker: 'Date',
|
|
329
371
|
fieldName: 'Save name',
|
|
330
372
|
fieldNamePlaceholder: 'Auto-generated, editable',
|
|
331
373
|
fieldLabel: 'Display Name',
|
|
@@ -1475,18 +1517,29 @@ const defineField = (type, definition) => {
|
|
|
1475
1517
|
}, definition));
|
|
1476
1518
|
};
|
|
1477
1519
|
const FIELD_GROUPS = [{
|
|
1478
|
-
|
|
1520
|
+
labelId: 'FieldGroupBasic',
|
|
1479
1521
|
types: ['Input', 'TextArea', 'InputNumber', 'Switch', 'Checkbox', 'DatePicker']
|
|
1480
1522
|
}, {
|
|
1481
|
-
|
|
1523
|
+
labelId: 'FieldGroupSelect',
|
|
1482
1524
|
types: ['Select', 'RadioGroup', 'CheckboxGroup']
|
|
1483
1525
|
}, {
|
|
1484
|
-
|
|
1526
|
+
labelId: 'FieldGroupAdvancedSelect',
|
|
1485
1527
|
types: ['SuperSelectList', 'SuperSelectTableList', 'SuperSelectTree', 'SuperSelectCascader']
|
|
1486
1528
|
}, {
|
|
1487
|
-
|
|
1529
|
+
labelId: 'FieldGroupBusinessSelect',
|
|
1488
1530
|
types: ['SelectFunction', 'SelectIndustry', 'SelectAddress']
|
|
1489
1531
|
}];
|
|
1532
|
+
const resolveRegistryLabel = (formatMessage, labelId, fallbackLabel) => {
|
|
1533
|
+
if (typeof formatMessage === 'function' && labelId) {
|
|
1534
|
+
return formatMessage({
|
|
1535
|
+
id: labelId
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
if (fallbackLabel != null && String(fallbackLabel).trim()) {
|
|
1539
|
+
return String(fallbackLabel).trim();
|
|
1540
|
+
}
|
|
1541
|
+
return labelId || '';
|
|
1542
|
+
};
|
|
1490
1543
|
const optionEnumValues = field => {
|
|
1491
1544
|
var _field$props;
|
|
1492
1545
|
const options = field == null || (_field$props = field.props) == null ? void 0 : _field$props.options;
|
|
@@ -1546,8 +1599,7 @@ const datePickerValueSchema = field => {
|
|
|
1546
1599
|
return item;
|
|
1547
1600
|
};
|
|
1548
1601
|
defineField('Input', {
|
|
1549
|
-
|
|
1550
|
-
group: '基础字段',
|
|
1602
|
+
labelId: 'FieldTypeInput',
|
|
1551
1603
|
component: Input,
|
|
1552
1604
|
defaultProps: {
|
|
1553
1605
|
allowClear: true
|
|
@@ -1558,8 +1610,7 @@ defineField('Input', {
|
|
|
1558
1610
|
}
|
|
1559
1611
|
});
|
|
1560
1612
|
defineField('TextArea', {
|
|
1561
|
-
|
|
1562
|
-
group: '基础字段',
|
|
1613
|
+
labelId: 'FieldTypeTextArea',
|
|
1563
1614
|
component: TextArea,
|
|
1564
1615
|
defaultProps: {
|
|
1565
1616
|
rows: 3
|
|
@@ -1573,8 +1624,7 @@ defineField('TextArea', {
|
|
|
1573
1624
|
}
|
|
1574
1625
|
});
|
|
1575
1626
|
defineField('InputNumber', {
|
|
1576
|
-
|
|
1577
|
-
group: '基础字段',
|
|
1627
|
+
labelId: 'FieldTypeInputNumber',
|
|
1578
1628
|
component: InputNumber,
|
|
1579
1629
|
defaultProps: {},
|
|
1580
1630
|
hasFieldProps: true,
|
|
@@ -1583,8 +1633,7 @@ defineField('InputNumber', {
|
|
|
1583
1633
|
}
|
|
1584
1634
|
});
|
|
1585
1635
|
defineField('Select', {
|
|
1586
|
-
|
|
1587
|
-
group: '选择字段',
|
|
1636
|
+
labelId: 'FieldTypeSelect',
|
|
1588
1637
|
component: Select,
|
|
1589
1638
|
defaultProps: {
|
|
1590
1639
|
options: [],
|
|
@@ -1595,8 +1644,7 @@ defineField('Select', {
|
|
|
1595
1644
|
valueSchema: stringWithEnumSchema
|
|
1596
1645
|
});
|
|
1597
1646
|
defineField('RadioGroup', {
|
|
1598
|
-
|
|
1599
|
-
group: '选择字段',
|
|
1647
|
+
labelId: 'FieldTypeRadioGroup',
|
|
1600
1648
|
component: RadioGroup,
|
|
1601
1649
|
defaultProps: {
|
|
1602
1650
|
options: []
|
|
@@ -1605,8 +1653,7 @@ defineField('RadioGroup', {
|
|
|
1605
1653
|
valueSchema: stringWithEnumSchema
|
|
1606
1654
|
});
|
|
1607
1655
|
defineField('CheckboxGroup', {
|
|
1608
|
-
|
|
1609
|
-
group: '选择字段',
|
|
1656
|
+
labelId: 'FieldTypeCheckboxGroup',
|
|
1610
1657
|
component: CheckboxGroup,
|
|
1611
1658
|
defaultProps: {
|
|
1612
1659
|
options: []
|
|
@@ -1627,8 +1674,7 @@ defineField('CheckboxGroup', {
|
|
|
1627
1674
|
}
|
|
1628
1675
|
});
|
|
1629
1676
|
defineField('SuperSelectList', {
|
|
1630
|
-
|
|
1631
|
-
group: 'SuperSelect',
|
|
1677
|
+
labelId: 'FieldTypeSuperSelectList',
|
|
1632
1678
|
component: SuperSelectList,
|
|
1633
1679
|
defaultProps: {
|
|
1634
1680
|
options: [],
|
|
@@ -1643,8 +1689,7 @@ defineField('SuperSelectList', {
|
|
|
1643
1689
|
valueSchema: superSelectValueSchema
|
|
1644
1690
|
});
|
|
1645
1691
|
defineField('SuperSelectTableList', {
|
|
1646
|
-
|
|
1647
|
-
group: 'SuperSelect',
|
|
1692
|
+
labelId: 'FieldTypeSuperSelectTableList',
|
|
1648
1693
|
component: SuperSelectTableList,
|
|
1649
1694
|
defaultProps: {
|
|
1650
1695
|
options: [],
|
|
@@ -1661,8 +1706,7 @@ defineField('SuperSelectTableList', {
|
|
|
1661
1706
|
valueSchema: superSelectValueSchema
|
|
1662
1707
|
});
|
|
1663
1708
|
defineField('SuperSelectTree', {
|
|
1664
|
-
|
|
1665
|
-
group: 'SuperSelect',
|
|
1709
|
+
labelId: 'FieldTypeSuperSelectTree',
|
|
1666
1710
|
component: SuperSelectTree,
|
|
1667
1711
|
defaultProps: {
|
|
1668
1712
|
options: [],
|
|
@@ -1678,8 +1722,7 @@ defineField('SuperSelectTree', {
|
|
|
1678
1722
|
valueSchema: superSelectValueSchema
|
|
1679
1723
|
});
|
|
1680
1724
|
defineField('SuperSelectCascader', {
|
|
1681
|
-
|
|
1682
|
-
group: 'SuperSelect',
|
|
1725
|
+
labelId: 'FieldTypeSuperSelectCascader',
|
|
1683
1726
|
component: SuperSelectCascader,
|
|
1684
1727
|
defaultProps: {
|
|
1685
1728
|
options: [],
|
|
@@ -1697,8 +1740,7 @@ defineField('SuperSelectCascader', {
|
|
|
1697
1740
|
valueSchema: superSelectValueSchema
|
|
1698
1741
|
});
|
|
1699
1742
|
defineField('SelectFunction', {
|
|
1700
|
-
|
|
1701
|
-
group: 'SuperSelectPlus',
|
|
1743
|
+
labelId: 'FieldTypeSelectFunction',
|
|
1702
1744
|
component: SelectFunctionField,
|
|
1703
1745
|
defaultProps: {
|
|
1704
1746
|
isPopup: true,
|
|
@@ -1709,8 +1751,7 @@ defineField('SelectFunction', {
|
|
|
1709
1751
|
valueSchema: superSelectValueSchema
|
|
1710
1752
|
});
|
|
1711
1753
|
defineField('SelectIndustry', {
|
|
1712
|
-
|
|
1713
|
-
group: 'SuperSelectPlus',
|
|
1754
|
+
labelId: 'FieldTypeSelectIndustry',
|
|
1714
1755
|
component: SelectIndustryField,
|
|
1715
1756
|
defaultProps: {
|
|
1716
1757
|
isPopup: true,
|
|
@@ -1721,8 +1762,7 @@ defineField('SelectIndustry', {
|
|
|
1721
1762
|
valueSchema: superSelectValueSchema
|
|
1722
1763
|
});
|
|
1723
1764
|
defineField('SelectAddress', {
|
|
1724
|
-
|
|
1725
|
-
group: 'SuperSelectPlus',
|
|
1765
|
+
labelId: 'FieldTypeSelectAddress',
|
|
1726
1766
|
component: SelectAddressField,
|
|
1727
1767
|
defaultProps: {
|
|
1728
1768
|
isPopup: true,
|
|
@@ -1733,8 +1773,7 @@ defineField('SelectAddress', {
|
|
|
1733
1773
|
valueSchema: superSelectValueSchema
|
|
1734
1774
|
});
|
|
1735
1775
|
defineField('Switch', {
|
|
1736
|
-
|
|
1737
|
-
group: '基础字段',
|
|
1776
|
+
labelId: 'FieldTypeSwitch',
|
|
1738
1777
|
component: Switch,
|
|
1739
1778
|
defaultProps: {},
|
|
1740
1779
|
hasFieldProps: true,
|
|
@@ -1743,8 +1782,7 @@ defineField('Switch', {
|
|
|
1743
1782
|
}
|
|
1744
1783
|
});
|
|
1745
1784
|
defineField('Checkbox', {
|
|
1746
|
-
|
|
1747
|
-
group: '基础字段',
|
|
1785
|
+
labelId: 'FieldTypeCheckbox',
|
|
1748
1786
|
component: Checkbox,
|
|
1749
1787
|
defaultProps: {
|
|
1750
1788
|
children: ''
|
|
@@ -1754,8 +1792,7 @@ defineField('Checkbox', {
|
|
|
1754
1792
|
}
|
|
1755
1793
|
});
|
|
1756
1794
|
defineField('DatePicker', {
|
|
1757
|
-
|
|
1758
|
-
group: '基础字段',
|
|
1795
|
+
labelId: 'FieldTypeDatePicker',
|
|
1759
1796
|
component: DatePicker,
|
|
1760
1797
|
defaultProps: {
|
|
1761
1798
|
format: 'YYYY-MM-DD',
|
|
@@ -1779,8 +1816,9 @@ defineField('DatePicker', {
|
|
|
1779
1816
|
* - min / max?: number(type=number)
|
|
1780
1817
|
* - options?: { label, value }[](type=select)
|
|
1781
1818
|
*
|
|
1782
|
-
* preset
|
|
1783
|
-
* -
|
|
1819
|
+
* preset / registerField 的 fields 项还可传:
|
|
1820
|
+
* - label / labelId?: 展示名;有 labelId 时随 formatMessage 切换语言
|
|
1821
|
+
* - groupName / groupNameId?: 自定义类型下拉分组;有 groupNameId 时随语言切换;都不传则归入「扩展字段」
|
|
1784
1822
|
* - valueSchema?: object | (field) => object 提交值的 JSON Schema 片段;缺省回退 { type: 'string' }
|
|
1785
1823
|
* 可含 format(date/month/week/time/date-time/password/color/json)与 display(option/phone/file/typed-date-range/date-to-today/html/money),供 SchemaContent 预览
|
|
1786
1824
|
* - formatDisplayValue?: (value, field, ctx) => string 覆盖 valueSchema 默认预览
|
|
@@ -1789,9 +1827,13 @@ const registerField = (type, definition) => {
|
|
|
1789
1827
|
var _definition$hasFieldP;
|
|
1790
1828
|
const propsSchema = Array.isArray(definition == null ? void 0 : definition.propsSchema) ? definition.propsSchema : undefined;
|
|
1791
1829
|
const groupName = (definition == null ? void 0 : definition.groupName) != null && String(definition.groupName).trim() ? String(definition.groupName).trim() : undefined;
|
|
1830
|
+
const groupNameId = (definition == null ? void 0 : definition.groupNameId) != null && String(definition.groupNameId).trim() ? String(definition.groupNameId).trim() : undefined;
|
|
1831
|
+
const labelId = (definition == null ? void 0 : definition.labelId) != null && String(definition.labelId).trim() ? String(definition.labelId).trim() : undefined;
|
|
1792
1832
|
defineField(type, _extends({}, definition, {
|
|
1793
1833
|
propsSchema,
|
|
1794
1834
|
groupName,
|
|
1835
|
+
groupNameId,
|
|
1836
|
+
labelId,
|
|
1795
1837
|
hasFieldProps: (_definition$hasFieldP = definition.hasFieldProps) != null ? _definition$hasFieldP : !!(propsSchema && propsSchema.length)
|
|
1796
1838
|
}));
|
|
1797
1839
|
};
|
|
@@ -1849,6 +1891,15 @@ const applyFromPropsSchema = (props, values = {}, propsSchema = []) => {
|
|
|
1849
1891
|
};
|
|
1850
1892
|
const getFieldDefinition = type => registry.get(type);
|
|
1851
1893
|
|
|
1894
|
+
/** 解析字段类型展示名:内置走 labelId;扩展字段可用已翻译的 label */
|
|
1895
|
+
const resolveFieldTypeLabel = (typeOrDefinition, formatMessage) => {
|
|
1896
|
+
const definition = typeof typeOrDefinition === 'string' ? registry.get(typeOrDefinition) : typeOrDefinition;
|
|
1897
|
+
if (!definition) {
|
|
1898
|
+
return typeof typeOrDefinition === 'string' ? typeOrDefinition : '';
|
|
1899
|
+
}
|
|
1900
|
+
return resolveRegistryLabel(formatMessage, definition.labelId, definition.label) || definition.type || '';
|
|
1901
|
+
};
|
|
1902
|
+
|
|
1852
1903
|
/**
|
|
1853
1904
|
* 解析字段提交值的 JSON Schema 片段。
|
|
1854
1905
|
* 优先用 definition.valueSchema(对象或 (field)=>schema);缺省 { type: 'string' }。
|
|
@@ -1898,15 +1949,12 @@ const getFieldComponent = (type, field) => {
|
|
|
1898
1949
|
}
|
|
1899
1950
|
return definition.component;
|
|
1900
1951
|
};
|
|
1901
|
-
const getFieldTypes =
|
|
1952
|
+
const getFieldTypes = formatMessage => {
|
|
1902
1953
|
const grouped = FIELD_GROUPS.map(group => ({
|
|
1903
|
-
label: group.label,
|
|
1904
|
-
options: group.types.map(type => registry.get(type)).filter(Boolean).map(({
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
}) => ({
|
|
1908
|
-
label,
|
|
1909
|
-
value: type
|
|
1954
|
+
label: resolveRegistryLabel(formatMessage, group.labelId, group.label),
|
|
1955
|
+
options: group.types.map(type => registry.get(type)).filter(Boolean).map(item => ({
|
|
1956
|
+
label: resolveFieldTypeLabel(item, formatMessage),
|
|
1957
|
+
value: item.type
|
|
1910
1958
|
}))
|
|
1911
1959
|
}));
|
|
1912
1960
|
const builtinTypes = new Set(FIELD_GROUPS.flatMap(group => group.types));
|
|
@@ -1915,20 +1963,28 @@ const getFieldTypes = () => {
|
|
|
1915
1963
|
const fallback = [];
|
|
1916
1964
|
registered.forEach(item => {
|
|
1917
1965
|
const option = {
|
|
1918
|
-
label: item
|
|
1966
|
+
label: resolveFieldTypeLabel(item, formatMessage),
|
|
1919
1967
|
value: item.type
|
|
1920
1968
|
};
|
|
1969
|
+
const groupNameId = item.groupNameId != null && String(item.groupNameId).trim() ? String(item.groupNameId).trim() : '';
|
|
1921
1970
|
const groupName = item.groupName != null && String(item.groupName).trim() ? String(item.groupName).trim() : '';
|
|
1922
|
-
if (!groupName) {
|
|
1971
|
+
if (!groupNameId && !groupName) {
|
|
1923
1972
|
fallback.push(option);
|
|
1924
1973
|
return;
|
|
1925
1974
|
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1975
|
+
const groupKey = groupNameId || groupName;
|
|
1976
|
+
if (!customGroups.has(groupKey)) {
|
|
1977
|
+
customGroups.set(groupKey, {
|
|
1978
|
+
label: resolveRegistryLabel(formatMessage, groupNameId || null, groupName),
|
|
1979
|
+
options: []
|
|
1980
|
+
});
|
|
1928
1981
|
}
|
|
1929
|
-
customGroups.get(
|
|
1982
|
+
customGroups.get(groupKey).options.push(option);
|
|
1930
1983
|
});
|
|
1931
|
-
customGroups.forEach((
|
|
1984
|
+
customGroups.forEach(({
|
|
1985
|
+
label,
|
|
1986
|
+
options
|
|
1987
|
+
}) => {
|
|
1932
1988
|
grouped.push({
|
|
1933
1989
|
label,
|
|
1934
1990
|
options
|
|
@@ -1936,7 +1992,7 @@ const getFieldTypes = () => {
|
|
|
1936
1992
|
});
|
|
1937
1993
|
if (fallback.length) {
|
|
1938
1994
|
grouped.push({
|
|
1939
|
-
label: '扩展字段',
|
|
1995
|
+
label: resolveRegistryLabel(formatMessage, 'FieldGroupExtended', '扩展字段'),
|
|
1940
1996
|
options: fallback
|
|
1941
1997
|
});
|
|
1942
1998
|
}
|
|
@@ -2314,7 +2370,7 @@ const FieldRow = ({
|
|
|
2314
2370
|
}), /*#__PURE__*/jsx(Tag, {
|
|
2315
2371
|
bordered: false,
|
|
2316
2372
|
color: TYPE_TAG_COLORS[field.type] || 'default',
|
|
2317
|
-
children: (definition
|
|
2373
|
+
children: resolveFieldTypeLabel(definition || field.type, formatMessage)
|
|
2318
2374
|
}), field.hidden ? /*#__PURE__*/jsx(Tag, {
|
|
2319
2375
|
bordered: false,
|
|
2320
2376
|
children: formatMessage({
|
|
@@ -2914,7 +2970,7 @@ const BlockListPanel = ({
|
|
|
2914
2970
|
}) : block.kind === 'multiField' ? formatMessage({
|
|
2915
2971
|
id: 'multiFieldSummary'
|
|
2916
2972
|
}, {
|
|
2917
|
-
type: block.fieldType
|
|
2973
|
+
type: resolveFieldTypeLabel(block.fieldType, formatMessage)
|
|
2918
2974
|
}) : block.kind === 'choice' ? formatMessage({
|
|
2919
2975
|
id: 'choiceOptionCount'
|
|
2920
2976
|
}, {
|
|
@@ -2938,7 +2994,9 @@ const BlockListPanel = ({
|
|
|
2938
2994
|
children: [/*#__PURE__*/jsx(Tag, {
|
|
2939
2995
|
bordered: false,
|
|
2940
2996
|
color: (definition == null ? void 0 : definition.color) || 'default',
|
|
2941
|
-
children: (
|
|
2997
|
+
children: formatMessage({
|
|
2998
|
+
id: `blockKind_${block.kind}`
|
|
2999
|
+
})
|
|
2942
3000
|
}), /*#__PURE__*/jsx(Text$3, {
|
|
2943
3001
|
strong: true,
|
|
2944
3002
|
ellipsis: true,
|
|
@@ -3056,7 +3114,7 @@ const BlockConfigFields = ({
|
|
|
3056
3114
|
formatMessage
|
|
3057
3115
|
} = useIntl();
|
|
3058
3116
|
const definition = getBlockDefinition(kind);
|
|
3059
|
-
const fieldTypeOptions = useMemo(() => getFieldTypes(), []);
|
|
3117
|
+
const fieldTypeOptions = useMemo(() => getFieldTypes(formatMessage), [formatMessage]);
|
|
3060
3118
|
const list = [];
|
|
3061
3119
|
if (kind === 'formInfo' || kind === 'list' || kind === 'tableList' || kind === 'object') {
|
|
3062
3120
|
list.push(/*#__PURE__*/jsx(Input, {
|
|
@@ -3269,7 +3327,9 @@ const BlockConfigFields = ({
|
|
|
3269
3327
|
return /*#__PURE__*/jsx("div", {
|
|
3270
3328
|
className: style['field-editor-form'],
|
|
3271
3329
|
children: /*#__PURE__*/jsx(FormInfo, {
|
|
3272
|
-
title: (
|
|
3330
|
+
title: formatMessage({
|
|
3331
|
+
id: `blockKind_${kind}`
|
|
3332
|
+
}),
|
|
3273
3333
|
subtitle: definition == null ? void 0 : definition.description,
|
|
3274
3334
|
column: 1,
|
|
3275
3335
|
list: list.filter(Boolean)
|
|
@@ -4457,7 +4517,7 @@ const FieldConfigFields = ({
|
|
|
4457
4517
|
openApi
|
|
4458
4518
|
} = useFormContext();
|
|
4459
4519
|
const [fieldType, setFieldType] = useState(initialType);
|
|
4460
|
-
const fieldTypeOptions = useMemo(() => getFieldTypes(), []);
|
|
4520
|
+
const fieldTypeOptions = useMemo(() => getFieldTypes(formatMessage), [formatMessage]);
|
|
4461
4521
|
const definition = getFieldDefinition(fieldType);
|
|
4462
4522
|
useEffect(() => {
|
|
4463
4523
|
setFieldType(initialType);
|
|
@@ -4974,6 +5034,7 @@ const ChoiceBlock = ({
|
|
|
4974
5034
|
block,
|
|
4975
5035
|
preview: _preview = false,
|
|
4976
5036
|
isMobile: _isMobile = false,
|
|
5037
|
+
isPartRoot: _isPartRoot = false,
|
|
4977
5038
|
formatMessage,
|
|
4978
5039
|
renderOptionContent
|
|
4979
5040
|
}) => {
|
|
@@ -5119,7 +5180,7 @@ const ChoiceBlock = ({
|
|
|
5119
5180
|
title,
|
|
5120
5181
|
subtitle: modeHint,
|
|
5121
5182
|
bordered,
|
|
5122
|
-
className: style['choice-block'],
|
|
5183
|
+
className: [style['choice-block'], _isPartRoot ? InfoPage.partRootClassName : null].filter(Boolean).join(' '),
|
|
5123
5184
|
'data-choice-mode': mode
|
|
5124
5185
|
}, /*#__PURE__*/createElement('div', {
|
|
5125
5186
|
className: style['choice-selector']
|
|
@@ -5143,8 +5204,14 @@ const buildLabelTips = tips => {
|
|
|
5143
5204
|
className: style['field-label-tips-icon']
|
|
5144
5205
|
}));
|
|
5145
5206
|
};
|
|
5207
|
+
const resolvePartRootClassName = (depth, ...extra) => {
|
|
5208
|
+
// 顶层模块一律重设一级标题,嵌入外层 FormInfo Part 时不降为二级胶囊
|
|
5209
|
+
const names = [depth === 0 ? InfoPage.partRootClassName : null, ...extra].filter(Boolean);
|
|
5210
|
+
return names.length ? names.join(' ') : undefined;
|
|
5211
|
+
};
|
|
5146
5212
|
const renderFieldElements = (fields = [], preview = false, {
|
|
5147
|
-
namePrefix
|
|
5213
|
+
namePrefix,
|
|
5214
|
+
locale
|
|
5148
5215
|
} = {}) => fields.filter(field => !field.hidden).map(field => {
|
|
5149
5216
|
var _props$options;
|
|
5150
5217
|
const Component = getFieldComponent(field.type, field);
|
|
@@ -5162,13 +5229,17 @@ const renderFieldElements = (fields = [], preview = false, {
|
|
|
5162
5229
|
delete props.range;
|
|
5163
5230
|
const description = field.description != null && String(field.description).trim() ? field.description : undefined;
|
|
5164
5231
|
const fieldName = namePrefix && field.name ? `${namePrefix}.${field.name}` : field.name;
|
|
5232
|
+
// 显式传 locale,避免 Global 仍为 zh-CN 时 react-form-antd withLocale 盖掉父级英文
|
|
5233
|
+
const localeProps = locale ? {
|
|
5234
|
+
locale
|
|
5235
|
+
} : {};
|
|
5165
5236
|
return /*#__PURE__*/createElement(Component, _extends({
|
|
5166
5237
|
key: field.id,
|
|
5167
5238
|
name: fieldName,
|
|
5168
5239
|
label: field.label,
|
|
5169
5240
|
rule: field.rule || undefined,
|
|
5170
5241
|
block: field.block || undefined
|
|
5171
|
-
}, props, {
|
|
5242
|
+
}, props, localeProps, {
|
|
5172
5243
|
labelTips: buildLabelTips(field.tips),
|
|
5173
5244
|
description
|
|
5174
5245
|
}));
|
|
@@ -5203,7 +5274,8 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5203
5274
|
isMobile = false,
|
|
5204
5275
|
formatMessage,
|
|
5205
5276
|
depth = 0,
|
|
5206
|
-
asListItem = false
|
|
5277
|
+
asListItem = false,
|
|
5278
|
+
locale
|
|
5207
5279
|
} = ctx;
|
|
5208
5280
|
if (!block || depth > MAX_BLOCK_DEPTH) {
|
|
5209
5281
|
return null;
|
|
@@ -5212,6 +5284,9 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5212
5284
|
depth: depth + 1,
|
|
5213
5285
|
asListItem: false
|
|
5214
5286
|
});
|
|
5287
|
+
const fieldRenderOpts = {
|
|
5288
|
+
locale
|
|
5289
|
+
};
|
|
5215
5290
|
const bordered = isMobile ? false : block.bordered || undefined;
|
|
5216
5291
|
// 仅 FormInfo/object 吃列表项 Part 样式;List 等交给 form-info nestDepth
|
|
5217
5292
|
const listItemPartProps = asListItem && isFormInfoLikeBlock(block.kind) ? nestedListItemPartProps : null;
|
|
@@ -5227,7 +5302,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5227
5302
|
switch (block.kind) {
|
|
5228
5303
|
case 'formInfo':
|
|
5229
5304
|
{
|
|
5230
|
-
const fields = renderFieldElements(block.list, preview);
|
|
5305
|
+
const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
|
|
5231
5306
|
const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
|
|
5232
5307
|
return withBlockLayout(/*#__PURE__*/createElement(FormInfo, _extends({
|
|
5233
5308
|
key: block.id,
|
|
@@ -5237,13 +5312,15 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5237
5312
|
gap: block.gap,
|
|
5238
5313
|
bordered,
|
|
5239
5314
|
list: [...fields, ...nested]
|
|
5240
|
-
}, listItemPartProps || {}
|
|
5315
|
+
}, listItemPartProps || {}, {
|
|
5316
|
+
className: resolvePartRootClassName(depth)
|
|
5317
|
+
})), asListItem);
|
|
5241
5318
|
}
|
|
5242
5319
|
case 'object':
|
|
5243
5320
|
{
|
|
5244
|
-
const fields = renderFieldElements(block.list, preview, {
|
|
5321
|
+
const fields = renderFieldElements(block.list, preview, _extends({}, fieldRenderOpts, {
|
|
5245
5322
|
namePrefix: block.name || ''
|
|
5246
|
-
});
|
|
5323
|
+
}));
|
|
5247
5324
|
const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
|
|
5248
5325
|
return withBlockLayout(/*#__PURE__*/createElement(FormInfo, _extends({
|
|
5249
5326
|
key: block.id,
|
|
@@ -5253,11 +5330,13 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5253
5330
|
gap: block.gap,
|
|
5254
5331
|
bordered,
|
|
5255
5332
|
list: [...fields, ...nested]
|
|
5256
|
-
}, listItemPartProps || {}
|
|
5333
|
+
}, listItemPartProps || {}, {
|
|
5334
|
+
className: resolvePartRootClassName(depth)
|
|
5335
|
+
})), asListItem);
|
|
5257
5336
|
}
|
|
5258
5337
|
case 'list':
|
|
5259
5338
|
{
|
|
5260
|
-
const fields = renderFieldElements(block.list, preview);
|
|
5339
|
+
const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
|
|
5261
5340
|
const nested = renderItemBlocks(block.itemBlocks || []);
|
|
5262
5341
|
return withBlockLayout(/*#__PURE__*/createElement(List, _extends({
|
|
5263
5342
|
key: block.id,
|
|
@@ -5265,6 +5344,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5265
5344
|
title: block.title || undefined,
|
|
5266
5345
|
important: block.important || undefined,
|
|
5267
5346
|
bordered,
|
|
5347
|
+
className: resolvePartRootClassName(depth),
|
|
5268
5348
|
maxLength: block.maxLength,
|
|
5269
5349
|
minLength: block.minLength
|
|
5270
5350
|
}, block.addText ? {
|
|
@@ -5277,7 +5357,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5277
5357
|
}
|
|
5278
5358
|
case 'tableList':
|
|
5279
5359
|
{
|
|
5280
|
-
const fields = renderFieldElements(block.list, preview);
|
|
5360
|
+
const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
|
|
5281
5361
|
return withBlockLayout(/*#__PURE__*/createElement(TableList, _extends({
|
|
5282
5362
|
key: block.id,
|
|
5283
5363
|
name: block.name,
|
|
@@ -5289,7 +5369,9 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5289
5369
|
addText: block.addText
|
|
5290
5370
|
} : {}, {
|
|
5291
5371
|
list: fields
|
|
5292
|
-
}, listItemPartProps || {}
|
|
5372
|
+
}, listItemPartProps || {}, {
|
|
5373
|
+
className: resolvePartRootClassName(depth)
|
|
5374
|
+
})), asListItem);
|
|
5293
5375
|
}
|
|
5294
5376
|
case 'multiField':
|
|
5295
5377
|
{
|
|
@@ -5314,10 +5396,11 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5314
5396
|
title: block.title || undefined,
|
|
5315
5397
|
subtitle: block.subtitle || undefined,
|
|
5316
5398
|
bordered,
|
|
5399
|
+
className: resolvePartRootClassName(depth),
|
|
5317
5400
|
prevIcon: /*#__PURE__*/createElement(ArrowLeftOutlined),
|
|
5318
5401
|
nextIcon: /*#__PURE__*/createElement(ArrowRightOutlined),
|
|
5319
5402
|
items: (block.items || []).map(step => {
|
|
5320
|
-
const fields = renderFieldElements(step.list, preview);
|
|
5403
|
+
const fields = renderFieldElements(step.list, preview, fieldRenderOpts);
|
|
5321
5404
|
const nested = renderChildBlocks(step.blocks || [], nextCtx);
|
|
5322
5405
|
const fieldNames = [...(step.list || []).filter(field => field && !field.hidden && field.name).map(field => field.name), ...collectBlockFieldNames(step.blocks || [])];
|
|
5323
5406
|
if (nested.length) {
|
|
@@ -5354,6 +5437,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5354
5437
|
block,
|
|
5355
5438
|
preview,
|
|
5356
5439
|
isMobile,
|
|
5440
|
+
isPartRoot: depth === 0,
|
|
5357
5441
|
formatMessage,
|
|
5358
5442
|
renderOptionContent: option => {
|
|
5359
5443
|
const nodes = [];
|
|
@@ -5379,6 +5463,7 @@ const renderSchemaInner = (schema, {
|
|
|
5379
5463
|
bodyClassName,
|
|
5380
5464
|
isMobile: _isMobile = false,
|
|
5381
5465
|
formatMessage,
|
|
5466
|
+
locale,
|
|
5382
5467
|
children,
|
|
5383
5468
|
actionNode
|
|
5384
5469
|
} = {}) => {
|
|
@@ -5386,7 +5471,8 @@ const renderSchemaInner = (schema, {
|
|
|
5386
5471
|
const blocks = normalized.blocks || [];
|
|
5387
5472
|
const contentChildren = blocks.map(block => renderBlockElement(block, _preview, {
|
|
5388
5473
|
isMobile: _isMobile,
|
|
5389
|
-
formatMessage
|
|
5474
|
+
formatMessage,
|
|
5475
|
+
locale
|
|
5390
5476
|
})).filter(Boolean);
|
|
5391
5477
|
if (!contentChildren.length && !children && !actionNode) {
|
|
5392
5478
|
return null;
|
|
@@ -5406,6 +5492,7 @@ const renderSchemaContent = (schema, {
|
|
|
5406
5492
|
bodyClassName,
|
|
5407
5493
|
isMobile: _isMobile2 = false,
|
|
5408
5494
|
formatMessage,
|
|
5495
|
+
locale,
|
|
5409
5496
|
children,
|
|
5410
5497
|
actionNode
|
|
5411
5498
|
} = {}) => {
|
|
@@ -5413,7 +5500,8 @@ const renderSchemaContent = (schema, {
|
|
|
5413
5500
|
const blocks = normalized.blocks || [];
|
|
5414
5501
|
const contentChildren = blocks.map(block => renderBlockElement(block, _preview2, {
|
|
5415
5502
|
isMobile: _isMobile2,
|
|
5416
|
-
formatMessage
|
|
5503
|
+
formatMessage,
|
|
5504
|
+
locale
|
|
5417
5505
|
})).filter(Boolean);
|
|
5418
5506
|
if (!contentChildren.length && !children) {
|
|
5419
5507
|
return null;
|
|
@@ -5522,7 +5610,8 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5522
5610
|
buttonFooterProps
|
|
5523
5611
|
} = props;
|
|
5524
5612
|
const {
|
|
5525
|
-
formatMessage
|
|
5613
|
+
formatMessage,
|
|
5614
|
+
locale
|
|
5526
5615
|
} = useIntl();
|
|
5527
5616
|
const isMobile = useIsMobile();
|
|
5528
5617
|
const normalized = normalizeSchema(schema);
|
|
@@ -5555,6 +5644,7 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5555
5644
|
bodyClassName,
|
|
5556
5645
|
isMobile,
|
|
5557
5646
|
formatMessage,
|
|
5647
|
+
locale,
|
|
5558
5648
|
children,
|
|
5559
5649
|
actionNode
|
|
5560
5650
|
});
|
|
@@ -5585,7 +5675,8 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5585
5675
|
buttonFooterProps
|
|
5586
5676
|
} = props;
|
|
5587
5677
|
const {
|
|
5588
|
-
formatMessage
|
|
5678
|
+
formatMessage,
|
|
5679
|
+
locale
|
|
5589
5680
|
} = useIntl();
|
|
5590
5681
|
const isMobile = useIsMobile();
|
|
5591
5682
|
const normalized = normalizeSchema(schema);
|
|
@@ -5619,6 +5710,7 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5619
5710
|
bodyClassName,
|
|
5620
5711
|
isMobile,
|
|
5621
5712
|
formatMessage,
|
|
5713
|
+
locale,
|
|
5622
5714
|
children,
|
|
5623
5715
|
actionNode
|
|
5624
5716
|
});
|
|
@@ -5636,7 +5728,8 @@ const FormCreator = withLocale$1(({
|
|
|
5636
5728
|
extraToolbar
|
|
5637
5729
|
}) => {
|
|
5638
5730
|
const {
|
|
5639
|
-
formatMessage
|
|
5731
|
+
formatMessage,
|
|
5732
|
+
locale
|
|
5640
5733
|
} = useIntl();
|
|
5641
5734
|
const isMobile = useIsMobile();
|
|
5642
5735
|
const [innerSchema, setInnerSchema] = useState(() => normalizeSchema(defaultValue || defaultSchema()));
|
|
@@ -5954,7 +6047,8 @@ const FormCreator = withLocale$1(({
|
|
|
5954
6047
|
children: hasRenderableContent(schema) ? /*#__PURE__*/jsx(SchemaRenderer$1, {
|
|
5955
6048
|
schema: schema,
|
|
5956
6049
|
preview: true,
|
|
5957
|
-
formProps: formProps
|
|
6050
|
+
formProps: formProps,
|
|
6051
|
+
locale: locale
|
|
5958
6052
|
}) : /*#__PURE__*/jsx(Empty, {
|
|
5959
6053
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
5960
6054
|
description: formatMessage({
|
|
@@ -6923,7 +7017,8 @@ const renderBlock = (block, data, ctx) => {
|
|
|
6923
7017
|
key: block.id,
|
|
6924
7018
|
title: block.title || block.label || undefined,
|
|
6925
7019
|
subtitle: block.subtitle || undefined,
|
|
6926
|
-
bordered
|
|
7020
|
+
bordered,
|
|
7021
|
+
className: depth === 0 ? InfoPage.partRootClassName : undefined
|
|
6927
7022
|
};
|
|
6928
7023
|
switch (block.kind) {
|
|
6929
7024
|
case 'formInfo':
|
|
@@ -7068,5 +7163,5 @@ const SchemaContent = withLocale$1(({
|
|
|
7068
7163
|
});
|
|
7069
7164
|
var SchemaContent$1 = SchemaContent;
|
|
7070
7165
|
|
|
7071
|
-
export { FormCreator$1 as FormCreator, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaContent$1 as SchemaContent, SchemaContentInner, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectBlockFieldNames, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, findBlockInTree, formValuesToBlock, formValuesToField, formatByValueSchema, formatFieldDisplayValue, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasRenderableContent, isFieldNameUnique, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, removeBlockInTree, resolveFieldValueSchema, schemaToDataSchema, updateBlocks };
|
|
7166
|
+
export { FormCreator$1 as FormCreator, MAX_BLOCK_DEPTH, RULE_LEN_PRESET, RULE_PRESET_ITEMS, SchemaContent$1 as SchemaContent, SchemaContentInner, SchemaRenderer$1 as SchemaRenderer, SchemaRendererInner, applyFromPropsSchema, blockToFormValues, buildRuleString, collectBlockFieldNames, collectSchemaFields, createBlock, createChoiceOption, createField$1 as createField, createFieldId, createStep, FormCreator$1 as default, defaultFormActions, defaultSchema, fieldToFormValues, findBlock, findBlockInTree, formValuesToBlock, formValuesToField, formatByValueSchema, formatFieldDisplayValue, getBlockDefinition, getBlockKindOptions, getFieldComponent, getFieldDefinition, getFieldTypes, getRulePresetItems, hasRenderableContent, isFieldNameUnique, mapBlocks, moveBlockInTree, moveItem, normalizeBlock, normalizeFormActions, normalizeOptions, normalizeSchema, parseRuleString, pickFieldProps, pickFromPropsSchema, preset, registerField, removeBlockInTree, resolveFieldTypeLabel, resolveFieldValueSchema, schemaToDataSchema, updateBlocks };
|
|
7072
7167
|
//# sourceMappingURL=index.modern.js.map
|