@electerm/electerm-react 2.3.30 → 2.3.36

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.
@@ -23,6 +23,7 @@ import CategorySelect from './category-select.jsx'
23
23
  import RdpAlert from './rdp-alert.jsx'
24
24
 
25
25
  const Fragment = React.Fragment
26
+ const FormItem = Form.Item
26
27
 
27
28
  const { TextArea } = Input
28
29
  const commonRenderTypes = new Set([
@@ -47,7 +48,7 @@ const commonRenderTypes = new Set([
47
48
  * @returns {JSX.Element|null} Rendered form item
48
49
  */
49
50
  export function renderFormItem (item, formItemLayout, form, ctxProps, index) {
50
- const { type, name, label, rules, valuePropName, hidden } = item
51
+ const { type, name, label, rules, valuePropName, hidden, normalize } = item
51
52
 
52
53
  // Render simple AntD controls directly inside Form.Item
53
54
  if (commonRenderTypes.has(type)) {
@@ -93,18 +94,22 @@ export function renderFormItem (item, formItemLayout, form, ctxProps, index) {
93
94
  control = null
94
95
  }
95
96
  if (!control) return null
97
+ const formItemProps = {
98
+ ...formItemLayout,
99
+ className: cls,
100
+ label,
101
+ name,
102
+ rules,
103
+ valuePropName,
104
+ normalize
105
+ }
96
106
  return (
97
- <Form.Item
107
+ <FormItem
98
108
  key={name}
99
- {...formItemLayout}
100
- className={cls}
101
- label={label}
102
- name={name}
103
- rules={rules}
104
- valuePropName={valuePropName}
109
+ {...formItemProps}
105
110
  >
106
111
  {control}
107
- </Form.Item>
112
+ </FormItem>
108
113
  )
109
114
  }
110
115
 
@@ -36,7 +36,19 @@ const serialConfig = {
36
36
  commonFields.category,
37
37
  commonFields.colorTitle,
38
38
  { type: 'serialPathSelector', name: 'path', label: 'path', rules: [{ required: true, message: 'path required' }] },
39
- { type: 'autocomplete', name: 'baudRate', label: 'baudRate', options: commonBaudRates.map(d => ({ value: d })) },
39
+ {
40
+ type: 'autocomplete',
41
+ name: 'baudRate',
42
+ label: 'baudRate',
43
+ options: commonBaudRates.map(d => ({ value: d })),
44
+ normalize: (value) => {
45
+ if (value === '' || value == null) {
46
+ return undefined
47
+ }
48
+ const numValue = Number(value)
49
+ return isNaN(numValue) ? undefined : numValue
50
+ }
51
+ },
40
52
  { type: 'select', name: 'dataBits', label: 'dataBits', options: commonDataBits.map(d => ({ value: d, label: d })) },
41
53
  { type: 'select', name: 'stopBits', label: 'stopBits', options: commonStopBits.map(d => ({ value: d, label: d })) },
42
54
  { type: 'select', name: 'parity', label: 'parity', options: commonParities.map(d => ({ value: d, label: d })) },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "2.3.30",
3
+ "version": "2.3.36",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",