@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.js
CHANGED
|
@@ -110,6 +110,27 @@ const locale$1 = {
|
|
|
110
110
|
stepNext: '下一步',
|
|
111
111
|
stepComplete: '完成',
|
|
112
112
|
fieldType: '填写项类型',
|
|
113
|
+
FieldGroupBasic: '基础字段',
|
|
114
|
+
FieldGroupSelect: '选择字段',
|
|
115
|
+
FieldGroupAdvancedSelect: '高级选择',
|
|
116
|
+
FieldGroupBusinessSelect: '业务选择',
|
|
117
|
+
FieldGroupExtended: '扩展字段',
|
|
118
|
+
FieldTypeInput: '单行文本',
|
|
119
|
+
FieldTypeTextArea: '多行文本',
|
|
120
|
+
FieldTypeInputNumber: '数字',
|
|
121
|
+
FieldTypeSelect: '下拉选择',
|
|
122
|
+
FieldTypeRadioGroup: '单选组',
|
|
123
|
+
FieldTypeCheckboxGroup: '复选组',
|
|
124
|
+
FieldTypeSuperSelectList: '普通下拉',
|
|
125
|
+
FieldTypeSuperSelectTableList: '表格选择',
|
|
126
|
+
FieldTypeSuperSelectTree: '树形选择',
|
|
127
|
+
FieldTypeSuperSelectCascader: '级联选择',
|
|
128
|
+
FieldTypeSelectFunction: '职能选择',
|
|
129
|
+
FieldTypeSelectIndustry: '行业选择',
|
|
130
|
+
FieldTypeSelectAddress: '地址选择',
|
|
131
|
+
FieldTypeSwitch: '开关',
|
|
132
|
+
FieldTypeCheckbox: '复选框',
|
|
133
|
+
FieldTypeDatePicker: '日期',
|
|
113
134
|
fieldName: '保存用的名称',
|
|
114
135
|
fieldNamePlaceholder: '已自动生成,可修改',
|
|
115
136
|
fieldLabel: '显示名称',
|
|
@@ -313,6 +334,27 @@ const locale = {
|
|
|
313
334
|
stepNext: 'Next',
|
|
314
335
|
stepComplete: 'Done',
|
|
315
336
|
fieldType: 'Field Type',
|
|
337
|
+
FieldGroupBasic: 'Basic Fields',
|
|
338
|
+
FieldGroupSelect: 'Select Fields',
|
|
339
|
+
FieldGroupAdvancedSelect: 'Advanced Select',
|
|
340
|
+
FieldGroupBusinessSelect: 'Business Select',
|
|
341
|
+
FieldGroupExtended: 'Extended Fields',
|
|
342
|
+
FieldTypeInput: 'Single-line Text',
|
|
343
|
+
FieldTypeTextArea: 'Multi-line Text',
|
|
344
|
+
FieldTypeInputNumber: 'Number',
|
|
345
|
+
FieldTypeSelect: 'Dropdown',
|
|
346
|
+
FieldTypeRadioGroup: 'Radio Group',
|
|
347
|
+
FieldTypeCheckboxGroup: 'Checkbox Group',
|
|
348
|
+
FieldTypeSuperSelectList: 'Select List',
|
|
349
|
+
FieldTypeSuperSelectTableList: 'Table Select',
|
|
350
|
+
FieldTypeSuperSelectTree: 'Tree Select',
|
|
351
|
+
FieldTypeSuperSelectCascader: 'Cascader',
|
|
352
|
+
FieldTypeSelectFunction: 'Job Function',
|
|
353
|
+
FieldTypeSelectIndustry: 'Industry',
|
|
354
|
+
FieldTypeSelectAddress: 'Address',
|
|
355
|
+
FieldTypeSwitch: 'Switch',
|
|
356
|
+
FieldTypeCheckbox: 'Checkbox',
|
|
357
|
+
FieldTypeDatePicker: 'Date',
|
|
316
358
|
fieldName: 'Save name',
|
|
317
359
|
fieldNamePlaceholder: 'Auto-generated, editable',
|
|
318
360
|
fieldLabel: 'Display Name',
|
|
@@ -1588,18 +1630,29 @@ const defineField = (type, definition) => {
|
|
|
1588
1630
|
});
|
|
1589
1631
|
};
|
|
1590
1632
|
const FIELD_GROUPS = [{
|
|
1591
|
-
|
|
1633
|
+
labelId: 'FieldGroupBasic',
|
|
1592
1634
|
types: ['Input', 'TextArea', 'InputNumber', 'Switch', 'Checkbox', 'DatePicker']
|
|
1593
1635
|
}, {
|
|
1594
|
-
|
|
1636
|
+
labelId: 'FieldGroupSelect',
|
|
1595
1637
|
types: ['Select', 'RadioGroup', 'CheckboxGroup']
|
|
1596
1638
|
}, {
|
|
1597
|
-
|
|
1639
|
+
labelId: 'FieldGroupAdvancedSelect',
|
|
1598
1640
|
types: ['SuperSelectList', 'SuperSelectTableList', 'SuperSelectTree', 'SuperSelectCascader']
|
|
1599
1641
|
}, {
|
|
1600
|
-
|
|
1642
|
+
labelId: 'FieldGroupBusinessSelect',
|
|
1601
1643
|
types: ['SelectFunction', 'SelectIndustry', 'SelectAddress']
|
|
1602
1644
|
}];
|
|
1645
|
+
const resolveRegistryLabel = (formatMessage, labelId, fallbackLabel) => {
|
|
1646
|
+
if (typeof formatMessage === 'function' && labelId) {
|
|
1647
|
+
return formatMessage({
|
|
1648
|
+
id: labelId
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
if (fallbackLabel != null && String(fallbackLabel).trim()) {
|
|
1652
|
+
return String(fallbackLabel).trim();
|
|
1653
|
+
}
|
|
1654
|
+
return labelId || '';
|
|
1655
|
+
};
|
|
1603
1656
|
const optionEnumValues = field => {
|
|
1604
1657
|
const options = field?.props?.options;
|
|
1605
1658
|
if (!Array.isArray(options) || !options.length) {
|
|
@@ -1660,8 +1713,7 @@ const datePickerValueSchema = field => {
|
|
|
1660
1713
|
return item;
|
|
1661
1714
|
};
|
|
1662
1715
|
defineField('Input', {
|
|
1663
|
-
|
|
1664
|
-
group: '基础字段',
|
|
1716
|
+
labelId: 'FieldTypeInput',
|
|
1665
1717
|
component: reactFormAntd.Input,
|
|
1666
1718
|
defaultProps: {
|
|
1667
1719
|
allowClear: true
|
|
@@ -1672,8 +1724,7 @@ defineField('Input', {
|
|
|
1672
1724
|
}
|
|
1673
1725
|
});
|
|
1674
1726
|
defineField('TextArea', {
|
|
1675
|
-
|
|
1676
|
-
group: '基础字段',
|
|
1727
|
+
labelId: 'FieldTypeTextArea',
|
|
1677
1728
|
component: reactFormAntd.TextArea,
|
|
1678
1729
|
defaultProps: {
|
|
1679
1730
|
rows: 3
|
|
@@ -1687,8 +1738,7 @@ defineField('TextArea', {
|
|
|
1687
1738
|
}
|
|
1688
1739
|
});
|
|
1689
1740
|
defineField('InputNumber', {
|
|
1690
|
-
|
|
1691
|
-
group: '基础字段',
|
|
1741
|
+
labelId: 'FieldTypeInputNumber',
|
|
1692
1742
|
component: reactFormAntd.InputNumber,
|
|
1693
1743
|
defaultProps: {},
|
|
1694
1744
|
hasFieldProps: true,
|
|
@@ -1697,8 +1747,7 @@ defineField('InputNumber', {
|
|
|
1697
1747
|
}
|
|
1698
1748
|
});
|
|
1699
1749
|
defineField('Select', {
|
|
1700
|
-
|
|
1701
|
-
group: '选择字段',
|
|
1750
|
+
labelId: 'FieldTypeSelect',
|
|
1702
1751
|
component: reactFormAntd.Select,
|
|
1703
1752
|
defaultProps: {
|
|
1704
1753
|
options: [],
|
|
@@ -1709,8 +1758,7 @@ defineField('Select', {
|
|
|
1709
1758
|
valueSchema: stringWithEnumSchema
|
|
1710
1759
|
});
|
|
1711
1760
|
defineField('RadioGroup', {
|
|
1712
|
-
|
|
1713
|
-
group: '选择字段',
|
|
1761
|
+
labelId: 'FieldTypeRadioGroup',
|
|
1714
1762
|
component: reactFormAntd.RadioGroup,
|
|
1715
1763
|
defaultProps: {
|
|
1716
1764
|
options: []
|
|
@@ -1719,8 +1767,7 @@ defineField('RadioGroup', {
|
|
|
1719
1767
|
valueSchema: stringWithEnumSchema
|
|
1720
1768
|
});
|
|
1721
1769
|
defineField('CheckboxGroup', {
|
|
1722
|
-
|
|
1723
|
-
group: '选择字段',
|
|
1770
|
+
labelId: 'FieldTypeCheckboxGroup',
|
|
1724
1771
|
component: reactFormAntd.CheckboxGroup,
|
|
1725
1772
|
defaultProps: {
|
|
1726
1773
|
options: []
|
|
@@ -1741,8 +1788,7 @@ defineField('CheckboxGroup', {
|
|
|
1741
1788
|
}
|
|
1742
1789
|
});
|
|
1743
1790
|
defineField('SuperSelectList', {
|
|
1744
|
-
|
|
1745
|
-
group: 'SuperSelect',
|
|
1791
|
+
labelId: 'FieldTypeSuperSelectList',
|
|
1746
1792
|
component: SuperSelectList,
|
|
1747
1793
|
defaultProps: {
|
|
1748
1794
|
options: [],
|
|
@@ -1757,8 +1803,7 @@ defineField('SuperSelectList', {
|
|
|
1757
1803
|
valueSchema: superSelectValueSchema
|
|
1758
1804
|
});
|
|
1759
1805
|
defineField('SuperSelectTableList', {
|
|
1760
|
-
|
|
1761
|
-
group: 'SuperSelect',
|
|
1806
|
+
labelId: 'FieldTypeSuperSelectTableList',
|
|
1762
1807
|
component: SuperSelectTableList,
|
|
1763
1808
|
defaultProps: {
|
|
1764
1809
|
options: [],
|
|
@@ -1775,8 +1820,7 @@ defineField('SuperSelectTableList', {
|
|
|
1775
1820
|
valueSchema: superSelectValueSchema
|
|
1776
1821
|
});
|
|
1777
1822
|
defineField('SuperSelectTree', {
|
|
1778
|
-
|
|
1779
|
-
group: 'SuperSelect',
|
|
1823
|
+
labelId: 'FieldTypeSuperSelectTree',
|
|
1780
1824
|
component: SuperSelectTree,
|
|
1781
1825
|
defaultProps: {
|
|
1782
1826
|
options: [],
|
|
@@ -1792,8 +1836,7 @@ defineField('SuperSelectTree', {
|
|
|
1792
1836
|
valueSchema: superSelectValueSchema
|
|
1793
1837
|
});
|
|
1794
1838
|
defineField('SuperSelectCascader', {
|
|
1795
|
-
|
|
1796
|
-
group: 'SuperSelect',
|
|
1839
|
+
labelId: 'FieldTypeSuperSelectCascader',
|
|
1797
1840
|
component: SuperSelectCascader,
|
|
1798
1841
|
defaultProps: {
|
|
1799
1842
|
options: [],
|
|
@@ -1811,8 +1854,7 @@ defineField('SuperSelectCascader', {
|
|
|
1811
1854
|
valueSchema: superSelectValueSchema
|
|
1812
1855
|
});
|
|
1813
1856
|
defineField('SelectFunction', {
|
|
1814
|
-
|
|
1815
|
-
group: 'SuperSelectPlus',
|
|
1857
|
+
labelId: 'FieldTypeSelectFunction',
|
|
1816
1858
|
component: SelectFunctionField,
|
|
1817
1859
|
defaultProps: {
|
|
1818
1860
|
isPopup: true,
|
|
@@ -1823,8 +1865,7 @@ defineField('SelectFunction', {
|
|
|
1823
1865
|
valueSchema: superSelectValueSchema
|
|
1824
1866
|
});
|
|
1825
1867
|
defineField('SelectIndustry', {
|
|
1826
|
-
|
|
1827
|
-
group: 'SuperSelectPlus',
|
|
1868
|
+
labelId: 'FieldTypeSelectIndustry',
|
|
1828
1869
|
component: SelectIndustryField,
|
|
1829
1870
|
defaultProps: {
|
|
1830
1871
|
isPopup: true,
|
|
@@ -1835,8 +1876,7 @@ defineField('SelectIndustry', {
|
|
|
1835
1876
|
valueSchema: superSelectValueSchema
|
|
1836
1877
|
});
|
|
1837
1878
|
defineField('SelectAddress', {
|
|
1838
|
-
|
|
1839
|
-
group: 'SuperSelectPlus',
|
|
1879
|
+
labelId: 'FieldTypeSelectAddress',
|
|
1840
1880
|
component: SelectAddressField,
|
|
1841
1881
|
defaultProps: {
|
|
1842
1882
|
isPopup: true,
|
|
@@ -1847,8 +1887,7 @@ defineField('SelectAddress', {
|
|
|
1847
1887
|
valueSchema: superSelectValueSchema
|
|
1848
1888
|
});
|
|
1849
1889
|
defineField('Switch', {
|
|
1850
|
-
|
|
1851
|
-
group: '基础字段',
|
|
1890
|
+
labelId: 'FieldTypeSwitch',
|
|
1852
1891
|
component: reactFormAntd.Switch,
|
|
1853
1892
|
defaultProps: {},
|
|
1854
1893
|
hasFieldProps: true,
|
|
@@ -1857,8 +1896,7 @@ defineField('Switch', {
|
|
|
1857
1896
|
}
|
|
1858
1897
|
});
|
|
1859
1898
|
defineField('Checkbox', {
|
|
1860
|
-
|
|
1861
|
-
group: '基础字段',
|
|
1899
|
+
labelId: 'FieldTypeCheckbox',
|
|
1862
1900
|
component: reactFormAntd.Checkbox,
|
|
1863
1901
|
defaultProps: {
|
|
1864
1902
|
children: ''
|
|
@@ -1868,8 +1906,7 @@ defineField('Checkbox', {
|
|
|
1868
1906
|
}
|
|
1869
1907
|
});
|
|
1870
1908
|
defineField('DatePicker', {
|
|
1871
|
-
|
|
1872
|
-
group: '基础字段',
|
|
1909
|
+
labelId: 'FieldTypeDatePicker',
|
|
1873
1910
|
component: reactFormAntd.DatePicker,
|
|
1874
1911
|
defaultProps: {
|
|
1875
1912
|
format: 'YYYY-MM-DD',
|
|
@@ -1893,8 +1930,9 @@ defineField('DatePicker', {
|
|
|
1893
1930
|
* - min / max?: number(type=number)
|
|
1894
1931
|
* - options?: { label, value }[](type=select)
|
|
1895
1932
|
*
|
|
1896
|
-
* preset
|
|
1897
|
-
* -
|
|
1933
|
+
* preset / registerField 的 fields 项还可传:
|
|
1934
|
+
* - label / labelId?: 展示名;有 labelId 时随 formatMessage 切换语言
|
|
1935
|
+
* - groupName / groupNameId?: 自定义类型下拉分组;有 groupNameId 时随语言切换;都不传则归入「扩展字段」
|
|
1898
1936
|
* - valueSchema?: object | (field) => object 提交值的 JSON Schema 片段;缺省回退 { type: 'string' }
|
|
1899
1937
|
* 可含 format(date/month/week/time/date-time/password/color/json)与 display(option/phone/file/typed-date-range/date-to-today/html/money),供 SchemaContent 预览
|
|
1900
1938
|
* - formatDisplayValue?: (value, field, ctx) => string 覆盖 valueSchema 默认预览
|
|
@@ -1902,10 +1940,14 @@ defineField('DatePicker', {
|
|
|
1902
1940
|
const registerField = (type, definition) => {
|
|
1903
1941
|
const propsSchema = Array.isArray(definition?.propsSchema) ? definition.propsSchema : undefined;
|
|
1904
1942
|
const groupName = definition?.groupName != null && String(definition.groupName).trim() ? String(definition.groupName).trim() : undefined;
|
|
1943
|
+
const groupNameId = definition?.groupNameId != null && String(definition.groupNameId).trim() ? String(definition.groupNameId).trim() : undefined;
|
|
1944
|
+
const labelId = definition?.labelId != null && String(definition.labelId).trim() ? String(definition.labelId).trim() : undefined;
|
|
1905
1945
|
defineField(type, {
|
|
1906
1946
|
...definition,
|
|
1907
1947
|
propsSchema,
|
|
1908
1948
|
groupName,
|
|
1949
|
+
groupNameId,
|
|
1950
|
+
labelId,
|
|
1909
1951
|
hasFieldProps: definition.hasFieldProps ?? !!(propsSchema && propsSchema.length)
|
|
1910
1952
|
});
|
|
1911
1953
|
};
|
|
@@ -1978,6 +2020,15 @@ const applyFromPropsSchema = function (props, values, propsSchema) {
|
|
|
1978
2020
|
};
|
|
1979
2021
|
const getFieldDefinition = type => registry.get(type);
|
|
1980
2022
|
|
|
2023
|
+
/** 解析字段类型展示名:内置走 labelId;扩展字段可用已翻译的 label */
|
|
2024
|
+
const resolveFieldTypeLabel = (typeOrDefinition, formatMessage) => {
|
|
2025
|
+
const definition = typeof typeOrDefinition === 'string' ? registry.get(typeOrDefinition) : typeOrDefinition;
|
|
2026
|
+
if (!definition) {
|
|
2027
|
+
return typeof typeOrDefinition === 'string' ? typeOrDefinition : '';
|
|
2028
|
+
}
|
|
2029
|
+
return resolveRegistryLabel(formatMessage, definition.labelId, definition.label) || definition.type || '';
|
|
2030
|
+
};
|
|
2031
|
+
|
|
1981
2032
|
/**
|
|
1982
2033
|
* 解析字段提交值的 JSON Schema 片段。
|
|
1983
2034
|
* 优先用 definition.valueSchema(对象或 (field)=>schema);缺省 { type: 'string' }。
|
|
@@ -2031,19 +2082,13 @@ const getFieldComponent = (type, field) => {
|
|
|
2031
2082
|
}
|
|
2032
2083
|
return definition.component;
|
|
2033
2084
|
};
|
|
2034
|
-
const getFieldTypes =
|
|
2085
|
+
const getFieldTypes = formatMessage => {
|
|
2035
2086
|
const grouped = FIELD_GROUPS.map(group => ({
|
|
2036
|
-
label: group.label,
|
|
2037
|
-
options: group.types.map(type => registry.get(type)).filter(Boolean).map(
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
} = _ref;
|
|
2042
|
-
return {
|
|
2043
|
-
label,
|
|
2044
|
-
value: type
|
|
2045
|
-
};
|
|
2046
|
-
})
|
|
2087
|
+
label: resolveRegistryLabel(formatMessage, group.labelId, group.label),
|
|
2088
|
+
options: group.types.map(type => registry.get(type)).filter(Boolean).map(item => ({
|
|
2089
|
+
label: resolveFieldTypeLabel(item, formatMessage),
|
|
2090
|
+
value: item.type
|
|
2091
|
+
}))
|
|
2047
2092
|
}));
|
|
2048
2093
|
const builtinTypes = new Set(FIELD_GROUPS.flatMap(group => group.types));
|
|
2049
2094
|
const registered = Array.from(registry.values()).filter(item => !builtinTypes.has(item.type));
|
|
@@ -2051,20 +2096,29 @@ const getFieldTypes = () => {
|
|
|
2051
2096
|
const fallback = [];
|
|
2052
2097
|
registered.forEach(item => {
|
|
2053
2098
|
const option = {
|
|
2054
|
-
label: item
|
|
2099
|
+
label: resolveFieldTypeLabel(item, formatMessage),
|
|
2055
2100
|
value: item.type
|
|
2056
2101
|
};
|
|
2102
|
+
const groupNameId = item.groupNameId != null && String(item.groupNameId).trim() ? String(item.groupNameId).trim() : '';
|
|
2057
2103
|
const groupName = item.groupName != null && String(item.groupName).trim() ? String(item.groupName).trim() : '';
|
|
2058
|
-
if (!groupName) {
|
|
2104
|
+
if (!groupNameId && !groupName) {
|
|
2059
2105
|
fallback.push(option);
|
|
2060
2106
|
return;
|
|
2061
2107
|
}
|
|
2062
|
-
|
|
2063
|
-
|
|
2108
|
+
const groupKey = groupNameId || groupName;
|
|
2109
|
+
if (!customGroups.has(groupKey)) {
|
|
2110
|
+
customGroups.set(groupKey, {
|
|
2111
|
+
label: resolveRegistryLabel(formatMessage, groupNameId || null, groupName),
|
|
2112
|
+
options: []
|
|
2113
|
+
});
|
|
2064
2114
|
}
|
|
2065
|
-
customGroups.get(
|
|
2115
|
+
customGroups.get(groupKey).options.push(option);
|
|
2066
2116
|
});
|
|
2067
|
-
customGroups.forEach(
|
|
2117
|
+
customGroups.forEach(_ref => {
|
|
2118
|
+
let {
|
|
2119
|
+
label,
|
|
2120
|
+
options
|
|
2121
|
+
} = _ref;
|
|
2068
2122
|
grouped.push({
|
|
2069
2123
|
label,
|
|
2070
2124
|
options
|
|
@@ -2072,7 +2126,7 @@ const getFieldTypes = () => {
|
|
|
2072
2126
|
});
|
|
2073
2127
|
if (fallback.length) {
|
|
2074
2128
|
grouped.push({
|
|
2075
|
-
label: '扩展字段',
|
|
2129
|
+
label: resolveRegistryLabel(formatMessage, 'FieldGroupExtended', '扩展字段'),
|
|
2076
2130
|
options: fallback
|
|
2077
2131
|
});
|
|
2078
2132
|
}
|
|
@@ -2448,7 +2502,7 @@ const FieldRow = ({
|
|
|
2448
2502
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
|
|
2449
2503
|
bordered: false,
|
|
2450
2504
|
color: TYPE_TAG_COLORS[field.type] || 'default',
|
|
2451
|
-
children: definition
|
|
2505
|
+
children: resolveFieldTypeLabel(definition || field.type, formatMessage)
|
|
2452
2506
|
}), field.hidden ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
|
|
2453
2507
|
bordered: false,
|
|
2454
2508
|
children: formatMessage({
|
|
@@ -3053,7 +3107,7 @@ const BlockListPanel = _ref3 => {
|
|
|
3053
3107
|
}) : block.kind === 'multiField' ? formatMessage({
|
|
3054
3108
|
id: 'multiFieldSummary'
|
|
3055
3109
|
}, {
|
|
3056
|
-
type: block.fieldType
|
|
3110
|
+
type: resolveFieldTypeLabel(block.fieldType, formatMessage)
|
|
3057
3111
|
}) : block.kind === 'choice' ? formatMessage({
|
|
3058
3112
|
id: 'choiceOptionCount'
|
|
3059
3113
|
}, {
|
|
@@ -3077,7 +3131,9 @@ const BlockListPanel = _ref3 => {
|
|
|
3077
3131
|
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
|
|
3078
3132
|
bordered: false,
|
|
3079
3133
|
color: definition?.color || 'default',
|
|
3080
|
-
children:
|
|
3134
|
+
children: formatMessage({
|
|
3135
|
+
id: `blockKind_${block.kind}`
|
|
3136
|
+
})
|
|
3081
3137
|
}), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
|
|
3082
3138
|
strong: true,
|
|
3083
3139
|
ellipsis: true,
|
|
@@ -3196,7 +3252,7 @@ const BlockConfigFields = _ref => {
|
|
|
3196
3252
|
formatMessage
|
|
3197
3253
|
} = reactIntl.useIntl();
|
|
3198
3254
|
const definition = getBlockDefinition(kind);
|
|
3199
|
-
const fieldTypeOptions = react.useMemo(() => getFieldTypes(), []);
|
|
3255
|
+
const fieldTypeOptions = react.useMemo(() => getFieldTypes(formatMessage), [formatMessage]);
|
|
3200
3256
|
const list = [];
|
|
3201
3257
|
if (kind === 'formInfo' || kind === 'list' || kind === 'tableList' || kind === 'object') {
|
|
3202
3258
|
list.push(/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
|
|
@@ -3409,7 +3465,9 @@ const BlockConfigFields = _ref => {
|
|
|
3409
3465
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3410
3466
|
className: style['field-editor-form'],
|
|
3411
3467
|
children: /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
|
|
3412
|
-
title:
|
|
3468
|
+
title: formatMessage({
|
|
3469
|
+
id: `blockKind_${kind}`
|
|
3470
|
+
}),
|
|
3413
3471
|
subtitle: definition?.description,
|
|
3414
3472
|
column: 1,
|
|
3415
3473
|
list: list.filter(Boolean)
|
|
@@ -4603,7 +4661,7 @@ const FieldConfigFields = _ref => {
|
|
|
4603
4661
|
openApi
|
|
4604
4662
|
} = reactFormAntd.useFormContext();
|
|
4605
4663
|
const [fieldType, setFieldType] = react.useState(initialType);
|
|
4606
|
-
const fieldTypeOptions = react.useMemo(() => getFieldTypes(), []);
|
|
4664
|
+
const fieldTypeOptions = react.useMemo(() => getFieldTypes(formatMessage), [formatMessage]);
|
|
4607
4665
|
const definition = getFieldDefinition(fieldType);
|
|
4608
4666
|
react.useEffect(() => {
|
|
4609
4667
|
setFieldType(initialType);
|
|
@@ -5312,7 +5370,8 @@ const renderFieldElements = function (fields, preview, _temp) {
|
|
|
5312
5370
|
fields = [];
|
|
5313
5371
|
}
|
|
5314
5372
|
let {
|
|
5315
|
-
namePrefix
|
|
5373
|
+
namePrefix,
|
|
5374
|
+
locale
|
|
5316
5375
|
} = _temp === void 0 ? {} : _temp;
|
|
5317
5376
|
return fields.filter(field => !field.hidden).map(field => {
|
|
5318
5377
|
const Component = getFieldComponent(field.type, field);
|
|
@@ -5333,6 +5392,10 @@ const renderFieldElements = function (fields, preview, _temp) {
|
|
|
5333
5392
|
delete props.range;
|
|
5334
5393
|
const description = field.description != null && String(field.description).trim() ? field.description : undefined;
|
|
5335
5394
|
const fieldName = namePrefix && field.name ? `${namePrefix}.${field.name}` : field.name;
|
|
5395
|
+
// 显式传 locale,避免 Global 仍为 zh-CN 时 react-form-antd withLocale 盖掉父级英文
|
|
5396
|
+
const localeProps = locale ? {
|
|
5397
|
+
locale
|
|
5398
|
+
} : {};
|
|
5336
5399
|
return /*#__PURE__*/react.createElement(Component, {
|
|
5337
5400
|
key: field.id,
|
|
5338
5401
|
name: fieldName,
|
|
@@ -5340,6 +5403,7 @@ const renderFieldElements = function (fields, preview, _temp) {
|
|
|
5340
5403
|
rule: field.rule || undefined,
|
|
5341
5404
|
block: field.block || undefined,
|
|
5342
5405
|
...props,
|
|
5406
|
+
...localeProps,
|
|
5343
5407
|
labelTips: buildLabelTips(field.tips),
|
|
5344
5408
|
description
|
|
5345
5409
|
});
|
|
@@ -5382,7 +5446,8 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5382
5446
|
isMobile = false,
|
|
5383
5447
|
formatMessage,
|
|
5384
5448
|
depth = 0,
|
|
5385
|
-
asListItem = false
|
|
5449
|
+
asListItem = false,
|
|
5450
|
+
locale
|
|
5386
5451
|
} = ctx;
|
|
5387
5452
|
if (!block || depth > MAX_BLOCK_DEPTH) {
|
|
5388
5453
|
return null;
|
|
@@ -5392,6 +5457,9 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5392
5457
|
depth: depth + 1,
|
|
5393
5458
|
asListItem: false
|
|
5394
5459
|
};
|
|
5460
|
+
const fieldRenderOpts = {
|
|
5461
|
+
locale
|
|
5462
|
+
};
|
|
5395
5463
|
const bordered = isMobile ? false : block.bordered || undefined;
|
|
5396
5464
|
// 仅 FormInfo/object 吃列表项 Part 样式;List 等交给 form-info nestDepth
|
|
5397
5465
|
const listItemPartProps = asListItem && isFormInfoLikeBlock(block.kind) ? nestedListItemPartProps : null;
|
|
@@ -5421,7 +5489,7 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5421
5489
|
switch (block.kind) {
|
|
5422
5490
|
case 'formInfo':
|
|
5423
5491
|
{
|
|
5424
|
-
const fields = renderFieldElements(block.list);
|
|
5492
|
+
const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
|
|
5425
5493
|
const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
|
|
5426
5494
|
return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo__default["default"], {
|
|
5427
5495
|
key: block.id,
|
|
@@ -5438,6 +5506,7 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5438
5506
|
case 'object':
|
|
5439
5507
|
{
|
|
5440
5508
|
const fields = renderFieldElements(block.list, preview, {
|
|
5509
|
+
...fieldRenderOpts,
|
|
5441
5510
|
namePrefix: block.name || ''
|
|
5442
5511
|
});
|
|
5443
5512
|
const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
|
|
@@ -5455,7 +5524,7 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5455
5524
|
}
|
|
5456
5525
|
case 'list':
|
|
5457
5526
|
{
|
|
5458
|
-
const fields = renderFieldElements(block.list);
|
|
5527
|
+
const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
|
|
5459
5528
|
const nested = renderItemBlocks(block.itemBlocks || []);
|
|
5460
5529
|
return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo.List, {
|
|
5461
5530
|
key: block.id,
|
|
@@ -5477,7 +5546,7 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5477
5546
|
}
|
|
5478
5547
|
case 'tableList':
|
|
5479
5548
|
{
|
|
5480
|
-
const fields = renderFieldElements(block.list);
|
|
5549
|
+
const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
|
|
5481
5550
|
return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo.TableList, {
|
|
5482
5551
|
key: block.id,
|
|
5483
5552
|
name: block.name,
|
|
@@ -5521,7 +5590,7 @@ const renderBlockElement = function (block, preview, ctx) {
|
|
|
5521
5590
|
prevIcon: /*#__PURE__*/react.createElement(icons.ArrowLeftOutlined),
|
|
5522
5591
|
nextIcon: /*#__PURE__*/react.createElement(icons.ArrowRightOutlined),
|
|
5523
5592
|
items: (block.items || []).map(step => {
|
|
5524
|
-
const fields = renderFieldElements(step.list);
|
|
5593
|
+
const fields = renderFieldElements(step.list, preview, fieldRenderOpts);
|
|
5525
5594
|
const nested = renderChildBlocks(step.blocks || [], nextCtx);
|
|
5526
5595
|
const fieldNames = [...(step.list || []).filter(field => field && !field.hidden && field.name).map(field => field.name), ...collectBlockFieldNames(step.blocks || [])];
|
|
5527
5596
|
if (nested.length) {
|
|
@@ -5585,6 +5654,7 @@ const renderSchemaInner = function (schema, _temp2) {
|
|
|
5585
5654
|
bodyClassName,
|
|
5586
5655
|
isMobile = false,
|
|
5587
5656
|
formatMessage,
|
|
5657
|
+
locale,
|
|
5588
5658
|
children,
|
|
5589
5659
|
actionNode
|
|
5590
5660
|
} = _temp2 === void 0 ? {} : _temp2;
|
|
@@ -5592,7 +5662,8 @@ const renderSchemaInner = function (schema, _temp2) {
|
|
|
5592
5662
|
const blocks = normalized.blocks || [];
|
|
5593
5663
|
const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
|
|
5594
5664
|
isMobile,
|
|
5595
|
-
formatMessage
|
|
5665
|
+
formatMessage,
|
|
5666
|
+
locale
|
|
5596
5667
|
})).filter(Boolean);
|
|
5597
5668
|
if (!contentChildren.length && !children && !actionNode) {
|
|
5598
5669
|
return null;
|
|
@@ -5613,6 +5684,7 @@ const renderSchemaContent = function (schema, _temp3) {
|
|
|
5613
5684
|
bodyClassName,
|
|
5614
5685
|
isMobile = false,
|
|
5615
5686
|
formatMessage,
|
|
5687
|
+
locale,
|
|
5616
5688
|
children,
|
|
5617
5689
|
actionNode
|
|
5618
5690
|
} = _temp3 === void 0 ? {} : _temp3;
|
|
@@ -5620,7 +5692,8 @@ const renderSchemaContent = function (schema, _temp3) {
|
|
|
5620
5692
|
const blocks = normalized.blocks || [];
|
|
5621
5693
|
const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
|
|
5622
5694
|
isMobile,
|
|
5623
|
-
formatMessage
|
|
5695
|
+
formatMessage,
|
|
5696
|
+
locale
|
|
5624
5697
|
})).filter(Boolean);
|
|
5625
5698
|
if (!contentChildren.length && !children) {
|
|
5626
5699
|
return null;
|
|
@@ -5743,7 +5816,8 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5743
5816
|
buttonFooterProps
|
|
5744
5817
|
} = props;
|
|
5745
5818
|
const {
|
|
5746
|
-
formatMessage
|
|
5819
|
+
formatMessage,
|
|
5820
|
+
locale
|
|
5747
5821
|
} = reactIntl.useIntl();
|
|
5748
5822
|
const isMobile = responsiveUtils.useIsMobile();
|
|
5749
5823
|
const normalized = normalizeSchema(schema);
|
|
@@ -5776,6 +5850,7 @@ const SchemaRendererInner = withLocale$1(props => {
|
|
|
5776
5850
|
bodyClassName,
|
|
5777
5851
|
isMobile,
|
|
5778
5852
|
formatMessage,
|
|
5853
|
+
locale,
|
|
5779
5854
|
children,
|
|
5780
5855
|
actionNode
|
|
5781
5856
|
});
|
|
@@ -5806,7 +5881,8 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5806
5881
|
buttonFooterProps
|
|
5807
5882
|
} = props;
|
|
5808
5883
|
const {
|
|
5809
|
-
formatMessage
|
|
5884
|
+
formatMessage,
|
|
5885
|
+
locale
|
|
5810
5886
|
} = reactIntl.useIntl();
|
|
5811
5887
|
const isMobile = responsiveUtils.useIsMobile();
|
|
5812
5888
|
const normalized = normalizeSchema(schema);
|
|
@@ -5840,6 +5916,7 @@ const SchemaRenderer = withLocale$1(props => {
|
|
|
5840
5916
|
bodyClassName,
|
|
5841
5917
|
isMobile,
|
|
5842
5918
|
formatMessage,
|
|
5919
|
+
locale,
|
|
5843
5920
|
children,
|
|
5844
5921
|
actionNode
|
|
5845
5922
|
});
|
|
@@ -5858,7 +5935,8 @@ const FormCreator = withLocale$1(_ref => {
|
|
|
5858
5935
|
extraToolbar
|
|
5859
5936
|
} = _ref;
|
|
5860
5937
|
const {
|
|
5861
|
-
formatMessage
|
|
5938
|
+
formatMessage,
|
|
5939
|
+
locale
|
|
5862
5940
|
} = reactIntl.useIntl();
|
|
5863
5941
|
const isMobile = responsiveUtils.useIsMobile();
|
|
5864
5942
|
const [innerSchema, setInnerSchema] = react.useState(() => normalizeSchema(defaultValue || defaultSchema()));
|
|
@@ -6207,7 +6285,8 @@ const FormCreator = withLocale$1(_ref => {
|
|
|
6207
6285
|
children: hasRenderableContent(schema) ? /*#__PURE__*/jsxRuntime.jsx(SchemaRenderer$1, {
|
|
6208
6286
|
schema: schema,
|
|
6209
6287
|
preview: true,
|
|
6210
|
-
formProps: formProps
|
|
6288
|
+
formProps: formProps,
|
|
6289
|
+
locale: locale
|
|
6211
6290
|
}) : /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
|
|
6212
6291
|
image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
|
|
6213
6292
|
description: formatMessage({
|
|
@@ -7400,7 +7479,9 @@ exports.parseRuleString = parseRuleString;
|
|
|
7400
7479
|
exports.pickFieldProps = pickFieldProps;
|
|
7401
7480
|
exports.pickFromPropsSchema = pickFromPropsSchema;
|
|
7402
7481
|
exports.preset = preset;
|
|
7482
|
+
exports.registerField = registerField;
|
|
7403
7483
|
exports.removeBlockInTree = removeBlockInTree;
|
|
7484
|
+
exports.resolveFieldTypeLabel = resolveFieldTypeLabel;
|
|
7404
7485
|
exports.resolveFieldValueSchema = resolveFieldValueSchema;
|
|
7405
7486
|
exports.schemaToDataSchema = schemaToDataSchema;
|
|
7406
7487
|
exports.updateBlocks = updateBlocks;
|