@ecoding/components.antd 0.2.12 → 0.2.13

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.
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ interface IProps {
3
+ placeholder?: string;
4
+ value?: string;
5
+ onChange?: any;
6
+ regionWidth?: number;
7
+ regions?: {
8
+ value: string;
9
+ label: string;
10
+ }[];
11
+ disabled?: boolean;
12
+ }
13
+ declare const LengthInput: React.FC<IProps>;
14
+ export default LengthInput;
@@ -0,0 +1,59 @@
1
+ import React, { useCallback, useEffect, useState } from 'react';
2
+ import { Select, Input } from 'antd';
3
+ const LengthInput = (props) => {
4
+ const [region, setRegion] = useState('+86');
5
+ const [v, setV] = useState('');
6
+ const inputHandler = useCallback((e) => {
7
+ let vs = e.target.value.trim();
8
+ props.onChange(`${region}-${vs}`);
9
+ }, [region]);
10
+ const selectHandler = useCallback((v) => {
11
+ setRegion(v);
12
+ }, []);
13
+ useEffect(() => {
14
+ const v = props.value || '';
15
+ if (v) {
16
+ const ary = v.split('-');
17
+ if (ary.length === 2) {
18
+ setRegion(ary[0]);
19
+ setV(ary[1]);
20
+ }
21
+ if (ary.length === 1) {
22
+ setV(ary[0]);
23
+ }
24
+ }
25
+ }, [props]);
26
+ return (React.createElement(Input, Object.assign({}, props, { value: v, addonBefore: React.createElement(Select, { className: "ant_select_no_padding", style: {
27
+ width: props.regionWidth,
28
+ paddingRight: 20,
29
+ boxSizing: 'content-box'
30
+ }, value: region, bordered: false, options: props.regions, onChange: selectHandler }), onChange: inputHandler })));
31
+ };
32
+ LengthInput.defaultProps = {
33
+ regionWidth: 60,
34
+ regions: [
35
+ { value: '+86', label: '+86' },
36
+ { value: '+65', label: '+65' },
37
+ { value: '+66', label: '+66' },
38
+ { value: '+62', label: '+62' },
39
+ { value: '+60', label: '+60' },
40
+ { value: '+673', label: '+673' },
41
+ { value: '+84', label: '+84' },
42
+ { value: '+81', label: '+81' },
43
+ { value: '+82', label: '+82' },
44
+ { value: '+63', label: '+63' },
45
+ { value: '+95', label: '+95' },
46
+ { value: '+234', label: '+234' },
47
+ { value: '+855', label: '+855' },
48
+ { value: '+853', label: '+853' },
49
+ { value: '+886', label: '+886' },
50
+ { value: '+852', label: '+852' },
51
+ { value: '+1', label: '+1' },
52
+ { value: '+7', label: '+7' },
53
+ { value: '+44', label: '+44' },
54
+ { value: '+33', label: '+33' },
55
+ { value: '+49', label: '+49' },
56
+ { value: '+39', label: '+39' } // 意大利
57
+ ]
58
+ };
59
+ export default LengthInput;
package/lib/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export { default as InjectNotification } from "./core/inject-notification";
6
6
  export { default as Confirm } from "./core/confirm";
7
7
  export { default as AsyncCascader } from "./core/async-cascader";
8
8
  export { default as LengthInput } from "./core/length-input";
9
+ export { default as PhoneInput } from "./core/phone-input";
9
10
  export { default as RangePicker } from "./core/range-picker";
10
11
  export { default as SingleImgUpload } from "./core/single-img-upload";
11
12
  export { default as SingleFileUpload } from "./core/single-file-upload";
package/lib/index.js CHANGED
@@ -6,6 +6,7 @@ export { default as InjectNotification } from "./core/inject-notification";
6
6
  export { default as Confirm } from "./core/confirm";
7
7
  export { default as AsyncCascader } from "./core/async-cascader";
8
8
  export { default as LengthInput } from "./core/length-input";
9
+ export { default as PhoneInput } from "./core/phone-input";
9
10
  export { default as RangePicker } from "./core/range-picker";
10
11
  export { default as SingleImgUpload } from "./core/single-img-upload";
11
12
  export { default as SingleFileUpload } from "./core/single-file-upload";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -44,5 +44,5 @@
44
44
  "dependencies": {
45
45
  "react-quill": "^2.0.0"
46
46
  },
47
- "gitHead": "40c7fd1769a29e3a3998f7c4dcb4db553aced298"
47
+ "gitHead": "b8a13d283463657b35fd7226d8e7938c37540256"
48
48
  }