@autobest-ui/components 2.5.3 → 2.6.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/index.d.ts +2 -0
- package/esm/index.js +1 -0
- package/esm/input/Adorn.d.ts +37 -0
- package/esm/input/Adorn.js +67 -0
- package/esm/input/Input.d.ts +65 -0
- package/esm/input/Input.js +180 -0
- package/esm/input/TextArea.d.ts +68 -0
- package/esm/input/TextArea.js +172 -0
- package/esm/input/index.d.ts +4 -0
- package/esm/input/index.js +2 -0
- package/esm/input/style/adorn.css +0 -0
- package/esm/input/style/input.css +1 -0
- package/esm/input/style/textArea.css +1 -0
- package/esm/input-number/ControlArrow.js +1 -3
- package/esm/input-number/index.d.ts +6 -24
- package/esm/input-number/index.js +35 -68
- package/esm/input-number/style/index.css +1 -1
- package/esm/style.css +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +13 -0
- package/lib/input/Adorn.d.ts +37 -0
- package/lib/input/Adorn.js +78 -0
- package/lib/input/Input.d.ts +65 -0
- package/lib/input/Input.js +188 -0
- package/lib/input/TextArea.d.ts +68 -0
- package/lib/input/TextArea.js +180 -0
- package/lib/input/index.d.ts +4 -0
- package/lib/input/index.js +20 -0
- package/lib/input/style/adorn.css +0 -0
- package/lib/input/style/input.css +1 -0
- package/lib/input/style/textArea.css +1 -0
- package/lib/input-number/ControlArrow.js +1 -3
- package/lib/input-number/index.d.ts +6 -24
- package/lib/input-number/index.js +35 -68
- package/lib/input-number/style/index.css +1 -1
- package/lib/style.css +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.InputNotRef = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _utils = require("@autobest-ui/utils");
|
|
10
|
+
var _Adorn = _interopRequireDefault(require("./Adorn"));
|
|
11
|
+
var __extends = void 0 && (void 0).__extends || function () {
|
|
12
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
13
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
14
|
+
__proto__: []
|
|
15
|
+
} instanceof Array && function (d, b) {
|
|
16
|
+
d.__proto__ = b;
|
|
17
|
+
} || function (d, b) {
|
|
18
|
+
for (var p in b) {
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return _extendStatics(d, b);
|
|
23
|
+
};
|
|
24
|
+
return function (d, b) {
|
|
25
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
26
|
+
_extendStatics(d, b);
|
|
27
|
+
function __() {
|
|
28
|
+
this.constructor = d;
|
|
29
|
+
}
|
|
30
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
|
+
};
|
|
32
|
+
}();
|
|
33
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
34
|
+
__assign = Object.assign || function (t) {
|
|
35
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
36
|
+
s = arguments[i];
|
|
37
|
+
for (var p in s) {
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return t;
|
|
42
|
+
};
|
|
43
|
+
return __assign.apply(this, arguments);
|
|
44
|
+
};
|
|
45
|
+
var InputNotRef = /** @class */function (_super) {
|
|
46
|
+
__extends(InputNotRef, _super);
|
|
47
|
+
function InputNotRef(props) {
|
|
48
|
+
var _this = _super.call(this, props) || this;
|
|
49
|
+
_this.prefixCls = 'ab-input';
|
|
50
|
+
_this.inputRef = /*#__PURE__*/_react.default.createRef();
|
|
51
|
+
_this.isFileUpload = function () {
|
|
52
|
+
return _this.props.type === 'file';
|
|
53
|
+
};
|
|
54
|
+
_this.getFileInfo = function (element) {
|
|
55
|
+
return element && element.files && element.files.length ? element.files[0] : undefined;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 修改value值的回调
|
|
59
|
+
* @param ev
|
|
60
|
+
*/
|
|
61
|
+
_this.onChange = function (ev) {
|
|
62
|
+
if (_this.props.disabled) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
var _a = _this.props,
|
|
66
|
+
onChange = _a.onChange,
|
|
67
|
+
name = _a.name;
|
|
68
|
+
if (_this.isFileUpload()) {
|
|
69
|
+
if (onChange) {
|
|
70
|
+
onChange(_this.getFileInfo(ev.target), name);
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
var value = ev.target.value;
|
|
75
|
+
if (onChange) {
|
|
76
|
+
onChange(value, name);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
_this.setState({
|
|
80
|
+
value: value
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
_this.onFocus = function (ev) {
|
|
84
|
+
var _a = _this.props,
|
|
85
|
+
name = _a.name,
|
|
86
|
+
onFocus = _a.onFocus;
|
|
87
|
+
if (_this.isFileUpload()) {
|
|
88
|
+
if (onFocus) {
|
|
89
|
+
onFocus(_this.getFileInfo(ev.target), name);
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
var value = ev.target.value;
|
|
94
|
+
if (onFocus) {
|
|
95
|
+
onFocus(value, name);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
_this.onBlur = function (ev) {
|
|
99
|
+
var _a = _this.props,
|
|
100
|
+
name = _a.name,
|
|
101
|
+
onBlur = _a.onBlur;
|
|
102
|
+
if (_this.isFileUpload()) {
|
|
103
|
+
if (onBlur) {
|
|
104
|
+
onBlur(_this.getFileInfo(ev.target), name);
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
var value = ev.target.value;
|
|
109
|
+
if (onBlur) {
|
|
110
|
+
onBlur(value, name);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
_this.state = {
|
|
114
|
+
value: props.defaultValue || ''
|
|
115
|
+
};
|
|
116
|
+
return _this;
|
|
117
|
+
}
|
|
118
|
+
InputNotRef.getDerivedStateFromProps = function (nextProps, prevStates) {
|
|
119
|
+
var nextState = {};
|
|
120
|
+
// 判断是否为受控方式
|
|
121
|
+
if ('value' in nextProps && nextProps.type !== 'file') {
|
|
122
|
+
if (nextProps.value !== prevStates.value) {
|
|
123
|
+
nextState.value = nextProps.value;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if ((0, _utils.isEmptyObject)(nextState)) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
return nextState;
|
|
130
|
+
};
|
|
131
|
+
InputNotRef.prototype.componentDidMount = function () {
|
|
132
|
+
// 设置input焦点
|
|
133
|
+
if (this.props.autoFocus) {
|
|
134
|
+
var element = this.inputRef.current;
|
|
135
|
+
if (!element) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
element.focus();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
InputNotRef.prototype.render = function () {
|
|
142
|
+
var cls = this.prefixCls;
|
|
143
|
+
var _a = this.props,
|
|
144
|
+
upperRef = _a.upperRef,
|
|
145
|
+
placeholder = _a.placeholder,
|
|
146
|
+
disabled = _a.disabled,
|
|
147
|
+
style = _a.style,
|
|
148
|
+
type = _a.type,
|
|
149
|
+
accept = _a.accept,
|
|
150
|
+
className = _a.className,
|
|
151
|
+
prefix = _a.prefix,
|
|
152
|
+
suffix = _a.suffix;
|
|
153
|
+
var value = this.state.value;
|
|
154
|
+
var isFileUpload = this.isFileUpload();
|
|
155
|
+
return /*#__PURE__*/_react.default.createElement(_Adorn.default, {
|
|
156
|
+
prefixCls: cls,
|
|
157
|
+
onFocus: this.onFocus,
|
|
158
|
+
onBlur: this.onBlur,
|
|
159
|
+
className: className,
|
|
160
|
+
disabled: disabled,
|
|
161
|
+
prefix: prefix,
|
|
162
|
+
suffix: suffix
|
|
163
|
+
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
164
|
+
className: "".concat(cls, "-control"),
|
|
165
|
+
ref: (0, _utils.composeRef)(this.inputRef, upperRef),
|
|
166
|
+
type: type,
|
|
167
|
+
placeholder: placeholder,
|
|
168
|
+
disabled: disabled,
|
|
169
|
+
accept: accept,
|
|
170
|
+
style: style,
|
|
171
|
+
value: isFileUpload ? undefined : value || '',
|
|
172
|
+
onChange: this.onChange
|
|
173
|
+
}));
|
|
174
|
+
};
|
|
175
|
+
InputNotRef.defaultProps = {
|
|
176
|
+
defaultValue: '',
|
|
177
|
+
type: 'text'
|
|
178
|
+
};
|
|
179
|
+
return InputNotRef;
|
|
180
|
+
}(_react.default.Component);
|
|
181
|
+
exports.InputNotRef = InputNotRef;
|
|
182
|
+
var Input = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
183
|
+
return /*#__PURE__*/_react.default.createElement(InputNotRef, __assign({}, props, {
|
|
184
|
+
upperRef: ref
|
|
185
|
+
}));
|
|
186
|
+
});
|
|
187
|
+
var _default = Input;
|
|
188
|
+
exports.default = _default;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AdornProps } from './Adorn';
|
|
3
|
+
export interface TextAreaProps extends Omit<AdornProps, 'prefixCls' | 'children' | 'onBlur' | 'onFocus' | 'suffix'>, Omit<React.TextareaHTMLAttributes<any>, 'onChange' | 'onBlur' | 'onFocus' | 'prefix'> {
|
|
4
|
+
/**
|
|
5
|
+
* 输入框默认值,用于非受控组件,配合ref使用
|
|
6
|
+
*/
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 输入框中的值
|
|
10
|
+
*/
|
|
11
|
+
value?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 输入框的别名
|
|
14
|
+
*/
|
|
15
|
+
name?: string;
|
|
16
|
+
/**
|
|
17
|
+
* 初始化后自动获取焦点
|
|
18
|
+
*/
|
|
19
|
+
autoFocus?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 字符串最大值
|
|
22
|
+
*/
|
|
23
|
+
maxlength?: number;
|
|
24
|
+
/**
|
|
25
|
+
* 值修改后的回调函数,用于修改value属性
|
|
26
|
+
*/
|
|
27
|
+
onChange?: (value: string | undefined, name?: string) => void;
|
|
28
|
+
/**
|
|
29
|
+
* 获得焦点的回调函数
|
|
30
|
+
*/
|
|
31
|
+
onFocus?: (value: string | undefined, name?: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* 失去焦点的回调函数
|
|
34
|
+
*/
|
|
35
|
+
onBlur?: (value: string | undefined, name?: string) => void;
|
|
36
|
+
}
|
|
37
|
+
interface TextareaStates {
|
|
38
|
+
value: string | undefined;
|
|
39
|
+
currentLength: number;
|
|
40
|
+
}
|
|
41
|
+
interface TextAreaPropsWithRef extends TextAreaProps {
|
|
42
|
+
/**
|
|
43
|
+
* 此属性可以忽略, storybook问题
|
|
44
|
+
*/
|
|
45
|
+
upperRef: React.Ref<HTMLTextAreaElement>;
|
|
46
|
+
}
|
|
47
|
+
export declare class TextAreaNotRef extends React.Component<TextAreaPropsWithRef, TextareaStates> {
|
|
48
|
+
prefixCls: string;
|
|
49
|
+
textareaRef: React.RefObject<HTMLTextAreaElement>;
|
|
50
|
+
static defaultProps: {
|
|
51
|
+
defaultValue: string;
|
|
52
|
+
maxlength: number;
|
|
53
|
+
};
|
|
54
|
+
constructor(props: TextAreaPropsWithRef);
|
|
55
|
+
static getDerivedStateFromProps(nextProps: TextAreaPropsWithRef, prevStates: TextareaStates): TextareaStates;
|
|
56
|
+
componentDidMount(): void;
|
|
57
|
+
/**
|
|
58
|
+
* 修改value值的回调
|
|
59
|
+
* @param ev
|
|
60
|
+
*/
|
|
61
|
+
onChange: (ev: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
62
|
+
onFocus: (ev: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
63
|
+
onBlur: (ev: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
64
|
+
renderSuffix(): React.ReactElement;
|
|
65
|
+
render(): JSX.Element;
|
|
66
|
+
}
|
|
67
|
+
declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
68
|
+
export default TextArea;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.TextAreaNotRef = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _utils = require("@autobest-ui/utils");
|
|
10
|
+
var _Adorn = _interopRequireDefault(require("./Adorn"));
|
|
11
|
+
var __extends = void 0 && (void 0).__extends || function () {
|
|
12
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
13
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
14
|
+
__proto__: []
|
|
15
|
+
} instanceof Array && function (d, b) {
|
|
16
|
+
d.__proto__ = b;
|
|
17
|
+
} || function (d, b) {
|
|
18
|
+
for (var p in b) {
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return _extendStatics(d, b);
|
|
23
|
+
};
|
|
24
|
+
return function (d, b) {
|
|
25
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
26
|
+
_extendStatics(d, b);
|
|
27
|
+
function __() {
|
|
28
|
+
this.constructor = d;
|
|
29
|
+
}
|
|
30
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
|
+
};
|
|
32
|
+
}();
|
|
33
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
34
|
+
__assign = Object.assign || function (t) {
|
|
35
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
36
|
+
s = arguments[i];
|
|
37
|
+
for (var p in s) {
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return t;
|
|
42
|
+
};
|
|
43
|
+
return __assign.apply(this, arguments);
|
|
44
|
+
};
|
|
45
|
+
function getValueLength(value) {
|
|
46
|
+
return (0, _utils.isBlank)(value) ? 0 : value.length;
|
|
47
|
+
}
|
|
48
|
+
var TextAreaNotRef = /** @class */function (_super) {
|
|
49
|
+
__extends(TextAreaNotRef, _super);
|
|
50
|
+
function TextAreaNotRef(props) {
|
|
51
|
+
var _this = _super.call(this, props) || this;
|
|
52
|
+
_this.prefixCls = 'ab-textarea';
|
|
53
|
+
_this.textareaRef = /*#__PURE__*/_react.default.createRef();
|
|
54
|
+
/**
|
|
55
|
+
* 修改value值的回调
|
|
56
|
+
* @param ev
|
|
57
|
+
*/
|
|
58
|
+
_this.onChange = function (ev) {
|
|
59
|
+
if (_this.props.disabled) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
var value = ev.target.value;
|
|
63
|
+
if (_this.props.maxlength > 0) {
|
|
64
|
+
var currentLength = getValueLength(value);
|
|
65
|
+
if (_this.props.maxlength && currentLength > _this.props.maxlength) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
_this.setState({
|
|
69
|
+
currentLength: currentLength
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
var _a = _this.props,
|
|
73
|
+
onChange = _a.onChange,
|
|
74
|
+
name = _a.name;
|
|
75
|
+
if (onChange) {
|
|
76
|
+
onChange(value, name);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
_this.setState({
|
|
80
|
+
value: value
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
_this.onFocus = function (ev) {
|
|
84
|
+
var _a = _this.props,
|
|
85
|
+
name = _a.name,
|
|
86
|
+
onFocus = _a.onFocus;
|
|
87
|
+
var value = ev.target.value;
|
|
88
|
+
if (onFocus) {
|
|
89
|
+
onFocus(value, name);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
_this.onBlur = function (ev) {
|
|
93
|
+
var value = ev.target.value;
|
|
94
|
+
var _a = _this.props,
|
|
95
|
+
name = _a.name,
|
|
96
|
+
onBlur = _a.onBlur;
|
|
97
|
+
if (onBlur) {
|
|
98
|
+
onBlur(value, name);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var value = props.defaultValue || '';
|
|
102
|
+
_this.state = {
|
|
103
|
+
value: value,
|
|
104
|
+
currentLength: getValueLength(value)
|
|
105
|
+
};
|
|
106
|
+
return _this;
|
|
107
|
+
}
|
|
108
|
+
TextAreaNotRef.getDerivedStateFromProps = function (nextProps, prevStates) {
|
|
109
|
+
var nextState = {};
|
|
110
|
+
// 判断是否为受控方式
|
|
111
|
+
if ('value' in nextProps) {
|
|
112
|
+
if (nextProps.value !== prevStates.value) {
|
|
113
|
+
nextState.value = nextProps.value;
|
|
114
|
+
nextState.currentLength = getValueLength(nextProps.value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if ((0, _utils.isEmptyObject)(nextState)) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return nextState;
|
|
121
|
+
};
|
|
122
|
+
TextAreaNotRef.prototype.componentDidMount = function () {
|
|
123
|
+
// 设置Textarea焦点
|
|
124
|
+
if (this.props.autoFocus) {
|
|
125
|
+
var element = this.textareaRef.current;
|
|
126
|
+
if (!element) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
element.focus();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
TextAreaNotRef.prototype.renderSuffix = function () {
|
|
133
|
+
var maxlength = this.props.maxlength;
|
|
134
|
+
if (!maxlength || maxlength < 0) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, this.state.currentLength, "/", maxlength);
|
|
138
|
+
};
|
|
139
|
+
TextAreaNotRef.prototype.render = function () {
|
|
140
|
+
var cls = this.prefixCls;
|
|
141
|
+
var _a = this.props,
|
|
142
|
+
upperRef = _a.upperRef,
|
|
143
|
+
placeholder = _a.placeholder,
|
|
144
|
+
disabled = _a.disabled,
|
|
145
|
+
style = _a.style,
|
|
146
|
+
className = _a.className,
|
|
147
|
+
prefix = _a.prefix;
|
|
148
|
+
var value = this.state.value;
|
|
149
|
+
return /*#__PURE__*/_react.default.createElement(_Adorn.default, {
|
|
150
|
+
prefixCls: cls,
|
|
151
|
+
onFocus: this.onFocus,
|
|
152
|
+
onBlur: this.onBlur,
|
|
153
|
+
className: className,
|
|
154
|
+
disabled: disabled,
|
|
155
|
+
prefix: prefix,
|
|
156
|
+
suffix: this.renderSuffix()
|
|
157
|
+
}, /*#__PURE__*/_react.default.createElement("textarea", {
|
|
158
|
+
className: "".concat(cls, "-control"),
|
|
159
|
+
ref: (0, _utils.composeRef)(this.textareaRef, upperRef),
|
|
160
|
+
placeholder: placeholder,
|
|
161
|
+
disabled: disabled,
|
|
162
|
+
style: style,
|
|
163
|
+
value: value || '',
|
|
164
|
+
onChange: this.onChange
|
|
165
|
+
}));
|
|
166
|
+
};
|
|
167
|
+
TextAreaNotRef.defaultProps = {
|
|
168
|
+
defaultValue: '',
|
|
169
|
+
maxlength: 0
|
|
170
|
+
};
|
|
171
|
+
return TextAreaNotRef;
|
|
172
|
+
}(_react.default.Component);
|
|
173
|
+
exports.TextAreaNotRef = TextAreaNotRef;
|
|
174
|
+
var TextArea = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
175
|
+
return /*#__PURE__*/_react.default.createElement(TextAreaNotRef, __assign({}, props, {
|
|
176
|
+
upperRef: ref
|
|
177
|
+
}));
|
|
178
|
+
});
|
|
179
|
+
var _default = TextArea;
|
|
180
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "Input", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _Input.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "TextArea", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _TextArea.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _Input = _interopRequireDefault(require("./Input"));
|
|
20
|
+
var _TextArea = _interopRequireDefault(require("./TextArea"));
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ab-input{display:flex;align-items:center;border:1px solid #ccc;overflow:hidden;position:relative;border-radius:.04rem}.ab-input-prefix{padding-left:.06rem}.ab-input-suffix{padding-right:.06rem}.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:.06rem;background-color:transparent;font-size:inherit}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ab-textarea{display:flex;align-items:center;border:1px solid #ccc;overflow:hidden;position:relative;border-radius:.04rem}.ab-textarea-prefix{padding-left:.06rem}.ab-textarea.ab-textarea-enter,.ab-textarea.ab-textarea-focus{border-color:#348fee}.ab-textarea.ab-textarea-focus{box-shadow:0 0 4px #348fee}.ab-textarea.ab-textarea-disabled .ab-textarea-control{cursor:not-allowed}.ab-textarea-control{resize:none;appearance:none;display:block;outline:0;border:none;width:100%;min-height:1.2rem;height:100%;padding:.06rem;background-color:transparent;font-size:inherit;line-height:1.4}.ab-textarea-suffix{position:absolute;right:.08rem;bottom:.06rem;color:#aaa;font-size:.13rem;padding-right:0}
|
|
@@ -23,9 +23,7 @@ function ArrowIcon(props) {
|
|
|
23
23
|
}));
|
|
24
24
|
}
|
|
25
25
|
function ControlArrow(props) {
|
|
26
|
-
return /*#__PURE__*/_react.default.createElement("
|
|
27
|
-
className: "".concat(props.cls, "-arrow")
|
|
28
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
26
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
29
27
|
className: "".concat(props.cls, "-up"),
|
|
30
28
|
onMouseDown: props.onKeyup
|
|
31
29
|
}, /*#__PURE__*/_react.default.createElement(ArrowIcon, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AddListenerEventHandler } from '@autobest-ui/utils';
|
|
3
|
-
|
|
3
|
+
import { InputProps, InputValue } from '../input/Input';
|
|
4
|
+
export interface InputNumberProps extends Omit<InputProps, 'value' | 'defaultValue' | 'onChange' | 'onBlur' | 'onFocus' | 'suffix'> {
|
|
4
5
|
/**
|
|
5
6
|
* 输入框默认值,用于非受控组件,配合ref使用
|
|
6
7
|
*/
|
|
@@ -9,14 +10,6 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
9
10
|
* 输入框中的值
|
|
10
11
|
*/
|
|
11
12
|
value?: number | string;
|
|
12
|
-
/**
|
|
13
|
-
* input样式
|
|
14
|
-
*/
|
|
15
|
-
className?: string;
|
|
16
|
-
/**
|
|
17
|
-
* 输入框的别名
|
|
18
|
-
*/
|
|
19
|
-
name?: string;
|
|
20
13
|
/**
|
|
21
14
|
* 最小值
|
|
22
15
|
*/
|
|
@@ -66,8 +59,6 @@ export interface InputNumberProps extends Omit<React.InputHTMLAttributes<any>, '
|
|
|
66
59
|
interface InputNumberStates {
|
|
67
60
|
originalValueStr: string | undefined;
|
|
68
61
|
parserValue: number | undefined;
|
|
69
|
-
isEnterInput: boolean;
|
|
70
|
-
isFocusInput: boolean;
|
|
71
62
|
}
|
|
72
63
|
interface InputNumberPropsWithRef extends InputNumberProps {
|
|
73
64
|
/**
|
|
@@ -103,26 +94,17 @@ export declare class InputNumberNotRef extends React.Component<InputNumberPropsW
|
|
|
103
94
|
*/
|
|
104
95
|
setInputFocus: () => void;
|
|
105
96
|
onKeyboard: (ev: KeyboardEvent) => void;
|
|
106
|
-
onFocus: (
|
|
107
|
-
|
|
108
|
-
}) => void;
|
|
109
|
-
onBlur: (ev: {
|
|
110
|
-
target: HTMLInputElement;
|
|
111
|
-
}) => void;
|
|
97
|
+
onFocus: (originalValueStr: InputValue, name?: string) => void;
|
|
98
|
+
onBlur: (originalValueStr: InputValue, name?: string) => void;
|
|
112
99
|
/**
|
|
113
100
|
* 修改value值的回调
|
|
114
101
|
* 注:value值当不在合法时,将不再触发onChange
|
|
115
102
|
* 在输入结束后(onBlur时),触发最后一次
|
|
116
|
-
* @param ev
|
|
117
103
|
*/
|
|
118
|
-
|
|
119
|
-
target: HTMLInputElement;
|
|
120
|
-
}) => void;
|
|
104
|
+
onChange: (originalValueStr: InputValue, name?: string) => void;
|
|
121
105
|
onKeyup: (ev: React.MouseEvent) => void;
|
|
122
106
|
onKeydown: (ev: React.MouseEvent) => void;
|
|
123
|
-
onMouseEnter: () => void;
|
|
124
|
-
onMouseLeave: () => void;
|
|
125
107
|
render(): JSX.Element;
|
|
126
108
|
}
|
|
127
|
-
declare const InputNumber: React.
|
|
109
|
+
declare const InputNumber: React.ForwardRefExoticComponent<InputNumberProps & React.RefAttributes<HTMLInputElement>>;
|
|
128
110
|
export default InputNumber;
|