@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/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',
@@ -1367,14 +1409,10 @@ const mapOptionItem = item => {
1367
1409
  * 搭建器选项是 { label, value, children };SelectCascader 默认 valueKey='id'、示例用 id/name。
1368
1410
  * 补齐两边的 key,避免 mapping 全部落到 undefined 导致下拉空白。
1369
1411
  */
1370
- const alignOptionKeys = function (options, _temp) {
1371
- if (options === void 0) {
1372
- options = [];
1373
- }
1374
- let {
1375
- valueKey = 'value',
1376
- labelKey = 'label'
1377
- } = _temp === void 0 ? {} : _temp;
1412
+ const alignOptionKeys = (options = [], {
1413
+ valueKey = 'value',
1414
+ labelKey = 'label'
1415
+ } = {}) => {
1378
1416
  if (!Array.isArray(options)) {
1379
1417
  return options;
1380
1418
  }
@@ -1413,16 +1451,12 @@ const alignOptionKeys = function (options, _temp) {
1413
1451
  * SelectTree 按扁平 parentId 组树,会覆盖节点上已有的 children。
1414
1452
  * 搭建器存的是嵌套 children,交给 SelectTree 前先拍平。
1415
1453
  */
1416
- const flattenTreeOptions = function (options, _temp2) {
1417
- if (options === void 0) {
1418
- options = [];
1419
- }
1420
- let {
1421
- valueKey = 'value',
1422
- parentKey = 'parentId',
1423
- childrenKey = 'children',
1424
- parentId
1425
- } = _temp2 === void 0 ? {} : _temp2;
1454
+ const flattenTreeOptions = (options = [], {
1455
+ valueKey = 'value',
1456
+ parentKey = 'parentId',
1457
+ childrenKey = 'children',
1458
+ parentId
1459
+ } = {}) => {
1426
1460
  const result = [];
1427
1461
  (Array.isArray(options) ? options : []).forEach(item => {
1428
1462
  if (!item || typeof item !== 'object') {
@@ -1448,16 +1482,11 @@ const flattenTreeOptions = function (options, _temp2) {
1448
1482
  });
1449
1483
  return result;
1450
1484
  };
1451
- const createApiFromOptions = function (options) {
1452
- if (options === void 0) {
1453
- options = [];
1454
- }
1455
- return {
1456
- loader: () => ({
1457
- pageData: options.map(mapOptionItem)
1458
- })
1459
- };
1460
- };
1485
+ const createApiFromOptions = (options = []) => ({
1486
+ loader: () => ({
1487
+ pageData: options.map(mapOptionItem)
1488
+ })
1489
+ });
1461
1490
 
1462
1491
  const {
1463
1492
  useOnChange: useOnChange$1
@@ -1601,18 +1630,29 @@ const defineField = (type, definition) => {
1601
1630
  });
1602
1631
  };
1603
1632
  const FIELD_GROUPS = [{
1604
- label: '基础字段',
1633
+ labelId: 'FieldGroupBasic',
1605
1634
  types: ['Input', 'TextArea', 'InputNumber', 'Switch', 'Checkbox', 'DatePicker']
1606
1635
  }, {
1607
- label: '选择字段',
1636
+ labelId: 'FieldGroupSelect',
1608
1637
  types: ['Select', 'RadioGroup', 'CheckboxGroup']
1609
1638
  }, {
1610
- label: '高级选择',
1639
+ labelId: 'FieldGroupAdvancedSelect',
1611
1640
  types: ['SuperSelectList', 'SuperSelectTableList', 'SuperSelectTree', 'SuperSelectCascader']
1612
1641
  }, {
1613
- label: '业务选择',
1642
+ labelId: 'FieldGroupBusinessSelect',
1614
1643
  types: ['SelectFunction', 'SelectIndustry', 'SelectAddress']
1615
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
+ };
1616
1656
  const optionEnumValues = field => {
1617
1657
  const options = field?.props?.options;
1618
1658
  if (!Array.isArray(options) || !options.length) {
@@ -1673,8 +1713,7 @@ const datePickerValueSchema = field => {
1673
1713
  return item;
1674
1714
  };
1675
1715
  defineField('Input', {
1676
- label: '单行文本',
1677
- group: '基础字段',
1716
+ labelId: 'FieldTypeInput',
1678
1717
  component: reactFormAntd.Input,
1679
1718
  defaultProps: {
1680
1719
  allowClear: true
@@ -1685,8 +1724,7 @@ defineField('Input', {
1685
1724
  }
1686
1725
  });
1687
1726
  defineField('TextArea', {
1688
- label: '多行文本',
1689
- group: '基础字段',
1727
+ labelId: 'FieldTypeTextArea',
1690
1728
  component: reactFormAntd.TextArea,
1691
1729
  defaultProps: {
1692
1730
  rows: 3
@@ -1700,8 +1738,7 @@ defineField('TextArea', {
1700
1738
  }
1701
1739
  });
1702
1740
  defineField('InputNumber', {
1703
- label: '数字',
1704
- group: '基础字段',
1741
+ labelId: 'FieldTypeInputNumber',
1705
1742
  component: reactFormAntd.InputNumber,
1706
1743
  defaultProps: {},
1707
1744
  hasFieldProps: true,
@@ -1710,8 +1747,7 @@ defineField('InputNumber', {
1710
1747
  }
1711
1748
  });
1712
1749
  defineField('Select', {
1713
- label: '下拉选择',
1714
- group: '选择字段',
1750
+ labelId: 'FieldTypeSelect',
1715
1751
  component: reactFormAntd.Select,
1716
1752
  defaultProps: {
1717
1753
  options: [],
@@ -1722,8 +1758,7 @@ defineField('Select', {
1722
1758
  valueSchema: stringWithEnumSchema
1723
1759
  });
1724
1760
  defineField('RadioGroup', {
1725
- label: '单选组',
1726
- group: '选择字段',
1761
+ labelId: 'FieldTypeRadioGroup',
1727
1762
  component: reactFormAntd.RadioGroup,
1728
1763
  defaultProps: {
1729
1764
  options: []
@@ -1732,8 +1767,7 @@ defineField('RadioGroup', {
1732
1767
  valueSchema: stringWithEnumSchema
1733
1768
  });
1734
1769
  defineField('CheckboxGroup', {
1735
- label: '复选组',
1736
- group: '选择字段',
1770
+ labelId: 'FieldTypeCheckboxGroup',
1737
1771
  component: reactFormAntd.CheckboxGroup,
1738
1772
  defaultProps: {
1739
1773
  options: []
@@ -1754,8 +1788,7 @@ defineField('CheckboxGroup', {
1754
1788
  }
1755
1789
  });
1756
1790
  defineField('SuperSelectList', {
1757
- label: '普通下拉',
1758
- group: 'SuperSelect',
1791
+ labelId: 'FieldTypeSuperSelectList',
1759
1792
  component: SuperSelectList,
1760
1793
  defaultProps: {
1761
1794
  options: [],
@@ -1770,8 +1803,7 @@ defineField('SuperSelectList', {
1770
1803
  valueSchema: superSelectValueSchema
1771
1804
  });
1772
1805
  defineField('SuperSelectTableList', {
1773
- label: '表格选择',
1774
- group: 'SuperSelect',
1806
+ labelId: 'FieldTypeSuperSelectTableList',
1775
1807
  component: SuperSelectTableList,
1776
1808
  defaultProps: {
1777
1809
  options: [],
@@ -1788,8 +1820,7 @@ defineField('SuperSelectTableList', {
1788
1820
  valueSchema: superSelectValueSchema
1789
1821
  });
1790
1822
  defineField('SuperSelectTree', {
1791
- label: '树形选择',
1792
- group: 'SuperSelect',
1823
+ labelId: 'FieldTypeSuperSelectTree',
1793
1824
  component: SuperSelectTree,
1794
1825
  defaultProps: {
1795
1826
  options: [],
@@ -1805,8 +1836,7 @@ defineField('SuperSelectTree', {
1805
1836
  valueSchema: superSelectValueSchema
1806
1837
  });
1807
1838
  defineField('SuperSelectCascader', {
1808
- label: '级联选择',
1809
- group: 'SuperSelect',
1839
+ labelId: 'FieldTypeSuperSelectCascader',
1810
1840
  component: SuperSelectCascader,
1811
1841
  defaultProps: {
1812
1842
  options: [],
@@ -1824,8 +1854,7 @@ defineField('SuperSelectCascader', {
1824
1854
  valueSchema: superSelectValueSchema
1825
1855
  });
1826
1856
  defineField('SelectFunction', {
1827
- label: '职能选择',
1828
- group: 'SuperSelectPlus',
1857
+ labelId: 'FieldTypeSelectFunction',
1829
1858
  component: SelectFunctionField,
1830
1859
  defaultProps: {
1831
1860
  isPopup: true,
@@ -1836,8 +1865,7 @@ defineField('SelectFunction', {
1836
1865
  valueSchema: superSelectValueSchema
1837
1866
  });
1838
1867
  defineField('SelectIndustry', {
1839
- label: '行业选择',
1840
- group: 'SuperSelectPlus',
1868
+ labelId: 'FieldTypeSelectIndustry',
1841
1869
  component: SelectIndustryField,
1842
1870
  defaultProps: {
1843
1871
  isPopup: true,
@@ -1848,8 +1876,7 @@ defineField('SelectIndustry', {
1848
1876
  valueSchema: superSelectValueSchema
1849
1877
  });
1850
1878
  defineField('SelectAddress', {
1851
- label: '地址选择',
1852
- group: 'SuperSelectPlus',
1879
+ labelId: 'FieldTypeSelectAddress',
1853
1880
  component: SelectAddressField,
1854
1881
  defaultProps: {
1855
1882
  isPopup: true,
@@ -1860,8 +1887,7 @@ defineField('SelectAddress', {
1860
1887
  valueSchema: superSelectValueSchema
1861
1888
  });
1862
1889
  defineField('Switch', {
1863
- label: '开关',
1864
- group: '基础字段',
1890
+ labelId: 'FieldTypeSwitch',
1865
1891
  component: reactFormAntd.Switch,
1866
1892
  defaultProps: {},
1867
1893
  hasFieldProps: true,
@@ -1870,8 +1896,7 @@ defineField('Switch', {
1870
1896
  }
1871
1897
  });
1872
1898
  defineField('Checkbox', {
1873
- label: '复选框',
1874
- group: '基础字段',
1899
+ labelId: 'FieldTypeCheckbox',
1875
1900
  component: reactFormAntd.Checkbox,
1876
1901
  defaultProps: {
1877
1902
  children: ''
@@ -1881,8 +1906,7 @@ defineField('Checkbox', {
1881
1906
  }
1882
1907
  });
1883
1908
  defineField('DatePicker', {
1884
- label: '日期',
1885
- group: '基础字段',
1909
+ labelId: 'FieldTypeDatePicker',
1886
1910
  component: reactFormAntd.DatePicker,
1887
1911
  defaultProps: {
1888
1912
  format: 'YYYY-MM-DD',
@@ -1906,8 +1930,9 @@ defineField('DatePicker', {
1906
1930
  * - min / max?: number(type=number)
1907
1931
  * - options?: { label, value }[](type=select)
1908
1932
  *
1909
- * preset({ type, definition }) 的 fields 项还可传:
1910
- * - groupName?: string 自定义类型下拉分组名;不传则归入「扩展字段」
1933
+ * preset / registerField 的 fields 项还可传:
1934
+ * - label / labelId?: 展示名;有 labelId 时随 formatMessage 切换语言
1935
+ * - groupName / groupNameId?: 自定义类型下拉分组;有 groupNameId 时随语言切换;都不传则归入「扩展字段」
1911
1936
  * - valueSchema?: object | (field) => object 提交值的 JSON Schema 片段;缺省回退 { type: 'string' }
1912
1937
  * 可含 format(date/month/week/time/date-time/password/color/json)与 display(option/phone/file/typed-date-range/date-to-today/html/money),供 SchemaContent 预览
1913
1938
  * - formatDisplayValue?: (value, field, ctx) => string 覆盖 valueSchema 默认预览
@@ -1915,10 +1940,14 @@ defineField('DatePicker', {
1915
1940
  const registerField = (type, definition) => {
1916
1941
  const propsSchema = Array.isArray(definition?.propsSchema) ? definition.propsSchema : undefined;
1917
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;
1918
1945
  defineField(type, {
1919
1946
  ...definition,
1920
1947
  propsSchema,
1921
1948
  groupName,
1949
+ groupNameId,
1950
+ labelId,
1922
1951
  hasFieldProps: definition.hasFieldProps ?? !!(propsSchema && propsSchema.length)
1923
1952
  });
1924
1953
  };
@@ -1991,6 +2020,15 @@ const applyFromPropsSchema = function (props, values, propsSchema) {
1991
2020
  };
1992
2021
  const getFieldDefinition = type => registry.get(type);
1993
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
+
1994
2032
  /**
1995
2033
  * 解析字段提交值的 JSON Schema 片段。
1996
2034
  * 优先用 definition.valueSchema(对象或 (field)=>schema);缺省 { type: 'string' }。
@@ -2044,19 +2082,13 @@ const getFieldComponent = (type, field) => {
2044
2082
  }
2045
2083
  return definition.component;
2046
2084
  };
2047
- const getFieldTypes = () => {
2085
+ const getFieldTypes = formatMessage => {
2048
2086
  const grouped = FIELD_GROUPS.map(group => ({
2049
- label: group.label,
2050
- options: group.types.map(type => registry.get(type)).filter(Boolean).map(_ref => {
2051
- let {
2052
- type,
2053
- label
2054
- } = _ref;
2055
- return {
2056
- label,
2057
- value: type
2058
- };
2059
- })
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
+ }))
2060
2092
  }));
2061
2093
  const builtinTypes = new Set(FIELD_GROUPS.flatMap(group => group.types));
2062
2094
  const registered = Array.from(registry.values()).filter(item => !builtinTypes.has(item.type));
@@ -2064,20 +2096,29 @@ const getFieldTypes = () => {
2064
2096
  const fallback = [];
2065
2097
  registered.forEach(item => {
2066
2098
  const option = {
2067
- label: item.label,
2099
+ label: resolveFieldTypeLabel(item, formatMessage),
2068
2100
  value: item.type
2069
2101
  };
2102
+ const groupNameId = item.groupNameId != null && String(item.groupNameId).trim() ? String(item.groupNameId).trim() : '';
2070
2103
  const groupName = item.groupName != null && String(item.groupName).trim() ? String(item.groupName).trim() : '';
2071
- if (!groupName) {
2104
+ if (!groupNameId && !groupName) {
2072
2105
  fallback.push(option);
2073
2106
  return;
2074
2107
  }
2075
- if (!customGroups.has(groupName)) {
2076
- customGroups.set(groupName, []);
2108
+ const groupKey = groupNameId || groupName;
2109
+ if (!customGroups.has(groupKey)) {
2110
+ customGroups.set(groupKey, {
2111
+ label: resolveRegistryLabel(formatMessage, groupNameId || null, groupName),
2112
+ options: []
2113
+ });
2077
2114
  }
2078
- customGroups.get(groupName).push(option);
2115
+ customGroups.get(groupKey).options.push(option);
2079
2116
  });
2080
- customGroups.forEach((options, label) => {
2117
+ customGroups.forEach(_ref => {
2118
+ let {
2119
+ label,
2120
+ options
2121
+ } = _ref;
2081
2122
  grouped.push({
2082
2123
  label,
2083
2124
  options
@@ -2085,7 +2126,7 @@ const getFieldTypes = () => {
2085
2126
  });
2086
2127
  if (fallback.length) {
2087
2128
  grouped.push({
2088
- label: '扩展字段',
2129
+ label: resolveRegistryLabel(formatMessage, 'FieldGroupExtended', '扩展字段'),
2089
2130
  options: fallback
2090
2131
  });
2091
2132
  }
@@ -2430,15 +2471,14 @@ const TYPE_TAG_COLORS = {
2430
2471
  Checkbox: 'green',
2431
2472
  DatePicker: 'lime'
2432
2473
  };
2433
- const FieldRow = _ref => {
2434
- let {
2435
- field,
2436
- index,
2437
- total,
2438
- onEdit,
2439
- onDelete,
2440
- onMove
2441
- } = _ref;
2474
+ const FieldRow = ({
2475
+ field,
2476
+ index,
2477
+ total,
2478
+ onEdit,
2479
+ onDelete,
2480
+ onMove
2481
+ }) => {
2442
2482
  const {
2443
2483
  formatMessage
2444
2484
  } = reactIntl.useIntl();
@@ -2462,7 +2502,7 @@ const FieldRow = _ref => {
2462
2502
  }), /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
2463
2503
  bordered: false,
2464
2504
  color: TYPE_TAG_COLORS[field.type] || 'default',
2465
- children: definition?.label || field.type
2505
+ children: resolveFieldTypeLabel(definition || field.type, formatMessage)
2466
2506
  }), field.hidden ? /*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
2467
2507
  bordered: false,
2468
2508
  children: formatMessage({
@@ -3067,7 +3107,7 @@ const BlockListPanel = _ref3 => {
3067
3107
  }) : block.kind === 'multiField' ? formatMessage({
3068
3108
  id: 'multiFieldSummary'
3069
3109
  }, {
3070
- type: block.fieldType
3110
+ type: resolveFieldTypeLabel(block.fieldType, formatMessage)
3071
3111
  }) : block.kind === 'choice' ? formatMessage({
3072
3112
  id: 'choiceOptionCount'
3073
3113
  }, {
@@ -3091,7 +3131,9 @@ const BlockListPanel = _ref3 => {
3091
3131
  children: [/*#__PURE__*/jsxRuntime.jsx(antd.Tag, {
3092
3132
  bordered: false,
3093
3133
  color: definition?.color || 'default',
3094
- children: definition?.label || block.kind
3134
+ children: formatMessage({
3135
+ id: `blockKind_${block.kind}`
3136
+ })
3095
3137
  }), /*#__PURE__*/jsxRuntime.jsx(Text$3, {
3096
3138
  strong: true,
3097
3139
  ellipsis: true,
@@ -3210,7 +3252,7 @@ const BlockConfigFields = _ref => {
3210
3252
  formatMessage
3211
3253
  } = reactIntl.useIntl();
3212
3254
  const definition = getBlockDefinition(kind);
3213
- const fieldTypeOptions = react.useMemo(() => getFieldTypes(), []);
3255
+ const fieldTypeOptions = react.useMemo(() => getFieldTypes(formatMessage), [formatMessage]);
3214
3256
  const list = [];
3215
3257
  if (kind === 'formInfo' || kind === 'list' || kind === 'tableList' || kind === 'object') {
3216
3258
  list.push(/*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
@@ -3423,7 +3465,9 @@ const BlockConfigFields = _ref => {
3423
3465
  return /*#__PURE__*/jsxRuntime.jsx("div", {
3424
3466
  className: style['field-editor-form'],
3425
3467
  children: /*#__PURE__*/jsxRuntime.jsx(FormInfo__default["default"], {
3426
- title: definition?.label || kind,
3468
+ title: formatMessage({
3469
+ id: `blockKind_${kind}`
3470
+ }),
3427
3471
  subtitle: definition?.description,
3428
3472
  column: 1,
3429
3473
  list: list.filter(Boolean)
@@ -3636,24 +3680,18 @@ const RulePresetEditor = () => {
3636
3680
  id: 'ruleLenMin'
3637
3681
  }),
3638
3682
  min: 0,
3639
- display: _ref => {
3640
- let {
3641
- openApi
3642
- } = _ref;
3643
- return (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET);
3644
- }
3683
+ display: ({
3684
+ openApi
3685
+ }) => (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET)
3645
3686
  }, "lenMin"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.InputNumber, {
3646
3687
  name: "lenMax",
3647
3688
  label: formatMessage({
3648
3689
  id: 'ruleLenMax'
3649
3690
  }),
3650
3691
  min: 0,
3651
- display: _ref2 => {
3652
- let {
3653
- openApi
3654
- } = _ref2;
3655
- return (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET);
3656
- }
3692
+ display: ({
3693
+ openApi
3694
+ }) => (openApi?.data?.rulePresets || []).includes(RULE_LEN_PRESET)
3657
3695
  }, "lenMax"), /*#__PURE__*/jsxRuntime.jsx("div", {
3658
3696
  block: true,
3659
3697
  children: /*#__PURE__*/jsxRuntime.jsx(Text$2, {
@@ -3694,30 +3732,19 @@ const createEmptyTableRow = columns => {
3694
3732
  });
3695
3733
  return row;
3696
3734
  };
3697
- const ensureOptionKeys = function (list) {
3698
- if (list === void 0) {
3699
- list = [];
3700
- }
3701
- return list.map(item => ({
3702
- ...item,
3703
- _key: item._key || createOptionKey(),
3704
- children: Array.isArray(item.children) ? ensureOptionKeys(item.children) : undefined
3705
- }));
3706
- };
3707
- const hasMissingOptionKey = function (list) {
3708
- if (list === void 0) {
3709
- list = [];
3710
- }
3711
- return list.some(item => !item?._key || Array.isArray(item.children) && hasMissingOptionKey(item.children));
3712
- };
3735
+ const ensureOptionKeys = (list = []) => list.map(item => ({
3736
+ ...item,
3737
+ _key: item._key || createOptionKey(),
3738
+ children: Array.isArray(item.children) ? ensureOptionKeys(item.children) : undefined
3739
+ }));
3740
+ const hasMissingOptionKey = (list = []) => list.some(item => !item?._key || Array.isArray(item.children) && hasMissingOptionKey(item.children));
3713
3741
 
3714
3742
  /** 扁平选项(非树) */
3715
- const FlatOptionRows = _ref => {
3716
- let {
3717
- list,
3718
- onChange,
3719
- allowDescription
3720
- } = _ref;
3743
+ const FlatOptionRows = ({
3744
+ list,
3745
+ onChange,
3746
+ allowDescription
3747
+ }) => {
3721
3748
  const {
3722
3749
  formatMessage
3723
3750
  } = reactIntl.useIntl();
@@ -3783,16 +3810,15 @@ const FlatOptionRows = _ref => {
3783
3810
  };
3784
3811
 
3785
3812
  /** 树形 / 级联选项 */
3786
- const TreeOptionNode = _ref2 => {
3787
- let {
3788
- item,
3789
- index,
3790
- siblings,
3791
- onChangeSiblings,
3792
- allowDescription,
3793
- depth,
3794
- maxDepth = 4
3795
- } = _ref2;
3813
+ const TreeOptionNode = ({
3814
+ item,
3815
+ index,
3816
+ siblings,
3817
+ onChangeSiblings,
3818
+ allowDescription,
3819
+ depth,
3820
+ maxDepth = 4
3821
+ }) => {
3796
3822
  const {
3797
3823
  formatMessage
3798
3824
  } = reactIntl.useIntl();
@@ -3889,12 +3915,11 @@ const TreeOptionNode = _ref2 => {
3889
3915
  }) : null]
3890
3916
  });
3891
3917
  };
3892
- const TreeOptionsEditor = _ref3 => {
3893
- let {
3894
- value = [],
3895
- onChange,
3896
- allowDescription
3897
- } = _ref3;
3918
+ const TreeOptionsEditor = ({
3919
+ value = [],
3920
+ onChange,
3921
+ allowDescription
3922
+ }) => {
3898
3923
  const {
3899
3924
  formatMessage
3900
3925
  } = reactIntl.useIntl();
@@ -3933,11 +3958,10 @@ const TreeOptionsEditor = _ref3 => {
3933
3958
  })]
3934
3959
  });
3935
3960
  };
3936
- const ColumnsEditor = _ref4 => {
3937
- let {
3938
- value = [],
3939
- onChange
3940
- } = _ref4;
3961
+ const ColumnsEditor = ({
3962
+ value = [],
3963
+ onChange
3964
+ }) => {
3941
3965
  const {
3942
3966
  formatMessage
3943
3967
  } = reactIntl.useIntl();
@@ -4032,12 +4056,11 @@ const ColumnsEditor = _ref4 => {
4032
4056
  }, "columns-editor")]
4033
4057
  });
4034
4058
  };
4035
- const TableRowsEditor = _ref5 => {
4036
- let {
4037
- columns = [],
4038
- value = [],
4039
- onChange
4040
- } = _ref5;
4059
+ const TableRowsEditor = ({
4060
+ columns = [],
4061
+ value = [],
4062
+ onChange
4063
+ }) => {
4041
4064
  const {
4042
4065
  formatMessage
4043
4066
  } = reactIntl.useIntl();
@@ -4162,16 +4185,15 @@ const TableRowsEditor = _ref5 => {
4162
4185
  }, "table-rows-editor")]
4163
4186
  });
4164
4187
  };
4165
- const OptionsEditor = _ref6 => {
4166
- let {
4167
- value = [],
4168
- onChange,
4169
- allowDescription = false,
4170
- allowChildren = false,
4171
- hasColumns = false,
4172
- columns = [],
4173
- onColumnsChange
4174
- } = _ref6;
4188
+ const OptionsEditor = ({
4189
+ value = [],
4190
+ onChange,
4191
+ allowDescription = false,
4192
+ allowChildren = false,
4193
+ hasColumns = false,
4194
+ columns = [],
4195
+ onColumnsChange
4196
+ }) => {
4175
4197
  const {
4176
4198
  formatMessage
4177
4199
  } = reactIntl.useIntl();
@@ -4238,10 +4260,9 @@ const OptionsEditor = _ref6 => {
4238
4260
  };
4239
4261
  var OptionsEditor$1 = OptionsEditor;
4240
4262
 
4241
- const SuperSelectPropsEditor = _ref => {
4242
- let {
4243
- definition
4244
- } = _ref;
4263
+ const SuperSelectPropsEditor = ({
4264
+ definition
4265
+ }) => {
4245
4266
  const {
4246
4267
  formatMessage
4247
4268
  } = reactIntl.useIntl();
@@ -4279,12 +4300,9 @@ const SuperSelectPropsEditor = _ref => {
4279
4300
  })
4280
4301
  }, "allowClear"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Checkbox, {
4281
4302
  name: "allowSelectedAll",
4282
- display: _ref2 => {
4283
- let {
4284
- openApi
4285
- } = _ref2;
4286
- return !openApi?.data?.single;
4287
- },
4303
+ display: ({
4304
+ openApi
4305
+ }) => !openApi?.data?.single,
4288
4306
  children: formatMessage({
4289
4307
  id: 'superSelectAllowSelectedAll'
4290
4308
  })
@@ -4306,12 +4324,9 @@ const SuperSelectPropsEditor = _ref => {
4306
4324
  placeholder: formatMessage({
4307
4325
  id: 'superSelectMaxLengthPlaceholder'
4308
4326
  }),
4309
- display: _ref3 => {
4310
- let {
4311
- openApi
4312
- } = _ref3;
4313
- return !openApi?.data?.single;
4314
- }
4327
+ display: ({
4328
+ openApi
4329
+ }) => !openApi?.data?.single
4315
4330
  }, "maxLength"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Input, {
4316
4331
  name: "placeholder",
4317
4332
  label: formatMessage({
@@ -4544,12 +4559,9 @@ const buildBuiltinList = (type, formatMessage) => {
4544
4559
  }]
4545
4560
  }, "format"), /*#__PURE__*/jsxRuntime.jsx(reactFormAntd.Checkbox, {
4546
4561
  name: "showTime",
4547
- display: _ref => {
4548
- let {
4549
- openApi
4550
- } = _ref;
4551
- return (openApi?.data?.picker || 'date') === 'date';
4552
- },
4562
+ display: ({
4563
+ openApi
4564
+ }) => (openApi?.data?.picker || 'date') === 'date',
4553
4565
  children: formatMessage({
4554
4566
  id: 'propShowTime'
4555
4567
  })
@@ -4576,11 +4588,10 @@ const buildBuiltinList = (type, formatMessage) => {
4576
4588
  return [];
4577
4589
  }
4578
4590
  };
4579
- const FieldPropsEditor = _ref2 => {
4580
- let {
4581
- type,
4582
- definition: definitionProp
4583
- } = _ref2;
4591
+ const FieldPropsEditor = ({
4592
+ type,
4593
+ definition: definitionProp
4594
+ }) => {
4584
4595
  const {
4585
4596
  formatMessage
4586
4597
  } = reactIntl.useIntl();
@@ -4650,7 +4661,7 @@ const FieldConfigFields = _ref => {
4650
4661
  openApi
4651
4662
  } = reactFormAntd.useFormContext();
4652
4663
  const [fieldType, setFieldType] = react.useState(initialType);
4653
- const fieldTypeOptions = react.useMemo(() => getFieldTypes(), []);
4664
+ const fieldTypeOptions = react.useMemo(() => getFieldTypes(formatMessage), [formatMessage]);
4654
4665
  const definition = getFieldDefinition(fieldType);
4655
4666
  react.useEffect(() => {
4656
4667
  setFieldType(initialType);
@@ -5172,14 +5183,14 @@ const buildMultipleHint = (formatMessage, minLength, maxLength) => {
5172
5183
  * choice:同一条选项 UI;mode=single 只挂载一支;mode=multiple 平铺所有选中支。
5173
5184
  * 外层用 InfoPage.Part 的 title 展示标题。
5174
5185
  */
5175
- const ChoiceBlock = _ref => {
5176
- let {
5177
- block,
5178
- preview = false,
5179
- isMobile = false,
5180
- formatMessage,
5181
- renderOptionContent
5182
- } = _ref;
5186
+ const ChoiceBlock = ({
5187
+ block,
5188
+ preview = false,
5189
+ isMobile = false,
5190
+ isPartRoot = false,
5191
+ formatMessage,
5192
+ renderOptionContent
5193
+ }) => {
5183
5194
  const mode = block.mode === 'multiple' ? 'multiple' : 'single';
5184
5195
  const selectorName = resolveSelectorName(block);
5185
5196
  const options = react.useMemo(() => block.options || [], [block.options]);
@@ -5325,7 +5336,7 @@ const ChoiceBlock = _ref => {
5325
5336
  title,
5326
5337
  subtitle: modeHint,
5327
5338
  bordered,
5328
- className: style['choice-block'],
5339
+ className: [style['choice-block'], isPartRoot ? InfoPage__default["default"].partRootClassName : null].filter(Boolean).join(' '),
5329
5340
  'data-choice-mode': mode
5330
5341
  }, /*#__PURE__*/react.createElement('div', {
5331
5342
  className: style['choice-selector']
@@ -5349,12 +5360,18 @@ const buildLabelTips = tips => {
5349
5360
  className: style['field-label-tips-icon']
5350
5361
  }));
5351
5362
  };
5363
+ const resolvePartRootClassName = function (depth) {
5364
+ // 顶层模块一律重设一级标题,嵌入外层 FormInfo Part 时不降为二级胶囊
5365
+ const names = [depth === 0 ? InfoPage__default["default"].partRootClassName : null, ...[].slice.call(arguments, 1)].filter(Boolean);
5366
+ return names.length ? names.join(' ') : undefined;
5367
+ };
5352
5368
  const renderFieldElements = function (fields, preview, _temp) {
5353
5369
  if (fields === void 0) {
5354
5370
  fields = [];
5355
5371
  }
5356
5372
  let {
5357
- namePrefix
5373
+ namePrefix,
5374
+ locale
5358
5375
  } = _temp === void 0 ? {} : _temp;
5359
5376
  return fields.filter(field => !field.hidden).map(field => {
5360
5377
  const Component = getFieldComponent(field.type, field);
@@ -5375,6 +5392,10 @@ const renderFieldElements = function (fields, preview, _temp) {
5375
5392
  delete props.range;
5376
5393
  const description = field.description != null && String(field.description).trim() ? field.description : undefined;
5377
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
+ } : {};
5378
5399
  return /*#__PURE__*/react.createElement(Component, {
5379
5400
  key: field.id,
5380
5401
  name: fieldName,
@@ -5382,6 +5403,7 @@ const renderFieldElements = function (fields, preview, _temp) {
5382
5403
  rule: field.rule || undefined,
5383
5404
  block: field.block || undefined,
5384
5405
  ...props,
5406
+ ...localeProps,
5385
5407
  labelTips: buildLabelTips(field.tips),
5386
5408
  description
5387
5409
  });
@@ -5424,7 +5446,8 @@ const renderBlockElement = function (block, preview, ctx) {
5424
5446
  isMobile = false,
5425
5447
  formatMessage,
5426
5448
  depth = 0,
5427
- asListItem = false
5449
+ asListItem = false,
5450
+ locale
5428
5451
  } = ctx;
5429
5452
  if (!block || depth > MAX_BLOCK_DEPTH) {
5430
5453
  return null;
@@ -5434,6 +5457,9 @@ const renderBlockElement = function (block, preview, ctx) {
5434
5457
  depth: depth + 1,
5435
5458
  asListItem: false
5436
5459
  };
5460
+ const fieldRenderOpts = {
5461
+ locale
5462
+ };
5437
5463
  const bordered = isMobile ? false : block.bordered || undefined;
5438
5464
  // 仅 FormInfo/object 吃列表项 Part 样式;List 等交给 form-info nestDepth
5439
5465
  const listItemPartProps = asListItem && isFormInfoLikeBlock(block.kind) ? nestedListItemPartProps : null;
@@ -5463,7 +5489,7 @@ const renderBlockElement = function (block, preview, ctx) {
5463
5489
  switch (block.kind) {
5464
5490
  case 'formInfo':
5465
5491
  {
5466
- const fields = renderFieldElements(block.list);
5492
+ const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
5467
5493
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
5468
5494
  return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo__default["default"], {
5469
5495
  key: block.id,
@@ -5473,12 +5499,14 @@ const renderBlockElement = function (block, preview, ctx) {
5473
5499
  gap: block.gap,
5474
5500
  bordered,
5475
5501
  list: [...fields, ...nested],
5476
- ...(listItemPartProps || {})
5502
+ ...(listItemPartProps || {}),
5503
+ className: resolvePartRootClassName(depth)
5477
5504
  }), asListItem);
5478
5505
  }
5479
5506
  case 'object':
5480
5507
  {
5481
5508
  const fields = renderFieldElements(block.list, preview, {
5509
+ ...fieldRenderOpts,
5482
5510
  namePrefix: block.name || ''
5483
5511
  });
5484
5512
  const nested = renderChildBlocks(block.blocks || [], nextCtx).map(node => withBlockLayout(node, true));
@@ -5490,12 +5518,13 @@ const renderBlockElement = function (block, preview, ctx) {
5490
5518
  gap: block.gap,
5491
5519
  bordered,
5492
5520
  list: [...fields, ...nested],
5493
- ...(listItemPartProps || {})
5521
+ ...(listItemPartProps || {}),
5522
+ className: resolvePartRootClassName(depth)
5494
5523
  }), asListItem);
5495
5524
  }
5496
5525
  case 'list':
5497
5526
  {
5498
- const fields = renderFieldElements(block.list);
5527
+ const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
5499
5528
  const nested = renderItemBlocks(block.itemBlocks || []);
5500
5529
  return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo.List, {
5501
5530
  key: block.id,
@@ -5503,6 +5532,7 @@ const renderBlockElement = function (block, preview, ctx) {
5503
5532
  title: block.title || undefined,
5504
5533
  important: block.important || undefined,
5505
5534
  bordered,
5535
+ className: resolvePartRootClassName(depth),
5506
5536
  maxLength: block.maxLength,
5507
5537
  minLength: block.minLength,
5508
5538
  ...(block.addText ? {
@@ -5516,7 +5546,7 @@ const renderBlockElement = function (block, preview, ctx) {
5516
5546
  }
5517
5547
  case 'tableList':
5518
5548
  {
5519
- const fields = renderFieldElements(block.list);
5549
+ const fields = renderFieldElements(block.list, preview, fieldRenderOpts);
5520
5550
  return withBlockLayout(/*#__PURE__*/react.createElement(FormInfo.TableList, {
5521
5551
  key: block.id,
5522
5552
  name: block.name,
@@ -5528,7 +5558,8 @@ const renderBlockElement = function (block, preview, ctx) {
5528
5558
  addText: block.addText
5529
5559
  } : {}),
5530
5560
  list: fields,
5531
- ...(listItemPartProps || {})
5561
+ ...(listItemPartProps || {}),
5562
+ className: resolvePartRootClassName(depth)
5532
5563
  }), asListItem);
5533
5564
  }
5534
5565
  case 'multiField':
@@ -5555,10 +5586,11 @@ const renderBlockElement = function (block, preview, ctx) {
5555
5586
  title: block.title || undefined,
5556
5587
  subtitle: block.subtitle || undefined,
5557
5588
  bordered,
5589
+ className: resolvePartRootClassName(depth),
5558
5590
  prevIcon: /*#__PURE__*/react.createElement(icons.ArrowLeftOutlined),
5559
5591
  nextIcon: /*#__PURE__*/react.createElement(icons.ArrowRightOutlined),
5560
5592
  items: (block.items || []).map(step => {
5561
- const fields = renderFieldElements(step.list);
5593
+ const fields = renderFieldElements(step.list, preview, fieldRenderOpts);
5562
5594
  const nested = renderChildBlocks(step.blocks || [], nextCtx);
5563
5595
  const fieldNames = [...(step.list || []).filter(field => field && !field.hidden && field.name).map(field => field.name), ...collectBlockFieldNames(step.blocks || [])];
5564
5596
  if (nested.length) {
@@ -5595,6 +5627,7 @@ const renderBlockElement = function (block, preview, ctx) {
5595
5627
  block,
5596
5628
  preview,
5597
5629
  isMobile,
5630
+ isPartRoot: depth === 0,
5598
5631
  formatMessage,
5599
5632
  renderOptionContent: option => {
5600
5633
  const nodes = [];
@@ -5621,6 +5654,7 @@ const renderSchemaInner = function (schema, _temp2) {
5621
5654
  bodyClassName,
5622
5655
  isMobile = false,
5623
5656
  formatMessage,
5657
+ locale,
5624
5658
  children,
5625
5659
  actionNode
5626
5660
  } = _temp2 === void 0 ? {} : _temp2;
@@ -5628,7 +5662,8 @@ const renderSchemaInner = function (schema, _temp2) {
5628
5662
  const blocks = normalized.blocks || [];
5629
5663
  const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
5630
5664
  isMobile,
5631
- formatMessage
5665
+ formatMessage,
5666
+ locale
5632
5667
  })).filter(Boolean);
5633
5668
  if (!contentChildren.length && !children && !actionNode) {
5634
5669
  return null;
@@ -5649,6 +5684,7 @@ const renderSchemaContent = function (schema, _temp3) {
5649
5684
  bodyClassName,
5650
5685
  isMobile = false,
5651
5686
  formatMessage,
5687
+ locale,
5652
5688
  children,
5653
5689
  actionNode
5654
5690
  } = _temp3 === void 0 ? {} : _temp3;
@@ -5656,7 +5692,8 @@ const renderSchemaContent = function (schema, _temp3) {
5656
5692
  const blocks = normalized.blocks || [];
5657
5693
  const contentChildren = blocks.map(block => renderBlockElement(block, preview, {
5658
5694
  isMobile,
5659
- formatMessage
5695
+ formatMessage,
5696
+ locale
5660
5697
  })).filter(Boolean);
5661
5698
  if (!contentChildren.length && !children) {
5662
5699
  return null;
@@ -5779,7 +5816,8 @@ const SchemaRendererInner = withLocale$1(props => {
5779
5816
  buttonFooterProps
5780
5817
  } = props;
5781
5818
  const {
5782
- formatMessage
5819
+ formatMessage,
5820
+ locale
5783
5821
  } = reactIntl.useIntl();
5784
5822
  const isMobile = responsiveUtils.useIsMobile();
5785
5823
  const normalized = normalizeSchema(schema);
@@ -5812,6 +5850,7 @@ const SchemaRendererInner = withLocale$1(props => {
5812
5850
  bodyClassName,
5813
5851
  isMobile,
5814
5852
  formatMessage,
5853
+ locale,
5815
5854
  children,
5816
5855
  actionNode
5817
5856
  });
@@ -5842,7 +5881,8 @@ const SchemaRenderer = withLocale$1(props => {
5842
5881
  buttonFooterProps
5843
5882
  } = props;
5844
5883
  const {
5845
- formatMessage
5884
+ formatMessage,
5885
+ locale
5846
5886
  } = reactIntl.useIntl();
5847
5887
  const isMobile = responsiveUtils.useIsMobile();
5848
5888
  const normalized = normalizeSchema(schema);
@@ -5876,6 +5916,7 @@ const SchemaRenderer = withLocale$1(props => {
5876
5916
  bodyClassName,
5877
5917
  isMobile,
5878
5918
  formatMessage,
5919
+ locale,
5879
5920
  children,
5880
5921
  actionNode
5881
5922
  });
@@ -5894,7 +5935,8 @@ const FormCreator = withLocale$1(_ref => {
5894
5935
  extraToolbar
5895
5936
  } = _ref;
5896
5937
  const {
5897
- formatMessage
5938
+ formatMessage,
5939
+ locale
5898
5940
  } = reactIntl.useIntl();
5899
5941
  const isMobile = responsiveUtils.useIsMobile();
5900
5942
  const [innerSchema, setInnerSchema] = react.useState(() => normalizeSchema(defaultValue || defaultSchema()));
@@ -6243,7 +6285,8 @@ const FormCreator = withLocale$1(_ref => {
6243
6285
  children: hasRenderableContent(schema) ? /*#__PURE__*/jsxRuntime.jsx(SchemaRenderer$1, {
6244
6286
  schema: schema,
6245
6287
  preview: true,
6246
- formProps: formProps
6288
+ formProps: formProps,
6289
+ locale: locale
6247
6290
  }) : /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
6248
6291
  image: antd.Empty.PRESENTED_IMAGE_SIMPLE,
6249
6292
  description: formatMessage({
@@ -7236,7 +7279,8 @@ const renderBlock = (block, data, ctx) => {
7236
7279
  key: block.id,
7237
7280
  title: block.title || block.label || undefined,
7238
7281
  subtitle: block.subtitle || undefined,
7239
- bordered
7282
+ bordered,
7283
+ className: depth === 0 ? InfoPage__default["default"].partRootClassName : undefined
7240
7284
  };
7241
7285
  switch (block.kind) {
7242
7286
  case 'formInfo':
@@ -7435,7 +7479,9 @@ exports.parseRuleString = parseRuleString;
7435
7479
  exports.pickFieldProps = pickFieldProps;
7436
7480
  exports.pickFromPropsSchema = pickFromPropsSchema;
7437
7481
  exports.preset = preset;
7482
+ exports.registerField = registerField;
7438
7483
  exports.removeBlockInTree = removeBlockInTree;
7484
+ exports.resolveFieldTypeLabel = resolveFieldTypeLabel;
7439
7485
  exports.resolveFieldValueSchema = resolveFieldValueSchema;
7440
7486
  exports.schemaToDataSchema = schemaToDataSchema;
7441
7487
  exports.updateBlocks = updateBlocks;