@autobest-ui/components 2.9.2 → 2.10.1-alpha.0
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/esm/affix/index.d.ts +3 -3
- package/esm/affix/index.js +2 -2
- package/esm/carousel/index.d.ts +2 -2
- package/esm/carousel/index.js +1 -1
- package/esm/checkbox/Checkbox.d.ts +60 -0
- package/esm/checkbox/Checkbox.js +120 -0
- package/esm/checkbox/CheckboxGroup.d.ts +16 -0
- package/esm/checkbox/CheckboxGroup.js +57 -0
- package/esm/checkbox/index.d.ts +4 -52
- package/esm/checkbox/index.js +2 -114
- package/esm/checkbox/style/index.css +1 -1
- package/esm/ellipsis/index.d.ts +1 -8
- package/esm/ellipsis/index.js +9 -9
- package/esm/ellipsis/style/index.css +1 -1
- package/esm/index.d.ts +8 -3
- package/esm/index.js +5 -2
- package/esm/input/Input.d.ts +13 -1
- package/esm/input/Input.js +66 -4
- package/esm/input/TextArea.d.ts +8 -0
- package/esm/input/TextArea.js +43 -12
- package/esm/input-number/getParserOriginalValue.d.ts +26 -0
- package/esm/input-number/getParserOriginalValue.js +73 -0
- package/esm/input-number/index.d.ts +20 -7
- package/esm/input-number/index.js +60 -48
- package/esm/input-phone/format.d.ts +23 -0
- package/esm/input-phone/format.js +81 -0
- package/esm/input-phone/index.d.ts +65 -0
- package/esm/input-phone/index.js +190 -0
- package/esm/input-phone/style/index.css +1 -0
- package/esm/modal/index.d.ts +3 -3
- package/esm/modal/index.js +2 -2
- package/esm/move/index.d.ts +6 -6
- package/esm/move/index.js +5 -5
- package/esm/popover/index.d.ts +1 -1
- package/esm/popover/index.js +7 -2
- package/esm/radio/Radio.d.ts +4 -0
- package/esm/radio/Radio.js +80 -0
- package/esm/radio/RadioGroup.d.ts +16 -0
- package/esm/radio/RadioGroup.js +106 -0
- package/esm/radio/context.d.ts +5 -0
- package/esm/radio/context.js +4 -0
- package/esm/radio/index.d.ts +3 -0
- package/esm/radio/index.js +2 -0
- package/esm/radio/interface.d.ts +17 -0
- package/esm/radio/interface.js +1 -0
- package/esm/radio/style/index.css +1 -0
- package/esm/select/index.d.ts +2 -2
- package/esm/select/index.js +1 -1
- package/esm/style.css +1 -1
- package/esm/table/body/CheckIcon.js +1 -1
- package/esm/table/header/CheckIcon.js +1 -1
- package/esm/table/index.d.ts +2 -2
- package/esm/table/index.js +2 -1
- package/esm/table/style/index.css +1 -1
- package/esm/tabs/index.d.ts +2 -2
- package/esm/tabs/index.js +1 -1
- package/esm/trigger/index.d.ts +5 -5
- package/esm/trigger/index.js +5 -5
- package/lib/affix/index.d.ts +3 -3
- package/lib/affix/index.js +2 -2
- package/lib/carousel/index.d.ts +2 -2
- package/lib/carousel/index.js +1 -1
- package/lib/checkbox/Checkbox.d.ts +60 -0
- package/lib/checkbox/Checkbox.js +128 -0
- package/lib/checkbox/CheckboxGroup.d.ts +16 -0
- package/lib/checkbox/CheckboxGroup.js +65 -0
- package/lib/checkbox/index.d.ts +4 -52
- package/lib/checkbox/index.js +13 -115
- package/lib/checkbox/style/index.css +1 -1
- package/lib/ellipsis/index.d.ts +1 -8
- package/lib/ellipsis/index.js +9 -9
- package/lib/ellipsis/style/index.css +1 -1
- package/lib/index.d.ts +8 -3
- package/lib/index.js +47 -2
- package/lib/input/Input.d.ts +13 -1
- package/lib/input/Input.js +66 -4
- package/lib/input/TextArea.d.ts +8 -0
- package/lib/input/TextArea.js +43 -12
- package/lib/input-number/getParserOriginalValue.d.ts +26 -0
- package/lib/input-number/getParserOriginalValue.js +79 -0
- package/lib/input-number/index.d.ts +20 -7
- package/lib/input-number/index.js +59 -47
- package/lib/input-phone/format.d.ts +23 -0
- package/lib/input-phone/format.js +90 -0
- package/lib/input-phone/index.d.ts +65 -0
- package/lib/input-phone/index.js +198 -0
- package/lib/input-phone/style/index.css +1 -0
- package/lib/modal/index.d.ts +3 -3
- package/lib/modal/index.js +2 -2
- package/lib/move/index.d.ts +6 -6
- package/lib/move/index.js +5 -5
- package/lib/popover/index.d.ts +1 -1
- package/lib/popover/index.js +7 -2
- package/lib/radio/Radio.d.ts +4 -0
- package/lib/radio/Radio.js +91 -0
- package/lib/radio/RadioGroup.d.ts +16 -0
- package/lib/radio/RadioGroup.js +117 -0
- package/lib/radio/context.d.ts +5 -0
- package/lib/radio/context.js +15 -0
- package/lib/radio/index.d.ts +3 -0
- package/lib/radio/index.js +20 -0
- package/lib/radio/interface.d.ts +17 -0
- package/lib/radio/interface.js +5 -0
- package/lib/radio/style/index.css +1 -0
- package/lib/select/index.d.ts +2 -2
- package/lib/select/index.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/body/CheckIcon.js +2 -2
- package/lib/table/header/CheckIcon.js +2 -2
- package/lib/table/index.d.ts +2 -2
- package/lib/table/index.js +2 -1
- package/lib/table/style/index.css +1 -1
- package/lib/tabs/index.d.ts +2 -2
- package/lib/tabs/index.js +1 -1
- package/lib/trigger/index.d.ts +5 -5
- package/lib/trigger/index.js +5 -5
- package/package.json +5 -4
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { isBlank } from '@autobest-ui/utils';
|
|
2
|
+
/**
|
|
3
|
+
* 按照给定的模板(111-222-333)格式化数字形式电话号码(111222333)
|
|
4
|
+
* @param value
|
|
5
|
+
* @param format
|
|
6
|
+
* @param placeholder
|
|
7
|
+
*/
|
|
8
|
+
export function getPhoneFormat(value, format, placeholder) {
|
|
9
|
+
var defaultValueArr = getNumberValue(value).split('');
|
|
10
|
+
return format.replace(/\d/g, function () {
|
|
11
|
+
return defaultValueArr.shift() || placeholder;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 删除字符串中非数字内容
|
|
16
|
+
* @param value
|
|
17
|
+
*/
|
|
18
|
+
export function getNumberValue(value) {
|
|
19
|
+
if (isBlank(value)) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
return value.replace(/[^\d]/g, '');
|
|
23
|
+
}
|
|
24
|
+
export function getFirstCursorPosition(value, format, placeholder) {
|
|
25
|
+
if (isBlank(value)) {
|
|
26
|
+
return format.search(/\d/);
|
|
27
|
+
}
|
|
28
|
+
var match;
|
|
29
|
+
while ((match = new RegExp(placeholder, 'g').exec(value)) !== null) {
|
|
30
|
+
if (match[0] !== format[match.index]) {
|
|
31
|
+
return match.index;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return value.length;
|
|
35
|
+
}
|
|
36
|
+
function getDifferIndex(value, prevValue) {
|
|
37
|
+
for (var i = 0, l = Math.max(value.length, prevValue.length); i < l; i++) {
|
|
38
|
+
if (value[i] !== prevValue[i]) {
|
|
39
|
+
return i;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return prevValue.length;
|
|
43
|
+
}
|
|
44
|
+
function getSlice(str, start, end) {
|
|
45
|
+
if (!end) {
|
|
46
|
+
return str.slice(start);
|
|
47
|
+
}
|
|
48
|
+
return str.slice(start, end);
|
|
49
|
+
}
|
|
50
|
+
export function getUpdatedValue(_a) {
|
|
51
|
+
var value = _a.value,
|
|
52
|
+
prevValue = _a.prevValue,
|
|
53
|
+
format = _a.format,
|
|
54
|
+
selectionEnd = _a.selectionEnd,
|
|
55
|
+
placeholder = _a.placeholder;
|
|
56
|
+
if (isBlank(value)) {
|
|
57
|
+
return {
|
|
58
|
+
value: getPhoneFormat('', format, placeholder),
|
|
59
|
+
cursorPosition: getFirstCursorPosition('', format, placeholder)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
var lastCursorIndex = (value.length - selectionEnd) * -1;
|
|
63
|
+
var differIndex = getDifferIndex(getSlice(value, 0, lastCursorIndex), getSlice(prevValue, 0, lastCursorIndex));
|
|
64
|
+
var differNumberArr = getNumberValue(getSlice(value, differIndex, lastCursorIndex)).split('');
|
|
65
|
+
var cursorPosition = differIndex;
|
|
66
|
+
var endIndex = format.length + lastCursorIndex;
|
|
67
|
+
var formatValue = format.replace(/\d/g, function (_match, index) {
|
|
68
|
+
if (index < differIndex) {
|
|
69
|
+
return prevValue[index];
|
|
70
|
+
}
|
|
71
|
+
if (!differNumberArr.length) {
|
|
72
|
+
return index >= endIndex ? prevValue[index] : placeholder;
|
|
73
|
+
}
|
|
74
|
+
cursorPosition = index + 1;
|
|
75
|
+
return differNumberArr.shift();
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
value: formatValue,
|
|
79
|
+
cursorPosition: cursorPosition
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputProps } from '../input/Input';
|
|
3
|
+
export interface InputPhoneProps extends Omit<InputProps<string>, 'onFocus' | 'onBlur' | 'onChange'> {
|
|
4
|
+
/**
|
|
5
|
+
* 输入框是否可以操作
|
|
6
|
+
*/
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 号码显示格式,以任意数字代替需要填入的数字位置
|
|
10
|
+
* 默认为(111)111-1111,表示会显示(xxx)xxx-xxxx格式的号码
|
|
11
|
+
*/
|
|
12
|
+
format?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 数字未填时的留空字符,默认为_
|
|
15
|
+
*/
|
|
16
|
+
placeholderChar?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 获得焦点的回调函数
|
|
19
|
+
* formatValue: 显示在输入框中的格式化后的电话号码
|
|
20
|
+
* phoneValue: 纯数字电话号码
|
|
21
|
+
*/
|
|
22
|
+
onFocus?: (formatValue: string, phoneValue: string, name?: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* 失去焦点的回调函数
|
|
25
|
+
* formatValue: 显示在输入框中的格式化后的电话号码
|
|
26
|
+
* phoneValue: 纯数字电话号码
|
|
27
|
+
*/
|
|
28
|
+
onBlur?: (formatValue: string, phoneValue: string, name?: string) => void;
|
|
29
|
+
/**
|
|
30
|
+
* 值修改后的回调函数,用于修改value属性
|
|
31
|
+
* formatValue: 显示在输入框中的格式化后的电话号码
|
|
32
|
+
* phoneValue: 纯数字电话号码
|
|
33
|
+
*/
|
|
34
|
+
onChange?: (formatValue: string, phoneValue: string, name?: string) => void;
|
|
35
|
+
}
|
|
36
|
+
interface InputPhoneState {
|
|
37
|
+
formatValue: string;
|
|
38
|
+
}
|
|
39
|
+
interface InputPhonePropsWithRef extends InputPhoneProps {
|
|
40
|
+
/**
|
|
41
|
+
* 此属性可以忽略, storybook问题
|
|
42
|
+
*/
|
|
43
|
+
upperRef: React.Ref<HTMLInputElement>;
|
|
44
|
+
}
|
|
45
|
+
export declare class InputPhoneNotRef extends React.Component<InputPhonePropsWithRef, InputPhoneState> {
|
|
46
|
+
prefixCls: string;
|
|
47
|
+
inputRef: React.RefObject<HTMLInputElement>;
|
|
48
|
+
prevFormatValue: string;
|
|
49
|
+
static defaultProps: {
|
|
50
|
+
defaultValue: string;
|
|
51
|
+
format: string;
|
|
52
|
+
placeholderChar: string;
|
|
53
|
+
};
|
|
54
|
+
constructor(props: InputPhonePropsWithRef);
|
|
55
|
+
static getDerivedStateFromProps(nextProps: InputPhoneProps, prevState: InputPhoneState): {
|
|
56
|
+
formatValue: any;
|
|
57
|
+
};
|
|
58
|
+
setInputCursor: (cursorPosition: any, timeout?: number) => void;
|
|
59
|
+
onFocus: (inputValue: string, name?: string) => void;
|
|
60
|
+
onBlur: (inputValue: string, name?: string) => void;
|
|
61
|
+
onChange: (inputValue: string, name?: string) => void;
|
|
62
|
+
render(): JSX.Element;
|
|
63
|
+
}
|
|
64
|
+
declare const InputPhone: React.ForwardRefExoticComponent<InputPhoneProps & React.RefAttributes<HTMLInputElement>>;
|
|
65
|
+
export default InputPhone;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
var __extends = this && this.__extends || function () {
|
|
2
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
3
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
4
|
+
__proto__: []
|
|
5
|
+
} instanceof Array && function (d, b) {
|
|
6
|
+
d.__proto__ = b;
|
|
7
|
+
} || function (d, b) {
|
|
8
|
+
for (var p in b) {
|
|
9
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
return _extendStatics(d, b);
|
|
13
|
+
};
|
|
14
|
+
return function (d, b) {
|
|
15
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
16
|
+
_extendStatics(d, b);
|
|
17
|
+
function __() {
|
|
18
|
+
this.constructor = d;
|
|
19
|
+
}
|
|
20
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
21
|
+
};
|
|
22
|
+
}();
|
|
23
|
+
var __assign = this && this.__assign || function () {
|
|
24
|
+
__assign = Object.assign || function (t) {
|
|
25
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
26
|
+
s = arguments[i];
|
|
27
|
+
for (var p in s) {
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
};
|
|
33
|
+
return __assign.apply(this, arguments);
|
|
34
|
+
};
|
|
35
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) {
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
39
|
+
}
|
|
40
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
};
|
|
45
|
+
import React from 'react';
|
|
46
|
+
import classNames from 'classnames';
|
|
47
|
+
import { composeRef } from '@autobest-ui/components';
|
|
48
|
+
import { isBlank } from '@autobest-ui/utils';
|
|
49
|
+
import Input from '../input/Input';
|
|
50
|
+
import { getFirstCursorPosition, getNumberValue, getPhoneFormat, getUpdatedValue } from './format';
|
|
51
|
+
var InputPhoneNotRef = /** @class */function (_super) {
|
|
52
|
+
__extends(InputPhoneNotRef, _super);
|
|
53
|
+
function InputPhoneNotRef(props) {
|
|
54
|
+
var _this = _super.call(this, props) || this;
|
|
55
|
+
_this.prefixCls = 'ab-input-phone';
|
|
56
|
+
_this.inputRef = /*#__PURE__*/React.createRef();
|
|
57
|
+
_this.setInputCursor = function (cursorPosition, timeout) {
|
|
58
|
+
if (!_this.inputRef.current) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (timeout) {
|
|
62
|
+
setTimeout(function () {
|
|
63
|
+
_this.inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
|
|
64
|
+
}, timeout);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
_this.inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
|
|
68
|
+
};
|
|
69
|
+
_this.onFocus = function (inputValue, name) {
|
|
70
|
+
var _a = _this.props,
|
|
71
|
+
onFocus = _a.onFocus,
|
|
72
|
+
format = _a.format,
|
|
73
|
+
placeholderChar = _a.placeholderChar;
|
|
74
|
+
var formatValue = inputValue;
|
|
75
|
+
if (onFocus) {
|
|
76
|
+
onFocus(formatValue, getNumberValue(formatValue), name);
|
|
77
|
+
}
|
|
78
|
+
if (isBlank(inputValue)) {
|
|
79
|
+
formatValue = getPhoneFormat('', format, placeholderChar);
|
|
80
|
+
_this.setState({
|
|
81
|
+
formatValue: formatValue
|
|
82
|
+
}, function () {
|
|
83
|
+
_this.setInputCursor(getFirstCursorPosition('', format, placeholderChar), 50);
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
_this.setInputCursor(getFirstCursorPosition(inputValue, format, placeholderChar), 50);
|
|
88
|
+
};
|
|
89
|
+
_this.onBlur = function (inputValue, name) {
|
|
90
|
+
if (_this.props.disabled) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
var formatValue = _this.state.formatValue;
|
|
94
|
+
var _a = _this.props,
|
|
95
|
+
format = _a.format,
|
|
96
|
+
placeholderChar = _a.placeholderChar,
|
|
97
|
+
onBlur = _a.onBlur;
|
|
98
|
+
if (formatValue === getPhoneFormat('', format, placeholderChar)) {
|
|
99
|
+
_this.setState({
|
|
100
|
+
formatValue: ''
|
|
101
|
+
});
|
|
102
|
+
if (onBlur) {
|
|
103
|
+
onBlur('', '', name);
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (onBlur) {
|
|
108
|
+
onBlur(inputValue, getNumberValue(inputValue), name);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
_this.onChange = function (inputValue, name) {
|
|
112
|
+
if (_this.props.disabled || !_this.inputRef.current) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
var _a = _this.props,
|
|
116
|
+
format = _a.format,
|
|
117
|
+
onChange = _a.onChange,
|
|
118
|
+
placeholderChar = _a.placeholderChar;
|
|
119
|
+
var _b = getUpdatedValue({
|
|
120
|
+
value: inputValue,
|
|
121
|
+
prevValue: _this.prevFormatValue,
|
|
122
|
+
format: format,
|
|
123
|
+
selectionEnd: _this.inputRef.current.selectionEnd,
|
|
124
|
+
placeholder: placeholderChar
|
|
125
|
+
}),
|
|
126
|
+
formatValue = _b.value,
|
|
127
|
+
cursorPosition = _b.cursorPosition;
|
|
128
|
+
_this.prevFormatValue = formatValue;
|
|
129
|
+
_this.setState({
|
|
130
|
+
formatValue: formatValue
|
|
131
|
+
}, function () {
|
|
132
|
+
_this.setInputCursor(cursorPosition);
|
|
133
|
+
});
|
|
134
|
+
if (onChange) {
|
|
135
|
+
onChange(formatValue, getNumberValue(formatValue), name);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var defaultValue = props.defaultValue,
|
|
139
|
+
format = props.format,
|
|
140
|
+
placeholderChar = props.placeholderChar;
|
|
141
|
+
_this.prevFormatValue = getPhoneFormat(defaultValue, format, placeholderChar);
|
|
142
|
+
_this.state = {
|
|
143
|
+
formatValue: isBlank(defaultValue) ? '' : _this.prevFormatValue
|
|
144
|
+
};
|
|
145
|
+
return _this;
|
|
146
|
+
}
|
|
147
|
+
InputPhoneNotRef.getDerivedStateFromProps = function (nextProps, prevState) {
|
|
148
|
+
if ('value' in nextProps) {
|
|
149
|
+
if (nextProps.value !== prevState.formatValue && (
|
|
150
|
+
// 兼容外部传入空string/null的情况, 只有当一个值非空时,才会重新重置State信息
|
|
151
|
+
!isBlank(nextProps.value) || !isBlank(prevState.formatValue))) {
|
|
152
|
+
return {
|
|
153
|
+
formatValue: getPhoneFormat(nextProps.value, nextProps.format, nextProps.placeholderChar)
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
};
|
|
159
|
+
InputPhoneNotRef.prototype.render = function () {
|
|
160
|
+
var cls = this.prefixCls;
|
|
161
|
+
var _a = this.props,
|
|
162
|
+
upperRef = _a.upperRef,
|
|
163
|
+
className = _a.className,
|
|
164
|
+
format = _a.format,
|
|
165
|
+
resetProps = __rest(_a, ["upperRef", "className", "format"]);
|
|
166
|
+
var formatValue = this.state.formatValue;
|
|
167
|
+
return /*#__PURE__*/React.createElement(Input, __assign({
|
|
168
|
+
ref: composeRef(this.inputRef, upperRef),
|
|
169
|
+
className: classNames(cls, className)
|
|
170
|
+
}, resetProps, {
|
|
171
|
+
value: formatValue,
|
|
172
|
+
onChange: this.onChange,
|
|
173
|
+
onBlur: this.onBlur,
|
|
174
|
+
onFocus: this.onFocus
|
|
175
|
+
}));
|
|
176
|
+
};
|
|
177
|
+
InputPhoneNotRef.defaultProps = {
|
|
178
|
+
defaultValue: '',
|
|
179
|
+
format: '(111)111-1111',
|
|
180
|
+
placeholderChar: '_'
|
|
181
|
+
};
|
|
182
|
+
return InputPhoneNotRef;
|
|
183
|
+
}(React.Component);
|
|
184
|
+
export { InputPhoneNotRef };
|
|
185
|
+
var InputPhone = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
186
|
+
return /*#__PURE__*/React.createElement(InputPhoneNotRef, __assign({}, props, {
|
|
187
|
+
upperRef: ref
|
|
188
|
+
}));
|
|
189
|
+
});
|
|
190
|
+
export default InputPhone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ab-input{display:flex;align-items:center;border:1px solid #ccc;overflow:hidden;position:relative;border-radius:.04rem;padding:.04rem}.ab-input-prefix,.ab-input-suffix{padding-left:.04rem;padding-right:.04rem}.ab-input.ab-input-enter,.ab-input.ab-input-focus{border-color:#348fee}.ab-input.ab-input-focus{box-shadow:0 0 4px #348fee}.ab-input.ab-input-disabled .ab-input-control{cursor:not-allowed}.ab-input-control{appearance:none;display:block;outline:0;border:none;width:100%;height:100%;padding:.02rem;background-color:transparent;font-size:inherit}
|
package/esm/modal/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
|
|
3
3
|
declare type PrevPopupSize = {
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
@@ -92,8 +92,8 @@ declare class Modal extends React.Component<ModalProps, ModalStates> {
|
|
|
92
92
|
maskClosable: boolean;
|
|
93
93
|
hiddenScroll: boolean;
|
|
94
94
|
};
|
|
95
|
-
clickOutsideHandler:
|
|
96
|
-
touchOutsideHandler:
|
|
95
|
+
clickOutsideHandler: AddListenerEventRemoveHandler;
|
|
96
|
+
touchOutsideHandler: AddListenerEventRemoveHandler;
|
|
97
97
|
popupTimer: any;
|
|
98
98
|
affixTimer: any;
|
|
99
99
|
popupRef: React.RefObject<HTMLDivElement>;
|
package/esm/modal/index.js
CHANGED
|
@@ -258,11 +258,11 @@ var Modal = /** @class */function (_super) {
|
|
|
258
258
|
Modal.prototype.clearOutsideHandler = function () {
|
|
259
259
|
this.clearPopupTimer();
|
|
260
260
|
if (this.clickOutsideHandler) {
|
|
261
|
-
this.clickOutsideHandler
|
|
261
|
+
this.clickOutsideHandler();
|
|
262
262
|
this.clickOutsideHandler = null;
|
|
263
263
|
}
|
|
264
264
|
if (this.touchOutsideHandler) {
|
|
265
|
-
this.touchOutsideHandler
|
|
265
|
+
this.touchOutsideHandler();
|
|
266
266
|
this.touchOutsideHandler = null;
|
|
267
267
|
}
|
|
268
268
|
};
|
package/esm/move/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
|
|
3
3
|
import { Position } from './utils';
|
|
4
4
|
export interface MoveProps {
|
|
5
5
|
/**
|
|
@@ -82,11 +82,11 @@ declare class Move extends React.Component<MoveProps> {
|
|
|
82
82
|
isTouchScale: boolean;
|
|
83
83
|
isForceUpdatePlacement: boolean;
|
|
84
84
|
moveRef: React.RefObject<HTMLElement>;
|
|
85
|
-
resizeHandler:
|
|
86
|
-
startHandler:
|
|
87
|
-
mousewheelHandler:
|
|
88
|
-
moveHandler:
|
|
89
|
-
endHandler:
|
|
85
|
+
resizeHandler: AddListenerEventRemoveHandler;
|
|
86
|
+
startHandler: AddListenerEventRemoveHandler;
|
|
87
|
+
mousewheelHandler: AddListenerEventRemoveHandler;
|
|
88
|
+
moveHandler: AddListenerEventRemoveHandler;
|
|
89
|
+
endHandler: AddListenerEventRemoveHandler;
|
|
90
90
|
updateTimer: any;
|
|
91
91
|
componentDidMount(): void;
|
|
92
92
|
componentDidUpdate(prevProps?: MoveProps): void;
|
package/esm/move/index.js
CHANGED
|
@@ -310,26 +310,26 @@ var Move = /** @class */function (_super) {
|
|
|
310
310
|
Move.prototype.componentWillUnmount = function () {
|
|
311
311
|
clearTimeout(this.updateTimer);
|
|
312
312
|
if (this.startHandler) {
|
|
313
|
-
this.startHandler
|
|
313
|
+
this.startHandler();
|
|
314
314
|
this.startHandler = null;
|
|
315
315
|
}
|
|
316
316
|
if (this.mousewheelHandler) {
|
|
317
|
-
this.mousewheelHandler
|
|
317
|
+
this.mousewheelHandler();
|
|
318
318
|
this.mousewheelHandler = null;
|
|
319
319
|
}
|
|
320
320
|
if (this.resizeHandler) {
|
|
321
|
-
this.resizeHandler
|
|
321
|
+
this.resizeHandler();
|
|
322
322
|
this.resizeHandler = null;
|
|
323
323
|
}
|
|
324
324
|
this.clearHandler();
|
|
325
325
|
};
|
|
326
326
|
Move.prototype.clearHandler = function () {
|
|
327
327
|
if (this.moveHandler) {
|
|
328
|
-
this.moveHandler
|
|
328
|
+
this.moveHandler();
|
|
329
329
|
this.moveHandler = null;
|
|
330
330
|
}
|
|
331
331
|
if (this.endHandler) {
|
|
332
|
-
this.endHandler
|
|
332
|
+
this.endHandler();
|
|
333
333
|
this.endHandler = null;
|
|
334
334
|
}
|
|
335
335
|
};
|
package/esm/popover/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface PopoverProps extends Pick<TriggerProps, Exclude<keyof TriggerPr
|
|
|
32
32
|
}
|
|
33
33
|
export declare type PopoverPlacement = TriggerPlacement;
|
|
34
34
|
export declare type PopoverTriggerType = TriggerType;
|
|
35
|
-
declare function Popover({ theme, innerClassName, closeClassName, arrowClassName, hiddenClose, tip, closeIcon, ...extraProps }: PopoverProps): JSX.Element;
|
|
35
|
+
declare function Popover({ theme, innerClassName, closeClassName, arrowClassName, hiddenClose, tip, closeIcon, maxHeight, ...extraProps }: PopoverProps): JSX.Element;
|
|
36
36
|
declare namespace Popover {
|
|
37
37
|
var defaultProps: {
|
|
38
38
|
hiddenClose: boolean;
|
package/esm/popover/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import classNames from 'classnames';
|
|
25
|
+
import { isBlank } from '@autobest-ui/utils';
|
|
25
26
|
import Trigger from '../trigger';
|
|
26
27
|
var prefixCls = 'ab-popover';
|
|
27
28
|
function Popover(_a) {
|
|
@@ -33,7 +34,8 @@ function Popover(_a) {
|
|
|
33
34
|
hiddenClose = _a.hiddenClose,
|
|
34
35
|
tip = _a.tip,
|
|
35
36
|
closeIcon = _a.closeIcon,
|
|
36
|
-
|
|
37
|
+
maxHeight = _a.maxHeight,
|
|
38
|
+
extraProps = __rest(_a, ["theme", "innerClassName", "closeClassName", "arrowClassName", "hiddenClose", "tip", "closeIcon", "maxHeight"]);
|
|
37
39
|
var triggerEl = React.useRef(null);
|
|
38
40
|
var _c = React.useState({}),
|
|
39
41
|
arrowStyle = _c[0],
|
|
@@ -71,7 +73,10 @@ function Popover(_a) {
|
|
|
71
73
|
className: classNames("".concat(cls, "-arrow"), arrowClassName),
|
|
72
74
|
style: arrowStyle
|
|
73
75
|
}), /*#__PURE__*/React.createElement("div", {
|
|
74
|
-
className: innerClass
|
|
76
|
+
className: innerClass,
|
|
77
|
+
style: !isBlank(maxHeight) ? {
|
|
78
|
+
maxHeight: "".concat(maxHeight, "px")
|
|
79
|
+
} : undefined
|
|
75
80
|
}, tip));
|
|
76
81
|
}
|
|
77
82
|
return /*#__PURE__*/React.createElement(Trigger, __assign({}, extraProps, {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __assign = this && this.__assign || function () {
|
|
2
|
+
__assign = Object.assign || function (t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) {
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
15
|
+
import { isEmptyObject } from '@autobest-ui/utils';
|
|
16
|
+
import RadioGroupContext from './context';
|
|
17
|
+
var cls = 'ab-radio';
|
|
18
|
+
var Radio = function Radio(props) {
|
|
19
|
+
var _a;
|
|
20
|
+
var _b = props.checked,
|
|
21
|
+
propsChecked = _b === void 0 ? false : _b,
|
|
22
|
+
name = props.name,
|
|
23
|
+
onChange = props.onChange,
|
|
24
|
+
children = props.children,
|
|
25
|
+
disabled = props.disabled,
|
|
26
|
+
value = props.value,
|
|
27
|
+
className = props.className;
|
|
28
|
+
var _c = useState(propsChecked),
|
|
29
|
+
checked = _c[0],
|
|
30
|
+
setChecked = _c[1];
|
|
31
|
+
var groupContext = useContext(RadioGroupContext);
|
|
32
|
+
var mergedProps = isEmptyObject(groupContext) ? {
|
|
33
|
+
name: name,
|
|
34
|
+
disabled: disabled
|
|
35
|
+
} : {
|
|
36
|
+
name: groupContext.name,
|
|
37
|
+
disabled: 'disabled' in props ? disabled : groupContext.disabled
|
|
38
|
+
};
|
|
39
|
+
if ('checked' in props && propsChecked !== checked) {
|
|
40
|
+
setChecked(propsChecked);
|
|
41
|
+
}
|
|
42
|
+
useEffect(function () {
|
|
43
|
+
// radioGroup
|
|
44
|
+
if ('value' in groupContext) {
|
|
45
|
+
setChecked(groupContext.value === value);
|
|
46
|
+
}
|
|
47
|
+
}, [groupContext, value]);
|
|
48
|
+
var onRadioChange = function onRadioChange(e) {
|
|
49
|
+
if (mergedProps.disabled) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (onChange) {
|
|
53
|
+
onChange(e, mergedProps.name);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
// radioGroup
|
|
57
|
+
if (groupContext.onChange) {
|
|
58
|
+
groupContext.onChange(e.target.value, mergedProps.name);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setChecked(!checked);
|
|
62
|
+
};
|
|
63
|
+
var onClick = function onClick(e) {
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
};
|
|
66
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
67
|
+
onClick: onClick,
|
|
68
|
+
className: classNames(cls, (_a = {}, _a["".concat(cls, "-disabled")] = mergedProps.disabled, _a["".concat(cls, "-checked")] = checked, _a), groupContext.className, className)
|
|
69
|
+
}, /*#__PURE__*/React.createElement("input", __assign({
|
|
70
|
+
type: "radio",
|
|
71
|
+
checked: checked,
|
|
72
|
+
value: value,
|
|
73
|
+
onChange: onRadioChange
|
|
74
|
+
}, mergedProps)), /*#__PURE__*/React.createElement("span", {
|
|
75
|
+
className: "".concat(cls, "-control")
|
|
76
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
77
|
+
className: "".concat(cls, "-child")
|
|
78
|
+
}, children));
|
|
79
|
+
};
|
|
80
|
+
export default Radio;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { RadioGroupProps, RadioValue } from './interface';
|
|
3
|
+
interface RadioGroupState {
|
|
4
|
+
value: RadioValue;
|
|
5
|
+
}
|
|
6
|
+
declare class RadioGroup extends Component<RadioGroupProps, RadioGroupState> {
|
|
7
|
+
constructor(props: any);
|
|
8
|
+
static getDerivedStateFromProps(nextProps: RadioGroupProps, prevState: RadioGroupState): {
|
|
9
|
+
value: RadioValue;
|
|
10
|
+
};
|
|
11
|
+
onRadioChange: (v: RadioValue, n: string) => void;
|
|
12
|
+
renderRadioGroup: () => JSX.Element;
|
|
13
|
+
renderRadioList: () => JSX.Element;
|
|
14
|
+
render(): JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __extends = this && this.__extends || function () {
|
|
2
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
3
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
4
|
+
__proto__: []
|
|
5
|
+
} instanceof Array && function (d, b) {
|
|
6
|
+
d.__proto__ = b;
|
|
7
|
+
} || function (d, b) {
|
|
8
|
+
for (var p in b) {
|
|
9
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
return _extendStatics(d, b);
|
|
13
|
+
};
|
|
14
|
+
return function (d, b) {
|
|
15
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
16
|
+
_extendStatics(d, b);
|
|
17
|
+
function __() {
|
|
18
|
+
this.constructor = d;
|
|
19
|
+
}
|
|
20
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
21
|
+
};
|
|
22
|
+
}();
|
|
23
|
+
import React, { Component, Fragment } from 'react';
|
|
24
|
+
import { isEmptyArray, isUndef } from '@autobest-ui/utils';
|
|
25
|
+
import { RadioGroupContextProvider } from './context';
|
|
26
|
+
import Radio from './Radio';
|
|
27
|
+
var cls = 'ab-radio';
|
|
28
|
+
function getRadioProp(radioProp, radioGroupProp) {
|
|
29
|
+
return isUndef(radioProp) ? radioGroupProp : radioProp;
|
|
30
|
+
}
|
|
31
|
+
var RadioGroup = /** @class */function (_super) {
|
|
32
|
+
__extends(RadioGroup, _super);
|
|
33
|
+
function RadioGroup(props) {
|
|
34
|
+
var _this = _super.call(this, props) || this;
|
|
35
|
+
_this.onRadioChange = function (v, n) {
|
|
36
|
+
var onChange = _this.props.onChange;
|
|
37
|
+
if (onChange) {
|
|
38
|
+
onChange(v, n);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
_this.setState({
|
|
42
|
+
value: v
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
_this.renderRadioGroup = function () {
|
|
46
|
+
var _a = _this.props,
|
|
47
|
+
name = _a.name,
|
|
48
|
+
children = _a.children,
|
|
49
|
+
disabled = _a.disabled;
|
|
50
|
+
var value = _this.state.value;
|
|
51
|
+
return /*#__PURE__*/React.createElement(RadioGroupContextProvider, {
|
|
52
|
+
value: {
|
|
53
|
+
name: name,
|
|
54
|
+
value: value,
|
|
55
|
+
disabled: disabled,
|
|
56
|
+
onChange: _this.onRadioChange,
|
|
57
|
+
className: "".concat(cls, "-item")
|
|
58
|
+
}
|
|
59
|
+
}, children);
|
|
60
|
+
};
|
|
61
|
+
_this.renderRadioList = function () {
|
|
62
|
+
var _a = _this.props,
|
|
63
|
+
name = _a.name,
|
|
64
|
+
options = _a.options,
|
|
65
|
+
disabled = _a.disabled;
|
|
66
|
+
var value = _this.state.value;
|
|
67
|
+
if (isEmptyArray(options)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return /*#__PURE__*/React.createElement(Fragment, null, options.map(function (item) {
|
|
71
|
+
return /*#__PURE__*/React.createElement(Radio, {
|
|
72
|
+
key: item.value,
|
|
73
|
+
className: "".concat(cls, "-item"),
|
|
74
|
+
name: name,
|
|
75
|
+
value: item.value,
|
|
76
|
+
disabled: getRadioProp(item.disabled, disabled),
|
|
77
|
+
checked: value === item.value,
|
|
78
|
+
onChange: function onChange(e, n) {
|
|
79
|
+
return _this.onRadioChange(e.target.value, n);
|
|
80
|
+
}
|
|
81
|
+
}, item.name);
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
_this.state = {
|
|
85
|
+
value: props.defaultValue
|
|
86
|
+
};
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
RadioGroup.getDerivedStateFromProps = function (nextProps, prevState) {
|
|
90
|
+
if ('value' in nextProps && nextProps.value !== prevState.value) {
|
|
91
|
+
return {
|
|
92
|
+
value: nextProps.value
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
};
|
|
97
|
+
RadioGroup.prototype.render = function () {
|
|
98
|
+
var _a = this.props.direction,
|
|
99
|
+
direction = _a === void 0 ? 'horizontal' : _a;
|
|
100
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
className: "".concat(cls, "-group-").concat(direction)
|
|
102
|
+
}, 'options' in this.props ? this.renderRadioList() : this.renderRadioGroup());
|
|
103
|
+
};
|
|
104
|
+
return RadioGroup;
|
|
105
|
+
}(Component);
|
|
106
|
+
export default RadioGroup;
|