@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,198 @@
|
|
|
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.InputPhoneNotRef = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _components = require("@autobest-ui/components");
|
|
11
|
+
var _utils = require("@autobest-ui/utils");
|
|
12
|
+
var _Input = _interopRequireDefault(require("../input/Input"));
|
|
13
|
+
var _format = require("./format");
|
|
14
|
+
var __extends = void 0 && (void 0).__extends || function () {
|
|
15
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
16
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
17
|
+
__proto__: []
|
|
18
|
+
} instanceof Array && function (d, b) {
|
|
19
|
+
d.__proto__ = b;
|
|
20
|
+
} || function (d, b) {
|
|
21
|
+
for (var p in b) {
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return _extendStatics(d, b);
|
|
26
|
+
};
|
|
27
|
+
return function (d, b) {
|
|
28
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29
|
+
_extendStatics(d, b);
|
|
30
|
+
function __() {
|
|
31
|
+
this.constructor = d;
|
|
32
|
+
}
|
|
33
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
+
};
|
|
35
|
+
}();
|
|
36
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
37
|
+
__assign = Object.assign || function (t) {
|
|
38
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
39
|
+
s = arguments[i];
|
|
40
|
+
for (var p in s) {
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
return __assign.apply(this, arguments);
|
|
47
|
+
};
|
|
48
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var p in s) {
|
|
51
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
52
|
+
}
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
55
|
+
}
|
|
56
|
+
return t;
|
|
57
|
+
};
|
|
58
|
+
var InputPhoneNotRef = /** @class */function (_super) {
|
|
59
|
+
__extends(InputPhoneNotRef, _super);
|
|
60
|
+
function InputPhoneNotRef(props) {
|
|
61
|
+
var _this = _super.call(this, props) || this;
|
|
62
|
+
_this.prefixCls = 'ab-input-phone';
|
|
63
|
+
_this.inputRef = /*#__PURE__*/_react.default.createRef();
|
|
64
|
+
_this.setInputCursor = function (cursorPosition, timeout) {
|
|
65
|
+
if (!_this.inputRef.current) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (timeout) {
|
|
69
|
+
setTimeout(function () {
|
|
70
|
+
_this.inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
|
|
71
|
+
}, timeout);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
_this.inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
|
|
75
|
+
};
|
|
76
|
+
_this.onFocus = function (inputValue, name) {
|
|
77
|
+
var _a = _this.props,
|
|
78
|
+
onFocus = _a.onFocus,
|
|
79
|
+
format = _a.format,
|
|
80
|
+
placeholderChar = _a.placeholderChar;
|
|
81
|
+
var formatValue = inputValue;
|
|
82
|
+
if (onFocus) {
|
|
83
|
+
onFocus(formatValue, (0, _format.getNumberValue)(formatValue), name);
|
|
84
|
+
}
|
|
85
|
+
if ((0, _utils.isBlank)(inputValue)) {
|
|
86
|
+
formatValue = (0, _format.getPhoneFormat)('', format, placeholderChar);
|
|
87
|
+
_this.setState({
|
|
88
|
+
formatValue: formatValue
|
|
89
|
+
}, function () {
|
|
90
|
+
_this.setInputCursor((0, _format.getFirstCursorPosition)('', format, placeholderChar), 50);
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
_this.setInputCursor((0, _format.getFirstCursorPosition)(inputValue, format, placeholderChar), 50);
|
|
95
|
+
};
|
|
96
|
+
_this.onBlur = function (inputValue, name) {
|
|
97
|
+
if (_this.props.disabled) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
var formatValue = _this.state.formatValue;
|
|
101
|
+
var _a = _this.props,
|
|
102
|
+
format = _a.format,
|
|
103
|
+
placeholderChar = _a.placeholderChar,
|
|
104
|
+
onBlur = _a.onBlur;
|
|
105
|
+
if (formatValue === (0, _format.getPhoneFormat)('', format, placeholderChar)) {
|
|
106
|
+
_this.setState({
|
|
107
|
+
formatValue: ''
|
|
108
|
+
});
|
|
109
|
+
if (onBlur) {
|
|
110
|
+
onBlur('', '', name);
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (onBlur) {
|
|
115
|
+
onBlur(inputValue, (0, _format.getNumberValue)(inputValue), name);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
_this.onChange = function (inputValue, name) {
|
|
119
|
+
if (_this.props.disabled || !_this.inputRef.current) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
var _a = _this.props,
|
|
123
|
+
format = _a.format,
|
|
124
|
+
onChange = _a.onChange,
|
|
125
|
+
placeholderChar = _a.placeholderChar;
|
|
126
|
+
var _b = (0, _format.getUpdatedValue)({
|
|
127
|
+
value: inputValue,
|
|
128
|
+
prevValue: _this.prevFormatValue,
|
|
129
|
+
format: format,
|
|
130
|
+
selectionEnd: _this.inputRef.current.selectionEnd,
|
|
131
|
+
placeholder: placeholderChar
|
|
132
|
+
}),
|
|
133
|
+
formatValue = _b.value,
|
|
134
|
+
cursorPosition = _b.cursorPosition;
|
|
135
|
+
_this.prevFormatValue = formatValue;
|
|
136
|
+
_this.setState({
|
|
137
|
+
formatValue: formatValue
|
|
138
|
+
}, function () {
|
|
139
|
+
_this.setInputCursor(cursorPosition);
|
|
140
|
+
});
|
|
141
|
+
if (onChange) {
|
|
142
|
+
onChange(formatValue, (0, _format.getNumberValue)(formatValue), name);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var defaultValue = props.defaultValue,
|
|
146
|
+
format = props.format,
|
|
147
|
+
placeholderChar = props.placeholderChar;
|
|
148
|
+
_this.prevFormatValue = (0, _format.getPhoneFormat)(defaultValue, format, placeholderChar);
|
|
149
|
+
_this.state = {
|
|
150
|
+
formatValue: (0, _utils.isBlank)(defaultValue) ? '' : _this.prevFormatValue
|
|
151
|
+
};
|
|
152
|
+
return _this;
|
|
153
|
+
}
|
|
154
|
+
InputPhoneNotRef.getDerivedStateFromProps = function (nextProps, prevState) {
|
|
155
|
+
if ('value' in nextProps) {
|
|
156
|
+
if (nextProps.value !== prevState.formatValue && (
|
|
157
|
+
// 兼容外部传入空string/null的情况, 只有当一个值非空时,才会重新重置State信息
|
|
158
|
+
!(0, _utils.isBlank)(nextProps.value) || !(0, _utils.isBlank)(prevState.formatValue))) {
|
|
159
|
+
return {
|
|
160
|
+
formatValue: (0, _format.getPhoneFormat)(nextProps.value, nextProps.format, nextProps.placeholderChar)
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
};
|
|
166
|
+
InputPhoneNotRef.prototype.render = function () {
|
|
167
|
+
var cls = this.prefixCls;
|
|
168
|
+
var _a = this.props,
|
|
169
|
+
upperRef = _a.upperRef,
|
|
170
|
+
className = _a.className,
|
|
171
|
+
format = _a.format,
|
|
172
|
+
resetProps = __rest(_a, ["upperRef", "className", "format"]);
|
|
173
|
+
var formatValue = this.state.formatValue;
|
|
174
|
+
return /*#__PURE__*/_react.default.createElement(_Input.default, __assign({
|
|
175
|
+
ref: (0, _components.composeRef)(this.inputRef, upperRef),
|
|
176
|
+
className: (0, _classnames.default)(cls, className)
|
|
177
|
+
}, resetProps, {
|
|
178
|
+
value: formatValue,
|
|
179
|
+
onChange: this.onChange,
|
|
180
|
+
onBlur: this.onBlur,
|
|
181
|
+
onFocus: this.onFocus
|
|
182
|
+
}));
|
|
183
|
+
};
|
|
184
|
+
InputPhoneNotRef.defaultProps = {
|
|
185
|
+
defaultValue: '',
|
|
186
|
+
format: '(111)111-1111',
|
|
187
|
+
placeholderChar: '_'
|
|
188
|
+
};
|
|
189
|
+
return InputPhoneNotRef;
|
|
190
|
+
}(_react.default.Component);
|
|
191
|
+
exports.InputPhoneNotRef = InputPhoneNotRef;
|
|
192
|
+
var InputPhone = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
193
|
+
return /*#__PURE__*/_react.default.createElement(InputPhoneNotRef, __assign({}, props, {
|
|
194
|
+
upperRef: ref
|
|
195
|
+
}));
|
|
196
|
+
});
|
|
197
|
+
var _default = InputPhone;
|
|
198
|
+
exports.default = _default;
|
|
@@ -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/lib/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/lib/modal/index.js
CHANGED
|
@@ -265,11 +265,11 @@ var Modal = /** @class */function (_super) {
|
|
|
265
265
|
Modal.prototype.clearOutsideHandler = function () {
|
|
266
266
|
this.clearPopupTimer();
|
|
267
267
|
if (this.clickOutsideHandler) {
|
|
268
|
-
this.clickOutsideHandler
|
|
268
|
+
this.clickOutsideHandler();
|
|
269
269
|
this.clickOutsideHandler = null;
|
|
270
270
|
}
|
|
271
271
|
if (this.touchOutsideHandler) {
|
|
272
|
-
this.touchOutsideHandler
|
|
272
|
+
this.touchOutsideHandler();
|
|
273
273
|
this.touchOutsideHandler = null;
|
|
274
274
|
}
|
|
275
275
|
};
|
package/lib/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/lib/move/index.js
CHANGED
|
@@ -320,26 +320,26 @@ var Move = /** @class */function (_super) {
|
|
|
320
320
|
Move.prototype.componentWillUnmount = function () {
|
|
321
321
|
clearTimeout(this.updateTimer);
|
|
322
322
|
if (this.startHandler) {
|
|
323
|
-
this.startHandler
|
|
323
|
+
this.startHandler();
|
|
324
324
|
this.startHandler = null;
|
|
325
325
|
}
|
|
326
326
|
if (this.mousewheelHandler) {
|
|
327
|
-
this.mousewheelHandler
|
|
327
|
+
this.mousewheelHandler();
|
|
328
328
|
this.mousewheelHandler = null;
|
|
329
329
|
}
|
|
330
330
|
if (this.resizeHandler) {
|
|
331
|
-
this.resizeHandler
|
|
331
|
+
this.resizeHandler();
|
|
332
332
|
this.resizeHandler = null;
|
|
333
333
|
}
|
|
334
334
|
this.clearHandler();
|
|
335
335
|
};
|
|
336
336
|
Move.prototype.clearHandler = function () {
|
|
337
337
|
if (this.moveHandler) {
|
|
338
|
-
this.moveHandler
|
|
338
|
+
this.moveHandler();
|
|
339
339
|
this.moveHandler = null;
|
|
340
340
|
}
|
|
341
341
|
if (this.endHandler) {
|
|
342
|
-
this.endHandler
|
|
342
|
+
this.endHandler();
|
|
343
343
|
this.endHandler = null;
|
|
344
344
|
}
|
|
345
345
|
};
|
package/lib/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/lib/popover/index.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _utils = require("@autobest-ui/utils");
|
|
10
11
|
var _trigger = _interopRequireDefault(require("../trigger"));
|
|
11
12
|
var __assign = void 0 && (void 0).__assign || function () {
|
|
12
13
|
__assign = Object.assign || function (t) {
|
|
@@ -40,7 +41,8 @@ function Popover(_a) {
|
|
|
40
41
|
hiddenClose = _a.hiddenClose,
|
|
41
42
|
tip = _a.tip,
|
|
42
43
|
closeIcon = _a.closeIcon,
|
|
43
|
-
|
|
44
|
+
maxHeight = _a.maxHeight,
|
|
45
|
+
extraProps = __rest(_a, ["theme", "innerClassName", "closeClassName", "arrowClassName", "hiddenClose", "tip", "closeIcon", "maxHeight"]);
|
|
44
46
|
var triggerEl = _react.default.useRef(null);
|
|
45
47
|
var _c = _react.default.useState({}),
|
|
46
48
|
arrowStyle = _c[0],
|
|
@@ -78,7 +80,10 @@ function Popover(_a) {
|
|
|
78
80
|
className: (0, _classnames.default)("".concat(cls, "-arrow"), arrowClassName),
|
|
79
81
|
style: arrowStyle
|
|
80
82
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
81
|
-
className: innerClass
|
|
83
|
+
className: innerClass,
|
|
84
|
+
style: !(0, _utils.isBlank)(maxHeight) ? {
|
|
85
|
+
maxHeight: "".concat(maxHeight, "px")
|
|
86
|
+
} : undefined
|
|
82
87
|
}, tip));
|
|
83
88
|
}
|
|
84
89
|
return /*#__PURE__*/_react.default.createElement(_trigger.default, __assign({}, extraProps, {
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _utils = require("@autobest-ui/utils");
|
|
12
|
+
var _context = _interopRequireDefault(require("./context"));
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
var __assign = void 0 && (void 0).__assign || function () {
|
|
16
|
+
__assign = Object.assign || function (t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) {
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
var cls = 'ab-radio';
|
|
28
|
+
var Radio = function Radio(props) {
|
|
29
|
+
var _a;
|
|
30
|
+
var _b = props.checked,
|
|
31
|
+
propsChecked = _b === void 0 ? false : _b,
|
|
32
|
+
name = props.name,
|
|
33
|
+
onChange = props.onChange,
|
|
34
|
+
children = props.children,
|
|
35
|
+
disabled = props.disabled,
|
|
36
|
+
value = props.value,
|
|
37
|
+
className = props.className;
|
|
38
|
+
var _c = (0, _react.useState)(propsChecked),
|
|
39
|
+
checked = _c[0],
|
|
40
|
+
setChecked = _c[1];
|
|
41
|
+
var groupContext = (0, _react.useContext)(_context.default);
|
|
42
|
+
var mergedProps = (0, _utils.isEmptyObject)(groupContext) ? {
|
|
43
|
+
name: name,
|
|
44
|
+
disabled: disabled
|
|
45
|
+
} : {
|
|
46
|
+
name: groupContext.name,
|
|
47
|
+
disabled: 'disabled' in props ? disabled : groupContext.disabled
|
|
48
|
+
};
|
|
49
|
+
if ('checked' in props && propsChecked !== checked) {
|
|
50
|
+
setChecked(propsChecked);
|
|
51
|
+
}
|
|
52
|
+
(0, _react.useEffect)(function () {
|
|
53
|
+
// radioGroup
|
|
54
|
+
if ('value' in groupContext) {
|
|
55
|
+
setChecked(groupContext.value === value);
|
|
56
|
+
}
|
|
57
|
+
}, [groupContext, value]);
|
|
58
|
+
var onRadioChange = function onRadioChange(e) {
|
|
59
|
+
if (mergedProps.disabled) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (onChange) {
|
|
63
|
+
onChange(e, mergedProps.name);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// radioGroup
|
|
67
|
+
if (groupContext.onChange) {
|
|
68
|
+
groupContext.onChange(e.target.value, mergedProps.name);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
setChecked(!checked);
|
|
72
|
+
};
|
|
73
|
+
var onClick = function onClick(e) {
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
};
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement("label", {
|
|
77
|
+
onClick: onClick,
|
|
78
|
+
className: (0, _classnames.default)(cls, (_a = {}, _a["".concat(cls, "-disabled")] = mergedProps.disabled, _a["".concat(cls, "-checked")] = checked, _a), groupContext.className, className)
|
|
79
|
+
}, /*#__PURE__*/_react.default.createElement("input", __assign({
|
|
80
|
+
type: "radio",
|
|
81
|
+
checked: checked,
|
|
82
|
+
value: value,
|
|
83
|
+
onChange: onRadioChange
|
|
84
|
+
}, mergedProps)), /*#__PURE__*/_react.default.createElement("span", {
|
|
85
|
+
className: "".concat(cls, "-control")
|
|
86
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
87
|
+
className: "".concat(cls, "-child")
|
|
88
|
+
}, children));
|
|
89
|
+
};
|
|
90
|
+
var _default = Radio;
|
|
91
|
+
exports.default = _default;
|
|
@@ -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,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _utils = require("@autobest-ui/utils");
|
|
11
|
+
var _context = require("./context");
|
|
12
|
+
var _Radio = _interopRequireDefault(require("./Radio"));
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
var __extends = void 0 && (void 0).__extends || function () {
|
|
16
|
+
var _extendStatics = function extendStatics(d, b) {
|
|
17
|
+
_extendStatics = Object.setPrototypeOf || {
|
|
18
|
+
__proto__: []
|
|
19
|
+
} instanceof Array && function (d, b) {
|
|
20
|
+
d.__proto__ = b;
|
|
21
|
+
} || function (d, b) {
|
|
22
|
+
for (var p in b) {
|
|
23
|
+
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return _extendStatics(d, b);
|
|
27
|
+
};
|
|
28
|
+
return function (d, b) {
|
|
29
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
30
|
+
_extendStatics(d, b);
|
|
31
|
+
function __() {
|
|
32
|
+
this.constructor = d;
|
|
33
|
+
}
|
|
34
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
35
|
+
};
|
|
36
|
+
}();
|
|
37
|
+
var cls = 'ab-radio';
|
|
38
|
+
function getRadioProp(radioProp, radioGroupProp) {
|
|
39
|
+
return (0, _utils.isUndef)(radioProp) ? radioGroupProp : radioProp;
|
|
40
|
+
}
|
|
41
|
+
var RadioGroup = /** @class */function (_super) {
|
|
42
|
+
__extends(RadioGroup, _super);
|
|
43
|
+
function RadioGroup(props) {
|
|
44
|
+
var _this = _super.call(this, props) || this;
|
|
45
|
+
_this.onRadioChange = function (v, n) {
|
|
46
|
+
var onChange = _this.props.onChange;
|
|
47
|
+
if (onChange) {
|
|
48
|
+
onChange(v, n);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
_this.setState({
|
|
52
|
+
value: v
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
_this.renderRadioGroup = function () {
|
|
56
|
+
var _a = _this.props,
|
|
57
|
+
name = _a.name,
|
|
58
|
+
children = _a.children,
|
|
59
|
+
disabled = _a.disabled;
|
|
60
|
+
var value = _this.state.value;
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement(_context.RadioGroupContextProvider, {
|
|
62
|
+
value: {
|
|
63
|
+
name: name,
|
|
64
|
+
value: value,
|
|
65
|
+
disabled: disabled,
|
|
66
|
+
onChange: _this.onRadioChange,
|
|
67
|
+
className: "".concat(cls, "-item")
|
|
68
|
+
}
|
|
69
|
+
}, children);
|
|
70
|
+
};
|
|
71
|
+
_this.renderRadioList = function () {
|
|
72
|
+
var _a = _this.props,
|
|
73
|
+
name = _a.name,
|
|
74
|
+
options = _a.options,
|
|
75
|
+
disabled = _a.disabled;
|
|
76
|
+
var value = _this.state.value;
|
|
77
|
+
if ((0, _utils.isEmptyArray)(options)) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, options.map(function (item) {
|
|
81
|
+
return /*#__PURE__*/_react.default.createElement(_Radio.default, {
|
|
82
|
+
key: item.value,
|
|
83
|
+
className: "".concat(cls, "-item"),
|
|
84
|
+
name: name,
|
|
85
|
+
value: item.value,
|
|
86
|
+
disabled: getRadioProp(item.disabled, disabled),
|
|
87
|
+
checked: value === item.value,
|
|
88
|
+
onChange: function onChange(e, n) {
|
|
89
|
+
return _this.onRadioChange(e.target.value, n);
|
|
90
|
+
}
|
|
91
|
+
}, item.name);
|
|
92
|
+
}));
|
|
93
|
+
};
|
|
94
|
+
_this.state = {
|
|
95
|
+
value: props.defaultValue
|
|
96
|
+
};
|
|
97
|
+
return _this;
|
|
98
|
+
}
|
|
99
|
+
RadioGroup.getDerivedStateFromProps = function (nextProps, prevState) {
|
|
100
|
+
if ('value' in nextProps && nextProps.value !== prevState.value) {
|
|
101
|
+
return {
|
|
102
|
+
value: nextProps.value
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
};
|
|
107
|
+
RadioGroup.prototype.render = function () {
|
|
108
|
+
var _a = this.props.direction,
|
|
109
|
+
direction = _a === void 0 ? 'horizontal' : _a;
|
|
110
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
111
|
+
className: "".concat(cls, "-group-").concat(direction)
|
|
112
|
+
}, 'options' in this.props ? this.renderRadioList() : this.renderRadioGroup());
|
|
113
|
+
};
|
|
114
|
+
return RadioGroup;
|
|
115
|
+
}(_react.Component);
|
|
116
|
+
var _default = RadioGroup;
|
|
117
|
+
exports.default = _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.RadioGroupContextProvider = void 0;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
var RadioGroupContext = /*#__PURE__*/React.createContext({});
|
|
12
|
+
var RadioGroupContextProvider = RadioGroupContext.Provider;
|
|
13
|
+
exports.RadioGroupContextProvider = RadioGroupContextProvider;
|
|
14
|
+
var _default = RadioGroupContext;
|
|
15
|
+
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, "Radio", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _Radio.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "RadioGroup", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _RadioGroup.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _Radio = _interopRequireDefault(require("./Radio"));
|
|
20
|
+
var _RadioGroup = _interopRequireDefault(require("./RadioGroup"));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ChangeEvent } from 'react';
|
|
2
|
+
export declare type RadioValue = string | number;
|
|
3
|
+
export interface RadioProps {
|
|
4
|
+
name?: string;
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
value?: RadioValue;
|
|
8
|
+
onChange?: (e: ChangeEvent<HTMLInputElement>, name: string) => void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare type RadioOptionItem = Pick<RadioProps, 'disabled' | 'name' | 'value'>;
|
|
12
|
+
export interface RadioGroupProps extends Pick<RadioProps, 'value' | 'name' | 'disabled' | 'className'> {
|
|
13
|
+
options?: RadioOptionItem[];
|
|
14
|
+
defaultValue?: RadioValue;
|
|
15
|
+
onChange?: (value: RadioValue, name: string) => void;
|
|
16
|
+
direction?: 'vertical' | 'horizontal';
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ab-radio{position:relative;overflow:hidden;display:inline-flex;align-items:center;cursor:pointer}.ab-radio input{width:1px;height:1px;margin:-1px;position:absolute}.ab-radio-checked .ab-radio-control{border-color:#0075ff}.ab-radio-checked .ab-radio-control::before{background-color:#0075ff}.ab-radio-checked .ab-radio-control:hover{border-color:#005cc8}.ab-radio-checked .ab-radio-control:hover::before{background-color:#005cc8}.ab-radio-disabled{cursor:not-allowed}.ab-radio-disabled .ab-radio-control{border-color:#d1d1d1;background-color:#f8f8f8}.ab-radio-disabled .ab-radio-control:hover{border-color:#d1d1d1}.ab-radio-disabled.ab-radio-checked .ab-radio-control::before{background-color:#d1d1d1}.ab-radio-control{width:.14rem;height:.14rem;border:1px solid #767676;border-radius:50%;margin-right:.06rem;position:relative;display:flex;align-items:center;justify-content:center}.ab-radio-control::before{content:"";width:.08rem;height:.08rem;border-radius:50%;background-color:transparent}.ab-radio-control:hover{border-color:#4f4f4f}.ab-radio-group-horizontal{display:flex}.ab-radio-group-horizontal .ab-radio-item{margin-right:.2rem}.ab-radio-group-horizontal .ab-radio-item:last-child{margin-right:0}.ab-radio-group-vertical{display:flex;flex-direction:column}.ab-radio-group-vertical .ab-radio-item{margin-bottom:.15rem}.ab-radio-group-vertical .ab-radio-item:last-child{margin-bottom:0}
|
package/lib/select/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AddListenerEventRemoveHandler } from '@autobest-ui/utils';
|
|
3
3
|
import { TriggerProps } from '../trigger';
|
|
4
4
|
declare type Value = string | number | null;
|
|
5
5
|
declare type NameValue = React.ReactChild | null;
|
|
@@ -97,7 +97,7 @@ interface SelectStates {
|
|
|
97
97
|
}
|
|
98
98
|
declare class Select extends React.Component<SelectProps, SelectStates> {
|
|
99
99
|
prefixCls: string;
|
|
100
|
-
keydownHandler:
|
|
100
|
+
keydownHandler: AddListenerEventRemoveHandler;
|
|
101
101
|
popupContentRef: React.RefObject<HTMLDivElement>;
|
|
102
102
|
static defaultProps: {
|
|
103
103
|
title: any;
|