@kne/form-creator 0.1.17 → 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 +171 -73
- package/dist/index.js +156 -75
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +154 -75
- 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 +3 -3
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);
|
|
@@ -5150,7 +5210,8 @@ const resolvePartRootClassName = (depth, ...extra) => {
|
|
|
5150
5210
|
return names.length ? names.join(' ') : undefined;
|
|
5151
5211
|
};
|
|
5152
5212
|
const renderFieldElements = (fields = [], preview = false, {
|
|
5153
|
-
namePrefix
|
|
5213
|
+
namePrefix,
|
|
5214
|
+
locale
|
|
5154
5215
|
} = {}) => fields.filter(field => !field.hidden).map(field => {
|
|
5155
5216
|
var _props$options;
|
|
5156
5217
|
const Component = getFieldComponent(field.type, field);
|
|
@@ -5168,13 +5229,17 @@ const renderFieldElements = (fields = [], preview = false, {
|
|
|
5168
5229
|
delete props.range;
|
|
5169
5230
|
const description = field.description != null && String(field.description).trim() ? field.description : undefined;
|
|
5170
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
|
+
} : {};
|
|
5171
5236
|
return /*#__PURE__*/createElement(Component, _extends({
|
|
5172
5237
|
key: field.id,
|
|
5173
5238
|
name: fieldName,
|
|
5174
5239
|
label: field.label,
|
|
5175
5240
|
rule: field.rule || undefined,
|
|
5176
5241
|
block: field.block || undefined
|
|
5177
|
-
}, props, {
|
|
5242
|
+
}, props, localeProps, {
|
|
5178
5243
|
labelTips: buildLabelTips(field.tips),
|
|
5179
5244
|
description
|
|
5180
5245
|
}));
|
|
@@ -5209,7 +5274,8 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5209
5274
|
isMobile = false,
|
|
5210
5275
|
formatMessage,
|
|
5211
5276
|
depth = 0,
|
|
5212
|
-
asListItem = false
|
|
5277
|
+
asListItem = false,
|
|
5278
|
+
locale
|
|
5213
5279
|
} = ctx;
|
|
5214
5280
|
if (!block || depth > MAX_BLOCK_DEPTH) {
|
|
5215
5281
|
return null;
|
|
@@ -5218,6 +5284,9 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5218
5284
|
depth: depth + 1,
|
|
5219
5285
|
asListItem: false
|
|
5220
5286
|
});
|
|
5287
|
+
const fieldRenderOpts = {
|
|
5288
|
+
locale
|
|
5289
|
+
};
|
|
5221
5290
|
const bordered = isMobile ? false : block.bordered || undefined;
|
|
5222
5291
|
// 仅 FormInfo/object 吃列表项 Part 样式;List 等交给 form-info nestDepth
|
|
5223
5292
|
const listItemPartProps = asListItem && isFormInfoLikeBlock(block.kind) ? nestedListItemPartProps : null;
|
|
@@ -5233,7 +5302,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5233
5302
|
switch (block.kind) {
|
|
5234
5303
|
case 'formInfo':
|
|
5235
5304
|
{
|
|
5236
|
-
const fields = renderFieldElements(block.list, preview);
|
|
5305
|
+
const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
|
|
5237
5306
|
const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
|
|
5238
5307
|
return withBlockLayout(/*#__PURE__*/createElement(FormInfo, _extends({
|
|
5239
5308
|
key: block.id,
|
|
@@ -5249,9 +5318,9 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5249
5318
|
}
|
|
5250
5319
|
case 'object':
|
|
5251
5320
|
{
|
|
5252
|
-
const fields = renderFieldElements(block.list, preview, {
|
|
5321
|
+
const fields = renderFieldElements(block.list, preview, _extends({}, fieldRenderOpts, {
|
|
5253
5322
|
namePrefix: block.name || ''
|
|
5254
|
-
});
|
|
5323
|
+
}));
|
|
5255
5324
|
const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
|
|
5256
5325
|
return withBlockLayout(/*#__PURE__*/createElement(FormInfo, _extends({
|
|
5257
5326
|
key: block.id,
|
|
@@ -5267,7 +5336,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5267
5336
|
}
|
|
5268
5337
|
case 'list':
|
|
5269
5338
|
{
|
|
5270
|
-
const fields = renderFieldElements(block.list, preview);
|
|
5339
|
+
const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
|
|
5271
5340
|
const nested = renderItemBlocks(block.itemBlocks || []);
|
|
5272
5341
|
return withBlockLayout(/*#__PURE__*/createElement(List, _extends({
|
|
5273
5342
|
key: block.id,
|
|
@@ -5288,7 +5357,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5288
5357
|
}
|
|
5289
5358
|
case 'tableList':
|
|
5290
5359
|
{
|
|
5291
|
-
const fields = renderFieldElements(block.list, preview);
|
|
5360
|
+
const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
|
|
5292
5361
|
return withBlockLayout(/*#__PURE__*/createElement(TableList, _extends({
|
|
5293
5362
|
key: block.id,
|
|
5294
5363
|
name: block.name,
|
|
@@ -5331,7 +5400,7 @@ const renderBlockElement = (block, preview = false, ctx = {}) => {
|
|
|
5331
5400
|
prevIcon: /*#__PURE__*/createElement(ArrowLeftOutlined),
|
|
5332
5401
|
nextIcon: /*#__PURE__*/createElement(ArrowRightOutlined),
|
|
5333
5402
|
items: (block.items || []).map(step => {
|
|
5334
|
-
const fields = renderFieldElements(step.list, preview);
|
|
5403
|
+
const fields = renderFieldElements(step.list, preview, fieldRenderOpts);
|
|
5335
5404
|
const nested = renderChildBlocks(step.blocks || [], nextCtx);
|
|
5336
5405
|
const fieldNames = [...(step.list || []).filter(field => field && !field.hidden && field.name).map(field => field.name), ...collectBlockFieldNames(step.blocks || [])];
|
|
5337
5406
|
if (nested.length) {
|
|
@@ -5394,6 +5463,7 @@ const renderSchemaInner = (schema, {
|
|
|
5394
5463
|
bodyClassName,
|
|
5395
5464
|
isMobile: _isMobile = false,
|
|
5396
5465
|
formatMessage,
|
|
5466
|
+
locale,
|
|
5397
5467
|
children,
|
|
5398
5468
|
actionNode
|
|
5399
5469
|
} = {}) => {
|
|
@@ -5401,7 +5471,8 @@ const renderSchemaInner = (schema, {
|
|
|
5401
5471
|
const blocks = normalized.blocks || [];
|
|
5402
5472
|
const contentChildren = blocks.map(block => renderBlockElement(block, _preview, {
|
|
5403
5473
|
isMobile: _isMobile,
|
|
5404
|
-
formatMessage
|
|
5474
|
+
formatMessage,
|
|
5475
|
+
locale
|
|
5405
5476
|
})).filter(Boolean);
|
|
5406
5477
|
if (!contentChildren.length && !children && !actionNode) {
|
|
5407
5478
|
return null;
|
|
@@ -5421,6 +5492,7 @@ const renderSchemaContent = (schema, {
|
|
|
5421
5492
|
bodyClassName,
|
|
5422
5493
|
isMobile: _isMobile2 = false,
|
|
5423
5494
|
formatMessage,
|
|
5495
|
+
locale,
|
|
5424
5496
|
children,
|
|
5425
5497
|
actionNode
|
|
5426
5498
|
} = {}) => {
|
|
@@ -5428,7 +5500,8 @@ const renderSchemaContent = (schema, {
|
|
|
5428
5500
|
const blocks = normalized.blocks || [];
|
|
5429
5501
|
const contentChildren = blocks.map(block => renderBlockElement(block, _preview2, {
|
|
5430
5502
|
isMobile: _isMobile2,
|
|
5431
|
-
formatMessage
|
|
5503
|
+
formatMessage,
|
|
5504
|
+
locale
|
|
5432
5505
|
})).filter(Boolean);
|
|
5433
5506
|
if (!contentChildren.length && !children) {
|
|
5434
5507
|
return null;
|
|
@@ -5537,7 +5610,8 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5537
5610
|
buttonFooterProps
|
|
5538
5611
|
} = props;
|
|
5539
5612
|
const {
|
|
5540
|
-
formatMessage
|
|
5613
|
+
formatMessage,
|
|
5614
|
+
locale
|
|
5541
5615
|
} = useIntl();
|
|
5542
5616
|
const isMobile = useIsMobile();
|
|
5543
5617
|
const normalized = normalizeSchema(schema);
|
|
@@ -5570,6 +5644,7 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5570
5644
|
bodyClassName,
|
|
5571
5645
|
isMobile,
|
|
5572
5646
|
formatMessage,
|
|
5647
|
+
locale,
|
|
5573
5648
|
children,
|
|
5574
5649
|
actionNode
|
|
5575
5650
|
});
|
|
@@ -5600,7 +5675,8 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5600
5675
|
buttonFooterProps
|
|
5601
5676
|
} = props;
|
|
5602
5677
|
const {
|
|
5603
|
-
formatMessage
|
|
5678
|
+
formatMessage,
|
|
5679
|
+
locale
|
|
5604
5680
|
} = useIntl();
|
|
5605
5681
|
const isMobile = useIsMobile();
|
|
5606
5682
|
const normalized = normalizeSchema(schema);
|
|
@@ -5634,6 +5710,7 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5634
5710
|
bodyClassName,
|
|
5635
5711
|
isMobile,
|
|
5636
5712
|
formatMessage,
|
|
5713
|
+
locale,
|
|
5637
5714
|
children,
|
|
5638
5715
|
actionNode
|
|
5639
5716
|
});
|
|
@@ -5651,7 +5728,8 @@ const FormCreator = withLocale$1(({
|
|
|
5651
5728
|
extraToolbar
|
|
5652
5729
|
}) => {
|
|
5653
5730
|
const {
|
|
5654
|
-
formatMessage
|
|
5731
|
+
formatMessage,
|
|
5732
|
+
locale
|
|
5655
5733
|
} = useIntl();
|
|
5656
5734
|
const isMobile = useIsMobile();
|
|
5657
5735
|
const [innerSchema, setInnerSchema] = useState(() => normalizeSchema(defaultValue || defaultSchema()));
|
|
@@ -5969,7 +6047,8 @@ const FormCreator = withLocale$1(({
|
|
|
5969
6047
|
children: hasRenderableContent(schema) ? /*#__PURE__*/jsx(SchemaRenderer$1, {
|
|
5970
6048
|
schema: schema,
|
|
5971
6049
|
preview: true,
|
|
5972
|
-
formProps: formProps
|
|
6050
|
+
formProps: formProps,
|
|
6051
|
+
locale: locale
|
|
5973
6052
|
}) : /*#__PURE__*/jsx(Empty, {
|
|
5974
6053
|
image: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
5975
6054
|
description: formatMessage({
|
|
@@ -7084,5 +7163,5 @@ const SchemaContent = withLocale$1(({
|
|
|
7084
7163
|
});
|
|
7085
7164
|
var SchemaContent$1 = SchemaContent;
|
|
7086
7165
|
|
|
7087
|
-
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 };
|
|
7088
7167
|
//# sourceMappingURL=index.modern.js.map
|