form-driver 0.4.17 → 0.4.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/es/m3.js CHANGED
@@ -19224,7 +19224,7 @@ var ASpecInputBox = /*#__PURE__*/function (_BaseViewer) {
19224
19224
  children: [item.country, " +", item.value]
19225
19225
  }, item.countryCode);
19226
19226
  })
19227
- }), jsx(Input, {
19227
+ }), jsx(InputNumber, {
19228
19228
  style: {
19229
19229
  width: "calc(100% - " + selectWidth + "px)"
19230
19230
  },
@@ -19232,9 +19232,10 @@ var ASpecInputBox = /*#__PURE__*/function (_BaseViewer) {
19232
19232
  bordered: !this.props.hideBorder,
19233
19233
  disabled: this.props.disable,
19234
19234
  defaultValue: phoneValue.phone,
19235
- onChange: function onChange(e) {
19235
+ min: "0",
19236
+ onChange: function onChange(value) {
19236
19237
  var updated = _objectSpread$l(_objectSpread$l({}, _this.getPhoneValue()), {}, {
19237
- phone: e.target.value
19238
+ phone: value
19238
19239
  });
19239
19240
 
19240
19241
  _this.changeValueEx(updated, false, false);
package/lib/m3.js CHANGED
@@ -19248,7 +19248,7 @@ var ASpecInputBox = /*#__PURE__*/function (_BaseViewer) {
19248
19248
  children: [item.country, " +", item.value]
19249
19249
  }, item.countryCode);
19250
19250
  })
19251
- }), jsxRuntime.jsx(antd.Input, {
19251
+ }), jsxRuntime.jsx(antd.InputNumber, {
19252
19252
  style: {
19253
19253
  width: "calc(100% - " + selectWidth + "px)"
19254
19254
  },
@@ -19256,9 +19256,10 @@ var ASpecInputBox = /*#__PURE__*/function (_BaseViewer) {
19256
19256
  bordered: !this.props.hideBorder,
19257
19257
  disabled: this.props.disable,
19258
19258
  defaultValue: phoneValue.phone,
19259
- onChange: function onChange(e) {
19259
+ min: "0",
19260
+ onChange: function onChange(value) {
19260
19261
  var updated = _objectSpread$l(_objectSpread$l({}, _this.getPhoneValue()), {}, {
19261
- phone: e.target.value
19262
+ phone: value
19262
19263
  });
19263
19264
 
19264
19265
  _this.changeValueEx(updated, false, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "form-driver",
3
- "version": "0.4.17",
3
+ "version": "0.4.18",
4
4
  "description": "An efficient framework for creating forms.",
5
5
  "license": "MIT",
6
6
  "authors": [
@@ -1,18 +1,17 @@
1
1
  import React from "react";
2
- import _ from "lodash"
3
- import { Input, Select } from "antd";
4
- import { BaseViewer } from '../../BaseViewer';
5
- import { AREA_CODE_LIST } from '../../../data/areaCodeData';
2
+ import _ from "lodash";
3
+ import { Input, InputNumber, Select } from "antd";
4
+ import { BaseViewer } from "../../BaseViewer";
5
+ import { AREA_CODE_LIST } from "../../../data/areaCodeData";
6
6
 
7
7
  /**
8
8
  * 手机号/邮箱等输入框
9
9
  * cnPhone/tel/email
10
- *
10
+ *
11
11
  * 当 type 为 tel 或 cnPhone 时,渲染为区号选择器 + 手机号输入框的复合组件
12
12
  * 数据格式为 {areaCode: "86", phone: "13800138000"}
13
13
  */
14
14
  export class ASpecInputBox extends BaseViewer {
15
-
16
15
  /**
17
16
  * 判断当前 schema 类型是否为手机号类型
18
17
  */
@@ -42,54 +41,65 @@ export class ASpecInputBox extends BaseViewer {
42
41
  const phoneValue = this.getPhoneValue();
43
42
  const selectWidth = 120;
44
43
 
45
- return <Input.Group compact key={this.props.path}>
46
- <Select
47
- style={{ width: selectWidth }}
48
- value={phoneValue.areaCode}
49
- showSearch
50
- optionLabelProp="shortLabel"
51
- filterOption={(input, option) => {
52
- const searchText = input.toLowerCase();
53
- // 支持按区号、国家中文名、英文名搜索
54
- const country = ((option as any)?.["data-country"] as string || "").toLowerCase();
55
- const englishName = ((option as any)?.["data-english"] as string || "").toLowerCase();
56
- const value = (option?.value as string || "");
57
- return value.includes(searchText) || country.includes(searchText) || englishName.includes(searchText);
58
- }}
59
- disabled={this.props.disable}
60
- onChange={(newAreaCode: string) => {
61
- const updated = { ...this.getPhoneValue(), areaCode: newAreaCode };
62
- this.changeValueEx(updated, false, true);
63
- }}
64
- >
65
- {AREA_CODE_LIST.map(item => (
66
- <Select.Option
67
- key={item.countryCode}
68
- value={item.value}
69
- shortLabel={`+${item.value}`}
70
- data-country={item.country}
71
- data-english={item.englishName}
72
- >
73
- {item.country} +{item.value}
74
- </Select.Option>
75
- ))}
76
- </Select>
77
- <Input
78
- style={{ width: `calc(100% - ${selectWidth}px)` }}
79
- placeholder={super.getPlaceholder()}
80
- bordered={!this.props.hideBorder}
81
- disabled={this.props.disable}
82
- defaultValue={phoneValue.phone}
83
- key={this.props.path + "/phone/" + this.state.ctrlVersion}
84
- onChange={(e) => {
85
- const updated = { ...this.getPhoneValue(), phone: e.target.value };
86
- this.changeValueEx(updated, false, false);
87
- }}
88
- onBlur={() => {
89
- this.changeValueEx(this.getPhoneValue(), false, true);
90
- }}
91
- />
92
- </Input.Group>;
44
+ return (
45
+ <Input.Group compact key={this.props.path}>
46
+ <Select
47
+ style={{ width: selectWidth }}
48
+ value={phoneValue.areaCode}
49
+ showSearch
50
+ optionLabelProp="shortLabel"
51
+ filterOption={(input, option) => {
52
+ const searchText = input.toLowerCase();
53
+ // 支持按区号、国家中文名、英文名搜索
54
+ const country = (
55
+ ((option as any)?.["data-country"] as string) || ""
56
+ ).toLowerCase();
57
+ const englishName = (
58
+ ((option as any)?.["data-english"] as string) || ""
59
+ ).toLowerCase();
60
+ const value = (option?.value as string) || "";
61
+ return (
62
+ value.includes(searchText) ||
63
+ country.includes(searchText) ||
64
+ englishName.includes(searchText)
65
+ );
66
+ }}
67
+ disabled={this.props.disable}
68
+ onChange={(newAreaCode: string) => {
69
+ const updated = { ...this.getPhoneValue(), areaCode: newAreaCode };
70
+ this.changeValueEx(updated, false, true);
71
+ }}
72
+ >
73
+ {AREA_CODE_LIST.map((item) => (
74
+ <Select.Option
75
+ key={item.countryCode}
76
+ value={item.value}
77
+ shortLabel={`+${item.value}`}
78
+ data-country={item.country}
79
+ data-english={item.englishName}
80
+ >
81
+ {item.country} +{item.value}
82
+ </Select.Option>
83
+ ))}
84
+ </Select>
85
+ <InputNumber
86
+ style={{ width: `calc(100% - ${selectWidth}px)` }}
87
+ placeholder={super.getPlaceholder()}
88
+ bordered={!this.props.hideBorder}
89
+ disabled={this.props.disable}
90
+ defaultValue={phoneValue.phone}
91
+ min={"0"}
92
+ key={this.props.path + "/phone/" + this.state.ctrlVersion}
93
+ onChange={(value) => {
94
+ const updated = { ...this.getPhoneValue(), phone: value };
95
+ this.changeValueEx(updated, false, false);
96
+ }}
97
+ onBlur={() => {
98
+ this.changeValueEx(this.getPhoneValue(), false, true);
99
+ }}
100
+ />
101
+ </Input.Group>
102
+ );
93
103
  }
94
104
 
95
105
  element() {
@@ -100,20 +110,21 @@ export class ASpecInputBox extends BaseViewer {
100
110
 
101
111
  // 其他类型(如 email):保持原有纯 Input 行为
102
112
  const p = this.props.schema.props ?? {};
103
- const deepCloneP = _.cloneDeep(p)
104
- const selfOnChange = p.onChange
105
- delete deepCloneP.onChange
106
-
107
- return <Input
108
- {...super.antProp()}
109
- defaultValue={super.getValue()}
110
- onBlur={() => this.changeValueEx(super.getValue(), false, true)}
111
- onChange={(v) => {
112
- this.changeValueEx(v.target.value, false, false);
113
- selfOnChange && selfOnChange(v)
114
- }}
115
- {...deepCloneP}
116
- />;
113
+ const deepCloneP = _.cloneDeep(p);
114
+ const selfOnChange = p.onChange;
115
+ delete deepCloneP.onChange;
116
+
117
+ return (
118
+ <Input
119
+ {...super.antProp()}
120
+ defaultValue={super.getValue()}
121
+ onBlur={() => this.changeValueEx(super.getValue(), false, true)}
122
+ onChange={(v) => {
123
+ this.changeValueEx(v.target.value, false, false);
124
+ selfOnChange && selfOnChange(v);
125
+ }}
126
+ {...deepCloneP}
127
+ />
128
+ );
117
129
  }
118
130
  }
119
-
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { BaseViewer } from '../../BaseViewer';
2
+ import { BaseViewer } from "../../BaseViewer";
3
3
  /**
4
4
  * 手机号/邮箱等输入框
5
5
  * cnPhone/tel/email